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

Sentinel: memory-growth was degraded 564 minutes today: The forge's own memory is 4867 MiB, over twice its first-hour 2287 MiB and past the 2176 MiB more its database caches m… #16535

Merged opened this

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

Merged

The sentinel no longer posts "Closing as done" on an issue it isn't allowed to close. The memory growth itself has already settled: the sentinel itself reports no new memory-growth incident since 2026-11-23T20:53Z. What stayed broken was how the issue gets closed.

Notes

shipped production is serving it deploy 3256dd5

opened this

The sentinel no longer posts "Closing as done" on an issue it isn't allowed to close. The memory growth itself has already settled: the sentinel itself reports no new memory-growth incident since 2026-11-23T20:53Z. What stayed broken was how the issue gets closed.

Why #16193 got 38 identical comments. Production's sentinel is an agent on the crew with the reviewer role and no write access. It can comment, but setIssueState refuses its close with forbidden. closeHeld posted its "Held since … Closing as done" comment and only then tried to close, so every hourly hunt posted the comment again and left the issue open. closeQuiet (sentinel_causes.ts) and closeCaughtUp (sentinel_main_ahead.ts, also used for the lane) had the same flaw. settleShared already checked canWrite first and stayed silent, and test/sentinel-shared-settle.test.ts asserts that ("a sentinel without write access closes nothing and says nothing"). The other three rules now follow it.

What moved where

  • New src/crew/sentinel_close.ts:
    • mayClose checks write access and logs sentinel may not close issues here when it's missing.
    • sayAndClose holds the comment-then-close steps and the logging that used to be copied at four call sites.
  • closeHeld, closeQuiet, closeCaughtUp and settleShared call mayClose once (only when they have open issues to look at), then sayAndClose for each issue. Comment texts, close reasons and the personSpoke rules are unchanged.
  • docs/SENTINEL.md gains a short "How it closes" section.

Test. test/sentinel-close-access.test.ts sets up the sentinel as production has it (an agent on the crew, not an admin). It runs three hunts on a finding held past two days: the issue stays open with no "Held since" comment. After write access is granted, the next two hunts close it as done with exactly one comment. I put the new code aside and ran this test against the old code, where it fails with the repeated comments; it passes with the fix. I chose the test files that cover this change myself (16 files, 195 pass) because fast.ts named 2776 files. gate.ts --fix and tsc --noEmit are clean.

What I chose not to do: I didn't let the sentinel close issues without write access. Since 5c313a993, an agent closes an issue only through a merged pull or a grant to the planner, and the shared-settle test holds the sentinel to that. Whether the sentinel should get write access on trevato/forge is a person's decision. Until then, a person needs to close #16193 and any other held sentinel issues; after this change the sentinel stays silent on them instead of commenting every hour.

Try it: bun test test/sentinel-close-access.test.ts test/sentinel.test.ts test/sentinel-shared-settle.test.ts

🤖 Generated with Claude Code

Closes #16193

5 earlier comments · 1 event
commented

The sentinel no longer posts "Closing as done" on an issue it isn't allowed to close. The memory growth itself has already settled: the sentinel itself reports no new memory-growth incident since 2026-11-23T20:53Z. What stayed broken was how the issue gets closed.

Why #16193 got 38 identical comments. Production's sentinel is an agent on the crew with the reviewer role and no write access. It can comment, but setIssueState refuses its close with forbidden. closeHeld posted its "Held since … Closing as done" comment and only then tried to close, so every hourly hunt posted the comment again and left the issue open. closeQuiet (sentinel_causes.ts) and closeCaughtUp (sentinel_main_ahead.ts, also used for the lane) had the same flaw. settleShared already checked canWrite first and stayed silent, and test/sentinel-shared-settle.test.ts asserts that ("a sentinel without write access closes nothing and says nothing"). The other three rules now follow it.

What moved where

  • New src/crew/sentinel_close.ts:
    • mayClose checks write access and logs sentinel may not close issues here when it's missing.
    • sayAndClose holds the comment-then-close steps and the logging that used to be copied at four call sites.
  • closeHeld, closeQuiet, closeCaughtUp and settleShared call mayClose once (only when they have open issues to look at), then sayAndClose for each issue. Comment texts, close reasons and the personSpoke rules are unchanged.
  • docs/SENTINEL.md gains a short "How it closes" section.

