Skip to content

refactor: reduce structural hotspots — split barrels, extract modules, auto-generate registry#116

Merged
chadjw merged 1 commit intomainfrom
hotspot-refactor
Apr 7, 2026
Merged

refactor: reduce structural hotspots — split barrels, extract modules, auto-generate registry#116
chadjw merged 1 commit intomainfrom
hotspot-refactor

Conversation

@chadjw
Copy link
Copy Markdown
Contributor

@chadjw chadjw commented Apr 7, 2026

Summary

  • Split types/src/index.ts (450 lines) into 5 domain files + barrel, fixing circular imports
  • Split learnings.ts (813 lines) into 4 acyclic leaf modules (content, loader, lifecycle, crud)
  • Auto-generate CLI command registry via scripts/generate-barrel-exports.mjs, replacing 48 manual imports
  • Document hidden sync-engine ↔ github-issues coupling
  • Update arch baselines for new module count

Re-opened after reverting PR #115 which contained rogue commits.

Test plan

  • All 4,371 tests pass across all packages
  • Typecheck and lint pass
  • Architecture gate passes with updated baselines

…, auto-generate registry

Address all findings from hotspot analysis (co-change, churn, hidden coupling):

Types package (450→95 lines + 5 domain files):
- Split index.ts into result.ts, workflow.ts, skill.ts, ci.ts, roadmap.ts
- Fix circular imports: tracker-sync.ts and orchestrator.ts now import from
  domain files directly instead of through index.ts

Learnings module (813→230 lines + 3 leaf modules):
- Extract learnings-content.ts (parsing, hashing, dedup — leaf, no siblings)
- Extract learnings-loader.ts (file loading + mtime cache — leaf, no siblings)
- Extract learnings-lifecycle.ts (prune, archive, promote — imports from leaves)
- Strictly acyclic dependency graph: content ← loader ← {learnings, lifecycle}

CLI command registration (108→14 lines in index.ts):
- Auto-generate _registry.ts via scripts/generate-barrel-exports.mjs
- createProgram() loops over discovered commands instead of 48 manual imports
- Supports both `export function` and `export const` patterns
- `pnpm run generate-barrel-exports --check` for CI freshness validation

Hidden dependency (sync-engine ↔ github-issues):
- Document adapter coupling via comment in sync-engine.ts

Update arch baselines for new module count (+10 files).
@chadjw chadjw merged commit 9d42ade into main Apr 7, 2026
@chadjw chadjw deleted the hotspot-refactor branch April 7, 2026 13:07
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