Skip to content

refactor: post-0.59 cleanup — dedup architecture/toml/fs utils merged in last 24h#590

Merged
TheMostlyGreat merged 6 commits into
mainfrom
refactor/post-24h-cleanup
Jul 1, 2026
Merged

refactor: post-0.59 cleanup — dedup architecture/toml/fs utils merged in last 24h#590
TheMostlyGreat merged 6 commits into
mainfrom
refactor/post-24h-cleanup

Conversation

@TheMostlyGreat

Copy link
Copy Markdown
Collaborator

Behavior-preserving cleanup of the CLI-src code merged over the last 24h (the architecture / test-plan / toml cluster from #560#578). Six commits, each one-change → test → commit, scouted by three parallel read-only passes + an /audit catch-net.

Refactors (all Tier-1/2 Extract Function, no behavior change)

Commit What
1549ee29 resolveTomlWorkspaceMembers — fold the byte-identical Cargo + uv detector tails
adbe8995 skeletonTarget — fold near-identical singleRepoTarget / leafTarget
fc156423 architectureFrontmatter — one writer for the doc preamble (the serialization side of a parsed contract)
4506f025 test: direct findFileMatchingInTree coverage (safety net for the next commit)
f135b140 isScannableSubdirectory — share the dir-exclude predicate across the fs tree-walkers
e20db8ad linesInTable generator — dedup the TOML table traversal (surfaced by /audit jscpd)

Deliberately NOT done (over-abstraction / already-mitigated)

  • Merging the 6 workspace detectors into one template — their file-format bodies are irreducible; a callback-heavy frame would be worse.
  • Unifying the CLI/hook fingerprint parsers — the hook can't import CLI src; already pinned by a differential parity test.
  • Section-parser overlap, dep-cruiser filename lists — non-substitutable / different purposes.

Verification

  • Per-refactor: eslint + tsc clean, targeted suites green (toml/architecture-monorepo/architecture-document/fs/cargo/pyproject).
  • /audit: architecture ✔ (no cycles/violations, 196 modules), dead-code ✔ (knip: nothing in touched files), duplication 1 → 0 (jscpd).
  • Full local suite: 4051/4052 passed; the handful of integration-test timeouts are local machine contention (issue Serialize package test runs machine-wide (global build-lock) to prevent cross-checkout SIGTERM contention #419), not regressions — deferring to CI's isolated full suite as the authoritative gate.

🤖 Generated with Claude Code

vsajan and others added 6 commits June 30, 2026 12:05
…tor tails)

detectCargoWorkspace and detectUvWorkspace shared a byte-identical members-
resolution tail (parsed when readable → absent for an explicitly-empty `[]` →
unreadable otherwise), differing only in the reader fn, table, label, and config
filename. Extract it into one helper both call after their own (differing)
pre-checks. Behavior-preserving; the six detectors otherwise stay separate (their
file-format bodies are irreducible — merging further would be over-abstraction).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
singleRepoTarget and leafTarget were identical but for the directory they
skeletonize and the path they render to. Fold the shared fingerprint→skeleton→
render wiring into one skeletonTarget(directory, path); the two stay as thin,
self-documenting wrappers. Behavior-preserving.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…amble)

renderDocument and renderRootIndex each hand-built the identical `---<generator>
<fingerprint>---\n\n# Architecture` preamble — the serialization side of the
contract that readDocumentFingerprint / isSafewordOwned and the standalone hook
parser read back. Route both through one architectureFrontmatter(fingerprint) so
a future change to the ownership/fingerprint head can't drift between the two
renderers. Byte-identical output (parity + nudge tests confirm).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
It was only exercised transitively via the Python test-plan path, unlike its
siblings findInTree/indexFilesInTree which have direct tests. Characterize it —
root/subdir match, no-match, maxDepth, and (the load-bearing one) that excluded
+ hidden directories are skipped — as the safety net for the next refactor.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
getScannableSubdirectories and scanTreeForMatch each inlined the same
"is a dir safe to recurse into" predicate (not hidden, not in SUBDIRECTORY_
EXCLUDE). Extract isScannableSubdirectory(entry) so the exclude rule lives in
one place — a future change (e.g. excluding symlinks) can't drift between the
two walkers, exactly the hazard fs.ts's own docs warn about. Behavior-preserving;
covered by the findFileMatchingInTree tests added in the prior commit.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
hasTomlTableKey and readTomlTableString each re-implemented the same table-scoped
line scan (split → strip comment → trim → track inTable via [headers]). Extract a
linesInTable(content, table) generator that yields the in-table lines; both
readers consume it and keep only their own per-line logic. Surfaced by /audit
(jscpd) — toml.ts was outside the original scout set. Behavior-preserving;
covered by the toml + cargo/pyproject manifest tests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@TheMostlyGreat TheMostlyGreat merged commit 1a9e4ba into main Jul 1, 2026
2 checks passed
@TheMostlyGreat TheMostlyGreat deleted the refactor/post-24h-cleanup branch July 1, 2026 00:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants