Skip to content

Interactive threads IT-1: a live session per thread, the session wall, signed owner turns, the ref check - #1006

Draft
hhff wants to merge 8 commits into
mainfrom
operator/it1-interactive-sessions
Draft

hhff wants to merge 8 commits into
mainfrom
operator/it1-interactive-sessions

Conversation

@hhff

@hhff hhff commented Dec 5, 2026 •

Copy link
Copy Markdown
Member

Implements ticket IT-1 of the approved design "interactive threads" (claude-in-a-thread.md rev 10.2, plan head 4dbe951d) in sanctuarycomputer/devteam-dev#840.

Merge condition: devteam-dev#840 merged (done).

What it does (stacked commits)

  1. The session writer class and the role check. A new writer, session-<thread id>, ranked like a ticket. It may write turn, message and observation lines. The kit treats a process as that writer when DEVTEAM_ROLE=session with DEVTEAM_THREAD is set, or when the checkout is on branch session/<t> and no environment is set.
    • thread reply (and --asks) works only in the session's own thread.
    • The session can send the supervisor info messages, and handoffs of its own thread. Nothing else.
    • supervisorOnly and ownerWriter refuse it.
    • The integrity check and the schema gain asks, routed_session (own thread only) and proof (the owner's own turn and thread lines only).
  2. merge --session <t>: the wall.
    • It runs every gate at the exact head and refuses --approved and --no-gates.
    • It refuses the protected set: kit folder, root dotfiles and scripts/, agent instructions, manifests and lockfiles, test-runner config and setup files, flaky lists, forge, bot and CI config, lint, type-check and format config, deploy config, secret files, gate-named paths, and a deleted test.
    • Where the repo has CI, every check the forge reports on main's head (less ignored_checks) must report green at the PR's head. A green preview or bot status never stands in for the rest, and a head with none reported is refused. Checks from outside .github/ count. CI files and folders count too: .github/workflows/, .circleci/, .buildkite/, .woodpecker/, Jenkinsfile, *-pipelines.yml, cloudbuild, .gitlab-ci.yml, .travis.yml, .drone.yml and appveyor. On forge git, a repo with CI refuses session PRs.
    • A commit on the PR whose message has a skip-ci marker ([skip ci], [ci skip], [no ci], [skip actions], skip-checks: true) is refused.
    • A path a gate's command names is protected: any word of the command that is a file in the tree, with or without ./, as the program or as an argument (./gradlew, sh ./run-tests, node tools/x.mjs). A word names a folder only when it reads as a path, so npm test doesn't protect test/. Build-tool config is protected too: vite, webpack, rollup, esbuild, tsup, babel, next, nuxt and svelte config, and .babelrc.
    • The diff is taken against the main sha read from the forge just now, not the local tracking ref.
    • It refuses while a ticket PR that is up to date with main has a final review at its head or an open merge-request, for at most 30 minutes after the update.
    • New act class merge-session, one of the kit's own act classes (KIT_ACT_CLASSES in devteam.mjs, added to the ladder's constitutional list where it is read). If the owner's constitution places the class anywhere, as owner-only or on the ladder, that placement wins. governance/constitution.md is untouched.
  3. Every branch is pushed from its owner's worktree. merge (every kind) and pinRecords refuse a branch whose origin tip isn't this box's local ref. One exception: origin's tip is that ref brought up to date with main the forge's way, meaning each step is one clean two-parent merge of main, with main read by ls-remote.
  4. Signed owner turns, the widened finding, and the thread sessions.
    • Gateway signing. ownerTurnSignature (devteam-owner-turn-v1\n<port>\nowner\n…) signs /api/thread-say and /api/thread-new, for the box's owner only. upstreamHeaders now drops any x-devteam-gateway-* header a client sends.
    • Checking the signature. The dashboard passes the signature on stdin. thread say and thread new check it against this press and this dashboard, accept each nonce once, and store the proof on the line.
    • Binding a turn. thread ask --turn <u> --paths <p,…> records one path list on the question line. answer --from-turn on such a question needs --said, re-checks the proof at the turn's own time, and refuses an unsigned, forged or off-box turn.
    • merged-without-merge now reads merge-session acts. Where every landing is a merge commit (forge git, or merge_method merge), it also raises any non-merge commit on main's first-parent line, i.e. a push to main.
    • Settings: owner_sessions (default true, as the design has it; false is the off switch), session_idle_minutes (20) and session_max_live (2), with validation.
    • The orientation prompt: docs/devteam/process/thread.md and prompt thread --thread <t>. User-facing words say "thread" ("this thread's agent"); internal names stay DEVTEAM_ROLE=session, session/<t>, merge --session and the session writer class.
    • Session commands: session start|stop|resume|state --thread <t> (start, stop and resume: the supervisor's, or the owner's own terminal, from home's own checkout; never another role or a worktree's environment) runs the session in tmux window session-<t>, worktree .worktrees/session-<t>, branch session/<t>. On Claude Code, the session's deny rules are added on top of worker_denied_commands: git update-ref*, git branch -f*, and git push to ticket/*, plan/* or chore-*.
    • Routing rule 3: owner turns, artifact notes included, go to the thread's own session unless that session is overdue.
    • Delivery starts or wakes the session. A session whose pane is still at a shell prompt within 2 minutes of its launch counts as starting: live and busy, so a turn then is held and never types a second launch. A turn for a session that is starting or busy is held. Busy means the busy marker is on screen, or the pane printed output in the last 10 s. A held turn is typed after 2 minutes at most, or as soon as the owner's next turn releases it.
    • The held-turn timer. When a turn is held, a detached session watch --thread <t> starts (one per session, by a heartbeat file under run/session-watch/). It checks every second and types the held turns once the session is idle (no busy marker and 10 s of silence) or at the 2-minute limit. It exits once nothing is held. The owner's next turn and the accounts tick still flush as before, as a backstop.
    • The cap: session_max_live live sessions, plus one more while every live session is mid-task.
    • A start is marked for as long as it runs (run/session-start/<name>.json, 20 minutes at most), worktree_setup and agent_trust_command included, outside the short launch lock. A turn during a slow setup is held at once ("it is starting"), never a second start. A start in progress holds its place in the cap.
    • A setup that fails is written in the thread ("This thread's agent couldn't start: …"), the command exits 0 with its turn written, and the next start runs worktree_setup again (its marker) and starts the agent afresh. Only a worktree whose agent was launched (run/session-launched/<name>) is resumed.
    • No room (the hard ceiling, a drained or parked fleet, memory at its ceiling): the turn is held, a line in the thread says it waits, the send says "waits for this thread's agent: …", and the tick starts the session once there is room; its watcher types the turn. A held turn is never typed into a pane still at its shell.
    • Sleeping uses the worker suspend checks: a session is put to sleep (cap, idle tick, off switch, session stop) only when paneIdleAtPrompt holds and paneAgentChildren is 0; one starting never; one whose agent exited may be closed. session stop on one that isn't idle says it is kept.
    • Another harness: with resume_command at the kit's (Claude Code's) default and an agent_command that isn't Claude Code, the session restarts with agent_command, never claude --continue.
    • The pool slot. Each live session holds a worker slot toward max_active_tickets. This shows in ready ("N live thread sessions among them", and thread_sessions in --json), next-step's "Waits for a worker slot", metrics' idle-capacity finding and the auto-start's room check. An asleep session holds none. The ceiling's extra session therefore takes the slot the next ticket would have started in.
    • The tick puts idle sessions to sleep, and all of them when owner_sessions is off. It removes an asleep worktree 7 days after its last start, sleep or thread turn (so a window that died unslept is bounded too), once its branch is pushed.
    • Closing a thread removes its worktree once the session is done: its PR merged (a merge-session act at the branch's tip), everything on its branch already on main, or (on GitHub) its PR closed unmerged with no open one (abandoned). This is judged on the worktree itself: a detached HEAD or one on another branch, a tip origin doesn't have, uncommitted or untracked work, or ignored files outside worktree_files, worktree_copy and common dependency and build folders each keep the worktree. With forge git, a branch with unmerged work is never treated as abandoned; it waits for the 7-day limit.
    • The page's words (dashboard and its app copies): the send's "sent to / held for / waits for / couldn't start" for this thread's agent read as plain card lines ("Held for this thread's agent: it is starting…", "Waiting: … Your words reach it once there is room."), and a landed turn routed to session-t-… is named "this thread's agent", never its raw id.
    • IT-S1/IT-S2 measures. metrics gains latency.thread_sessions, also printed in its text. It covers the last 50 answered owner turns routed to their thread's own session: from the turn to that session's first reply, split into warm (IT-S1, target p50 ≤ 10 s, p90 ≤ 30 s) and cold, where the turn started or woke the session (IT-S2, target p50 ≤ 30 s, p90 ≤ 60 s). It also counts turns still waiting.
    • quality.md: the §3 and §4 text from Q2.
  5. Seams for IT-3, and CI fixes.
    • cmdMerge's role check is now mergeRoleCheck(): still supervisorOnly('merge'), the one place IT-3 opens for merge --session <own t> --turn <u>. Until then --turn is refused by name ("IT-3 of devteam-dev#840, not in this kit yet"), never ignored.
    • ownerTurnSignature (gateway) and ownerTurnSigned (kit) take an optional list of extra fields, bound into the signed bytes after the role, so IT-3 can add its merge: field. With none, the bytes are the v1 bytes unchanged (tested).
    • The split overlay's IMAGE_RUNS override lists ownerTurnSigned and ownerTurnProofProblem and is re-pinned; G1's goldens are re-recorded (the three new settings, the merge-session label, and two push-to-main findings the G1 fixture's own direct commits cause).

Departures from the design, and why

  • The test fixtures made by init set owner_sessions: false (fleetFixture, bareProject, the machine fixture). Their tests check routing as it was before thread sessions, and with the setting on, the default agent_command (a real Claude Code) would be started in them. The interactive-sessions tests turn it on.
  • merge-session is a kit act class, not a constitution entry. It is in KIT_ACT_CLASSES, which ladder() adds to the constitutional list it reads. Any act class needs to be on that list to count as the supervisor's own act, and constitution.md is governance, so this way needs no governance edit.
  • A thread session counts as live while it is starting: its pane is still at a shell prompt within 2 minutes of its launch. Without this, a second turn sent during a slow start would type a second launch (CI caught this).
  • The proof is kept on the turn line only if the line still fits LINE_MAX (4096 bytes). A 2000-byte turn plus its base64 body can exceed it. When it doesn't fit, the kit warns and keeps the turn unsigned, so it falls back to the Inbox. Nothing is ever signed wrongly.
  • The ref check also accepts a local ref that is merely ahead of origin (commits not pushed yet). Origin's tip is then an earlier state of the owner's own branch, so nothing on it came from elsewhere. test/multirepo-home.records.test.mjs has a case where the records worktree pushed, then reset itself. That case is now refused by the ref check instead of by the records verdict, and its assertion is updated.
  • The widened merged-without-merge runs only where every landing is a merge commit. With squash or rebase, a landing is a single commit that no act names by its sha. There, only merges are read, as before. Three existing tests filter out the new push-to-main findings that their own fixture setup commits cause: multirepo-landing, multirepo-home.worker and multirepo-home.records. It is raised only for commits after the check reached main (upgradeAt).
  • The prompt tells the session to hand a ready PR to the supervisor with send supervisor --kind handoff. It does not use session land --pr, because that command and the land message kind are IT-3.
  • The session's Claude Code policy applies when agent_command names claude by name or by path (/^(\S*\/)?claude/). This applies to sessions only; workers are unchanged.
  • The held-turn timer is a short-lived detached process (session watch), not a timer inside the dashboard. The kit already starts its detached work this way (the auto-start's worker launch). It needs nothing running beyond the turn that held the line, and stops when nothing is held.
  • "Abandoned" means a PR closed unmerged on GitHub. With forge git there is no PR state to read, so a closed thread whose branch still has unmerged work keeps its worktree until the 7-day asleep limit removes it. The branch is never lost either way.
  • A check that main's head reports but that never runs on a PR (a push-only deploy job, a path-filtered workflow) blocks session PRs until the owner lists it in ignored_checks. That is the safe side of "every check green". The refusal names the check and says so.
  • The pool slot is the project's max_active_tickets slot. The box-level pool.json (pool@1) has no writer in the kit to add sessions to; its workers list is unchanged.
  • The measures read the last 50 answered session-routed turns whenever they were. They don't wait for IT-4 or keep the 2-week window; that reporting cadence is the supervisor's.
  • Spin-down has its own small tick (threadSessionsTick) and its own worker-slots acts (made|resumed|slept session …). It does not run through sessionMarks and holdForSuspended, which are tied to the worker and planner roles. A turn for an asleep session wakes it directly.
  • Release paths are not treated as command-named paths in the protected set: the release setting has no command to read them from.

Left undone (listed, not cut silently)

  • The hub's own window count (ourWindows) doesn't yet tell thread sessions from workers; the project's ready/metrics/auto-start counts do.

  • Warm or cold is decided from the session's state at the turn; a session put to sleep between the turn and its typing counts as warm.

  • The live/asleep/closed badge on the thread is IT-2's ("the thread's state badge" in IT-2's row). Here only session state --thread <t> shows the state.

  • IT-2 and IT-3 parts mentioned near IT-1 in the text:

    • the owner's floor on session panes and the Terminal tab (IT-2);
    • session land, start/land/close messages, the owner's-word merge --chore --approved paths refusal, and the matching quality.md §4 and supervisor.md §5 paragraphs (IT-3).

Tests

New:

  • test/interactive-sessions.roles.test.mjs: the writer class and the role check, by role and by session/ worktree; --asks; send rules; the integrity cases.
  • test/interactive-sessions.wall.test.mjs:
    • the protected set (a test per group, CODEOWNERS, a gate's script, a deleted test);
    • --approved and --no-gates refused; --turn refused as IT-3's;
    • a failing gate and no gates;
    • forge git with a workflow;
    • GitHub with a stand-in gh: checks from outside .github/, none reported refused, green passes, no CI passes;
    • the queue rule: an update just made, the 30-minute bound, a merge-request, a records PR.
  • test/interactive-sessions.pushed.test.mjs:
    • refused: a pushed chore commit, a moved ref, a pushed review record, a record pushed to home's ticket/<id>;
    • accepted: a local ref ahead of origin, an update-branch merge;
    • refused: an edited merge, an octopus, a conflicted merge.
  • test/interactive-sessions.signed.test.mjs:
    • a signed turn kept and validated; a press reused;
    • signatures refused: another key, another press, another dashboard, too old, a Settings Save signature;
    • thread ask --turn --paths and answer --from-turn --said;
    • refused: a path outside the repo, an unsigned turn, ask --paths without --turn;
    • re-checked at answer time: a turn signed 10 minutes earlier passes; another key, other words, no proof, another thread, a reused nonce and off-box are refused;
    • the widened merged-without-merge on a push to main.
  • test/interactive-sessions.sessions.test.mjs (tmux, a stand-in agent):
    • the settings validate; prompt thread renders;
    • the first turn routes to and starts the session (worktree, branch, act, deny rules); while its agent is still starting (a stand-in that waits in shell builtins) the session is live and a second turn is held, with one launch only;
    • the timer: held turns are typed once the session is idle, with no turn after them; the next turn follows, in order;
    • IT-S2: the reply after a turn that started the session is measured cold, with the targets;
    • the cap and the hard ceiling (the first session kept busy explicitly, so it doesn't depend on timing); each live session holds a worker slot (ready, ready --json);
    • stop/asleep and resume with resume_command;
    • a worker refused, and so is the supervisor's role in a worktree's environment; the tick sleeps every session when owner_sessions is off;
    • closing the thread removes its worktree once nothing on its branch is unmerged.
  • test/interactive-sessions.wall-ci.test.mjs (new, from review a):
    • every main check must be green at the head: a preview alone, missing and failing checks refused; all green passes; an ignored check needn't report;
    • each skip-ci marker refused;
    • a gate's script named as ./gradlew, ./check, node tools/lint.mjs and sh run-tests; npm test naming no folder;
    • .circleci/ counted as CI; build-tool config refused;
    • merge-session constitutional by default, and the owner's owner_only winning.
  • test/interactive-sessions.start.test.mjs (new, from review b): a slow setup held past the 10 s lock bound with a turn meanwhile held at once and one launch; a failed setup said in the thread, exit 0, then set up again and made afresh; another harness resumed without claude --continue; memory at its ceiling: the turn waits, said in the thread, and the tick starts it once there is room; a dead window's worktree removed 7 days after the thread's last turn.
  • test/interactive-sessions.card.test.mjs (new, from review b): the send parser and the card's plain lines for this thread's agent (sent, starting, at work, waits, couldn't start, landed, overdue), never a raw id.
  • test/interactive-sessions.sessions.test.mjs gains (review b): the hard ceiling now waits, said in the thread, and the tick starts it once one is idle; a session running a quiet child process at its prompt is never put to sleep; close cleanup keeps a detached HEAD and ignored work.
  • Each review-b test was run against the kit before the fix (0072696) and goes red there, except the another-harness case, which was not run red: the old kit would type a bare claude --continue into the fixture's pane.
  • test/auto-start.rules.test.mjs (new case): live thread sessions fill the cap with the workers, and the refusal names them.
  • test/gateway-terminal.test.mjs (new case): the owner's turns are signed under devteam-owner-turn-v1 with the role in the bytes; a full-level non-owner's turns go unsigned, with their forged headers dropped.

Updated: test/multirepo-landing.test.mjs, test/multirepo-home.worker.test.mjs, test/multirepo-home.records.test.mjs, test/multirepo-home.left.test.mjs (a local ref reset behind origin is now refused by the ref check; the case then deletes the local ref so the PR head alone decides, as before), test/session-threads.test.mjs (the integrity message names the thread's own session; its split overlay copy and ledger entry follow), test/dashboard-data.test.mjs (settings 71 → 74, value-kind 54 → 57), test/lib/kit.mjs and test/lib/machine-fixture.mjs (sessionsOff), test/fixtures/g1/* and test/split/overlay/apps-serve/overrides/IMAGE_RUNS.mjs.

Run here (on the box, through the test slots, DEVTEAM_BOX=off, own hub port): every file above, plus the merge, records and session-thread files near the change. On this box, gateway-terminal (A9), owner-setting.page (cases 2–4) and compound-box.files fail on an untouched origin/main in the same way, because of the box's own hub. CI runs the whole suite.

Could not be tested here:

  • a real Claude Code, OpenCode or Codex session behind a thread;
  • the gateway → real box dashboard → thread say path end to end (the gateway's signing and the CLI's checks are tested separately, and the dashboard's forwarding of the headers is not covered by a test);
  • the idle spin-down after session_idle_minutes (1 minute at least), and the 7-day removal of a slept session (the dead-window case is tested with a turn written 8 days back);
  • the drain and park holds at start (the memory hold is tested; they share its path);
  • the busy-marker hold and the 2-minute limit on a live agent (the timer is tested through the 10 s silence);
  • the merged and abandoned (GitHub PR closed) paths of the close cleanup; only "everything on main" is tested;
  • IT-S1's warm measure end to end (the split is tested through the cold case).

Opened by the box operator.
🤖 Generated with Claude Code

hhff and others added 6 commits December 5, 2026 01:34
An owner thread's own agent session writes as session-<thread id>, a class
of its own with a ticket's rank (x-authority). It replies in its own thread
only (--asks for a clarifying question), hands that thread to the
supervisor, and sends nothing else. logWriter, sessionBranch and
supervisorOnly learn session/ branches and DEVTEAM_ROLE=session; ownerWriter
refuses DEVTEAM_THREAD too. The integrity check and the log schema hold a
session's lines to its thread and accept proof on the owner's own turn and
thread line only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A thread session's PR (branch session/<t>, home only) merges with no spec,
plan or review records, held instead to: every gate in a clean worktree at
the exact head (no --no-gates, no gates no landing), the log rule, a
protected set no --approved lets through (the kit's folder but artifacts,
root dotfiles and dot-folders, root scripts/, agent instructions, manifests
and lockfiles, test-runner config and setup files, flaky lists, forge/CI
files, lint/type/format config, deploy config, secret files, any path a
gate's command names, and no deleted test), the forge's checks reported
where the repo has CI, and only between ticket merges: an up-to-date ticket
PR with a final at its head or an open merge request holds it, for 30
minutes at most. Logged as a merge-session act (constitutional).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
merge (every kind) and pinRecords refuse a branch whose origin tip isn't
this box's local ref, unless origin's tip is that ref brought up to date
with main by the forge (one clean two-parent merge of main per step,
main read with ls-remote) or the local ref is merely ahead (not pushed
yet). Tests: a pushed chore commit, a moved ref, a pushed review record,
a record pushed to home's ticket/<id>, an update-branch merge accepted,
an edited, three-parent or conflicted merge refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d sessions

Signed owner turns: the gateway signs the owner's /api/thread-say and
/api/thread-new (ownerTurnSignature, devteam-owner-turn-v1, the signer's
role in the bytes) for the box's owner alone, and drops any signature
headers anyone sends; the dashboard puts the signature on thread say's
and thread new's stdin; they check it for this press and dashboard, take
its nonce once and keep it on the turn (and thread) line when the line
fits. thread ask --turn --paths binds such a turn and the exact paths on
the question line; answer --from-turn on that question needs --said and
re-checks the proof at the turn's own time, refusing an unsigned, forged
or off-box turn.

merged-without-merge reads merge-session acts, and where every landing
is a merge commit (forge git, merge_method merge) raises any commit on
main's first-parent line that is no merge (a push to main).

Thread sessions: owner_sessions (off while IT-1 lands dark),
session_idle_minutes, session_max_live; process/session.md and prompt
session --thread; session start|stop|resume|state --thread; routing rule
3 to the thread's own session, artifact notes included, unless overdue;
delivery started or woken by the turn, held while it starts or is busy
(busy marker or 10 s of output), typed after 2 minutes at most, released
by the owner's next turn; the live cap and its hard ceiling; the tick
sleeps idle ones (and all with owner_sessions off) and removes an asleep
worktree after 7 days once its branch is pushed; the session's deny
rules on top of worker_denied_commands. quality.md §3 and §4 (Q2).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… thread wording; seams for IT-3; CI fixes

- process/session.md becomes process/thread.md, rendered by `prompt thread --thread <t>`;
  user-facing words say "this thread's agent"
- cmdMerge's role check is mergeRoleCheck(), the seam IT-3 opens for merge --session --turn;
  --turn is refused by name until then
- ownerTurnSignature/ownerTurnSigned take optional extra fields after the role (IT-3's merge:);
  none signs the v1 bytes unchanged
- a session whose agent is still starting (pane at a shell within 2 minutes of launch) is live
  and busy: a turn then is held, never a second launch typed
- tests: the starting race, the --turn refusal, the fields seam; the same-second race in the
  push-to-main test; the left test, session-threads message, dashboard-data counts, the G1
  goldens and the split IMAGE_RUNS override follow the change

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ol slot, held-turn timer, close cleanup, IT-S1/S2

- owner_sessions defaults to true, as the design has it (false is the off switch); the test
  fixtures made by init (fleetFixture, bareProject, the machine fixture) set it false, since their
  tests read the routing before thread sessions
- merge-session moves out of governance/constitution.md into the kit's own KIT_ACT_CLASSES,
  added to the ladder's constitutional list where it is read; constitution.md is untouched
- a live thread session holds a worker slot toward max_active_tickets: ready (and --json
  thread_sessions), next-step's waits-for-slot, metrics' idle-capacity and the auto-start
- a turn held for a session gets a timer: session watch, started detached, types it once the
  session is idle (busy marker, 10 s of silence) or at the 2-minute bound
- a closed thread's worktree is removed once its PR is merged, its branch is all on main, or its
  PR was closed unmerged (abandoned); work not on origin, or uncommitted, keeps it
- metrics' latency gains thread_sessions: IT-S1 (warm) and IT-S2 (cold start or resume) first
  replies over the last 50 session-routed owner turns, with their targets

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hhff

hhff commented Dec 5, 2026

Copy link
Copy Markdown
Member Author

PR #1006 review a: IT-1 walls hold for refs, signing and roles; the wall misses ./script gate files and a CI check any one status satisfies

  • Reviewer: operator-review-a (fresh subagent, claude-opus-5-5), not the author
  • Head: 38380f6
  • Date: 2026-12-05T08:10Z

What I ran vs only read

Read: git diff origin/main...HEAD (all of devteam.mjs, cloud/gateway.mjs, log.schema.json, process/thread.md, quality.md §3/§4), and the code it calls: claudePolicy/deniedFor, dashboardProofProblem, forgeCheckFails, cmdMerge (fetch order, flags, forge-git landing), the dashboard's owner-action origin guard, and the design's "The wall", "Who may do what" and IT-1 row (claude-in-a-thread.md rev 10.2).

Tests, through testslot, one file at a time, --file-timeout 900, DEVTEAM_BOX=off, own hub port, working set 37 to 43 GiB:

File Result
interactive-sessions.wall 8/8 pass
interactive-sessions.pushed 4/4 pass
interactive-sessions.signed 8/8 pass
interactive-sessions.roles 12/12 pass
interactive-sessions.sessions 7 pass, 4 fail, twice (subtests 7 to 9: the cap, stop/resume, owner_sessions off). See Notes: it is timing on a loaded box, not the code
gateway-terminal 10 pass, 1 fail: A9 only, the known box failure the PR names. The IT-1 case passes

Probe (a scratch test, not committed): gates { test, grad: 'sh ./gradlew check' }, main has gradlew. A session PR that rewrites gradlew to exit 0: merge --session <t> --dry-run exits 0 (F1).

Mutations (each restored after):

  • gateway: drop isOwner(person) from the owner-turn route: gateway-terminal's IT-1 case goes red.
  • integrity: drop the turn/thread proof rule: roles subtest 11 goes red.
  • signedTurnProblem: drop the twin-nonce check: signed subtest 5 goes red ("a nonce reused").
  • pushedFromOwnerFails: drop the merge-tree exit-status check: pushed subtest 2 goes red. The conflicted merge is still refused, by the tree comparison, so only the message changes. Two layers, and that is fine.
  • sessionWallFails: drop the deleted-test check: wall test "the protected set" goes red (7 pass, 1 fail).

CI at the head: box-image, test and test-stress all succeeded.

Findings

Id Severity Rule Where Finding
F1 Important design "The wall" item 4; quality.md §4 ("any file a gate's or release's command names") devteam.mjs sessionGateNamed defect: the leading ./ is removed before the /[./]/ filter, so a gate's extensionless script run as ./gradlew, ./mvnw, sh ./run-tests or ./check is never named. A session PR can rewrite that script to exit 0, and the gate it is meant to answer to then passes with no review. Shown by the probe above. Fix: decide the path test before stripping, e.g. keep any word that began with ./. The cat-file -e existence check already keeps out words like npm. Add a test case for it.
F2 Important design "The wall" bullet 1 ("needs the forge's checks green where the repo has CI"); quality.md §4 devteam.mjs cmdMerge session block (ci.ci && !(pr.statusCheckRollup …).length) defect: one reported check is enough. A session controls its head commit message, and [skip ci] there stops GitHub Actions from making any pull_request runs. Any other status still reports: a Vercel or Netlify preview, a bot, an external CI. The rollup is then non-empty and green, forgeCheckFails passes, and the PR lands without the repo's CI having run. A partly reported head (a fast external check green, Actions not yet queued) gets through the same way. Fix: on a repo with CI, require each check name the forge reports on main's head (less ignored_checks) to be present and green at the PR head. This is from reading the code: it can't be probed without GitHub.

Notes

Minor and Suggestion items (non-blocking):

  • harness: interactive-sessions.sessions "the cap" depends on the first session still counting as busy (output in the last 10 s) when T2 starts. On this loaded box the 10 s pass first, so threadSessionRoom sleeps it as the longest idle (correct behaviour). T2's start then succeeds, and subtests 7, 8 and 9 fail in a chain. It failed the same way in two runs here and passes on CI. Keep the first session busy explicitly, e.g. make the stand-in print every second.
  • cmdSession's guard reads only DEVTEAM_ROLE. A checkout on session/<t> with its environment dropped, or any process without DEVTEAM_ROLE, can session start|stop any thread's session, which writes worker-slots acts as the supervisor. Checking writerClass(logWriter()) as well would close that.
  • The schema text for question.paths says "a chore it approves lands no other path", and process/thread.md says the supervisor "lands only those". Neither is enforced in IT-1: the paths refusal is IT-3's, as the PR says. The wording should say "from IT-3", or say nothing yet.
  • At answer time, signedTurnProblem doesn't re-check proof.port against this dashboard. Another instance on the same box shares the gateway key. The thread id in the signed body makes a cross-instance replay practically impossible, so this is very low risk.
  • ladder() adds merge-session to constitutional even when an owner's constitution.md lists it under owner_only. It should skip a class the owner has placed anywhere.
  • The wall's diff base uses mainRef(), the tracking ref, which any worktree's git fetch can move. checkedMain is already pinned. This is only a race, but merge-base(checkedMain, sha) is the tighter choice.
  • Deny rules (design constants, matching worker parity, not blocking): the list is porous. git fetch . X:ticket/y followed by git push --all moves a ref without update-ref or branch -f. git -C . push … gets past every git push* pattern. A tag push (git push origin vX) is not denied, and the default release: "tag" deploys from tags. Workers have the same openings today, and the design names them as honest limits, but sessions now carry them too.
  • Edges outside the design's lists: .circleci/ isn't a CI signal when main's head reports no checks. vite.config.* (often the vitest config), cypress.json, *_test.go, test_*.py and spec/*_spec.rb deletions are not protected.
  • Checked and found holding:
    • the protected set, every group, CODEOWNERS and CI files outside .github/;
    • deleted tests, with renames read as a delete;
    • --approved, --no-gates and --turn refused;
    • the ref check: exactly two parents, the second on the ls-remote main, merge-tree exit 0 plus tree equality, and the behind/ahead cases;
    • owner-only signing, with x-devteam-gateway-* stripped on every proxied request;
    • the role fixed as owner in the signed bytes on both sides;
    • nonce reuse refused at say time and at answer time;
    • the proof re-checked at the turn's own time;
    • an unsigned turn sent to the Inbox;
    • integrity and schema accept proof only on the owner's turn or thread line;
    • a session can't write as the owner through the CLI (ownerWriter refuses its env, its branch and its worktree) and can't merge (supervisorOnly).
  • Pre-existing limit, unchanged by IT-1: a session, like any worker, can POST an unsigned owner turn to the local dashboard, which says so (kit-324). The signature closes this only on the owner's-word path.
  • Not checked: a real Claude Code session (whether the deny patterns match as intended), and the gateway → real dashboard → thread say path end to end.

Opened by the box operator.

Verdict: CHANGES 38380f6

… the head; skip-ci refused

- sessionGateNamed: any word of a gate's command that is a file in the tree is named, with or
  without ./ (./gradlew, sh ./run-tests, node tools/x.mjs, sh run-tests); a folder only when the
  word reads as a path, so `npm test` doesn't name test/
- a session's PR on a repo with CI: each check the forge reports on main's head (less
  ignored_checks) must report green at the PR's head; a commit on the PR with a skip-ci marker
  ([skip ci], [ci skip], [no ci], skip-checks: true) is refused
- the wall diffs against the main read from the forge (checkedMain), not the tracking ref
- CI folders .circleci/, .buildkite/, .woodpecker/ and .travis/.drone/appveyor files count as CI;
  vite/webpack/rollup/esbuild/tsup/babel/next/nuxt/svelte config and .babelrc are protected
- the owner's constitution wins over KIT_ACT_CLASSES (owner-only or a ladder class stays there)
- session start|stop: the supervisor's from home's own checkout, never a worktree's environment
- tests: interactive-sessions.wall-ci (new); the cap subtest keeps the first session busy
  explicitly instead of relying on timing

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hhff

hhff commented Dec 5, 2026

Copy link
Copy Markdown
Member Author

PR #1006 review b: IT-1's session start races its own setup, the default-on route breaks the thread card, and spin-down kills sessions mid-command

  • Reviewer: operator-review-b (fresh subagent, claude-opus-5-5), not the author
  • Head: 38380f6
  • Date: 2026-12-05T09:15Z

Scope: the session lifecycle, and regressions for existing fleets now that owner_sessions defaults to true. Read against claude-in-a-thread.md rev 10.2 (IT-1's row) and quality.md §1, §3 and §4 at the head. The head moved to 0072696 while I was reviewing. The verdict below is for 38380f6 only. 0072696 does not touch startThreadSession, threadSessionRoom, sleepThreadSession or the session branch of deliver, so from reading alone F1 to F4 still hold there. I did not run anything at 0072696.

What I ran vs only read

Every test ran through testslot nice -n 19 node test/run.mjs --file-timeout 900 <file>, one file at a time. DEVTEAM_HUB_PORT was set to a throwaway port and DEVTEAM_IMAGE_HUB unset. The memory gate was under 70 GiB on every run (34 to 45). The box's load average was 20 to 90 the whole time.

Results:

  • interactive-sessions.sessions: 7 passed, 3 failed. Cases 7, 8 and 9 failed. Case 7 (the cap) depends on 10 s of wall clock: under load the first session looked idle, so it was slept to make room, and cases 8 and 9 failed after it. The same file passed cases 7 to 10 in the M2 run. 0072696 adds a busy stand-in for this case.
  • interactive-sessions.roles: 12 of 12.
  • interactive-sessions.wall: 8 of 8.
  • interactive-sessions.pushed: 4 of 4.
  • interactive-sessions.signed: 8 of 8.
  • auto-start.rules: 20 of 20.
  • session-threads: 23 of 23.
  • multirepo-home.left, .records, .worker: 3, 3 and 4, all passing.
  • multirepo-landing: timed out at 900 s with no test finished. It normally takes about 30 to 40 s. I put this down to load and did not compare it on main.
  • dashboard-data: timed out twice at 900 s. The second run passed tests 1 to 7 first, including "every kit setting" (74 settings, value 57) and the class-words test.
  • gateway-terminal: 10 of 11. A9 failed with 403 ("the terminal answers only on this page"). The PR body reports the same failure on untouched main on this box. I did not re-run it on main.

Probes: a test file of my own in the scratch clone, using threadsFixture, its own tmux server and a stand-in agent. I removed it afterwards.

  • P1, a slow worktree_setup (40 s) and a second owner turn sent once the launch lock was more than 10 s old, while the first thread new was still in setup. The second turn took the lock, saw the worktree and launched resume_command (--continue). Then the first finished its setup and typed export DEVTEAM_HOME=… DEVTEAM_ROLE='session' … and the env -u CLAUDECODE … <agent_command> '<prompt>' line into the running agent's input as text. The log has two acts, resumed session … and made session ….
  • P2, a failing worktree_setup. thread new exited 1 ("worktree_setup failed in …/.worktrees/session-t-…") after its turn line was written, and the worktree was left on disk. After fixing the setup, the next turn launched … --continue in that worktree. Setup was never re-run.
  • P3, session_max_live 1, the first session's agent running a quiet 90 s child process with no busy marker, its turn typed and then 14 s of quiet, then a second thread. The first session was put to sleep ("asleep") and its child process was killed.

Mutations, each restored afterwards:

  • M1: dropped + sessions in autoStartNoRoom and autoStartDecide. The new auto-start.rules case went red.
  • M2: dropped startSessionWatch in the session branch of deliver. sessions case 4 (the timer) went red.

Checked by reading or by hand:

  • The ledger: both sha256 values in test/split/ledger/tests/session-threads.test.mjs.json match the files. The overlay copy differs from the source in exactly the way it does on main.
  • ladder(): it only appends KIT_ACT_CLASSES to constitutional. rungFor reads only classes and their ceilings, so no existing class changes rung.
  • The session watch timer: it exits by end (the hold limit plus 60 s). There is one per session, by a beat file that is stale after 5 s. flushHeld never types into a shell pane, because resolvePane reports a problem there.
  • The busy hold: the 2-minute cap is heldAge > SESSION_HOLD_MAX_MS. The next turn releases everything held, as the PR says.
  • The operator's threads (a separate store and /operator/* routes) are untouched.
  • git worktree remove without --force deletes ignored files and leaves commits made on a detached HEAD dangling. I checked this by hand.

CI at 38380f6: box-image, test and test-stress all succeeded.

Findings

Id Severity Rule Where Finding
F1 Important design "How a turn flows" step 2; PR body ("never types a second launch"); quality §3 (wrong behaviour) devteam.mjs startThreadSession defect: the worktree add and seedWorktree (worktree_setup, through the setup-slot runner, which can wait 15 min) run inside withLock(launch-session-<t>), whose lock goes stale at 10 s. A second turn during a setup longer than 10 s launches resume_command in the half-made worktree. The first start then types its export and launch lines into that agent as text (P1). With Claude Code and bypass permissions, that is a user message asking it to run a nested agent. A failing setup die()s out of thread say/thread new after the turn is written and leaves the worktree. From then on every start treats it as a resume (--continue), with setup never re-run (P2). With the default resume_command (claude --continue) there is no conversation to continue there, so every turn in that thread waits 5 minutes for session-overdue.
F2 Important design Values R2 (no codespeak to the owner); PR body ("user-facing words say 'thread'") deliver words vs dashboard/index.html tCardState (unchanged) defect: the page reads thread say's output with /(the agent on|the planner for)/. "sent to / held for this thread's agent" matches nothing, so typed is false. The page's own send then shows "Not delivered: no supervisor terminal took it. The supervisor sees it only when it next checks…" until the log read lands the turn. After that, sName('session-t-…') falls back to the raw writer id: "Sent to the agent on session-t-20261205-072324175-owner; it replies here.", and after T_WAIT_MS "The agent on session-t-… hasn't replied yet; the supervisor has been told." I checked this by evaluating tCardState from the head's index.html. With owner_sessions on by default, that is every owner turn on every project from the release. index.html is IT-2's file, so either ship the default off until IT-2, or make deliver's words match what the page reads. The PR doesn't state this departure.
F3 Important design "Live, asleep, closed": "Spin-down reuses the kit's suspend machinery"; "the longest-idle waiting (not mid-task) session goes to sleep" threadSessionRoom, threadSessionsTick, sleepThreadSession defect: a session is killed with kill-window after 10 s of pane silence (the cap's room) or 20 min (the tick). Neither path makes the suspend machinery's not-mid-task checks: paneIdleAtPrompt and paneAgentChildren(target) === 0. In P3 a session running a quiet command was slept and its process killed when the owner opened a second thread. On a harness whose busy marker the kit doesn't know (the non-Claude case the design is written for), any command quiet for 10 s is cut off. On Claude Code, a background task is. The departures say spin-down has its own tick, but not that these checks were dropped.
F4 Important design "Live cap": "Past that, the turn waits, with a line in the thread"; PR body "Departures" the session branch of deliver contradicts: at the hard ceiling the turn is written as routed_to: session, and nothing is said in the thread. The only notice is the command's "not delivered: … couldn't start (… the hard ceiling …)", which the page doesn't read: with F2 the card says "Sent to the agent on session-…". The supervisor hears only from session-overdue 5 minutes later. This departure is not stated in "Departures" or "Left undone".

Notes

Minor:

  • No folder-trust step. Session worktrees never run agent_trust_command (workers run trustWorktree), and blocked-prompt findings don't watch session panes. This is unstated.
  • Close cleanup judges the branch, not the worktree. It decides by refs/heads/session/<t>, not by the worktree's HEAD. A renamed branch ("it has no branch") or a detached HEAD still has its worktree removed. Detached commits dangle and ignored files go. No test covers the paths that keep a worktree (origin differs, unmerged, uncommitted); only "everything on main" is tested.
  • The 7-day bound is keyed on the last slept session act. A session whose window died (a box restart, the agent exiting) has no such act and is never bounded. One slept more than 7 days ago, then resumed and died, is removed at once (only once pushed, so nothing is lost).
  • No drain, park or memory checks. startThreadSession checks neither draining() nor memoryFull(), and a drain does not stop thread sessions. Sessions can also go past max_active_tickets, which the design accepts.
  • The hub's worker count includes sessions. ourWindows counts session windows (their panes start under .worktrees/), so hello's workers includes thread sessions.
  • Non-Claude fleets resume with Claude. A fleet that changed only agent_command keeps the default resume_command (claude --continue). Every wake after a 20-minute sleep then runs Claude, and sessions resume far more often than workers do.
  • The cold/warm split. A turn that arrives while the session is still starting from an earlier turn counts as warm.
  • The head is behind main. 38380f6 is not up to date with origin/main.

Could not check:

  • a real Claude Code, OpenCode or Codex session;
  • multirepo-landing and the rest of dashboard-data (load timeouts);
  • A9 on main;
  • anything at 0072696.

Opened by the box operator.

Verdict: CHANGES 38380f6

…; sleep only when idle

- A session start is marked (run/session-start) for as long as it runs, setup and the agent's
  trust command included, outside the short launch lock: a turn meanwhile is held, never a
  second start. A failed setup is said in the thread, exits 0, and runs again at the next start;
  only a worktree whose agent launched is resumed.
- At the hard ceiling, a drained or parked fleet, or memory at its ceiling, the turn is held, the
  thread says it waits, and the tick starts the session once there is room. A held turn is never
  typed into a pane still at its shell.
- Sessions sleep only as workers suspend: idle at the prompt, no child process.
- The dashboard and its app copies read "this thread's agent" sends in plain words.
- Close cleanup is judged on the worktree's HEAD and keeps detached, uncommitted or ignored work;
  the 7-day bound counts from the last start, sleep or turn; another harness is never resumed
  with the default claude --continue.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant