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

A maintenance duty that has not run in twice its interval raises one issue naming the duty #13437

Merged opened this

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

Merged

A maintenance duty whose last run is more than twice its interval old now gets one defect filed, naming the duty and when it last ran. The new duty-idle duty runs hourly and checks every other duty's last real start (budget stops don't count).

Notes

shipped production is serving it deploy 59903fa

opened this

A maintenance duty whose last run is more than twice its interval old now gets one defect filed, naming the duty and when it last ran.

The new duty-idle duty runs hourly and checks every other duty's last real start (budget stops don't count). It files through fileIssueOnce, so while the issue is open no second one is filed. The title is "The maintenance duty <name> has not run in twice its interval".

The new tests in test/duty-idle.test.ts pass, along with the existing maintenance suites. tsc and the gate are clean. I did not run the whole suite: scripts/fast.ts found the diff too broad to name tests, so I ran the maintenance ones I picked instead.

The files:

  • New duty: src/maintain/duties/duty_idle.ts.
  • Registry: src/maintain/registry.ts builds the watcher from the list of the other duties and appends it. Building it that way avoids an import cycle.
  • Test: test/duty-idle.test.ts drives the duty with an injected clock (the now passed in).

What I chose:

  • Watcher exempt: the watcher is skipped in its own scan, so it can't report itself or loop.
  • Never-run duties: a duty that has never run is skipped. There is no last run to name, and a fresh install would otherwise file an issue for every duty.
  • Boundary: a gap of exactly 2× is not idle; it has to be over.

To try it, run the forge, then stop a duty (or let it be paused). After more than twice its interval, the duty-idle run on the next hour files the issue.

Closes #13406

5 earlier comments · 1 event
commented

A maintenance duty whose last run is more than twice its interval old now gets one defect filed, naming the duty and when it last ran.

The new duty-idle duty runs hourly and checks every other duty's last real start (budget stops don't count). It files through fileIssueOnce, so while the issue is open no second one is filed. The title is "The maintenance duty <name> has not run in twice its interval".

The new tests in test/duty-idle.test.ts pass, along with the existing maintenance suites. tsc and the gate are clean. I did not run the whole suite: scripts/fast.ts found the diff too broad to name tests, so I ran the maintenance ones I picked instead.

The files:

  • New duty: src/maintain/duties/duty_idle.ts.
  • Registry: src/maintain/registry.ts builds the watcher from the list of the other duties and appends it. Building it that way avoids an import cycle.
  • Test: test/duty-idle.test.ts drives the duty with an injected clock (the now passed in).

What I chose:

  • Watcher exempt: the watcher is skipped in its own scan, so it can't report itself or loop.
  • Never-run duties: a duty that has never run is skipped. There is no last run to name, and a fresh install would otherwise file an issue for every duty.
  • Boundary: a gap of exactly 2× is not idle; it has to be over.

To try it, run the forge, then stop a duty (or let it be paused). After more than twice its interval, the duty-idle run on the next hour files the issue.

commented

The preview failed to start because src/maintain/registry.ts still had unresolved merge conflict markers from merging origin/main. I resolved them and pushed. I haven't confirmed the new preview deploy starts.

The registry now keeps both sides of the merge. diskFree from main is in the duty list, and the duty-idle watcher wraps the whole list, so it watches diskFree too.

Checks I ran:

  • tsc --noEmit and scripts/gate.ts --fix produced no errors.
  • The 8 test files that touch the registry, duty-idle and disk-free all pass (63 tests): duty-idle, maintain-disk-free, maintain, maintain-failing, maintain-pause, maintain-v1-proven, efficiency-runner and maintenance-week-doors.
  • scripts/fast.ts reported the diff too broad to name tests, so I picked these myself rather than running the full suite.
  • A search for other conflict markers under src found only two files that mention them in code or comments (src/tui/local/hunks.ts, src/git/conflicts.ts). Neither is a real conflict.

The fix is commit f7aa0c07c.

commented

I merged main into the branch and pushed it. The only conflict was in src/maintain/registry.ts, and I resolved it by keeping both sides.

  • What main added: a mergedBranches duty.
  • What this branch has: the dutyIdle watcher, which wraps the whole list of duties.
  • Result: the list now holds mergedBranches alongside diskFree, and dutyIdle watches all of them, mergedBranches included.

bun x tsc --noEmit and scripts/gate.ts --fix came back clean. I ran 103 tests across the duty-idle, maintain, maintenance-week-doors and merged_branches test files, and all pass. I did not run the full suite; the forge's check does that on the push.

The merge is commit 355fd9196.

commented

I merged main into the branch again and pushed it. The only conflict was in src/maintain/registry.ts, and I resolved it by keeping both sides.

  • What main added: a backupAge duty.
  • What this branch has: the dutyIdle watcher, which wraps the whole list of duties.
  • Result: the list now includes backupAge alongside diskFree and mergedBranches, and dutyIdle watches all of them, backupAge included.

bun x tsc --noEmit and scripts/gate.ts --fix came back clean. I ran 111 tests across the duty-idle, maintain, maintenance-week-doors and backup_age test files, and all pass. I did not run the full suite; the forge's check does that on the push.

The merge is commit 81ee75ec9.

Changes requested — before the latest push

The logic is sound (lastStarted ignores budget stops, exact 2x is not idle, fileIssueOnce dedupes, watcher exempt, injected clock in tests) and the preview answers 200. One miss: the duty has no how-to. docs/features/maintenance-duties.md documents each duty (e.g. merged-branches, #13321) and must get a short duty-idle section: what it watches, the 2x rule, that a never-run duty is skipped, the issue title, and the test file. Do not put it in README. Also say there why the duty has no terminal screen (it files an issue, which both doors already show), so the both-doors rule is answered. Nothing else needed.

commented

I added the missing how-to for the duty as a "Duty idle (#13406)" section at the end of docs/features/maintenance-duties.md. I left the README alone, and the push is commit 264554777.

The section covers each point you asked for:

  • What it watches: hourly, it checks when each other duty last started. Budget stops don't count as a start, and it never watches itself.
  • The 2x rule: a duty is idle only when its last start is more than twice its interval ago. Exactly 2x is not idle.
  • Never-run duties: these are skipped, because there is no last run to name.
  • The issue: one per idle duty, filed once, titled The maintenance duty <name> has not run in twice its interval. The body gives the last run time and the interval.
  • Both doors: it has no terminal screen because it files an issue, which the web and the terminal already show.
  • Tests: test/duty-idle.test.ts.

This change is docs only. scripts/gate.ts --fix changed nothing. I did not re-run the tests or the type check.

commented

A maintenance duty that has not run in twice its interval now gets one defect issue naming it and when it last ran. The new duty-idle watcher does this hourly, and the how-to documents it. It never watches itself, and it skips a duty that has never run.

CI failure: the budget test (pages-budget.test.ts) failed because /maintenance made 61 SQL statements against a budget of 60. Each duty added by the stacked duties (backup_age, disk_free, merged_branches, duty_idle) costs a few queries. dutyState in src/maintain/pause.ts read each duty's state row twice, once itself and once inside failing(). failing() now takes the from_run value the caller already has, which saves one query per duty. The budget itself is unchanged.

Tests: pages-budget.test.ts passes locally. The pause and maintenance tests (86 across 16 files) pass, and tsc and the gate are clean.

started-from-line.test.ts: I left it alone. It is red on main at d3fe125 too, with the same failing tests, so the check does not count it against this pull.

Not done: I did not run the full suite; the forge's check does that on the push.

Approved

Clean. No security surface is added: the duty reads the maintenance record and files through fileIssueOnce, with no user input, no shell and no SQL built from text. Dedupe, the exact-2x boundary, the watcher exemption and the never-run skip are tested with an injected clock. The how-to is in docs/features/maintenance-duties.md, not README, and says why there is no terminal screen. The failing() change in pause.ts keeps behaviour and saves a query to stay inside the pages budget. Minor, not blocking: the test sets process.env.FORGE_SENTINEL_REPO at module level, which can leak to other test files in the same process.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs