feat(audit): surface subtool audit - #1641
Conversation
PR Review SummarySize
Affected crates
Blast radius — ContainedThis PR touches: source code Updated automatically on each push to this PR. |
c606e03 to
327fb89
Compare
327fb89 to
9c25026
Compare
9c25026 to
e813ff7
Compare
Adds a closed outcome classification for command policy decisions, typed at the CLI emitters that author the vocabulary, and folds terminal decisions into a per-session rollup held in session metadata. Only terminal decisions count, so an invocation gate followed by its terminal decision records a single invocation. Covers the rollup with the session digest, so an edited summary no longer matches the digest committed to the ledger. The field is skipped while unset, keeping the digests of metadata written before it existed unchanged. Refs: #1574 Signed-off-by: Kurtis Charnock <kurtis@nolabs.ai>
Carries the recorder's command policy rollup into the session metadata written when a supervised run exits, on both the rollback and audit-only paths. Denormalising the rollup at finalize keeps later readers off the event log, so listing sessions costs the same whether a run mediated one tool call or millions. Refs: #1574 Signed-off-by: Kurtis Charnock <kurtis@nolabs.ai>
Prints a per-session rollup of mediated commands under each entry in `nono audit list`, naming the commands and highlighting denials, and exposes the same rollup through `--json`. A tool-sandbox decision is now visible without guessing which session to run `audit show` against. Sessions that mediated nothing print no extra line, and `--no-tools` suppresses the rollup. A session whose mediation never reached a terminal decision reports that rather than reading as untouched. Refs: #1574 Signed-off-by: Kurtis Charnock <kurtis@nolabs.ai>
Adds a mediated-command rollup to `nono inspect`, recomputed from the audit event log because session metadata carries one only once a session finalizes. `[live]` marks counts that are not final, and a log ending mid-record is reported rather than passed off as complete. Decision strings fold through a frozen classification, so an old log summarizes as it was written, and the session directory is confirmed to resolve inside an audit root before it is read. Folds the sandbox runtime event's tool_sandbox_active flag into the rollup, so a session that configures mediation produces a summary even when no mediated command is ever invoked. `nono audit list` renders that as `tools: active, no invocations`, separating a session that mediated nothing from one that ran without mediation at all. The flag comes from a sandbox runtime event recorded on Linux only, so a macOS session reports mediation inactive and is recognisable only by recorded decisions. Refs: #1574 Signed-off-by: Kurtis Charnock <kurtis@nolabs.ai>
e813ff7 to
897fb11
Compare
| let reader = BufReader::new(file); | ||
| let mut events = Vec::new(); | ||
| for (index, line) in reader.lines().enumerate() { |
There was a problem hiding this comment.
Any reason for dropping BufReader and using read_to_string?
The advantage with BufReader, it reads chunks and streams, which has a lower memory footprint, compared to read_to_string which reads the whole file into mem first, then iterates over its lines. I guess on most systems that might be ok, but some audit-events.ndjson may get big over time if not pruned.
| self.command_policy_summary.observe_mediation_active(); | ||
| } | ||
| self.append_event(AuditEventPayload::SandboxRuntime { event }) | ||
| } |
There was a problem hiding this comment.
maybe worth a switcheroo on these;
self.append_event(...)?;
self.command_policy_summary.observe_mediation_active()
If there is any sort of recoverable failure in self.append_event, it stops the in-memory summary being written into session.json during the finalization later on
- Summary state changes in memory.
- writes to audit-events.ndjson fails.
- The session continues and later finalizes successfully.
- session.json contains a summary claiming an event/state that the audit log does not contain.
This might be not be a valid review though, if self.append_event is solid around safe failing - but even still it might be good from a defensive point of view.
Linked Issue
Closes #1574
Summary
Records a per-session rollup of tool sandbox command-policy decisions, surfaced in
nono audit list,nono audit show --jsonandnono inspect.Test Plan
Run steps manually:
Checklist