From d6a4fe4969d7ccf9b5cafe7d19de10b9e4c34075 Mon Sep 17 00:00:00 2001 From: Sawyer Date: Sat, 5 Sep 2026 23:38:37 -0700 Subject: [PATCH 1/8] hub: point stale folded-runs comments at the packages that replaced it Several comments in apps/hub still named the deleted @corbits/folded-runs package and its FoldedRunsDeps type. Point them at createHubChatPlatform's CreateHubChatPlatformDeps, @corbits/workflows, and @corbits/run-scope, which now own the referenced behavior. --- apps/hub/src/hub-error-handler.ts | 2 +- apps/hub/src/index.ts | 22 +++++++++---------- apps/hub/src/mcp-credential-bindings.ts | 7 +++--- .../hub/src/native-workflow-routine-launch.ts | 12 +++++----- .../src/pinned-package-credential-bindings.ts | 7 +++--- apps/hub/src/tool-grants.test.ts | 4 +--- apps/hub/src/tool-grants.ts | 9 ++++---- 7 files changed, 32 insertions(+), 31 deletions(-) diff --git a/apps/hub/src/hub-error-handler.ts b/apps/hub/src/hub-error-handler.ts index 68b8b0dc0a..100fc4ed32 100644 --- a/apps/hub/src/hub-error-handler.ts +++ b/apps/hub/src/hub-error-handler.ts @@ -16,7 +16,7 @@ import { makeErrorEnvelope } from "@corbits/error-sink"; * Duck-typed rather than an `instanceof` allowlist: any error carrying a * string `guidance` alongside its `message` is a named, consumer-facing * failure the thrower already wrote for a human to read — see - * `@corbits/folded-runs`'s `DefinitionProjectionMissingError` and + * `@corbits/workflows`'s `DefinitionProjectionMissingError` and * `MultiStepFoldUnsupportedError`. Its `message` is safe to return * verbatim; anything else is a platform fault whose internals must not * leak to a client. diff --git a/apps/hub/src/index.ts b/apps/hub/src/index.ts index 795f0897f5..39d52b853d 100644 --- a/apps/hub/src/index.ts +++ b/apps/hub/src/index.ts @@ -757,17 +757,17 @@ export async function createHub(config: HubConfig) { }, }; const hubPublicKey = hexEncode(signingKey.publicKey); - // CL-6149: a folded run's pinned tool packages (`toolPackagePins`) - // carry no grants of their own — the deploy-time capability walk + // CL-6149: a launch's pinned tool packages (`toolPackagePins`) carry + // no grants of their own — the deploy-time capability walk // (`vendor/intx/workflow-deploy/src/capability-walk.ts`) only derives // `tool:` grants for inline tool factories, so a pinned package's // tools failed every call closed with "No matching grants". Every // `@corbits/*-tools` package's namespaced tool ids and approval marks // are read once here (`describeCorbitsToolPackages`), so - // `toolGrantsForPins` — the port every `FoldedRunsDeps` below is - // built with — can synchronously turn a launch's pins into the - // `tool:` grants `@corbits/folded-runs`' `deployAtHead` - // mints against the run's own principal. + // `toolGrantsForPins` — the port `createHubChatPlatform`'s + // `CreateHubChatPlatformDeps` is built with — can synchronously turn a + // launch's pins into the `tool:` grants minted against + // the run's own principal. const toolGrantsForPins = createToolGrantsForPins( await describeCorbitsToolPackages(), ); @@ -2800,11 +2800,11 @@ export async function createHub(config: HubConfig) { // down immediately — never a resident that outlives the request, so no // idle-sleep lifecycle is needed for it. - // Every genuine top-level deployment run, folded runs (workbench hosts, - // invited agents) excluded — the scoped listing CL-6061 adds - // so the Agent Directory and the shell's "Running" bands stop - // deriving that exclusion client-side from a tenant's workbenches alone - // (see `@corbits/folded-runs`'s `scope-routes.ts`, which a folded run + // Every genuine top-level deployment run, workbench-hosted and invited-agent + // runs excluded — the scoped listing CL-6061 adds so the Agent Directory + // and the shell's "Running" bands stop deriving that exclusion + // client-side from a tenant's workbenches alone (see + // `@corbits/run-scope`'s `scope-routes.ts`, which a non-top-level run // with no workbench involved silently slipped past). app.route( `${TENANT_PREFIX}/top-level-runs`, diff --git a/apps/hub/src/mcp-credential-bindings.ts b/apps/hub/src/mcp-credential-bindings.ts index 334fd19888..d425eb1c8f 100644 --- a/apps/hub/src/mcp-credential-bindings.ts +++ b/apps/hub/src/mcp-credential-bindings.ts @@ -1,6 +1,7 @@ -// The `McpCredentialBindingsFor` port every `FoldedRunsDeps` below is wired -// with — see `@corbits/folded-runs`' `types.ts` for why this has to be -// supplied by the composition root rather than derived by the deploy-time +// The `McpCredentialBindingsFor` port `createHubChatPlatform`'s +// `CreateHubChatPlatformDeps` is wired with — see `@corbits/chat`'s +// `platform-adapter.ts` for why this has to be supplied by the +// composition root rather than derived by the deploy-time // capability walk. `@corbits/mcp-tools`' credential handles are dynamic // (one `mcp.` per tenant-connected server), so this builds one // `CredentialBinding` per connection `@corbits/connections`' own diff --git a/apps/hub/src/native-workflow-routine-launch.ts b/apps/hub/src/native-workflow-routine-launch.ts index 1ce8e574d9..dd55f27b48 100644 --- a/apps/hub/src/native-workflow-routine-launch.ts +++ b/apps/hub/src/native-workflow-routine-launch.ts @@ -1,15 +1,15 @@ // Routes a multi-step routine definition onto Interchange's native -// workflow-run trigger primitive instead of `@corbits/folded-runs`' +// workflow-run trigger primitive instead of `@corbits/workflows`' // single-step fold. // // A multi-step `workflow_definition` can only exist in this repo as a // code-sourced `@intx/workflow` package deployed through // `POST /workflows/deployments` // (`vendor/intx/hub-api/src/routes/workflows.ts`, backed by -// `sessionService.deployWorkflowFromSource`) — `@corbits/folded-runs`' +// `sessionService.deployWorkflowFromSource`) — `@corbits/workflows`' // `readFoldedBody` throws `MultiStepFoldUnsupportedError` for exactly -// this reason (see `packages/folded-runs/src/definition.ts`): its -// deploy target, `@corbits/agent-runtime`'s single-turn +// this reason (see `packages/workflows/src/definition-projection.ts`): +// its deploy target, `@corbits/agent-runtime`'s single-turn // `AgentRuntimeConfig`, has no notion of step order, so folding a // multi-step body into it would silently run step one and drop the // rest. Since a code-sourced deploy is the ONLY way a multi-step @@ -23,8 +23,8 @@ // public surface, so the message is assembled here from the same // public `@intx/mime`/`@intx/crypto` primitives it uses, and delivered // through `SidecarRouter.routeMail` — a public method every -// `FoldedRunsDeps` caller (including the routine launcher) already -// holds. +// `createHubChatPlatform` caller (including the routine launcher) +// already holds. // // Grant authorization for this mail-triggered run is materialized by // the vendored session orchestrator's own `mail.outbound` handler diff --git a/apps/hub/src/pinned-package-credential-bindings.ts b/apps/hub/src/pinned-package-credential-bindings.ts index e286040225..57681a93c2 100644 --- a/apps/hub/src/pinned-package-credential-bindings.ts +++ b/apps/hub/src/pinned-package-credential-bindings.ts @@ -1,6 +1,7 @@ -// The `PinnedPackageCredentialBindingsFor` port every `FoldedRunsDeps` -// below is wired with — see `@corbits/folded-runs`' `types.ts` for why -// this has to be supplied by the composition root rather than declared as +// The `PinnedPackageCredentialBindingsFor` port `createHubChatPlatform`'s +// `CreateHubChatPlatformDeps` is wired with — see `@corbits/chat`'s +// `platform-adapter.ts` for why this has to be supplied by the +// composition root rather than declared as // a required assistant `credentialBindings` entry. Static-handle packages // (`@corbits/manus-tools`, granola-tools, …) declare // `interchange.credentials`, but requiring those binds on the assistant diff --git a/apps/hub/src/tool-grants.test.ts b/apps/hub/src/tool-grants.test.ts index 987dd0b385..13dacd1e2a 100644 --- a/apps/hub/src/tool-grants.test.ts +++ b/apps/hub/src/tool-grants.test.ts @@ -1,8 +1,6 @@ // CL-6149: proves the hub's `toolGrantsForPins` port turns a launch's // `toolPackagePins` into the exact `tool:` grants the -// workflow child's authz gate matches against — see -// `@corbits/folded-runs`' `deployAtHead`, which mints these into -// `config.grants`. +// workflow child's authz gate matches against. import { describe, expect, test } from "bun:test"; import { describeCorbitsToolPackages } from "@corbits/tool-registry-publish"; import { createToolGrantsForPins } from "./tool-grants"; diff --git a/apps/hub/src/tool-grants.ts b/apps/hub/src/tool-grants.ts index 11efd6a3c0..6358dd365b 100644 --- a/apps/hub/src/tool-grants.ts +++ b/apps/hub/src/tool-grants.ts @@ -1,10 +1,11 @@ -// CL-6149: a folded run's pinned tool packages (`toolPackagePins`) carry -// no grants of their own — the deploy-time capability walk +// CL-6149: a launch's pinned tool packages (`toolPackagePins`) carry no +// grants of their own — the deploy-time capability walk // (`vendor/intx/workflow-deploy/src/capability-walk.ts`) only derives // `tool:` grants for inline tool factories, so a pinned package's tools // failed every call closed with "No matching grants". This builds the -// `ToolGrantsForPins` port every `FoldedRunsDeps` in this composition is -// wired with: given a launch's pins, look up each pin's package by name +// `ToolGrantsForPins` port `createHubChatPlatform`'s +// `CreateHubChatPlatformDeps` is wired with: given a launch's pins, look +// up each pin's package by name // in the hub's own `describeCorbitsToolPackages()` read and mint one // `tool:` / `invoke` declaration per tool, floored at `ask` // for a tool the package itself marks `approval: "ask"`. From 9f218319bfc3a253eda2bf2693b2078054088c15 Mon Sep 17 00:00:00 2001 From: Sawyer Date: Sat, 5 Sep 2026 23:40:52 -0700 Subject: [PATCH 2/8] web: retire stale folded-run terminology in top-level-run comments Several comments described the scope-routes filter using the deleted @corbits/folded-runs package and a nonexistent folded_run marker table. Reworded them around the actual predicate (top-level vs non-top-level run) and pointed the package references at @corbits/run-scope. --- apps/web/src/agents-api.ts | 31 +++++++++++++------------- apps/web/src/agents-directory.ts | 6 ++--- apps/web/src/insights-api.ts | 8 +++---- apps/web/src/insights-stats.ts | 15 +++++++------ apps/web/src/shell/routine-activity.ts | 6 ++--- apps/web/test/bench-activity.test.tsx | 9 ++++---- apps/web/test/insights-route.test.tsx | 2 +- apps/web/test/routine-activity.test.ts | 11 ++++----- 8 files changed, 46 insertions(+), 42 deletions(-) diff --git a/apps/web/src/agents-api.ts b/apps/web/src/agents-api.ts index e34c8c5868..a7966772df 100644 --- a/apps/web/src/agents-api.ts +++ b/apps/web/src/agents-api.ts @@ -152,14 +152,15 @@ export function listAgentInstances( } /** - * The tenant's genuine top-level deployment runs — every folded run - * (workbench host, invited agent, routine fire, task) excluded server-side - * by the hub's own `folded_run` marker table (see `@corbits/folded-runs`'s - * `scope-routes.ts`), not derived client-side from a tenant's workbenches - * the way `foldedRunIdsFromWorkbenches` used to. Used wherever a page needs - * "real deployments only" — the Agent Directory. A routine fire IS a - * folded run, so this feed structurally never carries one; a caller that - * needs routine activity wants `listRoutineRunFires` below instead. + * The tenant's genuine top-level deployment runs — every non-top-level + * run (workbench host, invited agent, routine fire, task) excluded + * server-side by the same predicate `isTopLevelRun` uses (see + * `@corbits/run-scope`'s `scope-routes.ts`), not derived client-side + * from a tenant's workbenches the way `foldedRunIdsFromWorkbenches` used + * to. Used wherever a page needs "real deployments only" — the Agent + * Directory. A routine fire is NOT top-level, so this feed structurally + * never carries one; a caller that needs routine activity wants + * `listRoutineRunFires` below instead. */ export function listTopLevelRuns( tenantId: string, @@ -172,13 +173,13 @@ export function listTopLevelRuns( /** * `feed=fires` (CL-6249): the tenant's genuine *executed* runs — unlike - * `listTopLevelRuns`, a routine's fire is kept even though it is a folded - * run, tagged with the routine that fired it (see - * `@corbits/folded-runs`'s `scope-routes.ts`'s `listTopLevelRunFires`). + * `listTopLevelRuns`, a routine's fire is kept even though it is not a + * top-level run, tagged with the routine that fired it (see + * `@corbits/run-scope`'s `scope-routes.ts`'s `listTopLevelRunFires`). * The shell's "Running" activity band (CL-6595) reads this, not * `listTopLevelRuns`, so a routine's own run is actually visible here — - * `listTopLevelRuns`'s `notExists(folded_run)` filter drops every routine - * fire by construction, which left Mission Control's active-run count + * `listTopLevelRuns`'s top-level-only filter drops every routine fire by + * construction, which left Mission Control's active-run count * permanently desynced from the Routines page's own "Running now" pill. */ export function listRoutineRunFires( @@ -466,8 +467,8 @@ type SkillsOutcome = * so either failing alone never blanks the page. Failures surface as * `modelsError` / `skillsError` rather than silent empty collections. * `instances` comes from `listTopLevelRuns`, which already excludes every - * folded run (workbench host, invited agent) server-side — see - * `@corbits/folded-runs`'s `scope-routes.ts` — so this page never has to + * non-top-level run (workbench host, invited agent) server-side — see + * `@corbits/run-scope`'s `scope-routes.ts` — so this page never has to * derive that exclusion itself from a tenant's workbenches. */ export async function loadAgentDirectory( diff --git a/apps/web/src/agents-directory.ts b/apps/web/src/agents-directory.ts index 02705a4133..7eb2715436 100644 --- a/apps/web/src/agents-directory.ts +++ b/apps/web/src/agents-directory.ts @@ -40,9 +40,9 @@ export function purposeAgentDefinitions( /** * `instances` is expected to already come from `listTopLevelRuns` - * (see `./agents-api.ts`), which excludes every folded run (workbench - * host, invited agent, task) server-side — see - * `@corbits/folded-runs`'s `scope-routes.ts`. This still applies the + * (see `./agents-api.ts`), which excludes every non-top-level run + * (workbench host, invited agent, task) server-side — see + * `@corbits/run-scope`'s `scope-routes.ts`. This still applies the * shared name-based workbench-host filter as defense in depth. */ export function purposeAgentInstances( diff --git a/apps/web/src/insights-api.ts b/apps/web/src/insights-api.ts index 63cd692681..26ddf88d26 100644 --- a/apps/web/src/insights-api.ts +++ b/apps/web/src/insights-api.ts @@ -14,7 +14,7 @@ // /scope is how a page discovers that shape to build a switcher. // Plus one more reused as Insights' run feed: GET /top-level-runs?feed=fires // → Paginated -// (packages/folded-runs/src/scope-routes.ts's `listTopLevelRunFires`). +// (packages/run-scope/src/scope-routes.ts's `listTopLevelRunFires`). import { type } from "arktype"; import { WorkflowRunResponse, paginatedSchema } from "@intx/types"; @@ -259,10 +259,10 @@ const TOP_LEVEL_RUNS_LIMIT = 100; /** * Insights' run feed (CL-6062, `feed=fires` added by CL-6249): the - * tenant's genuine *executed* runs — a routine's fire (folded run though - * it is) included, and the resident, never-triggered deployment + * tenant's genuine *executed* runs — a routine's fire (not a top-level + * run though it is) included, and the resident, never-triggered deployment * placeholder for a definition (`status: "deployed"` forever) excluded — - * both decided server-side by `@corbits/folded-runs`'s + * both decided server-side by `@corbits/run-scope`'s * `scope-routes.ts`'s `listTopLevelRunFires`, never by a definitionName * slug guess here. Used in place of the dead `/me/workflows/runs` — its * `anchorRunId IS NULL` filter never matches, because every addressed run diff --git a/apps/web/src/insights-stats.ts b/apps/web/src/insights-stats.ts index 7ded59b02d..148529065e 100644 --- a/apps/web/src/insights-stats.ts +++ b/apps/web/src/insights-stats.ts @@ -60,12 +60,13 @@ export const INSIGHTS_RECENT_LIMIT = 12; /** * Purpose runs only — drop workbench-host anchors the same way Home does. * `insights-page.tsx` sources `runs` from `insightsTopLevelRunsPath` (see - * `./insights-api.ts`), which already excludes every folded run with no - * routine parent, and the resident never-fired deployment placeholder, - * server-side via `@corbits/folded-runs`'s `scope-routes.ts`'s - * `listTopLevelRunFires`. This filter is a client-side belt-and-suspenders - * pass against the workbench-host naming pattern alone, not a second scoping - * layer — a caller no longer needs to (and cannot) hand this a folded-run + * `./insights-api.ts`), which already excludes every non-top-level run + * (workbench host, invited agent) with no routine parent, and the + * resident never-fired deployment placeholder, server-side via + * `@corbits/run-scope`'s `scope-routes.ts`'s `listTopLevelRunFires`. This + * filter is a client-side belt-and-suspenders pass against the + * workbench-host naming pattern alone, not a second scoping layer — a + * caller no longer needs to (and cannot) hand this a non-top-level run * id set. CL-6062 replaced the dead `/me/workflows/runs` feed (its * `anchorRunId IS NULL` filter never matched anything, since every * addressed run self-anchors at creation) with this scoped one. @@ -83,7 +84,7 @@ export function purposeRunsForInsights( * from one, honestly falling back to the definition name for a run with * no routine/task parent — e.g. a directly launched workflow. Never * mapped from a client-side lookup table; the route already resolved - * `routineName` server-side (`@corbits/folded-runs`'s + * `routineName` server-side (`@corbits/run-scope`'s * `listTopLevelRunFires`). */ export function runDisplayName(run: InsightsRun): string { diff --git a/apps/web/src/shell/routine-activity.ts b/apps/web/src/shell/routine-activity.ts index 626ec6d940..fb018ea1b5 100644 --- a/apps/web/src/shell/routine-activity.ts +++ b/apps/web/src/shell/routine-activity.ts @@ -3,9 +3,9 @@ // `listRoutineActivity`, never on where the data actually comes from. // Filled from `./agents-api.ts`'s `listRoutineRunFires` — the `feed=fires` // listing, the one top-level-runs view that keeps a routine's fire despite -// it being a folded run (see that function's own comment). The plain -// `listTopLevelRuns` feed looks tempting here but is wrong: its -// `notExists(folded_run)` filter drops every routine fire by construction, +// it not being a top-level run (see that function's own comment). The +// plain `listTopLevelRuns` feed looks tempting here but is wrong: its +// top-level-only filter drops every routine fire by construction, // so a routine genuinely running would never show up in this band or count // toward Mission Control's "Active runs" — exactly CL-6595's desync // between the Routines page's own "Running now" pill and Mission Control's diff --git a/apps/web/test/bench-activity.test.tsx b/apps/web/test/bench-activity.test.tsx index 4d5cf7243a..91c810a187 100644 --- a/apps/web/test/bench-activity.test.tsx +++ b/apps/web/test/bench-activity.test.tsx @@ -139,10 +139,11 @@ describe("useBenchActivity", () => { }, ], // The workbench host and the invited agent never appear here: the - // hub's `/top-level-runs?feed=fires` route excludes every folded - // run that isn't a routine fire (see `@corbits/folded-runs`'s - // `scope-routes.ts`). A routine's own fire IS a folded run, so it - // must still show up here (`run_routine1`, tagged with its + // hub's `/top-level-runs?feed=fires` route excludes every + // non-top-level run that isn't a routine fire (see + // `@corbits/run-scope`'s `scope-routes.ts`). A routine's own fire + // is not a top-level run, so it must still show up here + // (`run_routine1`, tagged with its // `routineId`) -- that is the CL-6595 fix; a directly-triggered // deployment with no routine parent (`run_deployment1`) is not // routine activity and must not appear. diff --git a/apps/web/test/insights-route.test.tsx b/apps/web/test/insights-route.test.tsx index 4b482bb2f5..6ef34a19b4 100644 --- a/apps/web/test/insights-route.test.tsx +++ b/apps/web/test/insights-route.test.tsx @@ -1,5 +1,5 @@ // CL-6062: Insights' run feed reads from the tenant-scoped top-level-runs -// endpoint (packages/folded-runs/src/scope-routes.ts), not the dead +// endpoint (packages/run-scope/src/scope-routes.ts), not the dead // `/me/workflows/runs` (every addressed run self-anchors at creation, so // that feed's `anchorRunId IS NULL` filter never matched anything). These // tests exercise the real fetch wiring `InsightsRoute` owns — the unit diff --git a/apps/web/test/routine-activity.test.ts b/apps/web/test/routine-activity.test.ts index 385b2b5854..047c76696b 100644 --- a/apps/web/test/routine-activity.test.ts +++ b/apps/web/test/routine-activity.test.ts @@ -1,9 +1,10 @@ // CL-6595: the shell's "Running" section and Mission Control's active-run // count both read `listRoutineActivity`, which must source the `feed=fires` // listing — the one top-level-runs view that keeps a routine's fire (see -// `@corbits/folded-runs`'s `scope-routes.ts`). The plain `listTopLevelRuns` -// feed excludes every folded run, and a routine fire IS a folded run, so a -// routine genuinely running would never appear here at all -- Mission +// `@corbits/run-scope`'s `scope-routes.ts`). The plain `listTopLevelRuns` +// feed excludes every non-top-level run, and a routine fire is not a +// top-level run, so a routine genuinely running would never appear +// here at all -- Mission // Control would read "0 active" while the Routines page's own "Running // now" pill (driven by the same run's `workflow_run.status`) disagreed. @@ -131,8 +132,8 @@ describe("listRoutineActivity", () => { }); // A directly-triggered deployment run is also a `feed=fires` row (it is - // not a folded run at all), but it has no routine parent -- it must not - // be counted as routine activity. + // a top-level run), but it has no routine parent -- it must not be + // counted as routine activity. test("drops a fires-feed row with no routine parent", async () => { stubTopLevelRunsFetch([nonRoutineFire]); expect(await listRoutineActivity("tnt_1")).toEqual([]); From cbf7363190b12d9f4d8425d09200ada8242ecc1c Mon Sep 17 00:00:00 2001 From: Sawyer Date: Sat, 5 Sep 2026 23:41:35 -0700 Subject: [PATCH 3/8] sidecar: point lazy-wake comments at chat's wakeByAddress, not folded-runs The deferred-to-wake restore path's comments still named the deleted @corbits/folded-runs package's wakeFoldedRun/deployAtHead. Point them at @corbits/chat's wakeByAddress, which now backs the lazy-wake port. --- apps/sidecar/src/workflow-host-wiring/index.ts | 8 ++++---- apps/sidecar/test/workflow-restore-defer-to-wake.test.ts | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/sidecar/src/workflow-host-wiring/index.ts b/apps/sidecar/src/workflow-host-wiring/index.ts index a362fb3d38..26fe82a749 100644 --- a/apps/sidecar/src/workflow-host-wiring/index.ts +++ b/apps/sidecar/src/workflow-host-wiring/index.ts @@ -1653,10 +1653,10 @@ export function createSidecarDeployRouter(deps: { * * Returns `"deferred-to-wake"` instead of restoring for a single-step * ("warm-keep") deployment (CL-6648): that shape is exactly what a - * folded run deploys, and folded runs already have a working lazy-wake - * port (`@corbits/agent-lifecycle`'s `ensureAwake` -> - * `@corbits/folded-runs`' `wakeFoldedRun` -> `deployAtHead`) that - * re-resolves inference sources fresh against the tenant's LIVE catalog + * chat launch deploys, and it already has a working lazy-wake port + * (`@corbits/agent-lifecycle`'s `ensureAwake` -> `@corbits/chat`'s + * `wakeByAddress` -> `prepareProvisionedDeployment`) that re-resolves + * inference sources fresh against the tenant's LIVE catalog * on every wake -- `record.sources` is only ever a snapshot of what * resolved at the deployment's last deploy or rotation. Restoring one * eagerly here would instead replay that frozen snapshot forever, diff --git a/apps/sidecar/test/workflow-restore-defer-to-wake.test.ts b/apps/sidecar/test/workflow-restore-defer-to-wake.test.ts index 60f9ba2fef..92d6036f88 100644 --- a/apps/sidecar/test/workflow-restore-defer-to-wake.test.ts +++ b/apps/sidecar/test/workflow-restore-defer-to-wake.test.ts @@ -3,9 +3,9 @@ // its last deploy or rotation. Restoring one eagerly from that snapshot // at boot would replay a chain whose credential died after the freeze // forever -- the deployment reads as "already live" to every later wake -// check, so the folded-run wake path (`ensureAwake` -> -// `wakeFoldedRun`/`deployAtHead`, which DOES re-resolve fresh against the -// live catalog on every call) never gets a chance to heal it. +// check, so the lazy-wake path (`ensureAwake` -> `@corbits/chat`'s +// `wakeByAddress`, which DOES re-resolve fresh against the live catalog +// on every call) never gets a chance to heal it. // // The fix: boot-time restore defers a single-step deployment to that // wake path instead of restoring it from frozen sources -- proven here by From fe39826ad60a922e9147a0f029dfdd776be49414 Mon Sep 17 00:00:00 2001 From: Sawyer Date: Sat, 5 Sep 2026 23:42:31 -0700 Subject: [PATCH 4/8] agent-directory: drop folded-run terminology from client filter docs purposeAgentInstances' excludeRunIds no longer has a real caller in this repo (apps/web now scopes server-side via @corbits/run-scope), and the README pointed at a deleted @corbits/chat-ui helper. Rewrote the comments, README, and test names around the actual excludeRunIds contract. --- packages/agent-directory/README.md | 13 +++++++------ packages/agent-directory/src/client.test.ts | 6 +++--- packages/agent-directory/src/client.ts | 6 +++--- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/packages/agent-directory/README.md b/packages/agent-directory/README.md index 42af79deb6..31f0ec27bb 100644 --- a/packages/agent-directory/README.md +++ b/packages/agent-directory/README.md @@ -77,12 +77,13 @@ just at different points in the request lifecycle. **A host injects:** its own definition and instance lists, already fetched from wherever it gets them (`apps/web/src/agents-api.ts`'s -`loadAgentDirectory`, for this repo), and the folded-run-id set for -`excludeRunIds` (from `@corbits/chat-ui`'s -`foldedRunIdsFromChannels`, for this repo) — this subpath issues no -request and holds no state of its own. Every function is generic over the host's -concrete row type (constrained to the minimal shape it reads), so a host's -richer types pass through untouched. +`loadAgentDirectory`, for this repo) — this subpath issues no request and +holds no state of its own. `excludeRunIds` is available for a host whose +instance listing isn't already scoped server-side; this repo's own host +gets that scoping for free from `listTopLevelRuns` (see +`@corbits/run-scope`) and so never passes it. Every function is generic +over the host's concrete row type (constrained to the minimal shape it +reads), so a host's richer types pass through untouched. **Depends on:** `@corbits/chat/workbench-host-naming` directly — a domain package's naming contract, not app state, so it is a package dependency diff --git a/packages/agent-directory/src/client.test.ts b/packages/agent-directory/src/client.test.ts index 7b8c192c66..edaef76df3 100644 --- a/packages/agent-directory/src/client.test.ts +++ b/packages/agent-directory/src/client.test.ts @@ -86,12 +86,12 @@ describe("purposeAgentInstances", () => { expect(result).toEqual([instance]); }); - test("with no folded-run-id set, leaves an ordinary top-level deployment alone", () => { + test("with no excludeRunIds set, leaves an ordinary top-level deployment alone", () => { const result = purposeAgentInstances([instance]); expect(result).toEqual([instance]); }); - test("drops an invited-agent chat run whose id is in the folded-run-id set, even under a real definitionId", () => { + test("drops an invited-agent chat run whose id is in excludeRunIds, even under a real definitionId", () => { const result = purposeAgentInstances( [instance, invitedAgentInstance], new Set([invitedAgentInstance.id]), @@ -99,7 +99,7 @@ describe("purposeAgentInstances", () => { expect(result).toEqual([instance]); }); - test("still drops a workbench host when a folded-run-id set is also given", () => { + test("still drops a workbench host when excludeRunIds is also given", () => { const result = purposeAgentInstances( [instance, workbenchHostInstance, invitedAgentInstance], new Set([invitedAgentInstance.id]), diff --git a/packages/agent-directory/src/client.ts b/packages/agent-directory/src/client.ts index 57bb620409..fa70971de9 100644 --- a/packages/agent-directory/src/client.ts +++ b/packages/agent-directory/src/client.ts @@ -53,7 +53,7 @@ export type UserFacingAgentInstance = { * sidebar's DM list; `automatable` (schedulable as a routine) is orthogonal * and never decides this. Definitions never need the run-id filter * `purposeAgentInstances` below takes: definition rows aren't run rows, so a - * folded run's own id can never match here — an invited agent's real + * chat-plumbing run's own id can never match here — an invited agent's real * `definitionId` stays a legitimate, reusable template even though its * *instance* is chat plumbing. */ export function purposeAgentDefinitions( @@ -67,11 +67,11 @@ export function purposeAgentDefinitions( } /** - * `excludeRunIds` additionally drops folded chat runs (invited agents): + * `excludeRunIds` additionally drops chat-plumbing runs (invited agents): * they self-anchor like a real deployment and launch under a real, * user-authored `definitionId` that `isWorkbenchHostDefinitionName` never * catches, so the host names them by id instead. Defaults to an empty - * set so callers without a folded-run source keep the name-only filter. + * set so callers without a run-id source keep the name-only filter. */ export function purposeAgentInstances( instances: readonly T[], From aff79eb7e670a4bbfdaa7ec844959c5143aa033e Mon Sep 17 00:00:00 2001 From: Sawyer Date: Sat, 5 Sep 2026 23:44:29 -0700 Subject: [PATCH 5/8] chat: point stale folded-runs function names at their real replacements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit schema.ts and test comments still named the deleted @corbits/folded-runs package (inferenceSourcesDigest, findFoldedRunByAddress, wakeFoldedRun, sendFoldedMailWithReclaimRetry) — none of which exist any more. Point them at the actual in-package names: offeringDigest, the real address→run resolution, wakeByAddress, sendRunMailWithReclaimRetry. --- packages/chat/src/schema.ts | 4 ++-- packages/chat/test/chat-orchestrator.test.ts | 10 +++++----- packages/chat/test/platform-adapter.test.ts | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/chat/src/schema.ts b/packages/chat/src/schema.ts index 3a42198ec9..7ee2b0ddad 100644 --- a/packages/chat/src/schema.ts +++ b/packages/chat/src/schema.ts @@ -119,8 +119,8 @@ export const workbenchLaunch = chatSchema.table("workbench_launch", { priorRunIds: jsonb("prior_run_ids").notNull().default([]), foldedBody: jsonb("folded_body").notNull(), /** - * `@corbits/folded-runs`' `inferenceSourcesDigest` of the chain the - * current run last deployed with — secret included, hashed. A send + * `@corbits/chat`'s `offeringDigest` of the chain the current run + * last deployed with — secret included, hashed. A send * compares it against today's resolution so a rotated API key * reaches a live agent (CL-6687); `null` until the run's first * deploy, and for rows that predate the column. diff --git a/packages/chat/test/chat-orchestrator.test.ts b/packages/chat/test/chat-orchestrator.test.ts index 41a7d74a9d..47cd824d4b 100644 --- a/packages/chat/test/chat-orchestrator.test.ts +++ b/packages/chat/test/chat-orchestrator.test.ts @@ -150,9 +150,9 @@ function launchRowFor(runId: string, tenantId: string) { }; } -// The real `findFoldedRunByAddress` (exercised, not mocked, so this -// file never risks poisoning `@corbits/folded-runs`'s module namespace -// for `platform-adapter.test.ts` when the whole package's suite runs +// The real address→run resolution (exercised, not mocked, so this +// file never risks poisoning `@corbits/chat`'s module namespace for +// `platform-adapter.test.ts` when the whole package's suite runs // in one process) calls `db.query.workflowRun.findFirst({ where: // eq(workflowRun.address, address) })`. Every scenario here configures // at most one run, so this fake ignores the `where` filter and simply @@ -1237,8 +1237,8 @@ describe("createChatOrchestrator", () => { // stores, so every assertion below proves the posted row AND its // membership land in the source message's thread. // - // `findFoldedRunByAddress` is exercised for real (see this file's - // header comment), so the two-address fake answers by call order + // The real address→run resolution is exercised for real (see this + // file's header comment), so the two-address fake answers by call order // rather than inspecting the drizzle `where` expression: the tests // below await a macrotask between emissions, so resolutions happen in // emission order. diff --git a/packages/chat/test/platform-adapter.test.ts b/packages/chat/test/platform-adapter.test.ts index eeae01df5b..29281d3308 100644 --- a/packages/chat/test/platform-adapter.test.ts +++ b/packages/chat/test/platform-adapter.test.ts @@ -2525,12 +2525,12 @@ describe("createHubChatPlatform", () => { }); }); - // CL-7214: `sendFoldedMailWithReclaimRetry`'s reclaim-retry loop used + // CL-7214: `sendRunMailWithReclaimRetry`'s reclaim-retry loop used // to call `wakeByAddress` directly, bypassing `lifecycle.ensureAwake`'s // per-address coalescing entirely. Proves that a reclaim-retry wake and // an independent, concurrent `ensureAwake` call for the same address // now coalesce onto the same in-flight wake — never dispatching a - // second, concurrent `wakeFoldedRun` that would race the first on the + // second, concurrent `wakeByAddress` that would race the first on the // same `session_asset` primary key and git ref. describe("wakeByAddressBounded reclaim-retry coalescing", () => { test("a reclaim-retry wake and a concurrent ensureAwake call for the same address never redeploy it twice", async () => { @@ -2655,7 +2655,7 @@ describe("createHubChatPlatform", () => { }); // Proves the actual lever an edited system prompt reaches a running - // instance through: `wakeFoldedRun` (exercised via `sendMail`'s + // instance through: `wakeByAddress` (exercised via `sendMail`'s // wake-on-send path above) replays `workbench_launch.foldedBody` // verbatim and never reads the definition's asset itself, so a // definition edit only reaches a running instance if something From f73006de603be9beee3770d58c51e98cb7d284eb Mon Sep 17 00:00:00 2001 From: Sawyer Date: Sat, 5 Sep 2026 23:45:10 -0700 Subject: [PATCH 6/8] run-key-history: drop reference to a nonexistent folded-runs lookup reconnect.ts claimed the hub wires this alongside @corbits/folded-runs' lookupFoldedRunReconnectKey, which no longer exists anywhere. Also pointed the drizzle test's scope-routes cross-reference at @corbits/run-scope. --- packages/run-key-history/src/reconnect.ts | 5 ++--- packages/run-key-history/test/reconnect.drizzle.test.ts | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/run-key-history/src/reconnect.ts b/packages/run-key-history/src/reconnect.ts index 5c1b973302..5755e28b54 100644 --- a/packages/run-key-history/src/reconnect.ts +++ b/packages/run-key-history/src/reconnect.ts @@ -50,9 +50,8 @@ import { liveWorkflowRunStatuses, workflowRun } from "@intx/db/schema"; import type { RunKeyHistoryStore } from "./store"; /** - * The hub app wires this AFTER the platform's own `lookupPublicKey`, - * alongside `@corbits/folded-runs`' `lookupFoldedRunReconnectKey`: the - * platform's answer stands whenever it has one, and this repair is + * The hub app wires this AFTER the platform's own `lookupPublicKey`: + * the platform's answer stands whenever it has one, and this repair is * reached only for a live run whose `workflow_run` key the platform * could not supply or which disagrees with the last observed ack. * diff --git a/packages/run-key-history/test/reconnect.drizzle.test.ts b/packages/run-key-history/test/reconnect.drizzle.test.ts index 7fe860ee9d..093941efbe 100644 --- a/packages/run-key-history/test/reconnect.drizzle.test.ts +++ b/packages/run-key-history/test/reconnect.drizzle.test.ts @@ -1,5 +1,5 @@ // DB-gated: skipped when no DATABASE_URL is reachable, mirroring -// `@corbits/folded-runs`'s `scope-routes.drizzle.test.ts`. Runs the +// `@corbits/run-scope`'s `scope-routes.drizzle.test.ts`. Runs the // real platform schema (`@intx/db`'s `runMigrations`) alongside this // package's own `applyRunKeyHistoryMigrations`, so the reconnect // repair is proven against a real `workflow_run` row and a real From 8206619dfdf3b74b532a5d705e1e5e59dac18739 Mon Sep 17 00:00:00 2001 From: Sawyer Date: Sat, 5 Sep 2026 23:48:00 -0700 Subject: [PATCH 7/8] misc: point remaining stale folded-runs cross-references at real owners describe.ts, credential-error.ts, the seeding launchability test, collections' README, and the code-review/last-30-days-research workflow comments still named the deleted @corbits/folded-runs package or its files. Pointed each at where the described behavior actually lives now (@corbits/chat, @corbits/workflows, or vendor/intx/hub-sessions). --- packages/collections/README.md | 2 +- packages/connections/src/credential-error.ts | 5 +++-- packages/seeding/test/routine-launchability.test.ts | 2 +- packages/tool-registry-publish/src/describe.ts | 4 ++-- workflows/code-review/src/index.ts | 4 ++-- workflows/last-30-days-research/src/index.ts | 7 ++++--- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/packages/collections/README.md b/packages/collections/README.md index c4f5bae716..9159ea2699 100644 --- a/packages/collections/README.md +++ b/packages/collections/README.md @@ -21,7 +21,7 @@ lastSeenByUser.get(userId); // undefined once ttlMs has elapsed This is the first primitive in the package. `apps/hub/src/launch-caches.ts`'s `BoundedCache` (size-capped LRU, no TTL) is a sibling that predates this -package. `@corbits/folded-runs`' `createCryptoProviderCache` now consumes +package. `@corbits/chat`'s `createCryptoProviderCache` now consumes `createExpiringMap` directly (CL-7223); CL-7229 is expected to either do the same or contribute the size-capped-LRU shape here so `BoundedCache` can retire in favor of one place for this problem. diff --git a/packages/connections/src/credential-error.ts b/packages/connections/src/credential-error.ts index c0d3a8a40d..a3d4451b96 100644 --- a/packages/connections/src/credential-error.ts +++ b/packages/connections/src/credential-error.ts @@ -1,8 +1,9 @@ // The one typed signal for "this connector's credential is missing" — // the pop-up that lets someone connect it can't target the right // connector unless that identity survives past the failure. Today it -// doesn't: `packages/folded-runs/src/launch.ts` discards -// `buildCredentialDelivery`'s own `reason.binding.provider` into a +// doesn't: `vendor/intx/hub-sessions/src/session-service.ts`'s +// `deployCodeSourcedWorkflow` discards `buildCredentialDelivery`'s own +// `reason.binding.provider` into a // generic `Error` string, and every tool package bakes its own // hardcoded "not connected" prose instead of naming the connector // structurally. This class is the shared, identifiable shape a thrower diff --git a/packages/seeding/test/routine-launchability.test.ts b/packages/seeding/test/routine-launchability.test.ts index 427fa0b001..4f63bbe0c9 100644 --- a/packages/seeding/test/routine-launchability.test.ts +++ b/packages/seeding/test/routine-launchability.test.ts @@ -1,5 +1,5 @@ // CL-6495 found that every routine "run now" (and every scheduled -// fire) launched through `@corbits/folded-runs`' `readFoldedBody` (via +// fire) launched through `@corbits/workflows`' `readFoldedBody` (via // `apps/hub/src/routine-launcher.ts`), which has always required // exactly one step — a multi-step `DEFAULT_WORKFLOWS` entry threw // synchronously, uncaught, turning into a bare 500 on the very first diff --git a/packages/tool-registry-publish/src/describe.ts b/packages/tool-registry-publish/src/describe.ts index bd6ec3dd76..1a51f78ec8 100644 --- a/packages/tool-registry-publish/src/describe.ts +++ b/packages/tool-registry-publish/src/describe.ts @@ -1,9 +1,9 @@ // Static description of every published `@corbits/*-tools` package's // tool surface, read by importing each package's own `src/index.ts` // module (the pre-bundle source, not the packed tarball). The hub's -// folded-run launch composition (`apps/hub/src/index.ts`) uses this to +// chat launch composition (`apps/hub/src/index.ts`) uses this to // derive the `tool:` grants a launch's pinned packages -// need — see `@corbits/folded-runs`'s `ToolGrantsForPins` for why those +// need — see `@corbits/chat`'s `ToolGrantsForPins` for why those // grants have to be minted at deploy time rather than left to the // deploy-time capability walk, which only covers inline tool factories. import { readFile } from "node:fs/promises"; diff --git a/workflows/code-review/src/index.ts b/workflows/code-review/src/index.ts index 1399bda42c..9e133b672e 100644 --- a/workflows/code-review/src/index.ts +++ b/workflows/code-review/src/index.ts @@ -5,8 +5,8 @@ // One step, one agent — the shape every definition in this catalog // commits to, and the shape the webhook ingress can launch today // (`@corbits/webhook-triggers` launches a folded, single-step definition -// through `@corbits/folded-runs`). A GitHub `pull_request` webhook -// registered against this definition renders its input template into the +// through `@corbits/workflows`' `readFoldedBody`). A GitHub `pull_request` +// webhook registered against this definition renders its input template into the // run's first message, so the trigger is a real PR event, not a poll. // // The three reviewer lenses are not restated here: their prompts come diff --git a/workflows/last-30-days-research/src/index.ts b/workflows/last-30-days-research/src/index.ts index e10b2db64b..6c28916c89 100644 --- a/workflows/last-30-days-research/src/index.ts +++ b/workflows/last-30-days-research/src/index.ts @@ -21,9 +21,10 @@ // shipped the OG's six stages as six chained `@intx/workflow` steps // (`after: [...]`) — the first genuinely multi-step definition in this // catalog. Every routine "run now"/scheduled fire in this repo launches -// through `@corbits/folded-runs`' `readFoldedBody` -// (`apps/hub/src/routine-launcher.ts`), and that reader has always -// required exactly one step (`packages/folded-runs/src/definition.ts`): +// through `@corbits/workflows`' `readFoldedBody` +// (`apps/hub/src/native-workflow-routine-launch.ts`), and that reader has +// always required exactly one step +// (`packages/workflows/src/definition-projection.ts`): // it throws `"definition ... is not single-step (N steps)"` synchronously, // before any run row or sidecar deploy exists, which Hono turns into a // bare 500 on every single launch. There is no second, native multi-step From cf85b5b222a45292285c784728afd18d235eb68f Mon Sep 17 00:00:00 2001 From: Sawyer Date: Sat, 5 Sep 2026 23:50:00 -0700 Subject: [PATCH 8/8] db-setup: drop the dead folded_runs schema from the reset allowlist No package creates a folded_runs Postgres schema any more (the package was deleted); also renamed the run-scope drizzle test's isolation schema names off the same dead term. --- packages/run-scope/test/scope-routes.drizzle.test.ts | 4 ++-- scripts/db-setup.ts | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/run-scope/test/scope-routes.drizzle.test.ts b/packages/run-scope/test/scope-routes.drizzle.test.ts index 1d68eed74f..a63a328882 100644 --- a/packages/run-scope/test/scope-routes.drizzle.test.ts +++ b/packages/run-scope/test/scope-routes.drizzle.test.ts @@ -15,7 +15,7 @@ import { dbGate } from "../../../scripts/e2e/db-gate"; const databaseUrl = e2eDatabaseUrl(); const describeIfDb = dbGate(databaseUrl, import.meta.path); -const SCHEMA = "folded_runs_scope_routes_test"; +const SCHEMA = "run_scope_scope_routes_test"; const TENANT = "tnt_scope_routes"; describeIfDb("listTopLevelRuns", () => { @@ -145,7 +145,7 @@ describeIfDb("listTopLevelRuns", () => { }); }); -const FIRES_SCHEMA = "folded_runs_scope_routes_fires_test"; +const FIRES_SCHEMA = "run_scope_scope_routes_fires_test"; const FIRES_TENANT = "tnt_scope_routes_fires"; describeIfDb("listTopLevelRunFires", () => { diff --git a/scripts/db-setup.ts b/scripts/db-setup.ts index 8875aa3c82..8570f48fb4 100644 --- a/scripts/db-setup.ts +++ b/scripts/db-setup.ts @@ -584,7 +584,6 @@ export async function setupDatabase( // package's tables, not only the platform's. const PACKAGE_SCHEMAS = [ "mailbox", - "folded_runs", "chat", "routines", "insights",