Repository navigation
Fix the findings of the code review of #10 (security, correctness, performance, docs) - #11
Merged
Merged
Conversation
Security and robustness - an Azure token is no longer sent to non-Azure embedding endpoints; keys are chosen per provider; redirects are not followed; the API key is redacted from Debug - local --embed presets accept only loopback endpoints; the upload destination is printed before any request; units that cannot match are not embedded - embedding cache: a corrupt tail no longer blocks later appends (re-fetch loop), empty or non-numeric vectors are rejected, oversized entries cannot desync the file, owner-only permissions, 128-bit keys Correctness and performance - the k-gram prefilter no longer loses pairs that share no 4-gram; --embed-code no longer changes the copies renormalization; the default scan is faster than before (zero-weight features are not computed) - plain SQL queries are named like their file; .js/.mjs/.cjs use the TSX grammar; fragments and find keep the root in file names; --explain pairs units by full place - script noise is limited to module level; main() inlining keeps else branches and multi-line strings; compound statements report header lines; extraction runs on a large stack Tooling and docs - hardened eval scripts, corrected the dev/holdout description of the CodeNet sets, updated the agent skill, --help text and crate descriptions Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…s cannot be truncated on Windows) CI caught this: the tail cut used set_len on the append handle, which fails on Windows. The tail is now cut only if nobody appended since the file was read, so a concurrent writer's records are never lost. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #3 (Test Embeddings): fixes the embedding-related findings (credentials, uploads, cache) of the review of #10, which delivered the embedding support and its evaluation.
Related issues: #1 (ablation data posted there), #2, #4 (release flow used to ship 0.3.1). Issue comments: #1, #2, #3, #4.
Summary
Follow-up to #10. #10 was merged while a full code review of that branch was still being fixed, so these fixes
never reached
main. This PR contains exactly the difference betweenmainand the reviewed, fixed tree(19 files, +1,242 / -388, no files removed) plus the version bump to 0.3.1.
The review (architecture gate, security, two correctness reviewers, agent docs, performance, Python scripts,
duplication, then a verification pass on every blocking/should-fix candidate) found real defects; candidates
the verifiers could not reproduce were dropped. Everything below is fixed here, each with a regression test where
code is involved.
Release
Merging #10 bumped the version to 0.3.0 and published
v0.3.0frommain, which contains the defects fixedhere. This PR bumps the version to 0.3.1, so merging it publishes the fixed release (the Release workflow runs
on merge to
main).What is fixed
Credentials and uploads (security)
OPENAI_BASE_URLor a local server); a keylessOpenAI-compatible or Cohere endpoint now gets no credential. Reproduced with a fake endpoint and a fake
az.endpoint, an Azure key to a non-Azure one); it is now chosen from the endpoint's own provider.
api-keyheader to another host); the key isredacted from
Debug.--embedpresets (minilm|qwen3|potion) honored anyDUPLICATECODE_EMBED_ENDPOINT, so a leftoverremote value would receive all source text with
Bearer local. They now accept loopback hosts only, and every--embed*run prints where the text is sent before sending it (plus a warning for plain http to a remote host).scan/review/diffembedded every unit before applying--min-tokens/--skip-tests/boilerplate filters, sofiltered units were uploaded for nothing; they are filtered first when embeddings are enabled (default output is
unchanged).
Embedding cache
run (a permanent re-billing loop for a paid API). The bad tail is now cut off before appending.
cache hit forever; such rows are now rejected.
unix, keys are 128-bit, and identifier-name phrases are capped.
Correctness
alone reach the threshold (so embedding-only matches never appeared in
scan).--embed-codeforcedrenormalizeon for every profile, changingcopiesscores beyond the embedding term;the embedding term is now dropped whenever a unit has no vector, independent of the profile.
query, so any two queries matched by name; in the default profile twounrelated SELECTs scored 0.42 (above the
diffthreshold) and one shared filter pushed them to 0.65. They are nownamed like their file.
.js/.mjs/.cjswere parsed with the grammar that has no JSX, so React components in plain JS files produced nounits; they now use the TSX grammar (JS benchmark scores are unchanged).
fragmentsandfindwith several roots dropped same-named files from different roots as "nested"; they nowkeep the root in file names like
scan.--explainpaired units byfile:line, which mixed up units starting onthe same line; it uses the full place.
x = obj.attrinside functions was dropped as "script noise";main()inliningdeleted an
elsebranch of the guard and corrupted multi-line strings; compound statements reported their wholebody as differing lines in
--explainandfragments.large-stack thread (pre-existing for Python, newly reachable for SQL).
Performance (11k-unit repository, best of two runs, original
mainvs this tree): default scan 4.7 s to4.0 s;
scan --min-name 013.3 s to 6.9 s;--profile reimpl --min-name 04.0 s to 12.2 s. The review measured thedefault scan 28% slower and
reimpl4.7x slower before these changes.reimplstays about 3x slower than theoriginal because at its weights the k-gram prefilter cannot prune.
Benchmarks, tooling and docs
4 of 60 JavaScript problems appear in both. On holdout problems not in dev, Python scores 0.648 (0.659 on the full
holdout) and JavaScript 0.497 (unchanged). Docs corrected;
fetch_codenet.py --exclude-frombuilds a disjointholdout.
that matched the user's own directory name, remote data used in file paths, a validated and allowlisted local
embedding server, pinned dependency versions.
skills/duplicate-code-review/SKILL.md),--helptext and crate descriptions stilldescribed Python/TypeScript/C# only and no new commands; they now cover SQL/JS,
fragments,find,--explain,--embed, the profile defaults and the fact that hosted embedding presets upload source text.Tested
cargo fmt --check,cargo test --workspace --locked(52 tests, up from 34), clippy clean for new code.benchtop-1 rows unchangedagainst the earlier results; default-profile scan of a real Python repository still identical to the pre-Detection quality: SQL and JS/JSX support, optional embeddings, fragments/find/explain, eval harness #10
main(209 pairs, 0 score differences); fragment recall unchanged (Python 0.93 / 0.97, TypeScript 0.975 / 0.97 forblocks of 6 / 8).
scan dataset) was run locally earlier. macOS and Windows arecovered only by CI, which caught a Windows-only bug in the cache fix (an append handle cannot be truncated);
it is fixed in the last commit, which also never cuts away records a concurrent writer appended meanwhile.
Not fixed here
--profile reimplis slower than the original; SQL scoring compares every same-family unit; per-language rules arestill inlined in
units.rsand whole-file pruning rewrites source text instead of the token stream;Unit.textcopies source for every unit. All are recorded in
eval/REPORT.md.History note
#10 was merged with its full commit history, which includes early versions of
eval/REPORT.mdthat named aninternal repository and some of its folder, class and function names (no credentials or source code). The tip no
longer contains them; the history of
maindoes. Rewritingmainis a decision for the owner and is not part ofthis PR.
🤖 Generated with Claude Code