Repository navigation
feat(findings): duplicate-type flags a local copy of an exported object type - #483
Merged
Merged
Conversation
…ct type Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rt default, caps file size From Codex review round 1 (P2s): compare type tokens instead of text with all whitespace removed, count `export default Name` as an export, skip files over the scan's size cap, and check the deadline after parsing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sees both default exports Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
byronwall
force-pushed
the
claude/duplicate-type
branch
from
November 28, 2026 05:05
63b6f11 to
085c068
Compare
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.
srcly now reports a new finding,
duplicate-type: a file that declares its own object type while another file exports a type with the same name and mostly the same fields. A change to the exported type does not reach the copy, and a cast likefetchDoc(id) as Promise<DocDetail>hides that from tsc. The finding names the exported type and how many fields match, so the fix is clear: import or derive the type, then delete the copy.User impact: A new warning in findings: in
srcly report's checks line, the findings queue, the file findings in the code viewer, and the findings counts. The UI itself does not change.Why
In the Visual Notes cleanup probe (byronwall/visual-notes#361), a name-only scan of the symbol index found 59 type names declared in more than one file. Most were noise, such as 44 local
Propsand 40 exportedRootProps. Ranking by field overlap by hand found the two realDocDetailcopies. This rule does that ranking. It is step 2 of the cleanup loop in planning TASK-0017 (srcly-cleanup-loop.md). The probe also showed its second use: a rescan proves at product scope that the copies are gone and nothing new appeared.How it decides
A non-exported top-level
type X = { … }orinterface X { … }is reported when another non-test file exports an object typeX, and at least 3 of the copy's fields, and at least half of them, match that type by name and declared type. Type comparison ignores formatting and comments but keeps literal text, so"In Progress"is not"InProgress". Two-field shapes such asPoint { x, y }stay out. So do same-named types whose fields differ in type, such as a layoutTreeNodeand the compare payload'sTreeNode. The rule never claims two types are the same contract. Tests and.d.tsfiles are skipped.Proof
The rule on Visual Notes
main(d59937fe, 1,321 TS files, 1.1 s):On the visual-notes#361 branch, which removes the
DocDetailcopies, the same run gives 3 findings: the twoDocDetailrows are gone and nothing new appears.srcly reportlists the rule beside the others:Precision on other repos, every hit read by hand:
mainEvidenceElementinengine/src/analysis/scope-adapters/,RectinDependencyCanvas.tsx,Traceinsurvey-report.tsBoxintreemapLayout.tsBefore field types counted, srcly also flagged its layout
TreeNodeagainst the compare payload'sTreeNode(3 of 6 names shared). That was a false positive, and the type check removed it.I also checked recall on Visual Notes. 22 names have one exported declaration and at least one local one. For 10 of them, both sides are object types. The rule reports 4 of those 10 (
DocDetail,Prompt,UmapRunSummary,Topic). It drops 6:Point(nine copies that share onlyxandy), andBounds,Change,Placed,EmbeddingRunandSource, which have 0 or 1 matching fields. The other 12 names have no object-type pair (unions such asChunkerMode, aliases, or one side not an object).Tests:
tests/test_duplicate_types.py(copies with quoted and optional keys, an interface exported throughexport { Run }, look-alikes that must stay quiet, literal types, both default-export forms, oversized files, timeout).tests/test_findings.pynow lists the new tool.scripts/check.sh serverpasses.Codex review (gpt-6.2-sol), round 1: PASS, no P0 or P1 in this diff. Its three P2s are fixed in this PR: literal types kept whole,
export default Namecounted as an export, and the scan's 2 MiB file cap plus a deadline check after parsing. The close step's three class tests are added.Survey moves:
pnpm survey-gateon the stack (base54bf3bba→ head63b6f11d) moved onlyserver: traces +2, outcome partial +2, stopfrontier: external-code+30. No analysis code changed. The two new corpus modules,server/app/services/symbols/refs.pyandserver/app/services/findings/duplicate_types.py, add exported functions to the survey's export sample. Their traces stop where they call tree-sitter,pathliband the symbol index.Limits
type ChunkerMode = "a" | "b"declared twice) are not compared.NoteDocand an alias of it count as different types.srcly refs(layer 1). They predate this stack.refsmissesimport("…").Typeinline type references. It loses callers when a module imports a type and re-exports it. It merges a type and a value that share a name. They are worth a follow-up, becauserefsis how an agent maps callers before it deletes a copy.Stack: cleanup-loop helpers, layer 2 of 3
This slice: the
duplicate-typefinding.Why it is its own layer: It changes analysis output and needed its own review and survey check.
srcly refsbelow it is a read-only view of existing data.Full story: #482
🤖 Generated with Claude Code