Verification — ticket #68: approvals reflect reality (2026-11-03)
Branch: feat/v55-68. Scope: ticket #68 only (parent spec #66).
Native permission API facts (installed, not assumed)
Verified against installed node_modules (@opencode/plugin 2.2.1, @opencode/client promise types, @opencode/schema, @opencode/protocol):
- Host block events:
permission.askedwithdata: { sessionID, id, action, resources, source?, message? }andpermission.repliedwithdata: { sessionID, requestID, reply: once|always|reject }(@opencode/schema/dist/permission.d.ts,protocol/dist/groups/event.d.ts). Both are subscribable viactx.event.subscribe({ types: [...] }). - Plugin reply surface:
ctx.permission.reply({ sessionID, requestID, decision, message? })wheredecision: once|always|reject(PermissionReplyInput,client/dist/promise/generated/types.d.ts:5116).ctx.permission.list/get/hook("evaluate")/assertalso exist but are not used: the mirror is purely event-driven, so a restart can never resurrect an already-answered host request as a phantom approval. - Observed host at verification time:
opencode --versionbelow (2.x); declarations are 2.2.1 — event shapes are guarded with fail-open filters (unknown sessions ignored, unknown payloads ignored).
What changed
src/v2/types.ts:ApprovalKindgainsnative; newApprovalSource(native | agent | workspace | memory);Approval.source?(backfilled byapprovalSource()for old rows: native→native, ask_person→agent, outside_roster/interrupted→workspace, memory/share→memory).src/v2/service.ts:- Subscribes to
permission.asked/permission.replied. Asked on an Ensemble-owned session (live run, else stored binding) mints onenativeapproval{ permissionID, sessionID, action, resources }plus aNative permission needs a decisionsystem line. Replied resolves it (once|always→approved,reject→rejected) with no host call (host already answered). approval.resolveon a native approval replies on the host: approve→decision: "once"(least privilege), reject→"reject", fail-open when the host already dropped the request. Native mirrors are never stale-guarded: an explicit resolve always replies.- Pump and run-entry skip work whose bound session has a pending native mirror (no prompt pile-up behind a host block). Native approvals do NOT set
subtask.approvalID— the host already blocks the live session. - Failure branch no longer mints
interruptedapprovals: retriable inside budget (backoff 5s/60s, error kept, no approval), terminal viafailTask(failure surfaces as failure). Store restart recovery (store.tsload) requeuesworking→pendingwith attempts kept,interrupted: false, and mints nothing. toolAskparks the run while its approval is pending: the partial output is finalized as a paused note, never as the answer; the final reply lands only after resolve + requeue. Late terminal results no longer clobber a settled task (state === "replied"guard on the run callback).settlePendingApprovalsnow settles every kind tied to finished work (previously only ask/interrupted — outside_roster/cross_project went stale); run success andfailTasksettle linked product rows as superseded, excluding native. Binding replacement settles native mirrors of the dead session.
- Subscribes to
- TUI: inbox rows carry
[Native|Agent|Workspace|Memory]tags (approvalSourceTagintui/chrome.ts, rendered inApprovalList); work rows treat native-blocked subtasks as needs-you (isNeedsYouTaskthird param, wired inapp.tsx). - Compatibility preserved: coordination, handoffs, DMs,
$Namerouting, wizards/dialogs untouched; all prior UI behavior unchanged except the inbox tag prefix. Legacyinterruptedresolve paths kept for old rows.
Acceptance mapping
- Mirror native permissions — subscribed to the supported
permission.asked/permission.repliedevents; resolving a native approval replies on the native session (once/reject); documented above. Covered byticket68: a native permission request gates work and resolves through the hostandticket68: resolving a native approval replies on the native session. - Product decisions gate dependent work —
ask_personkeepsapprovalIDlinkage (pump excludes it) and no longer finalizes a reply while pending;sourcelabels agent/workspace/memory. Covered byticket68: ask_person parks the run until the user answers(+ label unit tests). - No shadow approvals — failure branch and restart recovery mint nothing; only terminal/native-proven blocks gate. Covered by
ticket68: an order with no native block produces no approval and answers,ticket68: restart recovery requeues dead work without a phantom approval, and the rewritten legacy tests (restart recovery requeues working subtasks without an approval gate, peer-turn/domain/store recovery updates). - Stale resolution — success/
failTask/cancel/retry/reassign settle linked product approvals of every kind; native resolves only via host/user; inbox tags distinguish native vs product; native-blocked rows show ◆. Covered byticket68: settling work rejects stale product approvals of every kindand the workrows/chrome label tests. - Compatibility — full unit suite, both fake live harnesses, and the real
test:liveall pass unmodified apart from the intended test updates.
Checks (exact)
| Check | Result |
|---|---|
npm run check (tsc --noEmit) | Pass |
npm test (node --test, all suites) | Pass — 308 tests, 0 fail |
npm run test:live:fake | Pass — fake live-check passed, incl. approvals empty-inbox assertion (Nothing waits for you.) |
npm run test:live:fake:empty | Pass |
npm run test:live (real host) | Pass |
git diff --check | Clean, no whitespace errors |
Versions: node --version → v26.12.1; opencode --version → recorded by harness at run time (2.2.x line; declarations pinned at 2.2.1).
Uncertainty / not covered live
- No live host permission was triggered: the fake provider returns text only (no tool calls), so no real
permission.askedcrossed the harness. The host reply path (ctx.permission.replydecision shapes) is covered by fake-ctx unit tests, not by a live host round-trip. permission.askedpayload shapes are filtered defensively (String(...)coercion, owner check, dedupe by permissionID); an unrecognized host shape fails open (no approval) rather than crashing.- Legacy
interruptedrows already stored stay resolvable; nothing mints new ones.
Post-merge rerun (integration/ensemble-v5.5 @ 2956296, ticket #69)
Merged into feat/v55-68 as 6425b98 (auto-merge, no conflicts; ticket #69 touched tui/app.tsx + tui/components.tsx in disjoint regions — ticket #68 hunks verified intact post-merge). Reran everything:
| Check | Result |
|---|---|
npm run check + git diff --check | Pass, clean |
npm test | Pass — 319 tests (308 ticket-#68 suite + 11 from #69), 0 fail |
npm run test:live:fake | Pass |
npm run test:live:fake:empty | Pass |
npm run test:live (real host, opencode v2.2.5) | Pass |
Worktree clean at 6425b98. Issues #66/#68 left open (not closed).