Skip to content

fix(session-control): authorize a child's private-store binding on caller authority - #12467

Merged
bolichen97 merged 1 commit into
mainfrom
fix/private-store-caller-isolation-11613
Sep 22, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/private-store-caller-isolation-11613

Conversation

@chenmingwei23

@chenmingwei23 chenmingwei23 commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

create_session derived the child's memory route from the selected agent. Selecting
an 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. #11593 fenced the birth pin to the store the
delegation 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.md still documented
memory_delegation_denied for 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:

  • the store is the caller's own, and that now needs TWO sources to agree:
    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 it
    publishes 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.agent and
    slot.memory_store stay inadmissible: a later write can change them, and both
    are rehydrated from that same record on restore;
  • the caller is not ownership-fenced, which is the owner's own dashboard
    session.

Refused is the population _caller_is_ownership_fenced already 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_denied 403 with a
fixed 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 the
other session-control routes already carry precomputed_ownership_fenced, because the
inline 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 the
persistent path of bind_session_execution after 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 an
execution record by its literal key without going through bind_session_execution, so
a 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:

  1. 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.

  2. Withdrawn when the session turns restricted, so the map never disagrees with the
    record it exists to corroborate.

  3. 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_execution releases a restricted session's identity and leaves a
    persistent 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_execution withdraws from both maps under
    their own compare-and-set wherever a withdrawal IS owed, because a persistent session
    has no live entry for the existing check to compare against.

  4. Withdrawn when a webhook turn ends. _run_hook_agent's finally withdraws too,
    which matters because that path is not a chat close and nothing else on it reaches the
    map: release returns the slot and SessionManager.reset recycles the session without
    going near the execution maps. The hook path binds persistent only -- _run_hook_inner
    raises 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 ordinary
    webhook pattern. Without the withdrawal the map gained one permanent entry per
    authenticated request, recoverable only by restarting the gateway. Being in the
    finally covers the crashed and cancelled turns as well, which is where such a leak
    would accumulate fastest.

  5. Withdrawn on a cancelled selection, not rolled back to the prior identity.
    restore_live_session_execution drops the vouched entry on its own terms, before and
    regardless of the live carrier. It does NOT restore prior, because prior is the
    record 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.

  6. 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_store is rehydrated from
    that 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 rather
    than 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.

  7. Evicted past a bound. The map is an OrderedDict with one named cap,
    _MAX_VOUCHED_EXECUTIONS = 4096, and past it the LEAST RECENTLY USED entry goes. The
    cap 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_execution answers None
    for 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: _vouch trims to the cap on every insert and the clear path only pops, so a
    non-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 for
    names 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_LEN already states for a retained
    backend-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 oversized
    field 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.agent and no agent argument is
passed; 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_route
was 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 the
condition 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_vouch runs over both
the 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) and
leaves 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_denied and publishes nothing, and a fresh bind admits the very same
dispatch. 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 prior reddens only the rollback pin (25 others in that file green), and the
restricted-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. vouch defaults 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 the
authorization this PR adds. handlers/hooks.py:bind_captured, whose identity was captured at
hook 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 ARGUMENT
from 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_selection threads 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_asks is behavioural: it asserts a silent bind
leaves 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_vouches is structural: it
AST-walks src/kiro_crew for every bind_session_execution call and asserts the exact set
of (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=vouch from record_agent_selection reddens only the structural one
and 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. MemoryStoreRef refuses a member on the Global store
and ExecutionContext requires the two ids to agree, so "no member" means "the Global
store" -- and the own-store admission identifies its caller BY member_id, refusing before
the 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_vouched pins the
refusal, and dropping the member check from the guard reddens only that test.

Second, record_agent_selection defaults to vouch=False as well. It is a second entry
point 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.py passes with all three declaring nothing. Its
template branch is also the live source of the member-less shape above, building
member_id=None whenever 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 that
already 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 it and leaves the other 80 tests in that file green. The pin also asserts the
durable 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.py and
test_chat_agent_selection.py; a further 479 across the
webhook, 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.py and
test_slot_create_default_agent.py, which cover the selection module this change also
touches. Black, flake8, isort, brand-name, comment-history, docs-lint and
subprocess-encoding gates pass, and mypy src/kiro_crew/ reports no error in any file
this 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_execution to
read_held_session_execution and had it fall back to the vouched map, on the stated
grounds 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 when
memory_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 claim
confirmed 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_store from the start -- as ABSENT, because I had judged its store
record-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 exercises
the 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

@github-actions

github-actions Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

Design-level review of 9aa4601be8a39a423192c66422237332ea99efc0 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

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

@github-actions

github-actions Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — ✅ PASS

Premise-level review of 9aa4601be8a39a423192c66422237332ea99efc0 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

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

  • Item 10 — rides along, undeclared: wholesale black reformatting of test/test_webhooks_api.py and its removal from .github/black-baseline.txt; mandated by the formatting gate once the file is touched, but the description never mentions it.

What this change ships

Inventory (10 items) — 9 justified

Intent: 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 require_memory_delegation finds 0 matches, so nothing enforced it).

  1. Cron slots, peer-naming member DMs, and anything they created are refused private-store child creation (403) — justified
  2. Own-store creation now needs the durable record and a process-vouched identity to agree — justified
  3. After a restart or cap eviction, own-store dispatch waits until the owner re-selects the agent — justified
  4. Vouched identities capped at 4096, LRU-by-use, with counted once-per-episode overflow warnings — justified
  5. An identity carrying an oversized string field is dropped from vouching, never truncated — justified
  6. A finished or crashed webhook turn withdraws its vouched identity — justified
  7. The create route forwards the HTTP gate's fence verdict like the four existing routes — justified
  8. A refusal logs which source failed, server-side only, naming neither store nor member — justified
  9. The test pinning a member capturing a peer's route is removed, replaced by refusal pins — justified
  10. test_webhooks_api.py reformatting plus baseline removal — rides along, undeclared

[FIRST-PRINCIPLES-REVIEWED] 9aa4601

@github-actions

github-actions Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of 9aa4601be8a39a423192c66422237332ea99efc0 and found no blocking issues.

This comment is updated in place on each push.

Review details

FINDING -- src/kiro_crew/session_agent_selection.py:106 -- "vouch=False" makes owner re-selection leave a restored member unable to create same-store workers -> Fix: default independently resolved replace=True member selections to vouch.
[GPT-REVIEWED] 9aa4601

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 9aa4601be8a39a423192c66422237332ea99efc0: <one-sentence reason>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 21, 2026
@github-actions

github-actions Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

Reviewed 9aa4601be8a39a423192c66422237332ea99efc0 — this comment is updated in place on each push.

Review details

Based on my analysis, I traced the single candidate to its core: whether any production path vouches a member DM session, which determines if member_dispatch breaks.

I established that:

  • A member-<slug> DM slot is ownership-fenced (_member_caller → _caller_is_ownership_fenced returns True) and is created via get_or_create_slot, not create_session, so _persist_birth never vouches it.
  • Its store is bound via _pin_private_agent_assignment, which the enumeration test confirms does NOT vouch.
  • There are exactly four vouch=True production sites (hooks.bind_captured, _persist_birth, bind_private_session_store, record_agent_selection via param); bind_private_session_store has no production caller, and provider agent switches are vetoed for pinned member threads.

That much supports part (b). But I could not close (a)/(c) to the required bar. The PR's own design frames the memory_delegation_denied refusal as a restart/eviction-specific condition that recovers on re-selection — i.e. it explicitly expects the member session to be vouched in steady state. I could not disprove that a steady-state vouch is established (the actual same-store dispatch may originate from a worker vouched at birth or the unfenced owner rather than an unvouched DM slot), and confirming the negative requires tracing the full member-turn dispatch flow I did not fully open. This matches the candidate's own "low" confidence. It does not survive falsification at 80+.

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 9aa4601be8a39a423192c66422237332ea99efc0.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 9aa4601be8a39a423192c66422237332ea99efc0: <one-sentence reason>

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Disposition: First Principles verification ask

target=first-principles, verdict PASS on cd1f372867fdca2d327fe73ea5744cfb4fae010e. One bullet, verified, no change required.

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.

_refuse_ineligible_creator (src/kiro_crew/dashboard/session_control.py:897) refuses a channel caller on two independent tests:

  • a non-empty linked_session_key that is not a cron link, which catches a channel-BORN slot -> linked_session_caller;
  • _has_channel_mirror, which catches a dashboard-born slot that has since gained an outbound mirror, because the link lives in the session store rather than on the slot -> mirrored_caller.

create_session applies it at line 1078, on entry. The private-store authorization this change adds is at line 1304. So the gate is strictly upstream of the admission the ask is about, and a channel caller never reaches it.

It is applied a second time at line 1400, immediately before the slot is allocated, because _has_channel_mirror reads the live session store and is not stable across the suspension points in between. A caller that acquires a mirror mid-flight is therefore also refused, and no slot is published for it.

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:

  • test/test_session_control.py asserts linked_session_caller from a direct create_session call, alongside app_scoped_caller and ephemeral_caller;
  • test/test_session_control.py pins mirrored_caller for the mid-flight case, with assert set(state._slots) == before so a refused caller cannot leave a published slot behind;
  • test/test_cron_session_control.py and test/test_queue_drain_revalidation.py carry the same codes on their own paths.

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.

@chenmingwei23
chenmingwei23 force-pushed the fix/private-store-caller-isolation-11613 branch from cd1f372 to d8bdeb5 Compare September 21, 2026 07:29
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 21, 2026
@chenmingwei23
chenmingwei23 force-pushed the fix/private-store-caller-isolation-11613 branch from d8bdeb5 to 3564f00 Compare September 21, 2026 08:30
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: passed Eligible automated validation passed for the current revision readiness: checking Automated validation is still running labels Sep 21, 2026

@buluoray buluoray 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.

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)] = execution at :394, then return.
  • persistent — falls through to :398-405 and writes only update_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.agent and slot.memory_store are 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.

@chenmingwei23
chenmingwei23 force-pushed the fix/private-store-caller-isolation-11613 branch from 3564f00 to 5c76de8 Compare September 21, 2026 09:51
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision labels Sep 21, 2026
@chenmingwei23
chenmingwei23 force-pushed the fix/private-store-caller-isolation-11613 branch from 5c76de8 to 0d89295 Compare September 21, 2026 10:15
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running labels Sep 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — 🔴 changes requested (blocking)

GPT 5.6 found at least one blocking issue that must be resolved before merging 8a676fb24eb5ea92ce9e29fb01616373e9fb5d69. Adjudication produced no [GPT-ADJUDICATED] marker for 8a676fb: the adjudication stage FAILED TO RUN (its raw output is in the Adjudication details block -- typically an API or setup error), so no proportionality review took place and GPT's blocking verdict stands unreviewed.

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
else await asyncio.to_thread(_caller_is_ownership_fenced, state, caller_key)
Global worker removes created_by from its writable transcript -> restart restores it unfenced -> session_create binds a child to another member’s private store.
Anchor: backend-security-controls
Fix: derive creator fencing from gateway-held authority and fail closed when unavailable.
[BLOCK-MERGE] 8a676fb
[GPT-REVIEWED] 8a676fb
False positive or not applicable? A repository writer can comment:
/ai-review override gpt 8a676fb24eb5ea92ce9e29fb01616373e9fb5d69: <one-sentence reason>

@github-actions

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ⚠️ review incomplete

GPT 5.6 did not produce a complete verdict for 3cde191fb0d58e47247cd51dd4624b8b760f9030; inspect the workflow logs and re-run it.

This comment is updated in place on each push.

See the GPT 5.6 Review job logs; this commit has no completed GPT verdict.

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 3cde191fb0d58e47247cd51dd4624b8b760f9030: <one-sentence reason>

@chenmingwei23

Copy link
Copy Markdown
Contributor Author
  • accepted-and-deferred: the admission's second source is cache residency, and a restart drops it span=2f5301ed1199

The lane is right, and the change states the same thing in its own words rather than
claiming otherwise: the vouched map is process state, a restart leaves it empty, and an
evicted or restart-dropped session is refused until its owner re-selects the agent.
That direction is fail-closed, but the lane's point stands that the refusal lands on
LIVE member sessions, which is a real cost paid by correct users on a routine event.

Deferred to #12528, which is this item's own stated clearing condition: an
authenticated identity for rehydrated sessions. It is open, labelled
deferred-finding, assigned, and carries Due: 2026-10-19.

Not fixed here because re-establishing the vouch after a restart needs a source this
process can trust that the session itself cannot write, and the only candidate
available today is the session's own transcript, which a Global worker can edit. Main
documents the same trade for the neighbouring attribute: _created_by alone is
restored for authorization, never promoted to lineage. A wrong re-establishment turns
a refusal into an admission, so the refusal stands until #12528 supplies the identity.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author
  • accepted-and-deferred: narrow the vouched population instead of absorbing it span=b4efdb80fe05

Accepted, and this round handed the lane its evidence. The absorbing machinery has now
produced two blocking findings in two consecutive rounds, both the same shape: a path
that shrinks the map without re-arming the overflow throttle. The first round found the
oversized-rebind pop in _vouch; this round found the restricted-session pop and the
rollback pop in restore_live_session_execution.

All four shrink sites now go through one _rearm_overflow_if_below_cap(), and a
structural test asserts every _VOUCHED_EXECUTIONS.pop is followed by that call, so a
fifth site fails the suite instead of shipping silent. That pins the invariant. It does
not remove the reason the invariant keeps being missed, which is the lane's actual
point and why this is accepted rather than answered.

Deferred to #12611: open, labelled deferred-finding, assigned, Due: 2026-10-19.

Not done here because narrowing changes WHICH callers are vouched, and that set is the
security-relevant surface this change exists to fence. Moving the fence and its
admission set in one change would leave neither reviewable on its own.

@github-actions

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ⚠️ review incomplete

GPT 5.6 did not produce a complete verdict for eea2c4e862c1ec53f7233be3a33ee2148215a0d2; inspect the workflow logs and re-run it.

This comment is updated in place on each push.

See the GPT 5.6 Review job logs; this commit has no completed GPT verdict.

False positive or not applicable? A repository writer can comment:
/ai-review override gpt eea2c4e862c1ec53f7233be3a33ee2148215a0d2: <one-sentence reason>

@chenmingwei23

Copy link
Copy Markdown
Contributor Author
  • accepted-and-deferred: a restart or a cap eviction revokes own-store dispatch until the owner re-selects span=23a17f4ffda9

The lane is right, and the change states the same thing in its own words rather than
claiming otherwise: the vouched half of the own-store admission is process state, a
restart leaves it empty, and an evicted or restart-dropped session is refused until its
owner re-selects the agent. The cost the lane names is real and lands on correct users:
an unattended member pipeline whose owner is not watching stays refused until someone
acts.

Deferred to #12528, which is this item's own first clearing condition -- an
independently authenticated identity for a rehydrated session. It is open, labelled
deferred-finding, assigned, and carries Due: 2026-10-19.

Not fixed here because re-establishing the vouch on the rehydrate path needs a source
this process can trust that the session itself cannot write, and every candidate
reachable there resolves through something the session influences: the durable record is
written by the session, slot.memory_store is rehydrated from that record, the
execution the selection path carries is built from it, and a config lookup is keyed by
that record's own member_id, so re-reading config agrees with a forged record by
construction instead of checking it. A wrong re-establishment converts a refusal into an
admission, which is the one direction this change exists to prevent, so the refusal
stands until #12528 supplies the identity.

Scope note, because the trigger set has narrowed on this head rather than staying where
the lane first found it: a non-destructive close and an idle archive are no longer
triggers. _release_closed_execution withdraws only a restricted session's identity, so
a persistent session keeps its vouch across a closed-and-reopened tab; that is pinned by
test_a_non_destructive_close_keeps_a_persistent_sessions_vouch over both close paths.
A restart and a cap eviction are what remain, and the spec states the recovery for an
operator in plain terms beside the design rationale.

The item's second clearing condition is a human explicitly accepting owner re-selection
as the interim recovery. That is not something this disposition can supply and not
something an agent should simulate: it is the merge decision itself, which is already a
human's. This record exists so that decision is made with the cost written down rather
than discovered afterwards.

@github-actions

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of 2739eb7ac7d74dabbfe72a644528ffed21d71988 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 2739eb7

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 2739eb7ac7d74dabbfe72a644528ffed21d71988: <one-sentence reason>

@chenmingwei23

Copy link
Copy Markdown
Contributor Author
  • accepted-and-fixed: the description's lifecycle event 3 and Tests paragraph described the behavior this PR no longer ships span=2daa4a8f6a35

The lane is right, and the miss is mine. The close path was narrowed so a persistent
session's vouch survives a non-destructive close; the spec paragraph and the commit
message were both re-read against that change and corrected, and the PR description was
not. So the description claimed "Withdrawn on close" and cited a test asserting the entry
"absent after" close_slot, while code, spec and test all pin retention.

The lane's own reading of the severity is the one I agree with: spec and code agree with
each other, so this was a stale description rather than a code defect. It still mattered,
because the seven-event enumeration is offered as the audit the next reader can check,
and the entry that was wrong stated a security-lifetime property -- how long this process
vouches for a closed session.

Fixed in the description, not argued down. Event 3 now reads "Retained across a
non-destructive close" and gives the reason (the conversation is recreated from the warm
pool on resume, and the turn-start rebind publishes nothing for an unchanged selection,
so a withdrawal there would charge a restart's refusal to closing a tab), together with
what bounds the retained population instead: the count cap, with eviction following use
so a closed session is reclaimed first. The Tests paragraph now names
test_a_non_destructive_close_keeps_a_persistent_sessions_vouch, says it runs over both
the tab close and the idle-archive cleanup, and states the mutation actually run --
re-widening the release reddens exactly those two cases and leaves the restricted-session
releases green.

The rest of the description was swept for the same class of staleness rather than trusting
that this was the only instance. Three other withdrawal passages were checked and are
accurate as written: the live carrier map is restricted-only and released by its own
close, the rollback withdrawal belongs to a cancelled switch, and the webhook teardown
withdrawal belongs to a finished hook turn. None of them describes a close.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author
  • accepted-and-deferred: a restart or a cap eviction refuses own-store dispatch until the owner re-selects span=1512a8828012

The lane is right, and the change states the same thing in its own words rather than
claiming otherwise: the vouched half of the own-store admission is process state, a
restart leaves it empty, and an evicted or restart-dropped session is refused until its
owner re-selects the agent. The cost the lane names is real and lands on correct users --
an unattended member workflow stays refused until someone acts, and the caller-facing
refusal names no cause the member can act on.

Deferred to #12528, which is this item's own first clearing condition: an independently
authenticated identity for a rehydrated session. It is open, labelled deferred-finding,
assigned, and carries Due: 2026-10-19.

Not fixed here because re-establishing the vouch on the rehydrate path needs a source
this process can trust that the session itself cannot write, and every candidate
reachable there resolves through something the session influences: the durable record is
written by the session, slot.memory_store is rehydrated from that record, the execution
the selection path carries is built from it, and a config lookup is keyed by that
record's own member_id, so re-reading config agrees with a forged record by
construction instead of checking it. A wrong re-establishment converts a refusal into an
admission, which is the one direction this change exists to prevent.

Two scope facts, so the cost is read as it stands today rather than as first reported. A
non-destructive close and an idle archive are NOT triggers: the release skips persistent
sessions, pinned by
test_a_non_destructive_close_keeps_a_persistent_sessions_vouch over both close paths.
And the recovery works on the agent the slot already names, because the owner-facing
switch records the selection with replace and so re-binds rather than short-circuiting
on an unchanged choice. A restart and a cap eviction are what remain, and the spec states
the operator-facing recovery beside the design rationale.

The item's second clearing condition is a human explicitly accepting the per-restart
owner-re-select cost. This disposition cannot supply that and an agent should not
simulate it: it is the merge decision, which is already a human's. This record exists so
that decision is made with the cost written down.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author
  • accepted-and-deferred: vouch only executions carrying a member_id span=94d9e3cc7da7

The suggestion is right, and this PR's own history is the evidence for it. The admission
consults the vouched map only for an execution that names a member, yet every persistent
bind_session_execution vouches -- including producers that mint a key per REQUEST, such
as a webhook arriving without a session key and a task-runner refine run. Those keys can
never be consulted, so they are pure cap pressure, and the eviction ordering and the
refresh-on-use machinery exist to keep them from displacing the member sessions that are
consulted.

Deferred to #12611, filed for exactly this narrowing. It is open, labelled
deferred-finding, assigned, and carries Due: 2026-10-19.

Not folded in here because narrowing the admission population changes which sessions get
vouched at all, which is a different question from the one this change answers -- whether
a caller may name another member's store. Doing both in one diff would mean a reviewer
could not tell which change is responsible for a behavior difference in the map, and the
bound this PR adds is what makes the unnarrowed population safe in the meantime.

Worth recording for whoever takes #12611: two separate blocking findings on this PR landed
inside the machinery that exists to absorb entries nothing ever consults. The structural
pin added here holds the invariant those findings broke; it does not shrink the population
that makes the invariant hard to hold. That argument belongs in the issue rather than in
this thread, and it is written there.

@github-actions

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ⚠️ review incomplete

GPT 5.6 did not produce a complete verdict for 2739eb7ac7d74dabbfe72a644528ffed21d71988; inspect the workflow logs and re-run it.

This comment is updated in place on each push.

See the GPT 5.6 Review job logs; this commit has no completed GPT verdict.

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 2739eb7ac7d74dabbfe72a644528ffed21d71988: <one-sentence reason>

1 similar comment
@github-actions

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ⚠️ review incomplete

GPT 5.6 did not produce a complete verdict for 2739eb7ac7d74dabbfe72a644528ffed21d71988; inspect the workflow logs and re-run it.

This comment is updated in place on each push.

See the GPT 5.6 Review job logs; this commit has no completed GPT verdict.

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 2739eb7ac7d74dabbfe72a644528ffed21d71988: <one-sentence reason>

@github-actions

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ⚠️ review incomplete

GPT 5.6 did not produce a complete verdict for 3a4c7dc742f94ea939ea39dec05fbd9e6495a3da; inspect the workflow logs and re-run it.

This comment is updated in place on each push.

See the GPT 5.6 Review job logs; this commit has no completed GPT verdict.

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 3a4c7dc742f94ea939ea39dec05fbd9e6495a3da: <one-sentence reason>

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

The lane's reading is correct and this PR does not dispute it. The vouched map is the only
source of own-store authority, it is process-local, and it is deliberately not rehydrated,
so a gateway restart drops every entry while the durable records survive. Until the owner
re-selects the agent, a member session's own-store admission is refused.

