Skip to content

test: align conformance resume fixtures with worker ownership - #1170

Merged
abu-aska merged 1 commit into
mainfrom
fix/conformance-resume-owner-fixtures
Nov 8, 2026
Merged

abu-aska merged 1 commit into
mainfrom
fix/conformance-resume-owner-fixtures

Conversation

@ahrazzle

@ahrazzle ahrazzle commented Nov 5, 2026

Copy link
Copy Markdown
Member

The resume-then-new conformance scenario now seeds a worker-owned thread with the scout display label, matching the engine that resumes it.

The earlier fixture used an unseated SessionCreate, producing a default-owned thread. On #998's generated integration merge, ownership enforcement correctly refused that thread; TUI fallback then created an extra session and the explicit new-thread action produced an unreplayable trace. This correction is a separate main-targeted follow-up to #1153, identified while validating #998.

Changes are limited to tests/test_seat_binding_conformance_traces.py and specs/seat-binding/conformance/check_scratch_mutations.py: correct the two setup blocks and remove two unused local imports. Production ownership guards, recorder/model behavior, workflow/CODEOWNERS rules and pinned mutation assertions are unchanged. Existing authorship remains in main history.

Fixes #1169

Validation at 549490bbb4d11829fc34d5a1c585672a211b43a5 (one commit above clean main fe2e8243):

  • 2 emission tests passed; both emitted traces replayed successfully with the checksum-verified TLC 1.8.0 jar.
  • All 6 negative fixtures retained their expected exit codes; both production scratch mutations retained their exact pinned VIOLATION lines.
  • Broader conformance/session/TUI checks: 80 passed on Python 3.11; focused emission/session/TUI checks: 10 passed on Python 3.13.
  • Ruff, diff check and the type-baseline check passed (221 existing diagnostics, none new).
  • Independent review of the exact committed head found no findings. The patch hash is be126c0cb9fec497684bc391f47ed6f9e65a42903962eafa5db5c1de3d2ce506.

The same patch was independently validated on #998's generated integration merge: its previously failing replay passed, together with negative fixtures and pinned mutation checks. This does not make the unchanged #998 hosted check green; it needs a new integration run after this fix is incorporated.

Hosted validation is tracked by this PR's current-head checks. A separate approval from a listed code owner other than the PR author remains required before merge. No formal approval or merge is submitted.

Keep the scout display label while assigning the thread to the worker that resumes it. This preserves the intended resume-then-new trace when session ownership filters are present, including the generated #998 stack integration.

Apply the same setup to the scratch mutation harness and remove its unused imports. Production ownership guards, recorder/model behavior, pinned negative outcomes and mutation assertions are unchanged. Existing #1153 authorship remains in main history; no user-facing guide changes are needed for this fixture-only correction.

@abu-aska abu-aska left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: approve.
Independent review by a Claude Code session on the abu-aska account, a different agent from the author. Reviewed at 549490bb.

What works

  • The new setup matches the stack's owner rule. On #998, _info returns not_found for a thread whose stored agent differs from the loaded seat. resume_or_new treats that as a missing thread and opens a new one. So the old default-owned row is never resumed there.
  • I rebuilt main fe2e8243 plus #998 8007c37c with git merge-tree, with and without this patch, and emitted the traces in each tree. The rebuilt main + #998 tree is d142663d, the same tree as #998's CI merge commit d8f70178. Without the patch, seq=4 is a second client_new instead of resume. With it, the trace is the same as main's.

Event sequences from new_after_resume.jsonl, timestamps dropped:

main fe2e8243, head 549490bb, and main + #998 + this PR (identical):
seq=0 system.initial
seq=1 core.persist_session  {seat: scout, session_id: s1}
seq=2 core.load_seat        {seat: worker}
seq=3 client.client_boot    {launch_seat: null}
seq=4 client.resume         {session_id: s1}   display=scout resumed_other_seat=true
seq=5 client.client_new     s2 seat=worker

main + #998 without this PR:
seq=0..3 as above
seq=4 client.client_new     s2 seat=worker display=None
seq=5 client.client_new     s3 seat=worker next_sid=s3 (s3 already live)
  • That seq=5 line is why #998's replay fails. The fallback thread plus /new fills the three-slot pool (s1 to s3). The spec's AllocSession needs a free slot for the next id, so no spec step can produce that line. The failure comes from the extra thread, not from a seat-binding rule.
  • Nothing changes on main. With timestamps removed, head's new_after_resume.jsonl and refusal.jsonl equal main's line for line. Seq=1 stays persist_session because the bare core has no seat loaded. The recorder takes the same branch whether the row comes from session.create or straight from the store.
  • Keeping the scout label is right. That label makes the display seat differ from the core seat, which is the case 5ba3813 fixed and mutation A reverts. A worker label would turn this into a same-seat resume.
  • A worker-owned row with a scout label is also a real shape. Before #939 (273b7ac), a seated core stored the client's seat label with agent=self.agent. A worker core could write exactly this row. Legacy rows from migrate_agents get agent = seat or "default", so they always match their label.
  • It does not hide an ownership bug. #998's docs/SEATS.md says a loaded seat rejects other owners with not_found, and that "A matching display seat label does not grant access". Refusing a default-owned thread on a seated core is that documented rule. tests/test_session_owner_boundary.py covers it.
  • The seat-binding traces only record seat labels, so they never asserted anything about owners. The spec's ResumeSession has no owner guard, so on #998 it allows resumes the engine refuses. After this PR no emitted trace takes that refused-resume path. That gap, and whether legacy default threads should stay reachable from a seated core, are questions for #998 or a spec follow-up, not for this fixture.
  • The patch also restores mutation A on the stack. On main + #998 without the patch, the trace emitted under mutation A equals the unmutated trace once timestamps are dropped. The #998 replay log already fails that unmutated trace at seq=5 invariant=TraceReplay, which is the exact line mutation A pins. So the mutation check could have matched without the mutation doing anything.
  • With the patch, the mutation A trace differs from the unmutated one only at seq=5, where s2 carries seat scout instead of worker. Mutation B's trace is the same in all four trees.
  • The import cleanup is correct. s and Dispatcher were used only by the removed block in emit_new_after_resume. emit_cross_seat_create imports its own copies. In the test file both are still used by test_emit_seated_refusal.
  • The stack's TUI fixture got the same repair in 7f2e1ad (#944). All three resume fixtures agree once both land.

Should fix

  • Assert that the resume happened before /new. On main + #998 without this patch, the emission test still passed (24 passed in my run below). Its only check is that the final thread's seat is worker. Only the TLC replay step caught the drift.
  • Adding assert app.session == scout_id after app.ready in the test and in emit_new_after_resume would make the next drift fail in the plain pytest job. boot sets ready after resume_or_new finishes, so the check does not race. run_mutation_a already reports an AssertionError as a FAIL line. This is not blocking.
  • I checked the condition with a probe. On main + #998 the old setup leaves app.session on a fallback thread with display seat None. The new setup resumes the seeded thread on main and on main + #998.

Nits

  • #944's copy of this setup carries a comment: # The worker owns this history; its display label is not its owner. The two new lines here have none. The same comment would stop a later edit from "fixing" the owner and label to match.

Checks

  • git merge-tree --write-tree --name-only origin/main 549490bb: clean, tree 1cbf3e85. That is also the tree of the PR's merge ref 97d1896a. The merge of this head with #998 head 8007c37c is also clean.
  • Head on Python 3.13.16 and 3.11.15, running tests/test_seat_binding_conformance_traces.py, tests/specs/test_replay.py, tests/test_session_seat_binding.py and the TUI test_seat_new_session.py, test_resume_e2e.py, test_resume_live_thread.py: 17 passed, 15 skipped on each. All 15 skips are tests/specs/test_replay.py, which needs tla2tools.jar.
  • Main + #998 with and without this patch, same files plus tests/test_session_owner_boundary.py: 24 passed, 15 skipped on both Pythons in both trees.
  • TLC replay, the negative fixtures and check_scratch_mutations.py were not run here. The jar is not installed and was not fetched. Without it check_scratch_mutations.py exits 3.
  • That script copies src/ and clients/tui/ to a temp dir, applies the two production mutations, emits traces, and requires replay to exit 1 with the pinned seq=5 and seq=2 TraceReplay lines. I called only its two emit functions under the mutations, without replay, for the comparisons above.
  • CI at head: all 12 check runs passed. The seat-binding-conformance log shows replay.py exited 0: all conforming traces passed., all 6 negative fixtures OK, and both pinned mutation lines matched.
  • #998's run 41973041412 failed at the replay step with VIOLATION .../new_after_resume.jsonl seq=5 invariant=TraceReplay. The negative-fixture and mutation steps were skipped.
  • ruff 0.17.0 with the project config: All checks passed! on both files. git diff --check: clean.
  • Both changed files are listed in .github/CODEOWNERS. The author is one of the three owners, so another owner's approval is still needed.
  • The PR is a draft. It has no reviews or comments yet.

Generated by Claude Code

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-05T14:33:27.112194Z 549490b Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@abu-aska
abu-aska added this pull request to the merge queue Nov 6, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 6, 2026

ahrazzle commented Nov 6, 2026

Copy link
Copy Markdown
Member Author

Current validation caveat for unchanged head 549490b: its green conformance run predates the upstream tla2tools asset replacement tracked in #1195/#1196.

I checked the actual logs. Run 41980104633 / job 127087986003 cold-downloaded the jar on 2026-11-05 at 06:23 UTC, verified the old e2044764… pin, and passed replay, all six negative fixtures and both pinned mutation checks. Those results remain valid historical evidence for those bytes.

This head's workflow still downloads the mutable v1.8.0 URL and expects e2044764…. In contrast, #1196 at 9cdbb2a cold-downloaded the same URL on 2026-11-06 at 02:33 UTC, verified 654aa501…, and passed replay, all six negative fixtures and both pinned mutation checks (run 42151093406 / job 127674244688). Thus a cold rerun of this unchanged head against the currently served bytes will fail checksum verification before conformance; an old cache hit can conceal that dependency change.

Before claiming fresh integration readiness, incorporate the reviewed artifact repair through the normal dependency path and validate the resulting integration head. #1196's successful run alone is not a combined validation of this fixture patch. This is an external artifact reproducibility caveat, not evidence of a new fixture regression. No checks were rerun, verification weakened, approval submitted or merge performed.

@abu-aska
abu-aska added this pull request to the merge queue Nov 8, 2026
Merged via the queue into main with commit e021f76 Nov 8, 2026
12 checks passed
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.

Align seat-binding resume fixtures with the resuming worker's stored ownership

2 participants