MS4 — Algorithms & Analysis Depth#5
Merged
Merged
Conversation
…ness artifact MS4 (Algorithms & Analysis Depth), first slice. The codeHealth lens scored via a flat penalty per finding, so the grade scaled with the raw COUNT of complex functions — a large healthy codebase was punished for merely having more code (this repo dogfooded to F). Grade instead on the SHARE of the codebase that is unhealthy: weighted complexity density (a >20 function weighs double a >10 one) plus oversized-file share, each capped. - `computeCodeHealthScore()` (exported, pure) encapsulates the calibration and guards divide-by-zero; `runCodeHealthLens` feeds it real full counts (not the top-10 finding cap) and reports "%N functions above complexity 10" in the summary. Findings list is unchanged (still surfaces the worst offenders). - Extracted `gradeForScore()` shared by both scorers. - Test proves relativity: same absolute complex-function count grades A in a 400-fn repo but D in a 15-fn repo; a dense high-complexity repo is F. Dogfood on this repo: codeHealth F -> B(76) (13% of 249 functions over complexity 10 — an honest B, not a size artifact), overall A(95). Gate green (lint/typecheck/build/test 20/20). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Roadmap MS4 row: codeHealth density calibration done (self-scan F→B(76), overall A(95)); remaining MS4 items enumerated (incremental re-analysis, benchmarks, #27/#28 module associations). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…s unchanged
MS4 (Algorithms & Analysis Depth), part 2. reanalyzeProject re-ran the full
walk/parse/lens pass every time, even when nothing changed. Now it fingerprints
the source tree and short-circuits when that fingerprint matches the last run —
near-instant on an unchanged repo.
- code-analyzer: computeSourceFingerprint(root) — sha256 of path|size|mtime over
the same files analyzeCode walks (stat-only; no reads/parsing, so it's far
cheaper than a full analysis). mtime+size heuristic, the standard build-cache
tradeoff, documented.
- schema: learning_maps.source_fingerprint (migration 0009); persistAnalysis
stores it on every import/refresh.
- reanalyzeProject: computes the current fingerprint, compares to the stored one,
and returns early with { unchanged: true } (artifacts untouched) when they
match. A real edit changes size/mtime → fingerprint flips → full refresh.
- tests: unchanged-tree reanalyze short-circuits (artifacts untouched); the
existing "replaces artifacts" test now touches a file first to exercise the
changed-tree path. Suite 21/21.
Gate: lint + typecheck + build + test all green.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
MS4 (Algorithms & Analysis Depth). Measured the CPU-bound analysis pipeline on synthetic 50/150/300-file projects (throwaway harness, per the scratch-script convention): - Full analysis of 300 files: <200 ms (analyzeCode ~180 ms + lens pass ~4 ms). - The 8-lens pass is flat ~3–4 ms at any size — it reuses the collected corpus, never re-walking or re-parsing. - analyzeCode stays bounded (AST capped at 100 files, total at 300, 80 KB/file); larger repos are analyzed on their most important files and marked truncated. - Incremental re-analysis: an unchanged tree short-circuits on the ~23 ms stat-only fingerprint — ~8× cheaper than a full pass, zero DB writes. docs/BENCHMARKS.md records method, numbers, and interpretation; roadmap MS4 row updated. Co-Authored-By: Claude Opus 4.8 <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.
MS4 (Algorithms & Analysis Depth), stacked on the now-merged MS3 (PR #3). Rebased onto master so this PR contains only the MS4 commits.
What's in it
computeCodeHealthScore()grades on complexity/oversize density, not raw finding count (a >20-complexity fn weighs 2× a >10 one, penalties capped). Fixes the F-from-bigness artifact; self-scan F→B(76), overall A(95).gradeForScore()extracted; relativity test added.computeSourceFingerprint(sha256 of path|size|mtime, stat-only) +learning_maps.source_fingerprint(migration 0009).reanalyzeProjectshort-circuits{unchanged:true}on an untouched tree (~8× cheaper, zero DB writes); a real edit flips the fingerprint and forces a full refresh.docs/BENCHMARKS.md: 300-file full analysis <200ms, flat ~4ms lens pass, bounded by MAX_FILES/AST caps.Remaining MS4 (follow-up)
Fold in the deferred #27/#28 module associations (REVIEW-012) — extend the analyzer to tag questions/concepts with a moduleId, then add the soft column.
Gate: lint + typecheck + build + test (21/21) all green.
🤖 Generated with Claude Code