Deferred to #12528, re-verified before citing it here: open, labelled deferred-finding,
assigned to chenmingwei23, Due: 2026-10-19. That issue is exactly this problem --
establishing own-store authority from a source the session cannot write, so authority
survives a restart without the process holding it in memory.

Why it is not fixed in this PR rather than deferred. The alternative available here is to
re-vouch on the resume path, and the code's own comment argues against it: the resuming
session is the party whose authority is in question, so letting a resume re-establish its
own vouch removes the property the map exists to provide. Opus agreed with that reading on
an earlier head. A correct fix needs a writer the session does not control, which is a
different design and a different change.

Two things a maintainer should have in front of them, because the cost is real and this
record is where it is disclosed.

The recovery is one owner action, and it is stated in owner-facing documentation that
ships with this PR: docs/system-specs/modules/session-control.md names the symptom, says
re-selecting the member's agent restores dispatch, and states that re-picking the agent
already named works, because the owner-facing switch endpoint passes replace=True and so
does not hit the unchanged-selection early return. That was verified against the call site
rather than assumed.

The honest limit on that recovery: the refusal names neither the store nor the member, so
a member session cannot diagnose this itself and the owner has to recognise the symptom.
That is a real operational cost of the interim design, and it is the cost #12528 removes.

One change from the previous head worth recording. The lane has stated this item's second
clearing branch three different ways across heads -- a maintainer accepting the interim
contract, the owner-facing docs stating the recovery, and now a maintainer accepting
per-restart owner re-selection as the documented recovery. The doc branch was satisfied
when it was offered and that text still ships; it is simply no longer listed as a way to
clear. Both branches now standing are outside what this PR can supply: separate work, or a
human's explicit acceptance. That is why this is a record and not another patch.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Accepted as read, not argued down. The suggestion is that once #12528 exists, own-store
authority should come from vouching at rehydrate out of a source the session cannot write,
instead of the interim map accumulating further lifecycle events -- and that the event
count is itself the signal the map is a stopgap rather than a home. That reading is right,
and it is the same conclusion this PR's own deferral rests on.

It is deferred rather than actioned because the suggestion is explicitly conditioned on
once #12528 exists. Building the source the session cannot write IS that issue's work;
there is nothing to apply here ahead of it, and inventing an interim version of it in this
PR would add the eighth lifecycle event the suggestion is warning against.

The pointer was checked by content rather than by title, because a deferral to an issue
that does not actually carry the mechanism is a dead pointer. #12528 is open, labelled
deferred-finding, assigned to chenmingwei23, Due: 2026-10-19. Its body states that
the own-store admission requires two sources to agree -- the durable execution record and
an identity this process committed itself -- that the second is process-local so a restart
empties it while the durable records survive, and that re-establishing the vouched identity
on the rehydrate path needs a value the session cannot write. That last line is this
suggestion's mechanism, already inside the issue's scope, so the constraint lands where the
work will happen.

One scoping note, stated so a reader does not have to infer it. This PR's last change to
that map's lifecycle narrowed an existing event rather than adding one: a persistent
session's vouch now survives a non-destructive close, so the close path withdraws less than
it did. This round therefore did not grow the enumeration the suggestion is measuring.
That is not offered as a rebuttal -- the count is still what the lane says it is, and the
stopgap reading stands.

@github-actions

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of 7046da5ac385029c799063e0fda557d5fa9a3650 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 7046da5

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 7046da5ac385029c799063e0fda557d5fa9a3650: <one-sentence reason>

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

The lane's reading is correct and this PR does not dispute it. The vouched map is the only
source of own-store authority, it is process-local, and it is deliberately not rehydrated.
A gateway restart therefore drops every entry while the durable records survive, and each
member session's own-store create_session is refused until its owner re-selects the
agent. The lane is also right that this lands per session rather than once, so on a
deployment where members dispatch their own workers the refusal arrives for every affected
session at the same moment.

Deferred to #12528, re-verified before citing it: open, labelled deferred-finding,
assigned to chenmingwei23, Due: 2026-10-19. Its body states the mechanism this needs --
re-establishing the vouched identity on the rehydrate path requires a value the session
cannot write -- so the pointer carries the work rather than only the topic.

Why it is not fixed here rather than deferred. The only re-establishment reachable on the
rehydrate path is one the session itself influences: the record is written by the session,
the slot's store is rehydrated from that record, and a config lookup keyed by that record's
own member id agrees with a forged record by construction instead of checking it. Two
separate blocking findings on this PR came from exactly that shape -- a publication and a
rollback each vouching a value taken from the record -- and both were fixed by refusing to
vouch, not by finding a safe way to re-derive. Re-establishing authority at rehydrate needs
an independent writer, which is a different design.

What a maintainer should have in front of them, because the cost is real and this record is
where it is disclosed. The recovery is one owner action and it ships documented:
docs/system-specs/modules/session-control.md names the symptom, says re-selecting the
member's agent restores dispatch, and states that re-picking the agent already named works,
because the owner-facing switch endpoint passes replace=True and so does not hit the
unchanged-selection early return. That was checked against the call site rather than
assumed.

The honest limit on that recovery: the refusal names neither the store nor the member, so a
member session cannot diagnose it and the owner has to recognise the symptom. That is the
operational cost of the interim design, and it is the cost #12528 removes.

Both branches this item offers to clear on are outside what an agent may supply -- separate
work, or a human's explicit acceptance of the interim behaviour. That is why this is a
record and not another patch.

…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
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

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:

  • The persistent exit of bind_session_execution writes no live carrier. Correct.
  • create_session refuses every non-persistent caller before the same-store check. Correct.
  • Therefore caller_execution.store on that path is always the disk transcript record. Correct.
  • The transcript store leaf carries no OS mask, so a same-UID in-sandbox open() reaches it. Correct.

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 now

Your 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:

  1. the caller's durable execution record, which the session itself can write, exactly as you described; and
  2. this process's vouched identity for that session, held in a map written only by bind_session_execution and reachable by no session at all.

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 3564f00f6745b59338e761fbebc70872e315b936, the head you source-verified. _VOUCHED_EXECUTIONS has no occurrences at that commit and fifteen at the current head, so the code you read genuinely did not have a second source. Current head is 9aa4601be8a39a423192c66422237332ea99efc0.

The Design suggestion you flagged

Taken. 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 review

The same class you identified recurred three more times once the second source existed, and each one is fixed rather than argued away:

  • A publication no longer vouches a store carried over from the session's own record. Collapsing the two sources into one caller-controlled value was the same forgery your review described, one layer up.
  • The rollback of a restricted admission now always withdraws the vouch instead of restoring the prior one, so publish-then-rollback cannot leave a vouch behind for a store the session chose.
  • Neither entry point to the vouched map vouches by default. A binder that says nothing publishes the record and claims no authority, so a path that has not thought about provenance cannot inherit authority by silence. The dashboard fork was exactly such a path: it binds what it reads from the SOURCE session's record.
  • A member-less identity is refused the vouch outright. No member means the Global store, and the admission identifies its caller by member, so such an entry could never be admitted.

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 bolichen97 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.

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 buluoray 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.

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_EXECUTIONS is still written only on the non-persistent exit, but the persistent exit now also calls _vouch(...) when the binder passed vouch=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_execution can still answer from disk, but the admission now also reads caller_vouched = read_vouched_session_execution(...) (:1158) and requires caller_vouched.store == caller_execution.store (:1371-1372). _VOUCHED_EXECUTIONS is a process-local OrderedDict (execution_context.py:41) with no on-disk form, so a sandboxed open() cannot write the second source.
  • L4 still holds and is uncontested — only cron-history is 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

readiness: passed Eligible automated validation passed for the current revision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

session-control: an unbound caller reaches a member's private store by selecting that member's agent

3 participants