Repository navigation
fix: backfill a 0.7.0.5 member session's execution_context on read - #13672
Conversation
|
Intent: Make a member chat written on 0.7.0.5 ( |
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Confirm against a real upgraded 0.7.0.5 home from #13398 that the first read backfills — tests replay the sequence, no manual run did. [DESIGN-REVIEWED] 92db533 |
First Principles Review (Fable 5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Verify one counted sibling: That sibling carries its own pin ("V2 never infers identity") and run records are short-lived, so it reads as deliberately out of scope, not a point patch — but the description's "the session record it missed" implies completeness, and only the author can confirm no upgraded run record is ever re-read. Everything else is grounded: the defect has a linked issue (#13398) and tests that fail on base; all 33 What this change shipsInventory (6 items) — 6 justifiedIntent: make member chats written on 0.7.0.5 readable again after the upgrade that added
[FIRST-PRINCIPLES-REVIEWED] 92db533 |
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
ebda1cc to
cc270db
Compare
Opus 5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
A member chat written on 0.7.0.5 carries {agent, memory_store} and no
execution_context. #11780 made that field the canonical carrier and
#12103 backfilled the config and the V2 store at process start, but no
path ever backfilled the session record, so read_session_execution
raised MissingExecutionIdentity for every such chat after the upgrade:
the chat could not run, could not spawn, and every private-memory
request answered member_identity_unavailable. The repair branch nine
lines below the raise in chat_runner was unreachable.
read_session_execution now derives the carrier from the store's
declared owner_member_id and persists it once, with a compare-and-set
against the exact legacy shape it read, only when the attribution is
unambiguous: the owner id names exactly one configured member, that
member resolves to the same store, and the record's own agent names
that member. No member is ever guessed. Every other shape (no agent,
another agent, a template pick, an unattributed store, a member_id
marker, a restricted mode) is left untouched and still refused, and
the refusal now names the remedy. The derived identity is never
vouched, so the migrated session stands where any member session
stands after a restart.
Records that already carry execution_context, Global sessions and V1
named-store sessions are not touched.
Fixes #13398
cc270db to
92db533
Compare
|
|
|
|
|
|
…irodotdev#13672) A member chat written on 0.7.0.5 carries {agent, memory_store} and no execution_context. kirodotdev#11780 made that field the canonical carrier and kirodotdev#12103 backfilled the config and the V2 store at process start, but no path ever backfilled the session record, so read_session_execution raised MissingExecutionIdentity for every such chat after the upgrade: the chat could not run, could not spawn, and every private-memory request answered member_identity_unavailable. The repair branch nine lines below the raise in chat_runner was unreachable. read_session_execution now derives the carrier from the store's declared owner_member_id and persists it once, with a compare-and-set against the exact legacy shape it read, only when the attribution is unambiguous: the owner id names exactly one configured member, that member resolves to the same store, and the record's own agent names that member. No member is ever guessed. Every other shape (no agent, another agent, a template pick, an unattributed store, a member_id marker, a restricted mode) is left untouched and still refused, and the refusal now names the remedy. The derived identity is never vouched, so the migrated session stands where any member session stands after a restart. Records that already carry execution_context, Global sessions and V1 named-store sessions are not touched. Fixes kirodotdev#13398 Co-authored-by: w <w@k.local>
Problem / Motivation
After the automatic upgrade from 0.7.0.5 to 0.7.0.8, every chat bound to a Crew Member's private memory stops working. Sending a message shows the error card
Execution memory is unavailable: session has no canonical member identity; Global was not used, and asking the agent in such a chat to spawn sub-agents fails withThe execution identity is unavailable; Global memory was not used. The transcript is intact; only the chat's member binding cannot be read.Why it matters
Every internal 0.7.0.x install that created a Crew Member and chatted with it loses all of those chats on upgrade, with no repair path other than hand-editing metadata files. It is the second breaking metadata change in the 0.7 line and was reported independently by two users on the same day (#13398).
What changed (motivation → approach → change)
read_session_executionon 0.7.0.6+execution_contextthe canonical member carrier; #12103 backfilled the config and the V2 store at process start, but nothing ever backfilled the session record, soread_session_execution(src/kiro_crew/execution_context.py) raisedMissingExecutionIdentityfor the{agent, memory_store}shape and the repair branch below it inchat_runnerwas unreachableread_session_executionderives the carrier from the store's declaredowner_member_idand persists it once, only when the attribution is unambiguousA 0.7.0.5 member chat carries
agentand amemory_storenaming the member's V2 store, and noexecution_context. The start-of-process store migration already attributed that store to exactly one member (owner_member_id). The read now uses that same fact: when the owner id names exactly one configured member, that member resolves to this store, and the record's ownagentnames that member (by alias or id), the read builds the member's execution context withresolve_member_execution, carrying the record's ownappattribution so an app-owned chat keeps its per-app governance profile, and writes it into the record with a compare-and-set against the exact legacy shape it read. Every later read decodes the field like any other session.No member is ever guessed. A record with no
agent, anagentnaming anyone else, an explicit template pick, a store the migration could not attribute (two bound members), amember_idmarker, a restricted memory mode, or a non-stringappis left byte-for-byte unchanged and still refused, and the refusal now names the remedy that works for that store: open a new chat with the same member (its memory is intact) or archive this one when the store has an attributed owner, or the legacy store repairkirocrew doctornames when the start-of-process migration could not attribute it (a new chat with that member would fail the same way). A successful backfill logs one INFO line naming the session, so an operator can see which chats were migrated. The derived identity is never vouched, because the store came from the session's own record; the migrated session stands exactly where a member session stands after a gateway restart and re-establishes own-store authority the same way. The write is a direct compare-and-set rather thanbind_session_execution, which re-enters this read. A lost race re-reads and returns what the other reader committed.Docs:
docs/system-specs/modules/session.md(agent selection provenance) anddocs/system-specs/modules/memory-skills-hooks.md(the store migration's session-record half) describe the backfill and its bounds.Existing-user visible behaviour: unchanged for every session that already carries
execution_context, every Global session, every V1 named-store session, and every ambiguous legacy record (still refused, same exception type, samecanonical member identityphrase). Changed only for (1) an unambiguous 0.7.0.5 member record, which previously raised and now loads, and (2) the text of the refusal for ambiguous records, which gains a remedy sentence; and (3) one new INFO log line per backfilled session.Backwards compatibility
Compatible: nothing main accepts is rejected, renamed or removed. A record main refused now loads when its attribution is unambiguous; every other input keeps the same outcome and exception type. The one text change is additive (
canonical member identityis retained, the remedy sentence is appended).required=Truereads are unchanged.Tests
test/test_legacy_member_session_backfill.py(new): the unambiguous record derives the owner and persists the carrier,capture_session_executionand arequired=Trueread agree with it, the backfill never vouches, the member id is accepted asagent, an app-owned record keeps itsappin the carrier and a record without one derives an empty app, a lost compare-and-set returns the winner's record; every ambiguous shape (other agent, unknown agent, no agent, template pick, unattributed store,member_idmarker, restricted mode, non-stringapp) stays refused with an unchanged record, the unattributed store naming the store repair and every other shape naming a new chat; a record with a carrier, a Global session, a V1 named-store session, an undeclared store and a malformed carrier behave exactly as before.test/test_legacy_session_history_save.py(updated): the unambiguous record now derives on save/close; two new cases keep the original coverage that a record with no owning agent is still refused and still saves and closes its transcript.Manual verification
N/A — unit coverage sufficient: the tests run the real upgrade sequence (
_write_legacy_home→repair_legacy_member_stores→ a 0.7.0.5-shaped record) against the same functions the chat, spawn and workflow paths call.Related Issues
Fixes #13398
Pattern harvest
Rule candidate: agents-md
Pattern: a refactor that adds a required identity field to a persisted record must ship the one-shot backfill for records written before the field existed -- the same rule #12103 harvested, applied to the session record it missed
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)