Files
buzz/docs
DuncanandWill Pfleger 6607eaf55e fix(acp): structural round — one nonce-keyed permission record, finish_permission() helper
Implements Thufir's minimal shape across three passes of residual defects:

Harness (acp.rs):
- Remove PermissionEntryState::Resolved — entries are removed from the map
  on every terminal transition (applied/timed_out/cancelled). The absence
  of a nonce is the replay guard; no tombstones means capacity counts only
  live (Pending|Writing) requests, fixing the 9th-request-in-one-turn bug.
- Add finish_permission() terminal helper owning Pending→Writing→Resolved
  for all terminals. Exactly one write+flush, exactly one nonce-correlated
  authorized acp_write with the terminal reason. Any write failure poisons
  the process and emits a permission_terminal observer-only event so Desktop
  can retire the card (the uncertain path).
- Cancel path: write failure also poisons and emits permission_terminal.
  cancel-during-write emits permission_terminal for the in-flight entry.
- Re-arm idle deadline when live pending count reaches zero so a slow human
  decision grants a fresh idle window instead of insta-cancelling the turn.
- Capacity check now counts only live (Pending|Writing) entries.
- Clippy: fix assert_eq!(x, true) → assert!(x), while-let-loop, doc
  overindented list items in acp.rs and config.rs.
- Fmt: cargo fmt applied.

Desktop (agentSessionTranscript.ts):
- acp_write authorized frames correlate exclusively by authorization.requestNonce
  (primary); JSON-RPC id correlation is a legacy fallback for non-ask paths.
- Terminal copy derives from authorization.reason (applied/timed_out/cancelled/
  uncertain) via describePermissionTerminalReason — timeout now renders 'Timed out'
  not 'Denied (reject_once)'.
- set actionable: false on all retirement paths.
- permission_terminal observer event handler retires the card via nonce.
- turn_completed and turn_error backstop: retireAllLivePermissionCards() retires
  any still-live cards so missing telemetry and archive replay cannot reconstruct
  live controls.
- Biome format applied.

lib.rs:
- fit_observer_event_to_budget: early return without mutation when
  event.authorization.is_some() — authorized frames are never leaf-trimmed
  or stubbed (NIP-AO §3 byte-for-byte requirement).
- Enqueue suppresses over-cap authorized frames entirely (defense in depth).
- Test: test_authorized_frame_payload_is_never_trimmed.

Tests:
- ask_production_path_emits_request_captures_nonce_and_delivers_decision:
  real script emits session/request_permission, harness captures nonce from
  in-process observer, routes decision through channel, asserts end_turn.
- cancel_writes_exactly_one_response_per_pending_id_no_replay: registers
  entries via production path, captures nonces before cancel, verifies each
  emitted cancel nonce matches a registered entry nonce, verifies no replay.
- ask_permission_idle_is_suspended_while_pending_entry_exists: paused-time,
  asserts entry present at 299s.
- ask_permission_deadline_fires_at_300_seconds: paused-time, asserts entry
  removed at exactly 300s.
- ask_permission_idle_rearmed_after_last_entry_resolves: paused-time,
  proves idle deadline re-armed after decision applied.
- ask_nine_sequential_requests_all_succeed_after_capacity_recovery: nine
  sequential requests each decided before the next is queued; asserts 9
  distinct authorized acp_write observer nonces.

NIP-AO.md:
- session_resolved = session establishment (not terminal).
- Added turn_completed and turn_error rows as terminal lifecycle events.
- uncertain path: permission_terminal observer event replaces wrong
  session_resolved reference.

Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
2026-08-07 11:25:19 -04:00
..
2026-07-21 17:16:23 +00:00