Skip to content

fix(temporal): fingerprint CI maintenance inputs without main's whole tree - #5450

Merged
shepherdjerred merged 1 commit into
mainfrom
fix/ci-maintenance-subtree-fingerprints
Nov 28, 2026
Merged

shepherdjerred merged 1 commit into
mainfrom
fix/ci-maintenance-subtree-fingerprints

Conversation

@shepherdjerred

@shepherdjerred shepherdjerred commented Nov 28, 2026 •

Copy link
Copy Markdown
Owner

Why

Since 2026-11-28T03:45Z every ci-maintenance-coordinator tick has failed in inspectCiMaintenance. maintenanceCandidates asked GitHub for main's whole recursive tree. Main now has about 54.9k entries, so GitHub truncates the response and the activity throws GitHub source tree was truncated. Until this is fixed, no golden workspace, ci-images or workspace-seed refresh can be selected (FM-372).

What

  • New sourceTreeEntries (ci-maintenance-source-tree.ts) reads only the entries at and under the fingerprint inputs. It never asks for the whole recursive tree:
    • it lists each distinct ancestor directory once, non-recursively and level by level from the commit's root, sharing each in-flight listing between inputs;
    • it fetches each directory input's own subtree recursively;
    • it rebuilds repo-relative paths, keeping the same path, mode, type and sha the whole-tree call returned.
  • Call count: one request per distinct ancestor directory (the root included), plus one per directory input. For today's image and golden inputs that is 5 getTree calls per tick: the root, ci, ci/ci-image and ci/ci-playwright listings, plus the recursive patches subtree. They run in three sequential rounds, well inside the 2-minute activity timeout.
  • Truncation: any truncated listing or subtree fails loudly with its path, for example GitHub source tree patches at <sha> was truncated. There is no fallback to a partial tree.
  • Missing inputs: a missing input behaves as before. It is absent from the entries, as it was from the whole tree, so the fingerprint still throws Missing <label> <path>.
  • maintenanceCandidates reads the union of IMAGE_INPUTS and GOLDEN_INPUTS. Fingerprint functions and workflow code are unchanged.

Demo

Before. The production failure, read-only from temporal workflow show --workflow-id ci-maintenance-coordinator:

run 8ee56942-61a1-45b7-8de6-ac1e4a311386 (RUNNING since 2026-11-28T12:05:50Z)
failed inspectCiMaintenance attempts: 63, from 2026-11-28T12:06:26Z to 17:17:29Z
Error: GitHub source tree was truncated
    at maintenanceCandidates (/app/packages/temporal/src/activities/maintenance/ci-maintenance-client.ts:274:38)
    at async inspectCiMaintenance (/app/packages/temporal/src/activities/maintenance/ci-maintenance.ts:70:25)

The new test file run against the old ci-maintenance-client.ts reproduces it: 3 of 5 tests fail, including inputs still fingerprint when GitHub truncates the whole recursive tree with Error: GitHub source tree was truncated.

After. The fingerprint-equality tests. A real Octokit runs against a fake GitHub trees API. The old whole-tree path and maintenanceCandidates use the same content-addressed objects.

 ✓ ci-maintenance-source-tree.test.ts > subtree reads fingerprint a commit exactly as its whole recursive tree did
 ✓ ci-maintenance-source-tree.test.ts > subtree entries are the whole tree's entries at and under each input
 ✓ ci-maintenance-source-tree.test.ts > inputs still fingerprint when GitHub truncates the whole recursive tree
 ✓ ci-maintenance-source-tree.test.ts > a truncated input subtree fails with its path
 ✓ ci-maintenance-source-tree.test.ts > a missing input fails as it did against the whole tree

Live, read-only, main 33b799c3. The old fingerprint comes from the full local git ls-tree -r -t, which is what an untruncated recursive call would return. The new fingerprint comes from sourceTreeEntries against the real GitHub API:

