Repository navigation
fix(session-control): authorize a child's private-store binding on caller authority - #12467
Conversation
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Verify the restart deferral is acceptable operationally: every gateway restart refuses member own-store dispatch until its owner re-selects the agent (#12528). [DESIGN-REVIEWED] 9aa4601 |
First Principles Review (Fable 5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Verify the restart cost: every member session's own-store dispatch is refused after each gateway restart until its owner re-selects the agent. Not justified as shipped
What this change shipsInventory (10 items) — 9 justifiedIntent: Stop any caller from minting a worker inside a crew member's private memory store just by naming that member's agent — a FIX (base spec pinned this refusal; grep for its enforcer
[FIRST-PRINCIPLES-REVIEWED] 9aa4601 |
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 completed its review of This comment is updated in place on each push. Review detailsFINDING -- src/kiro_crew/session_agent_selection.py:106 -- False positive or not applicable? A repository writer can comment: |
Opus 4.8 Review — ✅ no blocking findingsReviewed Review detailsBased on my analysis, I traced the single candidate to its core: whether any production path vouches a member DM session, which determines if I established that:
That much supports part (b). But I could not close (a)/(c) to the required bar. The PR's own design frames the No other grounded defect surfaced in the vouch/eviction/rollback machinery. No findings. [OPUS-REVIEWED] 9aa4601 Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
Disposition: First Principles verification ask
The ask. Verify that "not ownership-fenced" admits only the owner's dashboard, since a messaging-channel slot that is neither member, cron, nor agent-created would pass the second admission. Answer: that population cannot reach the second admission. It is refused before it, by a pre-existing gate this change does not touch.
It is applied a second time at line 1400, immediately before the slot is allocated, because What remains after both tests is a slot with neither a channel link nor a mirror, which is the owner's own dashboard session. That is the admission the change intends to preserve. Existing coverage, not added here. The create path's refusals are already pinned:
No code change follows from this bullet. The property it asks about is enforced one layer above the line it names, and is already pinned there. |
cd1f372 to
d8bdeb5
Compare
d8bdeb5 to
3564f00
Compare
buluoray
left a comment
There was a problem hiding this comment.
Source-verified at 3564f00f6745b59338e761fbebc70872e315b936. Requesting changes: the GPT finding at session_control.py:1284 is real, and the structural picture is stronger than the adjudication could establish — the live-carrier precedence it could not rule on is not merely unreliable here, it is unreachable for every caller that arrives.
The same-store branch always reads disk metadata
bind_session_execution (src/kiro_crew/execution_context.py:339) has two exits:
- non-persistent — writes the carrier:
_LIVE_EXECUTIONS[_live_key(session_key)] = executionat:394, thenreturn. - persistent — falls through to
:398-405and writes onlyupdate_metadata_if(...). It never touches_LIVE_EXECUTIONS.
So the in-process carrier is the restricted-session mechanism — which restore_live_session_execution's own docstring says ("CAS rollback a restricted admission"). A persistent session has no live entry at all.
create_session then refuses every non-persistent caller before reaching the branch:
# session_control.py:1094
if caller_execution is not None and caller_execution.memory_mode != "persistent":
raise SessionControlError(..., code="ephemeral_caller")
The two facts compose: the only callers that can reach the same-store check at :1283-1286 are exactly the callers for which read_session_execution (execution_context.py:279-315) must fall past _LIVE_EXECUTIONS and read ConversationLog().get_metadata_status. caller_execution.store is always the disk transcript record on this path, never a protected in-memory identity.
The comment defending the design states the opposite
session_control.py:1259-1264:
the store is the caller's OWN, read from its protected execution record ... The record is the only admissible input:
slot.agentandslot.memory_storeare metadata a later write can change
Both inputs are records the same writer reaches. The session transcript store is not in sandbox.py's hidden-leaf set (only cron-history is), so a same-UID in-sandbox open() reaches it — and that file's own neighbouring comments already say the file-tool fence "does not answer a sandboxed subprocess calling open()", which is the case here. The birth re-gate at :1590 compares against the same value, so it closes a change-during-creation window and does nothing about a record poisoned before the call.
Net: a fenced worker that rewrites its own session's execution record to name a peer's store satisfies caller_execution.store == child_execution.store, skips the fence, and binds the child into that peer's private store — the exact population this PR exists to refuse.
What I am not claiming
I did not build the end-to-end exploit. What I verified is each link: the persistent path writes no carrier, ephemeral callers are refused, the disk record is the sole remaining source, and the store leaf carries no OS mask. If any of those is wrong the finding collapses, so if you disagree please rebut the specific link rather than the conclusion.
Suggested direction
Derive same-store authority from something the agent cannot write. The nearest candidate already in this function is the fence verdict itself: the caller carries caller_fenced from the HTTP gate (handlers/session_control.py:256) and that verdict is computed gateway-side from config. An unfenced caller is already admitted by the second authority, so the same-store branch exists only to admit a fenced caller on its own store — which is the one case where the input has to be trustworthy. Either resolve the caller's store from the config record the fence itself reads, or drop the same-store admission and let those workers arrive under the owner's authority.
Everything else in the change reads correctly to me, and I do not want it lost: the refusal covers the inherited-slot-agent and fallback branches rather than only explicit selection, the message names neither store nor member, the carried-verdict route pin extends cleanly from four routes to five, and the spec row plus the new private-store section land in the same commit. Design and First Principles both PASS and I agree with them. The one Design suggestion is worth taking while you are here — the retained doc sentence "Global callers retain member assignment" now contradicts the fenced-cron refusal, since a cron is a global caller.
3564f00 to
5c76de8
Compare
5c76de8 to
0d89295
Compare
GPT 5.6 Review — 🔴 changes requested (blocking)GPT 5.6 found at least one blocking issue that must be resolved before merging This comment is updated in place on each push. BLOCKING -- src/kiro_crew/dashboard/session_control.py:1331 -- restored Global workers can erase their ownership fence |
GPT 5.6 Review —
|
The lane is right, and the change states the same thing in its own words rather than Deferred to #12528, which is this item's own stated clearing condition: an Not fixed here because re-establishing the vouch after a restart needs a source this |
Accepted, and this round handed the lane its evidence. The absorbing machinery has now All four shrink sites now go through one Deferred to #12611: open, labelled Not done here because narrowing changes WHICH callers are vouched, and that set is the |
GPT 5.6 Review —
|
The lane is right, and the change states the same thing in its own words rather than Deferred to #12528, which is this item's own first clearing condition -- an Not fixed here because re-establishing the vouch on the rehydrate path needs a source Scope note, because the trigger set has narrowed on this head rather than staying where The item's second clearing condition is a human explicitly accepting owner re-selection |
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: |
The lane is right, and the miss is mine. The close path was narrowed so a persistent The lane's own reading of the severity is the one I agree with: spec and code agree with Fixed in the description, not argued down. Event 3 now reads "Retained across a The rest of the description was swept for the same class of staleness rather than trusting |
The lane is right, and the change states the same thing in its own words rather than Deferred to #12528, which is this item's own first clearing condition: an independently Not fixed here because re-establishing the vouch on the rehydrate path needs a source Two scope facts, so the cost is read as it stands today rather than as first reported. A The item's second clearing condition is a human explicitly accepting the per-restart |
The suggestion is right, and this PR's own history is the evidence for it. The admission Deferred to #12611, filed for exactly this narrowing. It is open, labelled Not folded in here because narrowing the admission population changes which sessions get Worth recording for whoever takes #12611: two separate blocking findings on this PR landed |
GPT 5.6 Review —
|
1 similar comment
GPT 5.6 Review —
|
GPT 5.6 Review —
|
The lane's reading is correct and this PR does not dispute it. The vouched map is the only Deferred to #12528, re-verified before citing it here: open, labelled Why it is not fixed in this PR rather than deferred. The alternative available here is to Two things a maintainer should have in front of them, because the cost is real and this The recovery is one owner action, and it is stated in owner-facing documentation that The honest limit on that recovery: the refusal names neither the store nor the member, so One change from the previous head worth recording. The lane has stated this item's second |
Accepted as read, not argued down. The suggestion is that once #12528 exists, own-store It is deferred rather than actioned because the suggestion is explicitly conditioned on The pointer was checked by content rather than by title, because a deferral to an issue One scoping note, stated so a reader does not have to infer it. This PR's last change to |
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: |
The lane's reading is correct and this PR does not dispute it. The vouched map is the only Deferred to #12528, re-verified before citing it: open, labelled Why it is not fixed here rather than deferred. The only re-establishment reachable on the What a maintainer should have in front of them, because the cost is real and this record is The honest limit on that recovery: the refusal names neither the store nor the member, so a Both branches this item offers to clear on are outside what an agent may supply -- separate |
…ller authority Selecting an agent is a caller-supplied string, so it cannot authorize the private V2 store that agent names. create_session derived the child's store from the selection, so an unbound caller minted a worker inside any member's private memory by naming that member's agent, then read that memory through the child's turns. The population is wider than the owner clicking in the dashboard: a cron slot, and anything a fenced caller created, all name agents. Authorize once, at the single point where every branch of agent resolution has produced its final route, before the slot is allocated. Two admissions: the caller is not ownership-fenced, or the store is the caller's own. The own-store admission requires TWO sources to agree. A session's durable execution record is written by that session, so it cannot carry its own authority: a fenced worker that rewrote its record to name a peer's store would otherwise satisfy an equality check against that record alone. The gate therefore also requires this process's own word, held in a map written only by bind_session_execution and reachable by no session, and claimed only by OPT-IN: the default is not to vouch, so a binder that says nothing publishes the record and claims no authority, and neither entry point to that map -- the primitive or the selection recorder -- vouches by default. Asking is not sufficient either: a member-less identity means the Global store, which the admission can never accept, so it is refused the vouch outright. Only a publication that established the store may ask, never one carrying it over from the record -- a provider template switch rebuilds the execution from the record, so publishing it does not vouch for it, or a forged record plus a template switch would make both sources one value the session chose. A forged record cannot match a map it did not write, and a stale map cannot match a record that has moved on; disagreement refuses. Slot metadata authorizes nothing. That map is withdrawn when a session is restricted, when a restricted session's last consumer stops, and on a cancelled switch -- where it is DROPPED rather than rolled back to the prior identity, because prior is the record the session writes and the publication already overwrote whatever entry preceded it, so restoring it would let publish-then-rollback vouch a store the session chose. A non-destructive close retains a persistent session's vouch, because the conversation is recreated from the warm pool on resume and the turn-start rebind publishes nothing for an unchanged selection, so withdrawing there would refuse a resumed member's own-store dispatch until its owner re-selected the agent. It is bounded on both dimensions it adds: a named count cap, and the repository's own bound for each retained name or id. Eviction at the cap falls on the least recently USED entry, because a successful own-store admission refreshes its own -- otherwise the producers that mint a key per request would evict the member session still dispatching. One helper holds the withdrawal and the overflow throttle's re-arm together, and it is the only statement outside the eviction loop that shrinks the map, so a shrink that leaves the next eviction episode silent cannot be written rather than merely being noticed once it has been. Every refusal also records server-side WHICH source failed, so an operator can tell an evicted or restart-dropped entry from a record that disagrees with what this process committed; the caller's refusal still distinguishes neither. A restart empties the map by design, so a rehydrated session regains its own-store right when its owner next selects the agent. Re-establishing it without an owner action needs an identity the session cannot write, which no source on that path provides yet; tracked in #12528. The refusal population is the one the ownership fence already distrusts, and the owner's dispatch capability is unchanged, so no shipped capability is removed. The fence verdict is carried from the HTTP gate as the other routes already carry it. Closes #11613
|
Thank you for the link-by-link review. You asked to be rebutted on a specific link if any were wrong. None of them are wrong, so there is nothing to rebut: your analysis is correct, and it is what the change is now built on. To be explicit about each link, because agreeing is more useful to you than restating:
So the same-store admission as you read it rested on a value its own caller can rewrite, and the birth re-gate compares against that same value and closes only a during-creation window. That was a real defect, not a theoretical one. What the admission requires nowYour suggested direction was to derive the authority from something the agent cannot write. That is what it does. The own-store admission now requires TWO sources to AGREE:
A fenced worker that rewrites its own record to name a peer's store now satisfies source 1 and fails source 2, so it is refused. Requiring agreement rather than trusting either source is also what makes it fail closed in the other direction: a stale in-process entry cannot admit a caller whose record has moved on. That mechanism did not exist at The Design suggestion you flaggedTaken. The spec row now reads "unfenced global callers retain member assignment"; at the head you reviewed it read "Global callers retain member assignment" without the qualifier, which is the contradiction you spotted, since a fenced cron is a global caller that no longer retains it. Four further findings fixed after your reviewThe same class you identified recurred three more times once the second source existed, and each one is fixed rather than argued away:
One subtraction as well, from the First Principles lane: a reader that fell back to the vouched map was removed rather than justified. Its only consumer acts solely on non-persistent executions while vouched entries are only ever persistent, so the fallback could never be reached. It is back to its original live-only form, byte-identical to main. Every lane on the current head reports success, including Design, First Principles, GPT and Opus. The board is otherwise clear and this review is the only thing outstanding. No overrides were used anywhere in the above. |
bolichen97
left a comment
There was a problem hiding this comment.
Reviewed at 9aa4601 with Windows compatibility as the primary lens. The change is pure in-process Python (an OrderedDict vouched map under an RLock, keyed by the same _live_key as _LIVE_EXECUTIONS); no path, file, lock, permission, signal, subprocess or encoding code is touched, so nothing new can differ on Windows, and the Windows backend shards are green on the head. Local run on native Windows (worktree src): test_execution_context / test_member_session_control / test_session_control_member_gate / test_webhooks_api / test_dashboard_execution_retention - 217 passed, 0 skipped, 0 failed; no Windows-skipped tests in the changed files. Security: the own-store admission now needs the durable record AND the process-held vouched identity to agree, which is the two-source fix buluoray's change request asked for (a session can rewrite its transcript record but cannot write the vouched map); the carried fence verdict is read only as a refusal. The black-baseline.txt removal of test_webhooks_api.py is legitimate (black --check exits 0 at head). Deferrals #12528/#12611 are fail-closed residuals. Approving; merge waits on buluoray's change request being re-looked at.
buluoray
left a comment
There was a problem hiding this comment.
Source-verified at 9aa4601be8a39a423192c66422237332ea99efc0 (read through the refs/pull/12467/merge tree, 14e78b22). The blocker I raised at 3564f00f is closed. Dismissing my request for changes and approving.
My finding was that on every caller able to reach the same-store branch, caller_execution.store came from the on-disk record, so the branch compared two values the same writer reaches. Link by link at this head:
- L1 (my inference) is now FALSE, and that is the fix.
_LIVE_EXECUTIONSis still written only on the non-persistent exit, but the persistent exit now also calls_vouch(...)when the binder passedvouch=True(execution_context.py:658). A persistent caller therefore does hold process state, so "the disk record is the sole remaining source" no longer follows. - L2 still holds —
code="ephemeral_caller"refuses every non-persistent caller (session_control.py:1160). - L3 is mechanically true but no longer decisive.
read_session_executioncan still answer from disk, but the admission now also readscaller_vouched = read_vouched_session_execution(...)(:1158) and requirescaller_vouched.store == caller_execution.store(:1371-1372)._VOUCHED_EXECUTIONSis a process-localOrderedDict(execution_context.py:41) with no on-disk form, so a sandboxedopen()cannot write the second source. - L4 still holds and is uncontested — only
cron-historyis masked in that family, which is exactly why the record alone could not be the authority.
The agreement term is load-bearing, not decorative: a reviewer subagent neutralised it to record-only and exactly three isolation tests reddened (test_a_forged_execution_record_does_not_grant_the_own_store_admission, test_a_provider_template_switch_does_not_vouch_a_carried_over_store, test_a_restart_drops_the_own_store_admission_until_a_fresh_bind), restoring clean. test_execution_context.py + test_member_session_control.py are 91 passed here. vouch defaulting to False with test_every_binder_declares_whether_it_vouches enumerating the sites is the right shape — the asymmetry argument in that docstring is correct, and it makes a new binder answer the question instead of inheriting an answer.
One residual I want on the record, not blocking. Of the four vouch=True sites, three carry a store established outside the subject's record (member_memory_auth.py:43 takes it as an argument and refuses to rebind an existing record; session_control.py:1716 takes it from the authorization just performed; session_agent_selection.py passes vouch=False on the carried-over and restart paths). The fourth, hooks.py:1161, vouches execution from _load_hook_execution (hooks.py:507), which prefers the identity captured in the hooks.json row — but falls back to capture_session_execution (execution_context.py:541) when the row has no execution_context key, and that reads the session's own memory_store metadata. In that fallback, bind_captured's guard compares prior against a value from the same writable source, so it cannot discriminate. Reachability is narrow: the current writer always stores execution_context (mcp_tools/control.py:1130-1132) and refuses a row whose stored identity disagrees, so the fallback only applies to a row registered before that field existed. And the failure direction is toward the pre-PR state for that one path, not worse — which is why it does not hold this up. The cheap tightening, if you want it: have _load_hook_execution report whether it captured or fell back, and pass vouch=False on the fallback.
Design and First Principles are both PASS at this head and I agree with them. Deferred cap/restart cost (#12528, #12611) is fail-closed.
Not verified: I did not build the end-to-end exploit for the residual above, and did not audit whether a fenced worker can select a peer member's agent at all — a different surface, out of this PR's scope.
Problem / Motivation
create_sessionderived the child's memory route from the selected agent. Selectingan agent is a caller-supplied string, so a caller with no private-memory record of
its own could mint a functioning worker inside a crew member's private V2 store by
naming that member's agent, and then read that memory through the child's turns.
The population that reached it was wider than an owner clicking in the dashboard. A
cron slot has no private record, and neither does anything a fenced caller created,
and both can name an agent.
#11593fenced the birth pin to the store thedelegation gate had cleared; the gate that produced that value was later removed by
the one-SQLite-store refactor, so nothing was left checking the caller at all -- while
the refusal table in
docs/system-specs/modules/session-control.mdstill documentedmemory_delegation_deniedfor exactly this case.Why it matters
A member's private store is meant to be reachable only by that member. Reaching it
needed no credential, no race and no unusual timing: name the agent, then read the
child. A cron slot runs while nobody is watching, and a created child inherits its
creator's agent, so the reach survived a hop the ownership fence exists to catch.
What changed
One authorization, at the single point where every branch of agent resolution has
already produced the child's final route, and before the slot is allocated. Placing
it per branch is what left the surface open: the explicit member selection, the
inherited caller execution and the caller-agent fallback all reach a member store,
so a check on one of them leaves the others.
A private member store is now reachable on two authorities and no others:
this process's own vouched identity for the caller, and the caller's durable
execution record. Neither alone is admissible. The record is metadata on the
caller's own transcript, so on its own it answers a question about the caller
with the caller's own claim. The vouched identity is written only by
bind_session_execution, which no session can reach, and only when the store itpublishes was established independently of that record -- a publication that carries
the owner over FROM the record, as a provider template switch does, does not vouch for
it, because vouching a value the session chose would make the two sources one. A record
published by another module can also leave a vouched entry behind. Requiring agreement
fails closed against a
forged record and against a stale vouched entry alike.
slot.agentandslot.memory_storestay inadmissible: a later write can change them, and bothare rehydrated from that same record on restore;
session.
Refused is the population
_caller_is_ownership_fencedalready treats as untrusted:a cron slot, a member DM slot naming a peer member's agent, and anything either of
them created. The refusal reuses the existing
memory_delegation_denied403 with afixed message that names neither the store nor the member, so it cannot confirm a
guessed agent name. An app-token caller never reaches the route and an app-scoped one
cannot create at all, so the fence covers the whole remaining population.
The owner's dispatch capability is unchanged, so no shipped capability is removed and
no RFC is required. The nested-conductor design also survives: a member-created
worker is itself fenced but is on its own store, so the own-store authority still
admits its same-store children.
The fence verdict is carried in from the HTTP gate as
caller_fenced, exactly as theother session-control routes already carry
precomputed_ownership_fenced, because theinline predicate re-derives member status from the mutable config record and this
coroutine suspends many times before the check. It is only ever read as a refusal, so
a record that stops saying "member" in that window can turn a refusal into an
admission the owner already holds, never the reverse.
The vouched identity lives in a second map in
execution_context.py, written on thepersistent path of
bind_session_executionafter the durable compare-and-set commits,so the process never vouches for an identity the record does not carry -- and only when
that publication ESTABLISHED the store rather than carrying it over from the session's
own record, so the admission's two sources stay two. It is
deliberately not consulted by
read_session_execution: several modules publish anexecution record by its literal key without going through
bind_session_execution, soa map that shadowed that reader would serve a stale identity for the rest of a session
after any of them wrote.
A vouched entry has seven lifecycle events, and all seven are covered, so the next reader
can check the set rather than hunt for the one that is missing:
Published on a persistent bind that established its own store, after the durable
compare-and-set commits, so the process never vouches for an identity the record does
not carry, and never for one the session itself chose.
Withdrawn when the session turns restricted, so the map never disagrees with the
record it exists to corroborate.
Retained across a non-destructive close. Closing a tab and archiving an idle one
both save the conversation and recreate it from the warm pool on resume, and the
ordinary turn-start rebind publishes nothing when the selection has not changed. So
_release_closed_executionreleases a restricted session's identity and leaves apersistent session's vouch standing: withdrawing there would refuse a resumed
member's own-store dispatch until its owner re-selected the agent, charging a
restart's refusal to closing a tab. The count cap bounds the retained population
instead, and eviction follows use, so a closed session is the first entry reclaimed
rather than a permanent row.
clear_session_executionwithdraws from both maps undertheir own compare-and-set wherever a withdrawal IS owed, because a persistent session
has no live entry for the existing check to compare against.
Withdrawn when a webhook turn ends.
_run_hook_agent'sfinallywithdraws too,which matters because that path is not a chat close and nothing else on it reaches the
map:
releasereturns the slot andSessionManager.resetrecycles the session withoutgoing near the execution maps. The hook path binds persistent only --
_run_hook_innerraises for any other mode -- so every hook turn leaves a vouched entry, and hook session
keys are per-request by default (
hook:default:{ts}), with per-event keys the ordinarywebhook pattern. Without the withdrawal the map gained one permanent entry per
authenticated request, recoverable only by restarting the gateway. Being in the
finallycovers the crashed and cancelled turns as well, which is where such a leakwould accumulate fastest.
Withdrawn on a cancelled selection, not rolled back to the prior identity.
restore_live_session_executiondrops the vouched entry on its own terms, before andregardless of the live carrier. It does NOT restore
prior, becauseprioris therecord the session itself writes and the publication already overwrote whatever entry
preceded it -- so nothing at the rollback distinguishes a prior that was legitimately
vouched from a forged one that never was, and restoring it would let
publish-then-rollback hand a forged store the vouched half of the agreement. Leaving
the published entry behind would be just as wrong: a session could rewrite its own
record back to the abandoned store and re-establish agreement. Either way the answer is
to drop it, which defers own-store dispatch to the owner re-selecting the agent.
Deliberately NOT re-established after a restart. The map is process-local, so a
restart drops every entry while the durable records survive, and the own-store
admission is refused until the owner re-selects the agent -- which binds afresh through
the durable path and vouches again. Nothing on the rehydrate path can re-establish it
safely, because every candidate resolves through something the session itself can
influence: the record is written by the session,
slot.memory_storeis rehydrated fromthat record, the execution the selection path carries is built from it on the
provider-switch path, and a config lookup there is keyed by that record's own
member_id-- so re-reading config agrees with a forged record by construction ratherthan checking it. Refusing is the fail-closed direction, an owner's own dispatch is
unaffected, and the deferral is stated in the spec and pinned by tests in both
directions rather than left to be rediscovered. Building an independently authenticated
identity for rehydrated sessions would close the gap properly and is its own change to
shared session machinery, not part of this one. Tracked as session-control: a rehydrated member session loses own-store worker dispatch until its owner re-selects the agent #12528.
Evicted past a bound. The map is an
OrderedDictwith one named cap,_MAX_VOUCHED_EXECUTIONS = 4096, and past it the LEAST RECENTLY USED entry goes. Thecap is needed
because the population is not the set of live sessions: every persistent bind that
establishes its own store vouches,
and several binders mint a key per REQUEST rather than per session, so uptime alone
would grow the map until the process restarted. Each such producer releases its own
entry at teardown where it has one (event 4 is that release for the webhook path), and
the cap is the backstop for the producers that do not. Recency follows USE, not birth:
a successful own-store admission refreshes its own entry, so the churn from those
teardown-less producers falls on idle keys rather than on the member session still
dispatching through its own. The refresh grants nothing -- an absent key is a no-op and
the value is untouched, so the only thing it changes is which entry a later overflow
drops. An eviction refuses that
session's own-store admission until it binds again -- the same deferral and the same
fail-closed direction as event 6 -- and touches no durable record. Overflow is counted
and reported once per episode, because
read_vouched_session_executionanswersNonefor an evicted key exactly as it does for one never bound, so without a tally the cap
would be indistinguishable from a session nobody vouched for. The number in that line
is the ALL-TIME tally: the re-arm resets only the reported flag, so a later episode
continues the count rather than restarting it. The re-arm comparison is
strict:
_vouchtrims to the cap on every insert and the clear path only pops, so anon-strict one could never be false and every clear would re-arm.
A refusal also records its CAUSE server-side -- authority this process does not hold,
against a record that disagrees with what it committed -- so an operator can tell an
evicted or restart-dropped entry from the forgery the agreement exists to refuse. The
caller's own refusal still distinguishes neither, and the log names neither store nor
member, so it is not a second disclosure channel for what the refusal withholds.
Two bounds are declared, one per dimension the map adds: the entry COUNT above, and
the length of each retained STRING, since 4096 rows of an unbounded field is
unbounded. The string bound is
MAX_SHORT_STRING, the repository's own bound fornames and ids, rather than a literal of this module's, so two stores cannot bound the
same ids differently. An execution carrying an oversized field is DROPPED rather than
truncated -- the policy
MAX_ACP_SESSION_ID_LENalready states for a retainedbackend-authored id -- because a truncated identity would compare equal to the honest
session that owns the shortened form and be vouched for it. These strings are not all
config-derived: the provider-switch path builds an execution from the session's own
record with
dataclass_replace(prior, ...), so a session that writes an oversizedfield into its transcript reaches the retention point.
The retained key needs no bound of its own and deliberately has none: the vouch runs
strictly after the durable write, and that write names a file after the session key,
so a key the filesystem cannot name raises before the vouch is reached. A second
literal for it would be two bounds on one population. The pre-existing live map is
also left unbounded: it is restricted-only, released by its own close, and evicting a
restricted session's carrier would drop the authority that path reads rather than
merely withdrawing this process's word.
The one deliberate non-event: a store reassignment published by a module that writes the
record directly leaves the two sources disagreeing, which refuses rather than admits.
That is the fail-closed direction, and an unfenced caller is unaffected.
The spec's refusal row named the removed gate; it now states the two admissions and the
agreement requirement, and a new section records the model.
Tests
test/test_member_session_control.py::TestPrivateStoreCallerIsolation, 11 cases,both directions. Refused: a cron slot naming a member's agent; the second door on the
same store, where the child inherits
caller_slot.agentand noagentargument ispassed; an agent-created child; a member naming a peer; a forged record that a provider
template switch republishes, which must not become vouched merely because the switch
carried the owner over; and a carried fence verdict
deciding on its own with the config read monkeypatched to fail the test if reached.
Admitted: an owner's dashboard slot, a member's same-store worker by inheritance and
by explicit selection, a fenced caller's ordinary global-store worker, and a fenced
member-created worker dispatching its own same-store child. Each refusal also asserts
nothing was published (
creator_slot_count == 0).Mutation-checked in both directions, seven mutations, all killed, each asserted to have
applied and run against a green unmutated baseline. Weakening the refusal (disable it;
key it on the explicit-selection branch only; drop the store comparison; ignore the
carried verdict; make the publication vouch unconditionally, which reddens exactly the
provider-switch pin and leaves the other 61 cases in that file green) reddens the block
tests and leaves the allow tests green. Weakening
the admission (remove the same-store authority; stop carrying the verdict at the
route) reddens the allow tests and leaves the block tests green.
TestMemberChildExecutionContext::test_explicit_target_member_captures_selected_routewas parametrized over both caller classes while nothing enforced the refusal half. It
is narrowed to the global caller, which is the half the spec documents as admitted;
the private caller's case is now among the refusals above.
Two cases pin the authority itself, as a matched pair differing ONLY in who wrote the
identity. A fenced caller whose record claims a peer's store, with nothing vouching for
it, is refused; the same caller, same store, same agent, with the identity committed
through
bind_session_execution, is admitted. Dropping the two vouched terms from thecondition reddens the refusal and leaves the twin green, so the guard is conditional
rather than a blanket break.
Two cases pin the RETENTION, driven through the real close paths rather than the release
helper:
test_a_non_destructive_close_keeps_a_persistent_sessions_vouchruns over boththe tab close and the idle-archive cleanup, asserting a persistent session's vouched
entry is present before the close and still present after, with the slot asserted gone so
a green cannot mean the close never ran. Re-widening the release to cover persistent
sessions reddens exactly those two cases and leaves the restricted-session releases
green.
Three more cases pin the lifecycle events a single-process test set cannot reach by
accident. A cancelled persistent selection must WITHDRAW the vouched entry rather than
restore the prior one: the test asserts the switch really vouched for the new store
first, then that the rollback returns
False(the persistent path, no live carrier) andleaves NOTHING vouched. And a simulated restart -- the map emptied while the durable record persists --
is pinned in both directions: the own-store dispatch is refused with
memory_delegation_deniedand publishes nothing, and a fresh bind admits the very samedispatch. The pair is what makes the restart behaviour a stated deferral rather than a
capability quietly removed.
The rollback fix is mutation-verified with a blast radius of one case: reinstating the
re-vouch of
priorreddens only the rollback pin (25 others in that file green), and therestricted-session rollback and release
tests stay green, so it is not a blanket change.
Own-store authority is claimed only where it is spelled out.
vouchdefaults to False,so a publication vouches only by asking. That direction is chosen on the asymmetry: a caller
that should have vouched and did not loses a capability loudly, at a refused dispatch, while
one that vouches a store rebuilt from the session's own record grants access to another
member's private memory silently. All eight binders were audited for provenance, and exactly
three ask.
session_control.py:_persist_birth, whose child store came from theauthorization this PR adds.
handlers/hooks.py:bind_captured, whose identity was captured athook registration and whose guard raises when the record disagrees with it. And
member_memory_auth.py:bind_private_session_store, which takes the store as its own ARGUMENTfrom trusted gateway code, never reads it back from the session's record, and refuses to
rebind a session that already has one -- so it cannot re-point an existing session at a
peer's store.
record_agent_selectionthreads the decision because it serves both shapes.The rest -- the dashboard fork, which reads the SOURCE session's record, and both subagent
binders -- publishes without claiming authority.
Two pins hold that, and they cover different halves.
test_a_publication_does_not_vouch_unless_it_asksis behavioural: it asserts a silent bindleaves nothing vouched, paired with a twin that asks and does get vouched, so the refusal
cannot be a blanket break.
test_every_binder_declares_whether_it_vouchesis structural: itAST-walks
src/kiro_crewfor everybind_session_executioncall and asserts the exact setof (file, enclosing function, vouch argument), so a new binder reddens it until the site is
listed with its disposition. Restoring the fail-open default reddens only the behavioural
pin; dropping
vouch=vouchfromrecord_agent_selectionreddens only the structural oneand the provider-switch pin. Each mutation lands where it should, which is how the two are
known to be doing separate work.
Two things asking is still not enough for. First, a member-less publication is never
vouched, even when its caller asks.
MemoryStoreRefrefuses a member on the Global storeand
ExecutionContextrequires the two ids to agree, so "no member" means "the Globalstore" -- and the own-store admission identifies its caller BY
member_id, refusing beforethe store question when there is none. Such an entry could never be admitted, so keeping it
would spend a slot in a capped map while inviting a later reader to read "vouched" as
meaning more than it can.
test_a_member_less_publication_is_never_vouchedpins therefusal, and dropping the member check from the guard reddens only that test.
Second,
record_agent_selectiondefaults tovouch=Falseas well. It is a second entrypoint to the same map, and leaving it fail-open would have meant a future selection path
inherited authority by saying nothing -- the very thing the primitive's own default now
prevents. Its three dashboard callers were checked against that flip and none of them needs
the vouch:
test_chat_agent_selection.pypasses with all three declaring nothing. Itstemplate branch is also the live source of the member-less shape above, building
member_id=Nonewhenever no prior member is recorded.The suite-wide reset now clears the vouched map alongside the live carrier, so an entry
cannot leak from one test into the next.
The webhook teardown withdrawal is pinned in
test_webhooks_api.py, in the class thatalready pins the two other things a finished hook turn must not leak (its session key and
its capacity permit), and parametrized over a crashed turn as well as a clean one. It is
mutation-verified: neutering the withdrawal reddens both cases with
vouched identity outlived itand leaves the other 80 tests in that file green. The pin also asserts thedurable record survives, since withdrawing this process's word is not the same as
forgetting what the session was.
The directly-affected suites pass with
-n0:test_execution_context.py,test_dashboard_execution_retention.py,test_member_session_control.py,test_session_control_member_gate.py,test_webhooks_api.pyandtest_chat_agent_selection.py; a further 479 across thewebhook, hook-lifecycle and member-memory-runtime suites that exercise the teardown path;
and a further 296 across
test_chat_agent_selection.py,test_session_control.pyandtest_slot_create_default_agent.py, which cover the selection module this change alsotouches. Black, flake8, isort, brand-name, comment-history, docs-lint and
subprocess-encoding gates pass, and
mypy src/kiro_crew/reports no error in any filethis change touches.
Pattern harvest
A caller-supplied string cannot be an authorization input, however faithfully it is
resolved. The selection here was resolved correctly every time -- through config, under
the right locks, into a valid execution context -- and the store it produced was still
chosen by the caller. The record is the authority; the selection is a request.
An authorization placed per branch is an authorization with as many holes as the
branches nobody enumerated. Three branches reached a private store and one of them was
fenced, which reads as covered. The fix is one check on the value all of them produce.
Rule candidate: when several branches converge on one privileged value, authorize the
converged value at the single point every branch has already reached, not each branch.
A per-branch check is only as complete as the branch enumeration, and a fenced branch
among unfenced siblings reads as covered while the siblings stay open.
Rule candidate: an input the caller supplies can never be the authority for reaching
what that input names, even when it is resolved correctly. Derive authority from a
record the caller cannot write; treat the caller's value as a request against it.
Rule candidate: a record a party writes about itself cannot answer a question about
that party, so an authority needs a second source the party cannot reach -- and
requiring the two to AGREE is stronger than trusting either, because it fails closed
both when the writable one is forged and when the held one has fallen behind.
Rule candidate: widening a reader proves nothing until you read what its callers DO with
the answer. An earlier revision of this branch renamed
read_live_session_executiontoread_held_session_executionand had it fall back to the vouched map, on the statedgrounds that consulting one map "leaks the other half". That claim was false. Vouched
entries exist only on the persistent path -- the restricted branch withdraws explicitly --
so a vouched-only answer is always persistent, while the sole consumer
(
_release_closed_execution, reached from both call sites) acts only whenmemory_mode != "persistent". The fallback could never be acted on.It is gone: the reader is back to its original name and its live-only body, byte-identical
to
main, and all six affected suites pass unchanged -- which is the zero-consumer claimconfirmed from the other side. That also drops a rename from this diff, so the change is 11
lines smaller than it was. A distinction nothing consumes is not a safety margin; it is a
reader's future misreading, and the honest fix was subtraction rather than a justification.
Rule candidate: an enumeration pin encodes the author's BELIEF about each site, so a pin
whose expectation is wrong defends the bug instead of catching it. The structural pin listed
bind_private_session_storefrom the start -- asABSENT, because I had judged its storerecord-derived. It is not: the store is that function's own argument. So flipping the default
silently removed a vouch the seam needs, the pin agreed with the removal on three successive
heads, and the loss only surfaced when CI reached
test_session_control.py, which exercisesthe admission afterwards. What a shape pin cannot check is whether the shape is right; only a
test that USES the capability can. The named suites now include that file.
Closes #11613