feat(scan): a bare-path scan of a git checkout stamps the working-tree HEAD — the flag > project > git-detected metadata tier (#557) - #560
Conversation
…e HEAD — the flag > project > git-detected metadata tier (#557) A bare-path scan (the #539 primary usage) of a git checkout still reported commit_sha: null — the user had to type the 40-char SHA by hand even though the target's HEAD is one rev-parse away (the receipt: a monitored scan of a pinned external clone, the SHA known to the caller throughout). The fix (the need-check's amended shape): - git.HeadSHA in internal/git (beside CurrentBranch — dedupes the private rev-parse copies; resolves SUBDIRECTORIES where init's os.Stat(.git) gate fails; yields empty for a non-git path and for an unborn HEAD, never the zero-id); - resolveRepoMetadata gains the detected tier (flag > project > detected) and a mismatch WARN: an explicit flag in a CI synthetic-merge checkout is legitimate (the #539 flag-wins contract unchanged) but a stale PROJECT SHA against a moved tree is the footgun — both warned to stderr (the codebase's PrintWarning pattern). resolveLocalCommit is deliberately NOT reused: its warn-and-IGNORE contract would silently break flag-wins; - the nogit sentinel never reaches the SHA (it was flowing into /blob/nogit/... permalinks and SARIF revisionIds via the project tier); - detection runs AFTER prepareDiffManifest — the --pr path checks out the PR head inside it, and hoisting this above would stamp the pre-checkout SHA (the review round's ordering hazard); - recording HEAD on a possibly-dirty tree is NOT a new assertion: the incremental manifest already stamps rev-parse HEAD as diff.head_sha with no dirty check — consistency, not new semantics. Dirty-worktree warning is scoped out (init does not do it either; a divergence would be the opposite of reuse). The URL/remote tier is a separate question (scp-form remotes and credential-bearing URLs need normalization first).
|
Gate-session receipt (proportionate round — astra; the micro-feature class, #553's named follow-up) Re-derived independently: the 3 test groups pass (the 10-row resolver table incl. the detected tier + Astra: NOT-REFUTED — with the sharpenings receipt-noted: (a) the subdirectory resolution correct ( CI green. Merge-ready. |
Summary
A bare-path scan of a git checkout (the #539 primary usage) still reported
commit_sha: null— the user had to type the 40-char SHA by hand even though the target's HEAD is onerev-parseaway (the receipt: a monitored scan of a pinned external clone, the SHA known to the caller throughout).The fix:
git.HeadSHAininternal/git(besideCurrentBranch; dedupes the private rev-parse copies; resolves subdirectories where init'sos.Stat(.git)gate fails; an unborn repo errors at rev-parse — the empty return is the proof, no zero-guard needed);resolveRepoMetadatagains the detected tier (flag > project > git-detected) and a mismatch warn to stderr (the codebase'sPrintWarningpattern): the legitimate CI case (an explicit--commit-shain a synthetic-merge checkout — the The Go scan CLI cannot pass repository metadata the Python CLI already accepts — a bare-path scan's reports render [NOT PROVIDED] with no way to avoid it #539 flag-wins contract unchanged) and the stale-project footgun are both surfaced, the latter with the remedy (re-run openant init to refresh the project SHA);nogitsentinel never reaches the SHA (it was flowing into/blob/nogit/…permalinks and SARIFrevisionIds via the project tier);resolveScanMode(the--prpath checks out the PR head inmode.go'sFetchPR— hoisting detection above would stamp the pre-checkout SHA).Scoped out (named): dirty-worktree warning (init does not do it either — a divergence would be the opposite of reuse); the URL/remote tier (scp-form remotes and credential-bearing URLs need normalization first); recording HEAD on a possibly-dirty tree is not a new assertion — the incremental manifest already stamps
rev-parse HEADasdiff.head_shawith no dirty check.Closes #557.
Test plan
The 10-row
resolveRepoMetadatatable (the #539 rows + the detected tier: bare-path detection, non-git empty, the project/flag/CI mismatch warns, the remedy hint,nogit) +TestHeadSHA(a real repo, a subdirectory, a non-git dir, an unborn repo).Verification evidence
go test ./cmd/ -run 'TestResolveRepoMetadata|TestHeadSHA|TestScanRepoMetadata' -vgo test ./cmd/go build ./... && go vet ./cmd/