Repository navigation
fix(execution-context): narrow the vouched population to create-capable callers - #14737
Conversation
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: |
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Teardown comment at [DESIGN-REVIEWED] 8fd3da3 |
First Principles Review (Fable 5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Verify the now-stale comment at The narrowing is a pure subtraction with checkable provenance: issue #12611, deferred by parent PR #12467. I counted the vouched map's production readers — exactly one, What this change shipsInventory (3 items) — 3 justifiedIntent: FIX (deferred narrowing) — stop vouching hook sessions whose keys can never reach
[FIRST-PRINCIPLES-REVIEWED] 8fd3da3 |
…le callers Issue #12611 (follow-up to PR #12467's fence): `_vouch` retained an entry for every member-bearing `vouch=True` bind, including callers whose session key can never reach `create_session`, so those entries filled the capped `_VOUCHED_EXECUTIONS` map and were what the cap/LRU/overflow-tally/re-arm machinery existed to absorb. The vouched map's only reader is `create_session`'s own-store admission, which reads the entry for the CALLER slot (`session_control.py` `caller_vouched`). So a vouched entry is only ever useful if its session key can be that caller -- a real dashboard slot `caller_slot_key` resolves. Per the issues-conductor ruling (option a: restrict `_vouch` to callers whose session keys can reach `create_session`), the three `vouch=True` sites were classified against that predicate: - session_control `_persist_birth` -- binds the freshly created child slot, a real create-capable slot. KEEPS vouch. - member_memory_auth `bind_private_session_store` -- establishes own-store dispatch authority for a member's dashboard slot from a trusted store argument; its callers pass create-capable `dashboard:` slot keys and rely on the vouch for own-store dispatch (test_private_creator_keeps_its_memory). KEEPS vouch. - hooks `bind_captured` -- runs on a `hook:` synthetic key in an EPHEMERAL session `_run_hook_agent` destroys after the turn; it is never registered as a dashboard slot, so `caller_slot_key` never resolves it and it can never be the caller whose vouch `create_session` reads. DROPS to vouch=False -- the record is still published, so the hook turn is unchanged, but no slot is spent in the capped map. Tests co-designed with the call site: - test_every_binder_declares_whether_it_vouches: bind_captured pinned False. - test_a_hook_session_publishes_but_is_never_vouched (new): observable acceptance -- a hook key publishes its record but is not vouched, while a create-capable dashboard slot still vouches. Refusal invariants unchanged: a forged record still cannot obtain another member's store, and the cap/LRU/tally/re-arm and the withdraw-only-shrinks invariant remain correct for the reduced population.
1be6c86 to
8fd3da3
Compare
Opus 5 Review — ✅ no blocking findingsReviewed Review detailsNothing blocks; the hook path's removed vouch leaves its teardown comment and the owning spec stating the opposite. FINDING — src/kiro_crew/dashboard/handlers/hooks.py:1513 — with [OPUS-REVIEWED] 8fd3da3 Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
Problem / Motivation
Goal: Stop the execution-context vouching helper from retaining entries for callers that can never exercise them, so the vouched map holds only the population it exists to serve.
Follow-up refactor deferred by PR #12467's fence (issue #12611).
_vouchretained an entry for every member-bearingvouch=Truebind, gated only onmember_id(execution_context.pybind_session_execution), with no restriction to callers whose session keys can ever reachcreate_session. Teardown-less / per-request binders therefore filled the capped_VOUCHED_EXECUTIONSmap and were exactly what the cap, LRU refresh, overflow tally and re-arm machinery existed to absorb.Why it matters
The vouched map is one of the two sources
create_session's own-store admission requires to agree, and it is capacity-bounded (_MAX_VOUCHED_EXECUTIONS = 4096). Every entry that can never be read as a caller's vouch is dead weight that spends a slot, drives eviction of live member sessions under cap pressure, and enlarges the security-relevant "who is vouched" surface for no benefit. Narrowing the population is the smaller, safer default the parent PR deliberately left for a reviewed change of its own.Not a goal
_LIVE_EXECUTIONS(main's map) — explicitly out of scope per the parent PR.What changed (motivation → approach → change)
Root cause → approach → change:
Root cause. Vouching was gated only on
member_id, so it absorbed callers whose session key can never be thecaller_slotthatcreate_session's own-store admission reads (session_control.pycaller_vouched). That admission is the only reader of the vouched map, so a vouched entry is useful iff its session key can reachcreate_session— i.e. it is a real dashboard slot thatcaller_slot_keyresolves.Approach (issues-conductor ruling, option a). Restrict vouching to callers whose session key can reach
create_session. The predicate is applied at the call sites rather than inside_vouch, because_vouchis a pure primitive below thedashboard/layer and cannot seeDashboardState; the threevouch=Truesites were each classified against the predicate.Change. Classification of the three sites:
session_control._persist_birth— binds the freshly created child slot, a real create-capable slot. Keeps vouch.member_memory_auth.bind_private_session_store— establishes own-store dispatch authority for a member's dashboard slot from a trusted store argument (never from the session's own record); its callers pass create-capabledashboard:keys and rely on the vouch for own-store dispatch (test_private_creator_keeps_its_memory). Keeps vouch.hooks.bind_captured— runs on ahook:synthetic key in an ephemeral session that_run_hook_agentdestroys after the turn; it is never registered as a dashboard slot, socaller_slot_keynever resolves it and it can never be the caller whose vouchcreate_sessionreads. Dropped tovouch=False— one call-site flip.Deviation from the issue's two alternatives, recorded per the analyst's note that the implementer is closer to the code: only the hook binder unambiguously binds a non-create-capable key.
bind_private_session_storewas found load-bearing for real create-capable member callers, so option (a)'s predicate keeps its vouch rather than removing it.Backwards compatibility
Compatible: the only behavioral change is that a hook session is no longer vouched. Hook sessions are ephemeral (
hook:prefix, torn down after the turn) and are never acreate_sessioncaller, so no reachable code read their vouch —test_teardown_withdraws_the_vouched_execution_identity(which manually vouches a hook key to test teardown) still passes, and every member-memory-runtime / session-control / session-capabilities suite that relies on real slot vouching is green. The durable record is still published, so hook turns run unchanged.Tests
test_every_binder_declares_whether_it_vouches— updated:hooks.bind_capturedis pinned tovouch=False; the two establishing sites stayTrue. This AST enumeration reddens if any binder's vouch disposition drifts.test_a_hook_session_publishes_but_is_never_vouched(new) — observable acceptance for execution_context: narrow the vouched population instead of absorbing entries that never needed vouching #12611: ahook:key binding publishes its record (read_session_executionnon-None) but is not vouched (read_vouched_session_executionis None), while a create-capabledashboard:slot binding still vouches. Not asserted in prose.test_execution_context.py,test_webhooks_api.py,test_member_memory_runtime.py,test_session_capabilities.py,test_session_control.pyprivate-creator/worker-start paths,test_chat_hooks.py,test_hooks.py.Manual verification
N/A — unit coverage sufficient: the narrowing is a call-site vouch-disposition change with an observable map-level assertion and an AST enumeration test that pins every binder's disposition.
Related Issues
Fixes #12611
Pattern harvest
Rule candidate: review-prompt
Pattern: an entry admitted to a capped/shared map on a broad gate (here
member_id) when its only reader keys on a narrower identity (a create-capable caller slot) — admit on the reader's predicate, not the writer's convenience.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)