Skip to content

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.asked with data: { sessionID, id, action, resources, source?, message? } and permission.replied with data: { sessionID, requestID, reply: once|always|reject } (@opencode/schema/dist/permission.d.ts, protocol/dist/groups/event.d.ts). Both are subscribable via ctx.event.subscribe({ types: [...] }).
  • Plugin reply surface: ctx.permission.reply({ sessionID, requestID, decision, message? }) where decision: once|always|reject (PermissionReplyInput, client/dist/promise/generated/types.d.ts:5116). ctx.permission.list/get/hook("evaluate")/assert also 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 --version below (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: ApprovalKind gains native; new ApprovalSource (native | agent | workspace | memory); Approval.source? (backfilled by approvalSource() 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 one native approval { permissionID, sessionID, action, resources } plus a Native permission needs a decision system line. Replied resolves it (once|always→approved, reject→rejected) with no host call (host already answered).
    • approval.resolve on 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 interrupted approvals: retriable inside budget (backoff 5s/60s, error kept, no approval), terminal via failTask (failure surfaces as failure). Store restart recovery (store.ts load) requeues working→pending with attempts kept, interrupted: false, and mints nothing.
    • toolAsk parks 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).
    • settlePendingApprovals now settles every kind tied to finished work (previously only ask/interrupted — outside_roster/cross_project went stale); run success and failTask settle linked product rows as superseded, excluding native. Binding replacement settles native mirrors of the dead session.
  • TUI: inbox rows carry [Native|Agent|Workspace|Memory] tags (approvalSourceTag in tui/chrome.ts, rendered in ApprovalList); work rows treat native-blocked subtasks as needs-you (isNeedsYouTask third param, wired in app.tsx).
  • Compatibility preserved: coordination, handoffs, DMs, $Name routing, wizards/dialogs untouched; all prior UI behavior unchanged except the inbox tag prefix. Legacy interrupted resolve paths kept for old rows.

Acceptance mapping ​

  1. Mirror native permissions — subscribed to the supported permission.asked/permission.replied events; resolving a native approval replies on the native session (once/reject); documented above. Covered by ticket68: a native permission request gates work and resolves through the host and ticket68: resolving a native approval replies on the native session.
  2. Product decisions gate dependent work — ask_person keeps approvalID linkage (pump excludes it) and no longer finalizes a reply while pending; source labels agent/workspace/memory. Covered by ticket68: ask_person parks the run until the user answers (+ label unit tests).
  3. 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).
  4. 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 by ticket68: settling work rejects stale product approvals of every kind and the workrows/chrome label tests.
  5. Compatibility — full unit suite, both fake live harnesses, and the real test:live all pass unmodified apart from the intended test updates.

Checks (exact) ​

CheckResult
npm run check (tsc --noEmit)Pass
npm test (node --test, all suites)Pass — 308 tests, 0 fail
npm run test:live:fakePass — fake live-check passed, incl. approvals empty-inbox assertion (Nothing waits for you.)
npm run test:live:fake:emptyPass
npm run test:live (real host)Pass
git diff --checkClean, 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.asked crossed the harness. The host reply path (ctx.permission.reply decision shapes) is covered by fake-ctx unit tests, not by a live host round-trip.
  • permission.asked payload shapes are filtered defensively (String(...) coercion, owner check, dedupe by permissionID); an unrecognized host shape fails open (no approval) rather than crashing.
  • Legacy interrupted rows 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:

CheckResult
npm run check + git diff --checkPass, clean
npm testPass — 319 tests (308 ticket-#68 suite + 11 from #69), 0 fail
npm run test:live:fakePass
npm run test:live:fake:emptyPass
npm run test:live (real host, opencode v2.2.5)Pass

Worktree clean at 6425b98. Issues #66/#68 left open (not closed).

Released under the MIT License.