@cat-factory/node-server 0.145.0 → 0.146.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/container-content-library-deps.d.ts +14 -0
- package/dist/container-content-library-deps.d.ts.map +1 -1
- package/dist/container-content-library-deps.js +23 -0
- package/dist/container-content-library-deps.js.map +1 -1
- package/dist/container-core-deps.d.ts.map +1 -1
- package/dist/container-core-deps.js +4 -1
- package/dist/container-core-deps.js.map +1 -1
- package/dist/container-run-platform.d.ts +81 -0
- package/dist/container-run-platform.d.ts.map +1 -0
- package/dist/container-run-platform.js +227 -0
- package/dist/container-run-platform.js.map +1 -0
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +15 -208
- package/dist/container.js.map +1 -1
- package/dist/db/schema.d.ts +1 -0
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/db/schema.js +2 -0
- package/dist/db/schema.js.map +1 -1
- package/dist/db/tables/foundational-services.d.ts +652 -0
- package/dist/db/tables/foundational-services.d.ts.map +1 -0
- package/dist/db/tables/foundational-services.js +92 -0
- package/dist/db/tables/foundational-services.js.map +1 -0
- package/dist/foundationalServices.d.ts +8 -0
- package/dist/foundationalServices.d.ts.map +1 -0
- package/dist/foundationalServices.js +32 -0
- package/dist/foundationalServices.js.map +1 -0
- package/dist/repositories/foundationalServices.d.ts +32 -0
- package/dist/repositories/foundationalServices.d.ts.map +1 -0
- package/dist/repositories/foundationalServices.js +334 -0
- package/dist/repositories/foundationalServices.js.map +1 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +8 -1
- package/dist/server.js.map +1 -1
- package/drizzle/20260731183716_foundational_services/migration.sql +59 -0
- package/drizzle/20260731183716_foundational_services/snapshot.json +18917 -0
- package/package.json +20 -20
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { sql } from 'drizzle-orm';
|
|
2
|
+
import { bigint, index, integer, pgTable, primaryKey, text, uniqueIndex } from 'drizzle-orm/pg-core';
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
// The FOUNDATIONAL SERVICES tables, mirroring the Cloudflare D1 tables column-for-column
|
|
5
|
+
// (snake_case field names = column names) exactly as the rest of the Node schema does.
|
|
6
|
+
//
|
|
7
|
+
// One cohesive group — the tiered catalog of shared capabilities an Architect designs against
|
|
8
|
+
// (`foundational_services`), the API contract DOCUMENTS its consumers lazily read
|
|
9
|
+
// (`api_contracts`), and the repo links a sync keeps them fresh from
|
|
10
|
+
// (`foundational_service_sources`). Split out of `../schema.ts` so that module stays within its
|
|
11
|
+
// file-size budget; see docs/initiatives/foundational-services.md.
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
// Foundational services (docs/initiatives/foundational-services.md; mirror of D1 migration 0073).
|
|
14
|
+
// A tiered catalog of shared capabilities an Architect designs against, owner-scoped by an
|
|
15
|
+
// (owner_kind, owner_id) pair exactly like the prompt-fragment library. Identity and DOCUMENTS
|
|
16
|
+
// are separate tables on purpose: the catalog read runs on every design dispatch and must never
|
|
17
|
+
// load a contract body, while only the consumer steps — for only the services the design
|
|
18
|
+
// declared — read `api_contracts.body`.
|
|
19
|
+
export const foundationalServices = pgTable('foundational_services', {
|
|
20
|
+
service_id: text('service_id').notNull(),
|
|
21
|
+
owner_kind: text('owner_kind').notNull(),
|
|
22
|
+
owner_id: text('owner_id').notNull(),
|
|
23
|
+
name: text('name').notNull(),
|
|
24
|
+
summary: text('summary').notNull(),
|
|
25
|
+
description: text('description').notNull().default(''),
|
|
26
|
+
// JSON string[] of capability tags.
|
|
27
|
+
capabilities: text('capabilities').notNull().default('[]'),
|
|
28
|
+
source_id: text('source_id'),
|
|
29
|
+
source_path: text('source_path'),
|
|
30
|
+
pinned_commit: text('pinned_commit'),
|
|
31
|
+
created_at: bigint('created_at', { mode: 'number' }).notNull(),
|
|
32
|
+
updated_at: bigint('updated_at', { mode: 'number' }).notNull(),
|
|
33
|
+
deleted_at: bigint('deleted_at', { mode: 'number' }),
|
|
34
|
+
}, (t) => [
|
|
35
|
+
primaryKey({ columns: [t.owner_kind, t.owner_id, t.service_id] }),
|
|
36
|
+
index('idx_foundational_services_owner')
|
|
37
|
+
.on(t.owner_kind, t.owner_id)
|
|
38
|
+
.where(sql `${t.deleted_at} IS NULL`),
|
|
39
|
+
index('idx_foundational_services_source')
|
|
40
|
+
.on(t.source_id)
|
|
41
|
+
.where(sql `${t.deleted_at} IS NULL`),
|
|
42
|
+
]);
|
|
43
|
+
export const apiContracts = pgTable('api_contracts', {
|
|
44
|
+
owner_kind: text('owner_kind').notNull(),
|
|
45
|
+
owner_id: text('owner_id').notNull(),
|
|
46
|
+
service_id: text('service_id').notNull(),
|
|
47
|
+
contract_id: text('contract_id').notNull(),
|
|
48
|
+
format: text('format').notNull(),
|
|
49
|
+
title: text('title').notNull(),
|
|
50
|
+
// The document verbatim. Never selected by the catalog read (see the table note).
|
|
51
|
+
body: text('body').notNull(),
|
|
52
|
+
// Operations indexed ONCE at write time; JSON string[], empty for the TypeScript formats.
|
|
53
|
+
operations: text('operations').notNull().default('[]'),
|
|
54
|
+
omitted_operations: integer('omitted_operations').notNull().default(0),
|
|
55
|
+
source_path: text('source_path'),
|
|
56
|
+
source_sha: text('source_sha'),
|
|
57
|
+
created_at: bigint('created_at', { mode: 'number' }).notNull(),
|
|
58
|
+
updated_at: bigint('updated_at', { mode: 'number' }).notNull(),
|
|
59
|
+
}, (t) => [
|
|
60
|
+
primaryKey({ columns: [t.owner_kind, t.owner_id, t.service_id, t.contract_id] }),
|
|
61
|
+
index('idx_api_contracts_owner').on(t.owner_kind, t.owner_id, t.service_id),
|
|
62
|
+
]);
|
|
63
|
+
export const foundationalServiceSources = pgTable('foundational_service_sources', {
|
|
64
|
+
id: text('id').primaryKey(),
|
|
65
|
+
owner_kind: text('owner_kind').notNull(),
|
|
66
|
+
owner_id: text('owner_id').notNull(),
|
|
67
|
+
repo_owner: text('repo_owner').notNull(),
|
|
68
|
+
repo_name: text('repo_name').notNull(),
|
|
69
|
+
git_ref: text('git_ref').notNull().default('HEAD'),
|
|
70
|
+
// 'directory' scans <dir_path>/<service>/; 'files' reads an explicit path list for ONE service.
|
|
71
|
+
mode: text('mode').notNull().default('directory'),
|
|
72
|
+
dir_path: text('dir_path').notNull().default(''),
|
|
73
|
+
// JSON string[]; 'files' mode only.
|
|
74
|
+
file_paths: text('file_paths').notNull().default('[]'),
|
|
75
|
+
service_id: text('service_id'),
|
|
76
|
+
service_name: text('service_name'),
|
|
77
|
+
service_summary: text('service_summary'),
|
|
78
|
+
last_synced_commit: text('last_synced_commit'),
|
|
79
|
+
last_synced_at: bigint('last_synced_at', { mode: 'number' }),
|
|
80
|
+
created_at: bigint('created_at', { mode: 'number' }).notNull(),
|
|
81
|
+
deleted_at: bigint('deleted_at', { mode: 'number' }),
|
|
82
|
+
}, (t) => [
|
|
83
|
+
uniqueIndex('idx_foundational_sources_unique').on(t.owner_kind, t.owner_id, t.repo_owner, t.repo_name, t.git_ref, t.dir_path),
|
|
84
|
+
index('idx_foundational_sources_owner')
|
|
85
|
+
.on(t.owner_kind, t.owner_id)
|
|
86
|
+
.where(sql `${t.deleted_at} IS NULL`),
|
|
87
|
+
// The autorefresh sweep drains the oldest-synced live sources in bounded batches.
|
|
88
|
+
index('idx_foundational_sources_stale')
|
|
89
|
+
.on(t.last_synced_at)
|
|
90
|
+
.where(sql `${t.deleted_at} IS NULL`),
|
|
91
|
+
]);
|
|
92
|
+
//# sourceMappingURL=foundational-services.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"foundational-services.js","sourceRoot":"","sources":["../../../src/db/tables/foundational-services.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAEpG,8EAA8E;AAC9E,yFAAyF;AACzF,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AE,CAAC,OAAO,CAAC,IAAI,CAAC;IACtD,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC;IAC9B,YAAY,EAAE,IAAI,CAAC,cAAc,CAAC;IAClC,eAAe,EAAE,IAAI,CAAC,iBAAiB,CAAC;IACxC,kBAAkB,EAAE,IAAI,CAAC,oBAAoB,CAAC;IAC9C,cAAc,EAAE,MAAM,CAAC,gBAAgB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IAC5D,UAAU,EAAE,MAAM,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE;IAC9D,UAAU,EAAE,MAAM,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;CACrD,EACD,CAAC,CAAC,EAAE,EAAE,CAAC;IACL,WAAW,CAAC,iCAAiC,CAAC,CAAC,EAAE,CAC/C,CAAC,CAAC,UAAU,EACZ,CAAC,CAAC,QAAQ,EACV,CAAC,CAAC,UAAU,EACZ,CAAC,CAAC,SAAS,EACX,CAAC,CAAC,OAAO,EACT,CAAC,CAAC,QAAQ,CACX;IACD,KAAK,CAAC,gCAAgC,CAAC;SACpC,EAAE,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC;SAC5B,KAAK,CAAC,GAAG,CAAA,GAAG,CAAC,CAAC,UAAU,UAAU,CAAC;IACtC,kFAAkF;IAClF,KAAK,CAAC,gCAAgC,CAAC;SACpC,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC;SACpB,KAAK,CAAC,GAAG,CAAA,GAAG,CAAC,CAAC,UAAU,UAAU,CAAC;CACvC,CACF,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Logger, type ServerContainer } from '@cat-factory/server';
|
|
2
|
+
/**
|
|
3
|
+
* Start the periodic foundational-source refresh. Runs once immediately then on the interval,
|
|
4
|
+
* non-overlapping + best-effort (see {@link startSweeper}). A no-op when the catalog is not
|
|
5
|
+
* configured, or is configured without the GitHub integration a repo source needs.
|
|
6
|
+
*/
|
|
7
|
+
export declare function startFoundationalSourceSweeper(container: ServerContainer, log: Logger): () => void;
|
|
8
|
+
//# sourceMappingURL=foundationalServices.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"foundationalServices.d.ts","sourceRoot":"","sources":["../src/foundationalServices.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,MAAM,EACX,KAAK,eAAe,EACrB,MAAM,qBAAqB,CAAA;AAgB5B;;;;GAIG;AACH,wBAAgB,8BAA8B,CAC5C,SAAS,EAAE,eAAe,EAC1B,GAAG,EAAE,MAAM,GACV,MAAM,IAAI,CAWZ"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { FOUNDATIONAL_SOURCE_STALE_MS, sweepFoundationalSources, } from '@cat-factory/server';
|
|
2
|
+
import { startSweeper } from './sweeper.js';
|
|
3
|
+
// Periodic AUTOREFRESH of repo-linked foundational-service sources for the Node facade — the
|
|
4
|
+
// analogue of the Worker's cron-driven pass. Both run the SAME `sweepFoundationalSources` from
|
|
5
|
+
// the shared server layer (which owns the staleness window and the batch bound); only the
|
|
6
|
+
// trigger differs, because the Node service has no cron.
|
|
7
|
+
/**
|
|
8
|
+
* How often the sweep runs. Matched to the staleness window itself rather than set shorter: a
|
|
9
|
+
* source cannot go stale more often than the window, so a tighter cadence would only re-issue
|
|
10
|
+
* the same head-commit probes. The Worker gates its 2-minute cron down to the same effective
|
|
11
|
+
* cadence for the same reason.
|
|
12
|
+
*/
|
|
13
|
+
const FOUNDATIONAL_SWEEP_INTERVAL_MS = FOUNDATIONAL_SOURCE_STALE_MS;
|
|
14
|
+
/**
|
|
15
|
+
* Start the periodic foundational-source refresh. Runs once immediately then on the interval,
|
|
16
|
+
* non-overlapping + best-effort (see {@link startSweeper}). A no-op when the catalog is not
|
|
17
|
+
* configured, or is configured without the GitHub integration a repo source needs.
|
|
18
|
+
*/
|
|
19
|
+
export function startFoundationalSourceSweeper(container, log) {
|
|
20
|
+
if (!container.foundationalServices?.sourceService)
|
|
21
|
+
return () => { };
|
|
22
|
+
return startSweeper({
|
|
23
|
+
name: 'foundational-sources',
|
|
24
|
+
intervalMs: FOUNDATIONAL_SWEEP_INTERVAL_MS,
|
|
25
|
+
log,
|
|
26
|
+
failureMessage: 'foundational-source sweep failed',
|
|
27
|
+
tick: async () => {
|
|
28
|
+
await sweepFoundationalSources(container.foundationalServices, log);
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=foundationalServices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"foundationalServices.js","sourceRoot":"","sources":["../src/foundationalServices.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,wBAAwB,GAGzB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE3C,6FAA6F;AAC7F,+FAA+F;AAC/F,0FAA0F;AAC1F,yDAAyD;AAEzD;;;;;GAKG;AACH,MAAM,8BAA8B,GAAG,4BAA4B,CAAA;AAEnE;;;;GAIG;AACH,MAAM,UAAU,8BAA8B,CAC5C,SAA0B,EAC1B,GAAW;IAEX,IAAI,CAAC,SAAS,CAAC,oBAAoB,EAAE,aAAa;QAAE,OAAO,GAAG,EAAE,GAAE,CAAC,CAAA;IACnE,OAAO,YAAY,CAAC;QAClB,IAAI,EAAE,sBAAsB;QAC5B,UAAU,EAAE,8BAA8B;QAC1C,GAAG;QACH,cAAc,EAAE,kCAAkC;QAClD,IAAI,EAAE,KAAK,IAAI,EAAE;YACf,MAAM,wBAAwB,CAAC,SAAS,CAAC,oBAAoB,EAAE,GAAG,CAAC,CAAA;QACrE,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { FoundationalServiceOwnerKind } from '@cat-factory/contracts';
|
|
2
|
+
import type { ApiContractManifestEntry, ApiContractRecord, ApiContractRepository, FoundationalServiceRecord, FoundationalServiceRepository, FoundationalServiceSourceRecord, FoundationalServiceSourceRepository } from '@cat-factory/kernel';
|
|
3
|
+
import type { DrizzleDb } from '../db/client.js';
|
|
4
|
+
export declare class DrizzleFoundationalServiceRepository implements FoundationalServiceRepository {
|
|
5
|
+
private readonly db;
|
|
6
|
+
constructor(db: DrizzleDb);
|
|
7
|
+
listByOwner(ownerKind: FoundationalServiceOwnerKind, ownerId: string, includeDeleted?: boolean): Promise<FoundationalServiceRecord[]>;
|
|
8
|
+
get(ownerKind: FoundationalServiceOwnerKind, ownerId: string, serviceId: string): Promise<FoundationalServiceRecord | null>;
|
|
9
|
+
upsert(record: FoundationalServiceRecord): Promise<void>;
|
|
10
|
+
softDelete(ownerKind: FoundationalServiceOwnerKind, ownerId: string, serviceId: string, at: number): Promise<void>;
|
|
11
|
+
listBySource(sourceId: string): Promise<FoundationalServiceRecord[]>;
|
|
12
|
+
softDeleteBySource(sourceId: string, at: number): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
export declare class DrizzleApiContractRepository implements ApiContractRepository {
|
|
15
|
+
private readonly db;
|
|
16
|
+
constructor(db: DrizzleDb);
|
|
17
|
+
listManifestByOwner(ownerKind: FoundationalServiceOwnerKind, ownerId: string): Promise<ApiContractManifestEntry[]>;
|
|
18
|
+
listByServiceIds(ownerKind: FoundationalServiceOwnerKind, ownerId: string, serviceIds: string[]): Promise<ApiContractRecord[]>;
|
|
19
|
+
replaceForService(ownerKind: FoundationalServiceOwnerKind, ownerId: string, serviceId: string, contracts: ApiContractRecord[]): Promise<void>;
|
|
20
|
+
deleteForService(ownerKind: FoundationalServiceOwnerKind, ownerId: string, serviceId: string): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
export declare class DrizzleFoundationalServiceSourceRepository implements FoundationalServiceSourceRepository {
|
|
23
|
+
private readonly db;
|
|
24
|
+
constructor(db: DrizzleDb);
|
|
25
|
+
listByOwner(ownerKind: FoundationalServiceOwnerKind, ownerId: string): Promise<FoundationalServiceSourceRecord[]>;
|
|
26
|
+
get(id: string): Promise<FoundationalServiceSourceRecord | null>;
|
|
27
|
+
upsert(record: FoundationalServiceSourceRecord): Promise<void>;
|
|
28
|
+
updateSyncState(id: string, lastSyncedCommit: string | null, lastSyncedAt: number): Promise<void>;
|
|
29
|
+
softDelete(id: string, at: number): Promise<void>;
|
|
30
|
+
listStale(staleBefore: number, limit: number): Promise<FoundationalServiceSourceRecord[]>;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=foundationalServices.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"foundationalServices.d.ts","sourceRoot":"","sources":["../../src/repositories/foundationalServices.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,4BAA4B,EAE7B,MAAM,wBAAwB,CAAA;AAC/B,OAAO,KAAK,EACV,wBAAwB,EACxB,iBAAiB,EACjB,qBAAqB,EACrB,yBAAyB,EACzB,6BAA6B,EAC7B,+BAA+B,EAC/B,mCAAmC,EACpC,MAAM,qBAAqB,CAAA;AAE5B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAqDhD,qBAAa,oCAAqC,YAAW,6BAA6B;IAC5E,OAAO,CAAC,QAAQ,CAAC,EAAE;IAA/B,YAA6B,EAAE,EAAE,SAAS,EAAI;IAExC,WAAW,CACf,SAAS,EAAE,4BAA4B,EACvC,OAAO,EAAE,MAAM,EACf,cAAc,UAAQ,GACrB,OAAO,CAAC,yBAAyB,EAAE,CAAC,CAWtC;IAEK,GAAG,CACP,SAAS,EAAE,4BAA4B,EACvC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,yBAAyB,GAAG,IAAI,CAAC,CAa3C;IAEK,MAAM,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,CAqC7D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E,MAAM,GAAG,OAAO,CAAC,+BAA+B,GAAG,IAAI,CAAC,CAOrE;IAEK,MAAM,CAAC,MAAM,EAAE,+BAA+B,GAAG,OAAO,CAAC,IAAI,CAAC,CAuCnE;IAEK,eAAe,CACnB,EAAE,EAAE,MAAM,EACV,gBAAgB,EAAE,MAAM,GAAG,IAAI,EAC/B,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC,CAKf;IAEK,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAKtD;IAEK,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,+BAA+B,EAAE,CAAC,CAsB9F;CACF"}
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
import { and, asc, desc, eq, inArray, isNull, lt, or, sql } from 'drizzle-orm';
|
|
2
|
+
import { apiContracts, foundationalServiceSources, foundationalServices } from '../db/schema.js';
|
|
3
|
+
// Drizzle/Postgres mirrors of the foundational-services D1 repositories
|
|
4
|
+
// (docs/initiatives/foundational-services.md; D1 migration 0073). Behaviourally identical to
|
|
5
|
+
// the D1 repos, so the cross-runtime conformance suite asserts the same catalog against both.
|
|
6
|
+
/**
|
|
7
|
+
* How many service ids ride ONE `IN (…)` of the lazy contract read — the same chunking the D1
|
|
8
|
+
* repo applies, so a design that declared many services costs the same bounded number of
|
|
9
|
+
* queries on either runtime rather than the banned per-id N+1.
|
|
10
|
+
*/
|
|
11
|
+
const ID_CHUNK = 50;
|
|
12
|
+
/**
|
|
13
|
+
* A JSON `string[]` column, read LENIENTLY (the D1 repo does the same). A malformed value
|
|
14
|
+
* degrades to `[]` rather than throwing: these columns are written only by our own repos, so a
|
|
15
|
+
* bad value means a hand edit, and failing the whole catalog read over one row's tags would take
|
|
16
|
+
* down every design dispatch in the workspace.
|
|
17
|
+
*/
|
|
18
|
+
function parseStringArray(raw) {
|
|
19
|
+
if (!raw)
|
|
20
|
+
return [];
|
|
21
|
+
try {
|
|
22
|
+
const parsed = JSON.parse(raw);
|
|
23
|
+
return Array.isArray(parsed) ? parsed.filter((v) => typeof v === 'string') : [];
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
// silent-catch-ok: see the note above — a malformed list reads as empty and its row is served.
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function rowToService(row) {
|
|
31
|
+
return {
|
|
32
|
+
serviceId: row.service_id,
|
|
33
|
+
ownerKind: row.owner_kind,
|
|
34
|
+
ownerId: row.owner_id,
|
|
35
|
+
name: row.name,
|
|
36
|
+
summary: row.summary,
|
|
37
|
+
description: row.description,
|
|
38
|
+
capabilities: parseStringArray(row.capabilities),
|
|
39
|
+
sourceId: row.source_id,
|
|
40
|
+
sourcePath: row.source_path,
|
|
41
|
+
pinnedCommit: row.pinned_commit,
|
|
42
|
+
createdAt: row.created_at,
|
|
43
|
+
updatedAt: row.updated_at,
|
|
44
|
+
deletedAt: row.deleted_at,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export class DrizzleFoundationalServiceRepository {
|
|
48
|
+
db;
|
|
49
|
+
constructor(db) {
|
|
50
|
+
this.db = db;
|
|
51
|
+
}
|
|
52
|
+
async listByOwner(ownerKind, ownerId, includeDeleted = false) {
|
|
53
|
+
const base = and(eq(foundationalServices.owner_kind, ownerKind), eq(foundationalServices.owner_id, ownerId));
|
|
54
|
+
const rows = await this.db
|
|
55
|
+
.select()
|
|
56
|
+
.from(foundationalServices)
|
|
57
|
+
.where(includeDeleted ? base : and(base, isNull(foundationalServices.deleted_at)))
|
|
58
|
+
.orderBy(asc(foundationalServices.service_id));
|
|
59
|
+
return rows.map(rowToService);
|
|
60
|
+
}
|
|
61
|
+
async get(ownerKind, ownerId, serviceId) {
|
|
62
|
+
const [row] = await this.db
|
|
63
|
+
.select()
|
|
64
|
+
.from(foundationalServices)
|
|
65
|
+
.where(and(eq(foundationalServices.owner_kind, ownerKind), eq(foundationalServices.owner_id, ownerId), eq(foundationalServices.service_id, serviceId)))
|
|
66
|
+
.limit(1);
|
|
67
|
+
return row ? rowToService(row) : null;
|
|
68
|
+
}
|
|
69
|
+
async upsert(record) {
|
|
70
|
+
const values = {
|
|
71
|
+
service_id: record.serviceId,
|
|
72
|
+
owner_kind: record.ownerKind,
|
|
73
|
+
owner_id: record.ownerId,
|
|
74
|
+
name: record.name,
|
|
75
|
+
summary: record.summary,
|
|
76
|
+
description: record.description,
|
|
77
|
+
capabilities: JSON.stringify(record.capabilities),
|
|
78
|
+
source_id: record.sourceId,
|
|
79
|
+
source_path: record.sourcePath,
|
|
80
|
+
pinned_commit: record.pinnedCommit,
|
|
81
|
+
created_at: record.createdAt,
|
|
82
|
+
updated_at: record.updatedAt,
|
|
83
|
+
deleted_at: record.deletedAt,
|
|
84
|
+
};
|
|
85
|
+
await this.db
|
|
86
|
+
.insert(foundationalServices)
|
|
87
|
+
.values(values)
|
|
88
|
+
.onConflictDoUpdate({
|
|
89
|
+
target: [
|
|
90
|
+
foundationalServices.owner_kind,
|
|
91
|
+
foundationalServices.owner_id,
|
|
92
|
+
foundationalServices.service_id,
|
|
93
|
+
],
|
|
94
|
+
set: {
|
|
95
|
+
name: values.name,
|
|
96
|
+
summary: values.summary,
|
|
97
|
+
description: values.description,
|
|
98
|
+
capabilities: values.capabilities,
|
|
99
|
+
source_id: values.source_id,
|
|
100
|
+
source_path: values.source_path,
|
|
101
|
+
pinned_commit: values.pinned_commit,
|
|
102
|
+
updated_at: values.updated_at,
|
|
103
|
+
deleted_at: values.deleted_at,
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
async softDelete(ownerKind, ownerId, serviceId, at) {
|
|
108
|
+
await this.db
|
|
109
|
+
.update(foundationalServices)
|
|
110
|
+
.set({ deleted_at: at, updated_at: at })
|
|
111
|
+
.where(and(eq(foundationalServices.owner_kind, ownerKind), eq(foundationalServices.owner_id, ownerId), eq(foundationalServices.service_id, serviceId)));
|
|
112
|
+
}
|
|
113
|
+
async listBySource(sourceId) {
|
|
114
|
+
const rows = await this.db
|
|
115
|
+
.select()
|
|
116
|
+
.from(foundationalServices)
|
|
117
|
+
.where(and(eq(foundationalServices.source_id, sourceId), isNull(foundationalServices.deleted_at)))
|
|
118
|
+
.orderBy(asc(foundationalServices.service_id));
|
|
119
|
+
return rows.map(rowToService);
|
|
120
|
+
}
|
|
121
|
+
async softDeleteBySource(sourceId, at) {
|
|
122
|
+
await this.db
|
|
123
|
+
.update(foundationalServices)
|
|
124
|
+
.set({ deleted_at: at, updated_at: at })
|
|
125
|
+
.where(and(eq(foundationalServices.source_id, sourceId), isNull(foundationalServices.deleted_at)));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function rowToContract(row) {
|
|
129
|
+
return {
|
|
130
|
+
ownerKind: row.owner_kind,
|
|
131
|
+
ownerId: row.owner_id,
|
|
132
|
+
serviceId: row.service_id,
|
|
133
|
+
contractId: row.contract_id,
|
|
134
|
+
format: row.format,
|
|
135
|
+
title: row.title,
|
|
136
|
+
body: row.body,
|
|
137
|
+
operations: parseStringArray(row.operations),
|
|
138
|
+
omittedOperations: row.omitted_operations,
|
|
139
|
+
sourcePath: row.source_path,
|
|
140
|
+
sourceSha: row.source_sha,
|
|
141
|
+
createdAt: row.created_at,
|
|
142
|
+
updatedAt: row.updated_at,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
export class DrizzleApiContractRepository {
|
|
146
|
+
db;
|
|
147
|
+
constructor(db) {
|
|
148
|
+
this.db = db;
|
|
149
|
+
}
|
|
150
|
+
async listManifestByOwner(ownerKind, ownerId) {
|
|
151
|
+
// `length(body)` rather than `body`: the whole point of the manifest is that a catalog read
|
|
152
|
+
// transfers no document. Postgres `length()` on text counts CHARACTERS, matching both the
|
|
153
|
+
// SQLite side and the `body.length` the service compares against.
|
|
154
|
+
const rows = await this.db
|
|
155
|
+
.select({
|
|
156
|
+
service_id: apiContracts.service_id,
|
|
157
|
+
contract_id: apiContracts.contract_id,
|
|
158
|
+
format: apiContracts.format,
|
|
159
|
+
title: apiContracts.title,
|
|
160
|
+
size: sql `length(${apiContracts.body})`,
|
|
161
|
+
operations: apiContracts.operations,
|
|
162
|
+
omitted_operations: apiContracts.omitted_operations,
|
|
163
|
+
source_path: apiContracts.source_path,
|
|
164
|
+
})
|
|
165
|
+
.from(apiContracts)
|
|
166
|
+
.where(and(eq(apiContracts.owner_kind, ownerKind), eq(apiContracts.owner_id, ownerId)))
|
|
167
|
+
.orderBy(asc(apiContracts.service_id), asc(apiContracts.contract_id));
|
|
168
|
+
return rows.map((row) => ({
|
|
169
|
+
serviceId: row.service_id,
|
|
170
|
+
contractId: row.contract_id,
|
|
171
|
+
format: row.format,
|
|
172
|
+
title: row.title,
|
|
173
|
+
size: Number(row.size),
|
|
174
|
+
operations: parseStringArray(row.operations),
|
|
175
|
+
omittedOperations: row.omitted_operations,
|
|
176
|
+
sourcePath: row.source_path,
|
|
177
|
+
}));
|
|
178
|
+
}
|
|
179
|
+
async listByServiceIds(ownerKind, ownerId, serviceIds) {
|
|
180
|
+
const ids = [...new Set(serviceIds)].filter(Boolean);
|
|
181
|
+
if (ids.length === 0)
|
|
182
|
+
return [];
|
|
183
|
+
const out = [];
|
|
184
|
+
for (let i = 0; i < ids.length; i += ID_CHUNK) {
|
|
185
|
+
const rows = await this.db
|
|
186
|
+
.select()
|
|
187
|
+
.from(apiContracts)
|
|
188
|
+
.where(and(eq(apiContracts.owner_kind, ownerKind), eq(apiContracts.owner_id, ownerId), inArray(apiContracts.service_id, ids.slice(i, i + ID_CHUNK))))
|
|
189
|
+
.orderBy(asc(apiContracts.service_id), asc(apiContracts.contract_id));
|
|
190
|
+
for (const row of rows)
|
|
191
|
+
out.push(rowToContract(row));
|
|
192
|
+
}
|
|
193
|
+
return out;
|
|
194
|
+
}
|
|
195
|
+
async replaceForService(ownerKind, ownerId, serviceId, contracts) {
|
|
196
|
+
// One TRANSACTION so the delete and the inserts land together: a reader between the two would
|
|
197
|
+
// otherwise see a service whose contracts had vanished, which the catalog renders as a service
|
|
198
|
+
// with no interface rather than as a write in progress (the D1 repo uses a batch for this).
|
|
199
|
+
await this.db.transaction(async (tx) => {
|
|
200
|
+
await tx
|
|
201
|
+
.delete(apiContracts)
|
|
202
|
+
.where(and(eq(apiContracts.owner_kind, ownerKind), eq(apiContracts.owner_id, ownerId), eq(apiContracts.service_id, serviceId)));
|
|
203
|
+
if (contracts.length === 0)
|
|
204
|
+
return;
|
|
205
|
+
await tx.insert(apiContracts).values(contracts.map((contract) => ({
|
|
206
|
+
owner_kind: ownerKind,
|
|
207
|
+
owner_id: ownerId,
|
|
208
|
+
service_id: serviceId,
|
|
209
|
+
contract_id: contract.contractId,
|
|
210
|
+
format: contract.format,
|
|
211
|
+
title: contract.title,
|
|
212
|
+
body: contract.body,
|
|
213
|
+
operations: JSON.stringify(contract.operations),
|
|
214
|
+
omitted_operations: contract.omittedOperations,
|
|
215
|
+
source_path: contract.sourcePath,
|
|
216
|
+
source_sha: contract.sourceSha,
|
|
217
|
+
created_at: contract.createdAt,
|
|
218
|
+
updated_at: contract.updatedAt,
|
|
219
|
+
})));
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
async deleteForService(ownerKind, ownerId, serviceId) {
|
|
223
|
+
await this.db
|
|
224
|
+
.delete(apiContracts)
|
|
225
|
+
.where(and(eq(apiContracts.owner_kind, ownerKind), eq(apiContracts.owner_id, ownerId), eq(apiContracts.service_id, serviceId)));
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
function rowToSource(row) {
|
|
229
|
+
return {
|
|
230
|
+
id: row.id,
|
|
231
|
+
ownerKind: row.owner_kind,
|
|
232
|
+
ownerId: row.owner_id,
|
|
233
|
+
repoOwner: row.repo_owner,
|
|
234
|
+
repoName: row.repo_name,
|
|
235
|
+
gitRef: row.git_ref,
|
|
236
|
+
mode: row.mode,
|
|
237
|
+
dirPath: row.dir_path,
|
|
238
|
+
filePaths: parseStringArray(row.file_paths),
|
|
239
|
+
serviceId: row.service_id,
|
|
240
|
+
serviceName: row.service_name,
|
|
241
|
+
serviceSummary: row.service_summary,
|
|
242
|
+
lastSyncedCommit: row.last_synced_commit,
|
|
243
|
+
lastSyncedAt: row.last_synced_at,
|
|
244
|
+
createdAt: row.created_at,
|
|
245
|
+
deletedAt: row.deleted_at,
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
export class DrizzleFoundationalServiceSourceRepository {
|
|
249
|
+
db;
|
|
250
|
+
constructor(db) {
|
|
251
|
+
this.db = db;
|
|
252
|
+
}
|
|
253
|
+
async listByOwner(ownerKind, ownerId) {
|
|
254
|
+
const rows = await this.db
|
|
255
|
+
.select()
|
|
256
|
+
.from(foundationalServiceSources)
|
|
257
|
+
.where(and(eq(foundationalServiceSources.owner_kind, ownerKind), eq(foundationalServiceSources.owner_id, ownerId), isNull(foundationalServiceSources.deleted_at)))
|
|
258
|
+
.orderBy(desc(foundationalServiceSources.created_at));
|
|
259
|
+
return rows.map(rowToSource);
|
|
260
|
+
}
|
|
261
|
+
async get(id) {
|
|
262
|
+
const [row] = await this.db
|
|
263
|
+
.select()
|
|
264
|
+
.from(foundationalServiceSources)
|
|
265
|
+
.where(eq(foundationalServiceSources.id, id))
|
|
266
|
+
.limit(1);
|
|
267
|
+
return row ? rowToSource(row) : null;
|
|
268
|
+
}
|
|
269
|
+
async upsert(record) {
|
|
270
|
+
const values = {
|
|
271
|
+
id: record.id,
|
|
272
|
+
owner_kind: record.ownerKind,
|
|
273
|
+
owner_id: record.ownerId,
|
|
274
|
+
repo_owner: record.repoOwner,
|
|
275
|
+
repo_name: record.repoName,
|
|
276
|
+
git_ref: record.gitRef,
|
|
277
|
+
mode: record.mode,
|
|
278
|
+
dir_path: record.dirPath,
|
|
279
|
+
file_paths: JSON.stringify(record.filePaths),
|
|
280
|
+
service_id: record.serviceId,
|
|
281
|
+
service_name: record.serviceName,
|
|
282
|
+
service_summary: record.serviceSummary,
|
|
283
|
+
last_synced_commit: record.lastSyncedCommit,
|
|
284
|
+
last_synced_at: record.lastSyncedAt,
|
|
285
|
+
created_at: record.createdAt,
|
|
286
|
+
deleted_at: record.deletedAt,
|
|
287
|
+
};
|
|
288
|
+
await this.db
|
|
289
|
+
.insert(foundationalServiceSources)
|
|
290
|
+
.values(values)
|
|
291
|
+
.onConflictDoUpdate({
|
|
292
|
+
target: foundationalServiceSources.id,
|
|
293
|
+
set: {
|
|
294
|
+
repo_owner: values.repo_owner,
|
|
295
|
+
repo_name: values.repo_name,
|
|
296
|
+
git_ref: values.git_ref,
|
|
297
|
+
mode: values.mode,
|
|
298
|
+
dir_path: values.dir_path,
|
|
299
|
+
file_paths: values.file_paths,
|
|
300
|
+
service_id: values.service_id,
|
|
301
|
+
service_name: values.service_name,
|
|
302
|
+
service_summary: values.service_summary,
|
|
303
|
+
last_synced_commit: values.last_synced_commit,
|
|
304
|
+
last_synced_at: values.last_synced_at,
|
|
305
|
+
deleted_at: values.deleted_at,
|
|
306
|
+
},
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
async updateSyncState(id, lastSyncedCommit, lastSyncedAt) {
|
|
310
|
+
await this.db
|
|
311
|
+
.update(foundationalServiceSources)
|
|
312
|
+
.set({ last_synced_commit: lastSyncedCommit, last_synced_at: lastSyncedAt })
|
|
313
|
+
.where(eq(foundationalServiceSources.id, id));
|
|
314
|
+
}
|
|
315
|
+
async softDelete(id, at) {
|
|
316
|
+
await this.db
|
|
317
|
+
.update(foundationalServiceSources)
|
|
318
|
+
.set({ deleted_at: at })
|
|
319
|
+
.where(eq(foundationalServiceSources.id, id));
|
|
320
|
+
}
|
|
321
|
+
async listStale(staleBefore, limit) {
|
|
322
|
+
// A source linked but NEVER synced is the stalest thing there is, so it is matched
|
|
323
|
+
// explicitly and ordered first — `ORDER BY last_synced_at` alone puts NULLs last on
|
|
324
|
+
// Postgres and first on SQLite, which would make the two runtimes drain different sources.
|
|
325
|
+
const rows = await this.db
|
|
326
|
+
.select()
|
|
327
|
+
.from(foundationalServiceSources)
|
|
328
|
+
.where(and(isNull(foundationalServiceSources.deleted_at), or(isNull(foundationalServiceSources.last_synced_at), lt(foundationalServiceSources.last_synced_at, staleBefore))))
|
|
329
|
+
.orderBy(sql `${foundationalServiceSources.last_synced_at} IS NULL DESC`, asc(foundationalServiceSources.last_synced_at))
|
|
330
|
+
.limit(limit);
|
|
331
|
+
return rows.map(rowToSource);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
//# sourceMappingURL=foundationalServices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"foundationalServices.js","sourceRoot":"","sources":["../../src/repositories/foundationalServices.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAE9E,OAAO,EAAE,YAAY,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAEhG,wEAAwE;AACxE,6FAA6F;AAC7F,8FAA8F;AAE9F;;;;GAIG;AACH,MAAM,QAAQ,GAAG,EAAE,CAAA;AAEnB;;;;;GAKG;AACH,SAAS,gBAAgB,CAAC,GAAkB;IAC1C,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,CAAA;IACnB,IAAI,CAAC;QACH,MAAM,MAAM,GAAY,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QACvC,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IAC9F,CAAC;IAAC,MAAM,CAAC;QACP,+FAA+F;QAC/F,OAAO,EA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AAG,CACD,MAAM,CAAC,0BAA0B,CAAC,UAAU,CAAC,EAC7C,EAAE,CACA,MAAM,CAAC,0BAA0B,CAAC,cAAc,CAAC,EACjD,EAAE,CAAC,0BAA0B,CAAC,cAAc,EAAE,WAAW,CAAC,CAC3D,CACF,CACF;aACA,OAAO,CACN,GAAG,CAAA,GAAG,0BAA0B,CAAC,cAAc,eAAe,EAC9D,GAAG,CAAC,0BAA0B,CAAC,cAAc,CAAC,CAC/C;aACA,KAAK,CAAC,KAAK,CAAC,CAAA;QACf,OAAO,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;IAC9B,CAAC;CACF"}
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EACL,KAAK,MAAM,EAGX,KAAK,aAAa,EAClB,KAAK,eAAe,EAerB,MAAM,qBAAqB,CAAA;AAI5B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAI3B,OAAO,EAAE,KAAK,gBAAgB,EAAmB,MAAM,sBAAsB,CAAA;AAE7E,OAAO,EAAE,KAAK,oBAAoB,EAAsB,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EACL,KAAK,MAAM,EAGX,KAAK,aAAa,EAClB,KAAK,eAAe,EAerB,MAAM,qBAAqB,CAAA;AAI5B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAI3B,OAAO,EAAE,KAAK,gBAAgB,EAAmB,MAAM,sBAAsB,CAAA;AAE7E,OAAO,EAAE,KAAK,oBAAoB,EAAsB,MAAM,gBAAgB,CAAA;AAuB9E,OAAO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|
|
23
23
|
import { resolveSweepInterval, startInitiativeLoopSweeper } from './initiativeLoop.js';
|
|
24
24
|
import { startKaizenSweeper } from './kaizen.js';
|
|
25
25
|
import { startNotificationEscalationSweeper } from './notifications.js';
|
|
26
|
+
import { startFoundationalSourceSweeper } from './foundationalServices.js';
|
|
26
27
|
import { startPlatformHealthSweeper } from './platformHealth.js';
|
|
27
28
|
import { startInfraReachabilitySweeper } from './infraReachability.js';
|
|
28
29
|
import { buildRealtimePropagator } from './propagator.js';
|
|
@@ -278,6 +279,10 @@ function startBackgroundSweepers(deps) {
|
|
|
278
279
|
// Probe each workspace's CONFIGURED infrastructure connections and report a dead one as
|
|
279
280
|
// `unreachable` (the Worker uses cron). No-op unless `INFRA_REACHABILITY_WATCH` is opted in.
|
|
280
281
|
const stopInfraReachability = startInfraReachabilitySweeper(container, clock, logger);
|
|
282
|
+
// Refresh repo-linked foundational-service sources so a merged contract change reaches the
|
|
283
|
+
// catalog without anyone opening the management surface (the Worker uses cron). No-op unless
|
|
284
|
+
// the catalog + GitHub are both wired.
|
|
285
|
+
const stopFoundationalSources = startFoundationalSourceSweeper(container, logger);
|
|
281
286
|
return {
|
|
282
287
|
stopSweeper,
|
|
283
288
|
stopEnvTestSweeper,
|
|
@@ -292,6 +297,7 @@ function startBackgroundSweepers(deps) {
|
|
|
292
297
|
stopPlatformMetrics,
|
|
293
298
|
stopPlatformHealth,
|
|
294
299
|
stopInfraReachability,
|
|
300
|
+
stopFoundationalSources,
|
|
295
301
|
};
|
|
296
302
|
}
|
|
297
303
|
/**
|
|
@@ -462,7 +468,7 @@ async function bootServer(options, env) {
|
|
|
462
468
|
// The background sweepers only schedule `setInterval`s (no work runs until a timer fires), so
|
|
463
469
|
// start them AFTER the listener binds — the server accepts requests a few ms sooner. The pg-boss
|
|
464
470
|
// workers above stay before listen so an enqueued job always has a consumer.
|
|
465
|
-
const { stopSweeper, stopEnvTestSweeper, stopRetention, stopArtifactRetention, stopScheduleSweeper, stopInitiativeLoop, stopEnvironmentSweeper, stopNotificationEscalation, stopKaizenSweeper, stopGitHubReconcile, stopPlatformMetrics, stopPlatformHealth, stopInfraReachability, } = startBackgroundSweepers({ boss, pool, db, container, repos, runtime, clock, env });
|
|
471
|
+
const { stopSweeper, stopEnvTestSweeper, stopRetention, stopArtifactRetention, stopScheduleSweeper, stopInitiativeLoop, stopEnvironmentSweeper, stopNotificationEscalation, stopKaizenSweeper, stopGitHubReconcile, stopPlatformMetrics, stopPlatformHealth, stopInfraReachability, stopFoundationalSources, } = startBackgroundSweepers({ boss, pool, db, container, repos, runtime, clock, env });
|
|
466
472
|
// Backfill the deployment's declared environment-handler seeds onto every existing workspace
|
|
467
473
|
// (idempotent; new workspaces are seeded by WorkspaceService.create). FIRE-AND-FORGET after the
|
|
468
474
|
// listener binds so it never delays serving; best-effort + fully logged inside, and a no-op when
|
|
@@ -493,6 +499,7 @@ async function bootServer(options, env) {
|
|
|
493
499
|
stopPlatformMetrics();
|
|
494
500
|
stopPlatformHealth();
|
|
495
501
|
stopInfraReachability();
|
|
502
|
+
stopFoundationalSources();
|
|
496
503
|
stopRealtime();
|
|
497
504
|
// Release any cross-node propagation adapters (Redis connections); a no-op when none.
|
|
498
505
|
await realtimePropagator.stop();
|