Repository navigation
feat(cli): tole audit prints the delegation tree read-only (#585) - #629
Merged
Merged
Conversation
tole audit [goal] [--json] prints this workspace's delegation tree: the goals, or one goal's nodes with profile, mode, status, depth, budget carve against measured and charged use, allow list with dropped patterns, lease paths, report summary and reason. It reads only the delegation log in the data dir, without the host lock and without repairing a torn line; it writes nothing, reads nothing from the children's agent dirs and makes no network call. The task is one capped line, summaries and reasons are capped, control characters are dropped, and every string is redacted through the process SecretSet. Closes #585
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
| let nodes: Vec<Value> = d.tree(goal).into_iter().map(|n| node_json(&d, n)).collect(); | ||
| json!({ "log": log, "goal": goal, "nodes": nodes }) | ||
| } | ||
| }; |
| "{}\n", | ||
| serde_json::to_string_pretty(&value).map_err(|e| e.to_string())? | ||
| )); | ||
| } |
node_json capped and normalized the task, report summaries and reasons before the SecretSet pass, so a secret that straddled the 120 or 400 character cut, or held whitespace or control characters, was no longer matched and leaked. Each raw string is now redacted first, then control characters are dropped, whitespace collapsed and the text cut; a cut that would split a «NAME» marker drops the whole marker. The final redact_value pass stays as a second pass. Delegation::poll is documented as a pure lookup, with a test that audit and poll write nothing on a tree with a queued spawn and a running child whose process is gone.
# Conflicts: # CHANGELOG.md
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.
What
The last part of #585 (epic #583). Closes #585.
tole audit [goal] [--json]prints this workspace's delegation tree, read-only. Without a goal it lists the goals. With one it shows each node's:Why
Design
docs/profiles-collaboration-secrets.mdA8.2: every delegated run is an ordinary durable session, and the ledger records the tree (who spawned whom, budget, allowlist, workspace).tole audit <goal>prints it top-down.Owner rules that apply:
Changes
crates/tole-cli/src/audit.rs(new):audit(log, goal, json, secrets).delegate::log_path, outside every workspace, never child-writable), throughDelegation::open. That opens without the host lock and never repairs a torn line, so it writes nothing.SecretSetfirst, so a secret that would straddle the cut, or one that contains whitespace or control characters, is matched whole.«NAME»marker drops the whole marker.redact_valueagain, which also covers ids, paths and allow patterns.crates/tole-cli/src/main.rs:Command::Audit { goal, --json }(config gateSkip);--workspace, else cwd) and the log path intole_data_dir();SecretSet::from_env();crates/tole-core/src/delegation.rs:goals(),charged(id)andleases_of(id);pollis documented as a pure lookup in the folded state that reads, settles or writes nothing.docs/threat-model.md: atole auditentry;CHANGELOG.md;README.mdstatus line and command list;docs/epics.md: feat(core): delegation — budget carve, depth 2 (max 3), write lease and mandatory report #585 marked done.Testing
Unit tests (
audit_tests.rs, 6):a_secret_across_the_task_cut_never_leaks_a_prefix: a secret starting 10 characters before the 120-character cut leaks no prefix, and every line has balanced«/».a_secret_with_whitespace_or_control_characters_is_redacted: a secret with a double space and one with an ESC are both redacted to their«NAME»markers.pollfinding (a false positive):audit_and_poll_never_settle_or_write_even_with_work_pending. On a tree with a queued spawn and a running child whose process is gone,pollandauditleave both nodes as they were and the log bytes unchanged.End to end (
tests/audit_cli.rs): the real binary finds the log in the data dir, redacts a secret from its environment, and leaves the log unchanged.Each rule was broken on purpose; the matching test went red, and green again once restored:
SecretSetCommands (
CARGO_TARGET_DIRset explicitly,CARGO_INCREMENTAL=0, debuginfo off;df -h /checked first):cargo fmt --all: cleancargo clippy --workspace --all-targets -- -D warnings: cleancargo test --workspace --no-fail-fast: 1548 passed, 0 failedcargo test -p tole-core --no-default-features: 536 passed, 0 failedcargo build -p tole-cli --no-default-features: okcora review --no-llm --staged: no issues foundSize: 10 files, +708/-4.
Known limits:
session) is shown; it is a path under the workspace, not a secret.