@nicia-ai/typegraph 0.66.0 → 0.67.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/CHANGELOG.md +34 -0
- package/README.md +15 -0
- package/dist/backend/drizzle/engine/index.cjs +6 -6
- package/dist/backend/drizzle/engine/index.d.cts +4 -4
- package/dist/backend/drizzle/engine/index.d.ts +4 -4
- package/dist/backend/drizzle/engine/index.js +1 -1
- package/dist/backend/postgres/index.cjs +15 -15
- package/dist/backend/postgres/index.d.cts +2 -2
- package/dist/backend/postgres/index.d.ts +2 -2
- package/dist/backend/postgres/index.js +1 -1
- package/dist/backend/postgres/pglite-store.cjs +1 -1
- package/dist/backend/postgres/pglite-store.js +1 -1
- package/dist/backend/postgres/pglite.cjs +3 -3
- package/dist/backend/postgres/pglite.js +2 -2
- package/dist/backend/sqlite/index.cjs +14 -14
- package/dist/backend/sqlite/index.d.cts +2 -2
- package/dist/backend/sqlite/index.d.ts +2 -2
- package/dist/backend/sqlite/index.js +1 -1
- package/dist/backend/sqlite/libsql.cjs +6 -6
- package/dist/backend/sqlite/libsql.js +1 -1
- package/dist/backend/sqlite/local-store.cjs +1 -1
- package/dist/backend/sqlite/local-store.js +1 -1
- package/dist/backend/sqlite/local.cjs +3 -3
- package/dist/backend/sqlite/local.js +2 -2
- package/dist/{chunk-MUEPEWMQ.js → chunk-2DJKHZQ4.js} +10 -2
- package/dist/chunk-2DJKHZQ4.js.map +1 -0
- package/dist/{chunk-TR7QTODF.js → chunk-55DGFZYC.js} +3 -3
- package/dist/{chunk-TR7QTODF.js.map → chunk-55DGFZYC.js.map} +1 -1
- package/dist/{chunk-WB55URNM.js → chunk-6CKSTY2D.js} +7 -3
- package/dist/chunk-6CKSTY2D.js.map +1 -0
- package/dist/{chunk-732VS5PW.cjs → chunk-ANMCKLZQ.cjs} +12 -12
- package/dist/{chunk-732VS5PW.cjs.map → chunk-ANMCKLZQ.cjs.map} +1 -1
- package/dist/{chunk-SSDHR2C2.js → chunk-EFSXK3DW.js} +3 -3
- package/dist/{chunk-SSDHR2C2.js.map → chunk-EFSXK3DW.js.map} +1 -1
- package/dist/{chunk-Y4X6ODVY.cjs → chunk-FS2GVO2T.cjs} +56 -56
- package/dist/{chunk-Y4X6ODVY.cjs.map → chunk-FS2GVO2T.cjs.map} +1 -1
- package/dist/{chunk-K7YACILO.cjs → chunk-GXHEGNI6.cjs} +9 -9
- package/dist/{chunk-K7YACILO.cjs.map → chunk-GXHEGNI6.cjs.map} +1 -1
- package/dist/{chunk-XQNKN3UF.cjs → chunk-MN325MG4.cjs} +10 -2
- package/dist/chunk-MN325MG4.cjs.map +1 -0
- package/dist/{chunk-BX42F7IJ.cjs → chunk-SSDLQPMY.cjs} +7 -2
- package/dist/chunk-SSDLQPMY.cjs.map +1 -0
- package/dist/{chunk-MGCPSR4C.cjs → chunk-WWSYGZED.cjs} +6 -6
- package/dist/{chunk-MGCPSR4C.cjs.map → chunk-WWSYGZED.cjs.map} +1 -1
- package/dist/{chunk-HSLP6CVG.js → chunk-YHMXF7OZ.js} +3 -3
- package/dist/{chunk-HSLP6CVG.js.map → chunk-YHMXF7OZ.js.map} +1 -1
- package/dist/{chunk-C3HNC3S6.js → chunk-ZONDBN6H.js} +3 -3
- package/dist/{chunk-C3HNC3S6.js.map → chunk-ZONDBN6H.js.map} +1 -1
- package/dist/graph-merge/index.cjs +500 -26
- package/dist/graph-merge/index.cjs.map +1 -1
- package/dist/graph-merge/index.d.cts +384 -2
- package/dist/graph-merge/index.d.ts +384 -2
- package/dist/graph-merge/index.js +485 -15
- package/dist/graph-merge/index.js.map +1 -1
- package/dist/index.cjs +63 -63
- package/dist/index.js +3 -3
- package/dist/{local-store-impl-J6TJG45N.cjs → local-store-impl-7SPBIS4M.cjs} +9 -9
- package/dist/{local-store-impl-J6TJG45N.cjs.map → local-store-impl-7SPBIS4M.cjs.map} +1 -1
- package/dist/{local-store-impl-XKWR46WQ.js → local-store-impl-E23EDYPV.js} +6 -6
- package/dist/{local-store-impl-XKWR46WQ.js.map → local-store-impl-E23EDYPV.js.map} +1 -1
- package/dist/{pglite-store-impl-KXD5VWC5.cjs → pglite-store-impl-U55HQ5ZY.cjs} +9 -9
- package/dist/{pglite-store-impl-KXD5VWC5.cjs.map → pglite-store-impl-U55HQ5ZY.cjs.map} +1 -1
- package/dist/{pglite-store-impl-LRZ4TO3H.js → pglite-store-impl-VAIEJZOU.js} +6 -6
- package/dist/{pglite-store-impl-LRZ4TO3H.js.map → pglite-store-impl-VAIEJZOU.js.map} +1 -1
- package/dist/{postgres-CRRB2qzy.d.ts → postgres-BbTYW3b_.d.ts} +1 -1
- package/dist/{postgres-BIm6TDfF.d.cts → postgres-Dp3MpyJt.d.cts} +1 -1
- package/dist/{profile-DVd70NA-.d.ts → profile-Ch5SSewK.d.ts} +6 -6
- package/dist/{profile-CjAffcQt.d.cts → profile-DppApFgt.d.cts} +6 -6
- package/dist/schema/index.cjs +27 -27
- package/dist/schema/index.js +2 -2
- package/dist/{sqlite-DX9H3L7z.d.cts → sqlite-BpRtjC36.d.cts} +1 -1
- package/dist/{sqlite-BNwQ5pd7.d.ts → sqlite-CH0Zq0Qv.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/chunk-BX42F7IJ.cjs.map +0 -1
- package/dist/chunk-MUEPEWMQ.js.map +0 -1
- package/dist/chunk-WB55URNM.js.map +0 -1
- package/dist/chunk-XQNKN3UF.cjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { gy as NodeId, a5 as NodeType, d0 as JsonValue,
|
|
1
|
+
import { gy as NodeId, a5 as NodeType, d0 as JsonValue, e as GraphDef, b_ as EngineRevision, fy as EdgeId, gB as NodeKinds, fX as GetNodeType, G as GraphIdentityConfig, aN as TypeGraphError, hd as TypeGraphErrorOptions, g as GraphBackend, fZ as GraphAnnotations, d1 as KindAnnotations, gr as MetaEdge, a4 as AnyEdgeType, bB as DeleteBehavior, e3 as TemporalMode, I as IndexDeclaration, cC as GraphExtensionVersion, c9 as ExtensionNodeDef, c3 as ExtensionEdgeDef, ce as ExtensionOntologyRelation, c7 as ExtensionIndex } from '../types-BynPp5kU.js';
|
|
2
2
|
export { C as ContributionDiagnostic, a as ContributionDiagnosticState, b as ContributionRepairEntry, c as ContributionRepairResult } from '../types-BynPp5kU.js';
|
|
3
3
|
import { b as Store, bn as IdentityAssertionWriteFacade, bL as Node, dL as TransactionContext, ek as EDGE_TEMPORAL_READ_NAMES, g as IdentityFacade, el as IDENTITY_READ_NAMES, E as EvolutionPlan, dT as UniqueIntrospection } from '../store-C8ZPl7OW.js';
|
|
4
4
|
export { B as BatchReadBuilder, C as CompiledOneStatementRead } from '../store-C8ZPl7OW.js';
|
|
@@ -1780,6 +1780,388 @@ declare function planCandidateWriteSetReview<G extends GraphDef>(args: PlanCandi
|
|
|
1780
1780
|
*/
|
|
1781
1781
|
declare function revalidateCandidateWriteSetReview<G extends GraphDef>(args: RevalidateCandidateWriteSetReviewArgs<G>): Promise<Result<MergeReviewRevalidation, MergeError>>;
|
|
1782
1782
|
|
|
1783
|
+
/**
|
|
1784
|
+
* Durable working-copy branches: a JSON-serializable descriptor for a
|
|
1785
|
+
* PERSISTENT working copy plus reopen / destroy operations over it.
|
|
1786
|
+
*
|
|
1787
|
+
* `branch()` produces an {@link GraphBranch} whose store/close handle lives
|
|
1788
|
+
* only in the process that minted it. A durable branch instead pairs the normal
|
|
1789
|
+
* {@link GraphBranch} with a {@link DurableBranchDescriptor} — a plain JSON
|
|
1790
|
+
* document the caller can store anywhere — so a LATER process can reconnect to
|
|
1791
|
+
* the SAME mutated working copy without cloning the base and without keeping an
|
|
1792
|
+
* in-memory map of open handles.
|
|
1793
|
+
*
|
|
1794
|
+
* The descriptor has two halves:
|
|
1795
|
+
*
|
|
1796
|
+
* - TypeGraph-owned fences: `kind`/`version`, the owning `graphId`, the
|
|
1797
|
+
* branch id, the `base@V` token the working copy forked from, the at-fork
|
|
1798
|
+
* schema anchor (explicitly absent for an unmanaged store), and the
|
|
1799
|
+
* at-fork engine revision when the working copy resolved `lineage`.
|
|
1800
|
+
* - An opaque, strategy-defined `store` locator. TypeGraph never interprets
|
|
1801
|
+
* it and never assumes a database URL, product, or dialect.
|
|
1802
|
+
*
|
|
1803
|
+
* TAMPER MODEL: the descriptor is a document the caller stores and later hands
|
|
1804
|
+
* back, so every TypeGraph-owned fence in it is UNTRUSTED. The durable host is
|
|
1805
|
+
* the authority: at seal time it persists the {@link DurableBranchOrigin} that
|
|
1806
|
+
* TypeGraph captured at the fork, and at reopen it ATTESTS the complete origin
|
|
1807
|
+
* it holds. Reopen refuses unless every descriptor fence equals the attested
|
|
1808
|
+
* origin — a tampered `graphId`/`definitionHash`/`base`/`branchId`/
|
|
1809
|
+
* `forkRevision`/`schemaAnchor`, including DELETING `schemaAnchor` from the
|
|
1810
|
+
* envelope, cannot relabel a fork, because the host's own record is the
|
|
1811
|
+
* reference. `destroy` is verified the same way before it deletes (see
|
|
1812
|
+
* {@link DurableWorkingCopyStrategy.destroy}), so swapping one working copy's
|
|
1813
|
+
* locator for another's cannot destroy the wrong allocation.
|
|
1814
|
+
*
|
|
1815
|
+
* DEFINITION IDENTITY is part of that origin and is INDEPENDENT of the optional
|
|
1816
|
+
* committed `schemaAnchor`: the host attests the `graphId` AND a version-blind
|
|
1817
|
+
* {@link getGraphDefinitionHash} of the caller's fork-time definition. An
|
|
1818
|
+
* unmanaged working copy (one that committed no schema row, so its
|
|
1819
|
+
* `schemaAnchor` is absent) therefore still refuses descriptor `graphId`
|
|
1820
|
+
* relabeling, reopening with a different `graphId`, and — the case a missing
|
|
1821
|
+
* anchor used to let through — a SAME-ID graph whose definition hashes
|
|
1822
|
+
* differently. Definition identity is the fork-time caller definition; the
|
|
1823
|
+
* branch's CURRENT committed schema may legitimately evolve after forking, so
|
|
1824
|
+
* reopen never compares the live schema row to the fork-time identity.
|
|
1825
|
+
*
|
|
1826
|
+
* The host lifecycle is split deliberately. `GraphBranch.close()` releases the
|
|
1827
|
+
* process's CONNECTION to the working copy — it must never delete it. Explicit
|
|
1828
|
+
* teardown is a separate strategy operation, {@link DurableWorkingCopyStrategy.destroy},
|
|
1829
|
+
* surfaced through {@link destroyDurableBranch}. This keeps the ephemeral
|
|
1830
|
+
* {@link ForkHandle.dispose}-deletes-the-fork contract out of the durable path,
|
|
1831
|
+
* where "the process closed its connection" and "the working copy is gone" are
|
|
1832
|
+
* different events.
|
|
1833
|
+
*
|
|
1834
|
+
* The at-fork schema anchor is IMMUTABLE FORK METADATA, never a statement about
|
|
1835
|
+
* the working copy's CURRENT schema: a branch may legitimately evolve its
|
|
1836
|
+
* committed schema after forking, and reopen must still succeed. Reopen therefore
|
|
1837
|
+
* never compares the live schema row to the anchor; it compares the descriptor's
|
|
1838
|
+
* anchor to the host's, and the caller's graph definition to the attested
|
|
1839
|
+
* definition hash. The merge path separately refuses a branch whose LIVE schema
|
|
1840
|
+
* moved (see `merge.ts`'s at-fork drift guard); reopen is not that gate.
|
|
1841
|
+
*
|
|
1842
|
+
* Backend-specific mechanics remain entirely within the strategy.
|
|
1843
|
+
*/
|
|
1844
|
+
|
|
1845
|
+
/**
|
|
1846
|
+
* A strategy-defined, JSON-serializable locator for one PERSISTENT working
|
|
1847
|
+
* copy. TypeGraph treats it as opaque data: it is carried inside a
|
|
1848
|
+
* {@link DurableBranchDescriptor} and handed back to the strategy on reopen and
|
|
1849
|
+
* destroy, never inspected. It must survive `JSON.parse(JSON.stringify(...))`
|
|
1850
|
+
* unchanged. It MUST be a non-secret identifier: TypeGraph returns it to the
|
|
1851
|
+
* caller. Connection strings, credentials, bearer tokens, and other secrets do
|
|
1852
|
+
* not belong here; keep those in strategy-owned configuration and resolve this
|
|
1853
|
+
* locator there. TypeGraph deliberately omits it from cleanup error details.
|
|
1854
|
+
*/
|
|
1855
|
+
type DurableStoreDescriptor = JsonValue;
|
|
1856
|
+
/**
|
|
1857
|
+
* The write-access guarantee a strategy acquired for one opened working copy.
|
|
1858
|
+
*
|
|
1859
|
+
* `engine-fenced` means the database provides sound cross-client isolation and
|
|
1860
|
+
* change fencing for the full Store planning/apply access pattern, across every
|
|
1861
|
+
* connection and process that could mutate the working copy.
|
|
1862
|
+
* `exclusive` means the host acquired an allocation-wide writer lease before
|
|
1863
|
+
* returning. That lease MUST exclude every other process and backend instance,
|
|
1864
|
+
* not merely serialize calls through one in-memory queue. TypeGraph releases it
|
|
1865
|
+
* after the Store backend closes; a failed release is retried by the next
|
|
1866
|
+
* `GraphBranch.close()` call.
|
|
1867
|
+
*
|
|
1868
|
+
* A backend that provides only `caller-serialized` access MUST use `exclusive`:
|
|
1869
|
+
* each backend instance owns a different in-process queue, so that declaration
|
|
1870
|
+
* alone does not serialize two durable reopen handles or two processes.
|
|
1871
|
+
*/
|
|
1872
|
+
type DurableWorkingCopyAccess = Readonly<{
|
|
1873
|
+
kind: "engine-fenced";
|
|
1874
|
+
}> | Readonly<{
|
|
1875
|
+
kind: "exclusive";
|
|
1876
|
+
leaseId: string;
|
|
1877
|
+
release: () => Promise<void>;
|
|
1878
|
+
}>;
|
|
1879
|
+
/** Why an authoritative native merge attempt could not safely run. */
|
|
1880
|
+
type NativeDurableMergeUnsupportedDimension = "branchOrigin" | "graphScope" | "nativeConflicts" | "planSemantics" | "targetFence";
|
|
1881
|
+
/**
|
|
1882
|
+
* Result of a host-native merge optimization attempt.
|
|
1883
|
+
*
|
|
1884
|
+
* `unsupported` proves that NO native merge SQL or host mutation ran; TypeGraph
|
|
1885
|
+
* then executes the complete portable plan application. `applied` proves the
|
|
1886
|
+
* strategy atomically validated every dimension named by
|
|
1887
|
+
* {@link DurableWorkingCopyStrategy.merge} and applied exactly the approved
|
|
1888
|
+
* plan. A refusal or uncertain/partial execution throws instead of returning
|
|
1889
|
+
* `unsupported`, because falling back after a possible native write would
|
|
1890
|
+
* double-apply the plan.
|
|
1891
|
+
*/
|
|
1892
|
+
type NativeDurableMergeResult = Readonly<{
|
|
1893
|
+
outcome: "applied";
|
|
1894
|
+
merged: MergedCounts;
|
|
1895
|
+
warnings?: readonly string[] | undefined;
|
|
1896
|
+
}> | Readonly<{
|
|
1897
|
+
outcome: "unsupported";
|
|
1898
|
+
dimensions: readonly [
|
|
1899
|
+
NativeDurableMergeUnsupportedDimension,
|
|
1900
|
+
...NativeDurableMergeUnsupportedDimension[]
|
|
1901
|
+
];
|
|
1902
|
+
}>;
|
|
1903
|
+
/**
|
|
1904
|
+
* The complete immutable TypeGraph origin of one durable working copy — every
|
|
1905
|
+
* TypeGraph-owned fork fence, with NO dependence on the descriptor: the graph
|
|
1906
|
+
* id and version-blind graph-definition hash identifying the fork-time caller
|
|
1907
|
+
* definition, the branch id, the `base@V` token it forked from, the at-fork
|
|
1908
|
+
* schema anchor (`undefined` meaning the working copy committed no schema row —
|
|
1909
|
+
* an EXPLICIT absent, so a descriptor that simply omits the field still
|
|
1910
|
+
* disagrees with a host that persisted one), and the at-fork engine revision
|
|
1911
|
+
* (`undefined` when the working copy resolved no lineage).
|
|
1912
|
+
*
|
|
1913
|
+
* `graphId` and `definitionHash` are REQUIRED and carry the definition identity
|
|
1914
|
+
* even when `schemaAnchor` is absent: an unmanaged working copy still has to
|
|
1915
|
+
* reject relabeling and same-id divergent definitions. The host persists this
|
|
1916
|
+
* at seal time and attests it at reopen/destroy; it is the reference every
|
|
1917
|
+
* descriptor fence is compared against.
|
|
1918
|
+
*/
|
|
1919
|
+
type DurableBranchOrigin = Readonly<{
|
|
1920
|
+
graphId: string;
|
|
1921
|
+
definitionHash: string;
|
|
1922
|
+
branchId: BranchId;
|
|
1923
|
+
base: BaseVersion;
|
|
1924
|
+
schemaAnchor: Readonly<{
|
|
1925
|
+
version: number;
|
|
1926
|
+
hash: string;
|
|
1927
|
+
}> | undefined;
|
|
1928
|
+
forkRevision: EngineRevision | undefined;
|
|
1929
|
+
}>;
|
|
1930
|
+
/**
|
|
1931
|
+
* The durable envelope for a branch: the TypeGraph-owned fences a reopen
|
|
1932
|
+
* re-validates plus the strategy's opaque store locator.
|
|
1933
|
+
*
|
|
1934
|
+
* `kind`/`version` identify the strategy's descriptor FORMAT. `graphId` and
|
|
1935
|
+
* `definitionHash` bind the descriptor to one fork-time graph definition, and
|
|
1936
|
+
* `branchId` to one working copy. `base`, `schemaAnchor` and `forkRevision` are
|
|
1937
|
+
* the same at-fork fences a live {@link GraphBranch} carries, captured when the
|
|
1938
|
+
* branch was created.
|
|
1939
|
+
*
|
|
1940
|
+
* The fences are untrusted on reopen — see the module doc's tamper model.
|
|
1941
|
+
* `schemaAnchor` is PRESENT with value `undefined` when the working copy
|
|
1942
|
+
* committed no schema row (an unmanaged store), mirroring `branch()`'s own
|
|
1943
|
+
* representation; JSON storage drops the key, and the host's own attestation
|
|
1944
|
+
* restores the distinction on reopen.
|
|
1945
|
+
*/
|
|
1946
|
+
type DurableBranchDescriptor<TStoreDescriptor extends DurableStoreDescriptor = DurableStoreDescriptor> = Readonly<{
|
|
1947
|
+
/** Stable strategy type tag; must equal the reopening strategy's `type`. */
|
|
1948
|
+
kind: string;
|
|
1949
|
+
/** Strategy descriptor format version; must equal the strategy's `version`. */
|
|
1950
|
+
version: number;
|
|
1951
|
+
/** The graph id the working copy belongs to. */
|
|
1952
|
+
graphId: string;
|
|
1953
|
+
/**
|
|
1954
|
+
* The version-blind graph-definition hash of the caller's fork-time
|
|
1955
|
+
* definition. Attested by the host, so it fences a same-id divergent
|
|
1956
|
+
* definition even for an unmanaged working copy with no `schemaAnchor`.
|
|
1957
|
+
*/
|
|
1958
|
+
definitionHash: string;
|
|
1959
|
+
/** The TypeGraph branch id the working copy is identified by. */
|
|
1960
|
+
branchId: BranchId;
|
|
1961
|
+
/** The immutable `base@V` token the working copy forked from. */
|
|
1962
|
+
base: BaseVersion;
|
|
1963
|
+
/** The strategy's opaque, JSON-serializable locator for the working copy. */
|
|
1964
|
+
store: TStoreDescriptor;
|
|
1965
|
+
/** The at-fork committed schema `(version, hash)`; `undefined` when unmanaged. */
|
|
1966
|
+
schemaAnchor?: Readonly<{
|
|
1967
|
+
version: number;
|
|
1968
|
+
hash: string;
|
|
1969
|
+
}> | undefined;
|
|
1970
|
+
/** The at-fork engine revision, when the working copy resolves `lineage`. */
|
|
1971
|
+
forkRevision?: EngineRevision | undefined;
|
|
1972
|
+
}>;
|
|
1973
|
+
/**
|
|
1974
|
+
* The host-owned half of a durable working copy: how a persistent working copy
|
|
1975
|
+
* is allocated, sealed, reconnected to, and explicitly destroyed.
|
|
1976
|
+
*
|
|
1977
|
+
* The create -> seal/abort protocol has explicit ownership:
|
|
1978
|
+
*
|
|
1979
|
+
* 1. `create` allocates the persistent working copy and returns a mutable
|
|
1980
|
+
* {@link Store} over it plus the opaque locator. Once `create` resolves,
|
|
1981
|
+
* TypeGraph owns the allocation and the returned store.
|
|
1982
|
+
* 2. TypeGraph captures the fork state off the store and calls `seal` with
|
|
1983
|
+
* the complete {@link DurableBranchOrigin}. The host MUST persist that
|
|
1984
|
+
* origin durably before `seal` resolves — it is what later attestations
|
|
1985
|
+
* compare a descriptor against.
|
|
1986
|
+
* 3. If capturing OR sealing fails, TypeGraph calls `abort`: the host releases
|
|
1987
|
+
* the just-created allocation (deleting it) so no orphan survives. `abort`
|
|
1988
|
+
* is only ever called on an allocation this same `create` produced, so it
|
|
1989
|
+
* need not verify identity; it MUST tolerate a partially-sealed allocation.
|
|
1990
|
+
* An `abort` failure does NOT mask the original capture/seal failure:
|
|
1991
|
+
* TypeGraph returns a {@link BranchError} preserving that original failure
|
|
1992
|
+
* as its `cause` and reports `details.allocationAborted: false`. The opaque
|
|
1993
|
+
* locator and raw cleanup error are deliberately NOT copied into error
|
|
1994
|
+
* details, where application logging could disclose host credentials or
|
|
1995
|
+
* other strategy-private data. Operator tooling can use the safe TypeGraph
|
|
1996
|
+
* branch id supplied to `create` to identify the orphan.
|
|
1997
|
+
*
|
|
1998
|
+
* `reopen` reconnects to an EXISTING working copy identified by `descriptor`
|
|
1999
|
+
* without cloning, and returns the complete origin the host PERSISTED for that
|
|
2000
|
+
* locator. TypeGraph refuses when any descriptor fence disagrees with that
|
|
2001
|
+
* attested origin. A reopen failure (missing or deleted store, unreachable
|
|
2002
|
+
* host) throws; the strategy must not leave an opened backend behind when it
|
|
2003
|
+
* throws.
|
|
2004
|
+
*
|
|
2005
|
+
* `destroy` is the ONLY operation that may delete or archive the persistent
|
|
2006
|
+
* working copy. It receives the locator AND the caller's expected origin and
|
|
2007
|
+
* MUST verify, atomically with respect to its own persistence, that the origin
|
|
2008
|
+
* stored for that locator equals `expectedOrigin` before deleting — otherwise a
|
|
2009
|
+
* descriptor whose locator was swapped for another working copy's would destroy
|
|
2010
|
+
* the wrong allocation. A mismatch refuses without deleting. Closing the
|
|
2011
|
+
* returned branch's `close()` releases just the connection and must leave the
|
|
2012
|
+
* working copy reopenable.
|
|
2013
|
+
*/
|
|
2014
|
+
type DurableWorkingCopyStrategy<G extends GraphDef, TStoreDescriptor extends DurableStoreDescriptor = DurableStoreDescriptor> = Readonly<{
|
|
2015
|
+
type: string;
|
|
2016
|
+
version: number;
|
|
2017
|
+
create: (baseStore: Store<G>, base: BaseVersion, branchId: BranchId) => Promise<Readonly<{
|
|
2018
|
+
store: Store<G>;
|
|
2019
|
+
descriptor: TStoreDescriptor;
|
|
2020
|
+
access: DurableWorkingCopyAccess;
|
|
2021
|
+
}>>;
|
|
2022
|
+
seal: (descriptor: TStoreDescriptor, origin: DurableBranchOrigin) => Promise<void>;
|
|
2023
|
+
abort: (descriptor: TStoreDescriptor) => Promise<void>;
|
|
2024
|
+
reopen: (graph: G, descriptor: TStoreDescriptor) => Promise<Readonly<{
|
|
2025
|
+
store: Store<G>;
|
|
2026
|
+
origin: DurableBranchOrigin;
|
|
2027
|
+
access: DurableWorkingCopyAccess;
|
|
2028
|
+
}>>;
|
|
2029
|
+
destroy: (descriptor: TStoreDescriptor, expectedOrigin: DurableBranchOrigin) => Promise<void>;
|
|
2030
|
+
/**
|
|
2031
|
+
* Optional authoritative host-native merge optimization.
|
|
2032
|
+
*
|
|
2033
|
+
* Before returning `applied`, the strategy MUST, atomically with the native
|
|
2034
|
+
* merge operation:
|
|
2035
|
+
*
|
|
2036
|
+
* 1. attest `expectedOrigin` against the same allocation `branch.store` is
|
|
2037
|
+
* connected to;
|
|
2038
|
+
* 2. validate `plan.target` on the exact target branch/session the host will
|
|
2039
|
+
* merge into;
|
|
2040
|
+
* 3. prove the host-native diff contains exactly `plan.writes`, including all
|
|
2041
|
+
* TypeGraph sidecars and no rows belonging to another graph or application;
|
|
2042
|
+
* 4. prove the plan needs no canonicalization, repointing, identity, callback,
|
|
2043
|
+
* provenance, or other semantic work the native merge would bypass; and
|
|
2044
|
+
* 5. report the actual applied counts.
|
|
2045
|
+
*
|
|
2046
|
+
* A whole-database merge primitive therefore qualifies only for an allocation
|
|
2047
|
+
* whose complete physical diff is owned by this graph and is byte-for-byte
|
|
2048
|
+
* equivalent to the approved TypeGraph plan. If any dimension cannot be
|
|
2049
|
+
* proven, return `unsupported` BEFORE executing host SQL; TypeGraph will apply
|
|
2050
|
+
* the plan through its portable transaction path.
|
|
2051
|
+
*/
|
|
2052
|
+
merge?: ((args: Readonly<{
|
|
2053
|
+
target: Store<G>;
|
|
2054
|
+
branch: GraphBranch<G>;
|
|
2055
|
+
descriptor: TStoreDescriptor;
|
|
2056
|
+
expectedOrigin: DurableBranchOrigin;
|
|
2057
|
+
plan: MergePlanArtifactV1;
|
|
2058
|
+
}>) => Promise<NativeDurableMergeResult>) | undefined;
|
|
2059
|
+
}>;
|
|
2060
|
+
/**
|
|
2061
|
+
* A normal {@link GraphBranch} paired with the serializable descriptor that
|
|
2062
|
+
* lets a later process reopen the SAME working copy. `branch` behaves exactly
|
|
2063
|
+
* like a `branch()` result — plan/merge APIs and `close()` are unchanged.
|
|
2064
|
+
*/
|
|
2065
|
+
type DurableBranch<G extends GraphDef, TStoreDescriptor extends DurableStoreDescriptor = DurableStoreDescriptor> = Readonly<{
|
|
2066
|
+
branch: GraphBranch<G>;
|
|
2067
|
+
descriptor: DurableBranchDescriptor<TStoreDescriptor>;
|
|
2068
|
+
}>;
|
|
2069
|
+
/**
|
|
2070
|
+
* Creates a durable working-copy branch of `baseStore`.
|
|
2071
|
+
*
|
|
2072
|
+
* Stamps the `base@V` token off the base, mints (or accepts) a {@link BranchId},
|
|
2073
|
+
* delegates materialization to `strategy.create`, captures the graph id and
|
|
2074
|
+
* version-blind definition hash, the at-fork schema anchor, and the engine
|
|
2075
|
+
* revision, then SEALS the complete origin into the host before returning the
|
|
2076
|
+
* normal {@link GraphBranch} together with its JSON-serializable
|
|
2077
|
+
* {@link DurableBranchDescriptor}.
|
|
2078
|
+
*
|
|
2079
|
+
* Returns a {@link Result}; any failure is wrapped in a {@link BranchError}.
|
|
2080
|
+
* Once `strategy.create` resolves, the working copy's store and persistent
|
|
2081
|
+
* allocation belong to this function: a capture or seal failure closes the
|
|
2082
|
+
* store and calls `strategy.abort`, so this never returns an unrecoverable
|
|
2083
|
+
* success and never leaves an orphan.
|
|
2084
|
+
*
|
|
2085
|
+
* @param baseStore - The store to fork. Remains untouched.
|
|
2086
|
+
* @param strategy - The durable working-copy strategy owning the host mechanics.
|
|
2087
|
+
* @param options - Optional `{ id }` to set an explicit branch id.
|
|
2088
|
+
*/
|
|
2089
|
+
declare function branchDurable<G extends GraphDef, TStoreDescriptor extends DurableStoreDescriptor = DurableStoreDescriptor>(baseStore: Store<G>, strategy: DurableWorkingCopyStrategy<G, TStoreDescriptor>, options?: BranchOptions): Promise<Result<DurableBranch<G, TStoreDescriptor>, BranchError>>;
|
|
2090
|
+
/**
|
|
2091
|
+
* Reconnects to an existing durable working copy and reconstructs the normal
|
|
2092
|
+
* {@link GraphBranch} for it.
|
|
2093
|
+
*
|
|
2094
|
+
* Validates, in order: descriptor shape/type/version, graph id agreement,
|
|
2095
|
+
* strategy reconnect, store graph id, and — the load-bearing step — every
|
|
2096
|
+
* descriptor fence against the complete origin the host attests. A tampered
|
|
2097
|
+
* `graphId`/`definitionHash`/`branchId`/`base`/`schemaAnchor`/`forkRevision`,
|
|
2098
|
+
* including a DELETED `schemaAnchor`, is refused here; the host's persisted
|
|
2099
|
+
* record is the reference, never the descriptor. Finally the caller's graph
|
|
2100
|
+
* definition must hash to the attested fork-time definition AND agree on graph
|
|
2101
|
+
* id (a different graph definition, even one reusing the graph id, is not the
|
|
2102
|
+
* branch that was forked). Because the definition identity is attested
|
|
2103
|
+
* independently of `schemaAnchor`, this holds for an unmanaged working copy
|
|
2104
|
+
* with no committed schema row.
|
|
2105
|
+
*
|
|
2106
|
+
* The working copy's CURRENT committed schema is deliberately NOT compared to
|
|
2107
|
+
* the anchor: a branch may evolve its schema after forking and must remain
|
|
2108
|
+
* reopenable — the anchor is immutable fork metadata, not current schema.
|
|
2109
|
+
*
|
|
2110
|
+
* Every refusal is a typed {@link BranchError}, and any backend the strategy
|
|
2111
|
+
* opened is closed before the refusal is returned. The persistent working copy
|
|
2112
|
+
* is NEVER deleted here.
|
|
2113
|
+
*
|
|
2114
|
+
* @param graph - The graph definition the working copy was built with.
|
|
2115
|
+
* @param descriptor - The serialized descriptor returned by {@link branchDurable}.
|
|
2116
|
+
* @param strategy - The SAME strategy that produced `descriptor`.
|
|
2117
|
+
*/
|
|
2118
|
+
declare function reopenDurableBranch<G extends GraphDef, TStoreDescriptor extends DurableStoreDescriptor = DurableStoreDescriptor>(graph: G, descriptor: DurableBranchDescriptor<TStoreDescriptor>, strategy: DurableWorkingCopyStrategy<G, TStoreDescriptor>): Promise<Result<GraphBranch<G>, BranchError>>;
|
|
2119
|
+
/**
|
|
2120
|
+
* Explicitly destroys (deletes or archives) the persistent working copy the
|
|
2121
|
+
* descriptor names. This is the ONLY operation that may do so; closing a
|
|
2122
|
+
* reopened branch's `close()` never reaches here.
|
|
2123
|
+
*
|
|
2124
|
+
* The complete descriptor origin is passed to the strategy alongside the
|
|
2125
|
+
* locator and MUST be verified against the host's persisted origin before
|
|
2126
|
+
* deletion, so a descriptor whose locator was swapped for another working
|
|
2127
|
+
* copy's cannot destroy the wrong allocation.
|
|
2128
|
+
*
|
|
2129
|
+
* Returns a {@link Result}: a malformed/wrong-strategy descriptor or a strategy
|
|
2130
|
+
* failure (including an identity mismatch) is a typed {@link BranchError}. After
|
|
2131
|
+
* a successful destroy, reopening the same descriptor fails.
|
|
2132
|
+
*/
|
|
2133
|
+
declare function destroyDurableBranch<G extends GraphDef, TStoreDescriptor extends DurableStoreDescriptor = DurableStoreDescriptor>(descriptor: DurableBranchDescriptor<TStoreDescriptor>, strategy: DurableWorkingCopyStrategy<G, TStoreDescriptor>): Promise<Result<void, BranchError>>;
|
|
2134
|
+
|
|
2135
|
+
/**
|
|
2136
|
+
* Applies an approved merge plan through an optional host-native merge command,
|
|
2137
|
+
* with the ordinary portable applier as the complete fallback.
|
|
2138
|
+
*
|
|
2139
|
+
* The native command is an optimization attempt, never a second source of merge
|
|
2140
|
+
* semantics. TypeGraph validates the serialized plan and durable envelope first.
|
|
2141
|
+
* The strategy may return `applied` only after atomically proving and honoring
|
|
2142
|
+
* every dimension in `DurableWorkingCopyStrategy.merge`; `unsupported` means it
|
|
2143
|
+
* executed no host mutation, so the full portable plan is safe to run.
|
|
2144
|
+
*/
|
|
2145
|
+
|
|
2146
|
+
/** Arguments for {@link applyDurableMergePlan}. */
|
|
2147
|
+
type ApplyDurableMergePlanArgs<G extends GraphDef, TStoreDescriptor extends DurableStoreDescriptor = DurableStoreDescriptor> = Readonly<{
|
|
2148
|
+
target: Store<G>;
|
|
2149
|
+
branch: GraphBranch<G>;
|
|
2150
|
+
descriptor: DurableBranchDescriptor<TStoreDescriptor>;
|
|
2151
|
+
strategy: DurableWorkingCopyStrategy<G, TStoreDescriptor>;
|
|
2152
|
+
plan: MergePlanArtifact;
|
|
2153
|
+
options?: MergePlanApplyOptions<NoInfer<G>> | undefined;
|
|
2154
|
+
}>;
|
|
2155
|
+
/**
|
|
2156
|
+
* Applies an approved durable-branch plan, preferring a proven-equivalent
|
|
2157
|
+
* host-native merge and otherwise using {@link applyMergePlan} unchanged.
|
|
2158
|
+
*
|
|
2159
|
+
* Native merge is deliberately skipped when callbacks or persisted provenance
|
|
2160
|
+
* are requested. Those dimensions belong to TypeGraph's transaction and
|
|
2161
|
+
* sidecar owners; a raw database branch merge cannot silently drop them.
|
|
2162
|
+
*/
|
|
2163
|
+
declare function applyDurableMergePlan<G extends GraphDef, TStoreDescriptor extends DurableStoreDescriptor = DurableStoreDescriptor>(args: ApplyDurableMergePlanArgs<G, TStoreDescriptor>): Promise<Result<MergeReport<G>, MergeError>>;
|
|
2164
|
+
|
|
1783
2165
|
/**
|
|
1784
2166
|
* Forks an isolated branch from an evolution plan's resulting graph, before
|
|
1785
2167
|
* the caller opens its schema-write transaction. The original Store remains
|
|
@@ -2241,4 +2623,4 @@ type KeylessConfig = Readonly<{
|
|
|
2241
2623
|
sortFields: readonly string[];
|
|
2242
2624
|
}>;
|
|
2243
2625
|
|
|
2244
|
-
export { type BaseAmbiguity, type BaseNodeLookup, type BaseVersion, BaseVersionMismatchError, BranchError, type BranchId, type BranchOptions, type BranchProvenance, CANDIDATE_WRITE_SET_FORMAT_VERSION, type CandidateDiagnostic, type CandidateDiagnostics, type CandidateDiagnosticsOptions, type CandidateSource, CandidateSourceError, type CandidateWriteSet, CandidateWriteSetError, CandidateWriteSetSchema, type CandidateWriteSetTarget, CandidateWriteSetTargetSchema, type ComparisonCeilingPolicy, type ConflictingValue, type DeleteModifyConflict, type DeleteModifyPolicy, type DroppedItem, type Embedder, type EntityRef, type EntityResolution, type ForkHandle, type ForkedWorkingCopyOptions, type GraphBranch, IdentityAssertionWriteFacade, IdentityMergeConflictError, type IngestionBranch, IngestionImportTarget, type IngestionNodeCollections, InvalidMergeOptionsError, InvalidMergePlanError, type KeylessConfig, MERGE_ERROR_CODES, MERGE_OPTION_DEFAULTS, MERGE_PLAN_DIGEST_ALGORITHM, MERGE_PLAN_FORMAT_VERSION, MERGE_REVIEW_FORMAT_VERSION, type MakeBackend, type MatchEvidence, MatchEvidenceError, type MatchSource, type MatchStrategy, type MergeBranch, MergeConflictError, MergeConstraintConflictError, type MergeConstraintConflictErrorDetails, MergeError, type MergeIncrementalArgs, type MergeOptions, type MergePlanAnchors, type MergePlanApplied, type MergePlanApplyOptions, type MergePlanArtifact, type MergePlanArtifactV1, type MergePlanArtifactV1Input, type MergePlanBranchAnchor, type MergePlanCandidateDiagnostic, type MergePlanCanonicalMapping, MergePlanCapabilityError, type MergePlanDiagnostics, type MergePlanDigest, MergePlanDigestMismatchError, type MergePlanEdgeDelete, type MergePlanEdgeUpsert, type MergePlanEntityRef, type MergePlanEntityResolution, type MergePlanGuards, type MergePlanIdentityAssertion, type MergePlanMatchEvidence, type MergePlanMatchSource, type MergePlanNodeDelete, type MergePlanNodeUpsert, MergePlanOriginMismatchError, type MergePlanProposedSummary, type MergePlanProvenanceOptions, type MergePlanReadContext, type MergePlanRetype, type MergePlanReview, type MergePlanRevisionFence, type MergePlanSchemaFence, MergePlanSchemaMismatchError, type MergePlanSimilarityStrategy, type MergePlanTargetFence, MergePlanTargetMismatchError, type MergePlanTypeReconciliation, type MergePlanWrites, MergePlanningStaleError, type MergeReport, type MergeReviewArtifact, type MergeReviewBaseline, type MergeReviewDifference, MergeReviewError, type MergeReviewPolicy, type MergeReviewRevalidation, type MergeReviewRow, type MergedCounts, type NormalizedMergeOptions, type PlanCandidateWriteSetArgs, type PlanCandidateWriteSetForEvolutionArgs, type PlanCandidateWriteSetReviewArgs, type PropertyConflict, type PropertyConflictPolicy, type ProvenanceGraph, type ProvenanceIndex, type ProvenanceNode, type ProvenanceQuery, type ProvenanceRecord, type ReconcileTypesMode, type ResolveConfig, type ResolveMap, type ResolvedCluster, Result, type RevalidateCandidateWriteSetReviewArgs, type SimilarityStrategy, SimilarityUnavailableError, type SourceScope, StaleMergePlanError, type TypeReconciliation, UnsupportedMergePlanVersionError, VALIDITY_END_TARGET_PRECEDENCE, type ValidityEndResolution, type WorkingCopyStrategy, applyMergePlan, applyMergePlanInTransaction, asBaseVersion, asBranchId, branch, branchForEvolution, captureCandidateWriteSetTarget, captureCandidateWriteSetTargetForEvolution, cloneWorkingCopyStrategy, computeBaseVersion, forkedWorkingCopyStrategy, ingestionBranch, merge, mergeIncremental, normalizeMergeOptions, openProvenanceStore, persistProvenanceRecords, planCandidateWriteSet, planCandidateWriteSetForEvolution, planCandidateWriteSetReview, planMerge, planMergeForEvolution, planMergeIncremental, provenanceGraphId, readProvenance, revalidateCandidateWriteSetReview };
|
|
2626
|
+
export { type ApplyDurableMergePlanArgs, type BaseAmbiguity, type BaseNodeLookup, type BaseVersion, BaseVersionMismatchError, BranchError, type BranchId, type BranchOptions, type BranchProvenance, CANDIDATE_WRITE_SET_FORMAT_VERSION, type CandidateDiagnostic, type CandidateDiagnostics, type CandidateDiagnosticsOptions, type CandidateSource, CandidateSourceError, type CandidateWriteSet, CandidateWriteSetError, CandidateWriteSetSchema, type CandidateWriteSetTarget, CandidateWriteSetTargetSchema, type ComparisonCeilingPolicy, type ConflictingValue, type DeleteModifyConflict, type DeleteModifyPolicy, type DroppedItem, type DurableBranch, type DurableBranchDescriptor, type DurableBranchOrigin, type DurableStoreDescriptor, type DurableWorkingCopyAccess, type DurableWorkingCopyStrategy, type Embedder, type EntityRef, type EntityResolution, type ForkHandle, type ForkedWorkingCopyOptions, type GraphBranch, IdentityAssertionWriteFacade, IdentityMergeConflictError, type IngestionBranch, IngestionImportTarget, type IngestionNodeCollections, InvalidMergeOptionsError, InvalidMergePlanError, type KeylessConfig, MERGE_ERROR_CODES, MERGE_OPTION_DEFAULTS, MERGE_PLAN_DIGEST_ALGORITHM, MERGE_PLAN_FORMAT_VERSION, MERGE_REVIEW_FORMAT_VERSION, type MakeBackend, type MatchEvidence, MatchEvidenceError, type MatchSource, type MatchStrategy, type MergeBranch, MergeConflictError, MergeConstraintConflictError, type MergeConstraintConflictErrorDetails, MergeError, type MergeIncrementalArgs, type MergeOptions, type MergePlanAnchors, type MergePlanApplied, type MergePlanApplyOptions, type MergePlanArtifact, type MergePlanArtifactV1, type MergePlanArtifactV1Input, type MergePlanBranchAnchor, type MergePlanCandidateDiagnostic, type MergePlanCanonicalMapping, MergePlanCapabilityError, type MergePlanDiagnostics, type MergePlanDigest, MergePlanDigestMismatchError, type MergePlanEdgeDelete, type MergePlanEdgeUpsert, type MergePlanEntityRef, type MergePlanEntityResolution, type MergePlanGuards, type MergePlanIdentityAssertion, type MergePlanMatchEvidence, type MergePlanMatchSource, type MergePlanNodeDelete, type MergePlanNodeUpsert, MergePlanOriginMismatchError, type MergePlanProposedSummary, type MergePlanProvenanceOptions, type MergePlanReadContext, type MergePlanRetype, type MergePlanReview, type MergePlanRevisionFence, type MergePlanSchemaFence, MergePlanSchemaMismatchError, type MergePlanSimilarityStrategy, type MergePlanTargetFence, MergePlanTargetMismatchError, type MergePlanTypeReconciliation, type MergePlanWrites, MergePlanningStaleError, type MergeReport, type MergeReviewArtifact, type MergeReviewBaseline, type MergeReviewDifference, MergeReviewError, type MergeReviewPolicy, type MergeReviewRevalidation, type MergeReviewRow, type MergedCounts, type NativeDurableMergeResult, type NativeDurableMergeUnsupportedDimension, type NormalizedMergeOptions, type PlanCandidateWriteSetArgs, type PlanCandidateWriteSetForEvolutionArgs, type PlanCandidateWriteSetReviewArgs, type PropertyConflict, type PropertyConflictPolicy, type ProvenanceGraph, type ProvenanceIndex, type ProvenanceNode, type ProvenanceQuery, type ProvenanceRecord, type ReconcileTypesMode, type ResolveConfig, type ResolveMap, type ResolvedCluster, Result, type RevalidateCandidateWriteSetReviewArgs, type SimilarityStrategy, SimilarityUnavailableError, type SourceScope, StaleMergePlanError, type TypeReconciliation, UnsupportedMergePlanVersionError, VALIDITY_END_TARGET_PRECEDENCE, type ValidityEndResolution, type WorkingCopyStrategy, applyDurableMergePlan, applyMergePlan, applyMergePlanInTransaction, asBaseVersion, asBranchId, branch, branchDurable, branchForEvolution, captureCandidateWriteSetTarget, captureCandidateWriteSetTargetForEvolution, cloneWorkingCopyStrategy, computeBaseVersion, destroyDurableBranch, forkedWorkingCopyStrategy, ingestionBranch, merge, mergeIncremental, normalizeMergeOptions, openProvenanceStore, persistProvenanceRecords, planCandidateWriteSet, planCandidateWriteSetForEvolution, planCandidateWriteSetReview, planMerge, planMergeForEvolution, planMergeIncremental, provenanceGraphId, readProvenance, reopenDurableBranch, revalidateCandidateWriteSetReview };
|