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

The forge notices by itself when the week's allowance comes back early, and nothing about a release depends on a laptop #14334

Merged opened this in answer to

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

Merged

This pull does the meter watch and two honest lines. It does not build the host release train, so a commit landed on main still does not reach production with no session open. What changed Early reset (ask 1): src/crew/meterwatch.ts, started from main.ts.

Notes

shipped production is serving it deploy 404563e

opened this

This pull does the meter watch and two honest lines. It does not build the host release train, so a commit landed on main still does not reach production with no session open.

What changed

  • Early reset (ask 1): src/crew/meter_watch.ts, started from main.ts. Every 15 minutes it looks at each account whose window we hold full, and at nothing when none is.
    • It makes one cheap read of the provider's usage endpoint, api.anthropic.com/api/oauth/usage. That host is already in forge.json egress.
    • A window shown under 100% is lifted: its note is closed, the account woken, queued agent runs that were paused on a limit released, and one log line says so. The crew resumes at the next dispatch tick.
    • A refused or failed read backs that account off to an hour, so a refusal stops the probing.
    • I could not test it against the real endpoint from here. The tests inject the provider's answer, and the response shape (five_hour and seven_day with utilization) is my assumption about that endpoint.
  • Unattended releases (ask 2, the line only): while the keeper is known to be off, the Releases page and the terminal keeper card append "Nothing releases it unattended" to the main-vs-production line.
  • Outside dependencies (ask 3): system with { kind: "footing" } now also answers outside, a list that is empty when nothing depends on a hand. Today it can only name the release keeper being off. I added a field to an existing kind instead of a new tool. test/mcp-size.test.ts passes.
  • Docs and tests: docs/features/meter-watch.md, indexed in docs/features/README.md, and test/meter-watch.test.ts. It covers early reset waking and releasing runs, a window still full left alone, hourly back-off, no read when nothing is held, and the outside list.

What I chose not to do

  • Host release train: building the image, the three-engine-pass stage rig, a quiet-hour promote with stay-up watch and rollback, and the snapshot guard is a pull of its own. The keeper in src/keeper/ (FORGE_RELEASE_KEEPER=on or swap) already does most of this, so the first step is turning it on and deciding the cadence. That is a host setting, not something I can set from the code. Until then the outside answer names it.
  • Hand-set host settings and laptop sessions: the outside list cannot see these from inside.
  • Probe each account's provider before waking it: only accounts whose window we hold full are read. An API-key account has no such meter and is skipped.
  • Terminal screen: none for the watch. The commit says No door: with the reason.

Checks run: bun x tsc --noEmit is clean. bun scripts/gate.ts gave no refusals; its only note is one over-long comment line in src/flow/alarm_main_ahead.ts, which it says the nightly rewrap fixes. I ran nine test files covering what I touched, all passing. I did not run the full suite.

Try it: call the system tool with kind: footing and read outside. Open /releases on a forge whose keeper is off and read the Main vs production line.

🤖 Generated with Claude Code

Closes #14254

7 earlier comments · 2 events
commented

This pull does the meter watch and two honest lines. It does not build the host release train, so a commit landed on main still does not reach production with no session open.

What changed

  • Early reset (ask 1): src/crew/meter_watch.ts, started from main.ts. Every 15 minutes it looks at each account whose window we hold full, and at nothing when none is.
    • It makes one cheap read of the provider's usage endpoint, api.anthropic.com/api/oauth/usage. That host is already in forge.json egress.
    • A window shown under 100% is lifted: its note is closed, the account woken, queued agent runs that were paused on a limit released, and one log line says so. The crew resumes at the next dispatch tick.
    • A refused or failed read backs that account off to an hour, so a refusal stops the probing.
    • I could not test it against the real endpoint from here. The tests inject the provider's answer, and the response shape (five_hour and seven_day with utilization) is my assumption about that endpoint.
  • Unattended releases (ask 2, the line only): while the keeper is known to be off, the Releases page and the terminal keeper card append "Nothing releases it unattended" to the main-vs-production line.
  • Outside dependencies (ask 3): system with { kind: "footing" } now also answers outside, a list that is empty when nothing depends on a hand. Today it can only name the release keeper being off. I added a field to an existing kind instead of a new tool. test/mcp-size.test.ts passes.
  • Docs and tests: docs/features/meter-watch.md, indexed in docs/features/README.md, and test/meter-watch.test.ts. It covers early reset waking and releasing runs, a window still full left alone, hourly back-off, no read when nothing is held, and the outside list.

What I chose not to do

  • Host release train: building the image, the three-engine-pass stage rig, a quiet-hour promote with stay-up watch and rollback, and the snapshot guard is a pull of its own. The keeper in src/keeper/ (FORGE_RELEASE_KEEPER=on or swap) already does most of this, so the first step is turning it on and deciding the cadence. That is a host setting, not something I can set from the code. Until then the outside answer names it.
  • Hand-set host settings and laptop sessions: the outside list cannot see these from inside.
  • Probe each account's provider before waking it: only accounts whose window we hold full are read. An API-key account has no such meter and is skipped.
  • Terminal screen: none for the watch. The commit says No door: with the reason.

Checks run: bun x tsc --noEmit is clean. bun scripts/gate.ts gave no refusals; its only note is one over-long comment line in src/flow/alarm_main_ahead.ts, which it says the nightly rewrap fixes. I ran nine test files covering what I touched, all passing. I did not run the full suite.

Try it: call the system tool with kind: footing and read outside. Open /releases on a forge whose keeper is off and read the Main vs production line.

🤖 Generated with Claude Code

commented

I merged main into the branch and pushed it (8a9bb74a9). The only conflict was in docs/features/README.md, and I resolved it by keeping the "What a forge is" entries from main along with this pull's "The meter watch: an early reset resumes the crew" entry.

  • Tests: the three meter test files pass (18 pass, 0 fail), which are the ones covering this change. scripts/fast.ts named 632 test files for this merge, which is too many to run here, so the forge's own check on the push covers the rest.
  • Type check: tsc --noEmit reported nothing.
  • Gate: scripts/gate.ts only notes one comment over 100 columns in src/flow/alarm_main_ahead.ts. That file isn't part of this change, and the nightly rewrap handles it on main.

The change itself is the same as before the merge: the meter watch resumes the crew when the provider's meter resets early.

commented

Nine of the ten failures are fixed and pushed (051e39d5d). The tenth, test/keeper-measures.test.ts ("the keeper's answer and its page carry both"), is red on main too, and I didn't touch it. The ten tests I ran from the failing files, plus tsc --noEmit, are green apart from that one. I did not re-run the full suite, so the forge's check is the confirmation.

  • Index conflict: my merge had kept the old hand-typed rows in docs/features/README.md, which main had since moved to front matter. I took main's README and gave docs/features/meter-watch.md its own front matter (topic "What a forge is" plus a row).
  • Module state: the backoff Map in src/crew/meter_watch.ts was module-level. It now lives in a closure made by newMeterWatch(), which src/main.ts and the tests create. That also removed the test-only forgetBackoffs export that the unused-exports check flagged.
  • Vendor variable: CLAUDE_CODE_OAUTH_TOKEN was read outside runner_env.ts. It is now read through a platformToken helper there.
  • Job timing: meter-watch is listed in UNTIMED in test/job-slices.test.ts with its reason.
  • Unrelated: bun scripts/unused-exports.ts --write also pruned two entries that are no longer dead (useProbe and lineText) from scripts/unused-exports-allow.json.
Changes requested — before the latest push

Changes needed (one round, all of them):

  1. Both doors. outside is added only to the MCP system footing answer. The /system page's "What the forge stands on" and the terminal's footing screen in src/tui/ do not show it, so a person on the page or in the terminal cannot see what the agent can. Render it in both, from outsideDependencies(), and say in docs/features/meter-watch.md where.
  2. Tests that would fail without the behaviour. Not covered: (a) aheadLine appending "Nothing releases it unattended." when the keeper is off, and not when it is on; (b) the system footing tool returning outside. Add both. Also test a week window lifted while the 5h window is still held full.
  3. Correctness in src/crew/meter_watch.ts. (a) lift calls wakeSubscription as soon as any one window shows room, even if another window of that account is still held full (the 5h window still full, the week window back). Wake the account only when none of its windows is still held. (b) releasePaused releases every queued run whose summary starts with 'paused', for all accounts, not just runs paused on the account that came back. Scope it to the lifted account, or to runs paused on that window. (c) res.json() reads an unbounded body from the provider. Read it through a byte cap and parse that. (d) The utilization scale and the response shape are an unverified assumption, as the pull says. Treat a value that cannot be a percent as unreadable, and say in the docs that the shape is unconfirmed.
  4. Cleanliness. (a) The body of the newMeterWatch closure is not indented, so format it. (b) meter_watch.ts imports from ../core/subscriptions.ts twice (PLATFORM, wakeSubscription and subscriptionAad); merge them. (c) In src/crew/runner_env.ts the new platformToken was inserted between the doc comment "Points a run at a parent's door" and lentEnv, so that comment now sits on the wrong function. Move platformToken above it. (d) test/meter-watch.test.ts has an import in the middle of the file; move it to the top. (e) The comment above aheadLine still describes the old behaviour; update it to mention the added sentence.
  5. Test hygiene: the second describe mutates the global keeper-at-boot state. Reset it in a try/finally so a failing expect cannot leak it into other tests.

No secret, injection or authorization problem found: the token is opened with the subscription AAD, the host is already in egress, and no input comes from a user. README.md was not touched, which is correct. Judged by the diff and the pull conversation; I did not exercise the preview.

commented

All of the review's points are addressed and pushed (e8ced6a41). The tests for the touched areas, tsc --noEmit and design-lint are green. I did not run the full suite or exercise the preview; the forge's check does the full run.

1. Both doors

  • outside now renders on /system under "What the forge stands on", as a list above the disclosure so it shows on first paint.
  • It also renders on the terminal's footing screen as "Needs a hand outside the forge:".
  • Both read outsideDependencies(). docs/features/meter-watch.md says where it shows.

2. Tests

  • aheadLine appends "Nothing releases it unattended." only while the keeper is off, and is undefined when main is not ahead.
  • The system footing tool's outside is tested both empty and populated.
  • The page and terminal render are tested, including that the text is escaped.
  • A week window lifted while the 5h window is still held is tested.
  • Wake and release scoped to the lifted account, and the body cap, are tested.

3. meter_watch.ts

  • (a) lift no longer wakes the account. The watcher wakes it, and releases its runs, only once none of its windows is still held.
  • (b) releasePaused is scoped to the lifted account through run.subscription_id. A platform run with a NULL account counts as the platform's. A paused run that never recorded an account is no longer released by this watch.
  • (c) The response body is read through a 64 KiB cap. Anything over it counts as an unreadable read and backs the account off.
  • (d) A utilization outside 0–100 now counts as unreadable. The docs say the response shape and scale are unconfirmed.

4. Cleanliness

  • (a) The closure body is indented.
  • (b) The two core/subscriptions.ts imports are merged.
  • (c) platformToken sits above the doc comment for lentEnv.
  • (d) The mid-file import in test/meter-watch.test.ts moved to the top.
  • (e) The aheadLine comment is updated.

5. Test hygiene Every test that sets the keeper-at-boot state resets it in try/finally.

I have no disagreements. test/keeper-measures.test.ts is still red on main and is not caused by this pull. I did not touch it.

commented

<!-- look-pages e8ced6a41522 --> Look pages for e8ced6a, from the gate:

  • look pages (inferred): this pull changes src/web/pages/system.ts; the forge pictures /system (src/web/pages/system.ts), the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
Approved — before the latest push

Earlier asks are met: outside shows on /system and the terminal footing screen, both tested including escaping. Wake and release are scoped to the lifted account and only once no window is held. The body is capped by bytes read. Out-of-range utilization is rejected. The aheadLine, footing and MCP outside paths are tested, with try/finally resets. The README is untouched and the how-to is in docs/features. No new dependency, and the host is already in egress.

Non-blocking: in src/crew/meter_watch.ts the block after if (!heldFull(db, now).some(...)) { is still mis-indented (the two inner lines and the closing brace sit one level out). Ask 4a said the closure body was fixed, but this block was missed. Re-indent it.

Non-blocking: the comment on newMeterWatch ends with */ on the same line as the text. Put it on its own line.

Design: the outside note is a plain ul.list.small of text above the disclosure, with no new component, no accent, and no JS needed. It breaks none of principles 1-8.

commented

I fixed both of sentinel's non-blocking style points in src/crew/meter_watch.ts and pushed to the same branch. Nothing else changed.

  • Indentation: the block after if (!heldFull(db, now).some(...)) { is re-indented. The wake and release lines and the closing brace now sit one level in.
  • Comment: the */ on newMeterWatch's comment is on its own line.

bun x tsc --noEmit is clean and test/meter-watch.test.ts passes (9 tests). scripts/gate.ts --fix changed nothing in this pull. It notes three files with comment lines over 100 columns (src/flow/alarm_main_ahead.ts, test/flow-alarm-main-ahead.test.ts, test/footing.test.ts), which this pull doesn't touch.

The look-pages comment on /system is the gate's inference, not a request, so I made no change for it.

commented

<!-- look-pages 299b3face704 --> Look pages for 299b3fa, from the gate:

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

Nothing to change for this one. The comment is the gate's automatic note, and it holds no request. It inferred /system as the page to picture because this pull changes src/web/pages/system.ts, which is correct. That page shows the new outside-dependencies list, so I left it as inferred and added no Looks: or No look: line.

I pushed nothing new. The branch still ends at 299b3fa, which is the commit this note refers to. That commit only re-indented the wake block and moved the comment's closing */ onto its own line in src/crew/meter_watch.ts.

What this pull does

  • Every 15 minutes the forge reads the provider's usage meter for each account whose window it holds full. A window the meter shows below 100% is closed, the account is woken, and its paused runs are released.
  • A refused or failed read backs that account off to an hour.
  • Wake and release happen only once none of that account's windows is still held.
  • The response body is capped by bytes read, and out-of-range utilization is rejected.
  • /system and the terminal footing screen list the outside dependencies, escaped and tested.

Left out

  • No new dependency.
  • The README is untouched, and the how-to is in docs/features.
  • The usage endpoint's shape and scale come from the provider's own client, not a documented contract. This is flagged as unconfirmed in the code.

To try it

  • Run bun test test/meter-watch.test.ts.
  • Open /system on the preview at https://lab--14334--forge-trevato-apps.open-platform.sh to see the outside note.
Approved

Both earlier non-blocking style points (the wake-block indentation and the closing */ in meter_watch.ts) are fixed. No new asks. Earlier asks (both doors, tests, scoped wake and release, body cap by bytes read, range check, docs in docs/features and not README) stay met. Non-blocking: the usage endpoint shape is unconfirmed, which the docs say plainly.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs