@paraharness/sqlite 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +64 -2
- package/dist/builders/compaction-config-builder.d.ts +66 -0
- package/dist/builders/compaction-config-builder.d.ts.map +1 -0
- package/dist/builders/compaction-config-builder.js +2 -0
- package/dist/builders/compaction-config-builder.js.map +1 -0
- package/dist/builders/create-compaction-config-builder.d.ts +14 -0
- package/dist/builders/create-compaction-config-builder.d.ts.map +1 -0
- package/dist/builders/create-compaction-config-builder.js +66 -0
- package/dist/builders/create-compaction-config-builder.js.map +1 -0
- package/dist/builders/create-sqlite-global-rules-builder.d.ts +15 -0
- package/dist/builders/create-sqlite-global-rules-builder.d.ts.map +1 -0
- package/dist/builders/create-sqlite-global-rules-builder.js +30 -0
- package/dist/builders/create-sqlite-global-rules-builder.js.map +1 -0
- package/dist/builders/create-sqlite-ledger-builder.d.ts +15 -0
- package/dist/builders/create-sqlite-ledger-builder.d.ts.map +1 -0
- package/dist/builders/create-sqlite-ledger-builder.js +31 -0
- package/dist/builders/create-sqlite-ledger-builder.js.map +1 -0
- package/dist/builders/create-sqlite-lessons-builder.d.ts +12 -0
- package/dist/builders/create-sqlite-lessons-builder.d.ts.map +1 -0
- package/dist/builders/create-sqlite-lessons-builder.js +23 -0
- package/dist/builders/create-sqlite-lessons-builder.js.map +1 -0
- package/dist/builders/create-sqlite-topology-builder.d.ts +12 -0
- package/dist/builders/create-sqlite-topology-builder.d.ts.map +1 -0
- package/dist/builders/create-sqlite-topology-builder.js +23 -0
- package/dist/builders/create-sqlite-topology-builder.js.map +1 -0
- package/dist/builders/internal/compaction-config-builder-state.d.ts +16 -0
- package/dist/builders/internal/compaction-config-builder-state.d.ts.map +1 -0
- package/dist/builders/internal/compaction-config-builder-state.js +2 -0
- package/dist/builders/internal/compaction-config-builder-state.js.map +1 -0
- package/dist/builders/sqlite-global-rules-builder.d.ts +17 -0
- package/dist/builders/sqlite-global-rules-builder.d.ts.map +1 -0
- package/dist/builders/sqlite-global-rules-builder.js +2 -0
- package/dist/builders/sqlite-global-rules-builder.js.map +1 -0
- package/dist/builders/sqlite-ledger-builder.d.ts +21 -0
- package/dist/builders/sqlite-ledger-builder.d.ts.map +1 -0
- package/dist/builders/sqlite-ledger-builder.js +2 -0
- package/dist/builders/sqlite-ledger-builder.js.map +1 -0
- package/dist/builders/sqlite-lessons-builder.d.ts +18 -0
- package/dist/builders/sqlite-lessons-builder.d.ts.map +1 -0
- package/dist/builders/sqlite-lessons-builder.js +2 -0
- package/dist/builders/sqlite-lessons-builder.js.map +1 -0
- package/dist/builders/sqlite-namespace-contract.d.ts +64 -0
- package/dist/builders/sqlite-namespace-contract.d.ts.map +1 -0
- package/dist/builders/sqlite-namespace-contract.js +2 -0
- package/dist/builders/sqlite-namespace-contract.js.map +1 -0
- package/dist/builders/sqlite-namespace.d.ts +9 -0
- package/dist/builders/sqlite-namespace.d.ts.map +1 -0
- package/dist/builders/sqlite-namespace.js +17 -0
- package/dist/builders/sqlite-namespace.js.map +1 -0
- package/dist/builders/sqlite-topology-builder.d.ts +18 -0
- package/dist/builders/sqlite-topology-builder.d.ts.map +1 -0
- package/dist/builders/sqlite-topology-builder.js +2 -0
- package/dist/builders/sqlite-topology-builder.js.map +1 -0
- package/dist/ddl/internal/open-sqlite-connection.d.ts +24 -0
- package/dist/ddl/internal/open-sqlite-connection.d.ts.map +1 -0
- package/dist/ddl/internal/open-sqlite-connection.js +65 -0
- package/dist/ddl/internal/open-sqlite-connection.js.map +1 -0
- package/dist/ddl/sqlite-schema.constants.d.ts +21 -0
- package/dist/ddl/sqlite-schema.constants.d.ts.map +1 -0
- package/dist/ddl/sqlite-schema.constants.js +134 -0
- package/dist/ddl/sqlite-schema.constants.js.map +1 -0
- package/dist/executors/create-sqlite-executors.d.ts +11 -0
- package/dist/executors/create-sqlite-executors.d.ts.map +1 -0
- package/dist/executors/create-sqlite-executors.js +38 -0
- package/dist/executors/create-sqlite-executors.js.map +1 -0
- package/dist/executors/sqlite-executors.constants.d.ts +9 -0
- package/dist/executors/sqlite-executors.constants.d.ts.map +1 -0
- package/dist/executors/sqlite-executors.constants.js +9 -0
- package/dist/executors/sqlite-executors.constants.js.map +1 -0
- package/dist/executors/sqlite-rules-source-executor.d.ts +15 -0
- package/dist/executors/sqlite-rules-source-executor.d.ts.map +1 -0
- package/dist/executors/sqlite-rules-source-executor.js +47 -0
- package/dist/executors/sqlite-rules-source-executor.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/stores/internal/admit-lesson-params.d.ts +16 -0
- package/dist/stores/internal/admit-lesson-params.d.ts.map +1 -0
- package/dist/stores/internal/admit-lesson-params.js +2 -0
- package/dist/stores/internal/admit-lesson-params.js.map +1 -0
- package/dist/stores/internal/compute-normalized-relevance.d.ts +47 -0
- package/dist/stores/internal/compute-normalized-relevance.d.ts.map +1 -0
- package/dist/stores/internal/compute-normalized-relevance.js +63 -0
- package/dist/stores/internal/compute-normalized-relevance.js.map +1 -0
- package/dist/stores/internal/mark-frame-tombstone-params.d.ts +16 -0
- package/dist/stores/internal/mark-frame-tombstone-params.d.ts.map +1 -0
- package/dist/stores/internal/mark-frame-tombstone-params.js +2 -0
- package/dist/stores/internal/mark-frame-tombstone-params.js.map +1 -0
- package/dist/stores/internal/record-terminal-receipt-params.d.ts +16 -0
- package/dist/stores/internal/record-terminal-receipt-params.d.ts.map +1 -0
- package/dist/stores/internal/record-terminal-receipt-params.js +2 -0
- package/dist/stores/internal/record-terminal-receipt-params.js.map +1 -0
- package/dist/stores/internal/sqlite-ledger-compaction-ops.d.ts +14 -0
- package/dist/stores/internal/sqlite-ledger-compaction-ops.d.ts.map +1 -0
- package/dist/stores/internal/sqlite-ledger-compaction-ops.js +29 -0
- package/dist/stores/internal/sqlite-ledger-compaction-ops.js.map +1 -0
- package/dist/stores/internal/sqlite-ledger-fork-operations.d.ts +33 -0
- package/dist/stores/internal/sqlite-ledger-fork-operations.d.ts.map +1 -0
- package/dist/stores/internal/sqlite-ledger-fork-operations.js +44 -0
- package/dist/stores/internal/sqlite-ledger-fork-operations.js.map +1 -0
- package/dist/stores/internal/sqlite-ledger-frame-operations.d.ts +24 -0
- package/dist/stores/internal/sqlite-ledger-frame-operations.d.ts.map +1 -0
- package/dist/stores/internal/sqlite-ledger-frame-operations.js +40 -0
- package/dist/stores/internal/sqlite-ledger-frame-operations.js.map +1 -0
- package/dist/stores/internal/sqlite-ledger-frame-ops.d.ts +50 -0
- package/dist/stores/internal/sqlite-ledger-frame-ops.d.ts.map +1 -0
- package/dist/stores/internal/sqlite-ledger-frame-ops.js +90 -0
- package/dist/stores/internal/sqlite-ledger-frame-ops.js.map +1 -0
- package/dist/stores/internal/sqlite-ledger-plan-and-fork-ops.d.ts +59 -0
- package/dist/stores/internal/sqlite-ledger-plan-and-fork-ops.d.ts.map +1 -0
- package/dist/stores/internal/sqlite-ledger-plan-and-fork-ops.js +90 -0
- package/dist/stores/internal/sqlite-ledger-plan-and-fork-ops.js.map +1 -0
- package/dist/stores/internal/sqlite-ledger-plan-operations.d.ts +40 -0
- package/dist/stores/internal/sqlite-ledger-plan-operations.d.ts.map +1 -0
- package/dist/stores/internal/sqlite-ledger-plan-operations.js +39 -0
- package/dist/stores/internal/sqlite-ledger-plan-operations.js.map +1 -0
- package/dist/stores/internal/sqlite-ledger-run-operations.d.ts +41 -0
- package/dist/stores/internal/sqlite-ledger-run-operations.d.ts.map +1 -0
- package/dist/stores/internal/sqlite-ledger-run-operations.js +89 -0
- package/dist/stores/internal/sqlite-ledger-run-operations.js.map +1 -0
- package/dist/stores/internal/sqlite-ledger-run-ops.d.ts +58 -0
- package/dist/stores/internal/sqlite-ledger-run-ops.d.ts.map +1 -0
- package/dist/stores/internal/sqlite-ledger-run-ops.js +80 -0
- package/dist/stores/internal/sqlite-ledger-run-ops.js.map +1 -0
- package/dist/stores/internal/sqlite-ledger-step-operations.d.ts +28 -0
- package/dist/stores/internal/sqlite-ledger-step-operations.d.ts.map +1 -0
- package/dist/stores/internal/sqlite-ledger-step-operations.js +53 -0
- package/dist/stores/internal/sqlite-ledger-step-operations.js.map +1 -0
- package/dist/stores/internal/sqlite-ledger-step-ops.d.ts +47 -0
- package/dist/stores/internal/sqlite-ledger-step-ops.d.ts.map +1 -0
- package/dist/stores/internal/sqlite-ledger-step-ops.js +89 -0
- package/dist/stores/internal/sqlite-ledger-step-ops.js.map +1 -0
- package/dist/stores/internal/sqlite-lesson-ops.d.ts +100 -0
- package/dist/stores/internal/sqlite-lesson-ops.d.ts.map +1 -0
- package/dist/stores/internal/sqlite-lesson-ops.js +178 -0
- package/dist/stores/internal/sqlite-lesson-ops.js.map +1 -0
- package/dist/stores/internal/sqlite-lesson-row.d.ts +28 -0
- package/dist/stores/internal/sqlite-lesson-row.d.ts.map +1 -0
- package/dist/stores/internal/sqlite-lesson-row.js +2 -0
- package/dist/stores/internal/sqlite-lesson-row.js.map +1 -0
- package/dist/stores/internal/sqlite-overlay-step-mutation-entry.d.ts +21 -0
- package/dist/stores/internal/sqlite-overlay-step-mutation-entry.d.ts.map +1 -0
- package/dist/stores/internal/sqlite-overlay-step-mutation-entry.js +2 -0
- package/dist/stores/internal/sqlite-overlay-step-mutation-entry.js.map +1 -0
- package/dist/stores/internal/sqlite-run-row.d.ts +36 -0
- package/dist/stores/internal/sqlite-run-row.d.ts.map +1 -0
- package/dist/stores/internal/sqlite-run-row.js +2 -0
- package/dist/stores/internal/sqlite-run-row.js.map +1 -0
- package/dist/stores/internal/sqlite-step-row.d.ts +32 -0
- package/dist/stores/internal/sqlite-step-row.d.ts.map +1 -0
- package/dist/stores/internal/sqlite-step-row.js +2 -0
- package/dist/stores/internal/sqlite-step-row.js.map +1 -0
- package/dist/stores/internal/sqlite-suspended-fork-row.d.ts +22 -0
- package/dist/stores/internal/sqlite-suspended-fork-row.d.ts.map +1 -0
- package/dist/stores/internal/sqlite-suspended-fork-row.js +2 -0
- package/dist/stores/internal/sqlite-suspended-fork-row.js.map +1 -0
- package/dist/stores/internal/sqlite-topology-base-row.d.ts +18 -0
- package/dist/stores/internal/sqlite-topology-base-row.d.ts.map +1 -0
- package/dist/stores/internal/sqlite-topology-base-row.js +2 -0
- package/dist/stores/internal/sqlite-topology-base-row.js.map +1 -0
- package/dist/stores/internal/sqlite-topology-commit-ops.d.ts +37 -0
- package/dist/stores/internal/sqlite-topology-commit-ops.d.ts.map +1 -0
- package/dist/stores/internal/sqlite-topology-commit-ops.js +58 -0
- package/dist/stores/internal/sqlite-topology-commit-ops.js.map +1 -0
- package/dist/stores/internal/sqlite-topology-overlay-commit.d.ts +25 -0
- package/dist/stores/internal/sqlite-topology-overlay-commit.d.ts.map +1 -0
- package/dist/stores/internal/sqlite-topology-overlay-commit.js +51 -0
- package/dist/stores/internal/sqlite-topology-overlay-commit.js.map +1 -0
- package/dist/stores/internal/sqlite-topology-overlay-ops.d.ts +61 -0
- package/dist/stores/internal/sqlite-topology-overlay-ops.d.ts.map +1 -0
- package/dist/stores/internal/sqlite-topology-overlay-ops.js +156 -0
- package/dist/stores/internal/sqlite-topology-overlay-ops.js.map +1 -0
- package/dist/stores/internal/sqlite-topology-overlay-row.d.ts +40 -0
- package/dist/stores/internal/sqlite-topology-overlay-row.d.ts.map +1 -0
- package/dist/stores/internal/sqlite-topology-overlay-row.js +2 -0
- package/dist/stores/internal/sqlite-topology-overlay-row.js.map +1 -0
- package/dist/stores/internal/sqlite-topology-overlay-sync.d.ts +72 -0
- package/dist/stores/internal/sqlite-topology-overlay-sync.d.ts.map +1 -0
- package/dist/stores/internal/sqlite-topology-overlay-sync.js +116 -0
- package/dist/stores/internal/sqlite-topology-overlay-sync.js.map +1 -0
- package/dist/stores/internal/sqlite-wire-frame-row.d.ts +26 -0
- package/dist/stores/internal/sqlite-wire-frame-row.d.ts.map +1 -0
- package/dist/stores/internal/sqlite-wire-frame-row.js +2 -0
- package/dist/stores/internal/sqlite-wire-frame-row.js.map +1 -0
- package/dist/stores/internal/three-way-merge-contract.d.ts +25 -0
- package/dist/stores/internal/three-way-merge-contract.d.ts.map +1 -0
- package/dist/stores/internal/three-way-merge-contract.js +76 -0
- package/dist/stores/internal/three-way-merge-contract.js.map +1 -0
- package/dist/stores/internal/update-continuation-stack-params.d.ts +17 -0
- package/dist/stores/internal/update-continuation-stack-params.d.ts.map +1 -0
- package/dist/stores/internal/update-continuation-stack-params.js +2 -0
- package/dist/stores/internal/update-continuation-stack-params.js.map +1 -0
- package/dist/stores/internal/update-contract-in-overlay-params.d.ts +16 -0
- package/dist/stores/internal/update-contract-in-overlay-params.d.ts.map +1 -0
- package/dist/stores/internal/update-contract-in-overlay-params.js +2 -0
- package/dist/stores/internal/update-contract-in-overlay-params.js.map +1 -0
- package/dist/stores/internal/validate-lane-dag.d.ts +59 -0
- package/dist/stores/internal/validate-lane-dag.d.ts.map +1 -0
- package/dist/stores/internal/validate-lane-dag.js +117 -0
- package/dist/stores/internal/validate-lane-dag.js.map +1 -0
- package/dist/stores/sqlite-ledger-store.d.ts +222 -0
- package/dist/stores/sqlite-ledger-store.d.ts.map +1 -0
- package/dist/stores/sqlite-ledger-store.js +295 -0
- package/dist/stores/sqlite-ledger-store.js.map +1 -0
- package/dist/stores/sqlite-lesson-store.d.ts +96 -0
- package/dist/stores/sqlite-lesson-store.d.ts.map +1 -0
- package/dist/stores/sqlite-lesson-store.js +121 -0
- package/dist/stores/sqlite-lesson-store.js.map +1 -0
- package/dist/stores/sqlite-topology-store.d.ts +112 -0
- package/dist/stores/sqlite-topology-store.d.ts.map +1 -0
- package/dist/stores/sqlite-topology-store.js +137 -0
- package/dist/stores/sqlite-topology-store.js.map +1 -0
- package/package.json +70 -3
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Raw SQLite row shape for `harness_suspended_forks`.
|
|
3
|
+
*
|
|
4
|
+
* Maps snake_case columns for suspended fork persistence, filtering, and recursive epoch resolution.
|
|
5
|
+
*/
|
|
6
|
+
export interface SqliteSuspendedForkRow {
|
|
7
|
+
/** Monotonic `${forkId}#${suspensionEpoch}` identifier. */
|
|
8
|
+
readonly suspended_fork_id: string;
|
|
9
|
+
/** Logical fork identifier. */
|
|
10
|
+
readonly fork_id: string;
|
|
11
|
+
/** Positive integer suspension epoch. */
|
|
12
|
+
readonly suspension_epoch: number;
|
|
13
|
+
/** Enclosing flow run identifier. */
|
|
14
|
+
readonly run_id: string;
|
|
15
|
+
/** Parent step execution identifier. */
|
|
16
|
+
readonly parent_step_exec_id: string;
|
|
17
|
+
/** Full JSON-serialized `SuspendedForkRecord`. */
|
|
18
|
+
readonly record_json: string;
|
|
19
|
+
/** Resolution status (`'RESUMED' | 'ABORTED' | null`). */
|
|
20
|
+
readonly resolution_status: string | null;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=sqlite-suspended-fork-row.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-suspended-fork-row.d.ts","sourceRoot":"","sources":["../../../src/stores/internal/sqlite-suspended-fork-row.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,2DAA2D;IAC3D,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,+BAA+B;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,yCAAyC;IACzC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,qCAAqC;IACrC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,wCAAwC;IACxC,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACrC,kDAAkD;IAClD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,0DAA0D;IAC1D,QAAQ,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-suspended-fork-row.js","sourceRoot":"","sources":["../../../src/stores/internal/sqlite-suspended-fork-row.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Raw SQLite row shape for `harness_topology_base`.
|
|
3
|
+
*
|
|
4
|
+
* Maps canonical base partition state columns for `SqliteTopologyStore`.
|
|
5
|
+
*/
|
|
6
|
+
export interface SqliteTopologyBaseRow {
|
|
7
|
+
/** Logical partition identifier. */
|
|
8
|
+
readonly partition_id: string;
|
|
9
|
+
/** Monotonic base epoch integer. */
|
|
10
|
+
readonly epoch: number;
|
|
11
|
+
/** Canonical contract text in the base store. */
|
|
12
|
+
readonly contract_text: string;
|
|
13
|
+
/** ISO-8601 timestamp of the last base update. */
|
|
14
|
+
readonly updated_at: string;
|
|
15
|
+
/** Run ID that most recently committed a mutation to this partition, or `null`. */
|
|
16
|
+
readonly last_mutated_by_run_id: string | null;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=sqlite-topology-base-row.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-topology-base-row.d.ts","sourceRoot":"","sources":["../../../src/stores/internal/sqlite-topology-base-row.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC,oCAAoC;IACpC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,oCAAoC;IACpC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,iDAAiD;IACjD,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,kDAAkD;IAClD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,mFAAmF;IACnF,QAAQ,CAAC,sBAAsB,EAAE,MAAM,GAAG,IAAI,CAAC;CAChD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-topology-base-row.js","sourceRoot":"","sources":["../../../src/stores/internal/sqlite-topology-base-row.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { CommitRunOverlayResult } from '@paraharness/core';
|
|
2
|
+
import type Database from 'better-sqlite3';
|
|
3
|
+
/**
|
|
4
|
+
* Transitions `runId`'s overlay rows to `status = 'SEALED_UNMERGED'` (`SPEC.md` §3.3).
|
|
5
|
+
*
|
|
6
|
+
* Allows dependent stacked runs to absorb the sealed overlay via `syncRunOverlays` without polluting the base store.
|
|
7
|
+
*
|
|
8
|
+
* @param {Database.Database} db - Active SQLite database handle.
|
|
9
|
+
* @param {string} runId - Completed flow run identifier.
|
|
10
|
+
*
|
|
11
|
+
* @returns {void} Returns nothing once the overlay is sealed.
|
|
12
|
+
*/
|
|
13
|
+
export declare function sealOverlayForRun(db: Database.Database, runId: string): void;
|
|
14
|
+
/**
|
|
15
|
+
* Atomically commits `runId`'s overlay (and any absorbed `SEALED_UNMERGED` prerequisite overlays)
|
|
16
|
+
* into `harness_topology_base` using a 3-way contract text merge (`SPEC.md` §3.3).
|
|
17
|
+
*
|
|
18
|
+
* Allocates `base.epoch = currentBase.epoch + 1` monotonically and returns `{ committedRunIds, updatedEpochs }`.
|
|
19
|
+
*
|
|
20
|
+
* @param {Database.Database} db - Active SQLite database handle.
|
|
21
|
+
* @param {string} runId - Flow run identifier whose overlay is committing.
|
|
22
|
+
*
|
|
23
|
+
* @returns {CommitRunOverlayResult} Committed run identifiers and newly allocated base epochs.
|
|
24
|
+
*/
|
|
25
|
+
export declare function commitOverlayThreeWayMerge(db: Database.Database, runId: string): CommitRunOverlayResult;
|
|
26
|
+
/**
|
|
27
|
+
* Discards all uncommitted or sealed overlay rows for `runId` without modifying `harness_topology_base`.
|
|
28
|
+
*
|
|
29
|
+
* Used when a run fails, triggers `discardOnSignal`, or exceeds `maxSealedAgeHours`.
|
|
30
|
+
*
|
|
31
|
+
* @param {Database.Database} db - Active SQLite database handle.
|
|
32
|
+
* @param {string} runId - Flow run identifier whose overlay should be discarded.
|
|
33
|
+
*
|
|
34
|
+
* @returns {void} Returns nothing once the overlay is removed.
|
|
35
|
+
*/
|
|
36
|
+
export declare function discardOverlayForRun(db: Database.Database, runId: string): void;
|
|
37
|
+
//# sourceMappingURL=sqlite-topology-commit-ops.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-topology-commit-ops.d.ts","sourceRoot":"","sources":["../../../src/stores/internal/sqlite-topology-commit-ops.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAO3C;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAI5E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,0BAA0B,CACxC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,KAAK,EAAE,MAAM,GACZ,sBAAsB,CAoBxB;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAE/E"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { collectCommittedSqliteRunIds, mergeAndCommitSqliteOverlayRow, } from './sqlite-topology-overlay-commit.js';
|
|
2
|
+
/**
|
|
3
|
+
* Transitions `runId`'s overlay rows to `status = 'SEALED_UNMERGED'` (`SPEC.md` §3.3).
|
|
4
|
+
*
|
|
5
|
+
* Allows dependent stacked runs to absorb the sealed overlay via `syncRunOverlays` without polluting the base store.
|
|
6
|
+
*
|
|
7
|
+
* @param {Database.Database} db - Active SQLite database handle.
|
|
8
|
+
* @param {string} runId - Completed flow run identifier.
|
|
9
|
+
*
|
|
10
|
+
* @returns {void} Returns nothing once the overlay is sealed.
|
|
11
|
+
*/
|
|
12
|
+
export function sealOverlayForRun(db, runId) {
|
|
13
|
+
db.prepare("UPDATE harness_topology_overlays SET status = 'SEALED_UNMERGED', updated_at = ? WHERE run_id = ?").run(new Date().toISOString(), runId);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Atomically commits `runId`'s overlay (and any absorbed `SEALED_UNMERGED` prerequisite overlays)
|
|
17
|
+
* into `harness_topology_base` using a 3-way contract text merge (`SPEC.md` §3.3).
|
|
18
|
+
*
|
|
19
|
+
* Allocates `base.epoch = currentBase.epoch + 1` monotonically and returns `{ committedRunIds, updatedEpochs }`.
|
|
20
|
+
*
|
|
21
|
+
* @param {Database.Database} db - Active SQLite database handle.
|
|
22
|
+
* @param {string} runId - Flow run identifier whose overlay is committing.
|
|
23
|
+
*
|
|
24
|
+
* @returns {CommitRunOverlayResult} Committed run identifiers and newly allocated base epochs.
|
|
25
|
+
*/
|
|
26
|
+
export function commitOverlayThreeWayMerge(db, runId) {
|
|
27
|
+
const overlayRows = db
|
|
28
|
+
.prepare('SELECT * FROM harness_topology_overlays WHERE run_id = ? AND (mutated_in_run = 1 OR has_uncommitted_changes = 1) ORDER BY partition_id ASC')
|
|
29
|
+
.all(runId);
|
|
30
|
+
const committedRunIds = collectCommittedSqliteRunIds(db, runId, overlayRows);
|
|
31
|
+
const updatedEpochs = new Map();
|
|
32
|
+
for (const ovRow of overlayRows) {
|
|
33
|
+
const newBaseEpoch = mergeAndCommitSqliteOverlayRow(db, ovRow, runId);
|
|
34
|
+
updatedEpochs.set(ovRow.partition_id, newBaseEpoch);
|
|
35
|
+
}
|
|
36
|
+
const deleteStmt = db.prepare('DELETE FROM harness_topology_overlays WHERE run_id = ?');
|
|
37
|
+
for (const committedId of committedRunIds) {
|
|
38
|
+
deleteStmt.run(committedId);
|
|
39
|
+
}
|
|
40
|
+
return Object.freeze({
|
|
41
|
+
committedRunIds,
|
|
42
|
+
updatedEpochs,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Discards all uncommitted or sealed overlay rows for `runId` without modifying `harness_topology_base`.
|
|
47
|
+
*
|
|
48
|
+
* Used when a run fails, triggers `discardOnSignal`, or exceeds `maxSealedAgeHours`.
|
|
49
|
+
*
|
|
50
|
+
* @param {Database.Database} db - Active SQLite database handle.
|
|
51
|
+
* @param {string} runId - Flow run identifier whose overlay should be discarded.
|
|
52
|
+
*
|
|
53
|
+
* @returns {void} Returns nothing once the overlay is removed.
|
|
54
|
+
*/
|
|
55
|
+
export function discardOverlayForRun(db, runId) {
|
|
56
|
+
db.prepare('DELETE FROM harness_topology_overlays WHERE run_id = ?').run(runId);
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=sqlite-topology-commit-ops.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-topology-commit-ops.js","sourceRoot":"","sources":["../../../src/stores/internal/sqlite-topology-commit-ops.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,qCAAqC,CAAC;AAG7C;;;;;;;;;GASG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAAqB,EAAE,KAAa;IACpE,EAAE,CAAC,OAAO,CACR,kGAAkG,CACnG,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,KAAK,CAAC,CAAC;AACzC,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,0BAA0B,CACxC,EAAqB,EACrB,KAAa;IAEb,MAAM,WAAW,GAAG,EAAE;SACnB,OAAO,CACN,4IAA4I,CAC7I;SACA,GAAG,CAAC,KAAK,CAA+B,CAAC;IAC5C,MAAM,eAAe,GAAG,4BAA4B,CAAC,EAAE,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;IAC7E,MAAM,aAAa,GAAG,IAAI,GAAG,EAAkB,CAAC;IAChD,KAAK,MAAM,KAAK,IAAI,WAAW,EAAE,CAAC;QAChC,MAAM,YAAY,GAAG,8BAA8B,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QACtE,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;IACtD,CAAC;IACD,MAAM,UAAU,GAAG,EAAE,CAAC,OAAO,CAAC,wDAAwD,CAAC,CAAC;IACxF,KAAK,MAAM,WAAW,IAAI,eAAe,EAAE,CAAC;QAC1C,UAAU,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC9B,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAyB;QAC3C,eAAe;QACf,aAAa;KACd,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,oBAAoB,CAAC,EAAqB,EAAE,KAAa;IACvE,EAAE,CAAC,OAAO,CAAC,wDAAwD,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAClF,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type Database from 'better-sqlite3';
|
|
2
|
+
import type { SqliteTopologyOverlayRow } from './sqlite-topology-overlay-row.js';
|
|
3
|
+
/**
|
|
4
|
+
* Collects all run IDs (`runId` plus any absorbed `SEALED_UNMERGED` prerequisite run IDs)
|
|
5
|
+
* whose overlays are being committed together in a single `commitRunOverlay` transaction.
|
|
6
|
+
*
|
|
7
|
+
* @param {Database.Database} db - Active SQLite database handle.
|
|
8
|
+
* @param {string} runId - Primary committing flow run identifier.
|
|
9
|
+
* @param {readonly SqliteTopologyOverlayRow[]} overlayRows - Modified overlay rows for `runId`.
|
|
10
|
+
*
|
|
11
|
+
* @returns {readonly string[]} Frozen list of committed run identifiers.
|
|
12
|
+
*/
|
|
13
|
+
export declare function collectCommittedSqliteRunIds(db: Database.Database, runId: string, overlayRows: readonly SqliteTopologyOverlayRow[]): readonly string[];
|
|
14
|
+
/**
|
|
15
|
+
* Merges a single `SqliteTopologyOverlayRow` into `harness_topology_base` via 3-way merge
|
|
16
|
+
* and allocates a monotonically increasing base epoch (`currentBase.epoch + 1`).
|
|
17
|
+
*
|
|
18
|
+
* @param {Database.Database} db - Active SQLite database handle.
|
|
19
|
+
* @param {SqliteTopologyOverlayRow} ovRow - Overlay partition row to merge and commit.
|
|
20
|
+
* @param {string} runId - Committing flow run identifier.
|
|
21
|
+
*
|
|
22
|
+
* @returns {number} Newly allocated canonical base epoch for `ovRow.partition_id`.
|
|
23
|
+
*/
|
|
24
|
+
export declare function mergeAndCommitSqliteOverlayRow(db: Database.Database, ovRow: SqliteTopologyOverlayRow, runId: string): number;
|
|
25
|
+
//# sourceMappingURL=sqlite-topology-overlay-commit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-topology-overlay-commit.d.ts","sourceRoot":"","sources":["../../../src/stores/internal/sqlite-topology-overlay-commit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAE3C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAGjF;;;;;;;;;GASG;AACH,wBAAgB,4BAA4B,CAC1C,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,SAAS,wBAAwB,EAAE,GAC/C,SAAS,MAAM,EAAE,CAenB;AAED;;;;;;;;;GASG;AACH,wBAAgB,8BAA8B,CAC5C,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,KAAK,EAAE,wBAAwB,EAC/B,KAAK,EAAE,MAAM,GACZ,MAAM,CAiBR"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { threeWayMergeContract } from './three-way-merge-contract.js';
|
|
2
|
+
/**
|
|
3
|
+
* Collects all run IDs (`runId` plus any absorbed `SEALED_UNMERGED` prerequisite run IDs)
|
|
4
|
+
* whose overlays are being committed together in a single `commitRunOverlay` transaction.
|
|
5
|
+
*
|
|
6
|
+
* @param {Database.Database} db - Active SQLite database handle.
|
|
7
|
+
* @param {string} runId - Primary committing flow run identifier.
|
|
8
|
+
* @param {readonly SqliteTopologyOverlayRow[]} overlayRows - Modified overlay rows for `runId`.
|
|
9
|
+
*
|
|
10
|
+
* @returns {readonly string[]} Frozen list of committed run identifiers.
|
|
11
|
+
*/
|
|
12
|
+
export function collectCommittedSqliteRunIds(db, runId, overlayRows) {
|
|
13
|
+
const committedSet = new Set();
|
|
14
|
+
const selectSealedStmt = db.prepare("SELECT 1 AS found FROM harness_topology_overlays WHERE run_id = ? AND status = 'SEALED_UNMERGED' LIMIT 1");
|
|
15
|
+
for (const ovRow of overlayRows) {
|
|
16
|
+
const absorbedIds = JSON.parse(ovRow.absorbed_run_ids_json);
|
|
17
|
+
for (const absorbedId of absorbedIds) {
|
|
18
|
+
if (selectSealedStmt.get(absorbedId) !== undefined) {
|
|
19
|
+
committedSet.add(absorbedId);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
committedSet.add(runId);
|
|
24
|
+
return Object.freeze(Array.from(committedSet));
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Merges a single `SqliteTopologyOverlayRow` into `harness_topology_base` via 3-way merge
|
|
28
|
+
* and allocates a monotonically increasing base epoch (`currentBase.epoch + 1`).
|
|
29
|
+
*
|
|
30
|
+
* @param {Database.Database} db - Active SQLite database handle.
|
|
31
|
+
* @param {SqliteTopologyOverlayRow} ovRow - Overlay partition row to merge and commit.
|
|
32
|
+
* @param {string} runId - Committing flow run identifier.
|
|
33
|
+
*
|
|
34
|
+
* @returns {number} Newly allocated canonical base epoch for `ovRow.partition_id`.
|
|
35
|
+
*/
|
|
36
|
+
export function mergeAndCommitSqliteOverlayRow(db, ovRow, runId) {
|
|
37
|
+
const baseRow = db
|
|
38
|
+
.prepare('SELECT * FROM harness_topology_base WHERE partition_id = ?')
|
|
39
|
+
.get(ovRow.partition_id);
|
|
40
|
+
const currentBaseEpoch = baseRow?.epoch ?? 0;
|
|
41
|
+
const currentBaseText = baseRow?.contract_text ?? '';
|
|
42
|
+
const acquireBase = currentBaseText === ovRow.initial_base_contract_text
|
|
43
|
+
? ovRow.initial_base_contract_text
|
|
44
|
+
: ovRow.base_contract_text_at_acquire;
|
|
45
|
+
const mergedText = threeWayMergeContract(acquireBase, currentBaseText, ovRow.contract_text);
|
|
46
|
+
const newBaseEpoch = currentBaseEpoch + 1;
|
|
47
|
+
const now = new Date().toISOString();
|
|
48
|
+
db.prepare('INSERT OR REPLACE INTO harness_topology_base (partition_id, epoch, contract_text, updated_at, last_mutated_by_run_id) VALUES (?, ?, ?, ?, ?)').run(ovRow.partition_id, newBaseEpoch, mergedText, now, ovRow.last_mutated_by_run_id ?? runId);
|
|
49
|
+
return newBaseEpoch;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=sqlite-topology-overlay-commit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-topology-overlay-commit.js","sourceRoot":"","sources":["../../../src/stores/internal/sqlite-topology-overlay-commit.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEtE;;;;;;;;;GASG;AACH,MAAM,UAAU,4BAA4B,CAC1C,EAAqB,EACrB,KAAa,EACb,WAAgD;IAEhD,MAAM,YAAY,GAAG,IAAI,GAAG,EAAU,CAAC;IACvC,MAAM,gBAAgB,GAAG,EAAE,CAAC,OAAO,CACjC,0GAA0G,CAC3G,CAAC;IACF,KAAK,MAAM,KAAK,IAAI,WAAW,EAAE,CAAC;QAChC,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,qBAAqB,CAAa,CAAC;QACxE,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;YACrC,IAAI,gBAAgB,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,SAAS,EAAE,CAAC;gBACnD,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC;IACH,CAAC;IACD,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACxB,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;AACjD,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,8BAA8B,CAC5C,EAAqB,EACrB,KAA+B,EAC/B,KAAa;IAEb,MAAM,OAAO,GAAG,EAAE;SACf,OAAO,CAAC,4DAA4D,CAAC;SACrE,GAAG,CAAC,KAAK,CAAC,YAAY,CAAsC,CAAC;IAChE,MAAM,gBAAgB,GAAG,OAAO,EAAE,KAAK,IAAI,CAAC,CAAC;IAC7C,MAAM,eAAe,GAAG,OAAO,EAAE,aAAa,IAAI,EAAE,CAAC;IACrD,MAAM,WAAW,GACf,eAAe,KAAK,KAAK,CAAC,0BAA0B;QAClD,CAAC,CAAC,KAAK,CAAC,0BAA0B;QAClC,CAAC,CAAC,KAAK,CAAC,6BAA6B,CAAC;IAC1C,MAAM,UAAU,GAAG,qBAAqB,CAAC,WAAW,EAAE,eAAe,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;IAC5F,MAAM,YAAY,GAAG,gBAAgB,GAAG,CAAC,CAAC;IAC1C,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACrC,EAAE,CAAC,OAAO,CACR,8IAA8I,CAC/I,CAAC,GAAG,CAAC,KAAK,CAAC,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,GAAG,EAAE,KAAK,CAAC,sBAAsB,IAAI,KAAK,CAAC,CAAC;IAChG,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { TopologyPartitionState } from '@paraharness/core';
|
|
2
|
+
import type Database from 'better-sqlite3';
|
|
3
|
+
import type { UpdateContractInOverlayParams } from './update-contract-in-overlay-params.js';
|
|
4
|
+
/**
|
|
5
|
+
* Options for resetting uncommitted overlay mutations in `resetRunOverlay`.
|
|
6
|
+
*/
|
|
7
|
+
export interface ResetRunOverlayOptions {
|
|
8
|
+
/** Rollback granularity (`'step'` for a single step execution or `'run'` for the entire run overlay). */
|
|
9
|
+
readonly scope?: 'step' | 'run';
|
|
10
|
+
/** Target `stepExecId` when `scope === 'step'`. */
|
|
11
|
+
readonly stepExecId?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Loads the partition graph for `runId` (merging any uncommitted CoW overlay over `harness_topology_base`).
|
|
15
|
+
*
|
|
16
|
+
* Pins `base_contract_text_at_acquire` when `runId` first inspects each base partition (`SPEC.md` §3.3).
|
|
17
|
+
*
|
|
18
|
+
* @param {Database.Database} db - Active SQLite database handle.
|
|
19
|
+
* @param {string} [runId] - Optional active flow run identifier.
|
|
20
|
+
*
|
|
21
|
+
* @returns {ReadonlyMap<string, TopologyPartitionState>} Partition state map keyed by `partitionId`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function getPartitionsWithOverlay(db: Database.Database, runId?: string): ReadonlyMap<string, TopologyPartitionState>;
|
|
24
|
+
/**
|
|
25
|
+
* Writes a contract update to `params.runId`'s isolated CoW overlay and increments `epoch` at most once per `(runId, partitionId)`.
|
|
26
|
+
*
|
|
27
|
+
* Tags the mutation with `params.stepExecId` so `resetOverlayByScope` can roll back individual steps (`SPEC.md` §3.3).
|
|
28
|
+
*
|
|
29
|
+
* @param {Database.Database} db - Active SQLite database handle.
|
|
30
|
+
* @param {UpdateContractInOverlayParams} params - Contract update parameters.
|
|
31
|
+
*
|
|
32
|
+
* @returns {{ readonly newEpoch: number }} Updated overlay epoch for `params.partitionId`.
|
|
33
|
+
*/
|
|
34
|
+
export declare function updateContractInOverlay(db: Database.Database, params: UpdateContractInOverlayParams): {
|
|
35
|
+
readonly newEpoch: number;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Merges `ACTIVE` or `SEALED_UNMERGED` prerequisite overlays into `targetRunId`'s overlay (`SPEC.md` §3.3).
|
|
39
|
+
*
|
|
40
|
+
* Preserves `lastMutatedByRunId` and advances `targetRunId`'s `base_contract_text_at_acquire` to the prerequisite's `contract_text`.
|
|
41
|
+
*
|
|
42
|
+
* @param {Database.Database} db - Active SQLite database handle.
|
|
43
|
+
* @param {string} targetRunId - Dependent run absorbing the prerequisite overlays.
|
|
44
|
+
* @param {readonly string[]} prerequisiteRunIds - Prerequisite run IDs to merge from.
|
|
45
|
+
*
|
|
46
|
+
* @returns {void} Returns nothing once prerequisite overlays are absorbed.
|
|
47
|
+
*/
|
|
48
|
+
export declare function syncPrerequisiteOverlays(db: Database.Database, targetRunId: string, prerequisiteRunIds: readonly string[]): void;
|
|
49
|
+
/**
|
|
50
|
+
* Resets uncommitted overlay mutations for `runId` at either the `'step'` or `'run'` scope (`SPEC.md` §3.3).
|
|
51
|
+
*
|
|
52
|
+
* Reverts only `opts.stepExecId` mutations when `scope === 'step'`, or reverts the entire run overlay to its baseline when `scope === 'run'`.
|
|
53
|
+
*
|
|
54
|
+
* @param {Database.Database} db - Active SQLite database handle.
|
|
55
|
+
* @param {string} runId - Target flow run identifier.
|
|
56
|
+
* @param {ResetRunOverlayOptions} [opts] - Reset scope options.
|
|
57
|
+
*
|
|
58
|
+
* @returns {void} Returns nothing once the overlay reset is committed.
|
|
59
|
+
*/
|
|
60
|
+
export declare function resetOverlayByScope(db: Database.Database, runId: string, opts?: ResetRunOverlayOptions): void;
|
|
61
|
+
//# sourceMappingURL=sqlite-topology-overlay-ops.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-topology-overlay-ops.d.ts","sourceRoot":"","sources":["../../../src/stores/internal/sqlite-topology-overlay-ops.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAQ3C,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AAE5F;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,yGAAyG;IACzG,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAChC,mDAAmD;IACnD,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CACtC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,KAAK,CAAC,EAAE,MAAM,GACb,WAAW,CAAC,MAAM,EAAE,sBAAsB,CAAC,CA4D7C;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACrC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,MAAM,EAAE,6BAA6B,GACpC;IAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CA6C/B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CACtC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,WAAW,EAAE,MAAM,EACnB,kBAAkB,EAAE,SAAS,MAAM,EAAE,GACpC,IAAI,CA0CN;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CACjC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,KAAK,EAAE,MAAM,EACb,IAAI,CAAC,EAAE,sBAAsB,GAC5B,IAAI,CA6CN"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { computeSyncedSqliteOverlayValues, resolveNextSqliteAcquireBase, } from './sqlite-topology-overlay-sync.js';
|
|
2
|
+
/**
|
|
3
|
+
* Loads the partition graph for `runId` (merging any uncommitted CoW overlay over `harness_topology_base`).
|
|
4
|
+
*
|
|
5
|
+
* Pins `base_contract_text_at_acquire` when `runId` first inspects each base partition (`SPEC.md` §3.3).
|
|
6
|
+
*
|
|
7
|
+
* @param {Database.Database} db - Active SQLite database handle.
|
|
8
|
+
* @param {string} [runId] - Optional active flow run identifier.
|
|
9
|
+
*
|
|
10
|
+
* @returns {ReadonlyMap<string, TopologyPartitionState>} Partition state map keyed by `partitionId`.
|
|
11
|
+
*/
|
|
12
|
+
export function getPartitionsWithOverlay(db, runId) {
|
|
13
|
+
const baseRows = db
|
|
14
|
+
.prepare('SELECT * FROM harness_topology_base ORDER BY partition_id ASC')
|
|
15
|
+
.all();
|
|
16
|
+
const partitions = new Map();
|
|
17
|
+
for (const baseRow of baseRows) {
|
|
18
|
+
partitions.set(baseRow.partition_id, Object.freeze({
|
|
19
|
+
partitionId: baseRow.partition_id,
|
|
20
|
+
epoch: baseRow.epoch,
|
|
21
|
+
contractText: baseRow.contract_text,
|
|
22
|
+
updatedAt: baseRow.updated_at,
|
|
23
|
+
lastMutatedByRunId: baseRow.last_mutated_by_run_id ?? undefined,
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
if (runId === undefined) {
|
|
27
|
+
return partitions;
|
|
28
|
+
}
|
|
29
|
+
const overlayRows = db
|
|
30
|
+
.prepare('SELECT * FROM harness_topology_overlays WHERE run_id = ? ORDER BY partition_id ASC')
|
|
31
|
+
.all(runId);
|
|
32
|
+
const overlayPartitions = new Set();
|
|
33
|
+
for (const ovRow of overlayRows) {
|
|
34
|
+
overlayPartitions.add(ovRow.partition_id);
|
|
35
|
+
if (ovRow.has_uncommitted_changes === 1 || ovRow.mutated_in_run === 1) {
|
|
36
|
+
partitions.set(ovRow.partition_id, Object.freeze({
|
|
37
|
+
partitionId: ovRow.partition_id,
|
|
38
|
+
epoch: ovRow.epoch,
|
|
39
|
+
contractText: ovRow.contract_text,
|
|
40
|
+
updatedAt: ovRow.updated_at,
|
|
41
|
+
lastMutatedByRunId: ovRow.last_mutated_by_run_id ?? undefined,
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const pinStmt = db.prepare("INSERT OR IGNORE INTO harness_topology_overlays (run_id, partition_id, epoch, contract_text, base_contract_text_at_acquire, initial_base_contract_text, baseline_contract_text, baseline_epoch, baseline_last_mutated_by_run_id, mutated_in_run, has_uncommitted_changes, last_mutated_by_run_id, status, updated_at, absorbed_run_ids_json, step_mutations_json) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, 0, 0, ?, 'ACTIVE', ?, '[]', '[]')");
|
|
46
|
+
for (const baseRow of baseRows) {
|
|
47
|
+
if (!overlayPartitions.has(baseRow.partition_id)) {
|
|
48
|
+
pinStmt.run(runId, baseRow.partition_id, baseRow.epoch, baseRow.contract_text, baseRow.contract_text, baseRow.contract_text, baseRow.contract_text, baseRow.epoch, baseRow.last_mutated_by_run_id, baseRow.last_mutated_by_run_id, baseRow.updated_at);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return partitions;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Writes a contract update to `params.runId`'s isolated CoW overlay and increments `epoch` at most once per `(runId, partitionId)`.
|
|
55
|
+
*
|
|
56
|
+
* Tags the mutation with `params.stepExecId` so `resetOverlayByScope` can roll back individual steps (`SPEC.md` §3.3).
|
|
57
|
+
*
|
|
58
|
+
* @param {Database.Database} db - Active SQLite database handle.
|
|
59
|
+
* @param {UpdateContractInOverlayParams} params - Contract update parameters.
|
|
60
|
+
*
|
|
61
|
+
* @returns {{ readonly newEpoch: number }} Updated overlay epoch for `params.partitionId`.
|
|
62
|
+
*/
|
|
63
|
+
export function updateContractInOverlay(db, params) {
|
|
64
|
+
const baseRow = db
|
|
65
|
+
.prepare('SELECT * FROM harness_topology_base WHERE partition_id = ?')
|
|
66
|
+
.get(params.partitionId);
|
|
67
|
+
const ovRow = db
|
|
68
|
+
.prepare('SELECT * FROM harness_topology_overlays WHERE run_id = ? AND partition_id = ?')
|
|
69
|
+
.get(params.runId, params.partitionId);
|
|
70
|
+
const now = new Date().toISOString();
|
|
71
|
+
const baseEpoch = baseRow?.epoch ?? 0;
|
|
72
|
+
const baseText = baseRow?.contract_text ?? '';
|
|
73
|
+
const baseLastRun = baseRow?.last_mutated_by_run_id ?? null;
|
|
74
|
+
const currentEpoch = ovRow !== undefined ? ovRow.epoch : baseEpoch;
|
|
75
|
+
const alreadyMutated = ovRow !== undefined && ovRow.mutated_in_run === 1;
|
|
76
|
+
const newEpoch = alreadyMutated ? currentEpoch : currentEpoch + 1;
|
|
77
|
+
const history = ovRow !== undefined
|
|
78
|
+
? JSON.parse(ovRow.step_mutations_json)
|
|
79
|
+
: [];
|
|
80
|
+
history.push({
|
|
81
|
+
stepExecId: params.stepExecId ?? null,
|
|
82
|
+
prevContractText: ovRow !== undefined ? ovRow.contract_text : baseText,
|
|
83
|
+
prevEpoch: currentEpoch,
|
|
84
|
+
prevMutatedInRun: ovRow !== undefined ? ovRow.mutated_in_run : 0,
|
|
85
|
+
prevHasUncommittedChanges: ovRow !== undefined ? ovRow.has_uncommitted_changes : 0,
|
|
86
|
+
prevLastMutatedByRunId: ovRow !== undefined ? ovRow.last_mutated_by_run_id : baseLastRun,
|
|
87
|
+
});
|
|
88
|
+
const acquireBase = resolveNextSqliteAcquireBase(ovRow, baseText);
|
|
89
|
+
db.prepare("INSERT OR REPLACE INTO harness_topology_overlays (run_id, partition_id, epoch, contract_text, base_contract_text_at_acquire, initial_base_contract_text, baseline_contract_text, baseline_epoch, baseline_last_mutated_by_run_id, mutated_in_run, has_uncommitted_changes, last_mutated_by_run_id, status, updated_at, absorbed_run_ids_json, step_mutations_json) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, 1, 1, ?, 'ACTIVE', ?, ?, ?)").run(params.runId, params.partitionId, newEpoch, params.newContractText, acquireBase, ovRow !== undefined ? ovRow.initial_base_contract_text : baseText, ovRow !== undefined ? ovRow.baseline_contract_text : baseText, ovRow !== undefined ? ovRow.baseline_epoch : baseEpoch, ovRow !== undefined ? ovRow.baseline_last_mutated_by_run_id : baseLastRun, params.runId, now, ovRow !== undefined ? ovRow.absorbed_run_ids_json : '[]', JSON.stringify(history));
|
|
90
|
+
return Object.freeze({ newEpoch });
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Merges `ACTIVE` or `SEALED_UNMERGED` prerequisite overlays into `targetRunId`'s overlay (`SPEC.md` §3.3).
|
|
94
|
+
*
|
|
95
|
+
* Preserves `lastMutatedByRunId` and advances `targetRunId`'s `base_contract_text_at_acquire` to the prerequisite's `contract_text`.
|
|
96
|
+
*
|
|
97
|
+
* @param {Database.Database} db - Active SQLite database handle.
|
|
98
|
+
* @param {string} targetRunId - Dependent run absorbing the prerequisite overlays.
|
|
99
|
+
* @param {readonly string[]} prerequisiteRunIds - Prerequisite run IDs to merge from.
|
|
100
|
+
*
|
|
101
|
+
* @returns {void} Returns nothing once prerequisite overlays are absorbed.
|
|
102
|
+
*/
|
|
103
|
+
export function syncPrerequisiteOverlays(db, targetRunId, prerequisiteRunIds) {
|
|
104
|
+
const now = new Date().toISOString();
|
|
105
|
+
const selectPrereqStmt = db.prepare("SELECT * FROM harness_topology_overlays WHERE run_id = ? AND status IN ('ACTIVE', 'SEALED_UNMERGED') AND (mutated_in_run = 1 OR has_uncommitted_changes = 1)");
|
|
106
|
+
const selectTargetStmt = db.prepare('SELECT * FROM harness_topology_overlays WHERE run_id = ? AND partition_id = ?');
|
|
107
|
+
const upsertStmt = db.prepare('INSERT OR REPLACE INTO harness_topology_overlays (run_id, partition_id, epoch, contract_text, base_contract_text_at_acquire, initial_base_contract_text, baseline_contract_text, baseline_epoch, baseline_last_mutated_by_run_id, mutated_in_run, has_uncommitted_changes, last_mutated_by_run_id, status, updated_at, absorbed_run_ids_json, step_mutations_json) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, ?, ?, ?, ?, ?)');
|
|
108
|
+
for (const prereqRunId of prerequisiteRunIds) {
|
|
109
|
+
const prereqRows = selectPrereqStmt.all(prereqRunId);
|
|
110
|
+
for (const prereqRow of prereqRows) {
|
|
111
|
+
const targetRow = selectTargetStmt.get(targetRunId, prereqRow.partition_id);
|
|
112
|
+
const synced = computeSyncedSqliteOverlayValues({
|
|
113
|
+
targetRunId,
|
|
114
|
+
prereqRunId,
|
|
115
|
+
prereqRow,
|
|
116
|
+
targetRow,
|
|
117
|
+
});
|
|
118
|
+
upsertStmt.run(targetRunId, prereqRow.partition_id, synced.nextEpoch, synced.mergedContractText, synced.nextAcquireBase, synced.initialBase, prereqRow.contract_text, synced.nextEpoch, prereqRow.last_mutated_by_run_id, synced.mutatedInRun, synced.nextLastMutatedBy, synced.status, now, synced.absorbedRunIdsJson, synced.stepMutationsJson);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Resets uncommitted overlay mutations for `runId` at either the `'step'` or `'run'` scope (`SPEC.md` §3.3).
|
|
124
|
+
*
|
|
125
|
+
* Reverts only `opts.stepExecId` mutations when `scope === 'step'`, or reverts the entire run overlay to its baseline when `scope === 'run'`.
|
|
126
|
+
*
|
|
127
|
+
* @param {Database.Database} db - Active SQLite database handle.
|
|
128
|
+
* @param {string} runId - Target flow run identifier.
|
|
129
|
+
* @param {ResetRunOverlayOptions} [opts] - Reset scope options.
|
|
130
|
+
*
|
|
131
|
+
* @returns {void} Returns nothing once the overlay reset is committed.
|
|
132
|
+
*/
|
|
133
|
+
export function resetOverlayByScope(db, runId, opts) {
|
|
134
|
+
const rows = db
|
|
135
|
+
.prepare('SELECT * FROM harness_topology_overlays WHERE run_id = ?')
|
|
136
|
+
.all(runId);
|
|
137
|
+
const now = new Date().toISOString();
|
|
138
|
+
if (opts?.scope === 'step' && opts.stepExecId !== undefined) {
|
|
139
|
+
for (const row of rows) {
|
|
140
|
+
const history = JSON.parse(row.step_mutations_json);
|
|
141
|
+
const firstMatchIdx = history.findIndex((entry) => entry.stepExecId === opts.stepExecId);
|
|
142
|
+
const restoreTarget = firstMatchIdx >= 0 ? history[firstMatchIdx] : undefined;
|
|
143
|
+
if (restoreTarget !== undefined) {
|
|
144
|
+
const remaining = history.slice(0, firstMatchIdx);
|
|
145
|
+
db.prepare('UPDATE harness_topology_overlays SET contract_text = ?, epoch = ?, mutated_in_run = ?, has_uncommitted_changes = ?, last_mutated_by_run_id = ?, step_mutations_json = ?, updated_at = ? WHERE run_id = ? AND partition_id = ?').run(restoreTarget.prevContractText, restoreTarget.prevEpoch, restoreTarget.prevMutatedInRun, restoreTarget.prevHasUncommittedChanges, restoreTarget.prevLastMutatedByRunId, JSON.stringify(remaining), now, runId, row.partition_id);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
for (const row of rows) {
|
|
151
|
+
const hasSyncedBaseline = row.baseline_contract_text !== row.initial_base_contract_text ||
|
|
152
|
+
row.absorbed_run_ids_json !== '[]';
|
|
153
|
+
db.prepare("UPDATE harness_topology_overlays SET contract_text = ?, epoch = ?, mutated_in_run = 0, has_uncommitted_changes = ?, last_mutated_by_run_id = ?, step_mutations_json = '[]', updated_at = ? WHERE run_id = ? AND partition_id = ?").run(row.baseline_contract_text, row.baseline_epoch, hasSyncedBaseline ? 1 : 0, row.baseline_last_mutated_by_run_id, now, runId, row.partition_id);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=sqlite-topology-overlay-ops.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-topology-overlay-ops.js","sourceRoot":"","sources":["../../../src/stores/internal/sqlite-topology-overlay-ops.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,gCAAgC,EAChC,4BAA4B,GAC7B,MAAM,mCAAmC,CAAC;AAa3C;;;;;;;;;GASG;AACH,MAAM,UAAU,wBAAwB,CACtC,EAAqB,EACrB,KAAc;IAEd,MAAM,QAAQ,GAAG,EAAE;SAChB,OAAO,CAAC,+DAA+D,CAAC;SACxE,GAAG,EAA6B,CAAC;IACpC,MAAM,UAAU,GAAG,IAAI,GAAG,EAAkC,CAAC;IAC7D,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAA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C,SAAS,CAAC,SAAS,CAAC,EACzB,GAAG,EACH,KAAK,EACL,GAAG,CAAC,YAAY,CACjB,CAAC;YACJ,CAAC;QACH,CAAC;QACD,OAAO;IACT,CAAC;IACD,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,iBAAiB,GACrB,GAAG,CAAC,sBAAsB,KAAK,GAAG,CAAC,0BAA0B;YAC7D,GAAG,CAAC,qBAAqB,KAAK,IAAI,CAAC;QACrC,EAAE,CAAC,OAAO,CACR,kOAAkO,CACnO,CAAC,GAAG,CACH,GAAG,CAAC,sBAAsB,EAC1B,GAAG,CAAC,cAAc,EAClB,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EACzB,GAAG,CAAC,+BAA+B,EACnC,GAAG,EACH,KAAK,EACL,GAAG,CAAC,YAAY,CACjB,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Raw SQLite row shape for `harness_topology_overlays`.
|
|
3
|
+
*
|
|
4
|
+
* Tracks per-run Copy-on-Write partition overlays, pinned 3-way merge baselines, and step mutation history.
|
|
5
|
+
*/
|
|
6
|
+
export interface SqliteTopologyOverlayRow {
|
|
7
|
+
/** Active or sealed flow run identifier. */
|
|
8
|
+
readonly run_id: string;
|
|
9
|
+
/** Logical partition identifier. */
|
|
10
|
+
readonly partition_id: string;
|
|
11
|
+
/** Current overlay epoch number. */
|
|
12
|
+
readonly epoch: number;
|
|
13
|
+
/** Current overlay contract text. */
|
|
14
|
+
readonly contract_text: string;
|
|
15
|
+
/** Pinned 3-way merge-base contract text (advanced on `syncRunOverlays`). */
|
|
16
|
+
readonly base_contract_text_at_acquire: string;
|
|
17
|
+
/** Initial canonical base contract text when the overlay chain was first acquired. */
|
|
18
|
+
readonly initial_base_contract_text: string;
|
|
19
|
+
/** Run-start or synced-prerequisite baseline contract text for `scope: 'run'` resets. */
|
|
20
|
+
readonly baseline_contract_text: string;
|
|
21
|
+
/** Run-start or synced-prerequisite baseline epoch for `scope: 'run'` resets. */
|
|
22
|
+
readonly baseline_epoch: number;
|
|
23
|
+
/** Run-start or synced-prerequisite `last_mutated_by_run_id` for `scope: 'run'` resets. */
|
|
24
|
+
readonly baseline_last_mutated_by_run_id: string | null;
|
|
25
|
+
/** `1` if `updateContract` was already called in `run_id` since the last reset, `0` otherwise. */
|
|
26
|
+
readonly mutated_in_run: number;
|
|
27
|
+
/** `1` if the overlay carries uncommitted or absorbed prerequisite changes, `0` if purely pinned on read. */
|
|
28
|
+
readonly has_uncommitted_changes: number;
|
|
29
|
+
/** Run ID that most recently mutated this partition in the overlay lineage, or `null`. */
|
|
30
|
+
readonly last_mutated_by_run_id: string | null;
|
|
31
|
+
/** Overlay lifecycle status (`'ACTIVE' | 'SEALED_UNMERGED'`). */
|
|
32
|
+
readonly status: string;
|
|
33
|
+
/** ISO-8601 timestamp of the latest overlay update. */
|
|
34
|
+
readonly updated_at: string;
|
|
35
|
+
/** JSON-serialized `string[]` of prerequisite run IDs absorbed via `syncRunOverlays`. */
|
|
36
|
+
readonly absorbed_run_ids_json: string;
|
|
37
|
+
/** JSON-serialized `SqliteOverlayStepMutationEntry[]` for step-scoped rollback. */
|
|
38
|
+
readonly step_mutations_json: string;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=sqlite-topology-overlay-row.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-topology-overlay-row.d.ts","sourceRoot":"","sources":["../../../src/stores/internal/sqlite-topology-overlay-row.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC,4CAA4C;IAC5C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,oCAAoC;IACpC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,oCAAoC;IACpC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,qCAAqC;IACrC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,6EAA6E;IAC7E,QAAQ,CAAC,6BAA6B,EAAE,MAAM,CAAC;IAC/C,sFAAsF;IACtF,QAAQ,CAAC,0BAA0B,EAAE,MAAM,CAAC;IAC5C,yFAAyF;IACzF,QAAQ,CAAC,sBAAsB,EAAE,MAAM,CAAC;IACxC,iFAAiF;IACjF,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,2FAA2F;IAC3F,QAAQ,CAAC,+BAA+B,EAAE,MAAM,GAAG,IAAI,CAAC;IACxD,kGAAkG;IAClG,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,6GAA6G;IAC7G,QAAQ,CAAC,uBAAuB,EAAE,MAAM,CAAC;IACzC,0FAA0F;IAC1F,QAAQ,CAAC,sBAAsB,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/C,iEAAiE;IACjE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,uDAAuD;IACvD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,yFAAyF;IACzF,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC;IACvC,mFAAmF;IACnF,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;CACtC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-topology-overlay-row.js","sourceRoot":"","sources":["../../../src/stores/internal/sqlite-topology-overlay-row.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { SqliteTopologyOverlayRow } from './sqlite-topology-overlay-row.js';
|
|
2
|
+
/**
|
|
3
|
+
* Parameters for computing a merged SQLite overlay row when absorbing a prerequisite run's overlay.
|
|
4
|
+
*/
|
|
5
|
+
export interface ComputeSyncedSqliteOverlayParams {
|
|
6
|
+
/** Dependent run identifier absorbing the prerequisite overlay. */
|
|
7
|
+
readonly targetRunId: string;
|
|
8
|
+
/** Prerequisite run identifier being absorbed. */
|
|
9
|
+
readonly prereqRunId: string;
|
|
10
|
+
/** Prerequisite run's active or sealed overlay row. */
|
|
11
|
+
readonly prereqRow: SqliteTopologyOverlayRow;
|
|
12
|
+
/** Target run's existing overlay row for the same partition, if any. */
|
|
13
|
+
readonly targetRow: SqliteTopologyOverlayRow | undefined;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Computed column values for upserting an absorbed prerequisite overlay into `targetRunId`'s overlay.
|
|
17
|
+
*/
|
|
18
|
+
export interface SyncedSqliteOverlayValuesOptions {
|
|
19
|
+
/** Merged overlay epoch (`max(target.epoch, prereq.epoch)`). */
|
|
20
|
+
readonly nextEpoch: number;
|
|
21
|
+
/** 3-way merged contract text. */
|
|
22
|
+
readonly mergedContractText: string;
|
|
23
|
+
/** Updated `base_contract_text_at_acquire` for subsequent 3-way commit merges. */
|
|
24
|
+
readonly nextAcquireBase: string;
|
|
25
|
+
/** Preserved initial base contract text when `targetRunId` first acquired the partition. */
|
|
26
|
+
readonly initialBase: string;
|
|
27
|
+
/** Run identifier credited with the latest contract mutation. */
|
|
28
|
+
readonly nextLastMutatedBy: string | null;
|
|
29
|
+
/** JSON array of absorbed prerequisite run identifiers. */
|
|
30
|
+
readonly absorbedRunIdsJson: string;
|
|
31
|
+
/** Flag (`0` or `1`) indicating whether `targetRunId` itself mutated this partition. */
|
|
32
|
+
readonly mutatedInRun: number;
|
|
33
|
+
/** Overlay lifecycle status (`'ACTIVE'` or `'SEALED_UNMERGED'`). */
|
|
34
|
+
readonly status: string;
|
|
35
|
+
/** JSON-serialized step mutation rollback log. */
|
|
36
|
+
readonly stepMutationsJson: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Parameters for resolving a single field when folding a prerequisite overlay into a target overlay in SQLite.
|
|
40
|
+
*/
|
|
41
|
+
export interface ResolveSyncedSqliteOverlayFieldParams {
|
|
42
|
+
/** Prerequisite run's overlay row being absorbed. */
|
|
43
|
+
readonly prereqRow: SqliteTopologyOverlayRow;
|
|
44
|
+
/** Target run's existing overlay row, if any. */
|
|
45
|
+
readonly targetRow: SqliteTopologyOverlayRow | undefined;
|
|
46
|
+
/** Whether `prereqRow` already absorbed `targetRunId` (stacked child fold). */
|
|
47
|
+
readonly isStackedChildFold: boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Resolves the `base_contract_text_at_acquire` value to persist when updating a partition contract in an overlay.
|
|
51
|
+
*
|
|
52
|
+
* Preserves `ovRow.base_contract_text_at_acquire` when already mutated in the current run,
|
|
53
|
+
* uses `ovRow.baseline_contract_text` on the first mutation after a prerequisite sync,
|
|
54
|
+
* or falls back to `baseText` when creating a fresh overlay row.
|
|
55
|
+
*
|
|
56
|
+
* @param {SqliteTopologyOverlayRow | undefined} ovRow - Existing overlay row for `(runId, partitionId)`, if any.
|
|
57
|
+
* @param {string} baseText - Canonical base contract text.
|
|
58
|
+
*
|
|
59
|
+
* @returns {string} Acquire-base contract text to store on the overlay row.
|
|
60
|
+
*/
|
|
61
|
+
export declare function resolveNextSqliteAcquireBase(ovRow: SqliteTopologyOverlayRow | undefined, baseText: string): string;
|
|
62
|
+
/**
|
|
63
|
+
* Computes the merged overlay state when synchronizing `params.prereqRow` into `params.targetRunId`.
|
|
64
|
+
*
|
|
65
|
+
* Performs a 3-way contract merge when `targetRow` also mutated the partition and unions absorbed run IDs.
|
|
66
|
+
*
|
|
67
|
+
* @param {ComputeSyncedSqliteOverlayParams} params - Target and prerequisite overlay rows.
|
|
68
|
+
*
|
|
69
|
+
* @returns {SyncedSqliteOverlayValuesOptions} Computed column values for upserting the target overlay row.
|
|
70
|
+
*/
|
|
71
|
+
export declare function computeSyncedSqliteOverlayValues(params: ComputeSyncedSqliteOverlayParams): SyncedSqliteOverlayValuesOptions;
|
|
72
|
+
//# sourceMappingURL=sqlite-topology-overlay-sync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sql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