Summary
Two duplication clusters in the engine. Bundled because they're small fixes with the same shape: extract + import.
A. row → FileRecord mapper open-coded in three places
The same 20-field row-to-record mapping appears in:
packages/engine/src/catalog/files-repo.ts:118-140
packages/engine/src/organize/planner.ts:183-205
packages/engine/src/dedupe/planner.ts:50-79
Per standards/code-duplication.md: "Same multi-line block in three or more places... Severity: Important." A new column added to the files schema will need to be added in three spots. The two planners may also silently drift on which optional columns they read (e.g., lastVerifiedAt).
B. _FileOrganizer_quarantine literal in two files
packages/engine/src/quarantine/quarantine.ts:22 — const QUARANTINE_DIR = '_FileOrganizer_quarantine';
packages/engine/src/organize/applier.ts:13 (reviewer-cited as QUARANTINE_DIR_NAME) — same string, different constant name.
If either is renamed, the empty-dir sweep guard at applier.ts:211 silently breaks (it uses the local constant to identify the quarantine subdirectory and skip it). Per code-duplication.md: "Inline literals duplicated across files... extract to a named constant."
Background
From the 2026-05-17 multi-agent full-repo review.
Acceptance criteria
A. Mapper extraction
B. Quarantine dir constant
Files affected (likely)
packages/engine/src/catalog/files-repo.ts — export toFileRecord
packages/engine/src/organize/planner.ts:183-205 — use it
packages/engine/src/dedupe/planner.ts:50-79 — use it
packages/engine/src/quarantine/quarantine.ts:22 — export QUARANTINE_DIR_NAME
packages/engine/src/organize/applier.ts:13 — import
Out of scope
- Larger reorganization of repos / planners
- Other 2-place duplications (defer until they become 3-place)
References
- Standards:
standards/code-duplication.md
- Code: paths above
Summary
Two duplication clusters in the engine. Bundled because they're small fixes with the same shape: extract + import.
A.
row → FileRecordmapper open-coded in three placesThe same 20-field row-to-record mapping appears in:
packages/engine/src/catalog/files-repo.ts:118-140packages/engine/src/organize/planner.ts:183-205packages/engine/src/dedupe/planner.ts:50-79Per
standards/code-duplication.md: "Same multi-line block in three or more places... Severity: Important." A new column added to thefilesschema will need to be added in three spots. The two planners may also silently drift on which optional columns they read (e.g.,lastVerifiedAt).B.
_FileOrganizer_quarantineliteral in two filespackages/engine/src/quarantine/quarantine.ts:22—const QUARANTINE_DIR = '_FileOrganizer_quarantine';packages/engine/src/organize/applier.ts:13(reviewer-cited asQUARANTINE_DIR_NAME) — same string, different constant name.If either is renamed, the empty-dir sweep guard at
applier.ts:211silently breaks (it uses the local constant to identify the quarantine subdirectory and skip it). Percode-duplication.md: "Inline literals duplicated across files... extract to a named constant."Background
From the 2026-05-17 multi-agent full-repo review.
Acceptance criteria
A. Mapper extraction
toFileRecord(row: SqliteRow): FileRecordfunction frompackages/engine/src/catalog/files-repo.ts(or a siblingfiles-mapper.tsif you want to keep the repo class focused).organize/planner.ts:183-205anddedupe/planner.ts:50-79import and use it; the open-coded mapping is deleted from both.toFileRecordcovering all 20 fields including nullable / coerce-to-null branches.B. Quarantine dir constant
QUARANTINE_DIR_NAME = '_FileOrganizer_quarantine'frompackages/engine/src/quarantine/quarantine.ts(or@fileorganizer/sharedif it's needed by tests too).organize/applier.tsimports the named export; the local duplicate constant is deleted._FileOrganizer_quarantineto find them) uses the import.Files affected (likely)
packages/engine/src/catalog/files-repo.ts— exporttoFileRecordpackages/engine/src/organize/planner.ts:183-205— use itpackages/engine/src/dedupe/planner.ts:50-79— use itpackages/engine/src/quarantine/quarantine.ts:22— exportQUARANTINE_DIR_NAMEpackages/engine/src/organize/applier.ts:13— importOut of scope
References
standards/code-duplication.md