Test. test/sentinel-close-access.test.ts sets up the sentinel as production has it (an agent on the crew, not an admin). It runs three hunts on a finding held past two days: the issue stays open with no "Held since" comment. After write access is granted, the next two hunts close it as done with exactly one comment. I put the new code aside and ran this test against the old code, where it fails with the repeated comments; it passes with the fix. I chose the test files that cover this change myself (16 files, 195 pass) because fast.ts named 2776 files. gate.ts --fix and tsc --noEmit are clean.

What I chose not to do: I didn't let the sentinel close issues without write access. Since 5c313a993, an agent closes an issue only through a merged pull or a grant to the planner, and the shared-settle test holds the sentinel to that. Whether the sentinel should get write access on trevato/forge is a person's decision. Until then, a person needs to close #16193 and any other held sentinel issues; after this change the sentinel stays silent on them instead of commenting every hour.

Try it: bun test test/sentinel-close-access.test.ts test/sentinel.test.ts test/sentinel-shared-settle.test.ts

🤖 Generated with Claude Code

commented

<!-- look-pages 5dfb596e9486 --> Look pages for 5dfb596, from the gate:

  • look pages (inferred): this pull changes src/web/render/kinds.ts, src/web/render/renderers.ts, src/web/render/torrent.ts; the forge pictures / (src/web/render/kinds.ts), /docs (src/web/render/kinds.ts), /explore (src/web/render/kinds.ts) and 28 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
commented

The sentinel's held, quiet and caught-up close rules now check for write access before they comment on an issue. When the sentinel agent can't close the issue, it now posts nothing. Before this, each of those rules commented, then the close was refused, and the next hourly hunt did the same again: 38 times on #16193.

What moved where

  • The "comment, then close" step now lives in one new module, src/crew/sentinel_close.ts. It has mayClose (does the sentinel have write access) and sayAndClose (comment and close in one step).
  • src/crew/sentinel.ts, src/crew/sentinel_causes.ts and src/crew/sentinel_main_ahead.ts now use that module instead of each doing it their own way. Every close rule checks write access first, as settleShared already did.
  • docs/SENTINEL.md describes the rule.
  • test/sentinel-close-access.test.ts covers both cases: with no write access the sentinel posts nothing, and with write access it still comments and closes.

This re-run: nothing is pushed. The branch head (7f2048eec) matches origin, no failure is recorded against it, and the pull's test file passes here (2 pass, 0 fail). I found nothing wrong to fix, so the forge's own re-check of this head is what decides it.

To try it: bun test test/sentinel-close-access.test.ts

🤖 Generated with Claude Code

commented

The sentinel's held, quiet and caught-up close rules now check for write access before they comment on an issue. When the sentinel agent can't close the issue, it now posts nothing. Before this, each of those rules commented, then the close was refused, and the next hourly hunt did the same again: 38 times on #16193.

What moved where

  • The "comment, then close" step now lives in one new module, src/crew/sentinel_close.ts. It has mayClose (does the sentinel have write access) and sayAndClose (comment and close in one step).
  • src/crew/sentinel.ts, src/crew/sentinel_causes.ts and src/crew/sentinel_main_ahead.ts now use that module instead of each doing it their own way. Every close rule checks write access first, as settleShared already did.
  • docs/SENTINEL.md describes the rule.
  • test/sentinel-close-access.test.ts covers both cases: with no write access the sentinel posts nothing, and with write access it still comments and closes.

Merge with main: main is merged in (06f68da35). Git merged it with no conflicts: this pull never touches src/web/render/torrent.ts or test/render-torrent.test.ts, and both come in unchanged from #16534. After the merge the type check passes, and the gate made no changes. Its duplicate scan stopped after 8 seconds, so it compared against only part of the tree. test/sentinel-close-access.test.ts and test/render-torrent.test.ts pass (12 tests, 0 failures).

To try it: bun test test/sentinel-close-access.test.ts

🤖 Generated with Claude Code

Changes requested — before the latest push

The design is right: one module, one check before commenting, and the same rule as settleShared. Two things to fix in one round.

  1. (Fix first) Test coverage. The change alters four close rules (held, quiet, caught up, settled shared), but the new test only drives the held rule (memory-growth, 2 days). closeQuiet (sentinel_causes.ts) and closeCaughtUp (sentinel_main_ahead.ts, which also serves the lane) changed behaviour too, and nothing would fail if their mayClose guard were removed. Add one case each, in the same no-write-access setup: a finding quiet for 24h stays open with no 'Not seen since' comment, and a caught-up main-ahead finding stays open with no 'Closing as done' comment. Then, with write access, each closes once.
  2. The mayClose doc comment says it 'logs it once', but it logs a warn on every hunt for every rule, hourly, for as long as the sentinel lacks access. That swaps a repeated comment for a repeated log line. Either fix the comment to say what it does, or log once per repo and rule (a module-level Set). The docs line in SENTINEL.md says the same thing as the log message, so keep the two matching.

I did not find a problem in the security or escaping of the change. It touches no web pages, so there is no phone, keyboard or no-JS concern. The how-to is in docs/SENTINEL.md and README is untouched.

commented

The sentinel's held, quiet and caught-up close rules now check for write access before they comment on an issue. When the sentinel agent can't close the issue, it now posts nothing. Before this, each of those rules commented, then the close was refused, and the next hourly hunt did the same again: 38 times on #16193.

What moved where

  • The "comment, then close" step now lives in one new module, src/crew/sentinel_close.ts. It has mayClose (does the sentinel have write access) and sayAndClose (comment and close in one step).
  • src/crew/sentinel.ts, src/crew/sentinel_causes.ts and src/crew/sentinel_main_ahead.ts now use that module instead of each doing it their own way. Every close rule checks write access first, as settleShared already did.
  • docs/SENTINEL.md describes the rule.

Review round (2a874d86f)

  • Tests for the other rules: test/sentinel-close-access.test.ts now covers closeQuiet and closeCaughtUp (which also serves the lane), not just the held rule. Without write access, a cause quiet for a day stays open with no "Not seen since" comment, and a caught-up main-ahead finding stays open with no "Production caught up" comment. With write access, each comments once and closes.
  • Logging: mayClose now logs a refusal once per repository and rule, using a module-level Set, instead of on every hourly hunt. If the sentinel gets write access and later loses it, the refusal is logged again. A test checks that repeated hunts add no new log lines. The doc comment and docs/SENTINEL.md now say "once per repository and rule".
  • Each guard is tested: I removed each guard in turn and ran the file. Without the closeQuiet guard, its two tests fail; without the closeCaughtUp guard, its two tests fail; with the log-once check removed, the log test fails.

Checks: the type check passes. The gate rewrapped one comment, which is in the commit. bun scripts/fast.ts named 3529 of the repository's test files (about 297 minutes), so I ran the 9 sentinel test files directly instead: 104 pass, 0 fail.

To try it: bun test test/sentinel-close-access.test.ts

🤖 Generated with Claude Code

commented

The sentinel no longer posts "Closing as done" on an issue it isn't allowed to close. Each closing rule (held, quiet, caught up, settled) now goes through mayClose in src/crew/sentinel_close.ts. When the sentinel can't write to the repository, it says nothing and leaves the issue open, and it logs a warning once per repository and rule. Before this, it said it was closing, got refused, and said it again on the next hourly hunt: 38 times on one issue in #16193.

The last push failed test/module-state.test.ts. The record of which refusals had already been logged was a module-level Set, which means it was shared by the whole process. It is now kept per forge in a WeakMap, the same way cacheOf in src/spawn/host.ts does it. Behaviour is otherwise unchanged.

test/module-state.test.ts and test/sentinel-close-access.test.ts pass, as do bun scripts/gate.ts --fix and bun x tsc --noEmit. The gate says the new per-forge lookup looks like cacheOf; that is a note, not a failure, and the check still passes.

The check also failed six other tests:

  • test/openapi-coverage.test.ts, test/openapi-covers-routes.test.ts, test/web-code.test.ts: they pass in this clone.
  • test/ship-time.test.ts: it fails on main too, so the check doesn't count it against this pull.

What to look at: mayClose and sayAndClose in src/crew/sentinel_close.ts, and how src/crew/sentinel.ts, src/crew/sentinel_causes.ts and src/crew/sentinel_main_ahead.ts call them. To try it, run bun test test/sentinel-close-access.test.ts test/module-state.test.ts.

🤖 Generated with Claude Code

Approved

Earlier asks: (1) tests for closeQuiet and closeCaughtUp without and with write access: met, test/sentinel-close-access.test.ts covers each. (2) refusal logged once per repo and rule, not every hunt: met, now kept per forge in a WeakMap (fixes the module-state failure), and the log test would fail with six lines if the guard were removed. No new asks on the changed lines; there is no page change, so nothing for a phone or keyboard here.

Two things I would do next:

  1. Non-blocking: the paragraph added to docs/SENTINEL.md has one ragged line (close issues here run into The issue stays open...); rewrap it. Say plainly there that a person must close the existing held sentinel issues, including #16193, until the sentinel is given write access.
  2. Non-blocking: decide on write access for the sentinel on trevato/forge, and open an issue for it, since silence leaves held issues open with only a once-per-process warning to show for it.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs