Skip to content

Commit d52352d

Browse files
Merge pull request #185 from corbitsdev/cl-6458-seed-convergence
CL-6458: seed the template library on first read, not at boot behind an operator bench
2 parents 580af22 + 8028f47 commit d52352d

12 files changed

Lines changed: 440 additions & 323 deletions

File tree

‎apps/hub/src/index.ts‎

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ import {
257257
createArtifactRoutes,
258258
createTemplateLibraryDbStore,
259259
createTemplateLibraryRoutes,
260+
createTemplateLibrarySeeder,
260261
createUnavailableArtifactRoutes,
261262
createUnavailableTemplateLibraryRoutes,
262263
createUnavailableWorkflowArtifactRoutes,
@@ -333,7 +334,6 @@ import {
333334
} from "./config";
334335
import type { SidecarProvisioner } from "@intx/hub-sessions";
335336
import { scheduleEnvProviderCredentialPlant } from "./env-credential-plant";
336-
import { scheduleTemplateLibrarySeed } from "./template-library-seed";
337337
import { createHubRoutineLauncher } from "./routine-launcher";
338338
import { withTurnPartWriteDefaults } from "./turn-part-content-default";
339339
import { createHubRunSummaryResolver } from "./routine-run-summary";
@@ -3307,15 +3307,23 @@ export async function createHub(config: HubConfig) {
33073307

33083308
// The bench library's template shelf (CL-6344): what the
33093309
// new-workbench picker instantiates from — seeded rows, never a
3310-
// hardcoded import.
3310+
// hardcoded import. Reading the shelf is what seeds it (CL-6458), so
3311+
// a bench created at any point after boot carries the shipped
3312+
// manifests the first time its picker opens.
33113313
app.route(
33123314
`${TENANT_PREFIX}/library/templates`,
33133315
createTemplateLibraryRoutes({
33143316
store: createTemplateLibraryDbStore(artifactsHandle.db),
3317+
seeder: createTemplateLibrarySeeder({
3318+
db: artifactsHandle.db,
3319+
entries: workbenchTemplateLibraryEntries(),
3320+
log: (line) => log.info`${line}`,
3321+
}),
33153322
requireGrant: createRequireGrant({
33163323
grantStore: chatGrantStore,
33173324
conditionRegistry: chatConditionRegistry,
33183325
}),
3326+
log: (line) => log.error`${line}`,
33193327
}),
33203328
);
33213329

@@ -3456,23 +3464,6 @@ export async function createHub(config: HubConfig) {
34563464
fetch: (request) => Promise.resolve(guardedApp.fetch(request)),
34573465
});
34583466

3459-
// Bench-library template seed (CL-6344): the hub, as system, plants
3460-
// the shipped workbench template manifests and their tool tarballs
3461-
// into the operator bench's library at boot — idempotently, so a
3462-
// second boot leaves exactly one entry per template. Skipped in
3463-
// degraded (no-artifacts) mode: with no library to seed into there is
3464-
// nothing honest to do. See ./template-library-seed.ts.
3465-
const templateLibrarySeed =
3466-
artifactsHandle !== undefined
3467-
? scheduleTemplateLibrarySeed({
3468-
baseUrl: config.baseUrl,
3469-
admin: config.envCredentialPlantAdmin,
3470-
fetch: (request) => Promise.resolve(guardedApp.fetch(request)),
3471-
artifactsDb: artifactsHandle.db,
3472-
entries: workbenchTemplateLibraryEntries(),
3473-
})
3474-
: { stop: (): void => {} };
3475-
34763467
return {
34773468
app: guardedApp,
34783469
db,
@@ -3482,7 +3473,6 @@ export async function createHub(config: HubConfig) {
34823473
clearTimeout(sidecarAllocationReconciliationTimer);
34833474
}
34843475
envCredentialPlant.stop();
3485-
templateLibrarySeed.stop();
34863476
chatOrchestrator.dispose();
34873477
taskOrchestrator.dispose();
34883478
taskLifecycle.stop();

‎apps/hub/src/template-library-seed.ts‎

Lines changed: 0 additions & 212 deletions
This file was deleted.

‎apps/web/src/instant-agent-create.ts‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,19 +106,21 @@ export async function createWorkbenchFromTemplate(
106106
if (setupTemplate === undefined) {
107107
throw new Error("No default setup agent found for this workbench.");
108108
}
109-
// The manifest comes from the bench library the hub seeded at boot
110-
// (CL-6344), never from a hardcoded catalog import. `blank` is the one
111-
// id with no manifest by design; any other id resolving to nothing
112-
// means this bench's boot seed hasn't run — fail loud rather than
113-
// mint a workbench missing its agents.
109+
// The manifest comes from the bench library (CL-6344), never from a
110+
// hardcoded catalog import; reading it is what seeds the shelf
111+
// (CL-6458). `blank` is the one id with no manifest by design; any
112+
// other id resolving to nothing means this build ships no such
113+
// template — fail loud rather than mint a workbench missing its
114+
// agents. The picker only offers ids the library listed, so this is
115+
// the race-loser's message, not the everyday path.
114116
const manifest =
115117
templateId === "blank"
116118
? undefined
117119
: ((await fetchWorkbenchTemplateManifest(tenantId, templateId)) ??
118120
undefined);
119121
if (templateId !== "blank" && manifest === undefined) {
120122
throw new Error(
121-
`The "${templateId}" template isn't in this bench's library yet — its boot seed hasn't run.`,
123+
`This bench can't set up a ${templateId} workbench yet — it isn't in the library.`,
122124
);
123125
}
124126
const requiresGithub =

0 commit comments

Comments
 (0)