fix(terminal): terminal.session fails honestly instead of minting a false receipt - #374
Open
gnanirahulnutakki wants to merge 1 commit into
Open
fix(terminal): terminal.session fails honestly instead of minting a false receipt#374gnanirahulnutakki wants to merge 1 commit into
gnanirahulnutakki wants to merge 1 commit into
Conversation
…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>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #354.
terminal.sessionwas a silent no-op that still minted apermitted: truereceipt — false success plus false signed audit evidence.Root cause
crates/terminal/src/tools.rsTerminalSessionTool::invoke: afterensure_authorized, it readsession_id/action, never touchedcommand, and returned{"status":"ok"}withreceipt("terminal.session", …), whosereceipt(...)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)
ToolError::NotImplemented(String)tocrates/tool-registry/src/error.rs— the tool-independent "registered but backend unimplemented" class.terminal.sessionnow returnsErr(NotImplemented)after the capability check (so an unauthorized caller still getsCapabilityDenied, 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 toolErrreleases the cost reservation, fires the error lifecycle, and returns without pushing aToolCallReceiptor minting — so an honest error produces no fabricatedpermittedreceipt.map_tool_erroralready has a catch-all arm and there are no exhaustiveToolErrormatches, so the new variant is low-ripple.terminal.exec(which executes for real) is untouched.Tests
terminal_session_fails_honestly_and_mints_no_receipt— assertsErr(NotImplemented); fails against the oldOk{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— passcargo clippy -p ardur-terminal -p ardur-tool-registry --all-targets -- -D warnings— cleancargo fmt --check— cleanNot merged — left for peer review.