Commit Graph
6 Commits
Author SHA1 Message Date
grenadeandClaude Opus 5 467c8d35ad feat: severity depends on where a finding is, and judgements are remembered
Two mechanisms for the same complaint: nanny's own test fixtures were being
reported as critical, and dismissing them was per-row work that came back on
the next sweep.

Severity was purely a property of the rule — an Anthropic key is critical
because Anthropic keys are critical. That answers "what kind of credential"
and not the question an operator asks, which is what a leak at this location
costs them. A finding now carries the rule's severity, the effective one,
and the context that separates them; filters, sorts and alerts use the
effective one, and every demotion can state what it was and why. Contexts
are tests, benchmarks, fixtures, examples, documentation and .example
configs.

Demote, never drop. crates/nanny-core/src/scan.rs:271 should read
"medium - test fixture", not vanish: a tool that hides things is one you
cannot reason about, and nanny's silence is only worth something if it means
something. Demotion moves a finding below alert.min_severity, which stops
the interruption without losing the record.

Only in working trees. A .md in a repo is documentation; a .md in
~/.claude/projects/*/memory/ is an agent memory, which is exactly where a
real credential ends up. In a harness store there is no way to distinguish a
transcript quoting a test file from one that printed a live key, so nothing
there is demoted.

Rust needs more than a path rule, because its convention puts a
#[cfg(test)] mod tests inside the production source file — which is the
literal case that prompted this. Matches after that attribute in a .rs file
are classified as fixtures. Deliberately Rust-only: every other language
here keeps tests in their own files, which the path rules already catch.

The second mechanism is suppression. Marking a finding ignored settles one
row, but "that is an invented token" is true of the value wherever it turns
up next, transcripts included. Suppressions are keyed by fingerprint and
optionally scoped to a path prefix, so the table holds the same one-way
salted hashes as the findings table and no values — remembering a judgement
risks nothing the database did not already. Suppressed findings are still
recorded, as ignored, so the counts do not lie about what is on disk, and
each suppression tracks what it caught so one that stopped earning its place
is visible.

  nanny ignore 849 --everywhere
  nanny ignore --under ~/git/upstream --everywhere --note "their fixtures"
  nanny suppressions / nanny unsuppress <id>
  I in the triage screen, next to i

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XAqHWfdMAsYu1o36tgeima
2026-09-02 16:21:22 +03:00
grenadeandClaude Opus 5 04699f56ed fix(daemon): stop recursively watching $HOME and every working tree
Both the shell collector and the working-tree collector handed the watcher
their root directory, because that is what the port asked for. Rooted at
$HOME and ~/git, that asks the kernel for one inotify watch descriptor per
directory the user owns: 342 MB resident on this machine, plus a permanent
stream of permission denials from podman volume storage.

Neither watch bought anything. The shell history files that matter sit
directly in $HOME, and working trees are swept periodically precisely
because walking them is expensive — so every event they raised was
discarded.

watch_roots now returns WatchRoot { path, recursive }. A Periodic collector
registers no watch at all; the shell collector watches $HOME shallowly.
342 MB -> 49 MB, and the denials are gone. A test pins the policy, since the
regression is invisible in any fixture small enough to be a unit test.

Also moves StartLimitIntervalSec/StartLimitBurst to [Unit], where systemd
actually reads them — `systemd-analyze --user verify` was warning that it
was ignoring them in [Service].

Verified live: installed to ~/.local/bin, enabled as a systemd --user unit,
baseline swept 60849 sources / 977 MB, and a synthetic spill produced a
desktop notification.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XAqHWfdMAsYu1o36tgeima
2026-09-02 15:31:28 +03:00
grenadeandClaude Opus 5 eff78fcddf feat(cli): bulk triage, and stop truncating locations twice
Status changes take selectors — --rule, --harness, --under <path>,
--fingerprint — with --dry-run, alongside bare ids. A first sweep of a real
machine reports over a thousand findings, most of them the same few test
fixtures repeated through vendored dependencies, and dismissing those one id
at a time is data entry rather than triage: a tool that demands it gets
abandoned instead of tuned. --fingerprint is the useful one for a genuine
leak, since one rotation resolves every copy of the secret at once.

Also fixes the location column, which was shortened twice. short_path keeps
the tail of a path, then the table clipped the right-hand end, so the row
lost both the filename and the line number — the two things that identify a
finding. Column widths are now derived from the same constants as the
constraints, and format::location budgets for the line-number suffix before
shortening the path around it.

Verified by driving the TUI through a pty and reconstructing the frame.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XAqHWfdMAsYu1o36tgeima
2026-09-02 15:23:58 +03:00
grenadeandClaude Opus 5 510f856174 fix: make cursors round-trip, and stop re-walking trees on every event
Two defects found by putting the whole pipeline under test against a
synthetic home directory.

serde_json serialises an i128 happily and then refuses to read it back
inside an internally tagged enum, so every Cursor::Digest came back
unreadable. Unreadable cursors are treated as "never read this source",
which is safe and therefore silent: the whole-file fast path existed and
never once fired, and every memory, snapshot and working-tree file was
re-read on every sweep. Timestamps are now i64 nanoseconds, good to 2262,
with a round-trip test over every cursor variant. A warm sweep of a real
home directory drops from 25s to 3.3s.

Collectors now declare a cadence. Working trees and the opencode database
are Periodic; harness stores are Reactive. A sweep triggered by a file event
runs only the reactive collectors, because inotify fires every second or two
during an active agent session and re-walking a hundred thousand files each
time would leave the daemon permanently busy. Only a full sweep records
liveness, so `nanny status` cannot report health it has not established.

Adds end-to-end tests over a synthetic home, including the one that matters
most: dumping every text column of every row and asserting no part of any
planted secret appears anywhere in the database.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XAqHWfdMAsYu1o36tgeima
2026-09-02 15:19:35 +03:00
grenadeandClaude Opus 5 991ab992da docs: record the rotation seam and the exclusion evidence
Adds doc/rotation.md: what is already in place for optional rotation
(RotationHint, Status::Rotated, fingerprint-as-unit-of-work), what it would
take, and the four constraints a future executor does not get to relax —
chiefly that nanny holding provisioning credentials is the real cost of the
feature and must be opt-in per service.

Broadens the noise exclusions after a first sweep of a real ~/git produced
1030 working-tree findings, 273 of them from one crate's vendored
target/container/cargo/registry. Excluding all of target/ rather than just
debug/ and release/, plus vendored dependencies, build output, tool caches
and minified assets. .git/config stays readable: a password in a remote URL
is a genuine spill.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XAqHWfdMAsYu1o36tgeima
2026-09-02 15:13:30 +03:00
grenadeandClaude Opus 5 7ff8f5c8fa feat: watch local agent harnesses for leaked credentials
nanny scans the stores that claude-code, opencode and pi write — session
transcripts, agent memories, cached pastes, shell snapshots, tool output,
opencode's SQLite database — plus shell history and repository working
trees, and records where and when a credential leaked into them.

Detection is by shape alone. nanny deliberately has no read access to any
credential store (~/.agents, ~/.ssh, each harness's own auth file), so the
monitor is not itself a process worth compromising. The cost is false
positives, managed with per-rule confidence, entropy floors and allow
patterns.

The central invariant is that a matched secret never leaves the scanner:
Secret<'a> borrows, does not clone into an owned form, does not serialise,
and Debugs as <redacted, N bytes>. What is stored is a salted keyed hash, a
length, and a preview with every matched span masked — so nanny's own
database cannot become the next spill.

Records and alerts only; it never edits a harness's files. Rules carry a
RotationHint as the seam for optional rotation later.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XAqHWfdMAsYu1o36tgeima
2026-09-02 15:11:53 +03:00