@beehexa/hexasync-template-index 2608.20.18 → 2608.20.31

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.
Files changed (57) hide show
  1. package/dist/checkpoints.d.ts +47 -0
  2. package/dist/checkpoints.d.ts.map +1 -0
  3. package/dist/checkpoints.js +59 -0
  4. package/dist/checkpoints.js.map +1 -0
  5. package/dist/cursorContext.d.ts +204 -0
  6. package/dist/cursorContext.d.ts.map +1 -0
  7. package/dist/cursorContext.js +479 -0
  8. package/dist/cursorContext.js.map +1 -0
  9. package/dist/detectors.d.ts +103 -0
  10. package/dist/detectors.d.ts.map +1 -0
  11. package/dist/detectors.js +104 -0
  12. package/dist/detectors.js.map +1 -0
  13. package/dist/discovery.d.ts +249 -0
  14. package/dist/discovery.d.ts.map +1 -0
  15. package/dist/discovery.js +455 -0
  16. package/dist/discovery.js.map +1 -0
  17. package/dist/effectiveGraph.d.ts +251 -0
  18. package/dist/effectiveGraph.d.ts.map +1 -0
  19. package/dist/effectiveGraph.js +559 -0
  20. package/dist/effectiveGraph.js.map +1 -0
  21. package/dist/failures.d.ts +50 -0
  22. package/dist/failures.d.ts.map +1 -0
  23. package/dist/failures.js +125 -0
  24. package/dist/failures.js.map +1 -0
  25. package/dist/graph.d.ts +47 -0
  26. package/dist/graph.d.ts.map +1 -0
  27. package/dist/graph.js +230 -0
  28. package/dist/graph.js.map +1 -0
  29. package/dist/index.d.ts +21 -0
  30. package/dist/index.d.ts.map +1 -0
  31. package/dist/index.js +38 -0
  32. package/dist/index.js.map +1 -0
  33. package/dist/queries.d.ts +102 -0
  34. package/dist/queries.d.ts.map +1 -0
  35. package/dist/queries.js +469 -0
  36. package/dist/queries.js.map +1 -0
  37. package/dist/ranges.d.ts +104 -0
  38. package/dist/ranges.d.ts.map +1 -0
  39. package/dist/ranges.js +411 -0
  40. package/dist/ranges.js.map +1 -0
  41. package/dist/resolveField.d.ts +125 -0
  42. package/dist/resolveField.d.ts.map +1 -0
  43. package/dist/resolveField.js +234 -0
  44. package/dist/resolveField.js.map +1 -0
  45. package/dist/tier1Service.d.ts +96 -0
  46. package/dist/tier1Service.d.ts.map +1 -0
  47. package/dist/tier1Service.js +194 -0
  48. package/dist/tier1Service.js.map +1 -0
  49. package/dist/tier2Service.d.ts +195 -0
  50. package/dist/tier2Service.d.ts.map +1 -0
  51. package/dist/tier2Service.js +642 -0
  52. package/dist/tier2Service.js.map +1 -0
  53. package/dist/yamlScalar.d.ts +17 -0
  54. package/dist/yamlScalar.d.ts.map +1 -0
  55. package/dist/yamlScalar.js +101 -0
  56. package/dist/yamlScalar.js.map +1 -0
  57. package/package.json +4 -4
@@ -0,0 +1,234 @@
1
+ /**
2
+ * Point-wise value resolution — one field, on demand (FR-45, Story 3.3).
3
+ *
4
+ * Explaining a single field must not cost a whole-project substitution pass. A hover over one
5
+ * `url:` should not resolve 273 components, and a project that takes 650 ms to compose cannot
6
+ * afford to do it per cursor movement.
7
+ *
8
+ * It REUSES the composer's `resolveVariablePool` / `substituteVariables` rather than
9
+ * reimplementing them. Two answers to "what does this variable resolve to" is one answer too
10
+ * many: the editor explaining a field and the composer producing output have to agree, and the
11
+ * only way to guarantee that is one implementation. In particular the longest-key-first rule —
12
+ * without which `**Id**` corrupts `**ProductId**` — is the composer's, not a copy of it.
13
+ */
14
+ import { classifyTemplating, } from '@beehexa/hexasync-template-model';
15
+ import { resolveVariablePool, substituteVariables, } from '@beehexa/hexasync-template-compose';
16
+ export function preparePool(variables) {
17
+ return resolveVariablePool(variables);
18
+ }
19
+ /**
20
+ * Resolve one field's value against a project's pool.
21
+ *
22
+ * `pool` is prepared by the caller so a burst of fields shares one preparation — the transitive
23
+ * pass over the pool is O(keys²) and doing it per field would dominate everything else.
24
+ */
25
+ export function resolveFieldValue(raw, pool, variables) {
26
+ if (typeof raw !== 'string') {
27
+ return {
28
+ value: String(raw ?? ''),
29
+ literal: true,
30
+ contributed: [],
31
+ unresolved: [],
32
+ runtime: [],
33
+ };
34
+ }
35
+ const occurrences = classifyTemplating(raw);
36
+ const composeTime = occurrences.filter((o) => o.layer === 'compose-time');
37
+ const runtime = occurrences.filter((o) => o.layer === 'runtime');
38
+ if (composeTime.length === 0) {
39
+ // `classifyTemplating` only recognises IDENTIFIER-shaped `**Key**`, while `substituteVariables`
40
+ // replaces any pool key verbatim. A pool key with a dot, a hyphen or nothing at all between the
41
+ // markers therefore substitutes in the composer while the explainer called the field literal and
42
+ // handed back the unsubstituted text — two answers to one question, which this file's own
43
+ // premise says is one too many. Falling through to substitution keeps them the same answer.
44
+ const touched = pool.keys.some((key) => key !== '' && raw.includes(key));
45
+ if (!touched) {
46
+ return {
47
+ value: raw,
48
+ literal: runtime.length === 0,
49
+ contributed: [],
50
+ unresolved: [],
51
+ runtime,
52
+ };
53
+ }
54
+ return {
55
+ value: substituteVariables(raw, pool),
56
+ literal: false,
57
+ contributed: pool.keys
58
+ .filter((key) => key !== '' && raw.includes(key))
59
+ .map((key) => ({ key, value: pool.resolved[key] ?? '' })),
60
+ unresolved: [],
61
+ runtime,
62
+ };
63
+ }
64
+ const contributed = [];
65
+ const unresolved = [];
66
+ const seen = new Set();
67
+ for (const occurrence of composeTime) {
68
+ if (seen.has(occurrence.raw))
69
+ continue;
70
+ seen.add(occurrence.raw);
71
+ // `raw` is the full `**Key**` form, which is how the pool is keyed.
72
+ if (Object.prototype.hasOwnProperty.call(variables, occurrence.raw)) {
73
+ // A key defined with NO value — `'**Key**':` with nothing after it — is not a definition that
74
+ // resolves to empty. Read the DECLARED value, not `pool.resolved`: the pool already coerces a
75
+ // null through `?.toString() ?? ''`, so by then the distinction is gone. Left as `''` the
76
+ // token was erased from the text and success reported, so a truncated variables line silently
77
+ // deleted characters from every field using it.
78
+ const declared = variables[occurrence.raw];
79
+ if (declared === undefined || declared === null) {
80
+ unresolved.push(occurrence.raw);
81
+ continue;
82
+ }
83
+ contributed.push({
84
+ key: occurrence.raw,
85
+ value: pool.resolved[occurrence.raw] ?? '',
86
+ });
87
+ }
88
+ else {
89
+ unresolved.push(occurrence.raw);
90
+ }
91
+ }
92
+ // The composer's own substitution, over one string instead of a whole document.
93
+ const value = substituteVariables(raw, pool);
94
+ // Anything STILL a compose-time token after substitution is unresolved, whatever the pool said.
95
+ //
96
+ // The loop above only inspects tokens written in this field, so a token reached indirectly was
97
+ // invisible: with `{'**Host**': 'api.**Missing**.com'}`, the field `https://**Host**/x` returned
98
+ // `api.**Missing**.com` with `unresolved: []` — the file's own docstring calls that "how a
99
+ // `**Missing**` reaches production looking like a deliberate literal". The same check catches a
100
+ // cycle (`**A**`→`**B**`→`**A**` resolved to itself and reported as resolved) and a pool whose
101
+ // single non-fixpoint pass left a residual token behind, because all three end the same way: a
102
+ // token in the OUTPUT. Checking the result rather than the input is what makes it one rule.
103
+ for (const residual of classifyTemplating(value)) {
104
+ if (residual.layer !== 'compose-time')
105
+ continue;
106
+ if (seen.has(residual.raw) && unresolved.includes(residual.raw))
107
+ continue;
108
+ if (!unresolved.includes(residual.raw))
109
+ unresolved.push(residual.raw);
110
+ }
111
+ return {
112
+ value,
113
+ literal: false,
114
+ contributed,
115
+ unresolved,
116
+ runtime,
117
+ };
118
+ }
119
+ /**
120
+ * A resolver bound to one project's pool, with a cache.
121
+ *
122
+ * Keyed by PROJECT and pool GENERATION, not by identity: the same field asked twice while
123
+ * nothing changed must not repeat the work, and the cache must vanish the moment
124
+ * `variables.yaml` moves — which is what Story 3.6's invalidation drops.
125
+ */
126
+ export class FieldResolver {
127
+ variables;
128
+ generation;
129
+ projectId;
130
+ maxEntries;
131
+ #pool;
132
+ #cache;
133
+ constructor(variables,
134
+ /** Bumped by the owner whenever the pool changes; part of every cache key. */
135
+ generation,
136
+ /**
137
+ * The project this resolver belongs to, also part of the key (Story 3.3 AC 3).
138
+ *
139
+ * Two projects genuinely can share a generation number — nothing in the type system stops a
140
+ * caller numbering its own — and `**BaseUrl**` resolves to a different host in each. That the
141
+ * current owner happens to hand out a service-global counter makes the collision unreachable
142
+ * today by accident, not by design, and an accident is not a cache key.
143
+ */
144
+ projectId = '',
145
+ /**
146
+ * A cache store, optionally SHARED with other resolvers.
147
+ *
148
+ * The default is private to this resolver, and with a private store the composite key below
149
+ * is decorative — the instance already implies its project and generation. That was the state
150
+ * this class shipped in, and a test asserting the key "worked" passed with the key reduced to
151
+ * the raw value, which is no assertion at all.
152
+ *
153
+ * A shared store is what makes the key load-bearing, and is what Story 3.3 AC 3 describes
154
+ * when it asks for a cache "keyed by project and pool generation": one store, many projects,
155
+ * entries that must not be served across them.
156
+ */
157
+ store = new Map(),
158
+ /**
159
+ * Upper bound on the SHARED store, as a backstop against unbounded growth.
160
+ *
161
+ * Generous, because evicting a live project's entries costs a recompute rather than
162
+ * correctness, and the entries are small. The precise rule is `#evictSuperseded`'s
163
+ * generation check; this only catches what that cannot see.
164
+ */
165
+ maxEntries = 5_000) {
166
+ this.variables = variables;
167
+ this.generation = generation;
168
+ this.projectId = projectId;
169
+ this.maxEntries = maxEntries;
170
+ this.#pool = preparePool(variables);
171
+ this.#cache = store;
172
+ }
173
+ resolve(raw) {
174
+ if (typeof raw !== 'string') {
175
+ return resolveFieldValue(raw, this.#pool, this.variables);
176
+ }
177
+ const key = `${this.projectId}\u0000${this.generation}\u0000${raw}`;
178
+ const hit = this.#cache.get(key);
179
+ if (hit)
180
+ return hit;
181
+ const result = resolveFieldValue(raw, this.#pool, this.variables);
182
+ this.#cache.set(key, result);
183
+ this.#evictSuperseded();
184
+ return result;
185
+ }
186
+ /**
187
+ * Drop this project's entries from earlier generations, and bound the store.
188
+ *
189
+ * The generation moves on every `variables.yaml` keystroke, so a shared store — the mode this
190
+ * class documents as the real one — accumulated an entry per generation per field for the life of
191
+ * the process. Superseded entries became UNREACHABLE, which is not the same as removed, and the
192
+ * docstring's claim that the cache "must vanish the moment `variables.yaml` moves" had nothing
193
+ * implementing it: no clear, no delete, no bound, and `cacheSize` only observed.
194
+ *
195
+ * Two rules, in order. Entries for THIS project at an older generation are dead by definition, so
196
+ * they go first and precisely. The size cap is the backstop for everything else — other projects'
197
+ * entries, which this resolver cannot reason about — evicting in insertion order, which for a
198
+ * `Map` is oldest-first.
199
+ */
200
+ #evictSuperseded() {
201
+ const mine = `${this.projectId}\u0000`;
202
+ const current = `${mine}${this.generation}\u0000`;
203
+ for (const key of this.#cache.keys()) {
204
+ if (key.startsWith(mine) && !key.startsWith(current)) {
205
+ this.#cache.delete(key);
206
+ }
207
+ }
208
+ while (this.#cache.size > this.maxEntries) {
209
+ const oldest = this.#cache.keys().next().value;
210
+ if (oldest === undefined)
211
+ break;
212
+ this.#cache.delete(oldest);
213
+ }
214
+ }
215
+ /**
216
+ * Forget everything this resolver cached.
217
+ *
218
+ * The invalidation hook Story 3.6 AC 2's second clause describes and nothing provided. Scoped to
219
+ * this project, so a shared store goes on serving the others.
220
+ */
221
+ invalidate() {
222
+ const mine = `${this.projectId}\u0000`;
223
+ for (const key of this.#cache.keys()) {
224
+ if (key.startsWith(mine))
225
+ this.#cache.delete(key);
226
+ }
227
+ }
228
+ /** How many distinct values are cached — exposed so caching is testable. Counts the whole
229
+ * store, which may be shared with other projects' resolvers. */
230
+ get cacheSize() {
231
+ return this.#cache.size;
232
+ }
233
+ }
234
+ //# sourceMappingURL=resolveField.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveField.js","sourceRoot":"","sources":["../src/resolveField.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EACL,kBAAkB,GAEnB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,oCAAoC,CAAC;AA4B5C,MAAM,UAAU,WAAW,CAAC,SAAkC;IAC5D,OAAO,mBAAmB,CAAC,SAAS,CAAC,CAAC;AACxC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAC/B,GAAY,EACZ,IAAkB,EAClB,SAAkC;IAElC,IAAI,OAAO,GAAG,KAAK,QAAQ,E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M,KAAK,SAAS;gBAAE,MAAM;YAChC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,UAAU;QACR,MAAM,IAAI,GAAG,GAAG,IAAI,CAAC,SAAS,QAAQ,CAAC;QACvC,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;YACrC,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC;gBAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;IAED;qEACiE;IACjE,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IAC1B,CAAC;CACF"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * The Tier 1 index service — the single writer (Story 2.5, AD-5 and AD-14).
3
+ *
4
+ * AD-5 exists to prevent two owners of one entity, and a consumer unable to tell a stale reply
5
+ * from a fresh one. So: all mutation happens here, consumers receive an **immutable,
6
+ * version-stamped snapshot**, and a new version is announced by push. A consumer holding version
7
+ * N can always tell whether what it has is current, which is what makes caching a derived view
8
+ * safe at all.
9
+ *
10
+ * AD-14 exists because a branch switch rewrites hundreds of `main.yaml` files at once. A build
11
+ * per file would queue hundreds of stale builds behind the one that matters, so a superseded
12
+ * build is **dropped rather than queued**, and a cancelled request resolves to a sentinel instead
13
+ * of throwing — a cancellation is an ordinary outcome, not a failure.
14
+ */
15
+ import type { TemplateReader } from '@beehexa/hexasync-template-ports';
16
+ import { type DiscoveredProject, type DiscoveryOptions } from './discovery.js';
17
+ import { type InheritanceEdge, type ProjectGraph } from './graph.js';
18
+ /** What a cancelled build resolves to. Never thrown — see AD-14 above. */
19
+ export declare const CANCELLED: unique symbol;
20
+ export type Cancelled = typeof CANCELLED;
21
+ /** An immutable, version-stamped view. Consumers hold these; they never hold the service. */
22
+ export interface Tier1Snapshot {
23
+ readonly version: number;
24
+ readonly rootUri: string;
25
+ readonly graph: ProjectGraph;
26
+ /** Wall-clock milliseconds the build took — NFR-4's budget is measured, not assumed. */
27
+ readonly buildMs: number;
28
+ }
29
+ export interface Tier1Options extends DiscoveryOptions {
30
+ /** Injected so a test can drive time; the index must never read a clock it cannot control. */
31
+ now?: () => number;
32
+ /**
33
+ * How long to wait for the change storm to settle before rebuilding.
34
+ *
35
+ * A branch switch fires the watcher once per file. Coalescing turns hundreds of rebuilds into
36
+ * one; without it the last useful build starts only after every useless one has finished.
37
+ */
38
+ coalesceMs?: number;
39
+ /**
40
+ * Where a throwing listener's error goes.
41
+ *
42
+ * Without it a bad consumer takes the whole push loop down with it. Optional because the
43
+ * index has no opinion about reporting — the host does.
44
+ */
45
+ onListenerError?: (error: unknown) => void;
46
+ }
47
+ export type Tier1Listener = (snapshot: Tier1Snapshot) => void;
48
+ export declare class Tier1IndexService {
49
+ #private;
50
+ private readonly reader;
51
+ private readonly options;
52
+ constructor(reader: TemplateReader, options?: Tier1Options);
53
+ /** The current snapshot, or `undefined` before the first build completes. */
54
+ get snapshot(): Tier1Snapshot | undefined;
55
+ /** Subscribe to version pushes. Returns an unsubscribe function. */
56
+ onDidChange(listener: Tier1Listener): () => void;
57
+ /**
58
+ * Rebuild the whole index for `rootUri`.
59
+ *
60
+ * Every call takes a token. A build that finds a newer token on the way out resolves to
61
+ * `CANCELLED` and publishes nothing — which is what "dropped rather than queued" means in
62
+ * practice: the work may finish, but its result never becomes the snapshot.
63
+ */
64
+ rebuild(rootUri: string): Promise<Tier1Snapshot | Cancelled>;
65
+ /**
66
+ * Request a rebuild, coalescing a storm of them into one.
67
+ *
68
+ * Returns the promise of whichever build actually runs, so a caller can await settling without
69
+ * having to know how many changes arrived.
70
+ */
71
+ requestRebuild(rootUri: string): Promise<Tier1Snapshot | Cancelled>;
72
+ /**
73
+ * Rebuild ONE project's entry and its edges, leaving every other project untouched
74
+ * (Story 2.5 AC 1, added 2026-08-02 after the epic review).
75
+ *
76
+ * The full `rebuild` re-globs and re-reads every `main.yaml` in the folder — on the real
77
+ * corpus that is 113 reads for one keystroke, which contradicts the AC's second clause
78
+ * outright rather than merely leaving it untested.
79
+ *
80
+ * Edges are recomputed wholesale from the (mostly unchanged) project list because they are a
81
+ * pure function of it and cost no IO — the expensive part is reading, and this reads exactly
82
+ * one file. Returns `CANCELLED` when a newer build has already superseded it.
83
+ */
84
+ rebuildProject(mainYamlUri: string): Promise<Tier1Snapshot | Cancelled>;
85
+ /** Abandon any in-flight or scheduled build. Used on disposal and on workspace removal. */
86
+ cancelPending(): void;
87
+ /** The project owning a file, or `undefined` — never a guess (FR-51). */
88
+ projectForFile(fileUri: string): DiscoveredProject | undefined;
89
+ listProjects(): readonly DiscoveredProject[];
90
+ projectsInheriting(fileUri: string): string[];
91
+ outgoingEdges(projectId: string): InheritanceEdge[];
92
+ incomingEdges(projectId: string): InheritanceEdge[];
93
+ unresolvedEdges(): InheritanceEdge[];
94
+ cycles(): readonly (readonly string[])[];
95
+ }
96
+ //# sourceMappingURL=tier1Service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tier1Service.d.ts","sourceRoot":"","sources":["../src/tier1Service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAIL,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAML,KAAK,eAAe,EACpB,KAAK,YAAY,EAClB,MAAM,YAAY,CAAC;AAapB,0EAA0E;AAC1E,eAAO,MAAM,SAAS,eAAkC,CAAC;AACzD,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC;AAEzC,6FAA6F;AAC7F,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAC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EAAE,MAAM,GAAG,MAAM,EAAE,CAI5C;IAED,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,eAAe,EAAE,CAIlD;IAED,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,eAAe,EAAE,CAIlD;IAED,eAAe,IAAI,eAAe,EAAE,CAEnC;IAED,MAAM,IAAI,SAAS,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAEvC;CACF"}
@@ -0,0 +1,194 @@
1
+ import { discoverProjects, rediscoverProject, projectForFile, } from './discovery.js';
2
+ import { buildProjectGraph, getIncomingEdges, getOutgoingEdges, getProjectsInheriting, getUnresolvedEdges, } from './graph.js';
3
+ /** Freeze an object and everything reachable from it. */
4
+ function deepFreeze(value, seen = new WeakSet()) {
5
+ if (value === null || typeof value !== 'object')
6
+ return value;
7
+ if (seen.has(value))
8
+ return value;
9
+ seen.add(value);
10
+ for (const key of Object.getOwnPropertyNames(value)) {
11
+ deepFreeze(value[key], seen);
12
+ }
13
+ return Object.freeze(value);
14
+ }
15
+ /** What a cancelled build resolves to. Never thrown — see AD-14 above. */
16
+ export const CANCELLED = Symbol('tier1-build-cancelled');
17
+ export class Tier1IndexService {
18
+ reader;
19
+ options;
20
+ #snapshot;
21
+ #version = 0;
22
+ #listeners = new Set();
23
+ #buildToken = 0;
24
+ #coalesceTimer;
25
+ #pending;
26
+ #settlePending;
27
+ constructor(reader, options = {}) {
28
+ this.reader = reader;
29
+ this.options = options;
30
+ }
31
+ /** The current snapshot, or `undefined` before the first build completes. */
32
+ get snapshot() {
33
+ return this.#snapshot;
34
+ }
35
+ /** Subscribe to version pushes. Returns an unsubscribe function. */
36
+ onDidChange(listener) {
37
+ this.#listeners.add(listener);
38
+ return () => this.#listeners.delete(listener);
39
+ }
40
+ /**
41
+ * Rebuild the whole index for `rootUri`.
42
+ *
43
+ * Every call takes a token. A build that finds a newer token on the way out resolves to
44
+ * `CANCELLED` and publishes nothing — which is what "dropped rather than queued" means in
45
+ * practice: the work may finish, but its result never becomes the snapshot.
46
+ */
47
+ async rebuild(rootUri) {
48
+ const token = ++this.#buildToken;
49
+ const now = this.options.now ?? (() => Date.now());
50
+ const started = now();
51
+ const projects = await discoverProjects(rootUri, this.reader, this.options);
52
+ if (token !== this.#buildToken)
53
+ return CANCELLED;
54
+ const graph = buildProjectGraph(projects);
55
+ if (token !== this.#buildToken)
56
+ return CANCELLED;
57
+ // DEEP frozen. `Object.freeze` is shallow, so the previous version left `graph`,
58
+ // `graph.projects` and `graph.edges` freely mutable by any consumer — and the test that
59
+ // certified the AC asserted `Object.isFrozen(snapshot)`, which passes on a shallow freeze.
60
+ // The AC says immutable; a consumer caching a derived view has to be able to rely on it.
61
+ const snapshot = deepFreeze({
62
+ version: ++this.#version,
63
+ rootUri,
64
+ graph,
65
+ buildMs: now() - started,
66
+ });
67
+ this.#snapshot = snapshot;
68
+ this.#publish(snapshot);
69
+ return snapshot;
70
+ }
71
+ /**
72
+ * Push the new version (AD-5). A consumer that has to ask cannot know when to.
73
+ *
74
+ * Each listener is isolated: one that throws used to propagate out of `rebuild()` AND stop
75
+ * every later listener being notified, so a single bad consumer could silently freeze the
76
+ * status bar for everyone. Errors go to `onListenerError` if the host supplied one.
77
+ */
78
+ #publish(snapshot) {
79
+ for (const listener of this.#listeners) {
80
+ try {
81
+ listener(snapshot);
82
+ }
83
+ catch (error) {
84
+ this.options.onListenerError?.(error);
85
+ }
86
+ }
87
+ }
88
+ /**
89
+ * Request a rebuild, coalescing a storm of them into one.
90
+ *
91
+ * Returns the promise of whichever build actually runs, so a caller can await settling without
92
+ * having to know how many changes arrived.
93
+ */
94
+ requestRebuild(rootUri) {
95
+ const delay = this.options.coalesceMs ?? 50;
96
+ // Settle the request this one supersedes. Previously the timer was cleared and `#pending`
97
+ // reassigned, so the earlier promise's `resolve` was never called and it stayed pending
98
+ // FOREVER — a caller that awaited it simply hung. The AC says a cancelled request resolves
99
+ // to a sentinel; it resolved to nothing. Not user-visible only because the extension
100
+ // `void`s it, which is luck rather than design.
101
+ this.#settlePending?.(CANCELLED);
102
+ if (this.#coalesceTimer !== undefined)
103
+ clearTimeout(this.#coalesceTimer);
104
+ this.#pending = new Promise((resolve) => {
105
+ this.#settlePending = resolve;
106
+ this.#coalesceTimer = setTimeout(() => {
107
+ this.#coalesceTimer = undefined;
108
+ this.#settlePending = undefined;
109
+ resolve(this.rebuild(rootUri));
110
+ }, delay);
111
+ });
112
+ return this.#pending;
113
+ }
114
+ /**
115
+ * Rebuild ONE project's entry and its edges, leaving every other project untouched
116
+ * (Story 2.5 AC 1, added 2026-08-02 after the epic review).
117
+ *
118
+ * The full `rebuild` re-globs and re-reads every `main.yaml` in the folder — on the real
119
+ * corpus that is 113 reads for one keystroke, which contradicts the AC's second clause
120
+ * outright rather than merely leaving it untested.
121
+ *
122
+ * Edges are recomputed wholesale from the (mostly unchanged) project list because they are a
123
+ * pure function of it and cost no IO — the expensive part is reading, and this reads exactly
124
+ * one file. Returns `CANCELLED` when a newer build has already superseded it.
125
+ */
126
+ async rebuildProject(mainYamlUri) {
127
+ const current = this.#snapshot;
128
+ // Without a baseline there is nothing to patch; the caller must do a full build first.
129
+ if (!current)
130
+ return CANCELLED;
131
+ const token = ++this.#buildToken;
132
+ const now = this.options.now ?? (() => Date.now());
133
+ const started = now();
134
+ const updated = await rediscoverProject(mainYamlUri, this.reader, current.graph.projects, this.options);
135
+ if (token !== this.#buildToken)
136
+ return CANCELLED;
137
+ // Nothing moved — a save that did not change the project set. Publishing anyway would
138
+ // churn every consumer's cached view for no reason.
139
+ if (updated === current.graph.projects)
140
+ return current;
141
+ const snapshot = deepFreeze({
142
+ version: ++this.#version,
143
+ rootUri: current.rootUri,
144
+ graph: buildProjectGraph(updated),
145
+ buildMs: now() - started,
146
+ });
147
+ this.#snapshot = snapshot;
148
+ this.#publish(snapshot);
149
+ return snapshot;
150
+ }
151
+ /** Abandon any in-flight or scheduled build. Used on disposal and on workspace removal. */
152
+ cancelPending() {
153
+ this.#buildToken += 1;
154
+ if (this.#coalesceTimer !== undefined) {
155
+ clearTimeout(this.#coalesceTimer);
156
+ this.#coalesceTimer = undefined;
157
+ }
158
+ // Same reasoning as above: a scheduled request that is abandoned must still settle.
159
+ this.#settlePending?.(CANCELLED);
160
+ this.#settlePending = undefined;
161
+ }
162
+ // ---- Tier 1 query surface (FR-42). All answered from the snapshot, none building anything.
163
+ /** The project owning a file, or `undefined` — never a guess (FR-51). */
164
+ projectForFile(fileUri) {
165
+ if (!this.#snapshot)
166
+ return undefined;
167
+ return projectForFile(fileUri, this.#snapshot.graph.projects);
168
+ }
169
+ listProjects() {
170
+ return this.#snapshot?.graph.projects ?? [];
171
+ }
172
+ projectsInheriting(fileUri) {
173
+ return this.#snapshot
174
+ ? getProjectsInheriting(this.#snapshot.graph, fileUri)
175
+ : [];
176
+ }
177
+ outgoingEdges(projectId) {
178
+ return this.#snapshot
179
+ ? getOutgoingEdges(this.#snapshot.graph, projectId)
180
+ : [];
181
+ }
182
+ incomingEdges(projectId) {
183
+ return this.#snapshot
184
+ ? getIncomingEdges(this.#snapshot.graph, projectId)
185
+ : [];
186
+ }
187
+ unresolvedEdges() {
188
+ return this.#snapshot ? getUnresolvedEdges(this.#snapshot.graph) : [];
189
+ }
190
+ cycles() {
191
+ return this.#snapshot?.graph.cycles ?? [];
192
+ }
193
+ }
194
+ //# sourceMappingURL=tier1Service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tier1Service.js","sourceRoot":"","sources":["../src/tier1Service.ts"],"names":[],"mappings":"AAeA,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,GAGf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,GAGnB,MAAM,YAAY,CAAC;AAEpB,yDAAyD;AACzD,SAAS,UAAU,CAAI,KAAQ,EAAE,IAAI,GAAG,IAAI,OAAO,EAAU;IAC3D,IAAI,KAAK,KAAK,IAAI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