Skip to content

ADR-049: safe reindex, read-only hints, redacted output, a cheaper tool surface (B-057, B-045, B-018, B-019, B-021) - #92

Merged
ethanblauw-hub merged 7 commits into
masterfrom
feature/adr-049-safe-reindex-and-tool-output
Oct 20, 2026
Merged

ethanblauw-hub merged 7 commits into
masterfrom
feature/adr-049-safe-reindex-and-tool-output

Conversation

@ethanblauw-hub

Copy link
Copy Markdown
Collaborator

Implements ADR-049 (backlog B-057, B-045, B-018 output half, B-019, B-021 point 3).

What changes

  • A killed full rebuild can't wipe the index (B-057).
    • A backup left on disk is treated as the good copy and restored before a new run.
    • The snapshot is atomic.
    • The backup is removed only after a save or restore finishes.
  • reindex() defaults to incremental (B-057). A full rebuild has to be asked for.
  • _tool derives each tool's annotations (B-045). Read-only tools declare readOnlyHint; reindex is not idempotent.
  • Secrets are redacted at the MCP boundary (B-018). Every tool's output passes through src/redact.py, which marks each match [REDACTED:<kind>]. The index and the plain functions stay unredacted.
    • Families with a known prefix: PEM keys, service-account private_key, and GitHub, Slack, AWS access, Google, Anthropic and OpenAI keys.
    • Added on @EDB's answer: Stripe keys, AWS secret keys, URL credentials, connection-string passwords, and quoted literals assigned to password/secret/api_key/*_token names. These replace only the value and accept some false positives.
  • The server instructions route agents to the index before Grep (B-021).
  • The tool listing shrank 20% (B-019): 16,606 → 13,214 characters. Most of that comes from structured_output=False, which stays as @EDB answered, and from three trimmed descriptions.

Tests

  • Full suite: 795 passed, 1 skipped (with ADR-055 merged in) (Windows, CPU). flake8 clean. Conformance, resolution and L5X teeth baselines all hold.
  • MCP Inspector results are recorded in the ADR.

Still open (left in the ADR)

  • Should a finished incremental run remove a leftover backup?
  • Add ADR-050's symbol tools to the routing line once it merges.

🤖 Generated with Claude Code

claude and others added 7 commits October 20, 2026 20:02
…r tool surface

Covers B-057, B-045, B-018 (output half), B-019 and B-021 point 3.

Co-Authored-By: Claude <noreply@anthropic.com>

[ADR-049]
…tool

_tool now derives each tool's MCP annotations: readOnlyHint is reads_index,
so every read tool, including ones added later, declares it without its
author doing anything, and a writer passes its other hints at its decorator
(B-045). Its async wrapper runs the returned text through redact.redact(),
which replaces PEM private keys, "private_key" fields and common token
prefixes with a visible [REDACTED:<kind>] marker; the plain functions the
TUI and tests call stay unredacted, and so does the index (B-018, output
half). The listing also sends each docstring dedented and without the
{"result": string} output schema FastMCP generates for a -> str tool (B-019).

Co-Authored-By: Claude <noreply@anthropic.com>

[ADR-049 src/MCPServer.py src/redact.py]
…ld explicit

B-057, the 2026-09-29 incident. _snapshot_index deleted .pre-full-reindex/
as stale, but a backup left by a killed run is the good copy. Now a full
rebuild that finds one restores it first and reuses it; a new snapshot is
copied into .partial/ and renamed into place only once complete, before the
wipe; _restore_index copies instead of moving, so a killed restore can run
again; and the backup is removed only after a finished save or a finished
restore.

reindex's changed_files_only now defaults to True, so a bare call is
incremental; the name is kept so saved calls mean what they did. Its
annotations say it is destructive and not idempotent, so a client does not
auto-retry a timed-out rebuild. The TUI's fallback for an unreadable Mode
field is incremental too. CONTRIBUTING section 5 says to verify reindex on a
scratch index, never the live one.

Co-Authored-By: Claude <noreply@anthropic.com>

[ADR-049 src/MCPServer.py src/tui/app.py]
…l descriptions

Both branches of the server instructions now say when to prefer
semantic_code_search, trace_data_flow, what_writes and analyze_blast_radius
over Grep, and that Grep is for exact strings and the files a branch changed
(B-021 point 3). what_writes, investigate_architecture and index_status lose
narrative and pipeline internals, keeping their when-to-call guidance (B-019).
The tool-surface tests read the FastMCP registry, so a tool added later is
covered by the readOnlyHint and listing checks without editing them.

Co-Authored-By: Claude <noreply@anthropic.com>

[ADR-049 src/MCPServer.py]
…tions

Co-Authored-By: Claude <noreply@anthropic.com>

[ADR-049]
…rds, and secret assignments

@EDB answered ADR-049's open questions 1 and 2: keep structured_output=False, and add
the prefix-less families, accepting the false positives. The four name-keyed kinds
replace only the value and skip a value an earlier pattern already replaced. ADR-049
accepted.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

[ADR-049 src/redact.py]
…e-reindex-and-tool-output [ADR-049 src/hybrid_retriever.py src/iterative_retriever.py]
@ethanblauw-hub
ethanblauw-hub merged commit b0619f4 into master Oct 20, 2026
5 checks passed
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.

2 participants