@omgbase/core 0.11.1 → 0.19.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 +1 -1
- package/dist/src/core/ids.d.ts +4 -0
- package/dist/src/core/ids.js +17 -0
- package/dist/src/core/ingest.d.ts +39 -3
- package/dist/src/core/ingest.js +233 -202
- package/dist/src/core/store/schema.d.ts +3 -2
- package/dist/src/core/store/schema.js +28 -3
- package/dist/src/core/store/size.d.ts +76 -0
- package/dist/src/core/store/size.js +223 -0
- package/dist/src/core/store/store.d.ts +9 -0
- package/dist/src/core/store/store.js +11 -0
- package/dist/src/graph/history.js +15 -12
- package/dist/src/index.d.ts +12 -5
- package/dist/src/index.js +18 -7
- package/dist/src/mcp/arguments.d.ts +9 -2
- package/dist/src/mcp/arguments.js +15 -2
- package/dist/src/mcp/errors.d.ts +1 -1
- package/dist/src/mcp/errors.js +3 -0
- package/dist/src/mcp/reference.d.ts +1 -1
- package/dist/src/mcp/reference.js +27 -6
- package/dist/src/mcp/server.d.ts +56 -1
- package/dist/src/mcp/server.js +365 -203
- package/dist/src/mutate/apply.d.ts +93 -12
- package/dist/src/mutate/apply.js +203 -113
- package/dist/src/mutate/canonical.d.ts +27 -0
- package/dist/src/mutate/canonical.js +138 -0
- package/dist/src/mutate/commit.d.ts +150 -0
- package/dist/src/mutate/commit.js +349 -0
- package/dist/src/mutate/doc-store.d.ts +3 -3
- package/dist/src/mutate/doc-store.js +21 -6
- package/dist/src/mutate/docs.d.ts +42 -87
- package/dist/src/mutate/docs.js +50 -204
- package/dist/src/mutate/effects.d.ts +363 -0
- package/dist/src/mutate/effects.js +1161 -0
- package/dist/src/mutate/materialize.d.ts +49 -0
- package/dist/src/mutate/materialize.js +174 -0
- package/dist/src/mutate/opset.d.ts +27 -2
- package/dist/src/mutate/opset.js +12 -5
- package/dist/src/mutate/plan-update.d.ts +1 -46
- package/dist/src/mutate/plan-update.js +19 -67
- package/dist/src/mutate/plan.d.ts +210 -0
- package/dist/src/mutate/plan.js +512 -0
- package/dist/src/mutate/select.d.ts +89 -0
- package/dist/src/mutate/select.js +879 -0
- package/dist/src/mutate/sugar.d.ts +135 -0
- package/dist/src/mutate/sugar.js +167 -0
- package/dist/src/mutate/tree.d.ts +4 -2
- package/dist/src/oqx-js/planner.js +4 -0
- package/dist/src/oqx-js/run.d.ts +28 -1
- package/dist/src/oqx-js/run.js +85 -22
- package/dist/src/spec-versions.d.ts +6 -6
- package/dist/src/spec-versions.js +5 -5
- package/dist/src/surface-paths.d.ts +17 -26
- package/dist/src/surface-paths.js +27 -22
- package/dist/src/sync/checkpoint.d.ts +5 -2
- package/dist/src/sync/checkpoint.js +10 -6
- package/dist/src/sync/freshness.d.ts +10 -7
- package/dist/src/sync/freshness.js +15 -17
- package/dist/src/sync/observe.d.ts +4 -1
- package/dist/src/sync/observe.js +56 -5
- package/dist/src/sync/recovery.d.ts +4 -0
- package/dist/src/sync/recovery.js +4 -1
- package/dist/src/sync/stat-cache.d.ts +7 -0
- package/dist/src/sync/stat-cache.js +22 -0
- package/dist/src/sync/tombstone.js +23 -19
- package/dist/src/sync/watcher.d.ts +2 -0
- package/dist/src/sync/watcher.js +4 -1
- package/dist/src/sync/writer-lock.d.ts +15 -0
- package/dist/src/sync/writer-lock.js +104 -17
- package/dist/src/version.d.ts +7 -2
- package/dist/src/version.js +5 -2
- package/package.json +2 -2
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import type { Store } from "../core/store/store.js";
|
|
2
|
+
import { type ApplyRevision, type Op, type OpResult } from "./apply.js";
|
|
3
|
+
import { type DocStore } from "./doc-store.js";
|
|
4
|
+
import { type CreateEntry, type ResolvedEffect, type RetargetPreview } from "./effects.js";
|
|
5
|
+
import type { IdentityPreview } from "./opset.js";
|
|
6
|
+
import { type Selection } from "./select.js";
|
|
7
|
+
export declare const PLAN_VERSION: 1;
|
|
8
|
+
/** The lowering + conflict rules version (§11.4; the `matcher_v` precedent). */
|
|
9
|
+
export declare const PLANNER_V: "p3";
|
|
10
|
+
/** A kernel op as the plan spells it on the wire: the fixture spelling (`child_ids`). */
|
|
11
|
+
export type WireOp = Exclude<Op, {
|
|
12
|
+
op: "update";
|
|
13
|
+
}> | {
|
|
14
|
+
op: "update";
|
|
15
|
+
block: string;
|
|
16
|
+
markdown?: string;
|
|
17
|
+
attrs?: Record<string, unknown>;
|
|
18
|
+
expect?: {
|
|
19
|
+
content_hash?: string;
|
|
20
|
+
parent_children_hash?: string;
|
|
21
|
+
};
|
|
22
|
+
trivia?: string;
|
|
23
|
+
child_ids?: Record<string, string>;
|
|
24
|
+
};
|
|
25
|
+
/** The lowered form `execute` replays (§11.4): every key present, `[]` when empty. */
|
|
26
|
+
export interface PlanOpset {
|
|
27
|
+
/** `create` → the composed file, its document symbol and the index of the first kernel op planned after it (3.0; a later `set frontmatter.<k>` on the symbol is a head below) */
|
|
28
|
+
creates: CreateEntry[];
|
|
29
|
+
/** `move document` → the row/file rename (its retarget updates are in `ops`) */
|
|
30
|
+
moves: {
|
|
31
|
+
id: string;
|
|
32
|
+
from: string;
|
|
33
|
+
to: string;
|
|
34
|
+
}[];
|
|
35
|
+
/** `remove document` */
|
|
36
|
+
tombstones: {
|
|
37
|
+
id: string;
|
|
38
|
+
path: string;
|
|
39
|
+
}[];
|
|
40
|
+
/** per document, the file head — everything before the first block (frontmatter incl. fences and separator) */
|
|
41
|
+
set_frontmatter: {
|
|
42
|
+
doc: string;
|
|
43
|
+
raw: string;
|
|
44
|
+
}[];
|
|
45
|
+
/** the kernel ops, in order; new structure is referenced by kernel placeholders `$k.ids[j]` */
|
|
46
|
+
ops: WireOp[];
|
|
47
|
+
}
|
|
48
|
+
export interface PlanPreconditions {
|
|
49
|
+
/** the row triples (`spec/mutate` §4 step 5) of every document the plan touches, loaded ones first in load order */
|
|
50
|
+
docs: {
|
|
51
|
+
id: string;
|
|
52
|
+
path: string;
|
|
53
|
+
base_revision: string | null;
|
|
54
|
+
hash: string | null;
|
|
55
|
+
}[];
|
|
56
|
+
/** every block content hash the plan pins (caller-given or pinned from the live row), first-pin order */
|
|
57
|
+
blocks: {
|
|
58
|
+
id: string;
|
|
59
|
+
content_hash: string;
|
|
60
|
+
}[];
|
|
61
|
+
/** the caller's destination-parent CAS pins */
|
|
62
|
+
parents: {
|
|
63
|
+
doc: string;
|
|
64
|
+
parent: string | null;
|
|
65
|
+
parent_children_hash: string;
|
|
66
|
+
}[];
|
|
67
|
+
/** paths that must have no live document and no file: `create` paths and move destinations */
|
|
68
|
+
absent_paths: string[];
|
|
69
|
+
}
|
|
70
|
+
export interface PlanPreview {
|
|
71
|
+
results: OpResult[];
|
|
72
|
+
revisions: ApplyRevision[];
|
|
73
|
+
diffs: Record<string, {
|
|
74
|
+
before: string;
|
|
75
|
+
after: string;
|
|
76
|
+
}>;
|
|
77
|
+
/** (3.0) per `set content` document: the whole-document planner's identity consequences; present when a plan has one */
|
|
78
|
+
identity?: Record<string, IdentityPreview>;
|
|
79
|
+
/** (3.0) per `retarget` effect: its hits and pair counts; present when a plan has one */
|
|
80
|
+
retarget?: RetargetPreview[];
|
|
81
|
+
/** (3.3, §11.9) one line in words per resolved effect, in order — the plan as a worked example; `[]` for a zero-hit selection */
|
|
82
|
+
summary: string[];
|
|
83
|
+
}
|
|
84
|
+
/** The executable core the digest covers. */
|
|
85
|
+
export interface PlanCore {
|
|
86
|
+
version: typeof PLAN_VERSION;
|
|
87
|
+
planner_v: string;
|
|
88
|
+
effects: ResolvedEffect[];
|
|
89
|
+
opset: PlanOpset;
|
|
90
|
+
preconditions: PlanPreconditions;
|
|
91
|
+
new_ids: {
|
|
92
|
+
symbol: string;
|
|
93
|
+
kind: "block" | "document";
|
|
94
|
+
}[];
|
|
95
|
+
/** (3.1, §11.8) the selector, its templates and the hits it bound — present only for a selector plan */
|
|
96
|
+
selection?: Selection;
|
|
97
|
+
}
|
|
98
|
+
export interface Plan extends PlanCore {
|
|
99
|
+
plan_id: string;
|
|
100
|
+
diagnostics: string[];
|
|
101
|
+
/** (3.2, §11.8 "Sugar") a plain request's effects AS WRITTEN when one carried a `-> ` / `{ oqx }` expression;
|
|
102
|
+
* not digested (the core already holds the concrete effects), recorded in the intent record as `templates` */
|
|
103
|
+
templates?: unknown[];
|
|
104
|
+
/** excluded from the digest; omittable on echo */
|
|
105
|
+
preview?: PlanPreview;
|
|
106
|
+
}
|
|
107
|
+
export interface Receipt {
|
|
108
|
+
plan_id: string;
|
|
109
|
+
/** the one `commits` row (`null` when the plan had nothing to commit) */
|
|
110
|
+
commit: string | null;
|
|
111
|
+
revisions: ApplyRevision[];
|
|
112
|
+
/** `$new.n` → the minted id */
|
|
113
|
+
new_ids: Record<string, string>;
|
|
114
|
+
committed: true;
|
|
115
|
+
/** (3.3, §11.9) the plan's `preview.summary` — what was committed, in words (`[]` when the plan was handed back without its preview) */
|
|
116
|
+
summary: string[];
|
|
117
|
+
}
|
|
118
|
+
export { canonicalJson } from "./canonical.js";
|
|
119
|
+
/** The executable core of a plan — the six digested keys (seven with `selection`), nothing else. */
|
|
120
|
+
export declare function planCore(p: PlanCore): PlanCore;
|
|
121
|
+
/** `plan_id = hex(sha256(canonical(core)))` (§11.5). */
|
|
122
|
+
export declare function planDigest(core: PlanCore): string;
|
|
123
|
+
export interface PlanEffectsRequest {
|
|
124
|
+
repoId: string;
|
|
125
|
+
/** Working-tree root for the default doc store (the `path_taken` disk check; the move/remove previews). */
|
|
126
|
+
rootPath?: string;
|
|
127
|
+
docStore?: DocStore;
|
|
128
|
+
omgbaseDir?: string;
|
|
129
|
+
/** The effects as given (validated here: a shape error is `filter_invalid`); with `select`, the templates (§11.8). */
|
|
130
|
+
effects: unknown;
|
|
131
|
+
/** (3.1) an OQX selector: its hits × `effects` (templates) are the effects planned */
|
|
132
|
+
select?: unknown;
|
|
133
|
+
/** (3.1) `{ max }`: the bound on the selection (`selection_too_large` beyond it); the implicit ceiling without it */
|
|
134
|
+
expect?: unknown;
|
|
135
|
+
}
|
|
136
|
+
/** The kernel op as the plan carries it (`childIds` → `child_ids`). */
|
|
137
|
+
export declare function wireOp(o: Op): WireOp;
|
|
138
|
+
/** A plan's op back to the kernel's spelling. */
|
|
139
|
+
export declare function kernelOp(o: WireOp): Op;
|
|
140
|
+
/**
|
|
141
|
+
* Lower an ordered effect list into a frozen Plan (§11.6): under the symbolic
|
|
142
|
+
* minter, resolve and lower each effect in order (conflicts by focus kind,
|
|
143
|
+
* identical duplicates dropped with a diagnostic), render the touched documents,
|
|
144
|
+
* freeze the preconditions, digest the core. Reads only; mints no real id.
|
|
145
|
+
*/
|
|
146
|
+
export declare function planEffects(store: Store, req: PlanEffectsRequest): Plan;
|
|
147
|
+
export interface ExecuteRequest {
|
|
148
|
+
repoId: string;
|
|
149
|
+
rootPath?: string;
|
|
150
|
+
docStore?: DocStore;
|
|
151
|
+
omgbaseDir?: string;
|
|
152
|
+
/** the commit's `actor` (null when the caller has none — a fixture step without one) and `reason` */
|
|
153
|
+
origin: {
|
|
154
|
+
actor: string | null;
|
|
155
|
+
reason?: string;
|
|
156
|
+
};
|
|
157
|
+
/** Commit timestamp (RFC 3339 UTC); defaults to now (see `ApplyRequest.ts`). */
|
|
158
|
+
ts?: string;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* The plan form's admission (§11.7): `version` first — anything but 1 is
|
|
162
|
+
* `unsupported_plan_version { version, supported: [1] }` — then the core's keys
|
|
163
|
+
* must be present (`filter_invalid`), then the recomputed digest must equal the
|
|
164
|
+
* embedded `plan_id` (`plan_mismatch { expected, actual }`). `preview` and
|
|
165
|
+
* `diagnostics` are ignored.
|
|
166
|
+
*/
|
|
167
|
+
export declare function admitPlan(input: unknown): Plan;
|
|
168
|
+
/** `execute { plan }` (§11.7): admit, then commit exactly that plan. */
|
|
169
|
+
export declare function executePlan(store: Store, req: ExecuteRequest & {
|
|
170
|
+
plan: unknown;
|
|
171
|
+
}): Receipt;
|
|
172
|
+
/** `execute { plan_id, effects, select?, expect? }` (§11.7): re-plan (with the selector when one is given, §11.8); the digest must equal `plan_id`, else `plan_mismatch`. */
|
|
173
|
+
export declare function executeByDigest(store: Store, req: ExecuteRequest & {
|
|
174
|
+
planId: string;
|
|
175
|
+
effects: unknown;
|
|
176
|
+
select?: unknown;
|
|
177
|
+
expect?: unknown;
|
|
178
|
+
}): Receipt;
|
|
179
|
+
/**
|
|
180
|
+
* `apply { effects }` with both halves kept (the sugar's seam — `sugar.ts`,
|
|
181
|
+
* the `omg` verbs, the whole-document update): the Plan always, and the
|
|
182
|
+
* Receipt when it committed (`dryRun` plans only — the CLI's `--dry-run`,
|
|
183
|
+
* spec/cli §3.6). Plan + execute run under one lock and one transaction,
|
|
184
|
+
* exactly as `applyEffects`.
|
|
185
|
+
*/
|
|
186
|
+
export declare function applyEffectsDetailed(store: Store, req: ExecuteRequest & {
|
|
187
|
+
effects: unknown;
|
|
188
|
+
select?: unknown;
|
|
189
|
+
expect?: unknown;
|
|
190
|
+
dryRun?: boolean;
|
|
191
|
+
}): {
|
|
192
|
+
plan: Plan;
|
|
193
|
+
receipt?: Receipt;
|
|
194
|
+
};
|
|
195
|
+
/** `apply { effects, select?, expect? }` (§11.7): plan + execute under one lock and one transaction; `dryRun` returns the Plan. */
|
|
196
|
+
export declare function applyEffects(store: Store, req: ExecuteRequest & {
|
|
197
|
+
effects: unknown;
|
|
198
|
+
select?: unknown;
|
|
199
|
+
expect?: unknown;
|
|
200
|
+
dryRun?: boolean;
|
|
201
|
+
}): Plan | Receipt;
|
|
202
|
+
/** Every string that is a key of `ids` replaced by its value, recursively (arrays and plain objects) — a plan's `$new.n` realized from a receipt's `new_ids`. */
|
|
203
|
+
export declare function substituteSymbols<T>(value: T, ids: Record<string, string>): T;
|
|
204
|
+
/**
|
|
205
|
+
* A planner error as the sugar reports it (`sugar.ts` `applySugar`): the
|
|
206
|
+
* `effect_index` the planner adds (§11.6) is dropped — the tool or verb built
|
|
207
|
+
* the effects itself, so the index names nothing the caller sent and the
|
|
208
|
+
* kernel's data (`op_index`, `block`, `current`, …) stays as pinned.
|
|
209
|
+
*/
|
|
210
|
+
export declare function stripEffectIndex(err: unknown): unknown;
|