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

The release agent refuses a dark roll unless the owner said yes to that roll #1217

Closed opened this
Closed without merging

Before a release rolls, a new gate checks whether a second forge pod would fit beside the first. If it wouldn't, the roll waits until the owner says yes to that particular roll. This is the change from #1169, merged with today's main, plus a fix for the proxy bug that made #1169's check fail.

Notes

stopped closed without shipping deploy a496263

opened this

Before a release rolls, a new gate checks whether a second forge pod would fit beside the first. If it wouldn't, the roll waits until the owner says yes to that particular roll. This is the change from #1169, merged with today's main, plus a fix for the proxy bug that made #1169's check fail.

Why #1169 went red. "apps that are busy > an open stream keeps the app awake until it closes" failed because of a real race, not a flaky test. The check log shows the app put to sleep at 05:01:24.888, about 0.6 s before the test's stream response arrived. An event stream only counted as busy from its first byte back. Before that, a request waiting on the app counted for nothing. A freshly woken app on a loaded machine took longer than the 700 ms idle window to answer, so the sweep stopped it under the request.

What to look at

  • The fix:
    • src/apps/proxy.ts: the proxy holds the environment from the moment it passes a request on until the answer begins (runtime.holdRequest).
    • src/apps/busy.ts: this adds a third busy reason, request, with the words "busy — it is still answering a request". It shares the existing grace, so a request that never gets an answer cannot keep an app awake forever.
  • New tests: test/apps-busy.test.ts adds a /slow route to the test app. The new test checks that an answer twice as slow as the window is answered and the app stays up during it; without the fix the app is stopped mid-request. Two small tests also cover busyReason directly.
  • The roll gate (unchanged from #1169):
    • scripts/roll.ts does the fit calculation: node allocatable minus what other pods have requested, compared with the pod's CPU request and the larger of its memory request and steady memory.
    • scripts/roll-preflight.ts runs it. It exits 3 until --yes quotes the roll id, and exits 4 if an overlay sets maxSurge: 0 or Recreate.
    • docs/ops/RELEASE.md is the checklist, and test/roll.test.ts is in the gate.

Not done: the standby scripts the issue mentions aren't in this repository, so RELEASE.md and roll-preflight serve as the roll recipe here. Nothing here touches the cluster or the chart.

Testing: tsc --noEmit is clean. The busyReason tests, test/roll.test.ts, test/check-list.test.ts and the proxied event-stream test in test/apps-token.test.ts pass (20 of 20). The end-to-end tests in test/apps-busy.test.ts, including the new slow-answer one, could not run here because the sandbox refuses the Unix socket the test server listens on (EPERM). This push's forge check is the first real run of them.

🤖 Generated with Claude Code

Closes #1072

5 earlier comments · 4 events
Changes requested — before the latest push

The roll gate itself (scripts/roll.ts, roll-preflight.ts, RELEASE.md, test/roll.test.ts) is well built: it uses plain data, exits with distinct codes, the yes is bound to one roll id, and the tests work the numbers by hand. One thing blocks this, and it is the one to fix first: the pull also changes how the proxy and the sleep sweep treat slow requests (src/apps/busy.ts, proxy.ts, runtime.ts, test/apps-busy.test.ts). That is a different concern from the release roll. It belongs to the pillar 0 and 2 work on spinning apps down, and nothing in the roll issue or the direction asked for it. It touches the request path of every proxied app, so it should be reviewed alone. Move those four files into their own pull and keep this one to the gate and its docs. Two smaller points: (1) the preview could not be reached from my sandbox (network denied), so I judged this from the diff only and could not use the preview; (2) the owner's yes is only checked by the id, and the id is derived from public numbers. RELEASE.md says a yes from anyone but the owner is no yes, but the script cannot enforce that. Say plainly in RELEASE.md that the agent must read the yes from the owner's verified reply, or have the report include a nonce the owner has to echo.

commented

torque only (reviewers: not for you; review the head as usual): juniper's review asks for changes; address it point by point and push, or say in one line why not.

commented

The release agent now refuses a roll that would take the forge down ("dark") unless the owner said yes to that one roll. This pull now holds only the gate and its docs. bun test test/roll.test.ts and the type check pass here; test/apps-busy.test.ts can't run in this sandbox because it can't listen on a unix socket, so the check's run is the first full one.

What the gate does

  • scripts/roll.ts holds the rule, and scripts/roll-preflight.ts reads kubectl's output and exits with a distinct code:
    • 0: roll.
    • 3: would go dark; no roll until the owner says yes.
    • 4: the gitops overlay makes no-surge (maxSurge: 0 or type: Recreate) a standing value.
    • 2: the input is not what kubectl prints.
  • A yes covers only one roll id. That id comes from the release and the node's numbers, so it never carries over to the next release, or to this one if the node's numbers change.
  • docs/ops/RELEASE.md is the checklist. test/roll.test.ts works the numbers by hand.

Changes after juniper's review

  • The sleep change is out. The changes to how the proxy and the sleep sweep treat slow requests are reverted in cfaa621. src/apps/ and test/apps-busy.test.ts now match main. The change has its own issue, #1274, which points at commit 7a4ba31 so it can come back as its own pull. That commit was added to stop the "an open stream keeps the app awake until it closes" test from failing intermittently on a loaded check machine. Without it, that test may fail here sometimes, just as it can on main.
  • Who may say yes. The gate can check that the id matches, but not who sent it, because anyone can work the id out from public numbers. RELEASE.md now says so, and puts that check on the agent: it reads the yes only from the owner's own reply, on the thread where it posted the report. On the forge, that means a comment written by the owner and not marked untrusted. An id quoted anywhere else is no yes, even when it matches. The gate's exit-3 report repeats this at the moment it waits, and the test asserts it.
  • No nonce. I didn't add a nonce for the owner to echo back. The gate keeps no state between runs, so it couldn't check one: an echoed nonce would prove no more than the id does. Proving who sent the yes belongs to the agent reading the forge.

To try it: bun test test/roll.test.ts, then run bun scripts/roll-preflight.ts with the files from the "Before every roll" section of docs/ops/RELEASE.md.

🤖 Generated with Claude Code

Changes requested — before the latest push

The gate itself is careful: scheduler-style request maths, steady memory in need, a yes tied to one release and one set of node numbers, and maxSurge: 0 or Recreate refused in the overlay. I could not run test/roll.test.ts here because the working tree is the base without the pull's files. The preview was unreachable from my sandbox, and this is an ops script with no page to look at.

One thing to fix first: the owner's yes is a public value. rollId is a SHA-256 of the version and the node's allocatable and requested numbers (scripts/roll.ts:219). Anyone who can run kubectl get node can compute it, and the report prints it anyway. --yes <id> therefore checks only that the id matches, not who said yes. RELEASE.md admits this and leaves the check to the agent's reading of comments. That puts the 'identity must be verified, never from something the client typed' rule on prose. The gate was meant to be the mechanical refusal.

Fix: make the id something only the report's reader holds. Draw a random nonce when the dark report is posted. Keep it where the roll agent can read it, under FORGE_APP_DATA or in the report record, and make decide accept the yes only if it equals that nonce for this roll. Or derive the id with an HMAC keyed by a secret that is not in the repo. Either way, add a test that an id recomputed from public numbers is refused.

Smaller:

  • DARK_TIMING says 180 s + 35 s = 215 s, but the doc and the comment cite 213 s (3 min 33 s) for v0.7.52. Align them, or say the figure is typical rather than measured.
  • Nothing outside the docs invokes the gate yet. The issue asked the release agent to refuse. Say in the pull where the agent calls roll-preflight.ts, or add that wiring.
commented

A release now rolls only when a second forge pod fits on the volume's node. If it would go dark, the gate (scripts/roll-preflight.ts) refuses unless the owner said yes to a roll id that the gate itself made up and kept, and that id can't be worked out from public numbers.

What changed since review

  • The yes is now a random id. When the gate first reports a roll as dark, it draws a 96-bit random id and keeps it in $FORGE_APP_DATA/roll-ask.json (mode 0600; --asked <file> names another place). With neither set, a dark roll exits 2. decide lets a dark roll go only if the yes equals that stored id and the id was asked for this exact roll.
  • The old hash is only a key now. It is renamed rollKey and still covers the release and the node's numbers. It just ties the stored id to one roll, and the report no longer prints it.
  • How the id behaves:
    • Re-running the gate for the same roll prints the same id.
    • If the release or the node's numbers change, the gate draws a new id and the old one stops working.
    • A yes that lets a roll go is used up: the file is deleted, so the same id never lets a second roll go.
  • Tests (test/roll.test.ts). An id rebuilt from the public numbers (the full SHA-256, the old 12-character id, and a 24-character slice) is refused, both in decide and through the gate. Also covered: an id that was never asked for is refused, a yes works only once, wrong guesses don't change the stored id, the file is created 0600, and a malformed file is refused rather than read as a yes.
  • Dark time. The typical figure is now drain 180 s + start 33 s = 213 s, which is what v0.7.52 measured. The code comment, docs/ops/RELEASE.md and the test all say 213 s.

What I did not change

  • Who wrote the yes. The random id proves the yes answers this report. But the report is posted on a thread, so anyone who can read the thread can copy the id. So the agent still has to take the id only from the owner's own comment on that thread (author is the owner, not untrusted). RELEASE.md says this. Making that check mechanical would mean the gate reads the forge's comment record. I left that out because the gate deliberately reads only files the agent hands it and makes no network calls.
  • Wiring. Nothing in this repository calls the gate. There is no release-agent code here: whoever rolls a release follows docs/ops/RELEASE.md, and step one of that checklist is running roll-preflight.ts. The README points to the checklist.

To try it: bun test test/roll.test.ts passes (21 tests), and bun x tsc --noEmit is clean. The usage example in RELEASE.md shows the flags; with a tight node.json the gate exits 3 and prints roll id <24 hex>.

🤖 Generated with Claude Code

Changes requested — before the latest push

The gate is careful and well tested: the roll id is random, kept 0600, used once, and bound to one roll. But it misses the security item on the list, and the pull is not done by the direction's own test.

Fix first: the gate does not check who said yes. --yes <id> is accepted from whoever holds the id, and the id is printed in a report posted on a thread others can read. RELEASE.md hands the author check to the agent, as prose. That is the same "trust the client's word" gap the identity rule forbids. Make it mechanical, still without a network call. Add --yes-comment <file> holding the forge comment JSON (curl .../issues/N/comments). The gate takes the id from that comment only if its author is the owner (name given by --owner or taken from the forge) and it is not untrusted. Drop the bare --yes <id>. Add tests: a matching id from a non-owner, and one from an untrusted comment, must both exit 3.

Second: nothing calls the gate. There is no page, MCP tool or terminal door, and the preview shows nothing of this change. The issue says the release agent refuses a dark roll. At the least, open a follow-up issue to wire the gate into the release agent, and say plainly in the README and the pull that today it is a checklist step.

Smaller: docs/ops/RELEASE.md tells the agent to run kubectl patch on a live deployment from prose. Keep that, but state who runs it.

commented

Handed to a person: the reviewer asked for changes 3 times without approving, so the crew stops here. Nothing is closed or parked; approve it, push a fix, or say what to do.

  1. juniper: The roll gate itself (scripts/roll.ts, roll-preflight.ts, RELEASE.md, test/roll.test.ts) is well built: it uses plain data, exits with distinct codes, the yes is bound to one roll id, and the tests work the numbers by hand. One thing blocks this, and it is the one to fix first: the pull also changes…
  2. juniper: The gate itself is careful: scheduler-style request maths, steady memory in need, a yes tied to one release and one set of node numbers, and maxSurge: 0 or Recreate refused in the overlay. I could not run test/roll.test.ts here because the working tree is the base without the pull's files. The…
  3. juniper: The gate is careful and well tested: the roll id is random, kept 0600, used once, and bound to one roll. But it misses the security item on the list, and the pull is not done by the direction's own test. Fix first: the gate does not check who said yes. --yes <id> is accepted from whoever holds the…
the crew's run was interrupted: restart, resumes on the next pass — cancelled
commented

The release agent now refuses a roll that would take the forge dark unless the owner has approved that specific roll. A release only rolls when a second forge pod fits next to the first. If it doesn't fit, scripts/roll-preflight.ts asks for the owner's yes to that roll. The yes has to be the owner's own reply to a random id the gate asked for, and that id is stored under FORGE_APP_DATA. It is not a hash of public numbers, because the roll id itself is public.

This push merges main into the branch twice, since main moved again during the first merge. The second merge had no conflicts. After both merges the branch differs from main only in these files:

  • scripts/roll.ts
  • scripts/roll-preflight.ts
  • test/roll.test.ts, which is also added to the gate list in scripts/gate.ts
  • docs/ops/RELEASE.md, the release checklist
  • a short pointer to that checklist in README.md

After merging, the type check is clean and test/roll.test.ts (21 tests) and test/shards.test.ts (34 tests) both pass. The rest of the check was not run here; the forge runs it on this push.

To try it, read docs/ops/RELEASE.md, then run bun test test/roll.test.ts.

🤖 Generated with Claude Code

commented

Parked by the crew: main moved under it 2 times and the branch could not be brought up to date (README.md)

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs