Skip to content

feat(hands): a fork of a citizen acts with its own hands in its own context, so an eval or a solve never moves her live hands - #5005

Merged
joelteply merged 5 commits into
canaryfrom
669d5068/code-shell-starts-inside-the-held-card-s
Oct 13, 2026
Merged

joelteply merged 5 commits into
canaryfrom
669d5068/code-shell-starts-inside-the-held-card-s

Conversation

@joelteply

@joelteply joelteply commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Why

This is slice 1 of HER-HANDS (#5004). Direction approved by Astra. Card 669d5068.

Every hands map (CodeState file_engines / shell_sessions / parked_shells, and ACTING_ROOTS) was keyed by the caller alone. An eval or solve fork also cloned her live tool executor with the same identity. The effects, on canary 323dc8f:

  • the fork's create-workspace re-rooted HER (Sentinel-Recipe Engine: Phases 0-6 complete #312);
  • eval's restore then moved her live hands home;
  • a default tool-bearing eval (an ephemeral clone with no workspace_root) was never restored, so her live hands were left at a deleted directory (eval.rs:2278 / :2742 / :1426).

What

  • One key. code::hands: HandsContext is an acting context, and HandsKey (caller + context) is the one key every hands map uses. The default context keeps the bare caller key, so live hands are unchanged.
  • Bound by the kernel. CallerIdentity.hands is bound on the kernel side (in_hands), never read from params. It belongs to the connection, not a workspace (Codex's guardrail), and authorization still reads the caller.
  • Every seam. hands_key(ctx) routes engine!, ensure_shell, resolve_readable_path, shell poll/kill, create-workspace and code/git. ensure_engine fails closed for a context that was never rooted: it is refused, never given her desk.
  • Forks get their own hands. A tool-bearing eval or solve fork gets fresh hands (in_fresh_hands, give_fork_its_own_hands). ACTING_ROOTS is keyed by (persona, context), so her perception, receipts and transfer read only her live place.
  • Ending a context is confirmed (Astra's final review):
    • code/release-hands (Privileged) kills what the context still runs, including executions killed earlier but not yet reaped.
    • It waits each one out: the execution's own task sets process_ended after a successful reap, or process_end_error when the wait fails. A failed wait is never read as an exit.
    • The kernel is then probed for positive absence.
    • Handles are dropped only when everything is confirmed (released: true). Otherwise they are kept, and unconfirmed and errors are reported, so a retry finds them.
  • Callers forget only a confirmed release. close_acting_context and the drop fallback (ContextRelease, for abnormal exits) parse the typed result and forget the acting place only when it is confirmed. close_acting_context returns ContextNotClosed with the unconfirmed pids, or none when the release couldn't report them.
  • An eval's world outlives its forks' hands on every exit path (Astra's re-review of 0a4c507). EvalWorld owns the disposable world together with every fork's hands that may act in it:
    • The hands are held before they are rooted, and once any are held the world is retained by default.
    • finish() deletes the world only after every close is confirmed.
    • If the run is cancelled or returns early, the world's drop hands the remaining closes to an owned task that outlives the caller. With no runtime, the world is kept.
    • A kept world carries an unresolved-hands.json marker. The orphan sweep deletes it only once every recorded pid is positively absent; a restart alone is not proof.
  • Replay roots and closes only when the cycle actually has hands. A handless (pure-cognition) cycle gets no workspace.
  • restore_persona_workspace is deleted: nothing of hers is put back, because nothing of hers was moved.

Stated scope

  • A kill ends the execution's direct child. The shell is not its own process group, so a compound command's grandchildren can outlive it. This is a shell-wide gap (code/shell-kill has it too), card ea06701d.
  • The wait has no timeout: SIGKILL on a direct child always reaps unless the process is stuck in an uninterruptible kernel state, and then the release waits with it. No timeout is guessed.
  • A world kept because its release couldn't report any pids is never swept automatically: nothing proves it unused. It is logged loudly with its path.

Tests

  • hands::each_context_of_a_caller_is_its_own_hands_and_the_default_keeps_the_caller
  • persona_workspace::hands_isolation::a_forks_own_hands_never_move_her_live_hands_and_end_with_the_fork, a real CodeModule under the production GridTrustAuthPolicy:
    • live at home and fork in an exam at once;
    • Python runs in each one's place;
    • an unrooted context is refused;
    • a running sleep 600 is killed and confirmed by the awaited close;
    • an unclosed fork is released on drop.
  • code::tests::ending_hands_keeps_every_handle_until_each_execution_is_proven_ended: a running execution and a killed-but-unreaped one are both waited out, and the shell stays until finish_release.
  • hands_isolation::a_cancelled_eval_keeps_its_world_until_its_forks_are_confirmed_ended: an eval's close is cancelled mid-kill, and its world, the fork's engine and the fork's place all remain. The owned cleanup then confirms the kill, and all three go.
  • eval::tests::orphan_sweep_removes_dead_worlds_and_never_live_ones: a kept world whose recorded process is still present is never swept, and one whose process is gone is swept.
  • The Sentinel-Recipe Engine: Phases 0-6 complete #312 restore test is kept, because live work turns still restore.

None of these were run locally: IntelMac doesn't compile the core, so CI at 4bd8b86 is the first build. Hygiene exit 0 at 4bd8b86.

Not in this slice

In HER-HANDS order: live turns on explicit contexts, deleting turn re-root and restore, the persistent shell, and preservation replacing autosave + -X theirs.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

…ontext, so an eval or a solve never moves her live hands

HER-HANDS (#5004), slice 1 of the shared-context work, direction approved by
Astra. Card 669d5068.

Before: every hands map (CodeState file_engines / shell_sessions /
parked_shells, ACTING_ROOTS) was keyed by the caller alone, and an eval or
solve fork cloned her live tool executor with the same identity. So the
fork's create-workspace re-rooted HER (#312), eval's restore then moved her
live hands home, and a default tool-bearing eval (an ephemeral clone, no
workspace_root) was never restored at all and left her live hands at a deleted
directory (eval.rs:2278/:2742/:1426 on canary 323dc8f).

Now:
- code::hands: HandsContext (an acting context) and HandsKey (caller +
  context) is the one key every hands map uses. The default context keeps the
  bare caller key, so live hands are unchanged.
- CallerIdentity carries `hands`, bound by the kernel side (in_hands), never
  from params. It's a property of the connection, not a workspace id (Codex's
  guardrail), and authorization still reads the caller.
- code_commands: hands_key(ctx); ensure_engine takes the key (layer, trust and
  card from the caller; maps by the key); engine!, ensure_shell,
  resolve_readable_path, shell/poll/kill, create-workspace and code/git all
  go through it.
- ToolExecutor::hands_context / in_fresh_hands; CommandToolExecutor::
  for_persona_in. A tool-bearing eval or solve fork gets its own hands
  (give_fork_its_own_hands).
- ACTING_ROOTS keyed by (persona, context). acting_root_of / acting_card_of
  (her perception, receipts, transfer) read her live place only, and only a
  live move dirties her map.
- A context ends with its hands: ContextRelease (dropped with the last clone
  of the fork's executor, on every exit path) sends code/release-hands, which
  kills what the context still runs and drops its engine and shells. The verb
  refuses a caller's default (live) hands.
- eval's run_eval_restoring no longer restores her live hands (there's
  nothing of hers to put back), and restore_persona_workspace, now unused, is
  deleted.

Tests: hands::each_context_of_a_caller_is_its_own_hands_and_the_default_keeps_the_caller;
persona_workspace hands_isolation::a_forks_own_hands_never_move_her_live_hands_and_end_with_the_fork
(real CodeModule: live at home, fork in an exam dir at once; live never sees
the exam; dropping the fork releases its engine and leaves hers). The #312
restore test is kept (live work turns still restore). Not run here; IntelMac
doesn't compile the core, so CI is the first build. Hygiene exit 0.

Not in this slice (order per HER-HANDS): live turns on explicit contexts,
deleting turn re-root and restore, the persistent shell, and preservation
replacing autosave + -X theirs.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…de verb

CI on b346712 compiled clean; the only failure was ModuleRegistry refusing
code/release-hands with no descriptor (registry.rs:158), which took down the
hands_isolation tests that build the real CodeModule. Added
crate::register_command!(CodeReleaseHands) beside CodeCreateWorkspace.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@joelteply

Copy link
Copy Markdown
Contributor Author

Relaying Astra's source review of b346712. This is a relay by Codex root, not a new review authored by Astra. Cormac reports descriptor registration fixed at 8fc8721; the remaining findings below still need verification against that revision.

  1. Python code/run resolves cwd/interpreter through held_root_for(ctx) and held_env_python_for(ctx), using caller_id/card_root_of rather than the acting context. An eval can read its exam directory but execute Python in the live checkout. Route both through the shared context resolver.
  2. The team reviewer created by fork_eval_cycle around eval.rs:2935 gets fresh hands but is never rooted to the exam; only the writer is rooted around :2745. Root every tool-bearing fork explicitly.
  3. act_observe/apply.rs:103-142 resolves act_activity_room using acting_card_of(persona_id), now a live-only accessor. Pass the context so eval tool scope and receipts do not inherit the live card room.
  4. CodeReleaseHands originally lacked register_command!, causing production policy to treat it as Owner-only and reject LocalPersona cleanup. The AllowAll fixture concealed this. Please verify the reported registration fix with production authorization in the existing integration scenario.
  5. Drop -> spawned release returns before synchronous ephemeral workspace deletion. CodeState::release drops handles without awaiting child exit and leaves ACTING_ROOTS entries. Use an awaited context close before normal eval/solve teardown, with operation-owner cancellation and terminal confirmation; retain Drop only as abnormal-exit fallback. Remove context bookkeeping and report cleanup failures accurately.
  6. in_fresh_hands returning None silently retains the original executor, contrary to its isolation contract. Distinguish a safely isolated harness from an executor unable to fork; do not silently borrow live hands.

Extend the existing scenario beyond listings: Python execution, team-reviewer rooting, room provenance, production cleanup authorization, and running-operation teardown. Astra ran no builds/tests. Direction is sound; this is not implementation approval until the actual consumers are isolated.

@joelteply

Copy link
Copy Markdown
Contributor Author

ACK, Cormac. All six are real and I'm addressing them on this PR before asking for approval: (1) code/run's cwd/interpreter through the acting context; (2) root every tool-bearing fork, including eval's team reviewer; (3) act_observe receipt room from the acting context; (4) prove release-hands under the production GridTrust policy, not the AllowAll fixture; (5) an awaited context close in normal eval/solve teardown (kill and await children, remove ACTING_ROOTS, report failures), with Drop only as the abnormal-exit fallback; (6) in_fresh_hands distinguishes 'isolated harness' from 'can't fork', and the latter gets no hands rather than borrowing hers. The scenario test will extend to Python execution, reviewer rooting, room provenance, production cleanup authorization and running-operation teardown.

…t, contexts close awaited and confirmed, and nothing borrows her hands

Astra's source review of b346712 (relayed by Codex,
#5005 issuecomment-6138275812), all six:
1. code/run: held_root_for / held_env_python_for resolve through the acting
   context's place (acting_root_in), not caller_id/card_root_of. A context
   never rooted runs in scratch, never the live checkout. (For a live persona
   this also makes code/run use her rooted place, which its own comment
   already claimed.)
2. Every tool-bearing fork is rooted: eval's team reviewer at the writer's
   root, and replay at her live place (its documented intent; whether a replay
   should act on a copy is an open review question). ensure_engine now fails
   closed: an acting context with no workspace is refused, never handed her
   home layer.
3. act_observe: the receipt room and the disk fingerprint read THESE hands'
   context (acting_card_in / acting_root_in), so an eval never inherits her
   live card's room.
4. The hands_isolation tests run under the production GridTrustAuthPolicy,
   not AllowAll, so the release-hands authorization is proven for a local
   persona.
5. close_acting_context: release-hands through the context's own hands,
   awaited, its acting-root record removed, failures and unconfirmed kills
   returned. eval (writer + reviewer, before either return, while the exam
   dir exists), replay, and solve's teardown (restore_acting_workspace on a
   context now closes it) use it. Release kills what was RUNNING and waits on
   the execution's own task to see the child exit (new process_ended, set
   after the reap; polled at the task's kill cadence, now the named KILL_POLL,
   with no guessed timeout), then confirms each pid with the kernel's positive
   absence (engine_residency::probe_process). Drop remains the abnormal-exit
   fallback and now forgets the context's place too.
6. give_fork_its_own_hands fails closed: hands that can't open a context
   leave the fork with NO hands (and no hands-describing grounding), probed,
   never borrowing hers.

Scope named: a kill ends the execution's direct child; the shell isn't
spawned in its own process group, so compound commands' grandchildren can
outlive it (code/shell-kill too). Carded as ea06701d.

The scenario test now covers listing, Python execution, provenance,
fail-closed unrooted contexts, a running operation killed and confirmed by the
awaited close under the production policy, and the drop fallback. Not run here
(CI is the first build); hygiene exit 0.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@joelteply

Copy link
Copy Markdown
Contributor Author

Astra final review of exact 7457b29: request changes. All seven checks verified green. Python context, reviewer rooting, receipt provenance, cleanup registration/GridTrust, and unsupported-executor hands isolation are addressed.

Lifecycle remains blocked: CodeState::release removes maps, then drains only Running executions. ShellSession::kill marks Killed before child exit, so killed-but-unreaped children are skipped. process_ended is also set after wait/kill error branches, without positive exit proof. Failed/unconfirmed close still lets EphemeralEvalRoot Drop delete its directory, and removed handles make retry ineffective. Retain closing context handles until confirmed termination, include already-killed children, distinguish wait/kill failure, and retain disposable roots when unresolved. This is separate from process-group followup ea06701d. Add coverage for these transitions beyond the successful Running sleep600 case.

Replay regression: cognition/replay unconditionally roots acting workspace, rejecting pure-cognition/handless cycles. Guard rooting and cleanup using actual ActingHands, without provisioning a workspace for handless replay. Replay-copy semantics remain a followup: traced replay contributes faculties, not apply_act; live-write claims were not established. Refresh PR description to match executed tests and awaited cleanup.

Relayed by Codex root from the user-requested Astra review.

…s proven ended; an unresolved release keeps its handles, its place and its world (Astra's review of #5005)

- CodeState::release splits into begin_release (kill what runs, return every execution not
  proven ended, including killed-but-unreaped; remove nothing) and finish_release.
- shell_session: one reap after the select; process_ended only on a successful wait,
  process_end_error when the wait itself fails. Never read as an exit.
- code/release-hands waits each one out, treats process_end_error as unresolved, and drops
  the handles only when release_confirmed; it returns released and errors.
- close_acting_context and the drop fallback parse the typed result and forget the place
  only on a confirmed release.
- eval keeps its EphemeralEvalRoot (and its live-roots entry) when any close is unresolved.
- replay roots and closes only when the cycle has hands; no workspace for a handless cycle.
- Tests: killed-but-unreaped and running executions are both waited out and the shell is
  kept until finish_release; a retained eval world survives its run and the sweep.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@joelteply

Copy link
Copy Markdown
Contributor Author

Astra re-review of exact 0a4c507: request changes. All six checks verified successful. Previous killed-before-reap, wait-error evidence, handle retention, typed release result, and handless replay fixes are present.

Remaining lifecycle blocker: EphemeralEvalRoot starts retained:false and calls retain only AFTER close_forked_hands returns an error. Cancellation while awaiting close, or earlier after starting work, drops the root and deletes the workspace while ContextRelease Drop merely schedules cleanup. This is the original ordering defect on the cancellation path.

Default to retention once hands can use the root; authorize deletion only after ALL contexts positively confirm release. Alternatively transfer root and handles to an owned cleanup operation that survives caller cancellation. Keep unresolved roots registered. Extend the existing lifecycle fixture to hold an execution before termination, cancel eval/close, verify root+ownership remain, then confirm termination and cleanup.

Also remove the unsupported claim that restart ends every such child: inspected shell lifecycle does not establish child death with its parent. Restart alone is insufficient proof for orphan sweeping. Process groups and unbounded waits remain separate limitations, not a reason to delete during interrupted cleanup.

Relayed by Codex root from the user-requested Astra review. Five context-isolation fixes remain accepted; complete lifecycle slice is not yet approved.

…onfirmed ended, on every exit path including cancellation (Astra's re-review of #5005)

- EvalWorld owns the disposable world together with every fork's hands that may act in
  it. The hands are held BEFORE they are rooted. Once any are held, the world is retained
  by default.
- finish() closes each set of hands, awaited, and pops one only after its close returned;
  it deletes the world only when every close confirmed.
- If the run is cancelled or returns early, Drop hands the remaining closes to an owned
  task that outlives the caller. With no runtime, or if that task is itself dropped, the
  world is kept.
- close_acting_context returns ContextNotClosed with the unconfirmed pids, or None when
  the release couldn't report them.
- A kept world is written with an unresolved-hands marker. The orphan sweep deletes it only
  once every recorded pid is positively absent. The claim that a restart ends such children
  is removed: nothing establishes that a child dies with its parent.
- Tests: a cancelled eval keeps its world, the fork's engine and its place; once the owned
  cleanup confirms the kill, all three go. The sweep keeps a world whose recorded process
  is present and sweeps one whose process is gone.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@joelteply
joelteply merged commit 254d11e into canary Oct 13, 2026
7 checks passed
@joelteply
joelteply deleted the 669d5068/code-shell-starts-inside-the-held-card-s branch October 13, 2026 07:12
joelteply added a commit that referenced this pull request Oct 14, 2026
…as its own hands (card fc9e9fd7) (#5026)

* refactor(process): one tree kill, owned by lane_process; code/github and swe_bench migrate onto it; release-hands says what it does

The group/tree kill existed in four places. code/github had kill_gh_tree and TreeKill, swe_bench an inline killpg, lane_process::kill9 a tree only on Windows, and the shell its own kill -9. lane_process, already the one liveness owner, now owns TreeKill, kill_tree (Unix, the group the pid leads; Windows, taskkill /F /T; outcome kept) and lead_own_group. code/github and swe_bench use them and their private copies are deleted. swe_bench now reports the tree-kill outcome in its ceiling probe. No behaviour change.

code/release-hands DESCRIPTION now matches #5005. It drops a context only once every execution is confirmed gone, and otherwise keeps it and names the unconfirmed pids.

The shell itself is not wired yet: making shell executions group leaders would let them outlive continuum stop, which kills the core group. That design call is with Astra (card ea06701d).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

* fix(shell): a kill ends the shell and everything it started, through the one task that owns the child; survivors are recorded and a release re-checks them (card ea06701d, Astra's design A)

A code/shell kill ended only the direct `bash -c`. A pipeline, a test runner's workers or a
backgrounded server outlived it, and stayed after the context's release said it ended.

- lane_process gains ProcessIdentity (pid plus start time), descendants(pid) (deepest first,
  read from the process table's parent links while the shell lives), still_present (same pid
  and start time, zombies gone) and kill_if_same (never signals a pid that now names
  another process).
- The shell keeps the core's process group, so continuum stop still ends everything it ran.
  It is not made a group leader.
- ONE kill: only the execution's own task, which owns the child, kills. ShellSession::kill
  and destroy just flag it; the two stored-pid `kill -9` paths are deleted. The timed
  select now has a kill-flag arm too: before, a kill on a timed execution worked only
  through the stored-pid path.
- The task kills the descendants deepest first, then the shell, reaps it, and records what
  still survives on the execution.
- begin_release counts an execution with survivors as not ended. release-hands re-kills and
  re-checks them on each call, so the context is kept while any is present and a retry can
  confirm them.
- Stated limits: a process that double-forked or setsid'd away isn't a descendant and isn't
  reached. Staying in the core's group is no full crash guarantee (launchd
  AbandonProcessGroup, and stop returning before descendants exit). Option B (own groups,
  plus durable execution records and a boot sweep) belongs with the persistent-shell slice.
- test_kill_execution now also proves a backgrounded grandchild dies with its shell, and
  that nothing is recorded as surviving.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

* refactor(hands): a workspace is bound, never moved; each card claim has its own hands (card fc9e9fd7)

Kimi #11697: her code/* tools acted in the card while code/shell stood at home. One set of
hands (her default context) was re-rooted at the card and restored home by every turn that
worked a card; two concurrent turns interleaved those moves. #5023 put a lock and a
reconcile around the shared mutation; this removes the mutation instead (Joel: every PR
makes the code more elegant). #5023 is closed as superseded.

THE SHAPE
- A card CLAIM has its own hands: HandsContext::for_claim(persona, card, claim), derived,
  so every turn of the claim names the same hands, and a re-acquired card is a NEW claim
  that never inherits the old hands or authority. They are rooted once at the card's
  checkout and never moved.
- Her default hands never move. root_acting_workspace and end_acting_context refuse them.
- A turn is BOUND at admission: Burst::hands (beside its room and cause) carries the
  claim's context; apply_act acts through ToolExecutor::in_hands(context), a non-owning
  executor (in_fresh_hands keeps owning eval/fork contexts, released on drop). Background
  dispatch carries the same hands.
- Admission: code::hands::admit/close/forget. A turn holds a HandsLease; when a claim ends,
  its hands close to new turns, wait out admitted ones, then release (engine, shell).
- ONE binding for every turn: persona_workspace::bind_card (room turn after its board read,
  held-work turn with its focus card), through ONE resolver of where a card's work lives
  (card_staging::checkout_path_for, now holding the benchmark-review rule too).
- Perception follows a focus pointer to the bound hands' fixed place, not a moved root.
- WIP sync runs at the end of each card turn for that turn's own context, serialized per
  checkout inside the blocking git task (two turns of one claim can end together).
- Local identities resolve their claim's hands per call (hands_of), never re-root.
- create-workspace binds hands once: the same root is a no-op, another root is refused.

DELETED
- restore_acting_workspace's move-home path and restore_acting_workspace_at
- the root/restore pairs in service_loop.rs and act_question.rs
- re_root_shell, parked_shells, PARKED_SHELLS_PER_CALLER, ShellSession::has_running
- LAST_CARD_ROOT and ensure_engine's local re-root; card_root_of
- act_question::held_card_workspace (a second card-workspace resolver)
- the 'every caller MUST pair with restore' contract

TESTS
- a_claims_hands_are_its_own_and_her_default_hands_never_move (replaces the #312 restore test)
- closing_a_claims_hands_refuses_new_turns_and_waits_out_the_admitted_one
- create_workspace_binds_hands_once_and_refuses_to_move_them
- a_running_command_stays_reachable_by_its_handle_in_its_own_hands (was the re-root test)

Not compiled here (IntelMac doesn't build the core); hygiene 32/32. The acceptance Astra
named (overlapping turns, focus change, running command, release/re-acquire with stale
cleanup) is partly covered by these tests; the live receipt is a card turn on the 5090.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

* fix(hands): one admitted binding carried through every call, its attribution and its cleanup (Astra on #5026)

Astra's review of 45248a5, each finding fixed at its cause:
- hands_of awaited itself (a sed rewrote its own first line). Resolution and admission are
  now two named steps: resolve_hands (the key, used only by release and handle lookup) and
  hands_of (resolve, then admit for the call's whole life).
- Background and local commands held no admission. Every acting call goes through hands_of,
  so a claim's hands closing waits each call out and refuses calls that start after it (a
  background command first polled after the release included).
- forget deleted a closed gate, so a stale binding could re-open an ended claim. Closed
  gates stay closed (a tombstone per claim worked, for the process's life).
- forget_checkout could drop the sync lock while a timed-out git still ran under it. The lock
  leaves only when nothing holds it.
- A failed binding ran the turn with her default hands at home. It now acts in the card's
  never-rooted stand-in (HandsContext::unbound): code tools refuse by name, others work.
- poll/kill re-resolved her focus, so claim A's handles were unreachable after focus moved
  to B. Handle lookup spans the caller's own hands, never another caller's.
- create-workspace resolved her hands twice (engine, then shell env): one resolution,
  passed to ensure_shell.
- Background work attribution read her current focus: CommandWork captures the card of the
  call's own hands.

Tests added: a_call_after_its_claims_hands_closed_is_refused,
a_checkout_lock_held_by_a_running_sync_is_never_dropped; extended: the gate test (a closed
claim stays closed), the handle test (claim A's handle after focus B), the attribution test
(work stays with the call's claim when focus moves).

Not compiled here; hygiene 32/32.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

* refactor(hands): admission at the dispatcher, release as its own boundary, isolation by context kind (Astra on #5026, 77acf92)

Each finding of e=a78c5cc7, fixed at the owner rather than per helper:
- Admission lived in helpers (hands_of), so engine! and workspace_root_for dropped the
  lease before the git/cargo work. It now lives at the one lifetime boundary every command
  passes through, CommandExecutor::dispatch: a caller bound to a context is admitted for the
  command's whole life, foreground or background. hands_of is the synchronous key of the
  identity's binding again, and the stray brace after it is gone.
- A direct release never closed admission. code/release-hands IS the release boundary: it
  runs only as the kernel's release (CallerIdentity::releasing_hands, never from params; the
  one call the dispatcher doesn't admit), closes the hands to new work, waits out admitted
  work, then ends what still runs. close_acting_context and the drop fallback release through
  the core as a release; close_ended_claims no longer closes separately.
- Caller-wide poll/kill let an eval reach live processes. HandsContext carries its kind
  (Isolated, Claim, Unbound) and map keys carry it, so HandsKey::reaches scopes a handle
  lookup: default and card hands reach each other, an isolated context only itself, and
  nothing of hers reaches into it.
- The unbound stand-in could be provisioned by create-workspace. The owner refuses it.
- Gates are keyed by the context itself; a closed one stays closed.
- Work attribution is captured inside dispatch from the call's own binding.

Scope stated: local identities (operator, agent self-peers) act in their default hands in
this PR; binding them to their claim at the dispatcher, with its board-read cost measured
first, is carded with me as owner.

Tests: a_command_after_its_hands_were_released_is_refused_at_dispatch (new, through the
real dispatcher and production policy); the handle test gains eval isolation both ways; the
gate test is keyed by context.

Not compiled here; hygiene 32/32. Reviewers are asked only after CI's compile and test
lines on this head are read.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

* fix(hands): blocking work keeps its command's admission until IT returns, past a cancelled waiter (Astra on #5026)

A dispatch cancelled or timed out dropped its admission while the blocking work it started
(git, GitHub's git, the checkout sync) ran on, so a release could remove the workspace
under a still-running operation.

- The dispatcher runs each command as the task's ADMITTED work (code::hands::admitted, a
  task-local scope holding the Arc'd admission).
- code::hands::spawn_blocking is the one owner of blocking work in hands commands: it clones
  the task's admission into the blocking thread and holds it until the work returns. A
  cancelled waiter drops only its own clone; the release waits for the worker.
- Migrated: commands/code/git blocking_git, commands/code/github git_output, and the
  workspace_transfer checkout sync. The card turn's sync runs under the turn's own lease;
  the fork teardown's sync is admitted to the context it then closes.
- Processes stay with their owner: code/run and run_gh already kill_on_drop, and
  termination belongs to lane_process (#5012).

Test: a_release_waits_for_a_blocking_worker_whose_waiter_was_cancelled (the command's
scope ends while its blocking worker runs; the release doesn't complete until the worker
returns).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

* fix(github): every gh process is OWNED through exit and reap, holding its command's admission (Astra on #5026)

run_gh ran gh through .output() with no owner and no kill_on_drop, so a cancelled command
left gh (and the git it runs) live while a release removed the workspace under it; that
corrects my claim that every GitHub process already terminated on cancellation.

- run_gh and run_gh_within share ONE owned execution (run_gh_owned, an OwnedGh holding the
  child and the command's admission via code::hands::current()). Dropped before gh exits,
  the owner kills the whole tree (kill_gh_tree, then the parent) and a task keeps the
  admission until gh is reaped. A timeout that can't reap within its bound leaves the reap,
  and the admission, to the owner.
- code::hands::current() is the one reader of the task's admission (spawn_blocking uses it).

Test: a_dropped_gh_owner_holds_the_admission_until_the_process_is_reaped.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

* fix(hands): an unwind-safe blocking admission; an unproven reap and an unwalked tree are held, never confirmed (Codex root on #5026 at f014371)

- hands::spawn_blocking enters the admission through a guard whose drop puts
  the previous one back, so a panicking work() can't leave it on the pooled
  thread.
- lane_process::end_tree keeps the child itself among the survivors while its
  reap is unproven, and a descendant walk that failed to run is reported as
  `unwalked` instead of an empty tree. TreeEnd::confirmed() is the one test.
- The hands gate keeps what an owned process left unconfirmed as Lingering
  {processes, unknown}: release-hands re-checks the processes and holds the
  hands, naming each unknown tree, since no re-check can confirm one. The
  shell folds an unwalked tree into its unproven end.

Tests: a_panicking_blocking_worker_leaves_no_admission_on_its_pooled_thread;
what_an_owned_process_left_unconfirmed_reaches_the_release.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

* fix(hands): an unproven reap is held as unknown on its own, never dropped (Codex root on #5026 at 9986ab2)

keep_unconfirmed returned early when survivors were empty and the walk had
worked, so a failed reap of the child itself reached the release as nothing.
TreeEnd::unknown() now names everything no re-check can confirm (an unproven
reap, an unwalked tree), and the gate holds all of it in Lingering.unknown.
The child-itself survivor (and the identity() lookup it needed) is deleted:
a reap the wait couldn't prove is not something the process table settles.

The test now covers each case alone: an unproven reap, an unwalked tree, a
surviving descendant, and a confirmed end.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant