@bjornpagen/bumbledb-log 1.2.1 → 1.3.1
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/README.md +152 -63
- package/dist/admin.d.ts +1 -1
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +13 -0
- package/dist/bin.js.map +1 -0
- package/dist/codes.d.ts +1 -1
- package/dist/codes.d.ts.map +1 -1
- package/dist/codes.js +1 -8
- package/dist/codes.js.map +1 -1
- package/dist/errors.d.ts +7 -21
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +11 -45
- package/dist/errors.js.map +1 -1
- package/dist/identity.d.ts +0 -8
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +0 -5
- package/dist/identity.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/machine.d.ts +4 -28
- package/dist/machine.d.ts.map +1 -1
- package/dist/machine.js +183 -246
- package/dist/machine.js.map +1 -1
- package/dist/native.d.ts +59 -154
- package/dist/native.d.ts.map +1 -1
- package/dist/native.js.map +1 -1
- package/dist/options.d.ts +2 -11
- package/dist/options.d.ts.map +1 -1
- package/dist/outcome.d.ts +1 -85
- package/dist/outcome.d.ts.map +1 -1
- package/dist/schema-files.d.ts +16 -0
- package/dist/schema-files.d.ts.map +1 -0
- package/dist/schema-files.js +77 -0
- package/dist/schema-files.js.map +1 -0
- package/dist/schema.d.ts +6 -9
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +8 -8
- package/dist/schema.js.map +1 -1
- package/dist/transition.d.ts +75 -0
- package/dist/transition.d.ts.map +1 -0
- package/dist/transition.js +3 -0
- package/dist/transition.js.map +1 -0
- package/pack-provenance.json +4 -4
- package/package.json +4 -8
- package/dist/migration-ops.d.ts +0 -20
- package/dist/migration-ops.d.ts.map +0 -1
- package/dist/migration-ops.js +0 -7
- package/dist/migration-ops.js.map +0 -1
- package/dist/migrations/bin.d.ts.map +0 -1
- package/dist/migrations/bin.js +0 -30
- package/dist/migrations/bin.js.map +0 -1
- package/dist/migrations/canonical.d.ts +0 -40
- package/dist/migrations/canonical.d.ts.map +0 -1
- package/dist/migrations/canonical.js +0 -156
- package/dist/migrations/canonical.js.map +0 -1
- package/dist/migrations/cli.d.ts +0 -29
- package/dist/migrations/cli.d.ts.map +0 -1
- package/dist/migrations/cli.js +0 -124
- package/dist/migrations/cli.js.map +0 -1
- package/dist/migrations/codec.d.ts +0 -74
- package/dist/migrations/codec.d.ts.map +0 -1
- package/dist/migrations/codec.js +0 -2
- package/dist/migrations/codec.js.map +0 -1
- package/dist/migrations/decode.d.ts +0 -16
- package/dist/migrations/decode.d.ts.map +0 -1
- package/dist/migrations/decode.js +0 -302
- package/dist/migrations/decode.js.map +0 -1
- package/dist/migrations/diff.d.ts +0 -39
- package/dist/migrations/diff.d.ts.map +0 -1
- package/dist/migrations/diff.js +0 -385
- package/dist/migrations/diff.js.map +0 -1
- package/dist/migrations/expr.d.ts +0 -22
- package/dist/migrations/expr.d.ts.map +0 -1
- package/dist/migrations/expr.js +0 -219
- package/dist/migrations/expr.js.map +0 -1
- package/dist/migrations/fail.d.ts +0 -22
- package/dist/migrations/fail.d.ts.map +0 -1
- package/dist/migrations/fail.js +0 -52
- package/dist/migrations/fail.js.map +0 -1
- package/dist/migrations/fsops.d.ts +0 -37
- package/dist/migrations/fsops.d.ts.map +0 -1
- package/dist/migrations/fsops.js +0 -222
- package/dist/migrations/fsops.js.map +0 -1
- package/dist/migrations/generate.d.ts +0 -11
- package/dist/migrations/generate.d.ts.map +0 -1
- package/dist/migrations/generate.js +0 -455
- package/dist/migrations/generate.js.map +0 -1
- package/dist/migrations/index.d.ts +0 -23
- package/dist/migrations/index.d.ts.map +0 -1
- package/dist/migrations/index.js +0 -6
- package/dist/migrations/index.js.map +0 -1
- package/dist/migrations/intent.d.ts +0 -86
- package/dist/migrations/intent.d.ts.map +0 -1
- package/dist/migrations/intent.js +0 -97
- package/dist/migrations/intent.js.map +0 -1
- package/dist/migrations/lock.d.ts +0 -27
- package/dist/migrations/lock.d.ts.map +0 -1
- package/dist/migrations/lock.js +0 -14
- package/dist/migrations/lock.js.map +0 -1
- package/dist/migrations/native.d.ts +0 -26
- package/dist/migrations/native.d.ts.map +0 -1
- package/dist/migrations/native.js +0 -124
- package/dist/migrations/native.js.map +0 -1
- package/dist/migrations/repo.d.ts +0 -38
- package/dist/migrations/repo.d.ts.map +0 -1
- package/dist/migrations/repo.js +0 -191
- package/dist/migrations/repo.js.map +0 -1
- package/dist/migrations/theory.d.ts +0 -21
- package/dist/migrations/theory.d.ts.map +0 -1
- package/dist/migrations/theory.js +0 -107
- package/dist/migrations/theory.js.map +0 -1
- package/dist/migrations/types.d.ts +0 -242
- package/dist/migrations/types.d.ts.map +0 -1
- package/dist/migrations/types.js +0 -2
- package/dist/migrations/types.js.map +0 -1
- package/dist/migrations/workflow.d.ts +0 -11
- package/dist/migrations/workflow.d.ts.map +0 -1
- package/dist/migrations/workflow.js +0 -14
- package/dist/migrations/workflow.js.map +0 -1
- /package/dist/{migrations/bin.d.ts → bin.d.ts} +0 -0
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pure declarative schema-evolution intent. These constructors build inert
|
|
3
|
-
* authoring metadata: no rows are consumed, no schema is lowered, hashed or
|
|
4
|
-
* admitted, and no I/O happens here. Ambiguous rename/drop/backfill/convert
|
|
5
|
-
* and business seed data are typed inputs to bounded generation, never
|
|
6
|
-
* imperative migration files under another name. Expressions are the core's
|
|
7
|
-
* own `ScalarExpr` values — the generator serializes them into
|
|
8
|
-
* canonical plan data and the native executor evaluates them; there is no
|
|
9
|
-
* migration-only expression interpreter.
|
|
10
|
-
*/
|
|
11
|
-
import { AuthoringError } from "@bjornpagen/bumbledb";
|
|
12
|
-
const MAX_NAME = 255;
|
|
13
|
-
function name(context, value) {
|
|
14
|
-
if (typeof value !== "string" || value.length === 0 || value.length > MAX_NAME || value.includes("\0")) {
|
|
15
|
-
throw new AuthoringError({
|
|
16
|
-
message: `${context}: a schema name must be a nonempty string of at most ${MAX_NAME} characters without NUL`
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
return value;
|
|
20
|
-
}
|
|
21
|
-
export function migrationIntent(schema, entries) {
|
|
22
|
-
if (!Array.isArray(entries)) {
|
|
23
|
-
throw new AuthoringError({ message: "migrationIntent: entries must be an array of intent values" });
|
|
24
|
-
}
|
|
25
|
-
// Retain caller-owned input until generation. A metadata constructor never
|
|
26
|
-
// synchronously copies or consumes an arbitrary intent/seed graph.
|
|
27
|
-
return Object.freeze({ schema, entries: Object.freeze([...entries]) });
|
|
28
|
-
}
|
|
29
|
-
/** Identity intent: the relation previously named `from` is now `to`. */
|
|
30
|
-
export function renameRelation(from, to) {
|
|
31
|
-
return Object.freeze({
|
|
32
|
-
kind: "rename-relation",
|
|
33
|
-
from: name("renameRelation", from),
|
|
34
|
-
to: name("renameRelation", to.name)
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
/** Identity intent: `relation`'s field previously named `from` is now `to`. */
|
|
38
|
-
export function renameField(relation, from, to) {
|
|
39
|
-
return Object.freeze({
|
|
40
|
-
kind: "rename-field",
|
|
41
|
-
relation: name("renameField", relation.name),
|
|
42
|
-
from: name("renameField", from),
|
|
43
|
-
to: name("renameField", to)
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
/** The explicit whole-relation data-loss acknowledgement IS this constructor. */
|
|
47
|
-
export function dropRelation(relation) {
|
|
48
|
-
return Object.freeze({ kind: "drop-relation", relation: name("dropRelation", relation) });
|
|
49
|
-
}
|
|
50
|
-
/** The explicit field data-loss acknowledgement. `relation` is the surviving relation. */
|
|
51
|
-
export function dropField(relation, field) {
|
|
52
|
-
return Object.freeze({
|
|
53
|
-
kind: "drop-field",
|
|
54
|
-
relation: name("dropField", typeof relation === "string" ? relation : relation.name),
|
|
55
|
-
field: name("dropField", field)
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* A value for a NEW required field, as a core `ScalarExpr` over the source
|
|
60
|
-
* row's old fields — including unresolved field arithmetic. Native compile
|
|
61
|
-
* binds kinds; this constructor does not require a resolved result. No
|
|
62
|
-
* fabricated zero/null and no callback.
|
|
63
|
-
*/
|
|
64
|
-
export function backfill(relation, field, expression) {
|
|
65
|
-
return Object.freeze({
|
|
66
|
-
kind: "backfill",
|
|
67
|
-
relation: name("backfill", relation.name),
|
|
68
|
-
field: name("backfill", field),
|
|
69
|
-
expression
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* An explicit conversion for an EXISTING field whose type or meaning
|
|
74
|
-
* changes, as a core `ScalarExpr` over the source row's old fields —
|
|
75
|
-
* including unresolved field arithmetic (`Scalar.add(Scalar.field("units"),
|
|
76
|
-
* Scalar.u64(1n))`). Same-schema convert is a recorded plan, not a no-op.
|
|
77
|
-
*/
|
|
78
|
-
export function convert(relation, field, expression) {
|
|
79
|
-
return Object.freeze({
|
|
80
|
-
kind: "convert",
|
|
81
|
-
relation: name("convert", relation.name),
|
|
82
|
-
field: name("convert", field),
|
|
83
|
-
expression
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Declarative fixed seed facts with explicitly supplied application IDs.
|
|
88
|
-
* The iterable stays caller-owned and stable until generation settles; it is
|
|
89
|
-
* read once in cooperative batches, with native validation before publication.
|
|
90
|
-
*/
|
|
91
|
-
export function seed(relation, rows) {
|
|
92
|
-
if (rows === null || typeof rows !== "object" || !(Symbol.iterator in rows)) {
|
|
93
|
-
throw new AuthoringError({ message: "seed: rows must be an iterable of typed facts" });
|
|
94
|
-
}
|
|
95
|
-
return Object.freeze({ kind: "seed", relation: name("seed", relation.name), rows });
|
|
96
|
-
}
|
|
97
|
-
//# sourceMappingURL=intent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":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AEhE,OAAO,MAAM,CAAC,MAAM,CAAC;QACpB,IAAI,EAAE,SAAkB;QACxB,QAAQ,EAAE,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,IAAI,CAAC;QACxC,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC;QAC7B,UAAU;KACV,CAAC,CAAA;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,IAAI,CAAwB,QAAW,EAAE,IAAuB;IAC/E,IAAI,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,CAAC,QAAQ,IAAI,IAAI,CAAC,EAAE,CAAC;QAC7E,MAAM,IAAI,cAAc,CAAC,EAAE,OAAO,EAAE,+CAA+C,EAAE,CAAC,CAAA;IACvF,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAA;AAC7F,CAAC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Repository exclusion for generation (C8): the named internal seam
|
|
3
|
-
* `internalAcquireRepositoryLock` / `RepositoryLock`. The native stamped
|
|
4
|
-
* lock is the exclusion authority — this module does not keep a second
|
|
5
|
-
* in-memory ownership table. It never opens a core `Db`, never unlinks
|
|
6
|
-
* the lock inode, and never composes `runtimeDirectoryAcquire` / `Close`.
|
|
7
|
-
* Callers provide `Scope`. On cancel, L17 joins host I/O
|
|
8
|
-
* (`joinPendingIo`) and then the L16 hook `RepositoryLock.release`
|
|
9
|
-
* (`logRepositoryLockRelease`) runs from Scope. No public lock API.
|
|
10
|
-
*/
|
|
11
|
-
import type { NativeRuntime } from "@bjornpagen/bumbledb";
|
|
12
|
-
import type { RepositoryLock } from "@bjornpagen/bumbledb/internal/log";
|
|
13
|
-
import type { Scope } from "effect";
|
|
14
|
-
import { Effect } from "effect";
|
|
15
|
-
import type { LogError } from "../errors.js";
|
|
16
|
-
/** The held fence is the core `RepositoryLock` — directory + joined release. */
|
|
17
|
-
export type HeldRepositoryLock = RepositoryLock;
|
|
18
|
-
export interface RepositoryExclusion {
|
|
19
|
-
readonly acquire: (operation: string, directory: string) => Effect.Effect<RepositoryLock, LogError, NativeRuntime | Scope.Scope>;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Production exclusion: `internalAcquireRepositoryLock` only. Same-process
|
|
23
|
-
* and cross-process refuse live on the native stamped lock. Scope registers
|
|
24
|
-
* the joined close inside that acquire; do not open a `Db`.
|
|
25
|
-
*/
|
|
26
|
-
export declare const productionExclusion: RepositoryExclusion;
|
|
27
|
-
//# sourceMappingURL=lock.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lock.d.ts","sourceRoot":"","sources":["../../src/migrations/lock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAA;AAEvE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAG1C,gFAAgF;AAChF,MAAM,MAAM,kBAAkB,GAAG,cAAc,CAAA;AAE/C,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,OAAO,EAAE,CACjB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,KACb,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,QAAQ,EAAE,aAAa,GAAG,KAAK,CAAC,KAAK,CAAC,CAAA;CACzE;AAED;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,EAAE,mBAMjC,CAAA"}
|
package/dist/migrations/lock.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { internalAcquireRepositoryLock } from "@bjornpagen/bumbledb/internal/log";
|
|
2
|
-
import { Effect } from "effect";
|
|
3
|
-
import { logFailure } from "#errors.ts";
|
|
4
|
-
/**
|
|
5
|
-
* Production exclusion: `internalAcquireRepositoryLock` only. Same-process
|
|
6
|
-
* and cross-process refuse live on the native stamped lock. Scope registers
|
|
7
|
-
* the joined close inside that acquire; do not open a `Db`.
|
|
8
|
-
*/
|
|
9
|
-
export const productionExclusion = {
|
|
10
|
-
acquire(operation, directory) {
|
|
11
|
-
return internalAcquireRepositoryLock(operation, directory).pipe(Effect.mapError((error) => logFailure(operation, error)));
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=lock.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lock.js","sourceRoot":"","sources":["../../src/migrations/lock.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,6BAA6B,EAAE,MAAM,mCAAmC,CAAA;AAEjF,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAYvC;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAwB;IACvD,OAAO,CAAC,SAAS,EAAE,SAAS;QAC3B,OAAO,6BAA6B,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,IAAI,CAC9D,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CACxD,CAAA;IACF,CAAC;CACD,CAAA"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The production `MigrationCodec`: bounded JSON requests to and bounded
|
|
3
|
-
* JSON responses from the shared native runtime. Schema validation, canonical
|
|
4
|
-
* SchemaId + snapshot rendering (`schema_file::{schema_id, render}`), plan
|
|
5
|
-
* parsing/validation/rendering/digesting (`migration::plan`) and manifest
|
|
6
|
-
* verification/appending/plan-set digests (`migration::manifest`) are all
|
|
7
|
-
* native. The durable status/migrate/activate/abort workflow lives in
|
|
8
|
-
* `#migration-ops.ts`, reached through the `logAdmin` wire verb.
|
|
9
|
-
*
|
|
10
|
-
* The two imported core entrypoints accept bounded owned input and JSON
|
|
11
|
-
* response bytes under one registered cancellable operation. The schema verb
|
|
12
|
-
* takes the SDK `SchemaSpec` object because that wire already crosses the
|
|
13
|
-
* bridge for open/create; it is never respelled as text here. Both are
|
|
14
|
-
* read-only: they never open, initialize, freeze or migrate a database.
|
|
15
|
-
*/
|
|
16
|
-
import type { LogError } from "../errors.js";
|
|
17
|
-
import type { MigrationCodec } from "./codec.js";
|
|
18
|
-
/**
|
|
19
|
-
* A native refusal code becomes the typed log error through the shared wire
|
|
20
|
-
* decoder: known protocol codes become `ProtocolError`, anything else the
|
|
21
|
-
* core `Internal` — never a fabricated success and never string matching.
|
|
22
|
-
*/
|
|
23
|
-
export declare function nativeRefusal(operation: string, code: string, detail: string): LogError;
|
|
24
|
-
/** The one production binding of the generator's native-codec seam. */
|
|
25
|
-
export declare const productionCodec: MigrationCodec;
|
|
26
|
-
//# sourceMappingURL=native.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../../src/migrations/native.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAI1C,OAAO,KAAK,EAAgB,cAAc,EAAkB,MAAM,sBAAsB,CAAA;AAkDxF;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,QAAQ,CAKvF;AA+DD,uEAAuE;AACvE,eAAO,MAAM,eAAe,EAAE,cAAgD,CAAA"}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The production `MigrationCodec`: bounded JSON requests to and bounded
|
|
3
|
-
* JSON responses from the shared native runtime. Schema validation, canonical
|
|
4
|
-
* SchemaId + snapshot rendering (`schema_file::{schema_id, render}`), plan
|
|
5
|
-
* parsing/validation/rendering/digesting (`migration::plan`) and manifest
|
|
6
|
-
* verification/appending/plan-set digests (`migration::manifest`) are all
|
|
7
|
-
* native. The durable status/migrate/activate/abort workflow lives in
|
|
8
|
-
* `#migration-ops.ts`, reached through the `logAdmin` wire verb.
|
|
9
|
-
*
|
|
10
|
-
* The two imported core entrypoints accept bounded owned input and JSON
|
|
11
|
-
* response bytes under one registered cancellable operation. The schema verb
|
|
12
|
-
* takes the SDK `SchemaSpec` object because that wire already crosses the
|
|
13
|
-
* bridge for open/create; it is never respelled as text here. Both are
|
|
14
|
-
* read-only: they never open, initialize, freeze or migrate a database.
|
|
15
|
-
*/
|
|
16
|
-
import { internalMigrationRead, internalMigrationSchema } from "@bjornpagen/bumbledb/internal/log";
|
|
17
|
-
import { Effect, Schema } from "effect";
|
|
18
|
-
import { logFailure } from "#errors.ts";
|
|
19
|
-
import { compactJson } from "#migrations/canonical.ts";
|
|
20
|
-
import { boundedDetail, repository } from "#migrations/fail.ts";
|
|
21
|
-
const MAX_RESPONSE = 64 * 1024 * 1024;
|
|
22
|
-
const encoder = new TextEncoder();
|
|
23
|
-
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
24
|
-
// ---------------------------------------------------------------------------
|
|
25
|
-
// Response boundary models (small external models — Effect Schema).
|
|
26
|
-
// ---------------------------------------------------------------------------
|
|
27
|
-
const RefusalWire = Schema.Struct({
|
|
28
|
-
refused: Schema.Struct({
|
|
29
|
-
code: Schema.String,
|
|
30
|
-
detail: Schema.String
|
|
31
|
-
})
|
|
32
|
-
});
|
|
33
|
-
const SchemaOk = Schema.Struct({
|
|
34
|
-
schemaId: Schema.String,
|
|
35
|
-
snapshot: Schema.String
|
|
36
|
-
});
|
|
37
|
-
const SchemaResponse = Schema.Union([SchemaOk, RefusalWire]);
|
|
38
|
-
const EntryWire = Schema.Struct({
|
|
39
|
-
sequence: Schema.String,
|
|
40
|
-
id: Schema.String,
|
|
41
|
-
fromSchemaId: Schema.String,
|
|
42
|
-
toSchemaId: Schema.String,
|
|
43
|
-
planDigest: Schema.String,
|
|
44
|
-
prefixDigest: Schema.String
|
|
45
|
-
});
|
|
46
|
-
const ChainOk = Schema.Struct({
|
|
47
|
-
headPrefixDigest: Schema.String,
|
|
48
|
-
planSetDigest: Schema.NullOr(Schema.String),
|
|
49
|
-
appended: Schema.NullOr(Schema.Struct({
|
|
50
|
-
entry: EntryWire,
|
|
51
|
-
planText: Schema.String,
|
|
52
|
-
manifestText: Schema.String
|
|
53
|
-
}))
|
|
54
|
-
});
|
|
55
|
-
const ChainResponse = Schema.Union([ChainOk, RefusalWire]);
|
|
56
|
-
const decodeSchemaResponse = Schema.decodeUnknownOption(SchemaResponse);
|
|
57
|
-
const decodeChainResponse = Schema.decodeUnknownOption(ChainResponse);
|
|
58
|
-
/**
|
|
59
|
-
* A native refusal code becomes the typed log error through the shared wire
|
|
60
|
-
* decoder: known protocol codes become `ProtocolError`, anything else the
|
|
61
|
-
* core `Internal` — never a fabricated success and never string matching.
|
|
62
|
-
*/
|
|
63
|
-
export function nativeRefusal(operation, code, detail) {
|
|
64
|
-
return logFailure(operation, {
|
|
65
|
-
source: "protocol",
|
|
66
|
-
reason: { _tag: code, detail: boundedDetail(detail) }
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
// ---------------------------------------------------------------------------
|
|
70
|
-
// Request plumbing.
|
|
71
|
-
// ---------------------------------------------------------------------------
|
|
72
|
-
function requestBytes(body) {
|
|
73
|
-
return encoder.encode(compactJson(body));
|
|
74
|
-
}
|
|
75
|
-
function decodeResponse(operation, bytes) {
|
|
76
|
-
if (bytes.byteLength > MAX_RESPONSE) {
|
|
77
|
-
return Effect.fail(repository(operation, "<native response>", "response exceeds the bounded response cap"));
|
|
78
|
-
}
|
|
79
|
-
return Effect.try({
|
|
80
|
-
try: () => JSON.parse(decoder.decode(bytes)),
|
|
81
|
-
catch: () => repository(operation, "<native response>", "response is not bounded JSON")
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
// ---------------------------------------------------------------------------
|
|
85
|
-
// The production codec.
|
|
86
|
-
// ---------------------------------------------------------------------------
|
|
87
|
-
const schemaIdentity = Effect.fn("bumbledb-log.migrations.schemaIdentity")(function* (spec) {
|
|
88
|
-
const operation = "migrations.schemaIdentity";
|
|
89
|
-
const raw = yield* internalMigrationSchema(spec);
|
|
90
|
-
const response = yield* decodeResponse(operation, raw);
|
|
91
|
-
const decoded = decodeSchemaResponse(response);
|
|
92
|
-
if (decoded._tag === "None") {
|
|
93
|
-
return yield* Effect.fail(repository(operation, "<native response>", "unrecognized schema response"));
|
|
94
|
-
}
|
|
95
|
-
if ("refused" in decoded.value) {
|
|
96
|
-
return yield* Effect.fail(nativeRefusal(operation, decoded.value.refused.code, decoded.value.refused.detail));
|
|
97
|
-
}
|
|
98
|
-
const identity = { schemaId: decoded.value.schemaId, snapshot: decoded.value.snapshot };
|
|
99
|
-
return identity;
|
|
100
|
-
});
|
|
101
|
-
const verifyChain = Effect.fn("bumbledb-log.migrations.verifyChain")(function* (request) {
|
|
102
|
-
const operation = "migrations.verifyChain";
|
|
103
|
-
const raw = yield* internalMigrationRead(requestBytes({
|
|
104
|
-
kind: "chain",
|
|
105
|
-
manifest: request.manifest,
|
|
106
|
-
baseSchemaId: request.baseSchemaId,
|
|
107
|
-
snapshots: request.snapshots,
|
|
108
|
-
plans: request.plans,
|
|
109
|
-
append: request.append,
|
|
110
|
-
planSet: request.planSet === null ? null : { first: request.planSet.first, count: request.planSet.count }
|
|
111
|
-
}));
|
|
112
|
-
const response = yield* decodeResponse(operation, raw);
|
|
113
|
-
const decoded = decodeChainResponse(response);
|
|
114
|
-
if (decoded._tag === "None") {
|
|
115
|
-
return yield* Effect.fail(repository(operation, "<native response>", "unrecognized chain response"));
|
|
116
|
-
}
|
|
117
|
-
if ("refused" in decoded.value) {
|
|
118
|
-
return yield* Effect.fail(nativeRefusal(operation, decoded.value.refused.code, decoded.value.refused.detail));
|
|
119
|
-
}
|
|
120
|
-
return decoded.value;
|
|
121
|
-
});
|
|
122
|
-
/** The one production binding of the generator's native-codec seam. */
|
|
123
|
-
export const productionCodec = { schemaIdentity, verifyChain };
|
|
124
|
-
//# sourceMappingURL=native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"native.js","sourceRoot":"","sources":["../../src/migrations/native.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAA;AAClG,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAEvC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEvC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAEtD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAE/D,MAAM,YAAY,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAA;AAErC,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAA;AACjC,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;AAEzD,8EAA8E;AAC9E,oEAAoE;AACpE,8EAA8E;AAE9E,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC;QACtB,IAAI,EAAE,MAAM,CAAC,MAAM;QACnB,MAAM,EAAE,MAAM,CAAC,MAAM;KACrB,CAAC;CACF,CAAC,CAAA;AAEF,MAAM,QAAQ,GAAG,MAAM,CAAC,MAA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AAM,OAAO,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAA;IAC7C,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QAC7B,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,mBAAmB,EAAE,6BAA6B,CAAC,CAAC,CAAA;IACrG,CAAC;IACD,IAAI,SAAS,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QAChC,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;IAC9G,CAAC;IACD,OAAO,OAAO,CAAC,KAAK,CAAA;AACrB,CAAC,CAAC,CAAA;AAEF,uEAAuE;AACvE,MAAM,CAAC,MAAM,eAAe,GAAmB,EAAE,cAAc,EAAE,WAAW,EAAE,CAAA"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Effect } from "effect";
|
|
2
|
-
import type { LogError } from "../errors.js";
|
|
3
|
-
import type { MigrationManifest, MigrationRepository } from "./types.js";
|
|
4
|
-
export declare function manifestPath(directory: string): string;
|
|
5
|
-
export declare function planPath(directory: string, id: string): string;
|
|
6
|
-
export declare function snapshotPath(directory: string, sequence: number): string;
|
|
7
|
-
/** Empty-base schema snapshot — first row of the mandatory compile chain. */
|
|
8
|
-
export declare function baseSnapshotPath(directory: string): string;
|
|
9
|
-
export declare function snapshotsSidecarPath(directory: string): string;
|
|
10
|
-
export declare function indexPath(directory: string): string;
|
|
11
|
-
export declare function contractPath(repo: MigrationRepository): string;
|
|
12
|
-
/** The full human file id: `NNNN-<label>`. */
|
|
13
|
-
export declare function planId(sequence: number, label: string): string;
|
|
14
|
-
export interface RepositoryState {
|
|
15
|
-
/** `manifest.json` text, or null for a repo without any recorded plan. */
|
|
16
|
-
readonly manifestText: string | null;
|
|
17
|
-
readonly manifest: MigrationManifest | null;
|
|
18
|
-
/** Recorded plan file texts, in manifest order. */
|
|
19
|
-
readonly planTexts: readonly string[];
|
|
20
|
-
/** Recorded snapshot texts: empty-base first, then each entry's target. */
|
|
21
|
-
readonly snapshotTexts: readonly string[];
|
|
22
|
-
/**
|
|
23
|
-
* Unrecorded files whose name matches the NEXT sequence — leftovers of an
|
|
24
|
-
* interrupted generation (the manifest is written last, so an unlisted
|
|
25
|
-
* next-sequence file was never recorded). Generation deterministically
|
|
26
|
-
* rewrites them; any other unlisted file is drift, not a leftover.
|
|
27
|
-
*/
|
|
28
|
-
readonly staleDrafts: readonly string[];
|
|
29
|
-
}
|
|
30
|
-
/** Latest recorded target snapshot text, or null at the empty base. */
|
|
31
|
-
export declare function latestSnapshot(state: RepositoryState): string | null;
|
|
32
|
-
/**
|
|
33
|
-
* Read and structurally verify the recorded repository. Every recorded entry
|
|
34
|
-
* must have exactly its plan file and target snapshot; strays refuse as
|
|
35
|
-
* drift. Digest recomputation is the caller's native chain pass.
|
|
36
|
-
*/
|
|
37
|
-
export declare const readRepository: (repo: MigrationRepository) => Effect.Effect<RepositoryState, LogError, never>;
|
|
38
|
-
//# sourceMappingURL=repo.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"repo.d.ts","sourceRoot":"","sources":["../../src/migrations/repo.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAI1C,OAAO,KAAK,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAOlF,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED,wBAAgB,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAExE;AAED,6EAA6E;AAC7E,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,mBAAmB,GAAG,MAAM,CAE9D;AAED,8CAA8C;AAC9C,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED,MAAM,WAAW,eAAe;IAC/B,0EAA0E;IAC1E,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IACpC,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAA;IAC3C,mDAAmD;IACnD,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAA;IACrC,2EAA2E;IAC3E,QAAQ,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAA;IACzC;;;;;OAKG;IACH,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAA;CACvC;AAED,uEAAuE;AACvE,wBAAgB,cAAc,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,GAAG,IAAI,CAEpE;AA8BD;;;;GAIG;AACH,eAAO,MAAM,cAAc,gFA+HzB,CAAA"}
|
package/dist/migrations/repo.js
DELETED
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The repo-local migration repository: layout, bounded reads and structural
|
|
3
|
-
* integrity. Recorded artifacts are immutable — generation only appends a new
|
|
4
|
-
* plan/snapshot and rewrites the manifest/index/contract; an edited recorded
|
|
5
|
-
* file, an unrecorded stray plan, a missing snapshot or a reordered manifest
|
|
6
|
-
* is DRIFT and refuses before anything else happens. Digest-level tampering
|
|
7
|
-
* is judged natively (`migration::manifest::{verify_manifest, bind_plans}`)
|
|
8
|
-
* from the exact file texts read here; TypeScript never recomputes a hash.
|
|
9
|
-
*/
|
|
10
|
-
import { readdir } from "node:fs/promises";
|
|
11
|
-
import * as path from "node:path";
|
|
12
|
-
import { Effect } from "effect";
|
|
13
|
-
import { decodeManifestData } from "#migrations/decode.ts";
|
|
14
|
-
import { drift, repository as repositoryError } from "#migrations/fail.ts";
|
|
15
|
-
import { readBounded } from "#migrations/fsops.ts";
|
|
16
|
-
const MAX_MANIFEST_BYTES = 8 * 1024 * 1024;
|
|
17
|
-
const MAX_PLAN_BYTES = 64 * 1024 * 1024;
|
|
18
|
-
const MAX_SNAPSHOT_BYTES = 64 * 1024 * 1024;
|
|
19
|
-
const MAX_DIRECTORY_ENTRIES = 20000;
|
|
20
|
-
export function manifestPath(directory) {
|
|
21
|
-
return path.join(directory, "manifest.json");
|
|
22
|
-
}
|
|
23
|
-
export function planPath(directory, id) {
|
|
24
|
-
return path.join(directory, `${id}.plan.json`);
|
|
25
|
-
}
|
|
26
|
-
export function snapshotPath(directory, sequence) {
|
|
27
|
-
return path.join(directory, "meta", `${sequence.toString(10).padStart(4, "0")}.schema.json`);
|
|
28
|
-
}
|
|
29
|
-
/** Empty-base schema snapshot — first row of the mandatory compile chain. */
|
|
30
|
-
export function baseSnapshotPath(directory) {
|
|
31
|
-
return path.join(directory, "meta", "base.schema.json");
|
|
32
|
-
}
|
|
33
|
-
export function snapshotsSidecarPath(directory) {
|
|
34
|
-
return path.join(directory, "snapshots.json");
|
|
35
|
-
}
|
|
36
|
-
export function indexPath(directory) {
|
|
37
|
-
return path.join(directory, "index.ts");
|
|
38
|
-
}
|
|
39
|
-
export function contractPath(repo) {
|
|
40
|
-
return repo.contract ?? path.join(repo.directory, "runtime-contract.json");
|
|
41
|
-
}
|
|
42
|
-
/** The full human file id: `NNNN-<label>`. */
|
|
43
|
-
export function planId(sequence, label) {
|
|
44
|
-
return `${sequence.toString(10).padStart(4, "0")}-${label}`;
|
|
45
|
-
}
|
|
46
|
-
/** Latest recorded target snapshot text, or null at the empty base. */
|
|
47
|
-
export function latestSnapshot(state) {
|
|
48
|
-
return state.snapshotTexts.length === 0 ? null : (state.snapshotTexts[state.snapshotTexts.length - 1] ?? null);
|
|
49
|
-
}
|
|
50
|
-
function listNames(operation, directory) {
|
|
51
|
-
return Effect.tryPromise({
|
|
52
|
-
try: async () => {
|
|
53
|
-
let names;
|
|
54
|
-
try {
|
|
55
|
-
names = await readdir(directory);
|
|
56
|
-
}
|
|
57
|
-
catch (cause) {
|
|
58
|
-
if (typeof cause === "object" && cause !== null && "code" in cause && cause.code === "ENOENT") {
|
|
59
|
-
return [];
|
|
60
|
-
}
|
|
61
|
-
throw cause;
|
|
62
|
-
}
|
|
63
|
-
if (names.length > MAX_DIRECTORY_ENTRIES) {
|
|
64
|
-
throw { code: `directory exceeds ${MAX_DIRECTORY_ENTRIES} entries` };
|
|
65
|
-
}
|
|
66
|
-
return names;
|
|
67
|
-
},
|
|
68
|
-
catch: (cause) => repositoryError(operation, directory, typeof cause === "object" && cause !== null && "code" in cause && typeof cause.code === "string"
|
|
69
|
-
? cause.code
|
|
70
|
-
: "io failure")
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Read and structurally verify the recorded repository. Every recorded entry
|
|
75
|
-
* must have exactly its plan file and target snapshot; strays refuse as
|
|
76
|
-
* drift. Digest recomputation is the caller's native chain pass.
|
|
77
|
-
*/
|
|
78
|
-
export const readRepository = Effect.fn("bumbledb-log.migrations.readRepository")(function* (repo) {
|
|
79
|
-
const operation = "migrations.readRepository";
|
|
80
|
-
const directory = repo.directory;
|
|
81
|
-
const manifestText = yield* readBounded(operation, manifestPath(directory), MAX_MANIFEST_BYTES);
|
|
82
|
-
if (manifestText === null) {
|
|
83
|
-
// A fresh repository: nothing recorded. A sequence-0 plan/snapshot file
|
|
84
|
-
// is an interrupted first generation (manifest is written last); any
|
|
85
|
-
// other stray file is drift.
|
|
86
|
-
const names = yield* listNames(operation, directory);
|
|
87
|
-
const staleDrafts = [];
|
|
88
|
-
for (const name of names) {
|
|
89
|
-
if (!name.endsWith(".plan.json")) {
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
if (name.startsWith("0000-")) {
|
|
93
|
-
staleDrafts.push(name);
|
|
94
|
-
continue;
|
|
95
|
-
}
|
|
96
|
-
return yield* Effect.fail(drift(operation, `plan file ${name} exists but manifest.json does not — a recorded chain cannot be partial`));
|
|
97
|
-
}
|
|
98
|
-
const metaNames = yield* listNames(operation, path.join(directory, "meta"));
|
|
99
|
-
for (const name of metaNames) {
|
|
100
|
-
if (!name.endsWith(".schema.json")) {
|
|
101
|
-
continue;
|
|
102
|
-
}
|
|
103
|
-
if (name === "base.schema.json" || name === "0000.schema.json") {
|
|
104
|
-
staleDrafts.push(`meta/${name}`);
|
|
105
|
-
continue;
|
|
106
|
-
}
|
|
107
|
-
return yield* Effect.fail(drift(operation, `snapshot file meta/${name} exists but manifest.json does not — a recorded chain cannot be partial`));
|
|
108
|
-
}
|
|
109
|
-
const state = { manifestText: null, manifest: null, planTexts: [], snapshotTexts: [], staleDrafts };
|
|
110
|
-
return state;
|
|
111
|
-
}
|
|
112
|
-
let tree;
|
|
113
|
-
try {
|
|
114
|
-
tree = JSON.parse(manifestText);
|
|
115
|
-
}
|
|
116
|
-
catch {
|
|
117
|
-
return yield* Effect.fail(repositoryError(operation, manifestPath(directory), "manifest is not JSON"));
|
|
118
|
-
}
|
|
119
|
-
const decoded = decodeManifestData(tree);
|
|
120
|
-
if (!decoded.ok) {
|
|
121
|
-
return yield* Effect.fail(repositoryError(operation, manifestPath(directory), decoded.detail));
|
|
122
|
-
}
|
|
123
|
-
const manifest = decoded.value;
|
|
124
|
-
// Structural chain checks (native re-verifies with digests).
|
|
125
|
-
const ids = new Set();
|
|
126
|
-
for (const [index, entry] of manifest.entries.entries()) {
|
|
127
|
-
if (entry.sequence !== index.toString(10)) {
|
|
128
|
-
return yield* Effect.fail(drift(operation, `manifest entry ${entry.id} has sequence ${entry.sequence}, expected ${index}`));
|
|
129
|
-
}
|
|
130
|
-
if (ids.has(entry.id)) {
|
|
131
|
-
return yield* Effect.fail(drift(operation, `manifest reuses the label ${entry.id}`));
|
|
132
|
-
}
|
|
133
|
-
ids.add(entry.id);
|
|
134
|
-
}
|
|
135
|
-
// No stray or missing files. A next-sequence leftover of an interrupted
|
|
136
|
-
// generation is tolerated as a rewritable draft; anything else is drift.
|
|
137
|
-
const nextPrefix = `${manifest.entries.length.toString(10).padStart(4, "0")}-`;
|
|
138
|
-
const staleDrafts = [];
|
|
139
|
-
const names = yield* listNames(operation, directory);
|
|
140
|
-
for (const name of names) {
|
|
141
|
-
if (!name.endsWith(".plan.json") || ids.has(name.slice(0, -".plan.json".length))) {
|
|
142
|
-
continue;
|
|
143
|
-
}
|
|
144
|
-
if (name.startsWith(nextPrefix)) {
|
|
145
|
-
staleDrafts.push(name);
|
|
146
|
-
continue;
|
|
147
|
-
}
|
|
148
|
-
return yield* Effect.fail(drift(operation, `plan file ${name} is not recorded in the manifest`));
|
|
149
|
-
}
|
|
150
|
-
const metaNames = yield* listNames(operation, path.join(directory, "meta"));
|
|
151
|
-
for (const name of metaNames) {
|
|
152
|
-
if (!name.endsWith(".schema.json")) {
|
|
153
|
-
continue;
|
|
154
|
-
}
|
|
155
|
-
if (name === "base.schema.json") {
|
|
156
|
-
continue;
|
|
157
|
-
}
|
|
158
|
-
const stem = name.slice(0, -".schema.json".length);
|
|
159
|
-
const ordinal = Number.parseInt(stem, 10);
|
|
160
|
-
if (Number.isSafeInteger(ordinal) && ordinal >= 0 && ordinal < manifest.entries.length) {
|
|
161
|
-
continue;
|
|
162
|
-
}
|
|
163
|
-
if (ordinal === manifest.entries.length) {
|
|
164
|
-
staleDrafts.push(`meta/${name}`);
|
|
165
|
-
continue;
|
|
166
|
-
}
|
|
167
|
-
return yield* Effect.fail(drift(operation, `snapshot file meta/${name} is not recorded in the manifest`));
|
|
168
|
-
}
|
|
169
|
-
const planTexts = [];
|
|
170
|
-
const snapshotTexts = [];
|
|
171
|
-
const baseSnapshot = yield* readBounded(operation, baseSnapshotPath(directory), MAX_SNAPSHOT_BYTES);
|
|
172
|
-
if (baseSnapshot === null) {
|
|
173
|
-
return yield* Effect.fail(drift(operation, "recorded chain is missing meta/base.schema.json"));
|
|
174
|
-
}
|
|
175
|
-
snapshotTexts.push(baseSnapshot);
|
|
176
|
-
for (const [index, entry] of manifest.entries.entries()) {
|
|
177
|
-
const plan = yield* readBounded(operation, planPath(directory, entry.id), MAX_PLAN_BYTES);
|
|
178
|
-
if (plan === null) {
|
|
179
|
-
return yield* Effect.fail(drift(operation, `recorded plan ${entry.id} has no ${entry.id}.plan.json file`));
|
|
180
|
-
}
|
|
181
|
-
planTexts.push(plan);
|
|
182
|
-
const snapshot = yield* readBounded(operation, snapshotPath(directory, index), MAX_SNAPSHOT_BYTES);
|
|
183
|
-
if (snapshot === null) {
|
|
184
|
-
return yield* Effect.fail(drift(operation, `recorded plan ${entry.id} has no meta/${index.toString(10).padStart(4, "0")}.schema.json snapshot`));
|
|
185
|
-
}
|
|
186
|
-
snapshotTexts.push(snapshot);
|
|
187
|
-
}
|
|
188
|
-
const state = { manifestText, manifest, planTexts, snapshotTexts, staleDrafts };
|
|
189
|
-
return state;
|
|
190
|
-
});
|
|
191
|
-
//# sourceMappingURL=repo.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"repo.js","sourceRoot":"","sources":["../../src/migrations/repo.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC1C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAu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AI,CACxB,KAAK,CACJ,SAAS,EACT,iBAAiB,KAAK,CAAC,EAAE,gBAAgB,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,uBAAuB,CACnG,CACD,CAAA;QACF,CAAC;QACD,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAC7B,CAAC;IACD,MAAM,KAAK,GAAoB,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,CAAA;IAChG,OAAO,KAAK,CAAA;AACb,CAAC,CAAC,CAAA"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Bounded parse of the ONE native schema-file grammar
|
|
3
|
-
* (`crates/bumbledb-log/src/schema_file.rs`: `{relations, statements}`,
|
|
4
|
-
* closed extensions on relations) into the small image the diff walks.
|
|
5
|
-
* Snapshot files are the native `schema_file::render` text verbatim; this
|
|
6
|
-
* reader extracts relation/field names, canonical type spellings and
|
|
7
|
-
* closedness — statements never need TS interpretation because schema change
|
|
8
|
-
* is decided by the native canonical SchemaId, not by re-deriving laws here.
|
|
9
|
-
*/
|
|
10
|
-
import type { TheorySnapshot } from "./types.js";
|
|
11
|
-
export type TheoryResult = {
|
|
12
|
-
readonly ok: true;
|
|
13
|
-
readonly snapshot: TheorySnapshot;
|
|
14
|
-
} | {
|
|
15
|
-
readonly ok: false;
|
|
16
|
-
readonly detail: string;
|
|
17
|
-
};
|
|
18
|
-
/** Parse one snapshot text (already size-bounded by the file reader). */
|
|
19
|
-
export declare function parseTheory(raw: string): TheoryResult;
|
|
20
|
-
export declare const EMPTY_THEORY: TheorySnapshot;
|
|
21
|
-
//# sourceMappingURL=theory.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"theory.d.ts","sourceRoot":"","sources":["../../src/migrations/theory.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAA+B,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAMvF,MAAM,MAAM,YAAY,GACrB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAA;CAAE,GACxD;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AA4ClD,yEAAyE;AACzE,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CA6DrD;AAED,eAAO,MAAM,YAAY,EAAE,cAAgE,CAAA"}
|