Extract misfiled code out of packages/folded-runs - #294
Merged
Conversation
…from folded-runs packages/folded-runs was 2,806 source LOC across 13 files, but only definition.ts (~342 LOC) reads the folded projection its name promises; the rest is unrelated domain logic that happened to land there. Move the three misfiled slices to their own packages, pure refactor, no behavior change: - @corbits/agent-events: the sidecar agent.event parsers (connectorReplyContent, inferenceDoneBlocks, toolDoneResult, messageRunStarted, messageRunEnded). Zero dependencies, so trivially browser-safe. - @corbits/folded-run-one-shot: runOneShotFoldedPrompt, the synchronous request/reply runner over one folded run's opening turn. - @corbits/run-scope: createTopLevelRunRoutes and the top-level-run queries, an HTTP route with nothing to do with folded-run lifecycle beyond excluding folded rows. All 18 external importer files and 8 package.json workspace deps are repointed at the new packages; no re-export shim is left behind in folded-runs. folded-runs gains a "./migrations" export subpath so run-scope's own drizzle test can reach applyFoldedRunsMigrations through the package boundary instead of a relative src import.
runOneShotFoldedPrompt, scope-routes.ts, and agent-events.ts moved to @corbits/folded-run-one-shot, @corbits/run-scope, and @corbits/agent-events respectively.
TheGreatAxios
force-pushed
the
cl-folded-runs-extract
branch
from
August 22, 2026 04:09
a6dd7bb to
fa24973
Compare
scripts/e2e/folded-run-backfill.test.ts reached listTopLevelRuns through a relative path into folded-runs' src, bypassing the package's exports map, so repointing the package importers did not move it and the walking-skeleton run failed to resolve the module. scripts/db-setup.ts reaches applyFoldedRunsMigrations the same way and is left alone here: folded-runs still owns migrations, and that import is called out separately in this PR.
This was referenced Aug 22, 2026
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
Two independent reviews found that
packages/folded-runsis not the ~1,000line "renders source from a stored projection" package its description
suggests — it's 2,806 source LOC across 13 files, of which only
definition.ts(~342 LOC) actually reads the folded projection. The rest isreal domain logic that has nothing to do with folded runs and was simply
misfiled. This PR moves the three misfiled slices out, as a pure refactor
with zero behavior change. It does not touch
definition.tsitself — alater epic wants to delete the foldedBody-reading slice, and that's blocked
and out of scope here.
@corbits/agent-events—connectorReplyContent,inferenceDoneBlocks,toolDoneResult,messageRunStarted,messageRunEnded: recognizers forsidecar
agent.eventframes. Zero dependencies (didn't import anythingbefore the move either), so trivially browser-safe. Actual importers,
verified by reading the import graph rather than trusting grep-for-mentions:
packages/chat/src/chat-orchestrator.tsandpackages/tasks/src/orchestrator.ts. (chat-ui, slack-tag, github-tools, andworkflows/workbench-digest only mention these functions in comments — they
don't import them. slack-tag even carries its own mirrored copy of
connectorReplyContentrather than importing the real one.)@corbits/folded-run-one-shot—runOneShotFoldedPrompt, a synchronousrequest/reply runner over one folded run's opening turn with teardown on
every exit path. Depends on
@corbits/folded-runs' public exports(
readDefinitionProjection,readFoldedBody,launchFoldedRun,sendFoldedMailWithRetry,CryptoProviderCache,FoldedRunsDeps) and onthe new
@corbits/agent-events. Consumed by@corbits/routinesand@corbits/task-plannerdirectly;apps/hub/src/index.ts's 4 call sitesalready went through
@corbits/task-planner's re-export barrel (not@corbits/folded-runsdirectly), so hub's import of the function itselfneeded no change.
@corbits/run-scope—createTopLevelRunRoutes,listTopLevelRuns,listTopLevelRunFires: the HTTP route answering "which of this tenant'sworkflow runs are genuine top-level deployments," mounted once in
apps/hub/src/index.ts. Its only folded-run-specific coupling is aNOT EXISTS/LEFT JOINagainstfolded_run, now read through@corbits/folded-runs' publicfoldedRunexport.All 18 external importer files and 8
package.jsonworkspace deps arerepointed at the new packages. No re-export shim is left in
folded-runs.folded-runs' ownpackage.jsondropshono,@corbits/agent-lifecycle,and
@intx/log— each was only used by one of the three moved slices — andgains a
"./migrations"export subpath so the relocatedrun-scope/test/scope-routes.drizzle.test.tscan reachapplyFoldedRunsMigrationsthrough the package boundary instead of a relativesrc` import.Before/after LOC (
packages/folded-runs/src, non-test):2,806 → 1,986. Split out:
agent-events173,folded-run-one-shot278,run-scope338 (small deltas from header-comment path updates, index.tsbarrels).
Known wart, not touched:
scripts/db-setup.ts:32-34importsapplyFoldedRunsMigrations/backfillFoldedRunMarkersfrompackages/folded-runs/src/migrationsby relative path, bypassing thepackage's own
exportsmap.migrations.tsnever moved, so this import isunaffected by this PR — flagging per the review, not fixing here.
Bug spotted, deliberately not fixed: none found in the moved code itself
— this was a pure location change with no logic edits.
Test plan
bun run check(typecheck, lint, tests, all repo checks incl.check:licensesandcheck:browser-safe-subpaths) passes clean fromthe repo root.
bunx prettier --writeover every changed file (no-op — alreadyformatted).
apps/,packages/,workflows/,scripts/.