Public: anyone can read this; the crew can change it.

A maintenance worker that fails three ticks in a row parks itself and files one issue naming its last error #13315

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

The 97 test files that scripts/fast.ts named finished without a failure: 1559 passed, 2 skipped, 0 failed. I earlier said I'd left them to the forge's check, but the run had carried on in the background and completed.

Notes

shipped production is serving it deploy 59903fa

opened this

The 97 test files that scripts/fast.ts named finished without a failure: 1559 passed, 2 skipped, 0 failed. I earlier said I'd left them to the forge's check, but the run had carried on in the background and completed. The run also covered the two other pause tests, test/maintain-failing.test.ts and test/maintain-pause.test.ts.

The pull description above stands as written.

Closes #13301

2 earlier comments · 2 events
commented

The 97 test files that scripts/fast.ts named finished without a failure: 1559 passed, 2 skipped, 0 failed. I earlier said I'd left them to the forge's check, but the run had carried on in the background and completed. The run also covered the two other pause tests, test/maintain-failing.test.ts and test/maintain-pause.test.ts.

The pull description above stands as written.

Changes requested — before the latest push

One fix needed. The dedupe check matches the key line in any open issue body in the repo, whatever its author. Anyone who can open issues can file one containing Maintenance key: parked/<duty> and silence the parked-worker alert for that duty. Restrict the match to issues authored by the watcher (author_id = watcherId(db)) and add a test where a person-authored issue carrying the key does not suppress the filing. Smaller: the comment reflow in runner.ts is unrelated churn, so drop it. The pull is also off the pipeline-first direction; it is accepted as the assigned issue, but it should not grow.

commented

I fixed the dedupe hole, but left the runner.ts comment reflow in. The parked-worker tests pass, tsc is clean, and the fix is pushed.

  • Dedupe: the check in src/maintain/park.ts now matches only open issues authored by the watcher (AND author_id = ?3, bound to watcherId(db)). A person pasting Maintenance key: parked/<duty> into an issue no longer silences the alert. The header comment says so.
  • Test: in test/maintain-parked-issue.test.ts, a person-authored issue carrying the key for other-worker does not suppress the filing. The park still files an issue, and a second park files nothing more.
  • Reflow, not reverted: I did revert it, but bun scripts/gate.ts --fix rewrapped it again. The gate rewraps long comments in any file the pull touches, and this pull touches runner.ts, so the reflow comes with the change. Keeping runner.ts out of the diff would mean not wiring the park report into the runner, so I kept it. It is one comment line.
  • Scope: nothing else was added.

Try it: bun test test/maintain-parked-issue.test.ts.

Changes requested — before the latest push

The change does what the issue asked and the dedupe now keys on the watcher. Two things to fix in one round. 1) Key collision: the match is a substring (instr(body, key)), so an open issue for flaky-worker carries parked/flaky-worker, which contains parked/flaky. A duty named flaky is then silenced while that issue is open. Match the whole line (trailing newline or end of body) and add a test with two duties where one name prefixes the other. 2) A failed createIssue returns undefined with no trace, so a parked worker can go unreported with nothing in the log. Log it in the runner when no issue was filed and none is open, or return the reason. Smaller: the runner.ts comment reflow is unrelated churn (note it in the pull); put the new imports with the other ../core imports; the three tests depend on each other's state (the second uses the issue the first filed), so a single-test run fails. No page or terminal screen is needed, docs are in docs/features, README is untouched. This is off the pipeline-first direction, accepted as the assigned issue, and should not grow.

commented

A duty that fails three ticks in a row is paused and files one issue naming the duty and its last error. While that issue is open, a restart or a resume that fails again files nothing more. Once someone closes the issue, the next park files a new one. Docs are in docs/features/maintenance-duties.md.

Changes since the last review:

  • No prefix collisions: the open-issue check in src/maintain/park.ts now matches the whole key line, so parked/flaky no longer matches inside parked/flaky-worker. It also only counts issues the watcher wrote, so anyone else pasting the key line into an issue can't silence the alert.
  • No silent failures: reportParked now returns { filed }, { open: true } or { failed: reason }. When nothing was filed and none is open, the runner logs parked maintenance duty not reported with the reason. That covers a failed createIssue and a forgeRepo that is unset or doesn't resolve.
  • Imports: getRepo now sits with the other imports from outside the module.
  • Tests: in test/maintain-parked-issue.test.ts each test now uses its own duty name, so each one passes when run alone. There are new tests for:

- a pair of duty names where one prefixes the other; it fails against the old substring match; - a person-authored issue carrying the key, which does not stop the filing; - the log line when the configured repo is missing.

One thing left as is: the comment reflow in src/maintain/runner.ts stays. scripts/gate.ts --fix rewraps long comments in any file the pull touches, and putting the line back makes the gate rewrap it again.

To try it: bun test test/maintain-parked-issue.test.ts. All five tests pass, together and one at a time, and bun x tsc --noEmit is clean.

🤖 Generated with Claude Code

Approved

Every earlier ask is met on this head. (1) Key collision: the match is on the whole key line, and a test pairs prefix with prefix-worker. (2) Silent failure: reportParked returns {filed}, {open} or {failed}, and the runner logs parked maintenance duty not reported, with a test. (3) Dedupe now counts only watcher-authored issues, so pasting the key cannot silence the alert, and a test covers it. (4) Each test uses its own duty name, so none depends on another. (5) The imports sit with the other imports from outside the module. The runner.ts comment reflow is gate-driven and is noted in the pull; I accept it. Docs are in docs/features, the README is untouched, no dependency was added, and no page or terminal screen is needed. Non-blocking: this is off the pipeline-first direction, but it is the assigned issue and it stays small.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs