Skip to content

tool-path writes (remember/update/import) still resolve session identity from ambient getCurrent() #121

Closed

Description

@WhollyMindless

Follow-up from #118's approval review (note 2): the capture path got its session threading (#116 → #118), but the three tool-path runWriteGate sites in src/index.ts (remember / update / import) still resolve identity from the ambient getCurrent().

The window is fs-sized rather than model-sized - the hooks dispatch with current bound to the calling session, and there is no long await before gateContext() is constructed - but between setCurrent in execute.before and the gate's OWN awaits (analysis, locked append), another session's dispatch can still move current and attribute the write: stamp, evidence, liveRoot. Same disease, smaller dose.

Right seam (deliberately not rushed in #118): the tool hooks carry sessionID per event; the execute bodies get identity only via the global. Either a per-callID binding (the before-hook already sees callID) or reading the sid off the tool execution ctx - whichever keeps gateContext(sid)'s call-site shape.

A red pin needs the same deterministic interleave as #118's (a park seam at a fs await inside the gate rather than the model call - the harness seam already exists), and must show BOTH shapes #118 established: gate judged the hijacker, and the row stamped the hijacker's repo.

Activity

  1. abogartz commented on Oct 27, 2026

    @abogartz
    Owner

    The identity threading this issue asked for ships in #133: toolIds(context) reads sessionID/id off the host's per-call ToolContext synchronously at tool entry (src/index.ts), gateContext(sid) carries it into the gate, importMemories takes the importing session explicitly, and the gate's dedup/stale reads partition on the write's session (loadScope(scope, readerForSession(ctx.sessionID))). All three sites named here (remember / update / import) plus list/recall/status are covered.

    One acceptance line from this issue is not delivered: the deterministic write-hijack red pin — "gate judged the hijacker, and the row stamped the hijacker's repo". #133's test/security-session-isolation.test.ts pins the injection shape (3 tests: mid-read ambient move, unbound fail-closed, single-session guard); the capture write path keeps #118's pin, but the tool-write hijack shape has no red test anywhere.

    Maintainer call on #133 merge: close as fixed-by-#133 accepting the injection pins as sufficient, or keep open as a test-integrity follow-up for the tool-write hijack pin.

  2. added
    verified-on-main
    on Oct 30, 2026
  3. abogartz commented on Oct 30, 2026

    @abogartz
    Owner

    Fixed — every tool-path gate now receives a per-call session id

    grep -n "gateContext()" src/index.ts returns zero hits: each of the four runWriteGate sites passes an explicit sid.

    • memory_remember → src/index.ts:442 runWriteGate(candidate, gateContext(sid)), sid from toolIds(context) (line 424)
    • memory_update → src/index.ts:692 { ...gateContext(sid), reader, supersedesTs, durable }
    • memory_import → src/index.ts:1142 const importGate = gateContext(sid)
    • capture → src/index.ts:1535 const captureGate = gateContext(sid)

    toolIds (src/index.ts:340-355) reads sessionID/callID off the tool execution ctx via toolIdentity() and binds a provisional session→dir mapping for a session this instance has not yet seen — the "read the sid off the tool execution ctx" seam this ticket named. getCurrent() survives only as the documented fallback when the ctx carries no sid, and gateContext's comment now states that contract explicitly.

    Remaining sub-item, if you want it as its own ticket: a red pin with #118-style deterministic interleave at a gate fs await is still not committed for the tool paths (no test file names #121). That is a test-integrity child, not a correctness gap.


    Severity triage 2026-10-30 — reviewed against main @ 525ed89 (v0.14.24). Labeled verified-on-main: the behavior this ticket describes no longer exists, so there is nothing to build. Full-suite baseline at that commit: 722 pass / 12 skip / 0 fail. Closing is your call; the evidence is here so the claim is checkable rather than asserted.

  4. abogartz-opencode-self-improvement commented on Oct 31, 2026

    @abogartz-opencode-self-improvement

    🎉 This issue has been resolved in version 0.14.27 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    releasedverified-on-main

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions