Scope: review the commits unique to this branch vs origin/main, plus any uncommitted changes in the working tree. Ignore code outside this scope.
Checkpoint context from commits in scope:
cde5d8b348d8: prompt: Create a new branch to implement docs/semantic_provider_requirements.md. Write your progress into docs/progress-so-far.md. Make sure everything is tested, reviewed with "entire review", and commit/push along the way.
344d73e0a85b: prompt: Create a new branch to implement docs/semantic_provider_requirements.md. Write your progress into docs/progress-so-far.md. Make sure everything is tested, reviewed with "entire review", and commit/push along the way.
Use entire explain <id> for full checkpoint context, or entire explain <id> --raw-transcript for raw transcripts.
In-progress session context (uncommitted):
019e7da4 Codex (touched: 5 files) prompt: Try “entire review” again. If you don’t understand how it works, inspect the ../cli repo.
User
review
/review
/security-review
/simplify
Scope: review the commits unique to this branch vs origin/main, plus any uncommitted changes in the working tree. Ignore code outside this scope.
Checkpoint context from commits in scope:
cde5d8b348d8: prompt: Create a new branch to implement docs/semantic_provider_requirements.md. Write your progress into docs/progress-so-far.md. Make sure everything is tested, reviewed with "entire review", and commit/push along the way.
344d73e0a85b: prompt: Create a new branch to implement docs/semantic_provider_requirements.md. Write your progress into docs/progress-so-far.md. Make sure everything is tested, reviewed with "entire review", and commit/push along the way.
Use entire explain <id> for full checkpoint context, or entire explain <id> --raw-transcript for raw transcripts.
In-progress session context (uncommitted):
019e7da4 Codex (touched: 5 files) prompt: Try “entire review” again. If you don’t understand how it works, inspect the ../cli repo.
Assistant
Code Review: semantic-provider-contract
Scope: 3 commits ahead of origin/main + 4 uncommitted modifications (~1400 LOC added).
Overview
Adds a new entire-sem semantic provider contract: NDJSON snapshot/symbols/edges commands, capabilities reporting, and a structured doctor --json output. Backed by ~600 lines of new code in internal/sem/provider.go with regex-based import scanning, heuristic CALLS/HANDLES_* relation inference, and a HEAD-tree-vs-working-tree source selector. Adds gitutil.RevParse and .claude / .codex hooks plumbing.
The uncommitted delta is a sensible response to an earlier review: snapshot records now come from the advertised HEAD tree (instead of mixing HEAD metadata with dirty working-tree content), with a regression test and a .entire telemetry-off flip.
Correctness
Bugs
importsFor Go scanner over-matches (internal/sem/provider.go:524). The second regex ^\s*(?:\w+\s+)?["]([^"]+)["] is meant to catch lines inside import (...) blocks, but since scanImports reads line-by-line, the regex has no idea whether it's inside an import block — any line that begins with a quoted string (top-level docstrings, raw heredoc-style constants, struct tag lines, test fixtures) is reported as an import. Track import ( / ) block state instead.
looksLikeToolHandler is very liberal (provider.go:568). Any symbol whose qualified name or body contains "tool" together with one of "handler"/"execute"/"schema" emits a HANDLES_TOOL edge to an external:tool:<name> node. Across this very repo, that pattern matches a lot of unrelated test code. Confidence 0.58 is low, but the noise may swamp downstream consumers — consider raising the bar (require both the name and a tool token in the symbol name) or dropping it from Phase 1.
CALLS edge generation is O(files × symbols_in_file × all_short_names) plus a substring scan per pair (provider.go:397–417). For a 5k-symbol repo this is millions of containsIdentifier scans on file bodies. Scan each symbol block once into a set of identifiers, then intersect against symbolsByShortName — same semantics, vastly less work.
Stable symbol ID isn't actually rename-stable (provider.go:623). The ID embeds path, so a file rename mints brand-new IDs and breaks every CONTAINS/CALLS edge that referenced the old IDs. The header advertises stable-symbol-id-v1. If rename stability is out of scope for v1, fine — but the version string is misleading; document the limitation in the contract.
runDoctor arg validation is awkward (root.go:101–103). len(args) > 1 || (len(args) == 1 && !asJSON) rejects valid future flags. Cheaper: iterate and treat anything other than --json as an error.
version --json ignores trailing args (root.go:68). entire sem version --json garbage extra succeeds silently. Minor.
Tests
New TestBuildProviderSnapshotReadsAdvertisedHeadTree is exactly the right regression — it would have caught the bug the uncommitted diff fixes.
TestProviderNDJSONCommands walks all three new commands and verifies each line parses as JSON. Good.
Gap: no test for the warning emission when git rev-parse HEAD fails (i.e., the non-git fallback path that creates E_NO_GIT_HEAD). The whole new warnings branch in the uncommitted diff is currently untested.
Gap: no test for looksLikeToolHandler / HANDLES_TOOL — given how loose the heuristic is, a snapshot of expected matches would protect against future broadening.
Security
exec.CommandContext with structured args throughout gitutil — no shell, no injection vector. Good.
workingTreeFiles skips symlinks at the file level and filepath.WalkDir does not follow symlinked directories by default — symlink-escape is not exploitable here.
No file-size cap before os.ReadFile / git show (provider.go:475, snapshotSource). A 2 GB binary blob in HEAD will be slurped into RAM and SHA-256'd. Phase 1 is local-only so this is a DoS-on-yourself issue, but worth a size guard (e.g., skip > 4 MB with a E_FILE_TOO_LARGE partial failure).
--repo accepts any path including /. Same self-DoS class — the operator owns the consequences, but the snapshot command will walk anything it's pointed at. Consider verifying the repo arg is a git repo (or at least exists) before walking.
gitutil.ShowFile substring-matches error text (gitutil/git.go:101) — pre-existing, not in this diff's scope. Brittle but not a security issue.
Hooks (.claude/settings.json, .codex/hooks.json) are gated by command -v entire and pipe nothing back into a shell — safe.
Simplification opportunities (per /simplify)
runDoctor interleaves text and JSON output paths with scattered if !asJSON branches and mid-flight mutations to report. Build the report struct unconditionally, then render it via either encoder.Encode(report) or a small printTextReport(report, out) helper. The current shape is the largest readability cost in this diff.
snapshotSource duplicates the path→content map construction in both branches (provider.go:451–482). Collapse to a single helper that returns (path, content, ok) tuples, with the HEAD vs walk choice isolated to a lister function.
Warnings: []ProviderWarning{} is initialized twice (provider.go:248–250 plus the empty-init at line 264). Just declare warnings := []ProviderWarning{} up top and drop the nil check.
parseProviderFlags vs parseCommonFlags are 90% the same. Either share a parser or accept that snapshot/symbols/edges are a different shape and don't need a third style — but right now the divergence (e.g., provider parser rejects --, common parser handles it) creates surprises for users.
runProviderRecords switch on mode string with three string literals — pass the writer function in directly:
go
case "snapshot": return runProviderRecords(ctx, opts, args[1:], sem.WriteSnapshotNDJSON)
Removes the default branch and one source of typos.
completenessLevel magic numberfailures*4 > files (provider.go:593). One-line comment or a named constant (const unsafeFailureRatio = 0.25).
firstError is only called from one site that already proved at least one error is non-nil. Inline as errors.Join(commitErr, treeErr) (returning the joined error's message in Detail) and drop the helper.
Risks
The new commands are advertised in --help and in the capabilities report — they form an external contract. Bugs in the heuristics (HANDLES_TOOL noise, CALLS over-emission) will leak into any downstream consumer's index. Consider gating the noisier relation types behind a capability flag until they've been validated against a real consumer.
The HEAD-vs-working-tree split is now correct, but the working-tree fallback silently drops unreadable files while the HEAD path aborts — same provider, two different reliability stories. Document or unify.
Recommendation
Functionally close to ready. Before merging I'd want: the Go import-block state tracking fix, a test exercising the E_NO_GIT_HEAD warning branch added by the uncommitted diff, and either tightening looksLikeToolHandler or removing it from v1. The runDoctor cleanup and the buildRelations CALLS hot-loop are good follow-ups but not blockers.