Closes the harness's feature set per PROMPT.md modes 2 (Diff Review)
and Phase 5 (Memory). Rules subcommand still pending (it needs
operator-authored .review-rules.md content first; documented as
Phase E follow-up).
internal/memory/ — append-only writer:
- AppendKnownRisks: one JSONL line per confirmed finding per run.
O_APPEND only; never O_TRUNC. Empty findings list is a no-op
(doesn't even create the file — keeps clean runs from polluting
.memory/).
- AppendRunHistory: one JSONL line per run. Run summary stats +
receipts hash for cross-link.
- WriteProjectProfile: the ONLY non-versioned memory file; snapshot
semantics, overwrites are explicit + documented.
- 4 unit tests including TestAppendKnownRisks_NeverTruncates which
is the audit's "no silent overwrite" gate — write twice, assert
both writes' content survives.
Pipeline phase 5 wires it. Confirmed findings only — suspected
findings might still be wrong, keeping .memory/ authoritative.
Disabled if review-profile.memory.enabled = false.
internal/git/git.go — ChangedFiles helper:
- Probes unstaged + staged + branch diff against main/master.
- Dedup'd, stable order. Empty result on clean tree.
- Graceful failure: returns error if git binary missing or target
isn't a git repo.
cli/repo.go — Diff subcommand:
- `review-harness diff <path>` runs the same pipeline as scrum but
scoped to changed files only. Pipeline.Inputs gains DiffOnlyFiles
filter applied post-Walk.
- Empty diff (clean tree, no commits ahead of base) → exit 0 with
message; doesn't generate empty reports.
- LLM toggleable via --enable-llm same as scrum.
scanner/walk.go: added .memory to SkipDirs (universal — harness's
own audit trail, scanning it surfaces planted-secret evidence as
new findings — same class as B5 self-skip).
.gitignore tightened: /.memory/ → **/.memory/ to keep test-fixture
.memory dirs from leaking into version control (same fix as
reports/latest pattern).
Verified end-to-end:
- 4 memory unit tests PASS
- Append-only proven: insecure-repo run 1 → 16 known-risks lines;
run 2 → 44 lines (16 + 28 from new run); run-history grew 1 → 2.
- Diff subcommand against this repo (5 uncommitted Phase E files
staged) → exit 0, all reports produced, scoped to those 5 files
only (0 findings on the diff-scoped scan vs 129 on full repo —
changed files don't contain analyzer-flaggable patterns).
Phase A through E shipped today. Rules subcommand + tests for
internal/{config,scanner,git,llm,reporters,pipeline} remain.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
91 lines
2.6 KiB
Go
91 lines
2.6 KiB
Go
// Local review harness — entry point.
|
|
//
|
|
// Subcommands per PROMPT.md:
|
|
// repo /path — full-repo review (Phase B MVP)
|
|
// diff /path — diff/PR-style review (Phase E)
|
|
// scrum /path — scrum-test report bundle (Phase B MVP)
|
|
// rules /path — rules audit (Phase E)
|
|
// model doctor — Ollama probe + JSON shape (Phase A stub, Phase C real)
|
|
//
|
|
// PROMPT.md hard rules apply: no cloud deps, no auto-commit, no
|
|
// destructive changes to the target repo, no fake success.
|
|
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"os"
|
|
|
|
"local-review-harness/internal/cli"
|
|
)
|
|
|
|
func main() {
|
|
if len(os.Args) < 2 {
|
|
usage()
|
|
os.Exit(2)
|
|
}
|
|
|
|
// Per-subcommand flag sets. Common flags (--review-profile,
|
|
// --model-profile, --output-dir) live on each FlagSet rather than
|
|
// a global pre-parser; the CLI library would be overkill for 5
|
|
// subcommands.
|
|
sub := os.Args[1]
|
|
args := os.Args[2:]
|
|
|
|
switch sub {
|
|
case "repo":
|
|
os.Exit(cli.Repo(args))
|
|
case "diff":
|
|
os.Exit(cli.Diff(args))
|
|
case "scrum":
|
|
os.Exit(cli.Scrum(args))
|
|
case "rules":
|
|
fmt.Fprintln(os.Stderr, "rules: not implemented in MVP (Phase E)")
|
|
os.Exit(64)
|
|
case "model":
|
|
// Two-token verb: "model doctor"
|
|
if len(args) < 1 {
|
|
fmt.Fprintln(os.Stderr, "model: missing verb (try: model doctor)")
|
|
os.Exit(2)
|
|
}
|
|
switch args[0] {
|
|
case "doctor":
|
|
os.Exit(cli.ModelDoctor(args[1:]))
|
|
default:
|
|
fmt.Fprintf(os.Stderr, "model: unknown verb %q\n", args[0])
|
|
os.Exit(2)
|
|
}
|
|
case "-h", "--help", "help":
|
|
usage()
|
|
os.Exit(0)
|
|
case "version":
|
|
fmt.Println("review-harness 0.1.0 (Phase A skeleton)")
|
|
os.Exit(0)
|
|
default:
|
|
fmt.Fprintf(os.Stderr, "unknown subcommand: %q\n", sub)
|
|
usage()
|
|
os.Exit(2)
|
|
}
|
|
_ = flag.CommandLine // keep import stable across phases
|
|
}
|
|
|
|
func usage() {
|
|
fmt.Fprint(os.Stderr, `review-harness — local-first code review
|
|
|
|
Usage:
|
|
review-harness repo <path> full-repo review (MVP)
|
|
review-harness scrum <path> scrum-test report bundle (MVP)
|
|
review-harness model doctor probe Ollama / configured models
|
|
review-harness diff <path> diff review (Phase E, not yet)
|
|
review-harness rules <path> rules audit (Phase E, not yet)
|
|
review-harness version print version
|
|
review-harness help this message
|
|
|
|
Common flags (per subcommand):
|
|
--review-profile <path> YAML; defaults applied if omitted
|
|
--model-profile <path> YAML; defaults applied if omitted
|
|
--output-dir <path> override review-profile output dir
|
|
--enable-llm also run local-Ollama LLM review (Phase C)
|
|
`)
|
|
}
|