Repository navigation
Commit fe5a355
authored
* feat(audit): runAuditFromRef + worktree cache (Tracer 1)
* feat(audit): cmd-audit.ts --base <ref> parser + runner wired (Tracer 2)
- parseAuditRest gains --base <ref> / --base=<ref>; rejects --base + --baseline as mutually exclusive (clean error message); per-delta --<delta>-baseline still composes orthogonally.
- runAuditCmd dispatches to runAuditFromRef when opts.base is set; otherwise unchanged baseline-prefix path.
- makeWorktreeReindex injects the runtime save/restore around the worktree-side reindex (initCodemap mutates global state — restore needed so live-DB ops after the reindex still target the original project).
- main.ts forwards parsed.base.
- Help text updated with --base examples.
- .gitignore: .codemap/audit-cache/ (don't track cached worktrees; .codemap/recipes/ stays tracked).
- Smoke: bun src/index.ts audit --base HEAD~1 --json --summary works on this repo (4 files added vs HEAD~1, 7 deps, 0 deprecated). Second run hits cache (~110ms).
- 6 new parser tests cover --base alone, --base=, mutual exclusivity, per-delta composition, missing value.
* feat(audit): MCP audit tool gains base?: z.string() (Tracer 3)
- audit-engine.ts: makeWorktreeReindex lifted from cmd-audit.ts (single source of truth — both transports inject the same factory).
- tool-handlers.ts: handleAudit gains base/baseline_prefix mutual-exclusion guard + dispatches to runAuditFromRef when args.base set.
- mcp-server.ts: audit tool description rewritten to document the 3 snapshot sources (base / baseline_prefix / baselines per-delta) + their composition rules.
- 2 new MCP tests: rejects base + baseline_prefix combo, returns clean error in non-git project.
- HTTP POST /tool/audit lights up automatically via the existing dispatcher (Tracer 4 next).
* feat(audit): HTTP POST /tool/audit auto-wired (Tracer 4)
The dispatcher already validates with auditArgsSchema (which gained the
`base?: string` field in Tracer 3) — this commit just adds tests:
- audit + base + baseline_prefix combo → 400 mutually exclusive
- audit + base in non-git project → 400 'requires a git repository'
Both transports (MCP + HTTP) now expose the new --base path through the
same handleAudit pure function.
* docs(audit-base): sync README + architecture + glossary + agent rule/skill + changeset (Tracer 5)
- README.md: 'audit --base origin/main' code block + cache caveat
- docs/architecture.md: Audit wiring extended with --base details (worktree
+ atomic populate + cache + LRU + non-git error + GIT_* env hygiene);
audit-engine.ts inventory mentions runAuditFromRef + makeWorktreeReindex;
audit-worktree.ts added to application/ inventory
- docs/glossary.md: 'audit --base / git-ref baseline' entry; existing 'audit'
entry now mentions 3 mutually-exclusive sources
- docs/roadmap.md: drop the v1.x backlog item (it shipped)
- docs/research/fallow.md: B.5 row updated to 'v1 + v1.x partial shipped';
Adjacent-shipped bullet referencing PR #51 (plan) + #52 (impl)
- .agents/rules/codemap.md + templates/agents/rules/codemap.md: new
'Audit vs git ref' table row + paragraph rewrite (Rule 10 lockstep)
- .agents/skills/codemap/SKILL.md + templates/agents/skills/codemap/SKILL.md:
audit tool args + behavior reflect new 'base' field (Rule 10 lockstep)
- src/agents-init.ts: ensureGitignoreCodemapPattern now adds
'.codemap/audit-cache/' alongside '.codemap.*' (the audit cache lives
inside .codemap/ but .codemap/recipes/ stays git-tracked); test updated.
- .changeset/codemap-audit-base.md: minor — full design rationale
- docs/plans/audit-base.md: deleted per docs-governance Rule 3
* fix(audit-base): address all 6 CodeRabbit review comments + 2 nitpicks
Threads (all 6 actionable, no hallucinations):
1. .agents/rules + templates: stale 'B.6' spec leak → 'query_baselines entries' (consistent terminology)
2. audit-engine.ts: process-level mutex (_reindexChain promise queue) around makeWorktreeReindex's runtime-singleton swap. Concurrent HTTP/MCP audits no longer interleave initCodemap/configureResolver state. Long-term cleanup (runCodemapIndex takes explicit context) tracked separately.
3. audit-worktree.test.ts: commitFiles fixture now checks git commit exit code; throws with stderr on failure (was silently passing against previous commit)
4. audit-worktree.ts: tmpName gains randomUUID() suffix (defensive against cross-process races; in-process serialised by mutex from #2)
5. audit-worktree.ts: evictIfOverLimits accepts protectPath; populateWorktree passes finalPath so the freshly-populated entry can't evict itself when it alone exceeds MAX_CACHE_BYTES. New test covers the protect path.
6. mcp-server.ts + .agents/skills + templates: rephrased 'three mutually exclusive sources' to 'two mutually exclusive PRIMARY sources + optional per-delta overrides' (matches handleAudit's actual exclusivity rule)
Nitpicks:
- fallow.md status: 'v1 + v1.x partial shipped' → 'v1 + v1.x shipped; verdict deferred' (clarity)
- cmd-audit.test.ts: added --base= empty-value + --base "" two-token-empty-string parser tests for symmetry with --baseline coverage
1 parent e107bea commit fe5a355
25 files changed
Lines changed: 1285 additions & 208 deletions
File tree
- .agents
- rules
- skills/codemap
- .changeset
- docs
- plans
- research
- src
- application
- cli
- templates/agents
- rules
- skills/codemap
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
55 | | - | |
| 56 | + | |
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
| 68 | + | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
106 | 111 | | |
107 | 112 | | |
108 | 113 | | |
| |||
0 commit comments