You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d4dbd0e
Browse filesBrowse the repository at this point in the historyBrowse files
Sean Smith
authored and
Sean Smith
committed
session/attachment: gate supplemental borrow on scope resolution (CP-032 R-08)
A scope that has published its resolution stays registered until `closeNow`
unregisters it, and `locate` returned it to `executeSupplement` as borrowable.
Borrowing one loses the supplement's answer silently: `own()` returned on the
`state.closed` guard before reaching the throw, so no typed refusal was minted,
and `result()` short-circuits on `state.resolution` and replays the earlier
resolution and fallback. The run then files the earlier controlling position,
which `ledger.filed` already holds, and its own distinct answer disappears with
no note and no error. Once CP-032 B-1 parks an owner run inside `Scope.result()`
that window covers every concurrent supplemental sequence rather than a few
fiber hops.
Adds `AttachmentCoordinator.locateBorrowable`, which answers the borrow question
only. Raw `locate` is deliberately unchanged: of its three production consumers,
`tool/task.ts:289` reconciles the carried parent scope by object identity and
fails the call on disagreement, and `session/attachment/participant.ts:124`
reports covered edges for closure proof and must not narrow the proven set. A
global resolved-filter inside `locate` would regress both.
`open` now replaces a RESOLVED incumbent in place instead of failing, via a
private `resolved()` thunk on the registry entry rather than a new field on
`AttachmentContract.Current`. The check-and-swap is one `Effect.sync` critical
section and `closeNow` runs inside `transition`, so it is atomic without a new
lock. A live incumbent still loses the exclusive open, so a degraded-but-
unresolved scope keeps throwing from `own()` and keeps producing CP-031's
recoverable admission failure.
`Scope.own` now returns whether ownership was taken. A borrow check cannot rule
out resolution by itself: `promptAdmitted` yields through `revert.cleanup` and
`createUserMessage` between discovery and ownership, so a scope live at lookup
can resolve before the claim. Returning false lets that boundary raise
`SessionScopeOwnRefused` before `onAdmitted` fires, routing the supplement to
the sanctioned pre-admission note instead of a stale replay. The no-op itself is
preserved and load-bearing -- taking ownership would `invalidate()` a settled
candidate and let `result()` fall through to a different fallback -- so the
non-admission callers at prompt.ts:525 and prompt.ts:1235 ignore the result and
"ownership arriving after the successful gate closes is a no-op" passes
unchanged.
Fence bindings are deliberately untouched. A ref authorizes the exact scope
generation it was captured on; replacement rewrites only `registry.scopes`, so
an old ref keeps cancelling its own generation and never reaches the successor.
Files: packages/opencode/src/session/attachment/coordinator.ts,
packages/opencode/src/session/prompt.ts, packages/opencode/src/tool/task.ts
0 commit comments