@bjornpagen/bumbledb-log 1.0.1 → 1.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/README.md +31 -56
- package/dist/command.d.ts +4 -4
- package/dist/command.d.ts.map +1 -1
- package/dist/command.js.map +1 -1
- package/dist/history.d.ts +3 -3
- package/dist/history.d.ts.map +1 -1
- package/dist/history.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/machine.d.ts +13 -13
- package/dist/machine.d.ts.map +1 -1
- package/dist/machine.js +49 -55
- package/dist/machine.js.map +1 -1
- package/dist/migrations/bin.js +19 -32
- package/dist/migrations/bin.js.map +1 -1
- package/dist/migrations/cli.d.ts +2 -5
- package/dist/migrations/cli.d.ts.map +1 -1
- package/dist/migrations/cli.js +3 -26
- package/dist/migrations/cli.js.map +1 -1
- package/dist/migrations/codec.d.ts +3 -3
- package/dist/migrations/codec.d.ts.map +1 -1
- package/dist/migrations/fail.d.ts +0 -4
- package/dist/migrations/fail.d.ts.map +1 -1
- package/dist/migrations/fail.js +0 -9
- package/dist/migrations/fail.js.map +1 -1
- package/dist/migrations/generate.d.ts.map +1 -1
- package/dist/migrations/generate.js +51 -75
- package/dist/migrations/generate.js.map +1 -1
- package/dist/migrations/intent.d.ts +1 -1
- package/dist/migrations/intent.js +1 -1
- package/dist/migrations/lock.d.ts +2 -2
- package/dist/migrations/lock.d.ts.map +1 -1
- package/dist/migrations/lock.js +2 -2
- package/dist/migrations/lock.js.map +1 -1
- package/dist/migrations/native.d.ts.map +1 -1
- package/dist/migrations/native.js +4 -4
- package/dist/migrations/native.js.map +1 -1
- package/dist/migrations/types.d.ts +1 -2
- package/dist/migrations/types.d.ts.map +1 -1
- package/dist/native.d.ts +13 -17
- package/dist/native.d.ts.map +1 -1
- package/dist/native.js.map +1 -1
- package/dist/options.d.ts +11 -18
- package/dist/options.d.ts.map +1 -1
- package/dist/outcome.d.ts +3 -10
- package/dist/outcome.d.ts.map +1 -1
- package/dist/surface.d.ts +8 -9
- package/dist/surface.d.ts.map +1 -1
- package/pack-provenance.json +3 -3
- package/package.json +6 -3
package/dist/migrations/bin.js
CHANGED
|
@@ -1,43 +1,30 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/** The `bumbledb-log` executable: the one process boundary over the Effect CLI. */
|
|
3
3
|
import { NativeRuntime } from "@bjornpagen/bumbledb";
|
|
4
|
+
import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
|
|
4
5
|
import { Effect, Exit } from "effect";
|
|
5
6
|
import { cliProgram, loadAuthoring, parseCliArguments } from "#migrations/cli.ts";
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
inputBytes: 512n * 1024n * 1024n,
|
|
13
|
-
workingBytes: 512n * 1024n * 1024n,
|
|
14
|
-
scratchBytes: 512n * 1024n * 1024n,
|
|
15
|
-
resultBytes: 128n * 1024n * 1024n,
|
|
16
|
-
chunkBytes: 1024n * 1024n,
|
|
17
|
-
cleanupTimeout: 5000
|
|
18
|
-
};
|
|
19
|
-
const parsed = parseCliArguments(process.argv.slice(2));
|
|
20
|
-
if (typeof parsed === "string") {
|
|
21
|
-
process.stderr.write(`${parsed}\n`);
|
|
22
|
-
process.exitCode = 2;
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
7
|
+
const main = Effect.gen(function* () {
|
|
8
|
+
const parsed = parseCliArguments(process.argv.slice(2));
|
|
9
|
+
if (typeof parsed === "string") {
|
|
10
|
+
process.stderr.write(`${parsed}\n`);
|
|
11
|
+
return 2;
|
|
12
|
+
}
|
|
25
13
|
const program = loadAuthoring(parsed).pipe(Effect.flatMap((authored) => cliProgram(parsed, authored)));
|
|
26
|
-
const exit =
|
|
14
|
+
const exit = yield* Effect.exit(program.pipe(Effect.provide(NativeRuntime.layer())));
|
|
27
15
|
if (Exit.isSuccess(exit)) {
|
|
28
16
|
process.stdout.write(`${JSON.stringify(exit.value.report, null, 2)}\n`);
|
|
29
|
-
|
|
17
|
+
return exit.value.code;
|
|
30
18
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
process.exitCode = 2;
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
process.stderr.write(`${JSON.stringify(exit.cause, null, 2)}\n`);
|
|
39
|
-
process.exitCode = 1;
|
|
40
|
-
}
|
|
19
|
+
const failure = Exit.findErrorOption(exit);
|
|
20
|
+
if (failure._tag === "Some" && typeof failure.value === "string") {
|
|
21
|
+
process.stderr.write(`${failure.value}\n`);
|
|
22
|
+
return 2;
|
|
41
23
|
}
|
|
42
|
-
}
|
|
24
|
+
process.stderr.write(`${JSON.stringify(exit.cause, null, 2)}\n`);
|
|
25
|
+
return 1;
|
|
26
|
+
});
|
|
27
|
+
NodeRuntime.runMain(main, {
|
|
28
|
+
teardown: (exit, onExit) => onExit(Exit.isSuccess(exit) && typeof exit.value === "number" ? exit.value : 1)
|
|
29
|
+
});
|
|
43
30
|
//# sourceMappingURL=bin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../../src/migrations/bin.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../../src/migrations/bin.ts"],"names":[],"mappings":";AACA,mFAAmF;AACnF,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,KAAK,WAAW,MAAM,mCAAmC,CAAA;AAChE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AACrC,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAEjF,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAChC,M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AAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAA;IAChE,OAAO,CAAC,CAAA;AACT,CAAC,CAAC,CAAA;AAEF,WAAW,CAAC,OAAO,CAAC,IAAI,EAAE;IACzB,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;CAC3G,CAAC,CAAA"}
|
package/dist/migrations/cli.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import type { AnySchema
|
|
1
|
+
import type { AnySchema } from "@bjornpagen/bumbledb";
|
|
2
2
|
import { Effect } from "effect";
|
|
3
3
|
import type { MigrationIntent } from "./intent.js";
|
|
4
4
|
import type { CheckReport, GenerationReport } from "./types.js";
|
|
5
|
-
export declare const CLI_USAGE = "bumbledb-log <generate|check> --schema <module.ts> --out <migrations-dir>\n\t[--export <name>] schema export (default: \"default\", then \"schema\")\n\t[--intent <name>] intent export (default: \"evolution\" when present)\n\t[--label <label>] stable human label for a new plan ([a-z0-9-])\n\t[--contract <path>] runtime contract path (default: <out>/runtime-contract.json)\n
|
|
6
|
-
/** Generous fixed authoring-tool budgets; native admission still re-judges. */
|
|
7
|
-
export declare const CLI_WORK: ExecutionPolicy;
|
|
5
|
+
export declare const CLI_USAGE = "bumbledb-log <generate|check> --schema <module.ts> --out <migrations-dir>\n\t[--export <name>] schema export (default: \"default\", then \"schema\")\n\t[--intent <name>] intent export (default: \"evolution\" when present)\n\t[--label <label>] stable human label for a new plan ([a-z0-9-])\n\t[--contract <path>] runtime contract path (default: <out>/runtime-contract.json)\n";
|
|
8
6
|
export interface CliArguments {
|
|
9
7
|
readonly command: "generate" | "check";
|
|
10
8
|
readonly schemaPath: string;
|
|
@@ -13,7 +11,6 @@ export interface CliArguments {
|
|
|
13
11
|
readonly intentName: string | null;
|
|
14
12
|
readonly label: string | null;
|
|
15
13
|
readonly contract: string | null;
|
|
16
|
-
readonly timeoutMs: number | null;
|
|
17
14
|
}
|
|
18
15
|
export declare function parseCliArguments(argv: readonly string[]): CliArguments | string;
|
|
19
16
|
export interface AuthoredModule {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/migrations/cli.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/migrations/cli.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAGzE,eAAO,MAAM,SAAS,qYAKrB,CAAA;AAED,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAA;IACtC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IAClC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IAClC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;CAChC;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,YAAY,GAAG,MAAM,CA4ChF;AAiBD,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAA;IAC1B,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,GAAG,SAAS,CAAA;CACpE;AAED,0EAA0E;AAC1E,eAAO,MAAM,aAAa,qEAsBxB,CAAA;AAEF,eAAO,MAAM,UAAU;;UAeE,CAAC;;;;uEAQxB,CAAA"}
|
package/dist/migrations/cli.js
CHANGED
|
@@ -21,18 +21,7 @@ export const CLI_USAGE = `bumbledb-log <generate|check> --schema <module.ts> --o
|
|
|
21
21
|
[--intent <name>] intent export (default: "evolution" when present)
|
|
22
22
|
[--label <label>] stable human label for a new plan ([a-z0-9-])
|
|
23
23
|
[--contract <path>] runtime contract path (default: <out>/runtime-contract.json)
|
|
24
|
-
[--timeout-ms <n>] generation work deadline (default: 600000)
|
|
25
24
|
`;
|
|
26
|
-
/** Generous fixed authoring-tool budgets; native admission still re-judges. */
|
|
27
|
-
export const CLI_WORK = {
|
|
28
|
-
inputBytes: 256n * 1024n * 1024n,
|
|
29
|
-
workingBytes: 256n * 1024n * 1024n,
|
|
30
|
-
scratchBytes: 256n * 1024n * 1024n,
|
|
31
|
-
resultBytes: 64n * 1024n * 1024n,
|
|
32
|
-
rows: 1000000n,
|
|
33
|
-
workUnits: 1000000000n,
|
|
34
|
-
timeout: 600000
|
|
35
|
-
};
|
|
36
25
|
export function parseCliArguments(argv) {
|
|
37
26
|
const command = argv[0];
|
|
38
27
|
if (command !== "generate" && command !== "check") {
|
|
@@ -44,7 +33,6 @@ export function parseCliArguments(argv) {
|
|
|
44
33
|
let intentName = null;
|
|
45
34
|
let label = null;
|
|
46
35
|
let contract = null;
|
|
47
|
-
let timeoutMs = null;
|
|
48
36
|
for (let index = 1; index < argv.length; index += 2) {
|
|
49
37
|
const flag = argv[index];
|
|
50
38
|
const value = argv[index + 1];
|
|
@@ -70,14 +58,6 @@ export function parseCliArguments(argv) {
|
|
|
70
58
|
case "--contract":
|
|
71
59
|
contract = value;
|
|
72
60
|
break;
|
|
73
|
-
case "--timeout-ms": {
|
|
74
|
-
const parsed = Number.parseInt(value, 10);
|
|
75
|
-
if (!Number.isSafeInteger(parsed) || parsed <= 0) {
|
|
76
|
-
return CLI_USAGE;
|
|
77
|
-
}
|
|
78
|
-
timeoutMs = parsed;
|
|
79
|
-
break;
|
|
80
|
-
}
|
|
81
61
|
default:
|
|
82
62
|
return CLI_USAGE;
|
|
83
63
|
}
|
|
@@ -85,7 +65,7 @@ export function parseCliArguments(argv) {
|
|
|
85
65
|
if (schemaPath === null || directory === null) {
|
|
86
66
|
return CLI_USAGE;
|
|
87
67
|
}
|
|
88
|
-
return { command, schemaPath, directory, exportName, intentName, label, contract
|
|
68
|
+
return { command, schemaPath, directory, exportName, intentName, label, contract };
|
|
89
69
|
}
|
|
90
70
|
function isSchemaValue(value) {
|
|
91
71
|
return (typeof value === "object" &&
|
|
@@ -121,7 +101,6 @@ export const loadAuthoring = Effect.fn("bumbledb-log.cli.loadAuthoring")(functio
|
|
|
121
101
|
return authored;
|
|
122
102
|
});
|
|
123
103
|
export const cliProgram = Effect.fn("bumbledb-log.cli.program")(function* (cli, authored) {
|
|
124
|
-
const work = cli.timeoutMs === null ? CLI_WORK : { ...CLI_WORK, timeout: cli.timeoutMs };
|
|
125
104
|
const repository = {
|
|
126
105
|
directory: cli.directory,
|
|
127
106
|
...(cli.contract === null ? {} : { contract: cli.contract })
|
|
@@ -131,16 +110,14 @@ export const cliProgram = Effect.fn("bumbledb-log.cli.program")(function* (cli,
|
|
|
131
110
|
schema: authored.schema,
|
|
132
111
|
...(authored.intent === undefined ? {} : { intent: authored.intent }),
|
|
133
112
|
...(cli.label === null ? {} : { label: cli.label }),
|
|
134
|
-
repository
|
|
135
|
-
work
|
|
113
|
+
repository
|
|
136
114
|
});
|
|
137
115
|
return { report, code: 0 };
|
|
138
116
|
}
|
|
139
117
|
const report = yield* checkMigrations({
|
|
140
118
|
schema: authored.schema,
|
|
141
119
|
...(authored.intent === undefined ? {} : { intent: authored.intent }),
|
|
142
|
-
repository
|
|
143
|
-
work
|
|
120
|
+
repository
|
|
144
121
|
});
|
|
145
122
|
return { report, code: report.status === "clean" ? 0 : 1 };
|
|
146
123
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/migrations/cli.ts"],"names":[],"mappings":";;;;;;;;AAAA;;;;;GAKG;AACH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAExC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAG/B,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAE7E,MAAM,CAAC,MAAM,SAAS,GAAG
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/migrations/cli.ts"],"names":[],"mappings":";;;;;;;;AAAA;;;;;GAKG;AACH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAExC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAG/B,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAE7E,MAAM,CAAC,MAAM,SAAS,GAAG;;;;;CAKxB,CAAA;AAYD,MAAM,UAAU,iBAAiB,CAAC,IAAuB;IACxD,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;IACvB,IAAI,OAAO,KAAK,UAAU,IAAI,OAAO,KAAK,OAAO,EAAE,CAAC;QACnD,OAAO,SAAS,CAAA;IACjB,CAAC;IACD,IAAI,UAAU,GAAkB,IAAI,CAAA;IACpC,IAAI,SAAS,GAAkB,IAAI,CAAA;IACnC,IAAI,UAAU,GAAkB,IAAI,CAAA;IACpC,IAAI,UAAU,GAAkB,IAAI,CAAA;IACpC,IAAI,KAAK,GAAkB,IAA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,KAAK,EAAE,CAAC;YACnD,UAAU;SACV,CAAC,CAAA;QACF,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAU,EAAE,CAAA;IACpC,CAAC;IACD,MAAM,MAAM,GAAgB,KAAK,CAAC,CAAC,eAAe,CAAC;QAClD,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,GAAG,CAAC,QAAQ,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;QACrE,UAAU;KACV,CAAC,CAAA;IACF,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,KAAK,OAAO,CAAC,CAAC,CAAE,CAAW,CAAC,CAAC,CAAE,CAAW,EAAE,CAAA;AACjF,CAAC,CAAC,CAAA"}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* This module is types only — importing it performs no native work and does
|
|
14
14
|
* not load the addon.
|
|
15
15
|
*/
|
|
16
|
-
import type {
|
|
16
|
+
import type { NativeRuntime, SchemaSpec } from "@bjornpagen/bumbledb";
|
|
17
17
|
import type { Effect } from "effect";
|
|
18
18
|
import type { LogError } from "../errors.js";
|
|
19
19
|
import type { JsonValue } from "./canonical.js";
|
|
@@ -61,7 +61,7 @@ export interface ChainPayload {
|
|
|
61
61
|
}
|
|
62
62
|
export interface MigrationCodec {
|
|
63
63
|
/** Validate + fingerprint + render the current schema natively. */
|
|
64
|
-
schemaIdentity(spec: SchemaSpec
|
|
64
|
+
schemaIdentity(spec: SchemaSpec): Effect.Effect<SchemaIdentity, LogError, NativeRuntime>;
|
|
65
65
|
/**
|
|
66
66
|
* One native chain pass: parse + verify the manifest, bind every recorded
|
|
67
67
|
* plan's canonical digest, optionally validate/append a new plan (returning
|
|
@@ -69,6 +69,6 @@ export interface MigrationCodec {
|
|
|
69
69
|
* and optionally compute a pending plan-set digest. Nothing is trusted
|
|
70
70
|
* from text.
|
|
71
71
|
*/
|
|
72
|
-
verifyChain(request: ChainRequest
|
|
72
|
+
verifyChain(request: ChainRequest): Effect.Effect<ChainPayload, LogError, NativeRuntime>;
|
|
73
73
|
}
|
|
74
74
|
//# sourceMappingURL=codec.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../src/migrations/codec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../src/migrations/codec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACrE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAEzD,MAAM,WAAW,cAAc;IAC9B,uEAAuE;IACvE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,2EAA2E;IAC3E,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CACzB;AAED,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;CAC7B;AAED,MAAM,WAAW,YAAY;IAC5B,mFAAmF;IACnF,QAAQ,CAAC,QAAQ,EAAE,SAAS,GAAG,IAAI,CAAA;IACnC,wEAAwE;IACxE,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IACpC,uEAAuE;IACvE,QAAQ,CAAC,SAAS,EAAE,SAAS,SAAS,EAAE,CAAA;IACxC,2EAA2E;IAC3E,QAAQ,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,CAAA;IACpC,yEAAyE;IACzE,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAAA;IACjC,qEAAqE;IACrE,QAAQ,CAAC,OAAO,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAA;CAC3E;AAED,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;IACjC,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IACrC,QAAQ,CAAC,QAAQ,EAAE;QAClB,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAA;QAC5B,yEAAyE;QACzE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;QACzB,yDAAyD;QACzD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;KAC7B,GAAG,IAAI,CAAA;CACR;AAED,MAAM,WAAW,cAAc;IAC9B,mEAAmE;IACnE,cAAc,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAA;IACxF;;;;;;OAMG;IACH,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAA;CACxF"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Migration failures use the shared `DbError | ProtocolError` vocabulary.
|
|
3
3
|
* Reasons carry bounded structured detail; consumers never parse messages.
|
|
4
|
-
* Resource-budget refusals use the core `DbError` `ResourceLimit` reason.
|
|
5
4
|
*/
|
|
6
|
-
import { DbError } from "@bjornpagen/bumbledb";
|
|
7
5
|
import { ProtocolError } from "../errors.js";
|
|
8
6
|
/** One actionable generation refusal: what is required, about which subject. */
|
|
9
7
|
export interface IntentRequirement {
|
|
@@ -21,6 +19,4 @@ export declare function drift(operation: string, detail: string): ProtocolError;
|
|
|
21
19
|
export declare function unsupported(operation: string, detail: string): ProtocolError;
|
|
22
20
|
/** A malformed or unreadable repository artifact/layout. */
|
|
23
21
|
export declare function repository(operation: string, path: string, detail: string): ProtocolError;
|
|
24
|
-
/** A generation/seed budget refusal on the core resource reason. */
|
|
25
|
-
export declare function budget(operation: string, dimension: string, used: bigint, requested: bigint, limit: bigint): DbError;
|
|
26
22
|
//# sourceMappingURL=fail.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fail.d.ts","sourceRoot":"","sources":["../../src/migrations/fail.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"fail.d.ts","sourceRoot":"","sources":["../../src/migrations/fail.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE1C,gFAAgF;AAChF,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,IAAI,EACV,WAAW,GACX,aAAa,GACb,kBAAkB,GAClB,aAAa,GACb,aAAa,GACb,cAAc,GACd,oBAAoB,CAAA;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACvB;AAKD,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEpD;AAWD,iFAAiF;AACjF,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,SAAS,iBAAiB,EAAE,GAAG,aAAa,CAU3G;AAED,iFAAiF;AACjF,wBAAgB,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,aAAa,CAKtE;AAED,sEAAsE;AACtE,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,aAAa,CAK5E;AAED,4DAA4D;AAC5D,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,aAAa,CAKzF"}
|
package/dist/migrations/fail.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Migration failures use the shared `DbError | ProtocolError` vocabulary.
|
|
3
3
|
* Reasons carry bounded structured detail; consumers never parse messages.
|
|
4
|
-
* Resource-budget refusals use the core `DbError` `ResourceLimit` reason.
|
|
5
4
|
*/
|
|
6
|
-
import { DbError } from "@bjornpagen/bumbledb";
|
|
7
5
|
import { ProtocolError } from "#errors.ts";
|
|
8
6
|
const MAX_REQUIREMENTS = 32;
|
|
9
7
|
const MAX_DETAIL = 512;
|
|
@@ -51,11 +49,4 @@ export function repository(operation, path, detail) {
|
|
|
51
49
|
reason: { _tag: "MigrationRepository", path: boundedDetail(path), detail: boundedDetail(detail) }
|
|
52
50
|
});
|
|
53
51
|
}
|
|
54
|
-
/** A generation/seed budget refusal on the core resource reason. */
|
|
55
|
-
export function budget(operation, dimension, used, requested, limit) {
|
|
56
|
-
return new DbError({
|
|
57
|
-
operation,
|
|
58
|
-
reason: { _tag: "ResourceLimit", dimension, used, requested, limit }
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
52
|
//# sourceMappingURL=fail.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fail.js","sourceRoot":"","sources":["../../src/migrations/fail.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"fail.js","sourceRoot":"","sources":["../../src/migrations/fail.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAC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I,aAAa,CAAC;QACxB,SAAS;QACT,MAAM,EAAE,EAAE,IAAI,EAAE,sBAAsB,EAAE,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,EAAE;KACvE,CAAC,CAAA;AACH,CAAC;AAED,4DAA4D;AAC5D,MAAM,UAAU,UAAU,CAAC,SAAiB,EAAE,IAAY,EAAE,MAAc;IACzE,OAAO,IAAI,aAAa,CAAC;QACxB,SAAS;QACT,MAAM,EAAE,EAAE,IAAI,EAAE,qBAAqB,EAAE,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,EAAE;KACjG,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/migrations/generate.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/migrations/generate.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAY,aAAa,EAAE,eAAe,EAAc,MAAM,sBAAsB,CAAA;AAIhG,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAG1C,OAAO,KAAK,EAAgB,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAcxE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAc9D,OAAO,KAAK,EACX,YAAY,EACZ,WAAW,EACX,eAAe,EACf,gBAAgB,EAMhB,MAAM,sBAAsB,CAAA;AAiL7B,wBAAgB,aAAa,CAAC,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,mBAAmB;yBAqIC,IAAI,SAAS,eAAe;sBA8IlC,IAAI,SAAS,eAAe;EAgEzG"}
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
* schema lowering and the core row-cell codec are imported literally.
|
|
21
21
|
*/
|
|
22
22
|
import * as path from "node:path";
|
|
23
|
-
import {
|
|
24
|
-
import { lower } from "@bjornpagen/bumbledb/internal/log";
|
|
23
|
+
import { Uuid } from "@bjornpagen/bumbledb";
|
|
24
|
+
import { factCellsOf, lower, schemasAgree } from "@bjornpagen/bumbledb/internal/log";
|
|
25
25
|
import { Effect } from "effect";
|
|
26
26
|
import { bytesHex, f64Bits, planJson, renderContract, renderIndex, renderSnapshots } from "#migrations/canonical.ts";
|
|
27
27
|
import { diffSchemas } from "#migrations/diff.ts";
|
|
28
|
-
import {
|
|
28
|
+
import { drift, intentRequired, unsupported } from "#migrations/fail.ts";
|
|
29
29
|
import { ensureDirectory, joinPendingIo, readBounded, removeFile, writeDerived, writeImmutable, writeManifest } from "#migrations/fsops.ts";
|
|
30
30
|
import { baseSnapshotPath, contractPath, indexPath, latestSnapshot, manifestPath, planId, planPath, readRepository, snapshotPath, snapshotsSidecarPath } from "#migrations/repo.ts";
|
|
31
31
|
import { parseTheory } from "#migrations/theory.ts";
|
|
@@ -54,25 +54,12 @@ function deriveLabel(tokens) {
|
|
|
54
54
|
return label.endsWith("-") ? label.slice(0, -1) : label;
|
|
55
55
|
}
|
|
56
56
|
// ---------------------------------------------------------------------------
|
|
57
|
-
//
|
|
58
|
-
//
|
|
59
|
-
//
|
|
60
|
-
//
|
|
57
|
+
// Read caller iterables once, yielding between bounded processing steps.
|
|
58
|
+
// The generated document owns the lowered rows; no second chunk array is
|
|
59
|
+
// necessary. This is incremental ingestion, not a streaming document codec.
|
|
60
|
+
// Values lower through the core's exact row-shape and cell codec.
|
|
61
61
|
// ---------------------------------------------------------------------------
|
|
62
|
-
function
|
|
63
|
-
return (typeof member === "object" &&
|
|
64
|
-
member !== null &&
|
|
65
|
-
"data" in member &&
|
|
66
|
-
typeof member.data === "object" &&
|
|
67
|
-
member.data !== null &&
|
|
68
|
-
"fields" in member.data);
|
|
69
|
-
}
|
|
70
|
-
function planValueOfCell(relation, ordinal, cell) {
|
|
71
|
-
const declared = relation.fields[ordinal];
|
|
72
|
-
if (declared === undefined) {
|
|
73
|
-
throw new Error(`relation ${relation.name}: cell ${ordinal} has no declared field`);
|
|
74
|
-
}
|
|
75
|
-
const field = declared.field;
|
|
62
|
+
function planValueOfCell(context, field, cell) {
|
|
76
63
|
switch (field.kind) {
|
|
77
64
|
case "bool":
|
|
78
65
|
return { bool: cell === true };
|
|
@@ -87,7 +74,7 @@ function planValueOfCell(relation, ordinal, cell) {
|
|
|
87
74
|
// canonical hyphenated UUID string — already the plan wire
|
|
88
75
|
// spelling.
|
|
89
76
|
if (!Uuid.isUuid(cell)) {
|
|
90
|
-
throw new Error(
|
|
77
|
+
throw new Error(`${context}: uuid cell did not lower to canonical hex`);
|
|
91
78
|
}
|
|
92
79
|
return { uuid: cell };
|
|
93
80
|
}
|
|
@@ -95,13 +82,13 @@ function planValueOfCell(relation, ordinal, cell) {
|
|
|
95
82
|
return { string: String(cell) };
|
|
96
83
|
case "bytes": {
|
|
97
84
|
if (!(cell instanceof Uint8Array)) {
|
|
98
|
-
throw new Error(
|
|
85
|
+
throw new Error(`${context}: bytes cell did not lower to bytes`);
|
|
99
86
|
}
|
|
100
87
|
return { fixedBytes: bytesHex(cell) };
|
|
101
88
|
}
|
|
102
89
|
case "interval": {
|
|
103
90
|
if (typeof cell !== "object" || cell === null || !("start" in cell) || !("end" in cell)) {
|
|
104
|
-
throw new Error(
|
|
91
|
+
throw new Error(`${context}: interval cell did not lower to endpoints`);
|
|
105
92
|
}
|
|
106
93
|
if (field.element === "f64") {
|
|
107
94
|
return { intervalF64: [f64Bits(Number(cell.start)), f64Bits(Number(cell.end))] };
|
|
@@ -113,59 +100,48 @@ function planValueOfCell(relation, ordinal, cell) {
|
|
|
113
100
|
}
|
|
114
101
|
}
|
|
115
102
|
}
|
|
116
|
-
const lowerSeeds = Effect.fn("bumbledb-log.migrations.lowerSeeds")(function* (relations, intents, seedRelations
|
|
103
|
+
const lowerSeeds = Effect.fn("bumbledb-log.migrations.lowerSeeds")(function* (relations, intents, seedRelations) {
|
|
117
104
|
const operation = "migrations.generate";
|
|
118
105
|
const seedOps = [];
|
|
119
|
-
const used = { rows: 0n, bytes: 0n };
|
|
120
106
|
for (const relationName of seedRelations) {
|
|
121
107
|
const member = relations[relationName];
|
|
122
|
-
if (
|
|
108
|
+
if (member?.kind !== "relation") {
|
|
123
109
|
return yield* Effect.fail(unsupported(operation, `seed target ${relationName} is not an ordinary relation value`));
|
|
124
110
|
}
|
|
125
|
-
const
|
|
111
|
+
const fields = Object.entries(member.fields);
|
|
126
112
|
const rows = [];
|
|
127
113
|
for (const intent of intents) {
|
|
128
114
|
if (intent.kind !== "seed" || intent.relation !== relationName) {
|
|
129
115
|
continue;
|
|
130
116
|
}
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
done
|
|
142
|
-
|
|
117
|
+
const refused = (cause) => unsupported(operation, `seed ${relationName}: ${cause instanceof Error ? cause.message : "row refused by the core cell codec"}`);
|
|
118
|
+
yield* Effect.acquireUseRelease(Effect.try({
|
|
119
|
+
try: () => ({ iterator: intent.rows[Symbol.iterator](), done: false }),
|
|
120
|
+
catch: refused
|
|
121
|
+
}), (state) => Effect.gen(function* () {
|
|
122
|
+
while (!state.done) {
|
|
123
|
+
yield* Effect.try({
|
|
124
|
+
try: () => {
|
|
125
|
+
for (let index = 0; index < SEED_CHUNK; index += 1) {
|
|
126
|
+
const next = state.iterator.next();
|
|
127
|
+
if (next.done === true) {
|
|
128
|
+
state.done = true;
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
const fact = next.value;
|
|
132
|
+
const cells = factCellsOf(member, fact);
|
|
133
|
+
rows.push(fields.map(([name, field], ordinal) => planValueOfCell(`seed ${relationName}.${name}`, field, cells[ordinal])));
|
|
143
134
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
return planValueOfCell(data, ordinal, cell);
|
|
150
|
-
});
|
|
151
|
-
used.rows += 1n;
|
|
152
|
-
lowered.push(cells);
|
|
153
|
-
}
|
|
154
|
-
return lowered;
|
|
155
|
-
},
|
|
156
|
-
catch: (cause) => unsupported(operation, `seed ${relationName}: ${cause instanceof Error ? cause.message : "row refused by the core cell codec"}`)
|
|
157
|
-
});
|
|
158
|
-
if (used.rows > work.rows) {
|
|
159
|
-
return yield* Effect.fail(budget(operation, "seed.rows", used.rows, used.rows, work.rows));
|
|
160
|
-
}
|
|
161
|
-
if (used.bytes > work.inputBytes) {
|
|
162
|
-
return yield* Effect.fail(budget(operation, "seed.inputBytes", used.bytes, used.bytes, work.inputBytes));
|
|
135
|
+
},
|
|
136
|
+
catch: refused
|
|
137
|
+
});
|
|
138
|
+
if (!state.done)
|
|
139
|
+
yield* Effect.yieldNow;
|
|
163
140
|
}
|
|
164
|
-
|
|
165
|
-
if (!done)
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
141
|
+
}), (state) => Effect.sync(() => {
|
|
142
|
+
if (!state.done)
|
|
143
|
+
state.iterator.return?.();
|
|
144
|
+
}));
|
|
169
145
|
}
|
|
170
146
|
seedOps.push({ kind: "seed", target: relationName, rows });
|
|
171
147
|
}
|
|
@@ -180,8 +156,8 @@ function parseTree(operation, label, text) {
|
|
|
180
156
|
export function makeGenerator(codec, exclusion) {
|
|
181
157
|
const analyze = Effect.fn("bumbledb-log.migrations.analyze")(function* (options) {
|
|
182
158
|
const operation = "migrations.analyze";
|
|
183
|
-
if (options.intent !== undefined && options.intent.schema
|
|
184
|
-
return yield* Effect.fail(unsupported(operation, "the migration intent was declared for a different schema
|
|
159
|
+
if (options.intent !== undefined && !schemasAgree(options.intent.schema, options.schema)) {
|
|
160
|
+
return yield* Effect.fail(unsupported(operation, "the migration intent was declared for a different logical schema than the one being generated"));
|
|
185
161
|
}
|
|
186
162
|
const repoState = yield* readRepository(options.repository);
|
|
187
163
|
// Recorded texts become parsed trees for the bridge; identity is judged
|
|
@@ -196,9 +172,9 @@ export function makeGenerator(codec, exclusion) {
|
|
|
196
172
|
planTrees.push(yield* parseTree(operation, `plan ${index}`, text));
|
|
197
173
|
}
|
|
198
174
|
const currentSpec = lower(options.schema);
|
|
199
|
-
const identity = yield* codec.schemaIdentity(currentSpec
|
|
175
|
+
const identity = yield* codec.schemaIdentity(currentSpec);
|
|
200
176
|
// Empty-base snapshot is always compiled — empty source is not a shortcut.
|
|
201
|
-
const emptyIdentity = yield* codec.schemaIdentity(EMPTY_SPEC
|
|
177
|
+
const emptyIdentity = yield* codec.schemaIdentity(EMPTY_SPEC);
|
|
202
178
|
const baseSchemaId = repoState.manifest === null ? emptyIdentity.schemaId : repoState.manifest.baseSchemaId;
|
|
203
179
|
const emptySnapshotTree = yield* parseTree(operation, "empty-base snapshot", emptyIdentity.snapshot);
|
|
204
180
|
const snapshotChain = snapshotTrees.length > 0 ? snapshotTrees : [emptySnapshotTree];
|
|
@@ -209,7 +185,7 @@ export function makeGenerator(codec, exclusion) {
|
|
|
209
185
|
plans: planTrees,
|
|
210
186
|
append: null,
|
|
211
187
|
planSet: null
|
|
212
|
-
}
|
|
188
|
+
});
|
|
213
189
|
const previousText = latestSnapshot(repoState);
|
|
214
190
|
const prevSource = previousText === null ? emptyIdentity.snapshot : previousText;
|
|
215
191
|
const parsedPrev = parseTheory(prevSource);
|
|
@@ -268,7 +244,7 @@ export function makeGenerator(codec, exclusion) {
|
|
|
268
244
|
// -------------------------------------------------------------------------
|
|
269
245
|
// generateMigrations
|
|
270
246
|
// -------------------------------------------------------------------------
|
|
271
|
-
function exclusive(operation, directory,
|
|
247
|
+
function exclusive(operation, directory, body) {
|
|
272
248
|
return Effect.uninterruptibleMask((restore) => Effect.scoped(Effect.gen(function* () {
|
|
273
249
|
// L16 `internalAcquireRepositoryLock` registers
|
|
274
250
|
// `RepositoryLock.release` (`logRepositoryLockRelease`)
|
|
@@ -279,14 +255,14 @@ export function makeGenerator(codec, exclusion) {
|
|
|
279
255
|
// release (request: clear `slot.owner` after
|
|
280
256
|
// `joinLockRelease` so `joinPendingIo.andThen(lock.release)`
|
|
281
257
|
// is the one close).
|
|
282
|
-
yield* restore(exclusion.acquire(operation, directory
|
|
258
|
+
yield* restore(exclusion.acquire(operation, directory));
|
|
283
259
|
return yield* restore(body).pipe(Effect.ensuring(joinPendingIo));
|
|
284
260
|
})));
|
|
285
261
|
}
|
|
286
262
|
const generateMigrations = Effect.fn("bumbledb-log.generateMigrations")(function* (options) {
|
|
287
263
|
const operation = "migrations.generate";
|
|
288
264
|
const directory = options.repository.directory;
|
|
289
|
-
return yield* exclusive(operation, directory,
|
|
265
|
+
return yield* exclusive(operation, directory, Effect.gen(function* () {
|
|
290
266
|
yield* ensureDirectory(operation, directory);
|
|
291
267
|
if (options.label !== undefined && !validLabel(options.label)) {
|
|
292
268
|
return yield* Effect.fail(unsupported(operation, `label must be 1..${MAX_LABEL} characters of [a-z0-9-]`));
|
|
@@ -336,7 +312,7 @@ export function makeGenerator(codec, exclusion) {
|
|
|
336
312
|
const label = options.label ?? deriveLabel(analysis.diff.labelTokens);
|
|
337
313
|
const id = planId(sequence, label);
|
|
338
314
|
// Seeds are ingested exactly once, bounded, at generation time.
|
|
339
|
-
const seedOps = yield* lowerSeeds(options.schema.relations, analysis.seedIntents, analysis.diff.seedRelations
|
|
315
|
+
const seedOps = yield* lowerSeeds(options.schema.relations, analysis.seedIntents, analysis.diff.seedRelations);
|
|
340
316
|
const operations = [
|
|
341
317
|
...analysis.diff.operations,
|
|
342
318
|
...seedOps,
|
|
@@ -360,7 +336,7 @@ export function makeGenerator(codec, exclusion) {
|
|
|
360
336
|
plans: analysis.planTrees,
|
|
361
337
|
append: planJson(plan),
|
|
362
338
|
planSet: null
|
|
363
|
-
}
|
|
339
|
+
});
|
|
364
340
|
if (chain.appended === null) {
|
|
365
341
|
return yield* Effect.fail(drift(operation, "the native chain pass did not append the validated plan"));
|
|
366
342
|
}
|
|
@@ -419,7 +395,7 @@ export function makeGenerator(codec, exclusion) {
|
|
|
419
395
|
const checkMigrations = Effect.fn("bumbledb-log.checkMigrations")(function* (options) {
|
|
420
396
|
const operation = "migrations.check";
|
|
421
397
|
const directory = options.repository.directory;
|
|
422
|
-
return yield* exclusive(operation, directory,
|
|
398
|
+
return yield* exclusive(operation, directory, Effect.gen(function* () {
|
|
423
399
|
const analysis = yield* analyze(options);
|
|
424
400
|
if (analysis.diff.requirements.length > 0) {
|
|
425
401
|
return yield* Effect.fail(intentRequired(operation, analysis.diff.requirements));
|