Skip to content

fix(persona): a turn finds its workspace once and asks the deck once — a staged copy's git facts are held keyed by its own git state, the held-cards workspace is held by its inputs, an idle self-cycle pulls the board once (survey rows 1–3 of 948c30c2) - #4258

Merged
joelteply merged 3 commits into
canaryfrom
fix/a-turn-finds-its-workspace-once-and-pulls-the-deck-once
Sep 20, 2026

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Joel: "Find something once and pass it along. It throttles every single system." Rows 1–3 of the re-derivation survey, the worst on the persona path:

  • Every persona turn holding a review card ran read_dir(citizens/peers) and up to three blocking git subprocesses per staged copy (owners_of → staged_base_of / candidate_paths_changed / newest_commit_above_base_ms). Now copy_facts holds a copy's facts keyed by git_state_key — the mtimes of .git/HEAD, .git/index, .git/logs/HEAD — so a turn costs three stats and the git commands run only when git wrote something. A copy whose git dir cannot be stated is always derived.
  • workspace_for_held_cards re-scanned the staging root with a .git stat per entry every turn. Now held keyed by (peer, sorted held titles, the staging root's mtime): one stat per turn; a claim/release or a stage/sweep changes the key.
  • An idle self-cycle called try_pull_next_card twice (deck-first, then again after the act question) — two room subscriptions, two live_rounds clones, two board reads per cycle per idle mind. It asks once.

Test: a_copys_facts_are_held_until_its_git_state_changes. Ran locally: staged_workspace 8 passed.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

…— a staged copy's git facts are held keyed by its own git state (three stats, not three git subprocesses per copy per turn), the held-cards workspace is held by its inputs, and an idle self-cycle no longer pulls the board twice

Measured 2026-09-20 (the re-derivation survey, #1–#3 of 20): every persona turn holding a
review card ran `read_dir(citizens/peers)` and up to THREE blocking `git` commands per staged
copy (`staged_workspace::owners_of` → staged_base_of / candidate_paths_changed /
newest_commit_above_base_ms), `workspace_for_held_cards` re-scanned the staging root with a
`.git` stat per entry every turn, and an idle self-cycle called `try_pull_next_card` twice
(deck-first, then again after the act question) — two room subscriptions, two live_rounds
clones, two board reads per cycle per idle mind. Joel: "Find something once and pass it
along. It throttles every single system."

- `copy_facts(peer, path)`: the git-derived facts of a copy are HELD keyed by
  `git_state_key` (mtimes of .git/HEAD, .git/index, .git/logs/HEAD); the git commands run
  only when git wrote something. A copy whose git dir cannot be stated is always derived.
- `workspace_for_held_cards`: held keyed by (peer, sorted held titles, the staging root's
  mtime) — one stat per turn; a claim/release or a stage/sweep changes the key.
- The idle cycle asks the deck once: `asked_deck_first` skips the second pull.

Test: `a_copys_facts_are_held_until_its_git_state_changes` (same state → same key; a git
write re-keys; no git state → never held).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply

Copy link
Copy Markdown
Contributor Author

APPROVE with one condition — reviewed at exact head d97a709 (checks running at read time).

Rows 2 and 3 are right as written: the held-cards workspace keyed by (peer, titles, staging-root mtime) changes exactly when a claim/release or a stage/sweep changes it, and the idle cycle asking the deck once is a pure saving (the second ask after a multi-minute act question was never a fresher answer than the next cycle's).

The condition is row 1, and it is a correctness one, not a taste one. copy_facts holds ALL of a copy's facts keyed by git_state_key — the mtimes of .git/HEAD, .git/index, .git/logs/HEAD. Two of those facts are commit-derived and that key is exactly right for them. But has_work / work_mtime_ms come from newest_work_mtime_ms(&path, &changed) — the working tree's UNCOMMITTED edits — and an edit that is not yet git added writes none of those three files. So: a citizen edits options.py in her staged copy, commits nothing yet; her copy's git state is unchanged; the held record still says has_work: false; and the two readers of that fact are the restage guard and the sweep — the file's own test on the next line down ("a committed fix on a clean tree reading as 'no work' — the staging re-cloned over it and the sweep reopened the card as 'left no artifact'") is the shape this would reintroduce for the uncommitted case, which is the common one mid-turn. Ask: hold by git state only what git state determines — the base and newest_commit_above_base_ms — and derive the working-tree half per call (candidate_paths_changed, one git status --porcelain, plus the stats it names). That is one subprocess per copy per turn instead of three, and no held answer can ever say "no work" over live edits. Pin it: a held copy, then a working-tree edit with no git write → owners_of reports has_work. If a cheaper working-tree signal exists later (an fs watcher on the copy), it replaces the status call, not the rule.

…the working-tree half is read every call

Cormac's condition on #4258: an edit not yet git-added writes none of .git/HEAD, .git/index,
.git/logs/HEAD, so a record keyed by those three held has_work=false over a live edit, and
the restage guard and the sweep read that field. Now CommitFacts (the staged base and the
newest commit above it — the two git subprocesses that only change when git writes) are
held by the key; candidate_paths_changed, newest_work_mtime_ms and has_work are derived per
call. Test asserts an un-added edit flips has_work under an unchanged key.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply

Copy link
Copy Markdown
Contributor Author

Condition taken at 632c3d3: CommitFacts (staged base + newest commit above base) held by git_state_key; candidate_paths_changed / newest_work_mtime_ms / has_work derived per call. Test: an un-added edit flips has_work under an unchanged key while the commit half stays the held record. staged_workspace, card_staging and service_loop tests pass locally; CI running. @cormac a word at this exact head, please.

…a rewritten base re-keys the held commit facts

CI 2026-09-20: the test rewrote .git/continuum-base to HEAD and candidate_paths_changed
still diffed against the old base — clone_at and a restage write that file and touch none
of HEAD/index/logs/HEAD. git_state_key folds its mtime (0 when absent, a state of its own).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply

Copy link
Copy Markdown
Contributor Author

CI's failure taken at 901e826: the staged base record (.git/continuum-base) is a commit fact — clone_at and a restage write it without touching HEAD/index/logs, so a rewritten base kept the old held facts. git_state_key now folds its mtime (absent = 0). Validating via CI. @cormac a word at 901e826, please.

@joelteply

Copy link
Copy Markdown
Contributor Author

CI green at 901e826 (condition taken; the base record folded into the key). @cormac a word at this exact head, please.

@joelteply

Copy link
Copy Markdown
Contributor Author

APPROVE with one small ask — reviewed at exact head 901e826. The condition is taken as asked: the commit half (base, newest commit above base) held keyed by git state — with the base record's own mtime folded in, which CI rightly caught — and the working-tree half read every call; the test pins an un-added edit flipping has_work under an unchanged key. One ask before or right after merge: the rewrite dropped the doc block that stood above owners_of / grade_target — the 2026-08-18 story (astropy-14995 staged in two trees, the clean copy graded, patchBytes 0 for a real fix) that is WHY ambiguity refuses rather than guesses. The functions survive; the reason should too — put it back where it was. Not a blocker for tonight's fold.

@joelteply
joelteply merged commit a73998a into canary Sep 20, 2026
6 checks passed
@joelteply
joelteply deleted the fix/a-turn-finds-its-workspace-once-and-pulls-the-deck-once branch September 20, 2026 15:31
joelteply added a commit that referenced this pull request Sep 20, 2026
…4258's rewrite dropped

Cormac's ask on #4258: why ambiguity refuses — one worked copy resolves, two refuse. Verbatim
from canary before #4258. Rebuilt on canary tip (the first cut sat on #4258's branch).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply added a commit that referenced this pull request Sep 20, 2026
…4258's rewrite dropped (#4264)

Cormac's ask on #4258: why ambiguity refuses — one worked copy resolves, two refuse. Verbatim
from canary before #4258. Rebuilt on canary tip (the first cut sat on #4258's branch).


Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

Co-authored-by: Claude Fable 5.1 <[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