Skip to content

fix(terminal): terminal.session fails honestly instead of minting a false receipt - #374

Open
gnanirahulnutakki wants to merge 1 commit into
devfrom
fix/354-terminal-session-honest
Open

fix(terminal): terminal.session fails honestly instead of minting a false receipt#374
gnanirahulnutakki wants to merge 1 commit into
devfrom
fix/354-terminal-session-honest

Conversation

@gnanirahulnutakki

Copy link
Copy Markdown
Member

Summary

Fixes #354. terminal.session was a silent no-op that still minted a permitted: true receipt — false success plus false signed audit evidence.

Root cause

crates/terminal/src/tools.rs TerminalSessionTool::invoke: after ensure_authorized, it read session_id/action, never touched command, and returned {"status":"ok"} with receipt("terminal.session", …), whose receipt(...) helper sets "permitted": true. No session was created, no command executed, nothing closed — yet the signed receipt chain recorded a permitted action that never happened.

The persistent-session backend does not exist; the tool was a stub that faked success.

Fix (tightest scope)

  • Added ToolError::NotImplemented(String) to crates/tool-registry/src/error.rs — the tool-independent "registered but backend unimplemented" class.
  • terminal.session now returns Err(NotImplemented) after the capability check (so an unauthorized caller still gets CapabilityDenied, not a leak of the not-implemented state).

Why this removes the misleading receipt: the runtime mints a tool receipt only on the Ok path. In fused-runtime/src/runtime.rs, a tool Err releases the cost reservation, fires the error lifecycle, and returns without pushing a ToolCallReceipt or minting — so an honest error produces no fabricated permitted receipt. map_tool_error already has a catch-all arm and there are no exhaustive ToolError matches, so the new variant is low-ripple. terminal.exec (which executes for real) is untouched.

Tests

  • terminal_session_fails_honestly_and_mints_no_receipt — asserts Err(NotImplemented); fails against the old Ok{status:ok} + receipt behavior.
  • terminal_session_denies_unauthorized_before_not_implemented — pins the cap-check ordering.

Verification (local)

  • cargo test -p ardur-terminal -p ardur-tool-registry — pass (incl. 2 new regressions)
  • cargo test -p ardur-e2e-tests — pass
  • cargo clippy -p ardur-terminal -p ardur-tool-registry --all-targets -- -D warnings — clean
  • cargo fmt --check — clean

Not merged — left for peer review.

…alse receipt

`terminal.session` was a silent no-op: after the capability check it read
`session_id`/`action`, never touched `command`, and returned
`{"status":"ok"}` while minting a receipt marked `permitted: true`. No session
was created, no command run, nothing closed — yet the signed receipt chain
recorded a permitted action that never happened. False success plus false audit
evidence.

The runtime mints a tool receipt only on the Ok path (fused-runtime
runtime.rs: a tool `Err` releases the reservation and returns without pushing a
ToolCallReceipt), so returning an error is the honest-failure path.

Since the persistent-session backend does not exist yet, return a new
`ToolError::NotImplemented` after the capability check. Callers now see an
explicit not-implemented error and no permitted receipt is minted for
unperformed work. `terminal.exec`, which runs for real, is untouched.

Regression tests: `terminal_session_fails_honestly_and_mints_no_receipt`
(fails against the old ok+receipt behavior) and
`terminal_session_denies_unauthorized_before_not_implemented` (pins the cap
check ordering).

Fixes #354

Checkpoint: architect/sessions/issue-354-terminal-session-honest/journal.md
Signed-off-by: Gnani Nutakki <gnani.nutakki@gmail.com>
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5df5bf74-97b7-4485-91f3-ab9247a8d7ef

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/354-terminal-session-honest

Comment @coderabbitai help to get the list of available commands.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant