Repository navigation
fix(sessions): prevent lifecycle races and unsafe session management - #114477
Conversation
96907c0 to
56f7b2e
Compare
|
Codex review: needs maintainer review before merge. Reviewed July 27, 2026, 6:10 AM ET / 10:10 UTC. ClawSweeper reviewWhat this changesThe branch serializes session lifecycle work, makes plugin ownership authoritative for session operations, refreshes subagent inheritance after final tool policy, adds a Merge readinessKeep this PR open for maintainer review. It is a broad, evidence-backed hardening patch with no newly supported line-level correctness defect in the supplied diff, but it intentionally changes the plugin session-ownership contract: previously permitted cross-owner patch, reset, delete, fork, link, and adoption paths now fail closed. The Likely related people: Priority: P1 Review scores
Verification
How this fits togetherAgent-facing flowchart LR
A[Agent session tools] --> B[Gateway session APIs]
B --> C[Ownership and visibility checks]
C --> D[Lifecycle admission]
D --> E[Persisted session records]
A --> F[Subagent launch]
F --> G[Final authorized tool policy]
G --> H[Child agent session]
Decision needed
Why: The implementation is mechanically coherent and the PR expressly frames this as an intentional compatibility and authorization-boundary change, but only maintainers can decide whether that breaking plugin-runtime contract is the desired product policy. Before merge
Agent review detailsSecurityNone. PR surfaceSource +256, Tests +848, Docs +8. Total +1112 across 32 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land only after a responsible owner explicitly accepts authoritative same-plugin ownership as the permanent plugin-runtime contract and the remaining exact-head checks finish green; retain the focused ownership, lifecycle-generation, and concurrent-operation coverage as the regression boundary. Do we have a high-confidence way to reproduce the issue? Yes, at source level: the supplied related reports provide concrete direct-Gateway reproduction paths for cross-owner patch and fork access, missing inherited MCP tools under restrictive policy, and absent per-call subagent timeouts. I could not independently execute those paths because the read-only command sandbox rejected repository commands before they ran. Is this the best way to solve the issue? Unclear: the shared ownership and lifecycle approach is a maintainable consolidation, and the PR avoids a parallel session-create route, but accepting unconditional fail-closed behavior for existing plugin callers is a maintainer policy choice rather than a purely technical conclusion. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against b8e7f27ff254. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles) |
|
Validation update for reviewed head
Security/compatibility decision: session ownership is authoritative. Plugins may mutate, adopt, reset, delete, fork, or link only their own sessions; cross-owner requests intentionally fail closed. Model-facing reset/delete must obey visibility and lifecycle-generation guards, and persistent creation remains on the existing authorized visible-spawn path. No runtime compatibility fallback for cross-owner mutation is intended. Remaining landing gate: reproduce and repair the Linux |
|
Final immutable-head proof for
Maintainer-requested policy decision: plugin session ownership is a fail-closed security boundary; cross-owner adopt, patch, reset, delete, fork, and link are intentionally denied. The final race fix waits only for the already-scheduled canonical SQLite projection rebuild and does not introduce a file fallback or schema migration. |
|
Merged via squash.
|
…penclaw#114477) * fix(sessions): harden lifecycle, ownership, and subagent spawning * test(agents): refresh session tool prompt snapshots * fix(sessions): await rebuilding transcript projections --------- Co-authored-by: Peter Steinberger <[email protected]>
Closes #114187
Closes #113005
Closes #103089
Closes #103077
Related: #106641
What Problem This Solves
Fixes an issue where users creating or managing sessions could lose concurrent session records, target the wrong session generation during deletion, bypass plugin ownership during patch/fork/link/reset, or lose bundled MCP tools and per-run timeout control when spawning subagents. Visible session creation now remains on the existing controlled spawn path instead of introducing a separate route around inherited tool policy, sandboxing, depth, and concurrency limits.
Why This Change Was Made
Serialize session creation on canonical lifecycle identities, enforce one storage-neutral plugin ownership contract for create/adoption, patch, delete, and reset, and bind archive-then-delete to the exact returned session generation. Materialize inherited MCP capabilities after final tool-policy/schema projection and expose the canonical per-run timeout consistently for native, ACP, and visible subagent runs. Preserve plugin ownership across reset and when a plugin reset materializes a missing session.
User Impact
Agents can safely reset and delete visible sessions, spawn visible and background sessions through the normal capability-controlled path, retain authorized bundled MCP tools, and set bounded run timeouts. Plugin-owned sessions cannot mutate or destroy operator-owned or foreign-plugin sessions, and concurrent session creation, reset, and deletion preserve the correct session records.
Evidence
sessions.sendwhile a SQLite transcript projection is rebuilding.225cef8ebfa7a27428e53253468475fddda8502e:Run Native live gateway fresh OpenAI API-key default, including successful repository-secret auth/profile hydration and target-SHA verification. The four mock-provider Gateway scenarios are reported separately and are not represented as real-provider proof.Ownership and compatibility decision
Session ownership is authoritative: a plugin can adopt, patch, reset, delete, fork, or link only sessions owned by that same plugin. Cross-owner operations intentionally fail closed; no compatibility alias or runtime fallback is intended. Model-visible reset and delete require existing visibility, current-session refusal, archival, and exact lifecycle-generation guards. Persistent creation remains on the existing capability-controlled visible-spawn path.
Final immutable-head validation
check-prompt-snapshots,checks-node-compact-small-2, production/test types, build artifacts, and security and QA shards.225cef8ebfa7a27428e53253468475fddda8502e.95637f7056835fea66bdd0044414af480fc0fd74:dynamic_tools.rs#L13,thread.rs#L127,router.rs#L43, and the dynamic-tool app-server regression.