Skip to content

chore: baseline-driven fallow gate + Husky pre-commit#33

Merged
ethanj merged 3 commits intomainfrom
fallow-upgrade
Apr 22, 2026
Merged

chore: baseline-driven fallow gate + Husky pre-commit#33
ethanj merged 3 commits intomainfrom
fallow-upgrade

Conversation

@ethanj
Copy link
Copy Markdown
Contributor

@ethanj ethanj commented Apr 22, 2026

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 audit uses baselines in .fallow/health-baseline.json and .fallow/dupes-baseline.json (committed) as the floor. Only increases beyond the baseline fail.
  • Husky v9 pre-commit hook runs the same fallow audit locally, so a commit that passes here will pass CI.
  • CI workflows (ci.yml, release.yml) unpinned from fallow@2.43.0 — future fallow improvements flow in without blocking unrelated PRs.
  • .gitignore split: baselines tracked; regenerable cache.bin / churn.bin ignored.

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

  • Extract memory-repository.tspg-memory-store.ts / pg-search-store.ts near-duplicates (~375 lines across three clone groups) — biggest single dupes-baseline win.
  • Dedupe runtime-container.ts:227-242 vs memories.ts:611-626 formatHealthConfig readers (16 lines).
  • Refactor the four HIGH-tagged functions to drop the complexity ceiling.

Test plan

  • npx fallow audit --health-baseline=... --dupes-baseline=... passes (0 issues in 8 changed files)
  • Pre-commit hook runs the same audit and passes on this branch's changes
  • CI on this PR runs green end-to-end

ethanj and others added 3 commits April 22, 2026 12:59
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>
@ethanj ethanj merged commit baa7480 into main Apr 22, 2026
1 check passed
@ethanj ethanj deleted the fallow-upgrade branch April 22, 2026 20:16
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.

1 participant