Skip to content

refactor: extract generatorDispatch + factBreakout to forge/ (tier-2) - #137

Merged
dsmcewan merged 2 commits into
mainfrom
chore/forge-tier2-extraction
Jul 26, 2026
Merged

refactor: extract generatorDispatch + factBreakout to forge/ (tier-2)#137
dsmcewan merged 2 commits into
mainfrom
chore/forge-tier2-extraction

Conversation

@dsmcewan

Copy link
Copy Markdown
Owner

Summary

Closes the tier-2 scope from #30 — extracts the byte-identical generatorDispatch, writeUnder, and factBreakout functions into shared forge/ modules.

  • forge/generators.mjs — shared generatorDispatch + writeUnder (extracted from both forges)
  • forge/breakouts.mjs — shared factBreakout (extracted from both forges)
  • forge/scripts/test-boundaries.mjs — CI grep guard: asserts ai-forge/ never imports from saas-forge/ and vice versa

Both products re-export from the shared modules, so zero downstream consumer changes — all existing import paths work unchanged, including the 4 doc run scripts.

Product-specific code stays product-side:

ai-forge saas-forge
makePatternGenerators makeDemoGenerators
runPatternBreakouts runTeamBreakouts (incl. fight-log persistence)

Test plan

  • npm test --prefix forge — 5 existing tests + boundary guard pass
  • npm test --prefix ai-forge — all 15 tests pass with zero test modifications
  • npm test --prefix saas-forge — all 3 tests pass with zero test modifications
  • node --check on all 4 doc run scripts (re-export means paths unchanged)
  • Net LOC: -29 lines (74 added, 103 removed)

🤖 Generated with Claude Code

https://claude.ai/code/session_01FhZFdxVtf2rgMnzxCEW5NS

…30)

Move the byte-identical generatorDispatch, writeUnder, and factBreakout
functions from ai-forge/ and saas-forge/ into forge/generators.mjs and
forge/breakouts.mjs. Both products re-export from the shared module so
downstream import paths are unchanged.

Product-specific code stays product-side:
- ai-forge: makePatternGenerators, runPatternBreakouts
- saas-forge: makeDemoGenerators, runTeamBreakouts (incl. fight logs)

Adds forge/scripts/test-boundaries.mjs — a CI grep guard that asserts
neither product imports from the other.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FhZFdxVtf2rgMnzxCEW5NS
@dsmcewan

Copy link
Copy Markdown
Owner Author

@claude take care of th9s please

@claude

claude Bot commented Jul 26, 2026

Copy link
Copy Markdown

Claude finished @dsmcewan's task in 1m 27s —— View job


Review complete ✅

  • Read PR context and diff
  • Check CI status for this PR
  • Review the extraction changes (forge/generators.mjs, forge/breakouts.mjs, boundary guard)
  • Run affected package test suites (verified via CI — see note below)
  • Post summary

CI status: both CI and Claude Code Review workflows are green (all matrix jobs, including forge, ai-forge, saas-forge on Node 18 & 20) — https://github.com/dsmcewan/TELOS/actions/runs/30193046750

Code review — looks correct, nothing to fix:

  • forge/generators.mjs / forge/breakouts.mjs are byte-identical lifts of generatorDispatch/writeUnder/factBreakout out of ai-forge and saas-forge — verified the diffs line-by-line, no behavioral drift.
  • Both products now just export { generatorDispatch } / export { factBreakout } from ../forge/..., so all existing downstream import paths (including the 4 doc run scripts) keep working — confirmed no other file imports the old local definitions.
  • forge/scripts/test-boundaries.mjs correctly greps ai-forge/ for saas-forge imports and vice versa, scoped to the repo root via import.meta.url resolution — sound guard against re-coupling the two products.
  • forge/package.json's check/test scripts were updated to node --check the two new modules and run the new boundary test — consistent with this repo's "npm test runs node --check first" convention.
  • Cross-package imports (forge/generators.mjs../merkle-dag/vendor.mjs, forge/breakouts.mjs../breakout/verifier.mjs) match the pre-existing pattern already used by forge/ratchet.mjs and forge/operator.mjs, so this doesn't introduce a new architectural coupling.
  • Removed the stale "Phase A duplication — each forge owns its own copy" comment from ai-forge/breakouts.mjs, which is correct now that the duplication is gone.
  • No dependencies added, all imports use the node: prefix, style matches the surrounding zero-dependency .mjs packages — compliant with CLAUDE.md conventions.

I wasn't able to execute npm test locally myself (the sandbox requires interactive approval for that command and none was available in this run), but CI already ran the identical npm test for forge, ai-forge, and saas-forge across both supported Node versions and passed, which covers the PR's stated test plan.

Verdict: this PR is clean, scoped correctly, and CI-green — looks ready to merge as-is. No changes needed from me.

@dsmcewan
dsmcewan merged commit 8fe2b70 into main Jul 26, 2026
29 checks passed
@dsmcewan
dsmcewan deleted the chore/forge-tier2-extraction branch July 26, 2026 17:49
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