git ls-tree -r -t entries: 54889; GitHub recursive getTree: truncated=true, 54113 entries returned
subtree requests (5):
  GET git/trees/33b799c3fed050c324c2b7071e3d3b4787e677f4                  (root)
  GET git/trees/6eb1f8d68074fc8b2034fd87120aa261bf8e4b1a                  (ci)
  GET git/trees/8e2df27cbf49f739c9810dd4329984b079b82f17?recursive=1      (patches)
  GET git/trees/9d72d22ba6da5c8ac9b0a021837594fd7edbac3b                  (ci/ci-image)
  GET git/trees/fb9bde7fa76f7ef2243d750d79a06976b52ec50a                  (ci/ci-playwright)
fingerprint whole tree (git ls-tree) subtree reads (GitHub) equal
ci-images 6998bcaf0197c381 6998bcaf0197c381 yes
workspace-golden b2ae7787c839fcce b2ae7787c839fcce yes

Verification

  • bunx vitest run src/activities/maintenance (temporal): 30 files, 319 tests pass, including the 5 new ci-maintenance-source-tree.test.ts tests.
    • Mutation checks: the old ci-maintenance-client.ts fails 3 of 5 new tests (the truncated whole tree throws GitHub source tree was truncated), and dropping the path prefix fails 4 of 5.
  • bunx turbo run build typecheck test lint --filter=@shepherdjerred/temporal:
    • build, typecheck and lint pass;
    • test passes every maintenance file. Its 28 failures, in 11 files, are 10 CI-excluded *.integration.test.ts suites (Temporal test server and real-git, 60 to 90 s timeouts under host load) plus git-backup.test.ts 5 s timeouts. git-backup.test.ts passes when run alone, and none of these files import maintenance code (see AI-1133).
  • bunx turbo run jscpd quality-ratchet knip --filter=//: passes, knip included. The feat(scout-for-lol): add the Live games list and the Live game lobby to the app #5419 knip failure did not reproduce on this base.
  • bunx lefthook run pre-commit on 683effaaaa, all hooks including jscpd, directory-file-counts and package-quality: passes.
  • Extended tier: bun run verify:extended -- --filter='...[origin/main...HEAD]' passes on 35db2ae566, the identical diff over b8dc31835c before the restack onto 683effaaaa: 37/37 tasks in 44m53s. Temporal extended vitest has 45 files and 152 tests; the extended workflow tests have 89 files and 460 tests.
  • Live and read-only: temporal workflow show confirms the failure above. The live fingerprint comparison against main 33b799c3 is in Demo.
  • Not verified yet: the deployed worker and the first successful production coordinator tick. The worker picks this up only after main publishes and Delivery deploys temporal.

🤖 Generated with Claude Code

@shepherdjerred

Copy link
Copy Markdown
Owner Author

This change is part of the following stack:

Change managed by git-spice.

@greptile-apps

greptile-apps Bot commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Automatic reviews are disabled for this repository. Configure in Code Review Settings.

@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@shepherdjerred
shepherdjerred marked this pull request as ready for review November 28, 2026 19:00
@shepherdjerred

Copy link
Copy Markdown
Owner Author

@codex review

Automated re-review request for 35db2ae from the CI review gate.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-28T19:03:00.075302Z 35db2ae Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 35db2ae566

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

… tree

Why
Since 2026-11-28T03:45Z every ci-maintenance-coordinator tick has failed in
inspectCiMaintenance with "GitHub source tree was truncated". Main now has
about 54.9k tree entries, and GitHub truncates a recursive getTree of the
whole commit (54,113 entries returned for 33b799c). So no golden workspace,
ci-images or workspace-seed refresh can be selected.

What
- New sourceTreeEntries reads only the entries at and under the fingerprint
  inputs. It lists each distinct ancestor directory once, non-recursively and
  level by level from the commit's root, then fetches each directory input's
  subtree recursively. Paths are rebuilt to the repo-relative form the
  whole-tree call returned, with the same mode, type and sha.
- A truncated listing or subtree fails with its path. An input that does not
  exist is absent, as it was from the whole tree, so the fingerprint still
  throws "Missing <label> <path>".
- maintenanceCandidates reads the union of the image and golden inputs. That
  is five getTree calls per tick: the root, ci, ci/ci-image and
  ci/ci-playwright listings, and the recursive patches subtree. It never asks
  for the whole recursive tree. Workflow code is unchanged.

