@beehexa/hexasync-template-index 2608.15.1 → 2608.20.18
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/package.json +4 -4
- package/dist/checkpoints.d.ts +0 -47
- package/dist/checkpoints.d.ts.map +0 -1
- package/dist/checkpoints.js +0 -59
- package/dist/checkpoints.js.map +0 -1
- package/dist/cursorContext.d.ts +0 -204
- package/dist/cursorContext.d.ts.map +0 -1
- package/dist/cursorContext.js +0 -479
- package/dist/cursorContext.js.map +0 -1
- package/dist/detectors.d.ts +0 -103
- package/dist/detectors.d.ts.map +0 -1
- package/dist/detectors.js +0 -104
- package/dist/detectors.js.map +0 -1
- package/dist/discovery.d.ts +0 -249
- package/dist/discovery.d.ts.map +0 -1
- package/dist/discovery.js +0 -455
- package/dist/discovery.js.map +0 -1
- package/dist/effectiveGraph.d.ts +0 -240
- package/dist/effectiveGraph.d.ts.map +0 -1
- package/dist/effectiveGraph.js +0 -523
- package/dist/effectiveGraph.js.map +0 -1
- package/dist/failures.d.ts +0 -50
- package/dist/failures.d.ts.map +0 -1
- package/dist/failures.js +0 -125
- package/dist/failures.js.map +0 -1
- package/dist/graph.d.ts +0 -47
- package/dist/graph.d.ts.map +0 -1
- package/dist/graph.js +0 -230
- package/dist/graph.js.map +0 -1
- package/dist/index.d.ts +0 -21
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -38
- package/dist/index.js.map +0 -1
- package/dist/queries.d.ts +0 -102
- package/dist/queries.d.ts.map +0 -1
- package/dist/queries.js +0 -469
- package/dist/queries.js.map +0 -1
- package/dist/ranges.d.ts +0 -71
- package/dist/ranges.d.ts.map +0 -1
- package/dist/ranges.js +0 -322
- package/dist/ranges.js.map +0 -1
- package/dist/resolveField.d.ts +0 -125
- package/dist/resolveField.d.ts.map +0 -1
- package/dist/resolveField.js +0 -234
- package/dist/resolveField.js.map +0 -1
- package/dist/tier1Service.d.ts +0 -96
- package/dist/tier1Service.d.ts.map +0 -1
- package/dist/tier1Service.js +0 -194
- package/dist/tier1Service.js.map +0 -1
- package/dist/tier2Service.d.ts +0 -195
- package/dist/tier2Service.d.ts.map +0 -1
- package/dist/tier2Service.js +0 -642
- package/dist/tier2Service.js.map +0 -1
- package/dist/yamlScalar.d.ts +0 -17
- package/dist/yamlScalar.d.ts.map +0 -1
- package/dist/yamlScalar.js +0 -101
- package/dist/yamlScalar.js.map +0 -1
package/dist/effectiveGraph.js
DELETED
|
@@ -1,523 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tier 2 — one project's EFFECTIVE graph: everything it contains, including what it inherits.
|
|
3
|
-
*
|
|
4
|
-
* Tier 1 answers "which project am I in" from 113 `main.yaml` reads. Tier 2 answers "what is in
|
|
5
|
-
* this project" and costs far more, so it is lazy, per project, and bounded: it resolves that
|
|
6
|
-
* project's worklist through the SHARED COMPOSER and parses only those files — a MEASURED median
|
|
7
|
-
* of 99, range 19-213, never the workspace's 7,729 (FR-41, NFR-7).
|
|
8
|
-
*
|
|
9
|
-
* Story 3.1's AC and NFR-5 USED to say "roughly 68 for an average project", and both were amended
|
|
10
|
-
* on 2026-08-02 to the measured median of 99 — along with NFR-5's budget, which had been calibrated
|
|
11
|
-
* against the wrong figure. Recorded here because the correction is the interesting part: the
|
|
12
|
-
* premise was wrong before the result was. Argued in NOTES-epic-3.md §1.
|
|
13
|
-
*
|
|
14
|
-
* Two graphs, never merged (FR-43). The **authored** graph is what this project's own files
|
|
15
|
-
* declare; the **effective** graph is what it actually contains after inheritance and precedence.
|
|
16
|
-
* A caller must say which it wants, because the honest answer to "does this project define X" is
|
|
17
|
-
* different from "does this project have X", and a single ambiguous surface would let a caller
|
|
18
|
-
* silently get the wrong one.
|
|
19
|
-
*
|
|
20
|
-
* Components are keyed in TOKEN FORM — before variable substitution (FR-45). Structural identity
|
|
21
|
-
* has to be substitution-independent: a component whose id is `**Prefix**_Orders` is the same
|
|
22
|
-
* component whatever the pool resolves it to, and keying on the resolved value would make it a
|
|
23
|
-
* different component in every project that inherits it.
|
|
24
|
-
*/
|
|
25
|
-
import { parse } from 'yaml';
|
|
26
|
-
import { dirnameUri, joinUri } from '@beehexa/hexasync-template-model';
|
|
27
|
-
import { assembleVariablesWithProvenance, DIRECTIVE_KEYS, mergeToMainValue, normalizeComponentKey, prefetchSources, resolve as resolveWorklist, resumeMerge, } from '@beehexa/hexasync-template-compose';
|
|
28
|
-
import { checkpointPositions, nearestCheckpoint, DEFAULT_MAX_CHECKPOINTS, } from './checkpoints.js';
|
|
29
|
-
/**
|
|
30
|
-
* Collections whose entries are components.
|
|
31
|
-
*
|
|
32
|
-
* Re-exported from the composer rather than re-declared. The two lists were byte-identical, and
|
|
33
|
-
* two answers to "which top-level keys are directives rather than components" is one too many:
|
|
34
|
-
* the day a new directive is added to the merge engine, an independent copy here would start
|
|
35
|
-
* reporting it as authored data in every query and search.
|
|
36
|
-
*/
|
|
37
|
-
export { DIRECTIVE_KEYS } from '@beehexa/hexasync-template-compose';
|
|
38
|
-
/**
|
|
39
|
-
* The pool and its per-key provenance, shaped for the graph.
|
|
40
|
-
*
|
|
41
|
-
* One call, so `variables` and `variableProvenance` are always the same computation's two halves.
|
|
42
|
-
*/
|
|
43
|
-
function withProvenance(sets) {
|
|
44
|
-
const { pool, provenance } = assembleVariablesWithProvenance(sets);
|
|
45
|
-
return { variables: pool, variableProvenance: provenance };
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Serve the host's text for any file it has newer than disk, and fall through for the rest.
|
|
49
|
-
*
|
|
50
|
-
* Exported (Story 2.2 of the extension's Phase 4) because an editor-initiated compose needs exactly
|
|
51
|
-
* this and a second copy would be free to disagree about the one clause that is easy to get wrong:
|
|
52
|
-
* `exists` must be true for a file the overlay holds, or an unsaved file reads as absent.
|
|
53
|
-
*/
|
|
54
|
-
export function overlayReader(base, texts) {
|
|
55
|
-
return {
|
|
56
|
-
read: async (uri) => texts.get(uri) ?? base.read(uri),
|
|
57
|
-
exists: async (uri) => texts.has(uri) || base.exists(uri),
|
|
58
|
-
glob: (baseUri, pattern) => base.glob(baseUri, pattern),
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Record each file's document version at the moment its text is read.
|
|
63
|
-
*
|
|
64
|
-
* The watermark has to describe the text the build actually folded. Querying the host again once
|
|
65
|
-
* the build has finished asks a different question — "what version is it NOW" — and the two differ
|
|
66
|
-
* for exactly the file the developer is typing in.
|
|
67
|
-
*/
|
|
68
|
-
function stampVersions(base, documentVersion, into) {
|
|
69
|
-
const stamp = (uri) => {
|
|
70
|
-
const version = documentVersion(uri);
|
|
71
|
-
if (version !== undefined)
|
|
72
|
-
into.set(uri, version);
|
|
73
|
-
};
|
|
74
|
-
return {
|
|
75
|
-
read: async (uri) => {
|
|
76
|
-
// Stamped BEFORE the read resolves: the version must not be later than the text.
|
|
77
|
-
stamp(uri);
|
|
78
|
-
return base.read(uri);
|
|
79
|
-
},
|
|
80
|
-
exists: (uri) => base.exists(uri),
|
|
81
|
-
glob: (baseUri, pattern) => base.glob(baseUri, pattern),
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* The host's text, for EVERY read path resolution takes — not just `readFileIfExists`.
|
|
86
|
-
*
|
|
87
|
-
* `searchMain` is the one that mattered and was missed. `projectResolver` reads every ancestor's
|
|
88
|
-
* `main.yaml` through it (`projectResolver.ts:328`) and takes that file's `externals` and inline
|
|
89
|
-
* `variables` from the returned string, so an unsaved edit to an ancestor's `main.yaml` was resolved
|
|
90
|
-
* from DISK while the same file was then re-read through the overlaid reader during prefetch: one
|
|
91
|
-
* build reading one file two ways and getting two answers, with the watermark recording the
|
|
92
|
-
* editor's version. `applyChanges` deliberately routes such an edit down the rebuild path *because*
|
|
93
|
-
* the overlay is supposed to handle it.
|
|
94
|
-
*
|
|
95
|
-
* `globYaml` passes through: the overlay carries text for files that already exist, and a file the
|
|
96
|
-
* host has but disk does not is a create, which `#touches` routes to a rebuild that re-globs anyway.
|
|
97
|
-
*/
|
|
98
|
-
function overlayIO(base, texts) {
|
|
99
|
-
return {
|
|
100
|
-
...base,
|
|
101
|
-
readFileIfExists: async (uri) => texts.get(uri) ?? base.readFileIfExists(uri),
|
|
102
|
-
searchMain: async (folder) => {
|
|
103
|
-
const found = await base.searchMain(folder);
|
|
104
|
-
const overlaid = texts.get(joinUri(found.componentPath, 'main.yaml'));
|
|
105
|
-
return overlaid === undefined ? found : { ...found, mainYml: overlaid };
|
|
106
|
-
},
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Pull the components out of one parsed document.
|
|
111
|
-
*
|
|
112
|
-
* A collection is an array of items carrying `id` or `key`; a map collection is keyed by its own
|
|
113
|
-
* keys. Both shapes exist in the corpus and both have to be walked, because a component the
|
|
114
|
-
* graph cannot see is a component no later feature can offer.
|
|
115
|
-
*/
|
|
116
|
-
function collectComponents(parsed, provenance) {
|
|
117
|
-
if (!parsed || typeof parsed !== 'object')
|
|
118
|
-
return [];
|
|
119
|
-
const out = [];
|
|
120
|
-
for (const [collection, value] of Object.entries(parsed)) {
|
|
121
|
-
if (DIRECTIVE_KEYS.has(collection))
|
|
122
|
-
continue;
|
|
123
|
-
if (Array.isArray(value)) {
|
|
124
|
-
for (const item of value) {
|
|
125
|
-
if (!item || typeof item !== 'object')
|
|
126
|
-
continue;
|
|
127
|
-
const raw = 'id' in item
|
|
128
|
-
? item.id
|
|
129
|
-
: 'key' in item
|
|
130
|
-
? item.key
|
|
131
|
-
: undefined;
|
|
132
|
-
// The merge engine's own normalisation, imported rather than re-derived: it strips a
|
|
133
|
-
// surrounding quote pair and reads a leading `!` as a REMOVAL directive. Taking
|
|
134
|
-
// `String(raw)` verbatim made `- id: '!DROPME'` appear in the authored graph as a component
|
|
135
|
-
// named `!DROPME` that the project does not declare and no real component can ever match,
|
|
136
|
-
// while `effective` correctly omitted it — the two halves disagreeing about what a file says.
|
|
137
|
-
const key = normalizeComponentKey(raw);
|
|
138
|
-
if (!key)
|
|
139
|
-
continue; // `{id: null}` phantoms, and items with no id at all
|
|
140
|
-
// A removal declares nothing. `absent, not present-and-flagged` (Story 3.2 AC 4) has to
|
|
141
|
-
// hold for the authored graph too, which is the surface answering "what does this file say".
|
|
142
|
-
if (key.removes)
|
|
143
|
-
continue;
|
|
144
|
-
out.push({
|
|
145
|
-
collection,
|
|
146
|
-
id: key.id,
|
|
147
|
-
value: item,
|
|
148
|
-
provenance: { ...provenance, overrides: false, redefined: false },
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
continue;
|
|
152
|
-
}
|
|
153
|
-
if (value && typeof value === 'object') {
|
|
154
|
-
for (const [key, item] of Object.entries(value)) {
|
|
155
|
-
out.push({
|
|
156
|
-
collection,
|
|
157
|
-
id: key,
|
|
158
|
-
value: item,
|
|
159
|
-
provenance: { ...provenance, overrides: false, redefined: false },
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
return out;
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* A component's identity: collection AND id, joined by a separator no id can contain.
|
|
168
|
-
*
|
|
169
|
-
* Written as the ESCAPE `\u0000`, never as a raw byte. A literal NUL in a `.ts` file makes git
|
|
170
|
-
* treat the whole file as binary, which silently removes it from every textual diff, review and
|
|
171
|
-
* blame — 5.5 KB of source that no reviewer can see. That is exactly how it went unnoticed here.
|
|
172
|
-
*/
|
|
173
|
-
const identityOf = (c) => `${c.collection}\u0000${c.id}`;
|
|
174
|
-
/**
|
|
175
|
-
* Build one project's effective graph.
|
|
176
|
-
*
|
|
177
|
-
* Goes through the composer rather than reimplementing merge, so the graph and the artefact
|
|
178
|
-
* `compose` produces cannot drift — NFR-1's rule that the editor invents no semantics the
|
|
179
|
-
* runtime lacks is only true if there is one implementation of them.
|
|
180
|
-
*/
|
|
181
|
-
export async function buildEffectiveGraph(projectId, componentPath, mainYml, options) {
|
|
182
|
-
const { documentVersion, overlay } = options;
|
|
183
|
-
const io = overlay?.size ? overlayIO(options.io, overlay) : options.io;
|
|
184
|
-
const overlaid = overlay?.size
|
|
185
|
-
? overlayReader(options.reader, overlay)
|
|
186
|
-
: options.reader;
|
|
187
|
-
// AD-7a, captured AT READ TIME rather than at the end of the build.
|
|
188
|
-
//
|
|
189
|
-
// Every read here is awaited, so a document can advance between being read and the build
|
|
190
|
-
// finishing. Sampling `documentVersion(path)` in `finishGraph` therefore stamped the version the
|
|
191
|
-
// document had AFTERWARDS onto content read BEFORE — verified certifying v4 for text read at v3,
|
|
192
|
-
// which is the precise false-freshness the watermark exists to make impossible.
|
|
193
|
-
const readVersions = new Map();
|
|
194
|
-
const reader = documentVersion
|
|
195
|
-
? stampVersions(overlaid, documentVersion, readVersions)
|
|
196
|
-
: overlaid;
|
|
197
|
-
const { worklist, variableSets, unadmittedVariableFiles, libraryVariableSets, } = await resolveWorklist(componentPath, mainYml, io);
|
|
198
|
-
/** Wholesale losses seen by THIS build (Story 1.9). */
|
|
199
|
-
const overwrites = [];
|
|
200
|
-
const sources = await prefetchSources(worklist, reader, componentPath, mainYml);
|
|
201
|
-
// NO second parse pass. The merge already parses every worklist file, so it hands each
|
|
202
|
-
// parsed value over as it consumes it (`onFileParsed`) and the index reuses them.
|
|
203
|
-
//
|
|
204
|
-
// Measured on a real 99-file project: a separate pass cost 484 ms of a 1,295 ms build,
|
|
205
|
-
// against NFR-5's 500 ms budget — the pass WAS the budget. What remains is the composer's
|
|
206
|
-
// own merge, which is irreducible without reimplementing it, and NFR-1 forbids that.
|
|
207
|
-
const state = newFoldState();
|
|
208
|
-
// The root main.yaml is the merge BASE, so its inline components are written before any
|
|
209
|
-
// worklist file and can be overridden by one. Noted first for exactly that reason: noting it
|
|
210
|
-
// last made a partial's override look as though root main.yaml had won.
|
|
211
|
-
const rootComponents = collectComponents(safeParse(mainYml), {
|
|
212
|
-
project: projectId,
|
|
213
|
-
generation: 0,
|
|
214
|
-
sourceFile: `${componentPath}/main.yaml`,
|
|
215
|
-
});
|
|
216
|
-
state.authored.push(...rootComponents);
|
|
217
|
-
note(state, rootComponents);
|
|
218
|
-
const consume = fileConsumer(state, projectId, worklist);
|
|
219
|
-
const wanted = checkpointSchedule(worklist, options.checkpoints);
|
|
220
|
-
// EFFECTIVE: the composed result. Built by merging, so precedence, `!`-removal and
|
|
221
|
-
// later-wins are the composer's rules rather than a second implementation of them.
|
|
222
|
-
// The merged VALUE, taken directly — and through `mergeToMainValue`, which does not serialize.
|
|
223
|
-
// The stringify/reparse round trip cost 382 ms of a 977 ms build on a real 99-file project; the
|
|
224
|
-
// REPARSE half was removed here first, while `mergeToMain` went on serializing the whole document
|
|
225
|
-
// and sweeping it with a regex for a string this function immediately discarded. Both halves are
|
|
226
|
-
// gone now. `mergeToMain` is still the entry point that produces the artefact.
|
|
227
|
-
let mergedValue = {};
|
|
228
|
-
mergeToMainValue(mainYml, worklist, undefined, componentPath, sources, undefined, {
|
|
229
|
-
onFileParsed: consume,
|
|
230
|
-
onOverwrite: (record) => {
|
|
231
|
-
// Only depth-0 losses of real components. A nested id-less config array being replaced is
|
|
232
|
-
// ordinary customization, and reporting it would bury the real case.
|
|
233
|
-
if (record.depth === 0 && record.hadComponents)
|
|
234
|
-
overwrites.push(record);
|
|
235
|
-
},
|
|
236
|
-
onMerged: (value) => {
|
|
237
|
-
mergedValue = value;
|
|
238
|
-
},
|
|
239
|
-
onCheckpoint: (index, live) => captureCheckpoint(state, wanted, index, live, overwrites),
|
|
240
|
-
});
|
|
241
|
-
return finishGraph({
|
|
242
|
-
projectId,
|
|
243
|
-
componentPath,
|
|
244
|
-
mergedValue,
|
|
245
|
-
state,
|
|
246
|
-
worklist,
|
|
247
|
-
variableSets,
|
|
248
|
-
unadmittedVariableFiles,
|
|
249
|
-
libraryVariableSets,
|
|
250
|
-
overwrites,
|
|
251
|
-
sources,
|
|
252
|
-
readVersions,
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
/**
|
|
256
|
-
* Rebuild a graph after an edit, resuming from a retained prefix checkpoint (Story 3.5, FR-46).
|
|
257
|
-
*
|
|
258
|
-
* Returns `undefined` when the change cannot be applied incrementally, rather than guessing.
|
|
259
|
-
* The caller then does a full build — which is always correct, so every case this declines is a
|
|
260
|
-
* case that stays right rather than a case that breaks.
|
|
261
|
-
*
|
|
262
|
-
* `updates` carries the new text of each changed file. Nothing is read here: an incremental
|
|
263
|
-
* re-merge that went back to the filesystem would be reading the very files the editor already
|
|
264
|
-
* holds newer versions of.
|
|
265
|
-
*/
|
|
266
|
-
export function resumeEffectiveGraph(graph,
|
|
267
|
-
/**
|
|
268
|
-
* The checkpoints to resume from — passed in rather than read off the graph.
|
|
269
|
-
*
|
|
270
|
-
* They are the heaviest thing the build produces and the only part a holder may want to drop
|
|
271
|
-
* independently of the graph itself (AD-10's last-good snapshot is worth keeping long after
|
|
272
|
-
* its checkpoints are worth their memory). Making the holder name them is what lets the Tier 2
|
|
273
|
-
* service bound them to the project being edited while every hot graph stays whole.
|
|
274
|
-
*/
|
|
275
|
-
checkpoints, updates, options = {}) {
|
|
276
|
-
if (updates.size === 0)
|
|
277
|
-
return graph;
|
|
278
|
-
// FIRST index, not last. A path can occupy several worklist positions — a library file pulled in
|
|
279
|
-
// by two ancestors is a duplicate, which ordinary `type: local` declarations produce. `Map.set`
|
|
280
|
-
// in a plain forEach keeps the LAST index, so the resume began AFTER the file's earlier
|
|
281
|
-
// occurrences and folded their stale text: editing such a file gave
|
|
282
|
-
// `{id: SH, name: EDITED, legacy: yes}` where a full recompose gives `{id: SH, name: EDITED}`.
|
|
283
|
-
// Every earlier occurrence has to be replayed, so the earliest position is the one that matters.
|
|
284
|
-
const positionOf = new Map();
|
|
285
|
-
graph.worklist.forEach((item, i) => {
|
|
286
|
-
if (!positionOf.has(item.path))
|
|
287
|
-
positionOf.set(item.path, i);
|
|
288
|
-
});
|
|
289
|
-
let first = Number.POSITIVE_INFINITY;
|
|
290
|
-
for (const path of updates.keys()) {
|
|
291
|
-
const at = positionOf.get(path);
|
|
292
|
-
// Not a worklist file: the merge base (main.yaml), a variables file, an `!md` include, or a
|
|
293
|
-
// file the worklist does not yet know about. Each changes something a prefix checkpoint
|
|
294
|
-
// cannot represent — the base, the variable pool, or the worklist itself.
|
|
295
|
-
if (at === undefined)
|
|
296
|
-
return undefined;
|
|
297
|
-
if (at < first)
|
|
298
|
-
first = at;
|
|
299
|
-
}
|
|
300
|
-
const from = nearestCheckpoint(checkpoints, first - 1);
|
|
301
|
-
// Nothing retained early enough — including the case where the FIRST worklist file changed,
|
|
302
|
-
// which has no prefix to resume from and is simply a full build.
|
|
303
|
-
if (!from)
|
|
304
|
-
return undefined;
|
|
305
|
-
const sources = new Map(graph.sources);
|
|
306
|
-
for (const [path, text] of updates)
|
|
307
|
-
sources.set(path, text);
|
|
308
|
-
const state = {
|
|
309
|
-
authored: graph.authored.slice(0, from.authoredCount),
|
|
310
|
-
winningSource: new Map(from.winningSource),
|
|
311
|
-
// Checkpoints at or after the resume point describe a document that no longer exists.
|
|
312
|
-
checkpoints: checkpoints.filter((cp) => cp.index <= from.index),
|
|
313
|
-
};
|
|
314
|
-
const suffix = graph.worklist.slice(from.index + 1);
|
|
315
|
-
const consume = fileConsumer(state, graph.projectId, graph.worklist);
|
|
316
|
-
const wanted = new Set(checkpointPositions(graph.worklist, options.maxCheckpoints ?? DEFAULT_MAX_CHECKPOINTS).filter((p) => p > from.index));
|
|
317
|
-
// The prefix's losses come from the checkpoint; the suffix's are observed as it re-merges.
|
|
318
|
-
const overwrites = [...from.overwrites];
|
|
319
|
-
const mergedValue = resumeMerge(from.merged, suffix, from.index + 1, undefined, sources, undefined, {
|
|
320
|
-
onFileParsed: consume,
|
|
321
|
-
onOverwrite: (record) => {
|
|
322
|
-
// Only depth-0 losses of real components. A nested id-less config array being replaced is
|
|
323
|
-
// ordinary customization, and reporting it would bury the real case.
|
|
324
|
-
if (record.depth === 0 && record.hadComponents)
|
|
325
|
-
overwrites.push(record);
|
|
326
|
-
},
|
|
327
|
-
onCheckpoint: (index, live) => captureCheckpoint(state, wanted, index, live, overwrites),
|
|
328
|
-
});
|
|
329
|
-
return finishGraph({
|
|
330
|
-
projectId: graph.projectId,
|
|
331
|
-
componentPath: graph.componentPath,
|
|
332
|
-
mergedValue,
|
|
333
|
-
state,
|
|
334
|
-
worklist: graph.worklist,
|
|
335
|
-
variableSets: graph.variableSets,
|
|
336
|
-
unadmittedVariableFiles: graph.unadmittedVariableFiles,
|
|
337
|
-
libraryVariableSets: graph.libraryVariableSets,
|
|
338
|
-
overwrites,
|
|
339
|
-
sources,
|
|
340
|
-
readVersions: resumeVersions(graph, updates, options.documentVersion),
|
|
341
|
-
resumedFrom: from.index + 1,
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
/**
|
|
345
|
-
* Watermark for a resumed graph: carried forward for untouched files, refreshed for changed ones.
|
|
346
|
-
*
|
|
347
|
-
* A resume reads nothing — it folds `graph.sources` with `updates` applied — so an untouched file's
|
|
348
|
-
* text is exactly what the previous build recorded and its watermark is still true. Only the files
|
|
349
|
-
* in `updates` have new text, and their version is the one the caller supplied that text at.
|
|
350
|
-
*
|
|
351
|
-
* Re-querying the host for EVERY path would restamp untouched files with whatever version they have
|
|
352
|
-
* now, asserting freshness the resumed graph's sources do not have.
|
|
353
|
-
*/
|
|
354
|
-
function resumeVersions(graph, updates, documentVersion) {
|
|
355
|
-
const versions = new Map(graph.watermark);
|
|
356
|
-
for (const path of updates.keys()) {
|
|
357
|
-
const version = documentVersion?.(path);
|
|
358
|
-
if (version === undefined)
|
|
359
|
-
versions.delete(path);
|
|
360
|
-
else
|
|
361
|
-
versions.set(path, version);
|
|
362
|
-
}
|
|
363
|
-
return versions;
|
|
364
|
-
}
|
|
365
|
-
const newFoldState = () => ({
|
|
366
|
-
authored: [],
|
|
367
|
-
winningSource: new Map(),
|
|
368
|
-
checkpoints: [],
|
|
369
|
-
});
|
|
370
|
-
/**
|
|
371
|
-
* Record where each identity's WINNING definition came from.
|
|
372
|
-
*
|
|
373
|
-
* The merge consumes the worklist in order, so the last writer seen is the winner — exactly the
|
|
374
|
-
* composer's rule, observed rather than re-derived.
|
|
375
|
-
*/
|
|
376
|
-
function note(state, components) {
|
|
377
|
-
for (const c of components) {
|
|
378
|
-
const key = identityOf(c);
|
|
379
|
-
const prior = state.winningSource.get(key);
|
|
380
|
-
state.winningSource.set(key, {
|
|
381
|
-
...c.provenance,
|
|
382
|
-
seen: (prior?.seen ?? 0) + 1,
|
|
383
|
-
maxGeneration: Math.max(c.provenance.generation, prior?.maxGeneration ?? c.provenance.generation),
|
|
384
|
-
});
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
/**
|
|
388
|
-
* Consume one parsed worklist file into the fold state.
|
|
389
|
-
*
|
|
390
|
-
* Shared by the full build and the resume so an incrementally rebuilt graph cannot describe its
|
|
391
|
-
* components differently from a freshly built one.
|
|
392
|
-
*/
|
|
393
|
-
function fileConsumer(state, projectId, worklist) {
|
|
394
|
-
// A path can occupy SEVERAL worklist positions — a library file pulled in by two ancestors — and
|
|
395
|
-
// the occurrences can differ in `project` and `generation`. A plain `Map<path, item>` keeps the
|
|
396
|
-
// last one, so components contributed at the earlier position were stamped with the later
|
|
397
|
-
// position's provenance on an ordinary full build, no resume involved. The fold visits the
|
|
398
|
-
// worklist in order, so each path's occurrences are consumed in order too: queue them and take
|
|
399
|
-
// the next one per call, holding the final occurrence for any extra calls.
|
|
400
|
-
const pending = new Map();
|
|
401
|
-
for (const item of worklist) {
|
|
402
|
-
const queue = pending.get(item.path);
|
|
403
|
-
if (queue)
|
|
404
|
-
queue.push(item);
|
|
405
|
-
else
|
|
406
|
-
pending.set(item.path, [item]);
|
|
407
|
-
}
|
|
408
|
-
return (path, parsed) => {
|
|
409
|
-
const queue = pending.get(path);
|
|
410
|
-
const item = queue && (queue.length > 1 ? queue.shift() : queue[0]);
|
|
411
|
-
const generation = item?.generation ?? 0;
|
|
412
|
-
const provenance = {
|
|
413
|
-
project: item?.project ?? projectId,
|
|
414
|
-
generation,
|
|
415
|
-
sourceFile: path,
|
|
416
|
-
};
|
|
417
|
-
if (generation === 0) {
|
|
418
|
-
// COPIED before collecting. The merge folds this very object into the document and later
|
|
419
|
-
// files then deep-merge onto it in place, so an authored component holding a reference
|
|
420
|
-
// would end up showing the merged result — reporting what the project HAS under the name
|
|
421
|
-
// of what one of its files DECLARES, which is the one distinction the authored graph
|
|
422
|
-
// exists to make.
|
|
423
|
-
const components = collectComponents(structuredClone(parsed), provenance);
|
|
424
|
-
state.authored.push(...components);
|
|
425
|
-
note(state, components);
|
|
426
|
-
return;
|
|
427
|
-
}
|
|
428
|
-
note(state, collectComponents(parsed, provenance));
|
|
429
|
-
};
|
|
430
|
-
}
|
|
431
|
-
/** Which positions this build should retain, given the caller's checkpoint request. */
|
|
432
|
-
function checkpointSchedule(worklist, request) {
|
|
433
|
-
if (!request)
|
|
434
|
-
return new Set();
|
|
435
|
-
const max = typeof request === 'object'
|
|
436
|
-
? (request.max ?? DEFAULT_MAX_CHECKPOINTS)
|
|
437
|
-
: DEFAULT_MAX_CHECKPOINTS;
|
|
438
|
-
return new Set(checkpointPositions(worklist, max));
|
|
439
|
-
}
|
|
440
|
-
/** Retain one checkpoint, copying the live document because the fold goes on mutating it. */
|
|
441
|
-
function captureCheckpoint(state, wanted, index, live, overwrites) {
|
|
442
|
-
if (!wanted.has(index))
|
|
443
|
-
return;
|
|
444
|
-
state.checkpoints.push({
|
|
445
|
-
index,
|
|
446
|
-
merged: structuredClone(live),
|
|
447
|
-
authoredCount: state.authored.length,
|
|
448
|
-
winningSource: new Map(state.winningSource),
|
|
449
|
-
// A snapshot, not the live array: it goes on growing as the suffix merges.
|
|
450
|
-
overwrites: [...overwrites],
|
|
451
|
-
});
|
|
452
|
-
}
|
|
453
|
-
/** Turn a completed fold into the published graph. Shared so build and resume agree. */
|
|
454
|
-
function finishGraph(input) {
|
|
455
|
-
const { state } = input;
|
|
456
|
-
const rootMainPath = `${input.componentPath}/main.yaml`;
|
|
457
|
-
const effective = collectComponents(input.mergedValue, {
|
|
458
|
-
project: input.projectId,
|
|
459
|
-
generation: 0,
|
|
460
|
-
sourceFile: rootMainPath,
|
|
461
|
-
}).map((c) => {
|
|
462
|
-
const won = state.winningSource.get(identityOf(c));
|
|
463
|
-
return won
|
|
464
|
-
? {
|
|
465
|
-
...c,
|
|
466
|
-
provenance: {
|
|
467
|
-
project: won.project,
|
|
468
|
-
generation: won.generation,
|
|
469
|
-
sourceFile: won.sourceFile,
|
|
470
|
-
// Beat a definition from FURTHER UP the inheritance chain — which is what "overrides an
|
|
471
|
-
// inherited one" means. A component redefined twice within one project is `redefined`
|
|
472
|
-
// but overrides nothing inherited.
|
|
473
|
-
overrides: won.generation < won.maxGeneration,
|
|
474
|
-
redefined: won.seen > 1,
|
|
475
|
-
},
|
|
476
|
-
}
|
|
477
|
-
: c;
|
|
478
|
-
});
|
|
479
|
-
// AD-7a: what each source WAS when it was read. Scoped to the files this graph is actually built
|
|
480
|
-
// from, so a stamp left over from a file no longer in the worklist cannot claim freshness for it.
|
|
481
|
-
const watermark = new Map();
|
|
482
|
-
for (const path of input.sources.keys()) {
|
|
483
|
-
const version = input.readVersions?.get(path);
|
|
484
|
-
if (version !== undefined)
|
|
485
|
-
watermark.set(path, version);
|
|
486
|
-
}
|
|
487
|
-
return {
|
|
488
|
-
projectId: input.projectId,
|
|
489
|
-
componentPath: input.componentPath,
|
|
490
|
-
mergedValue: input.mergedValue,
|
|
491
|
-
authored: state.authored,
|
|
492
|
-
effective,
|
|
493
|
-
...withProvenance([...input.variableSets]),
|
|
494
|
-
unadmittedVariableFiles: input.unadmittedVariableFiles,
|
|
495
|
-
libraryVariableSets: input.libraryVariableSets,
|
|
496
|
-
overwrites: input.overwrites,
|
|
497
|
-
variableSets: input.variableSets,
|
|
498
|
-
worklist: input.worklist,
|
|
499
|
-
sources: input.sources,
|
|
500
|
-
watermark,
|
|
501
|
-
checkpoints: state.checkpoints,
|
|
502
|
-
...(input.resumedFrom === undefined
|
|
503
|
-
? {}
|
|
504
|
-
: { resumedFrom: input.resumedFrom }),
|
|
505
|
-
};
|
|
506
|
-
}
|
|
507
|
-
/**
|
|
508
|
-
* Parse without letting one broken file destroy the graph (AD-10, Story 3.6).
|
|
509
|
-
*
|
|
510
|
-
* A developer produces dozens of transient invalid states an hour. Throwing here would mean the
|
|
511
|
-
* graph disappears mid-keystroke, which is precisely when it is most wanted.
|
|
512
|
-
*/
|
|
513
|
-
function safeParse(text) {
|
|
514
|
-
try {
|
|
515
|
-
return parse(text, { keepSourceTokens: true }) ?? {};
|
|
516
|
-
}
|
|
517
|
-
catch {
|
|
518
|
-
return {};
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
/** The directory a project's files live under — used to scope watchers. */
|
|
522
|
-
export const projectFolderOf = (componentPath) => dirnameUri(componentPath);
|
|
523
|
-
//# sourceMappingURL=effectiveGraph.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"effectiveGraph.js","sourceRoot":"","sources":["../src/effectiveGraph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAEvE,OAAO,EACL,+BAA+B,EAC/B,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EACrB,eAAe,EACf,OAAO,IAAI,eAAe,EAC1B,WAAW,GAQZ,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,kBAAkB,CAAC;AAE1B;;;;;;;GAOG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAuCpE;;;;GAIG;AACH,SAAS,cAAc,CAAC,IAA0B;IAIhD,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,+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EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,2EAA2E;AAC3E,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,aAAqB,EAAU,EAAE,CAC/D,UAAU,CAAC,aAAa,CAAC,CAAC"}
|
package/dist/failures.d.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Turning a thrown error into something a diagnostic publisher can use (Story 3.6, AD-9).
|
|
3
|
-
*
|
|
4
|
-
* A developer produces dozens of transient invalid states in an hour of typing, and every one of
|
|
5
|
-
* them reaches the index as an exception. What a publisher needs from each is not a string: it
|
|
6
|
-
* needs a CODE to branch on, the FILE and RANGE to underline, and the original error kept intact
|
|
7
|
-
* so nothing is lost on the way. A message alone forces the consumer to parse English back into
|
|
8
|
-
* structure, which is how "Error at file /a/b.yaml: ..." becomes a squiggle in the wrong place.
|
|
9
|
-
*
|
|
10
|
-
* Phase 2 Story 2.1 publishes these. Nothing here publishes anything — this only makes the
|
|
11
|
-
* failure describable.
|
|
12
|
-
*/
|
|
13
|
-
/** Zero-based, matching the editor conventions a publisher will map onto. */
|
|
14
|
-
export interface SourcePosition {
|
|
15
|
-
readonly line: number;
|
|
16
|
-
readonly column: number;
|
|
17
|
-
}
|
|
18
|
-
export interface SourceRange {
|
|
19
|
-
readonly start: SourcePosition;
|
|
20
|
-
readonly end: SourcePosition;
|
|
21
|
-
}
|
|
22
|
-
export type FailureCode =
|
|
23
|
-
/** The YAML in a worklist file could not be parsed. */
|
|
24
|
-
'parse-failed'
|
|
25
|
-
/** The worklist could not be resolved — a missing `type: project` target, a cycle. */
|
|
26
|
-
| 'resolve-failed'
|
|
27
|
-
/** Anything else that stopped the compose. */
|
|
28
|
-
| 'compose-failed';
|
|
29
|
-
export interface IndexFailure {
|
|
30
|
-
readonly code: FailureCode;
|
|
31
|
-
readonly message: string;
|
|
32
|
-
/** The file the failure is about, when the error names one. */
|
|
33
|
-
readonly sourceFile?: string;
|
|
34
|
-
/** Where in that file, when the error carries a position. */
|
|
35
|
-
readonly range?: SourceRange;
|
|
36
|
-
/**
|
|
37
|
-
* The original error, unflattened.
|
|
38
|
-
*
|
|
39
|
-
* Kept because the cause chain is where the actual YAML error lives — the composer wraps it to
|
|
40
|
-
* add the filename, and a consumer that only got the wrapper would have the name of the file
|
|
41
|
-
* and nothing about what is wrong inside it.
|
|
42
|
-
*/
|
|
43
|
-
readonly cause?: unknown;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Describe a thrown error as a structured failure. Never throws and never returns undefined:
|
|
47
|
-
* a failure that cannot be described is still a failure, and swallowing it is what AC 3 forbids.
|
|
48
|
-
*/
|
|
49
|
-
export declare function describeFailure(error: unknown, fallbackFile?: string): IndexFailure;
|
|
50
|
-
//# sourceMappingURL=failures.d.ts.map
|
package/dist/failures.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"failures.d.ts","sourceRoot":"","sources":["../src/failures.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,6EAA6E;AAC7E,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAC/B,QAAQ,CAAC,GAAG,EAAE,cAAc,CAAC;CAC9B;AAED,MAAM,MAAM,WAAW;AACrB,uDAAuD;AACrD,cAAc;AAChB,sFAAsF;GACpF,gBAAgB;AAClB,8CAA8C;GAC5C,gBAAgB,CAAC;AAErB,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,+DAA+D;IAC/D,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,6DAA6D;IAC7D,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC;IAC7B;;;;;;OAMG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CAC1B;AA2DD;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,OAAO,EACd,YAAY,CAAC,EAAE,MAAM,GACpB,YAAY,CA2Dd"}
|