You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(kb): address code-review findings on the auto-routing hook
Adversarial multi-agent review of the kb-mod-cacg branch surfaced these
(all verified against the real kb binary + the test suite):
- SIGPIPE/exit-5 abort: extracting the prompt via `... | head -c 2000` under
pipefail aborted the hook on >64KB prompts (141) and on malformed stdin (5).
Now extract with `|| true` and truncate in-shell (char-based, no mid-UTF8 split).
- No time bound: wrap `kb search` in run_with_timeout (repo convention); the
existing `|| exit 0` already turns a 124 into a clean no-op.
- Flag-like prompts: pass the query after `--` so a prompt starting with '-'
is not misparsed by clap and dropped.
- Context-injection hardening: scrub newlines from .title/.path/.card_id (not
just .summary) so a tampered card cannot forge a heading in additionalContext.
- Injected hint now points at `.claude/knowledge/kb-query.sh show <card_id>`
(resolved from the discovered KB root) instead of bare `kb show` (which needs
--source-matrix and would error if run literally).
- kb_top_k now clamps to [1,25] so the injected block stays bounded at source.
- Codex prompts: qualify the `kb verify --round-summary` command as requiring a
verify-tier export (the default query tier omits chunks_manifest.json).
- Tests (16 -> 27): mock kb now logs argv + is query-sensitive, so the suite
asserts the prompt->search plumbing (verb, query-after-`--`, --source-matrix/
--summaries/--top-k wiring); adds malformed-stdin (exit 0), >64KB prompt (no
SIGPIPE), top-k clamp, and kb_discover_root/kb_resolve_binary override cases.
test-kb-provenance-format.sh stays 25/25; config-merge + bitlesson green.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
+ "Search suggestions only. Open a card with `kb show <card_id>` (or read its `.md`) and cite it in your round summary'"'"'s `## Knowledge Consulted` section ONLY if you actually opened and used it.\n\n"
76
+
+ "Search suggestions only. Open a card with `\($wrapper) show <card_id>` (or read its `.md`) and cite it in your round summary'"'"'s `## Knowledge Consulted` section ONLY if you actually opened and used it.\n\n"
Copy file name to clipboardExpand all lines: prompt-template/codex/full-alignment-review.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -74,7 +74,7 @@ The `Mainline Progress Verdict` line is mandatory. If you omit it, the Humanize
74
74
- Verify Claude's claims match reality
75
75
- Identify any gaps, bugs, or incomplete work
76
76
- Reference @{{DOCS_PATH}} for design documents
77
-
-**Knowledge Provenance Check**: Verify Claude's summary includes a `## Knowledge Consulted` section listing concrete reference files (e.g. CACG cards under `.claude/knowledge/cards/<deck>/**/*.md`, other `.claude/knowledge/**/*.md`, vendor manuals, paper PDFs, metric manifests) or the exact string `N/A -- task not KB-relevant this round`. If the section is missing on KB-relevant work, or if `N/A` is used as a shortcut for domain-specific / modeling / metrics tasks, flag as a Blocking Side Issue. When a CACG export is present, the cited card paths can be content-verified with `kb verify --round-summary <summary-file> --source-matrix .claude/knowledge/out/<deck>/source_matrix.json --chunks-manifest .claude/knowledge/out/<deck>/chunks_manifest.json`.
77
+
-**Knowledge Provenance Check**: Verify Claude's summary includes a `## Knowledge Consulted` section listing concrete reference files (e.g. CACG cards under `.claude/knowledge/cards/<deck>/**/*.md`, other `.claude/knowledge/**/*.md`, vendor manuals, paper PDFs, metric manifests) or the exact string `N/A -- task not KB-relevant this round`. If the section is missing on KB-relevant work, or if `N/A` is used as a shortcut for domain-specific / modeling / metrics tasks, flag as a Blocking Side Issue. When a **verify-tier (or full)**CACG export is present (`chunks_manifest.json` ships only at `--tier verify` and above; the default `query` tier omits it), the cited card paths can be content-verified with `kb verify --round-summary <summary-file> --source-matrix .claude/knowledge/out/<deck>/source_matrix.json --chunks-manifest .claude/knowledge/out/<deck>/chunks_manifest.json`.
Copy file name to clipboardExpand all lines: prompt-template/codex/regular-review.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,7 +35,7 @@ Below is Claude's summary of the work completed:
35
35
- Your review should elaborate on those unfinished tasks, explore the codebase, and draft an implementation plan.
36
36
- A good engineering implementation plan should be **singular, directive, and definitive**, rather than discussing multiple possible implementation options.
37
37
- The implementation plan should be **unambiguous**, internally consistent, and coherent from beginning to end, so that **Claude can execute the work accurately and without error**.
38
-
-**Knowledge Provenance Check**: Verify Claude's summary includes a `## Knowledge Consulted` section listing concrete reference files (e.g. CACG cards under `.claude/knowledge/cards/<deck>/**/*.md`, other `.claude/knowledge/**/*.md`, vendor manuals, paper PDFs, metric manifests) or the exact string `N/A -- task not KB-relevant this round`. If the section is missing on KB-relevant work, or if `N/A` is used as a shortcut for domain-specific / modeling / metrics tasks, flag as a Blocking Side Issue. When a CACG export is present, the cited card paths can be content-verified with `kb verify --round-summary <summary-file> --source-matrix .claude/knowledge/out/<deck>/source_matrix.json --chunks-manifest .claude/knowledge/out/<deck>/chunks_manifest.json`.
38
+
-**Knowledge Provenance Check**: Verify Claude's summary includes a `## Knowledge Consulted` section listing concrete reference files (e.g. CACG cards under `.claude/knowledge/cards/<deck>/**/*.md`, other `.claude/knowledge/**/*.md`, vendor manuals, paper PDFs, metric manifests) or the exact string `N/A -- task not KB-relevant this round`. If the section is missing on KB-relevant work, or if `N/A` is used as a shortcut for domain-specific / modeling / metrics tasks, flag as a Blocking Side Issue. When a **verify-tier (or full)**CACG export is present (`chunks_manifest.json` ships only at `--tier verify` and above; the default `query` tier omits it), the cited card paths can be content-verified with `kb verify --round-summary <summary-file> --source-matrix .claude/knowledge/out/<deck>/source_matrix.json --chunks-manifest .claude/knowledge/out/<deck>/chunks_manifest.json`.
0 commit comments