Skip to content

fix(temporal): page for a CI maintenance coordinator that never inspected - #5489

Merged
shepherdjerred merged 1 commit into
mainfrom
fix/ci-maintenance-never-inspected-alert
Dec 3, 2026
Merged

shepherdjerred merged 1 commit into
mainfrom
fix/ci-maintenance-never-inspected-alert

Conversation

@shepherdjerred

@shepherdjerred shepherdjerred commented Nov 28, 2026 •

Copy link
Copy Markdown
Owner

Why

CiMaintenanceCoordinatorStalled (from #5345) 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"; #5450 fixes that). It has never completed an inspection on the code that dates inspections, so its memo has no inspectedAt and the alert could never fire. Health publishing itself still runs: Alertmanager shows only CiMaintenanceStreamBlocked (release-notes).

What

  • Coordinator (workflows/ci/maintenance.ts): behind the new ci-maintenance-inspection-tracking-v1 patch, the first tick without the field records inspectionTrackedSince (workflow time). It writes the field to the memo before scheduling the inspection, so it is durable even when the inspection fails, or never finishes because no poller or repo-automation slot takes it. Continue-as-new keeps it.
  • Alert (shared/alerts/ci-maintenance-alert.ts): a memo without inspectedAt is now judged from inspectionTrackedSince, with the same 30-minute bound and the health activity's confirming read a minute later. Once an inspection succeeds, inspectedAt takes over. Only a memo with neither field, written before tracking, stays exempt. The summary and description say "has not completed an inspection since it began tracking them at ..." for this case.
  • Health memo schema reads the new field. The README documents it.
  • Replay fixture workflows/ci/fixtures/ci-maintenance-before-inspection-tracking.ts freezes the deployed coordinator (bounded stalls and health, no tracking). Its shared state logic is copied verbatim, not imported, so later shared changes cannot alter what it records. Three upgrade tests record a history with it, swap in the new code and replay the whole history. They cover both marker orders and a first tracked tick whose inspection never finishes. .jscpd-baseline.json records the fixture's deliberate duplication; every changed pair involves the fixture.

Why a patch, not activity or shared code

When an inspection fails or hangs, only workflow code can still write the memo. The memo is workflow state, so no activity can write it. The health activity only reads the memo, which is what lets it page while the coordinator is wedged. Core does not compare memo or continue-as-new payloads on replay: a probe with the write ungated replayed cleanly. Ungated, though, replaying an existing run would 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. Its cost is one marker per run, plus one memo upsert when tracking starts.

Demo

Live mechanism (prod, read-only). toolkit temporal --namespace prod workflow describe --workflow-id ci-maintenance-coordinator, run 8ee56942, build 986a0d6b (contains #5345):

{"blocked":{"release-notes":{"reason":"Pipeline 14708 ended failure; inspect before retrying","requestId":"68644c4f-93d1-4fb1-96cd-60fd7205b988"}},"completed":{...},"goldenSnapshot":null,"lastKind":"workspace-golden","observation":"Maintenance inspection failed; no new submission","pending":null}

There is no inspectedAt. History shows 96/96 inspectCiMaintenance attempts failed with GitHub source tree was truncated and no patch markers, because the bounded patch is only evaluated after a successful inspection. The previous run, 13aacb6e, failed all 100 attempts.

Before and after for that memo. The live memo was evaluated with main's alert builder and memo parser, then with this branch's. Assume this code's first tick lands at 20:10Z:

scenario main branch
live memo now (no inspectedAt, no tracking) resolved resolved
first tick on this code, inspection still failing; +31 min resolved firing: CI maintenance coordinator has not completed an inspection since 2026-11-28T20:10:00.000Z
inspection recovers at +35 min; evaluated +36 min resolved resolved

Patch markers recorded across an upgrade. Taken from the upgrade tests' histories:

history markers, in order
deployed code, inspections failing (production's shape) → new code → recovery ci-maintenance-inspection-tracking-v1, ci-maintenance-bounded-stalls-v1
deployed code after a successful inspection → new code ci-maintenance-bounded-stalls-v1, ci-maintenance-inspection-tracking-v1
deployed code, failing → new code whose first inspection never finishes ci-maintenance-inspection-tracking-v1; the memo already holds inspectionTrackedSince and the stalled alert fires at +31 min
pre-bounded fixture → new code ci-maintenance-inspection-tracking-v1, ci-maintenance-bounded-stalls-v1

Verification

  • vitest for src/shared/alerts/ci-maintenance-alert.test.ts, src/activities/ops/ci-maintenance, and src/shared/ci-maintenance.test.ts: 49 passed. The new cases are:

    • a never-completed inspection fires once tracking began over 30 minutes ago;
    • recent tracking fires nothing, and neither does dispatch off;
    • a successful inspection clears it, and an older success still governs;
    • a memo with neither field does not fire;
    • the health activity confirms with a second read, then pages.

    With the old exemption restored, the new firing cases fail.

  • bun run --cwd packages/temporal test:workflows src/workflows/ci: 6 files, 36 tests passed. src/workflows/bundle.test.ts also passed. Fixture-then-new-code histories replay cleanly through Worker.runReplayHistory (maintenance-stalls.test.ts). Without the early memo write, the hung-inspection test fails.

  • bun run --cwd packages/temporal typecheck and lint, run directly to bypass the turbo cache: pass.

  • bunx turbo run jscpd quality-ratchet knip --filter=//: pass.

  • Exact-head CI on the earlier head 3ca68befb8 (pipeline 20661): 93 of 94 verify tasks passed. The only failure was knip's @base-ui/react finding in packages/mail, inherited from main (feat(mail): shared console shell, banner, description list and email preview #5483) and fixed there by fix(mail): drop unused @base-ui/react dependency #5490.

  • Final head 5c03df1304, restacked onto main 79685e6ab8; main changed only .jscpd-baseline.json and the README among this PR's files, and the restack applied cleanly. Rerun on this head, all passing:

    • typecheck and lint (run directly);
    • jscpd, quality-ratchet and knip;
    • the alert, health and shared unit tests (49);
    • src/workflows/ci plus bundle.test.ts (7 files, 37 tests).
  • Extended tier on head 78e349b932 (before the restacks, which brought in only main's commits): bun run verify:extended -- --filter='...[origin/main...HEAD]' (only @shepherdjerred/temporal is affected): pass. Integration: 45 files, 152 tests. Workflows: 89 files, 463 tests.

  • Independent review of 427d58713d was clean: no P0–P2 findings, determinism verified for both history shapes, alert timing (about 35 minutes) correct. Its three P3s are applied in this head:

    1. inspectionTrackedSince is written to the memo before the inspect activity is scheduled, so a hung first tracked tick still pages. A new test covers that case.
    2. The fixture copies the deployed shared state logic verbatim instead of importing it.
    3. The inspection clock is computed once.
  • Not yet verified: artifact publication, ArgoCD and Delivery rollout, and live alert behavior. fix(temporal): fingerprint CI maintenance inputs without main's whole tree #5450 has deployed and the coordinator inspects successfully, so after this deploys its memo should gain inspectionTrackedSince, keep advancing inspectedAt, and CiMaintenanceCoordinatorStalled should stay quiet.

🤖 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

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The CI maintenance coordinator now records when inspection tracking begins. Health alerting uses that timestamp when no successful inspection has completed. Version-gated workflow changes and upgrade tests cover memo persistence and replay behavior.

Changes: CI maintenance inspection tracking

Layer / File(s) Summary
Persist inspection tracking
packages/temporal/src/shared/ci-maintenance.ts, packages/temporal/src/workflows/ci/maintenance.ts
MaintenanceState adds optional inspectionTrackedSince. A version marker gates recording and memoizing the timestamp before inspection is scheduled.
Evaluate inspection staleness
packages/temporal/src/activities/ops/ci-maintenance/ci-maintenance-health.ts, packages/temporal/src/shared/alerts/ci-maintenance-alert.ts, packages/temporal/src/activities/ops/ci-maintenance/ci-maintenance-health.test.ts, packages/temporal/src/shared/alerts/ci-maintenance-alert.test.ts, packages/temporal/README.md
Health memo parsing and alert state accept inspectionTrackedSince. Alerting uses inspectedAt when present, otherwise the tracking timestamp; states with neither timestamp remain unjudged. Tests and documentation cover the behavior.
Verify workflow upgrade behavior
packages/temporal/src/workflows/ci/fixtures/ci-maintenance-before-inspection-tracking.ts, packages/temporal/src/workflows/ci/maintenance-stalls.test.ts, .jscpd-baseline.json
The earlier workflow fixture and upgrade tests cover patch ordering, inspection failures, hung inspections, recovery, and preservation of a prior successful inspection timestamp. The clone baseline records the fixture’s clone pairs.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant Coordinator as CI maintenance coordinator
  participant Memo as Coordinator memo
  participant Health as Health publication
  participant Alerts as buildCiMaintenanceAlerts
  Coordinator->>Memo: Persist inspectionTrackedSince before scheduling inspection
  Health->>Memo: Read coordinator state
  Health->>Alerts: Provide inspection timestamps
  Alerts->>Health: Return stalled alert when selected timestamp is over 30 minutes old
Loading
Merge Risk: Minimal · up to 3ca68

The coordinator-stalled alert can now fire when the CI maintenance coordinator has never completed an inspection. The change is patch-gated and tested against replay of older workflow histories. No concrete merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the fix (paging on a CI maintenance coordinator that never completed an inspection) and the affected component (temporal). This matches the main change: CiMaintenanceCoordinatorStalled…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title names the fix (paging on a CI maintenance coordinator that never completed an inspection) and the affected component (temporal). This matches the main change: CiMaintenanceCoordinatorStalled now alerts when inspectedAt is absent, using a new inspectionTrackedSince field recorded behind a patch marker. The title uses a conventional commit prefix and is specific. It does not mention the patch gating or the fixture and tests, which is acceptable because the title need not cover every detail.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • 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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 668482c and 3ca68be.

Files selected for processing: 10

  • .jscpd-baseline.json
  • packages/temporal/README.md
  • packages/temporal/src/activities/ops/ci-maintenance/ci-maintenance-health.test.ts
  • packages/temporal/src/activities/ops/ci-maintenance/ci-maintenance-health.ts
  • packages/temporal/src/shared/alerts/ci-maintenance-alert.test.ts
  • packages/temporal/src/shared/alerts/ci-maintenance-alert.ts
  • packages/temporal/src/shared/ci-maintenance.ts
  • packages/temporal/src/workflows/ci/fixtures/ci-maintenance-before-inspection-tracking.ts
  • packages/temporal/src/workflows/ci/maintenance-stalls.test.ts
  • packages/temporal/src/workflows/ci/maintenance.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@shepherdjerred

Copy link
Copy Markdown
Owner Author

@coderabbitai review

Automated re-review request for 3ca68be from the CI review gate.

@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@shepherdjerred

Copy link
Copy Markdown
Owner Author

@coderabbitai review

Automated re-review request for 3ca68be (attempt 2 of 2) from the CI review gate.

@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@shepherdjerred

Copy link
Copy Markdown
Owner Author

@codex review

Automated re-review request for 3ca68be 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-28T22:36:21.729711Z 3ca68be 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. Can't wait for the next one!

Reviewed commit: 3ca68befb8

ℹ️ 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".

…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
shepherdjerred force-pushed the fix/ci-maintenance-never-inspected-alert branch from 3ca68be to 5c03df1 Compare December 3, 2026 03:09
@shepherdjerred
shepherdjerred merged commit 2bd384b into main Dec 3, 2026
6 checks passed
@shepherdjerred
shepherdjerred deleted the fix/ci-maintenance-never-inspected-alert branch December 3, 2026 03:21
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