chore: baseline-driven fallow gate + Husky pre-commit#33
Merged
Conversation
fallow 2.45 introduced stricter thresholds (CRAP >= 30 and updated cyclomatic/cognitive scoring) that flag 17 pre-existing complex functions plus 29 clone groups on untouched files (llm.ts chat/ recordOpenAICost, repository-claims.ts createClaim*, embedding.ts requestAndTrack, search-pipeline.ts applyExpansionAndReranking, memory-repository.ts ↔ pg-*-store.ts near-duplicates, etc.). Rather than pin fallow forever or rewrite the ingest/search/AUDN internals in one pass, switch the gate to baseline-driven `fallow audit`: - Save current state as the floor (.fallow/health-baseline.json and .fallow/dupes-baseline.json, tracked in git). CI compares against these; only NEW regressions beyond the baseline fail. - Husky v9 pre-commit hook runs `npx fallow audit` with the same baselines and the same auto-detected base-branch scope as CI, so a commit that passes locally will pass CI. - CI workflows switch from the pinned `npx fallow@2.43.0 --no-cache` to `npx fallow audit`. Unpinning lets future fallow improvements land; the baseline protects pre-existing debt from blocking unrelated PRs. .gitignore was split so baselines stay tracked while regenerable fallow artifacts (.fallow/cache.bin, .fallow/churn.bin) stay out of git. Follow-up worth tracking: - Extract the memory-repository ↔ pg-memory-store / pg-search-store near-duplicates (~375 lines across three clone groups) — biggest single win for the dupes baseline. - Dedupe the runtime-container vs formatHealthConfig config-snapshot reader (16 lines, already flagged). - Refactor the four HIGH-tagged functions (repository-write.ts buildBaseParams, repository-claims.ts createClaimVersionWithClient, llm.ts chat, memory-audn.ts tryOpinionIntercept) to drop the complexity ceiling. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
actions/checkout@v4 defaults to fetch-depth: 1, leaving only HEAD in the runner's clone. fallow audit then fails with "could not detect base branch" because it has no ref to diff against. Fix: fetch-depth: 0 and pass --base=origin/<base_ref> explicitly so audit scopes to the PR's diff against its target branch. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Ratchet: new step runs scripts/check-baseline-ratchet.sh after the fallow audit, failing any PR that grows .fallow/health-baseline.json or .fallow/dupes-baseline.json beyond the base branch's entry count. Refactors that drop entries pass freely; regressions are blocked even if they'd still fit under the grandfathered audit. Over time, this pushes the baseline to zero without anyone having to remember. Seeded tech-debt.md with the 17 HIGH-complexity functions and 29 clone groups the current baseline grandfathers, each with enough context to pick up later. Lists the high-leverage wins first (memory-repository dedupe, the four HIGH-tagged service functions, the repository-claims / memory-lineage clone) so the next debt-paydown pass knows where to start. Co-Authored-By: Claude Opus 4.7 (1M context) <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.
Summary
Swap the fallow CI gate from a full-codebase check (which fallow 2.45 fails on ~17 pre-existing complex functions + 29 clone groups we didn't touch) to a baseline-driven audit. New regressions still fail; pre-existing debt is frozen at today's floor and tracked for future refactors.
fallow audituses baselines in.fallow/health-baseline.jsonand.fallow/dupes-baseline.json(committed) as the floor. Only increases beyond the baseline fail.fallow auditlocally, so a commit that passes here will pass CI.ci.yml,release.yml) unpinned fromfallow@2.43.0— future fallow improvements flow in without blocking unrelated PRs..gitignoresplit: baselines tracked; regenerablecache.bin/churn.binignored.Why baseline-driven instead of "fix everything"
A full cleanup of the 17 complexity violations + 29 clone groups would mean rewriting ingest/search/AUDN internals (
repository-write.ts buildBaseParams,repository-claims.ts createClaim*,llm.ts chat,memory-audn.ts tryOpinionIntercept,search-pipeline.ts applyExpansionAndReranking, plus 3 memory-repository ↔ pg-*-store near-duplicates) in one pass. That's a high-risk rewrite of hot paths with no DB-backed regression signal locally. Baseline now, refactor in focused follow-ups.Follow-ups worth tracking
memory-repository.ts↔pg-memory-store.ts/pg-search-store.tsnear-duplicates (~375 lines across three clone groups) — biggest single dupes-baseline win.runtime-container.ts:227-242vsmemories.ts:611-626formatHealthConfigreaders (16 lines).Test plan
npx fallow audit --health-baseline=... --dupes-baseline=...passes (0 issues in 8 changed files)