Verification
- A new ci-maintenance-source-tree.test.ts runs a real Octokit against a fake
  GitHub trees API. Both the old whole-tree path and maintenanceCandidates
  produce identical ci-images and workspace-golden fingerprints. The test
  asserts the exact five requests, and that the subtree entries deep-equal the
  whole tree filtered to the inputs. It also covers a truncated whole tree
  (old code: "GitHub source tree was truncated"; new code: same
  fingerprints), a truncated patches subtree failing with its path, and a
  missing input failing exactly as before.
- Live, read-only, against main 33b799c: fingerprints from the full
  `git ls-tree -r -t` (54,889 entries) equal the subtree reads from GitHub
  for both kinds, in 5 requests.
- bunx turbo run build typecheck test lint --filter=@shepherdjerred/temporal:
  build, typecheck and lint pass. test passes for every maintenance file;
  its 28 failures are all CI-excluded *.integration.test.ts suites or
  git-backup 5 s timeouts under host load (git-backup passes alone).
- bunx turbo run jscpd quality-ratchet knip --filter=// passes, and so does
  the full lefthook pre-commit (jscpd, package-quality typecheck and lint) on
  this base.
- bun run verify:extended -- --filter='...[origin/main...HEAD]' passed
  37/37 tasks on the identical diff over b8dc318.
- Not run: no production tick after deploy yet. The worker picks this up only
  after main publishes and Delivery deploys temporal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@shepherdjerred
shepherdjerred force-pushed the fix/ci-maintenance-subtree-fingerprints branch from 35db2ae to 279877f Compare November 28, 2026 19:23
@shepherdjerred
shepherdjerred merged commit 3642e02 into main Nov 28, 2026
6 checks passed
@shepherdjerred
shepherdjerred deleted the fix/ci-maintenance-subtree-fingerprints branch November 28, 2026 22:46
shepherdjerred added a commit that referenced this pull request Dec 3, 2026
…cted

Why

CiMaintenanceCoordinatorStalled skipped any memo without `inspectedAt`, and
only a successful inspection writes that field. Production's
ci-maintenance-coordinator has failed every inspectCiMaintenance since
2026-11-28T03:45Z ("GitHub source tree was truncated", fixed separately in
#5450). It has never completed one on the code that dates inspections, so
its memo has no `inspectedAt` and the alert could never fire. Health
publishing itself runs: Alertmanager shows only CiMaintenanceStreamBlocked.

What

- Behind the `ci-maintenance-inspection-tracking-v1` patch, the first tick
  without the field records `inspectionTrackedSince` (workflow time) and
  writes it to the memo before scheduling the inspection. An inspection that
  fails, or never finishes because no poller or slot takes it, still leaves
  the field durable. Continue-as-new keeps it.
- CiMaintenanceCoordinatorStalled now judges a memo without `inspectedAt`
  from `inspectionTrackedSince`, with the same 30-minute bound and confirming
  read. Once an inspection succeeds, `inspectedAt` takes over. Only a memo
  with neither field, written before tracking, stays exempt.
- The health memo schema reads the new field, and the README documents it.
- A frozen fixture of the deployed coordinator, with its shared state logic
  copied verbatim, records histories that the new code replays in three
  upgrade tests. They cover both marker orders and a first tracked tick
  whose inspection never finishes. The jscpd baseline records the fixture's
  deliberate duplication.

The field could not be written from an activity. When an inspection fails or
hangs, only workflow code can still write the memo. The memo is workflow
state, and the health activity only reads it, so it keeps paging while the
coordinator is wedged. Core does not compare memo payloads on replay, so an
ungated write would also replay cleanly. But replaying an existing run would
then backdate the field to that run's first recorded tick, and the replayed
state would differ from the recorded memo. The patch starts tracking at a
point recorded in history and leaves pre-patch histories unchanged. The
early memo write adds commands only inside the patched branch.

Verification

- Live, read-only: describe and show of prod ci-maintenance-coordinator run
  8ee56942. The memo has no inspectedAt. All 96 inspectCiMaintenance
  attempts failed with "GitHub source tree was truncated", and the run has
  no patch markers. Previous run 13aacb6e: all 100 attempts failed.
- vitest for the alert, health and shared state tests: 49 passed. With the
  old exemption restored, the new never-inspected alert and health cases
  fail.
- test:workflows src/workflows/ci: 6 files, 36 tests passed. bundle.test.ts
  also passed. Histories recorded by the fixture and then by the new code
  replay cleanly. Without the early memo write, the hung-inspection test
  fails.
- typecheck and lint for @shepherdjerred/temporal, run directly in the
  package: pass.
- bunx turbo run jscpd quality-ratchet knip --filter=//: pass.
- bunx turbo run test:extended --filter='...[origin/main...HEAD]'
  --continue (temporal only) passed on the previous revision of this
  change: integration 45 files and 152 tests, workflows 89 files and 462
  tests. Since then only CI-maintenance workflow code and its tests changed,
  and those were rerun above.
- Not run (freeze FM-385): Woodpecker CI, deployment, and the live alert
  firing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
shepherdjerred added a commit that referenced this pull request Dec 3, 2026
…cted (#5489)

Why

CiMaintenanceCoordinatorStalled skipped any memo without `inspectedAt`, and
only a successful inspection writes that field. Production's
ci-maintenance-coordinator has failed every inspectCiMaintenance since
2026-11-28T03:45Z ("GitHub source tree was truncated", fixed separately in
#5450). It has never completed one on the code that dates inspections, so
its memo has no `inspectedAt` and the alert could never fire. Health
publishing itself runs: Alertmanager shows only CiMaintenanceStreamBlocked.

What

- Behind the `ci-maintenance-inspection-tracking-v1` patch, the first tick
  without the field records `inspectionTrackedSince` (workflow time) and
  writes it to the memo before scheduling the inspection. An inspection that
  fails, or never finishes because no poller or slot takes it, still leaves
  the field durable. Continue-as-new keeps it.
- CiMaintenanceCoordinatorStalled now judges a memo without `inspectedAt`
  from `inspectionTrackedSince`, with the same 30-minute bound and confirming
  read. Once an inspection succeeds, `inspectedAt` takes over. Only a memo
  with neither field, written before tracking, stays exempt.
- The health memo schema reads the new field, and the README documents it.
- A frozen fixture of the deployed coordinator, with its shared state logic
  copied verbatim, records histories that the new code replays in three
  upgrade tests. They cover both marker orders and a first tracked tick
  whose inspection never finishes. The jscpd baseline records the fixture's
  deliberate duplication.

The field could not be written from an activity. When an inspection fails or
hangs, only workflow code can still write the memo. The memo is workflow
state, and the health activity only reads it, so it keeps paging while the
coordinator is wedged. Core does not compare memo payloads on replay, so an
ungated write would also replay cleanly. But replaying an existing run would
then backdate the field to that run's first recorded tick, and the replayed
state would differ from the recorded memo. The patch starts tracking at a
point recorded in history and leaves pre-patch histories unchanged. The
early memo write adds commands only inside the patched branch.

Verification

- Live, read-only: describe and show of prod ci-maintenance-coordinator run
  8ee56942. The memo has no inspectedAt. All 96 inspectCiMaintenance
  attempts failed with "GitHub source tree was truncated", and the run has
  no patch markers. Previous run 13aacb6e: all 100 attempts failed.
- vitest for the alert, health and shared state tests: 49 passed. With the
  old exemption restored, the new never-inspected alert and health cases
  fail.
- test:workflows src/workflows/ci: 6 files, 36 tests passed. bundle.test.ts
  also passed. Histories recorded by the fixture and then by the new code
  replay cleanly. Without the early memo write, the hung-inspection test
  fails.
- typecheck and lint for @shepherdjerred/temporal, run directly in the
  package: pass.
- bunx turbo run jscpd quality-ratchet knip --filter=//: pass.
- bunx turbo run test:extended --filter='...[origin/main...HEAD]'
  --continue (temporal only) passed on the previous revision of this
  change: integration 45 files and 152 tests, workflows 89 files and 462
  tests. Since then only CI-maintenance workflow code and its tests changed,
  and those were rerun above.
- Not run (freeze FM-385): Woodpecker CI, deployment, and the live alert
  firing.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant