@ontrails/core 1.0.0-beta.13 → 1.0.0-beta.15
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/.turbo/turbo-lint.log +1 -1
- package/CHANGELOG.md +17 -0
- package/README.md +19 -14
- package/dist/branded.d.ts +1 -1
- package/dist/branded.d.ts.map +1 -1
- package/dist/branded.js +1 -1
- package/dist/branded.js.map +1 -1
- package/dist/context.d.ts +13 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +19 -3
- package/dist/context.js.map +1 -1
- package/dist/contour.d.ts +81 -0
- package/dist/contour.d.ts.map +1 -0
- package/dist/contour.js +176 -0
- package/dist/contour.js.map +1 -0
- package/dist/cross-schema.d.ts +18 -0
- package/dist/cross-schema.d.ts.map +1 -0
- package/dist/cross-schema.js +29 -0
- package/dist/cross-schema.js.map +1 -0
- package/dist/derive.d.ts +6 -0
- package/dist/derive.d.ts.map +1 -1
- package/dist/derive.js +29 -5
- package/dist/derive.js.map +1 -1
- package/dist/draft.d.ts +28 -0
- package/dist/draft.d.ts.map +1 -0
- package/dist/draft.js +157 -0
- package/dist/draft.js.map +1 -0
- package/dist/errors.d.ts +62 -4
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +44 -1
- package/dist/errors.js.map +1 -1
- package/dist/execute.d.ts +26 -9
- package/dist/execute.d.ts.map +1 -1
- package/dist/execute.js +441 -20
- package/dist/execute.js.map +1 -1
- package/dist/fire.d.ts +43 -0
- package/dist/fire.d.ts.map +1 -0
- package/dist/fire.js +185 -0
- package/dist/fire.js.map +1 -0
- package/dist/index.d.ts +33 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -12
- package/dist/index.js.map +1 -1
- package/dist/internal/cross-batch.d.ts +44 -0
- package/dist/internal/cross-batch.d.ts.map +1 -0
- package/dist/internal/cross-batch.js +58 -0
- package/dist/internal/cross-batch.js.map +1 -0
- package/dist/internal/fork-ctx.d.ts +41 -0
- package/dist/internal/fork-ctx.d.ts.map +1 -0
- package/dist/internal/fork-ctx.js +47 -0
- package/dist/internal/fork-ctx.js.map +1 -0
- package/dist/internal/signal-ref.d.ts +15 -0
- package/dist/internal/signal-ref.d.ts.map +1 -0
- package/dist/internal/signal-ref.js +41 -0
- package/dist/internal/signal-ref.js.map +1 -0
- package/dist/internal/topo-saves.d.ts +53 -0
- package/dist/internal/topo-saves.d.ts.map +1 -0
- package/dist/internal/topo-saves.js +449 -0
- package/dist/internal/topo-saves.js.map +1 -0
- package/dist/internal/topo-snapshots.d.ts +57 -0
- package/dist/internal/topo-snapshots.d.ts.map +1 -0
- package/dist/internal/topo-snapshots.js +372 -0
- package/dist/internal/topo-snapshots.js.map +1 -0
- package/dist/internal/topo-store-read.d.ts +70 -0
- package/dist/internal/topo-store-read.d.ts.map +1 -0
- package/dist/internal/topo-store-read.js +221 -0
- package/dist/internal/topo-store-read.js.map +1 -0
- package/dist/internal/topo-store.d.ts +26 -0
- package/dist/internal/topo-store.d.ts.map +1 -0
- package/dist/internal/topo-store.js +621 -0
- package/dist/internal/topo-store.js.map +1 -0
- package/dist/internal/tracing.d.ts +98 -0
- package/dist/internal/tracing.d.ts.map +1 -0
- package/dist/internal/tracing.js +102 -0
- package/dist/internal/tracing.js.map +1 -0
- package/dist/internal/trails-db.d.ts +16 -0
- package/dist/internal/trails-db.d.ts.map +1 -0
- package/dist/internal/trails-db.js +118 -0
- package/dist/internal/trails-db.js.map +1 -0
- package/dist/internal/zod-wrappers.d.ts +40 -0
- package/dist/internal/zod-wrappers.d.ts.map +1 -0
- package/dist/internal/zod-wrappers.js +59 -0
- package/dist/internal/zod-wrappers.js.map +1 -0
- package/dist/layer.d.ts +22 -5
- package/dist/layer.d.ts.map +1 -1
- package/dist/layer.js +20 -3
- package/dist/layer.js.map +1 -1
- package/dist/path-security.d.ts +1 -1
- package/dist/path-security.d.ts.map +1 -1
- package/dist/path-security.js +1 -1
- package/dist/path-security.js.map +1 -1
- package/dist/resilience.d.ts +1 -1
- package/dist/resilience.d.ts.map +1 -1
- package/dist/resilience.js +3 -3
- package/dist/resilience.js.map +1 -1
- package/dist/resource-config.d.ts +22 -0
- package/dist/resource-config.d.ts.map +1 -0
- package/dist/resource-config.js +210 -0
- package/dist/resource-config.js.map +1 -0
- package/dist/resource.d.ts +74 -0
- package/dist/resource.d.ts.map +1 -0
- package/dist/resource.js +61 -0
- package/dist/resource.js.map +1 -0
- package/dist/run.d.ts +4 -3
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +5 -4
- package/dist/run.js.map +1 -1
- package/dist/serialization.d.ts.map +1 -1
- package/dist/serialization.js +2 -1
- package/dist/serialization.js.map +1 -1
- package/dist/store/accessor-protocol.d.ts +51 -0
- package/dist/store/accessor-protocol.d.ts.map +1 -0
- package/dist/store/accessor-protocol.js +2 -0
- package/dist/store/accessor-protocol.js.map +1 -0
- package/dist/store/index.d.ts +2 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.js +2 -0
- package/dist/store/index.js.map +1 -0
- package/dist/surface-filter.d.ts +13 -0
- package/dist/surface-filter.d.ts.map +1 -0
- package/dist/surface-filter.js +76 -0
- package/dist/surface-filter.js.map +1 -0
- package/dist/topo-store.d.ts +62 -0
- package/dist/topo-store.d.ts.map +1 -0
- package/dist/topo-store.js +319 -0
- package/dist/topo-store.js.map +1 -0
- package/dist/topo.d.ts +23 -9
- package/dist/topo.d.ts.map +1 -1
- package/dist/topo.js +175 -46
- package/dist/topo.js.map +1 -1
- package/dist/trail.d.ts +86 -19
- package/dist/trail.d.ts.map +1 -1
- package/dist/trail.js +59 -4
- package/dist/trail.js.map +1 -1
- package/dist/trails/derive-trail.d.ts +66 -0
- package/dist/trails/derive-trail.d.ts.map +1 -0
- package/dist/trails/derive-trail.js +378 -0
- package/dist/trails/derive-trail.js.map +1 -0
- package/dist/trails/index.d.ts +5 -0
- package/dist/trails/index.d.ts.map +1 -0
- package/dist/trails/index.js +3 -0
- package/dist/trails/index.js.map +1 -0
- package/dist/trails/ingest.d.ts +24 -0
- package/dist/trails/ingest.d.ts.map +1 -0
- package/dist/trails/ingest.js +63 -0
- package/dist/trails/ingest.js.map +1 -0
- package/dist/transport-error-map.d.ts +106 -0
- package/dist/transport-error-map.d.ts.map +1 -0
- package/dist/transport-error-map.js +24 -0
- package/dist/transport-error-map.js.map +1 -0
- package/dist/type-checks.test-d.d.ts +71 -0
- package/dist/type-checks.test-d.d.ts.map +1 -0
- package/dist/type-checks.test-d.js +12 -0
- package/dist/type-checks.test-d.js.map +1 -0
- package/dist/type-utils.d.ts +11 -2
- package/dist/type-utils.d.ts.map +1 -1
- package/dist/type-utils.js.map +1 -1
- package/dist/types.d.ts +113 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/validate-established-topo.d.ts +76 -0
- package/dist/validate-established-topo.d.ts.map +1 -0
- package/dist/validate-established-topo.js +43 -0
- package/dist/validate-established-topo.js.map +1 -0
- package/dist/validate-topo.d.ts.map +1 -1
- package/dist/validate-topo.js +27 -8
- package/dist/validate-topo.js.map +1 -1
- package/dist/workspace.d.ts +1 -1
- package/dist/workspace.d.ts.map +1 -1
- package/dist/workspace.js +1 -1
- package/dist/workspace.js.map +1 -1
- package/package.json +10 -1
- package/src/__tests__/branded.test.ts +5 -5
- package/src/__tests__/context.test.ts +3 -3
- package/src/__tests__/contour.test.ts +263 -0
- package/src/__tests__/derive-trail.test.ts +668 -0
- package/src/__tests__/derive.test.ts +58 -1
- package/src/__tests__/errors.test.ts +118 -0
- package/src/__tests__/execute.test.ts +1179 -141
- package/src/__tests__/fire.test.ts +1056 -0
- package/src/__tests__/fork-ctx.test.ts +83 -0
- package/src/__tests__/ingest.test.ts +191 -0
- package/src/__tests__/{gate.test.ts → layer.test.ts} +21 -21
- package/src/__tests__/path-security.test.ts +7 -7
- package/src/__tests__/resilience.test.ts +8 -8
- package/src/__tests__/resource.test.ts +204 -0
- package/src/__tests__/run.test.ts +13 -13
- package/src/__tests__/service-config.test.ts +28 -32
- package/src/__tests__/surface-filter.test.ts +196 -0
- package/src/__tests__/topo-store-read.test.ts +256 -0
- package/src/__tests__/topo-store.test.ts +869 -0
- package/src/__tests__/topo.test.ts +350 -54
- package/src/__tests__/trail.test.ts +189 -24
- package/src/__tests__/trails-db.test.ts +198 -0
- package/src/__tests__/transport-error-map.test.ts +82 -0
- package/src/__tests__/type-utils.test.ts +29 -1
- package/src/__tests__/validate-topo.test.ts +305 -16
- package/src/__tests__/workspace.test.ts +6 -6
- package/src/__tests__/zod-wrappers.test.ts +62 -0
- package/src/branded.ts +1 -1
- package/src/context.ts +24 -4
- package/src/contour.ts +344 -0
- package/src/cross-schema.ts +36 -0
- package/src/derive.ts +39 -8
- package/src/draft.ts +338 -0
- package/src/errors.ts +62 -18
- package/src/execute.ts +840 -29
- package/src/fire.ts +295 -0
- package/src/index.ts +142 -26
- package/src/internal/cross-batch.ts +77 -0
- package/src/internal/fork-ctx.ts +69 -0
- package/src/internal/signal-ref.ts +87 -0
- package/src/internal/topo-snapshots.ts +517 -0
- package/src/internal/topo-store-read.ts +481 -0
- package/src/internal/topo-store.ts +1192 -0
- package/src/internal/tracing.ts +187 -0
- package/src/internal/trails-db.ts +187 -0
- package/src/internal/zod-wrappers.ts +78 -0
- package/src/layer.ts +50 -0
- package/src/path-security.ts +1 -1
- package/src/resilience.ts +3 -3
- package/src/{provision-config.ts → resource-config.ts} +109 -123
- package/src/resource.ts +155 -0
- package/src/run.ts +5 -4
- package/src/serialization.ts +2 -0
- package/src/store/accessor-protocol.ts +56 -0
- package/src/store/index.ts +4 -0
- package/src/surface-filter.ts +182 -0
- package/src/topo-store.ts +510 -0
- package/src/topo.ts +328 -57
- package/src/trail.ts +199 -31
- package/src/trails/derive-trail.ts +842 -0
- package/src/trails/index.ts +9 -0
- package/src/trails/ingest.ts +146 -0
- package/src/transport-error-map.ts +56 -0
- package/src/type-checks.test-d.ts +106 -0
- package/src/type-utils.ts +17 -2
- package/src/types.ts +148 -11
- package/src/validate-established-topo.ts +63 -0
- package/src/validate-topo.ts +37 -9
- package/src/workspace.ts +1 -1
- package/tsconfig.tests.json +10 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/adapters.d.ts +0 -39
- package/dist/adapters.d.ts.map +0 -1
- package/dist/adapters.js +0 -2
- package/dist/adapters.js.map +0 -1
- package/dist/dispatch.d.ts +0 -27
- package/dist/dispatch.d.ts.map +0 -1
- package/dist/dispatch.js +0 -34
- package/dist/dispatch.js.map +0 -1
- package/dist/event.d.ts +0 -8
- package/dist/event.d.ts.map +0 -1
- package/dist/event.js +0 -7
- package/dist/event.js.map +0 -1
- package/dist/gate.d.ts +0 -17
- package/dist/gate.d.ts.map +0 -1
- package/dist/gate.js +0 -21
- package/dist/gate.js.map +0 -1
- package/dist/health.d.ts +0 -18
- package/dist/health.d.ts.map +0 -1
- package/dist/health.js +0 -5
- package/dist/health.js.map +0 -1
- package/dist/job.d.ts +0 -24
- package/dist/job.d.ts.map +0 -1
- package/dist/job.js +0 -17
- package/dist/job.js.map +0 -1
- package/dist/provision-config.d.ts +0 -22
- package/dist/provision-config.d.ts.map +0 -1
- package/dist/provision-config.js +0 -210
- package/dist/provision-config.js.map +0 -1
- package/dist/provision.d.ts +0 -71
- package/dist/provision.d.ts.map +0 -1
- package/dist/provision.js +0 -56
- package/dist/provision.js.map +0 -1
- package/dist/service-config.d.ts +0 -22
- package/dist/service-config.d.ts.map +0 -1
- package/dist/service-config.js +0 -210
- package/dist/service-config.js.map +0 -1
- package/dist/service.d.ts +0 -71
- package/dist/service.d.ts.map +0 -1
- package/dist/service.js +0 -56
- package/dist/service.js.map +0 -1
- package/src/__tests__/service.test.ts +0 -197
- package/src/event.ts +0 -15
- package/src/gate.ts +0 -44
- package/src/provision.ts +0 -148
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"topo-store-read.js","sourceRoot":"","sources":["../../src/internal/topo-store-read.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe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AE,OAAO,EAAE,QAAQ,CAAC,CAAC;IACxD,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,GAAG,GAAG,EAAE;SACX,KAAK,CACJ;;;eAGS,CACV;SACA,GAAG,CAAC,QAAQ,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;IAEhC,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,KAAK,GAAG,iBAAiB,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC;IACjD,OAAO,cAAc,CACnB,GAAG,EACH,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,EAC3B,eAAe,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE,UAAU,EAAE,UAAU,CAAC,CACzD,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,EAAY,EACZ,GAAW,EACX,QAAsC,EACrB,EAAE,CACnB,EAAE;KACC,KAAK,CAA2B,GAAG,CAAC;KACpC,GAAG,CAAC,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Database } from 'bun:sqlite';
|
|
2
|
+
import { Result } from '../result.js';
|
|
3
|
+
import type { Topo } from '../topo.js';
|
|
4
|
+
import type { AnyTrail } from '../trail.js';
|
|
5
|
+
import type { CreateTopoSnapshotInput, TopoSnapshot } from './topo-snapshots.js';
|
|
6
|
+
interface TopoFiresRow {
|
|
7
|
+
readonly snapshotId: string;
|
|
8
|
+
readonly signalId: string;
|
|
9
|
+
readonly trailId: string;
|
|
10
|
+
}
|
|
11
|
+
interface TopoOnRow {
|
|
12
|
+
readonly snapshotId: string;
|
|
13
|
+
readonly signalId: string;
|
|
14
|
+
readonly trailId: string;
|
|
15
|
+
}
|
|
16
|
+
export interface StoredTopoExport {
|
|
17
|
+
readonly lockContent: string;
|
|
18
|
+
readonly surfaceHash: string;
|
|
19
|
+
readonly surfaceMapJson: string;
|
|
20
|
+
}
|
|
21
|
+
export declare const normalizeFiresRows: (trails: readonly AnyTrail[], snapshotId: string) => readonly TopoFiresRow[];
|
|
22
|
+
export declare const normalizeOnRows: (trails: readonly AnyTrail[], snapshotId: string) => readonly TopoOnRow[];
|
|
23
|
+
export declare const getStoredTopoExport: (db: Database, snapshotId: string) => StoredTopoExport | undefined;
|
|
24
|
+
export declare const createTopoSnapshot: (db: Database, topo: Topo, input?: CreateTopoSnapshotInput) => Result<TopoSnapshot, Error>;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=topo-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"topo-store.d.ts","sourceRoot":"","sources":["../../src/internal/topo-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAoB,MAAM,YAAY,CAAC;AAI7D,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAItC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG5C,OAAO,KAAK,EACV,uBAAuB,EACvB,YAAY,EACb,MAAM,qBAAqB,CAAC;AAuC7B,UAAU,YAAY;IACpB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,UAAU,SAAS;IACjB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAsED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CACjC;AAiLD,eAAO,MAAM,kBAAkB,GAC7B,QAAQ,SAAS,QAAQ,EAAE,EAC3B,YAAY,MAAM,KACjB,SAAS,YAAY,EAOrB,CAAC;AAEJ,eAAO,MAAM,eAAe,GAC1B,QAAQ,SAAS,QAAQ,EAAE,EAC3B,YAAY,MAAM,KACjB,SAAS,SAAS,EAOlB,CAAC;AAkyBJ,eAAO,MAAM,mBAAmB,GAC9B,IAAI,QAAQ,EACZ,YAAY,MAAM,KACjB,gBAAgB,GAAG,SAkBrB,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,IAAI,QAAQ,EACZ,MAAM,IAAI,EACV,QAAQ,uBAAuB,KAC9B,MAAM,CAAC,YAAY,EAAE,KAAK,CAyB5B,CAAC"}
|
|
@@ -0,0 +1,621 @@
|
|
|
1
|
+
import { getContourReferences } from '../contour.js';
|
|
2
|
+
import { deriveCliPath } from '../derive.js';
|
|
3
|
+
import { Result } from '../result.js';
|
|
4
|
+
import { validateEstablishedTopo } from '../validate-established-topo.js';
|
|
5
|
+
import { zodToJsonSchema } from '../validation.js';
|
|
6
|
+
import { ensureTopoSnapshotSchema, insertTopoSnapshotRecord, } from './topo-snapshots.js';
|
|
7
|
+
const canonicalLeaf = (value) => {
|
|
8
|
+
switch (typeof value) {
|
|
9
|
+
case 'bigint': {
|
|
10
|
+
return value.toString();
|
|
11
|
+
}
|
|
12
|
+
case 'function': {
|
|
13
|
+
return `[Function:${value.name || 'anonymous'}]`;
|
|
14
|
+
}
|
|
15
|
+
case 'symbol': {
|
|
16
|
+
return `[Symbol:${value.description ?? ''}]`;
|
|
17
|
+
}
|
|
18
|
+
case 'undefined': {
|
|
19
|
+
return '[Undefined]';
|
|
20
|
+
}
|
|
21
|
+
default: {
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const canonicalObject = (value, visit) => {
|
|
27
|
+
const sorted = {};
|
|
28
|
+
for (const key of Object.keys(value).toSorted()) {
|
|
29
|
+
const next = value[key];
|
|
30
|
+
sorted[key] = next === undefined ? '[Undefined]' : visit(next);
|
|
31
|
+
}
|
|
32
|
+
return sorted;
|
|
33
|
+
};
|
|
34
|
+
const canonicalize = (value) => {
|
|
35
|
+
if (Array.isArray(value)) {
|
|
36
|
+
return value.map(canonicalize);
|
|
37
|
+
}
|
|
38
|
+
if (value instanceof Date) {
|
|
39
|
+
return value.toISOString();
|
|
40
|
+
}
|
|
41
|
+
if (value instanceof RegExp) {
|
|
42
|
+
return value.toString();
|
|
43
|
+
}
|
|
44
|
+
if (value !== null && typeof value === 'object') {
|
|
45
|
+
return canonicalObject(value, canonicalize);
|
|
46
|
+
}
|
|
47
|
+
return canonicalLeaf(value);
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Canonicalize a value for schema definition hashing.
|
|
51
|
+
*
|
|
52
|
+
* Matches the canonicalization logic used in `@ontrails/schema` so that
|
|
53
|
+
* schema hashes are consistent regardless of which code path computes them.
|
|
54
|
+
* Unlike the general `canonicalize`, this does not convert `Date`, `RegExp`,
|
|
55
|
+
* or `undefined` to sentinel strings — Zod `_zod.def` objects are plain
|
|
56
|
+
* JSON-serializable structures and both paths must agree on the same encoding.
|
|
57
|
+
*/
|
|
58
|
+
const schemaCanonical = (value) => {
|
|
59
|
+
if (Array.isArray(value)) {
|
|
60
|
+
return value.map(schemaCanonical);
|
|
61
|
+
}
|
|
62
|
+
if (value !== null && typeof value === 'object') {
|
|
63
|
+
const sorted = {};
|
|
64
|
+
for (const key of Object.keys(value).toSorted()) {
|
|
65
|
+
sorted[key] = schemaCanonical(value[key]);
|
|
66
|
+
}
|
|
67
|
+
return sorted;
|
|
68
|
+
}
|
|
69
|
+
return value;
|
|
70
|
+
};
|
|
71
|
+
const stableJson = (value) => JSON.stringify(canonicalize(value));
|
|
72
|
+
const hashText = (text) => {
|
|
73
|
+
const hasher = new Bun.CryptoHasher('sha256');
|
|
74
|
+
hasher.update(text);
|
|
75
|
+
return hasher.digest('hex');
|
|
76
|
+
};
|
|
77
|
+
const hashValue = (value) => hashText(stableJson(value));
|
|
78
|
+
const parseJsonRecord = (value) => JSON.parse(value);
|
|
79
|
+
const schemaDefinitionHash = (schema) => {
|
|
80
|
+
const def = typeof schema === 'object' &&
|
|
81
|
+
schema !== null &&
|
|
82
|
+
'_zod' in schema &&
|
|
83
|
+
typeof schema._zod === 'object' &&
|
|
84
|
+
schema._zod !== null &&
|
|
85
|
+
'def' in schema._zod
|
|
86
|
+
? schema._zod.def
|
|
87
|
+
: schema;
|
|
88
|
+
return hashText(JSON.stringify(schemaCanonical(def)));
|
|
89
|
+
};
|
|
90
|
+
const sortedJsonSchema = (schema) => {
|
|
91
|
+
const json = stableJson(zodToJsonSchema(schema));
|
|
92
|
+
return {
|
|
93
|
+
json,
|
|
94
|
+
value: parseJsonRecord(json),
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
const sortKeys = (value) => {
|
|
98
|
+
const sorted = {};
|
|
99
|
+
for (const key of Object.keys(value).toSorted()) {
|
|
100
|
+
sorted[key] = value[key];
|
|
101
|
+
}
|
|
102
|
+
return sorted;
|
|
103
|
+
};
|
|
104
|
+
const normalizeTrailRows = (trails, snapshotId) => trails.map((trail) => ({
|
|
105
|
+
description: trail.description ?? null,
|
|
106
|
+
exampleCount: trail.examples?.length ?? 0,
|
|
107
|
+
hasExamples: (trail.examples?.length ?? 0) > 0 ? 1 : 0,
|
|
108
|
+
hasOutput: trail.output === undefined ? 0 : 1,
|
|
109
|
+
id: trail.id,
|
|
110
|
+
idempotent: trail.idempotent === true ? 1 : 0,
|
|
111
|
+
intent: trail.intent,
|
|
112
|
+
meta: trail.meta === undefined ? null : stableJson(trail.meta),
|
|
113
|
+
pattern: trail.pattern ?? null,
|
|
114
|
+
snapshotId,
|
|
115
|
+
}));
|
|
116
|
+
const normalizeCrossingRows = (trails, snapshotId) => trails.flatMap((trail) => [...new Set(trail.crosses)].toSorted().map((targetId) => ({
|
|
117
|
+
snapshotId,
|
|
118
|
+
sourceId: trail.id,
|
|
119
|
+
targetId,
|
|
120
|
+
})));
|
|
121
|
+
export const normalizeFiresRows = (trails, snapshotId) => trails.flatMap((trail) => [...new Set(trail.fires)].toSorted().map((signalId) => ({
|
|
122
|
+
signalId,
|
|
123
|
+
snapshotId,
|
|
124
|
+
trailId: trail.id,
|
|
125
|
+
})));
|
|
126
|
+
export const normalizeOnRows = (trails, snapshotId) => trails.flatMap((trail) => [...new Set(trail.on)].toSorted().map((signalId) => ({
|
|
127
|
+
signalId,
|
|
128
|
+
snapshotId,
|
|
129
|
+
trailId: trail.id,
|
|
130
|
+
})));
|
|
131
|
+
const normalizeTrailResourceRows = (trails, snapshotId) => trails.flatMap((trail) => [...new Set(trail.resources.map((resource) => resource.id))]
|
|
132
|
+
.toSorted()
|
|
133
|
+
.map((resourceId) => ({
|
|
134
|
+
resourceId,
|
|
135
|
+
snapshotId,
|
|
136
|
+
trailId: trail.id,
|
|
137
|
+
})));
|
|
138
|
+
const normalizeResourceRows = (resources, snapshotId) => resources.map((resource) => ({
|
|
139
|
+
hasHealth: resource.health === undefined ? 0 : 1,
|
|
140
|
+
hasMock: resource.mock === undefined ? 0 : 1,
|
|
141
|
+
id: resource.id,
|
|
142
|
+
snapshotId,
|
|
143
|
+
}));
|
|
144
|
+
const normalizeSignalRows = (signals, snapshotId) => signals.map((signal) => ({
|
|
145
|
+
description: signal.description ?? null,
|
|
146
|
+
id: signal.id,
|
|
147
|
+
snapshotId,
|
|
148
|
+
}));
|
|
149
|
+
const normalizeTrailSignalRows = (signals, snapshotId) => signals.flatMap((signal) => [...new Set(signal.from)].toSorted().map((trailId) => ({
|
|
150
|
+
signalId: signal.id,
|
|
151
|
+
snapshotId,
|
|
152
|
+
trailId,
|
|
153
|
+
})));
|
|
154
|
+
/**
|
|
155
|
+
* Project surface rows for stored topo.
|
|
156
|
+
*
|
|
157
|
+
* Currently records only CLI-derived rows. MCP, HTTP, and other surface
|
|
158
|
+
* projections are intentionally deferred until the topo-store schema supports
|
|
159
|
+
* multi-surface representation. The JSON export (`surface_map` in
|
|
160
|
+
* `topo_exports`) is more faithful for now. See ADR-0015 for the target shape.
|
|
161
|
+
*/
|
|
162
|
+
const normalizeSurfaceRows = (trails, snapshotId) => trails.map((trail) => ({
|
|
163
|
+
derivedName: deriveCliPath(trail.id).join(' '),
|
|
164
|
+
method: null,
|
|
165
|
+
snapshotId,
|
|
166
|
+
surface: 'cli',
|
|
167
|
+
trailId: trail.id,
|
|
168
|
+
}));
|
|
169
|
+
const buildExampleId = (snapshotId, trailId, ordinal) => `${snapshotId}:${trailId}:${ordinal.toString().padStart(4, '0')}`;
|
|
170
|
+
const normalizeExampleRows = (trails, snapshotId) => trails.flatMap((trail) => (trail.examples ?? []).map((example, index) => ({
|
|
171
|
+
description: example.description ?? null,
|
|
172
|
+
error: example.error ?? null,
|
|
173
|
+
expected: example.expected === undefined ? null : stableJson(example.expected),
|
|
174
|
+
expectedMatch: example.expectedMatch === undefined
|
|
175
|
+
? null
|
|
176
|
+
: stableJson(example.expectedMatch),
|
|
177
|
+
id: buildExampleId(snapshotId, trail.id, index),
|
|
178
|
+
input: stableJson(example.input),
|
|
179
|
+
name: example.name,
|
|
180
|
+
ordinal: index,
|
|
181
|
+
snapshotId,
|
|
182
|
+
trailId: trail.id,
|
|
183
|
+
})));
|
|
184
|
+
const normalizeTopoProjection = (topo, snapshotId) => {
|
|
185
|
+
const trails = topo.list().toSorted((a, b) => a.id.localeCompare(b.id));
|
|
186
|
+
const resources = topo
|
|
187
|
+
.listResources()
|
|
188
|
+
.toSorted((a, b) => a.id.localeCompare(b.id));
|
|
189
|
+
const signals = topo
|
|
190
|
+
.listSignals()
|
|
191
|
+
.toSorted((a, b) => a.id.localeCompare(b.id));
|
|
192
|
+
return {
|
|
193
|
+
crossings: normalizeCrossingRows(trails, snapshotId),
|
|
194
|
+
examples: normalizeExampleRows(trails, snapshotId),
|
|
195
|
+
fires: normalizeFiresRows(trails, snapshotId),
|
|
196
|
+
on: normalizeOnRows(trails, snapshotId),
|
|
197
|
+
resources: normalizeResourceRows(resources, snapshotId),
|
|
198
|
+
signals: normalizeSignalRows(signals, snapshotId),
|
|
199
|
+
surfaces: normalizeSurfaceRows(trails, snapshotId),
|
|
200
|
+
trailResources: normalizeTrailResourceRows(trails, snapshotId),
|
|
201
|
+
trailSignals: normalizeTrailSignalRows(signals, snapshotId),
|
|
202
|
+
trails: normalizeTrailRows(trails, snapshotId),
|
|
203
|
+
};
|
|
204
|
+
};
|
|
205
|
+
/**
|
|
206
|
+
* Look up a cached JSON schema by content hash.
|
|
207
|
+
*
|
|
208
|
+
* The query matches on `zod_hash` without filtering by `snapshot_id` because the
|
|
209
|
+
* cache is intentionally cross-snapshot: if the Zod schema definition has not
|
|
210
|
+
* changed (same hash), the serialized JSON Schema is reused regardless of
|
|
211
|
+
* which snapshot produced it. This is safe as long as `zodToJsonSchema` is
|
|
212
|
+
* deterministic for a given `_def` hash — the `schemaDefinitionHash` pipeline
|
|
213
|
+
* guarantees that structurally identical schemas produce the same hash.
|
|
214
|
+
*/
|
|
215
|
+
const readCachedJsonSchema = (db, ownerId, ownerKind, schemaKind, zodHash) => {
|
|
216
|
+
const row = db
|
|
217
|
+
.query(`SELECT json_schema
|
|
218
|
+
FROM topo_schemas
|
|
219
|
+
WHERE owner_id = ?
|
|
220
|
+
AND owner_kind = ?
|
|
221
|
+
AND schema_kind = ?
|
|
222
|
+
AND zod_hash = ?
|
|
223
|
+
LIMIT 1`)
|
|
224
|
+
.get(ownerId, ownerKind, schemaKind, zodHash);
|
|
225
|
+
return row?.json_schema;
|
|
226
|
+
};
|
|
227
|
+
const resolveSchemaRow = (db, ownerId, ownerKind, snapshotId, schemaKind, schema) => {
|
|
228
|
+
const zodHash = schemaDefinitionHash(schema);
|
|
229
|
+
const cachedJson = readCachedJsonSchema(db, ownerId, ownerKind, schemaKind, zodHash);
|
|
230
|
+
if (cachedJson !== undefined) {
|
|
231
|
+
return {
|
|
232
|
+
row: {
|
|
233
|
+
jsonSchema: cachedJson,
|
|
234
|
+
ownerId,
|
|
235
|
+
ownerKind,
|
|
236
|
+
schemaKind,
|
|
237
|
+
snapshotId,
|
|
238
|
+
zodHash,
|
|
239
|
+
},
|
|
240
|
+
value: parseJsonRecord(cachedJson),
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
const generated = sortedJsonSchema(schema);
|
|
244
|
+
return {
|
|
245
|
+
row: {
|
|
246
|
+
jsonSchema: generated.json,
|
|
247
|
+
ownerId,
|
|
248
|
+
ownerKind,
|
|
249
|
+
schemaKind,
|
|
250
|
+
snapshotId,
|
|
251
|
+
zodHash,
|
|
252
|
+
},
|
|
253
|
+
value: generated.value,
|
|
254
|
+
};
|
|
255
|
+
};
|
|
256
|
+
const materializeTrailSchema = (db, snapshotId, trail) => {
|
|
257
|
+
const inputSchema = resolveSchemaRow(db, trail.id, 'trail', snapshotId, 'input', trail.input);
|
|
258
|
+
if (trail.output === undefined) {
|
|
259
|
+
return {
|
|
260
|
+
rows: [inputSchema.row],
|
|
261
|
+
value: {
|
|
262
|
+
input: inputSchema.value,
|
|
263
|
+
},
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
const outputSchema = resolveSchemaRow(db, trail.id, 'trail', snapshotId, 'output', trail.output);
|
|
267
|
+
return {
|
|
268
|
+
rows: [inputSchema.row, outputSchema.row],
|
|
269
|
+
value: {
|
|
270
|
+
input: inputSchema.value,
|
|
271
|
+
output: outputSchema.value,
|
|
272
|
+
},
|
|
273
|
+
};
|
|
274
|
+
};
|
|
275
|
+
const materializeTrailSchemas = (db, snapshotId, trails) => {
|
|
276
|
+
const rows = [];
|
|
277
|
+
const trailSchemas = new Map();
|
|
278
|
+
for (const trail of trails) {
|
|
279
|
+
const materialized = materializeTrailSchema(db, snapshotId, trail);
|
|
280
|
+
rows.push(...materialized.rows);
|
|
281
|
+
trailSchemas.set(trail.id, materialized.value);
|
|
282
|
+
}
|
|
283
|
+
return {
|
|
284
|
+
rows,
|
|
285
|
+
trailSchemas,
|
|
286
|
+
};
|
|
287
|
+
};
|
|
288
|
+
const materializeSignalSchemas = (db, snapshotId, signals) => {
|
|
289
|
+
const rows = [];
|
|
290
|
+
const signalPayloads = new Map();
|
|
291
|
+
for (const signal of signals) {
|
|
292
|
+
const payloadSchema = resolveSchemaRow(db, signal.id, 'signal', snapshotId, 'payload', signal.payload);
|
|
293
|
+
rows.push(payloadSchema.row);
|
|
294
|
+
signalPayloads.set(signal.id, payloadSchema.value);
|
|
295
|
+
}
|
|
296
|
+
return {
|
|
297
|
+
rows,
|
|
298
|
+
signalPayloads,
|
|
299
|
+
};
|
|
300
|
+
};
|
|
301
|
+
const materializeSchemas = (db, snapshotId, signals, trails) => {
|
|
302
|
+
const trailMaterial = materializeTrailSchemas(db, snapshotId, trails);
|
|
303
|
+
const signalMaterial = materializeSignalSchemas(db, snapshotId, signals);
|
|
304
|
+
return {
|
|
305
|
+
rows: [...trailMaterial.rows, ...signalMaterial.rows],
|
|
306
|
+
signalPayloads: signalMaterial.signalPayloads,
|
|
307
|
+
trailSchemas: trailMaterial.trailSchemas,
|
|
308
|
+
};
|
|
309
|
+
};
|
|
310
|
+
const extractTrailheads = (raw) => Array.isArray(raw['trailheads'])
|
|
311
|
+
? raw['trailheads'].toSorted()
|
|
312
|
+
: [];
|
|
313
|
+
const addSafetyMarkers = (entry, trail) => {
|
|
314
|
+
if (trail.intent !== 'write') {
|
|
315
|
+
entry['intent'] = trail.intent;
|
|
316
|
+
}
|
|
317
|
+
if (trail.idempotent === true) {
|
|
318
|
+
entry['idempotent'] = true;
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
const addExtendedMetadata = (entry, raw, trail) => {
|
|
322
|
+
if (raw['deprecated'] === true) {
|
|
323
|
+
entry['deprecated'] = true;
|
|
324
|
+
}
|
|
325
|
+
if (typeof raw['replacedBy'] === 'string') {
|
|
326
|
+
entry['replacedBy'] = raw['replacedBy'];
|
|
327
|
+
}
|
|
328
|
+
if (trail.detours.length > 0) {
|
|
329
|
+
entry['detours'] = trail.detours.map((d) => ({
|
|
330
|
+
maxAttempts: Math.max(1, Math.min(d.maxAttempts ?? 1, 5)),
|
|
331
|
+
on: d.on.name,
|
|
332
|
+
}));
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
const addTrailRelations = (entry, trail) => {
|
|
336
|
+
if (trail.crosses.length > 0) {
|
|
337
|
+
entry['crosses'] = trail.crosses.toSorted();
|
|
338
|
+
}
|
|
339
|
+
if (trail.contours.length > 0) {
|
|
340
|
+
entry['contours'] = trail.contours
|
|
341
|
+
.map((contour) => contour.name)
|
|
342
|
+
.toSorted();
|
|
343
|
+
}
|
|
344
|
+
if (trail.resources.length > 0) {
|
|
345
|
+
entry['resources'] = trail.resources
|
|
346
|
+
.map((resource) => resource.id)
|
|
347
|
+
.toSorted();
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
const buildTrailEntryBase = (trail, trailSchema) => {
|
|
351
|
+
const raw = trail;
|
|
352
|
+
const entry = {
|
|
353
|
+
cli: { path: deriveCliPath(trail.id) },
|
|
354
|
+
exampleCount: trail.examples?.length ?? 0,
|
|
355
|
+
id: trail.id,
|
|
356
|
+
input: trailSchema.input,
|
|
357
|
+
kind: trail.kind,
|
|
358
|
+
trailheads: extractTrailheads(raw),
|
|
359
|
+
};
|
|
360
|
+
if (trailSchema.output !== undefined) {
|
|
361
|
+
entry['output'] = trailSchema.output;
|
|
362
|
+
}
|
|
363
|
+
if (trail.description !== undefined) {
|
|
364
|
+
entry['description'] = trail.description;
|
|
365
|
+
}
|
|
366
|
+
if (trail.pattern !== undefined) {
|
|
367
|
+
entry['pattern'] = trail.pattern;
|
|
368
|
+
}
|
|
369
|
+
return {
|
|
370
|
+
entry,
|
|
371
|
+
raw,
|
|
372
|
+
};
|
|
373
|
+
};
|
|
374
|
+
const trailToEntryRecord = (trail, trailSchema) => {
|
|
375
|
+
const { entry, raw } = buildTrailEntryBase(trail, trailSchema);
|
|
376
|
+
addSafetyMarkers(entry, trail);
|
|
377
|
+
addExtendedMetadata(entry, raw, trail);
|
|
378
|
+
addTrailRelations(entry, trail);
|
|
379
|
+
return sortKeys(entry);
|
|
380
|
+
};
|
|
381
|
+
const signalToEntryRecord = (signal, payloadSchema) => {
|
|
382
|
+
const raw = signal;
|
|
383
|
+
const entry = {
|
|
384
|
+
exampleCount: 0,
|
|
385
|
+
id: signal.id,
|
|
386
|
+
input: payloadSchema,
|
|
387
|
+
kind: 'signal',
|
|
388
|
+
trailheads: extractTrailheads(raw),
|
|
389
|
+
};
|
|
390
|
+
if (signal.description !== undefined) {
|
|
391
|
+
entry['description'] = signal.description;
|
|
392
|
+
}
|
|
393
|
+
if (raw['deprecated'] === true) {
|
|
394
|
+
entry['deprecated'] = true;
|
|
395
|
+
}
|
|
396
|
+
if (typeof raw['replacedBy'] === 'string') {
|
|
397
|
+
entry['replacedBy'] = raw['replacedBy'];
|
|
398
|
+
}
|
|
399
|
+
return sortKeys(entry);
|
|
400
|
+
};
|
|
401
|
+
const resourceToEntryRecord = (resource) => {
|
|
402
|
+
const entry = {
|
|
403
|
+
exampleCount: 0,
|
|
404
|
+
id: resource.id,
|
|
405
|
+
kind: 'resource',
|
|
406
|
+
trailheads: [],
|
|
407
|
+
};
|
|
408
|
+
if (resource.description !== undefined) {
|
|
409
|
+
entry['description'] = resource.description;
|
|
410
|
+
}
|
|
411
|
+
if (resource.health !== undefined) {
|
|
412
|
+
entry['healthcheck'] = true;
|
|
413
|
+
}
|
|
414
|
+
return sortKeys(entry);
|
|
415
|
+
};
|
|
416
|
+
const contourToEntryRecord = (contour) => {
|
|
417
|
+
const schema = sortedJsonSchema(contour);
|
|
418
|
+
const entry = {
|
|
419
|
+
exampleCount: contour.examples?.length ?? 0,
|
|
420
|
+
id: contour.name,
|
|
421
|
+
identity: contour.identity,
|
|
422
|
+
kind: 'contour',
|
|
423
|
+
schema: schema.value,
|
|
424
|
+
trailheads: [],
|
|
425
|
+
};
|
|
426
|
+
const references = getContourReferences(contour);
|
|
427
|
+
if (references.length > 0) {
|
|
428
|
+
entry['references'] = references;
|
|
429
|
+
}
|
|
430
|
+
return sortKeys(entry);
|
|
431
|
+
};
|
|
432
|
+
const requireTrailSchema = (trailSchemas, trailId) => {
|
|
433
|
+
const schema = trailSchemas.get(trailId);
|
|
434
|
+
if (schema === undefined) {
|
|
435
|
+
throw new Error(`Missing cached trail schema for "${trailId}"`);
|
|
436
|
+
}
|
|
437
|
+
return schema;
|
|
438
|
+
};
|
|
439
|
+
const requireSignalPayload = (signalPayloads, signalId) => {
|
|
440
|
+
const payload = signalPayloads.get(signalId);
|
|
441
|
+
if (payload === undefined) {
|
|
442
|
+
throw new Error(`Missing cached signal schema for "${signalId}"`);
|
|
443
|
+
}
|
|
444
|
+
return payload;
|
|
445
|
+
};
|
|
446
|
+
const buildSurfaceMap = (contours, generatedAt, resources, signalPayloads, signals, trailSchemas, trails) => {
|
|
447
|
+
const entries = [
|
|
448
|
+
...contours.map((contour) => contourToEntryRecord(contour)),
|
|
449
|
+
...trails.map((trail) => trailToEntryRecord(trail, requireTrailSchema(trailSchemas, trail.id))),
|
|
450
|
+
...signals.map((signal) => signalToEntryRecord(signal, requireSignalPayload(signalPayloads, signal.id))),
|
|
451
|
+
...resources.map((resource) => resourceToEntryRecord(resource)),
|
|
452
|
+
].toSorted((a, b) => a.id.localeCompare(b.id));
|
|
453
|
+
return {
|
|
454
|
+
entries,
|
|
455
|
+
generatedAt,
|
|
456
|
+
version: '1.0',
|
|
457
|
+
};
|
|
458
|
+
};
|
|
459
|
+
const hashSurfaceMapRecord = (surfaceMap) => {
|
|
460
|
+
const { generatedAt: _unused, ...rest } = surfaceMap;
|
|
461
|
+
return hashValue(rest);
|
|
462
|
+
};
|
|
463
|
+
const entryPayload = (entry) => {
|
|
464
|
+
const { id: _unusedId, kind: _unusedKind, ...rest } = entry;
|
|
465
|
+
return sortKeys(rest);
|
|
466
|
+
};
|
|
467
|
+
const entriesForKind = (entries, kind) => Object.fromEntries(entries
|
|
468
|
+
.filter((entry) => entry.kind === kind)
|
|
469
|
+
.map((entry) => [entry.id, entryPayload(entry)]));
|
|
470
|
+
const buildSerializedLock = (hash, topo, surfaceMap) => sortKeys({
|
|
471
|
+
apps: sortKeys({
|
|
472
|
+
[topo.name]: sortKeys({
|
|
473
|
+
contours: entriesForKind(surfaceMap.entries, 'contour'),
|
|
474
|
+
resources: entriesForKind(surfaceMap.entries, 'resource'),
|
|
475
|
+
signals: entriesForKind(surfaceMap.entries, 'signal'),
|
|
476
|
+
trails: entriesForKind(surfaceMap.entries, 'trail'),
|
|
477
|
+
}),
|
|
478
|
+
}),
|
|
479
|
+
generatedAt: surfaceMap.generatedAt,
|
|
480
|
+
hash,
|
|
481
|
+
version: 1,
|
|
482
|
+
});
|
|
483
|
+
const buildStoredTopoExport = (db, snapshot, topo) => {
|
|
484
|
+
const contours = topo
|
|
485
|
+
.listContours()
|
|
486
|
+
.toSorted((a, b) => a.name.localeCompare(b.name));
|
|
487
|
+
const trails = topo.list().toSorted((a, b) => a.id.localeCompare(b.id));
|
|
488
|
+
const resources = topo
|
|
489
|
+
.listResources()
|
|
490
|
+
.toSorted((a, b) => a.id.localeCompare(b.id));
|
|
491
|
+
const signals = topo
|
|
492
|
+
.listSignals()
|
|
493
|
+
.toSorted((a, b) => a.id.localeCompare(b.id));
|
|
494
|
+
const schemas = materializeSchemas(db, snapshot.id, signals, trails);
|
|
495
|
+
const surfaceMap = buildSurfaceMap(contours, snapshot.createdAt, resources, schemas.signalPayloads, signals, schemas.trailSchemas, trails);
|
|
496
|
+
const surfaceHash = hashSurfaceMapRecord(surfaceMap);
|
|
497
|
+
const serializedLock = `${JSON.stringify(buildSerializedLock(surfaceHash, topo, surfaceMap), null, 2)}\n`;
|
|
498
|
+
return {
|
|
499
|
+
exportRow: {
|
|
500
|
+
serializedLock,
|
|
501
|
+
snapshotId: snapshot.id,
|
|
502
|
+
surfaceHash,
|
|
503
|
+
surfaceMap: `${JSON.stringify(surfaceMap, null, 2)}\n`,
|
|
504
|
+
},
|
|
505
|
+
schemaRows: schemas.rows,
|
|
506
|
+
};
|
|
507
|
+
};
|
|
508
|
+
const insertRows = (db, rows, statement, toParams) => {
|
|
509
|
+
for (const row of rows) {
|
|
510
|
+
db.run(statement, toParams(row));
|
|
511
|
+
}
|
|
512
|
+
};
|
|
513
|
+
const insertProjectedRows = (db, projection) => {
|
|
514
|
+
insertRows(db, projection.trails, `INSERT INTO topo_trails (
|
|
515
|
+
id, intent, idempotent, has_output, has_examples, example_count, description, pattern, meta, snapshot_id
|
|
516
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, (row) => [
|
|
517
|
+
row.id,
|
|
518
|
+
row.intent,
|
|
519
|
+
row.idempotent,
|
|
520
|
+
row.hasOutput,
|
|
521
|
+
row.hasExamples,
|
|
522
|
+
row.exampleCount,
|
|
523
|
+
row.description,
|
|
524
|
+
row.pattern,
|
|
525
|
+
row.meta,
|
|
526
|
+
row.snapshotId,
|
|
527
|
+
]);
|
|
528
|
+
insertRows(db, projection.crossings, 'INSERT INTO topo_crossings (source_id, target_id, snapshot_id) VALUES (?, ?, ?)', (row) => [row.sourceId, row.targetId, row.snapshotId]);
|
|
529
|
+
insertRows(db, projection.trailResources, `INSERT INTO topo_trail_resources (trail_id, resource_id, snapshot_id)
|
|
530
|
+
VALUES (?, ?, ?)`, (row) => [row.trailId, row.resourceId, row.snapshotId]);
|
|
531
|
+
insertRows(db, projection.resources, `INSERT INTO topo_resources (id, has_mock, has_health, snapshot_id)
|
|
532
|
+
VALUES (?, ?, ?, ?)`, (row) => [row.id, row.hasMock, row.hasHealth, row.snapshotId]);
|
|
533
|
+
insertRows(db, projection.signals, 'INSERT INTO topo_signals (id, description, snapshot_id) VALUES (?, ?, ?)', (row) => [row.id, row.description, row.snapshotId]);
|
|
534
|
+
insertRows(db, projection.trailSignals, `INSERT INTO topo_trail_signals (trail_id, signal_id, snapshot_id)
|
|
535
|
+
VALUES (?, ?, ?)`, (row) => [row.trailId, row.signalId, row.snapshotId]);
|
|
536
|
+
insertRows(db, projection.fires, `INSERT INTO topo_trail_fires (trail_id, signal_id, snapshot_id)
|
|
537
|
+
VALUES (?, ?, ?)`, (row) => [row.trailId, row.signalId, row.snapshotId]);
|
|
538
|
+
insertRows(db, projection.on, `INSERT INTO topo_trail_on (trail_id, signal_id, snapshot_id)
|
|
539
|
+
VALUES (?, ?, ?)`, (row) => [row.trailId, row.signalId, row.snapshotId]);
|
|
540
|
+
insertRows(db, projection.surfaces, `INSERT INTO topo_surfaces (trail_id, surface, derived_name, method, snapshot_id)
|
|
541
|
+
VALUES (?, ?, ?, ?, ?)`, (row) => [
|
|
542
|
+
row.trailId,
|
|
543
|
+
row.surface,
|
|
544
|
+
row.derivedName,
|
|
545
|
+
row.method,
|
|
546
|
+
row.snapshotId,
|
|
547
|
+
]);
|
|
548
|
+
insertRows(db, projection.examples, `INSERT INTO topo_examples (
|
|
549
|
+
id, trail_id, ordinal, name, description, input, expected, error, snapshot_id
|
|
550
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`, (row) => [
|
|
551
|
+
row.id,
|
|
552
|
+
row.trailId,
|
|
553
|
+
row.ordinal,
|
|
554
|
+
row.name,
|
|
555
|
+
row.description,
|
|
556
|
+
row.input,
|
|
557
|
+
row.expected,
|
|
558
|
+
row.error,
|
|
559
|
+
row.snapshotId,
|
|
560
|
+
]);
|
|
561
|
+
};
|
|
562
|
+
const insertSchemaRows = (db, rows) => {
|
|
563
|
+
insertRows(db, rows, `INSERT INTO topo_schemas (
|
|
564
|
+
owner_id, owner_kind, schema_kind, zod_hash, json_schema, snapshot_id
|
|
565
|
+
) VALUES (?, ?, ?, ?, ?, ?)`, (row) => [
|
|
566
|
+
row.ownerId,
|
|
567
|
+
row.ownerKind,
|
|
568
|
+
row.schemaKind,
|
|
569
|
+
row.zodHash,
|
|
570
|
+
row.jsonSchema,
|
|
571
|
+
row.snapshotId,
|
|
572
|
+
]);
|
|
573
|
+
};
|
|
574
|
+
const insertStoredExport = (db, exportRow) => {
|
|
575
|
+
db.run(`INSERT INTO topo_exports (
|
|
576
|
+
snapshot_id, surface_map, surface_hash, serialized_lock
|
|
577
|
+
) VALUES (?, ?, ?, ?)`, [
|
|
578
|
+
exportRow.snapshotId,
|
|
579
|
+
exportRow.surfaceMap,
|
|
580
|
+
exportRow.surfaceHash,
|
|
581
|
+
exportRow.serializedLock,
|
|
582
|
+
]);
|
|
583
|
+
};
|
|
584
|
+
export const getStoredTopoExport = (db, snapshotId) => {
|
|
585
|
+
const row = db
|
|
586
|
+
.query(`SELECT surface_map, surface_hash, serialized_lock
|
|
587
|
+
FROM topo_exports
|
|
588
|
+
WHERE snapshot_id = ?`)
|
|
589
|
+
.get(snapshotId);
|
|
590
|
+
if (row === undefined || row === null) {
|
|
591
|
+
return undefined;
|
|
592
|
+
}
|
|
593
|
+
return {
|
|
594
|
+
lockContent: row.serialized_lock,
|
|
595
|
+
surfaceHash: row.surface_hash,
|
|
596
|
+
surfaceMapJson: row.surface_map,
|
|
597
|
+
};
|
|
598
|
+
};
|
|
599
|
+
export const createTopoSnapshot = (db, topo, input) => {
|
|
600
|
+
const validated = validateEstablishedTopo(topo);
|
|
601
|
+
if (validated.isErr()) {
|
|
602
|
+
return Result.err(validated.error);
|
|
603
|
+
}
|
|
604
|
+
ensureTopoSnapshotSchema(db);
|
|
605
|
+
const snapshotInput = {
|
|
606
|
+
...input,
|
|
607
|
+
resourceCount: input?.resourceCount ?? topo.resources.size,
|
|
608
|
+
signalCount: input?.signalCount ?? topo.signals.size,
|
|
609
|
+
trailCount: input?.trailCount ?? topo.trails.size,
|
|
610
|
+
};
|
|
611
|
+
const snapshot = db.transaction(() => {
|
|
612
|
+
const record = insertTopoSnapshotRecord(db, snapshotInput);
|
|
613
|
+
const artifacts = buildStoredTopoExport(db, record, topo);
|
|
614
|
+
insertProjectedRows(db, normalizeTopoProjection(topo, record.id));
|
|
615
|
+
insertSchemaRows(db, artifacts.schemaRows);
|
|
616
|
+
insertStoredExport(db, artifacts.exportRow);
|
|
617
|
+
return record;
|
|
618
|
+
})();
|
|
619
|
+
return Result.ok(snapshot);
|
|
620
|
+
};
|
|
621
|
+
//# sourceMappingURL=topo-store.js.map
|