Skip to content

Delete the registered-turn box and carry stored context identities - #2965

Merged
trissim merged 8 commits into
mainfrom
refactor/turn-id-box-deletion
Oct 24, 2026
Merged

trissim merged 8 commits into
mainfrom
refactor/turn-id-box-deletion

Conversation

@trissim

@trissim trissim commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Deleting RegisteredTurn removes a forwarding-only box, but changes recorded context identity from {"value": ""} to a bare TurnId string. This PR carries that stored shape before the strict new reader opens it.

Head: f222b1c. Remote equals HEAD; ready for commander review. Main c9683a1 is merged.

Ownership and migration

Registration, leases, goals, context, tasks and send consumers now pass TurnId directly. No production replacement wrapper or alias.

ContextTurnIds in tools/cutover/carry_context_turn_ids.py owns the cutover:

  • StoredRegisteredTurn (:20) declares the retired box, confined to this tool.
  • BoxedContextTurn (:29) and UnboxedContextTurn (:32) are separate local DeclaredFamily roots composing CarriedContextTurn. Their RecordedBoxedContextTurn (:36) and RecordedUnboxedContextTurn (:45) members derive the same tag from their class names and family affixes. Neither subclasses the production ContextTurn family.
  • rewrite (:57) decodes the complete payload through RecordedBoxedContextTurn | RecordedUnboxedContextTurn, calls carried(), then encodes RecordedContextTurn. Dictionary unpacking preserves the callback dictionary annotation, as in the sibling carry. No field-key access, external type switch or hand-written discriminator. MalformedRecord adds the original path/payload as a note and propagates.
  • carry() reads ContextRequest.identity through its declared column rewrite_document and selects RecordedContextTurn. It collects changed rows, writes through Carry.rewrite_stored inside one write transaction per changed store, and reports root-relative paths. The existing carry method, SQL helper and test are unchanged by the latest correction.
  • ContextRequest is already a TypedTable, not a record with a .table attribute. Carry.rewrite_stored derives its sole key from the table's declared primary-key column: seq for the existing WakeClaim caller, id for this caller. The existing SQL/trigger implementation stays shared.

The commander's all-store scan found old boxed records only in context_request.identity. No other store is rewritten just because it declares a similarly named field.

Latest correction checks

grep -nE 'payload\[|isinstance|"kind"' tools/cutover/carry_context_turn_ids.py
# no output

Only tools/cutover/carry_context_turn_ids.py changed from 8045850. AST comparison confirms carry() is unchanged. Ruff checks the entire 31-file Python diff: 174 existing findings, zero findings on changed lines. No whole-file formatter or unrelated lint edit.

No local tests were run. The review fork owns the new-head live-copy carry and test. Prior-head passing hosted checks are not claimed for this head.

Existing checks and test

  • RegisteredTurn has no src/tests occurrence. Its old-shape declaration exists only inside this carry.
  • No UPDATE or DROP TRIGGER in tools/cutover; both consumers use the existing guarded writer.
  • Carry family discovery and CarryChain.at found ContextTurnIds exactly once, without a roster or registration line.
  • tests/test_carry_context_turn_ids.py:12 writes an old boxed row through an actual ContextStore fixture, checks dry-run count, applies the carry, reads through ContextStore.snapshot and ContextRequest.require, checks the TurnId, then applies again expecting zero changes. The test remains unchanged.

Readers checked

ContextRequest.newest (context_store.py:220), ContextStoreInfo.page (:128), ContextRequest.recorded (:247–251), CapturedContext.require_newest (:325–328), ContextStore.latest (:481–487), prior (:502–505), and resolve (:521–545, including the prior.identity.thread comparison at :534) all retain the strict decoder. Test readers checked: test_unreadable_history_observation.py:65–66, test_context_manifest_deltas.py:148–151, test_turn_context_wire.py:43.

Assumed: the commander's all-store inventory defines this carry's scope; both current rewrite consumers declare one integer primary key. Boxed and unboxed records retain the same occurrence and declared family tag. No old-format decoder is added to production.

git diff --stat origin/main...HEAD
 src/agent_comms/following_inputs.py       |  4 +-
 src/agent_comms/goal_turn_permit.py       |  5 +-
 src/agent_comms/goals.py                  | 18 ++++--
 src/agent_comms/input_disposition.py      |  5 +-
 src/agent_comms/installer/probes/carry.py |  3 +-
 src/agent_comms/native_turn_context.py    |  3 +-
 src/agent_comms/ordinary_turn_rules.py    |  4 +-
 src/agent_comms/owned_send.py             |  9 ++-
 src/agent_comms/owned_turn.py             |  9 ++-
 src/agent_comms/registration.py           | 11 ++--
 src/agent_comms/selected_turn.py          |  3 +-
 src/agent_comms/task_sources.py           |  9 ++-
 src/agent_comms/thread_identity.py        |  3 -
 src/agent_comms/threads.py                | 10 ++--
 src/agent_comms/turn_context.py           |  9 +--
 src/agent_comms/turn_goal_account.py      | 14 ++---
 src/agent_comms/turn_input_source.py      |  8 +--
 src/agent_comms/turn_lease.py             | 37 ++++++------
 src/agent_comms/turn_terminal.py          |  2 +-
 tests/test_carry_context_turn_ids.py      | 42 ++++++++++++++
 tests/test_claim_bus_read.py              |  4 +-
 tests/test_context_manifest_deltas.py     |  6 +-
 tests/test_context_source_inspection.py   | 16 ++++--
 tests/test_goal_answers.py                |  5 +-
 tests/test_input_documents.py             |  5 +-
 tests/test_owned_turn_goal_replacement.py |  2 +-
 tests/test_task_decisions.py              |  3 +-
 tests/test_turn_context_wire.py           |  4 +-
 tests/test_turn_declaration.py            |  5 +-
 tests/test_turn_goal_account.py           |  5 +-
 tools/cutover/carry_context_turn_ids.py   | 96 +++++++++++++++++++++++++++++++
 31 files changed, 248 insertions(+), 111 deletions(-)

@trissim
trissim changed the base branch from refactor/id128-nominal-type to main October 24, 2026 02:42
@trissim
trissim marked this pull request as ready for review October 24, 2026 02:52
Copilot AI balanced review requested due to automatic review settings October 24, 2026 02:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

debt-tools at 871b601, every finding:

grew TypeErrors:tools/cutover/carry_context_turn_ids.py +1

@trissim trissim changed the title Delete the registered-turn box and pass the nominal TurnId Delete the registered-turn box and carry stored context identities Oct 24, 2026
@trissim
trissim merged commit 30f3093 into main Oct 24, 2026
8 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.

2 participants