Skip to content

fix: humanize search, sessions, and mutation output#39

Merged
karngyan merged 1 commit into
mainfrom
fix/humanize-cli-output
Jul 17, 2026
Merged

fix: humanize search, sessions, and mutation output#39
karngyan merged 1 commit into
mainfrom
fix/humanize-cli-output

Conversation

@karngyan

Copy link
Copy Markdown
Contributor

Claim

The text-mode output of search, sessions, and mutations show is now scannable, basis-points jargon is gone from every text surface, the zero-finding digest no longer buries the signal under one-occurrence giants, and short id prefixes are accepted everywhere a stored id is a required argument. --output json is byte-for-byte unchanged — every new report field is #[serde(skip)] (or a transparent #[serde(flatten)] wrapper), so machine consumers see no change.

Before / after

search (text)

Before:

evt_claude_fc1bc1d7… (full 64-hex)	full_text	5000 bps	{"command":"mise exec -- [cargo] [test] -p ...

After:

evt_generic_3333eeee…    1d ago  demo  text  50.0%  mise exec -- [cargo] test -p autophagy-store --all-features ...

Full event ids, raw snippets, and the basis-points ranking fields remain in --output json (noted in search --help).

sessions (text)

Before:

SESSION\tSOURCE\tEVENTS\tLAST EVENT\tPROJECT
ses_claude_d19bfbd8…(71 chars)\tgeneric-jsonl\t2\t2026-07-16T10:01:00Z\t/workspace/demo

After:

SESSION                  SOURCE         EVENTS  LAST EVENT  PROJECT
ses_generic_9999cccc…    generic-jsonl       2  1d ago      /workspace/demo

Home-relative (~/...) projects; compact times; full ids and RFC3339 timestamps stay in JSON.

mutations show (text)

Before: header line + transitions only; the lesson lived in JSON.
After:

Prevent repeated command failure: shell: mise run check
id            mut_6b51ef81…
state         candidate
hypothesis    The recurring `mise run check` failure is caused or amplified by missing preconditions or unchanged retries.
intervention  Before running `mise run check`, verify its required preconditions. If it fails with exit code 1, do not retry it unchanged; ...
triggers      failure/v2|shell|mise run check|exit:1
evidence      3 events · 1 counterexamples
gates         5+ replays · 80.0% success · ≤10.0% false positives

2026-07-17T14:23:11Z	none -> candidate	generated from evidence

Near-miss / digest (text)

Before: five 1-occurrence rows ending in … bps support unmet: min_occurrences.
After (recurring candidate):

Repeated command failure: shell: mise exec -- cargo test -p…	2 occ · 1 sessions · 0 counterexamples · 100.0% support	needs 3+ occurrences, saw 2

After (nothing recurs):

2 candidate signatures, none recurring — nothing near threshold

Short ids

mutations show mut_6b51ef819f resolves the unique prefix; an ambiguous prefix errors with the candidates; next-step hints echo the short id the user typed. Applies to mutations show/challenge/reject/replay/replay-draft/shadow/shadow-draft/install/uninstall and delete session.

Evidence

New unit tests (bin autophagy): short_id_keeps_prefix_and_eight_digest_chars, short_id_leaves_already_short_ids_untouched, percent_renders_basis_points_to_one_decimal, clean_snippet_extracts_command_and_preserves_highlights, clean_snippet_handles_truncated_command_payload, clean_snippet_strips_json_framing_without_a_command_field, clean_snippet_leaves_plain_text_alone, truncate_words_cuts_at_a_word_boundary, truncate_words_leaves_short_text_unchanged, shorten_project_and_basename, resolve_stored_id_matches_a_unique_prefix, resolve_stored_id_passes_through_an_exact_full_id, resolve_stored_id_reports_an_ambiguous_prefix, resolve_stored_id_passes_missing_and_too_short_prefixes_through.

New integration tests (tests/cli.rs): search_text_humanizes_rows_while_json_keeps_full_fields, sessions_text_aligns_and_compacts_while_json_stays_stable, digest_summarizes_when_no_candidate_recurs, mutations_show_text_renders_the_lesson, short_mutation_id_prefix_resolves_and_hint_echoes_it. Updated setup_digest_surfaces_scan_stats_and_observations_when_nothing_qualifies for the plain-language gate phrasing.

mise run check is green (ci + docs + fmt + lint + test).

Privacy

Presentation only. Snippets rendered in text mode are the same redaction-approved projection already used for search; no new data is read, persisted, or exposed. JSON output is unchanged, so the spec-versioned surface is untouched.

🤖 Generated with Claude Code

https://claude.ai/code/session_015LY7xtercMc3NtLeX2z4YV

Reformat the text-mode output of search, sessions, and mutations show so
they are scannable, and accept short id prefixes everywhere a stored id is
required. JSON output is unchanged (new report fields are `#[serde(skip)]`).

- search rows: abbreviated event id, compact time, project basename, plain
  match kind, percentage score, and a cleaned command snippet (JSON framing
  stripped, `[...]` match highlights preserved).
- sessions: aligned columns, abbreviated session id, compact time,
  `~`-relative project path.
- mutations show: a labeled lesson block (hypothesis, intervention, trigger
  selectors, evidence counts, promotion gates as percentages) before the
  audit trail.
- percentages replace basis points in every text surface (findings support,
  search score, shadow precision/recall, near-miss support).
- near-miss list shows only candidates with >=2 occurrences (capped at 5),
  prints a summary line when none recur, uses plain-language gate reasons
  ("needs 3+ occurrences, saw 2"), and truncates commands at word
  boundaries.
- short id prefixes (>=6 chars past the type prefix) resolve to a unique
  stored id for mutations show/challenge/reject/replay/replay-draft/shadow/
  shadow-draft/install/uninstall and delete session; ambiguous prefixes
  error with the candidates; next-step hints echo the id form the user gave.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@karngyan
karngyan merged commit a0f6714 into main Jul 17, 2026
1 check failed
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