@bitcobblers/wod-wiki-lang 0.37.2137 → 0.37.2139

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.
@@ -1,49 +1,4 @@
1
- import { ICodeStatement, ParseError, MetricContainer, IMetric, BlockKey, TimeSpan as TimeSpan$1, OutputStatementType, MetricType, IOutputStatement, MetricOrigin } from '@bitcobblers/wod-wiki-core';
2
-
3
- interface IScript {
4
- source: string;
5
- statements: ICodeStatement[];
6
- errors?: ParseError[] | undefined;
7
- getIds(ids: number[]): ICodeStatement[];
8
- getId(id: number): ICodeStatement | undefined;
9
- getAt(index: number): ICodeStatement | undefined;
10
- }
11
- declare class WhiteboardScript implements IScript {
12
- source: string;
13
- statements: ICodeStatement[];
14
- errors: ParseError[] | undefined;
15
- private _idMap?;
16
- constructor(source: string, statements: ICodeStatement[], errors?: ParseError[]);
17
- /**
18
- * Gets the ID-to-statement Map, building it lazily on first access.
19
- * Provides O(1) lookups instead of O(n) find() calls.
20
- */
21
- private getIdMap;
22
- /**
23
- * Resolves multiple statement IDs to statements.
24
- * Uses cached Map for O(n) performance instead of O(n²).
25
- */
26
- getIds(ids: number[]): ICodeStatement[];
27
- /**
28
- * Resolves a single statement ID to a statement.
29
- * Uses cached Map for O(1) performance instead of O(n).
30
- */
31
- getId(id: number): ICodeStatement | undefined;
32
- /**
33
- * Gets a statement by its array index.
34
- */
35
- getAt(index: number): ICodeStatement | undefined;
36
- /**
37
- * Flattens grouped children (number[][]) and resolves to statements.
38
- * Convenience wrapper for getIds(children.flat()).
39
- */
40
- getFlatChildren(children: number[][]): ICodeStatement[];
41
- /**
42
- * Resolves grouped children while preserving group structure.
43
- * Maps each number[] group to ICodeStatement[] group.
44
- */
45
- getChildGroups(children: number[][]): ICodeStatement[][];
46
- }
1
+ import { ReferenceMatchKind, ReferenceRef, ReferenceDiagnostic, ICodeStatement, ParseError, MetricContainer, IMetric, BlockKey, TimeSpan as TimeSpan$1, OutputStatementType, MetricType, IOutputStatement, MetricOrigin } from '@bitcobblers/wod-wiki-core';
47
2
 
48
3
  /**
49
4
  * Canonical discipline vocabulary — the single source of truth for effort
@@ -122,6 +77,14 @@ interface IEffort {
122
77
  baseAttributes: EffortBaseAttributes;
123
78
  /** Where this record came from */
124
79
  registrySource: EffortRegistrySource;
80
+ /** Canonical equipment slugs this effort is typically performed with (ordered, deduped). */
81
+ equipment?: string[];
82
+ /** Owning note in the content store, when this record is a note projection. */
83
+ ownerNoteId?: string;
84
+ /** Seed/source collection this record was imported from. */
85
+ sourceId?: string;
86
+ /** Source file path within the originating collection. */
87
+ sourcePath?: string;
125
88
  /** Clone-based derivation metadata (user efforts only) */
126
89
  derivation?: EffortDerivation;
127
90
  /** ISO timestamp */
@@ -158,6 +121,56 @@ interface EffortStorageAdapter {
158
121
  save(effort: IEffort): Promise<void>;
159
122
  delete(slug: string): Promise<void>;
160
123
  }
124
+ /**
125
+ * Canonical equipment entity (dumbbell, rower, kettlebell…).
126
+ *
127
+ * Same durable-identity rule as efforts: references point at the slug.
128
+ * No synthetic tier — unknown equipment stays authored source + diagnostics.
129
+ */
130
+ interface IEquipment {
131
+ /** UUID */
132
+ id: string;
133
+ /** Canonical identifier — unique, lowercase, hyphenated */
134
+ slug: string;
135
+ /** Primary human-readable name */
136
+ label: string;
137
+ /** Alternative names for exact matching */
138
+ aliases: string[];
139
+ /** Where this record came from */
140
+ registrySource: 'bundled' | 'user';
141
+ /** Free-form markdown description / notes */
142
+ body?: string;
143
+ /** Owning note in the content store, when this record is a note projection. */
144
+ ownerNoteId?: string;
145
+ /** Seed/source collection this record was imported from. */
146
+ sourceId?: string;
147
+ /** Source file path within the originating collection. */
148
+ sourcePath?: string;
149
+ /** ISO timestamp */
150
+ createdAt?: string;
151
+ /** ISO timestamp */
152
+ updatedAt?: string;
153
+ }
154
+ /** Read/write registry surface for equipment definitions (mirrors IEffortRegistry). */
155
+ interface IEquipmentRegistry {
156
+ resolve(slug: string): IEquipment | null;
157
+ resolveByAlias(label: string): IEquipment | null;
158
+ list(): readonly IEquipment[];
159
+ listByOrigin(origin: 'bundled' | 'user'): readonly IEquipment[];
160
+ upsert(equipment: IEquipment): Promise<void>;
161
+ delete(slug: string): Promise<void>;
162
+ loadBundled(): Promise<void>;
163
+ isInitialized(): boolean;
164
+ }
165
+ /**
166
+ * Pluggable asynchronous persistence adapter for user-defined equipment.
167
+ * Implemented by host environments (e.g. IndexedDB in browser, filesystem in CLI).
168
+ */
169
+ interface EquipmentStorageAdapter {
170
+ load(): Promise<IEquipment[]>;
171
+ save(equipment: IEquipment): Promise<void>;
172
+ delete(slug: string): Promise<void>;
173
+ }
161
174
  interface EffortResolutionOptions {
162
175
  /** Attribute metrics from /effort/:slug query params or logged execution metrics. */
163
176
  modifiers?: Record<string, string>;
@@ -215,6 +228,124 @@ interface EffortResolverOptions {
215
228
  }
216
229
  declare const DEFAULT_RESOLVER_OPTIONS: Required<EffortResolverOptions>;
217
230
 
231
+ /**
232
+ * Shared exact reference resolver — the single door for authored-label →
233
+ * canonical effort/equipment resolution used by the parser, editor preview,
234
+ * runtime enrichment, and seed/local indexing.
235
+ *
236
+ * Precedence (accepted proposal): explicit JSON ref > exact equipment word
237
+ * prefix + remaining effort (both must resolve uniquely) > whole-label exact
238
+ * (slug/alias) > note defaults (empty-movement fill only) > effort-definition
239
+ * equipment. Fuzzy matching never produces a canonical reference here —
240
+ * unknown/ambiguous/invalid values retain the authored source and carry a
241
+ * visible diagnostic instead of falling back.
242
+ *
243
+ * The index is built once per catalog (hydration), never per statement.
244
+ */
245
+
246
+ /** Catalog collections the resolver resolves against (hydrated from storage/seed). */
247
+ interface ReferenceCatalog {
248
+ efforts: readonly IEffort[];
249
+ equipment: readonly IEquipment[];
250
+ }
251
+ /** Note/workout-level reference defaults (`metrics.*` frontmatter). */
252
+ interface ReferenceResolutionDefaults {
253
+ /** Default effort slug applied when a statement's movement is otherwise missing. */
254
+ effort?: string;
255
+ /** Default equipment slugs applied when the line and effort define none. */
256
+ equipment?: readonly string[];
257
+ }
258
+ /** Result of resolving one authored label. */
259
+ interface ResolvedReferences {
260
+ matched: ReferenceMatchKind;
261
+ /** Full authored label — never rewritten. */
262
+ label: string;
263
+ /** Materialized effort, or null when unresolved. */
264
+ effort: ResolvedEffort | null;
265
+ /** Canonical effort ref, or null. */
266
+ effortRef: ReferenceRef | null;
267
+ /** Ordered deduplicated canonical equipment refs. */
268
+ equipment: ReferenceRef[];
269
+ /** Remaining movement text after the equipment prefix strip (split path). */
270
+ remaining: string;
271
+ /** Unknown/ambiguous/invalid findings — never silently dropped. */
272
+ diagnostics: ReferenceDiagnostic[];
273
+ }
274
+ /** Materialize an effort definition (MET/derivation math) — pass the legacy EffortResolver in hosts. */
275
+ type EffortMaterializer = (effort: IEffort) => ResolvedEffort;
276
+ interface ReferenceIndex {
277
+ /** Resolve an authored movement label (statement effort text or frontmatter value). */
278
+ resolve(label: string, defaults?: ReferenceResolutionDefaults): ResolvedReferences;
279
+ /** Exact slug/alias effort lookup — no fuzzy, never synthetic. */
280
+ resolveEffort(slugOrAlias: string): IEffort | null;
281
+ /** Exact slug/alias equipment lookup — no fuzzy. */
282
+ resolveEquipment(slugOrAlias: string): IEquipment | null;
283
+ /** Materialize a resolved definition (wraps the legacy resolver when provided). */
284
+ materialize(effort: IEffort): ResolvedEffort;
285
+ }
286
+ declare function createReferenceIndex(catalog: ReferenceCatalog, materialize?: EffortMaterializer): ReferenceIndex;
287
+ /**
288
+ * Canonical statement refs for index/analytics projection — the single shared
289
+ * replacement for the per-host `extractEffortSlugs` copies.
290
+ *
291
+ * ONLY validated durable refs are returned: canonical slugs carried on the
292
+ * statement's effort/equipment metrics by the shared resolver at parse time.
293
+ * Unresolved labels yield nothing here (their authored source and diagnostics
294
+ * stay on the statement) — resolve authored labels through
295
+ * `ReferenceIndex.resolve` when projecting un-parsed text.
296
+ */
297
+ declare function extractStatementRefs(statements: readonly ICodeStatement[]): {
298
+ efforts: string[];
299
+ equipment: string[];
300
+ };
301
+ /** Canonical slugify for label→candidate-slug hygiene in host projection code. */
302
+ declare function slugifyRefLabel(label: string): string;
303
+
304
+ interface IScript {
305
+ source: string;
306
+ statements: ICodeStatement[];
307
+ errors?: ParseError[] | undefined;
308
+ getIds(ids: number[]): ICodeStatement[];
309
+ getId(id: number): ICodeStatement | undefined;
310
+ getAt(index: number): ICodeStatement | undefined;
311
+ }
312
+ declare class WhiteboardScript implements IScript {
313
+ source: string;
314
+ statements: ICodeStatement[];
315
+ errors: ParseError[] | undefined;
316
+ private _idMap?;
317
+ constructor(source: string, statements: ICodeStatement[], errors?: ParseError[]);
318
+ /**
319
+ * Gets the ID-to-statement Map, building it lazily on first access.
320
+ * Provides O(1) lookups instead of O(n) find() calls.
321
+ */
322
+ private getIdMap;
323
+ /**
324
+ * Resolves multiple statement IDs to statements.
325
+ * Uses cached Map for O(n) performance instead of O(n²).
326
+ */
327
+ getIds(ids: number[]): ICodeStatement[];
328
+ /**
329
+ * Resolves a single statement ID to a statement.
330
+ * Uses cached Map for O(1) performance instead of O(n).
331
+ */
332
+ getId(id: number): ICodeStatement | undefined;
333
+ /**
334
+ * Gets a statement by its array index.
335
+ */
336
+ getAt(index: number): ICodeStatement | undefined;
337
+ /**
338
+ * Flattens grouped children (number[][]) and resolves to statements.
339
+ * Convenience wrapper for getIds(children.flat()).
340
+ */
341
+ getFlatChildren(children: number[][]): ICodeStatement[];
342
+ /**
343
+ * Resolves grouped children while preserving group structure.
344
+ * Maps each number[] group to ICodeStatement[] group.
345
+ */
346
+ getChildGroups(children: number[][]): ICodeStatement[][];
347
+ }
348
+
218
349
  /**
219
350
  * Minimal executable runtime action shape.
220
351
  *
@@ -514,6 +645,7 @@ interface RuntimeStackOptions extends IRuntimeOptions {
514
645
  hooks?: RuntimeStackHooks;
515
646
  analyticsOptions?: {
516
647
  effortResolver?: IEffortResolver;
648
+ references?: ReferenceIndex;
517
649
  userProfile?: {
518
650
  vo2max?: number;
519
651
  };
@@ -1936,6 +2068,8 @@ interface IAnalyticsEngine {
1936
2068
  interface AnalyticsContext {
1937
2069
  /** Effort resolver for canonical slug and fuzzy alias matching. */
1938
2070
  effortResolver: IEffortResolver;
2071
+ /** Shared reference index for canonical effort/equipment resolution. */
2072
+ references?: ReferenceIndex;
1939
2073
  }
1940
2074
 
1941
2075
  interface IJitCompiler {
@@ -2363,4 +2497,4 @@ declare function getRuntimeNowMs(): number;
2363
2497
  /** Creates an INowProvider that reads the browser sender-clock when available. */
2364
2498
  declare function createBrowserRuntimeNow(): INowProvider;
2365
2499
 
2366
- export { type IRuntimeOptions as $, type AnalyticsContext as A, type BehaviorEventType as B, type CompletionDecision as C, type IRuntimeMemory as D, type EffortResolverOptions as E, TypedMemoryReference as F, type MemorySearchCriteria as G, type IMemoryReference as H, type IEffortResolver as I, type RuntimeStackLogger as J, type StackObserver as K, type StackSnapshot as L, type MemoryTag as M, type StackListener as N, type OutputListener as O, MemoryTypeEnum as P, type IAnchorValue as Q, type ResolvedEffort as R, type SubscribeOptions as S, TimeSpan as T, type Unsubscribe as U, type ButtonConfig as V, WhiteboardScript as W, type IEventHandler as X, type HandlerScope as Y, type IScriptRuntime as Z, type TestableBlockConfig as _, type IEffortRegistry as a, ScriptRuntime as a0, type EventHandlerOptions as a1, type EventCallback as a2, type TimerState as a3, type IRealtimeProcessor as a4, type ISummaryProcessor as a5, type ProjectionResult as a6, type ButtonVariant as a7, type ButtonsState as a8, type ChildrenStatusState as a9, type StackEvent as aA, type TimerDirection as aB, VISIBILITY_ICONS as aC, VISIBILITY_LABELS as aD, createBrowserRuntimeNow as aE, disciplineFactorFor as aF, filterTagsByVisibility as aG, frozenNow as aH, getMetricVisibility as aI, getRuntimeNowMs as aJ, isEffortDiscipline as aK, isFragmentTag as aL, wallClockNow as aM, type CompletionState as aa, DEFAULT_RESOLVER_OPTIONS as ab, DEFAULT_RUNTIME_OPTIONS as ac, DISCIPLINE_FACTORS as ad, type DisplayState as ae, EFFORT_DISCIPLINES as af, EFFORT_REGISTRY_ORIGINS as ag, type EffortBaseAttributes as ah, type EffortDerivation as ai, type EffortDiscipline as aj, type EffortResolvedFrom as ak, type FenceDialect as al, type FragmentDisplayState as am, type FragmentState as an, type IAnalyticsProcessorDescriptor as ao, INTENSITY_TIERS as ap, type IScript as aq, type IntensityTier as ar, type InterceptMode as as, MemoryLocation as at, type MemoryType as au, type MemoryTypeMap as av, type MemoryValueOf as aw, type RoundState as ax, type RuntimeState as ay, type ScriptRuntimeDependencies as az, type IEffort as b, type EffortResolutionOptions as c, type EffortRegistrySource as d, type EffortStorageAdapter as e, type IRuntimeActionable as f, type IEventBus as g, type IRuntimeStack as h, type IRuntimeClock as i, type IJitCompiler as j, type INowProvider as k, type RuntimeStackOptions as l, type RuntimeError as m, type IEvent as n, type IRuntimeAction as o, type IAnalyticsEngine as p, type IRuntimeBlock as q, type IBehaviorContext as r, type BehaviorEventListener as s, type Unsubscribe$1 as t, type OutputOptions as u, type IMemoryLocation as v, type IRuntimeBehavior as w, type IBlockContext as x, type MetricVisibility as y, type BlockLifecycleOptions as z };
2500
+ export { type HandlerScope as $, type AnalyticsContext as A, type BehaviorEventType as B, type IBlockContext as C, type MetricVisibility as D, type EffortResolverOptions as E, type BlockLifecycleOptions as F, type CompletionDecision as G, type IRuntimeMemory as H, type IEquipment as I, TypedMemoryReference as J, type MemorySearchCriteria as K, type IMemoryReference as L, type MemoryTag as M, type RuntimeStackLogger as N, type OutputListener as O, type StackObserver as P, type StackSnapshot as Q, type ReferenceIndex as R, type SubscribeOptions as S, TimeSpan as T, type Unsubscribe as U, type StackListener as V, WhiteboardScript as W, MemoryTypeEnum as X, type IAnchorValue as Y, type ButtonConfig as Z, type IEventHandler as _, type ReferenceResolutionDefaults as a, type IScriptRuntime as a0, type TestableBlockConfig as a1, type IRuntimeOptions as a2, ScriptRuntime as a3, type EventHandlerOptions as a4, type EventCallback as a5, type TimerState as a6, type IRealtimeProcessor as a7, type ISummaryProcessor as a8, type ProjectionResult as a9, type MemoryType as aA, type MemoryTypeMap as aB, type MemoryValueOf as aC, type ReferenceCatalog as aD, type ResolvedReferences as aE, type RoundState as aF, type RuntimeState as aG, type ScriptRuntimeDependencies as aH, type StackEvent as aI, type TimerDirection as aJ, VISIBILITY_ICONS as aK, VISIBILITY_LABELS as aL, createBrowserRuntimeNow as aM, createReferenceIndex as aN, disciplineFactorFor as aO, extractStatementRefs as aP, filterTagsByVisibility as aQ, frozenNow as aR, getMetricVisibility as aS, getRuntimeNowMs as aT, isEffortDiscipline as aU, isFragmentTag as aV, slugifyRefLabel as aW, wallClockNow as aX, type ButtonVariant as aa, type ButtonsState as ab, type ChildrenStatusState as ac, type CompletionState as ad, DEFAULT_RESOLVER_OPTIONS as ae, DEFAULT_RUNTIME_OPTIONS as af, DISCIPLINE_FACTORS as ag, type DisplayState as ah, EFFORT_DISCIPLINES as ai, EFFORT_REGISTRY_ORIGINS as aj, type EffortBaseAttributes as ak, type EffortDerivation as al, type EffortDiscipline as am, type EffortMaterializer as an, type EffortResolvedFrom as ao, type EquipmentStorageAdapter as ap, type FenceDialect as aq, type FragmentDisplayState as ar, type FragmentState as as, type IAnalyticsProcessorDescriptor as at, type IEquipmentRegistry as au, INTENSITY_TIERS as av, type IScript as aw, type IntensityTier as ax, type InterceptMode as ay, MemoryLocation as az, type IEffort as b, type IEffortResolver as c, type IEffortRegistry as d, type EffortResolutionOptions as e, type ResolvedEffort as f, type EffortRegistrySource as g, type EffortStorageAdapter as h, type IRuntimeActionable as i, type IEventBus as j, type IRuntimeStack as k, type IRuntimeClock as l, type IJitCompiler as m, type INowProvider as n, type RuntimeStackOptions as o, type RuntimeError as p, type IEvent as q, type IRuntimeAction as r, type IAnalyticsEngine as s, type IRuntimeBlock as t, type IBehaviorContext as u, type BehaviorEventListener as v, type Unsubscribe$1 as w, type OutputOptions as x, type IMemoryLocation as y, type IRuntimeBehavior as z };
@@ -1,49 +1,4 @@
1
- import { ICodeStatement, ParseError, MetricContainer, IMetric, BlockKey, TimeSpan as TimeSpan$1, OutputStatementType, MetricType, IOutputStatement, MetricOrigin } from '@bitcobblers/wod-wiki-core';
2
-
3
- interface IScript {
4
- source: string;
5
- statements: ICodeStatement[];
6
- errors?: ParseError[] | undefined;
7
- getIds(ids: number[]): ICodeStatement[];
8
- getId(id: number): ICodeStatement | undefined;
9
- getAt(index: number): ICodeStatement | undefined;
10
- }
11
- declare class WhiteboardScript implements IScript {
12
- source: string;
13
- statements: ICodeStatement[];
14
- errors: ParseError[] | undefined;
15
- private _idMap?;
16
- constructor(source: string, statements: ICodeStatement[], errors?: ParseError[]);
17
- /**
18
- * Gets the ID-to-statement Map, building it lazily on first access.
19
- * Provides O(1) lookups instead of O(n) find() calls.
20
- */
21
- private getIdMap;
22
- /**
23
- * Resolves multiple statement IDs to statements.
24
- * Uses cached Map for O(n) performance instead of O(n²).
25
- */
26
- getIds(ids: number[]): ICodeStatement[];
27
- /**
28
- * Resolves a single statement ID to a statement.
29
- * Uses cached Map for O(1) performance instead of O(n).
30
- */
31
- getId(id: number): ICodeStatement | undefined;
32
- /**
33
- * Gets a statement by its array index.
34
- */
35
- getAt(index: number): ICodeStatement | undefined;
36
- /**
37
- * Flattens grouped children (number[][]) and resolves to statements.
38
- * Convenience wrapper for getIds(children.flat()).
39
- */
40
- getFlatChildren(children: number[][]): ICodeStatement[];
41
- /**
42
- * Resolves grouped children while preserving group structure.
43
- * Maps each number[] group to ICodeStatement[] group.
44
- */
45
- getChildGroups(children: number[][]): ICodeStatement[][];
46
- }
1
+ import { ReferenceMatchKind, ReferenceRef, ReferenceDiagnostic, ICodeStatement, ParseError, MetricContainer, IMetric, BlockKey, TimeSpan as TimeSpan$1, OutputStatementType, MetricType, IOutputStatement, MetricOrigin } from '@bitcobblers/wod-wiki-core';
47
2
 
48
3
  /**
49
4
  * Canonical discipline vocabulary — the single source of truth for effort
@@ -122,6 +77,14 @@ interface IEffort {
122
77
  baseAttributes: EffortBaseAttributes;
123
78
  /** Where this record came from */
124
79
  registrySource: EffortRegistrySource;
80
+ /** Canonical equipment slugs this effort is typically performed with (ordered, deduped). */
81
+ equipment?: string[];
82
+ /** Owning note in the content store, when this record is a note projection. */
83
+ ownerNoteId?: string;
84
+ /** Seed/source collection this record was imported from. */
85
+ sourceId?: string;
86
+ /** Source file path within the originating collection. */
87
+ sourcePath?: string;
125
88
  /** Clone-based derivation metadata (user efforts only) */
126
89
  derivation?: EffortDerivation;
127
90
  /** ISO timestamp */
@@ -158,6 +121,56 @@ interface EffortStorageAdapter {
158
121
  save(effort: IEffort): Promise<void>;
159
122
  delete(slug: string): Promise<void>;
160
123
  }
124
+ /**
125
+ * Canonical equipment entity (dumbbell, rower, kettlebell…).
126
+ *
127
+ * Same durable-identity rule as efforts: references point at the slug.
128
+ * No synthetic tier — unknown equipment stays authored source + diagnostics.
129
+ */
130
+ interface IEquipment {
131
+ /** UUID */
132
+ id: string;
133
+ /** Canonical identifier — unique, lowercase, hyphenated */
134
+ slug: string;
135
+ /** Primary human-readable name */
136
+ label: string;
137
+ /** Alternative names for exact matching */
138
+ aliases: string[];
139
+ /** Where this record came from */
140
+ registrySource: 'bundled' | 'user';
141
+ /** Free-form markdown description / notes */
142
+ body?: string;
143
+ /** Owning note in the content store, when this record is a note projection. */
144
+ ownerNoteId?: string;
145
+ /** Seed/source collection this record was imported from. */
146
+ sourceId?: string;
147
+ /** Source file path within the originating collection. */
148
+ sourcePath?: string;
149
+ /** ISO timestamp */
150
+ createdAt?: string;
151
+ /** ISO timestamp */
152
+ updatedAt?: string;
153
+ }
154
+ /** Read/write registry surface for equipment definitions (mirrors IEffortRegistry). */
155
+ interface IEquipmentRegistry {
156
+ resolve(slug: string): IEquipment | null;
157
+ resolveByAlias(label: string): IEquipment | null;
158
+ list(): readonly IEquipment[];
159
+ listByOrigin(origin: 'bundled' | 'user'): readonly IEquipment[];
160
+ upsert(equipment: IEquipment): Promise<void>;
161
+ delete(slug: string): Promise<void>;
162
+ loadBundled(): Promise<void>;
163
+ isInitialized(): boolean;
164
+ }
165
+ /**
166
+ * Pluggable asynchronous persistence adapter for user-defined equipment.
167
+ * Implemented by host environments (e.g. IndexedDB in browser, filesystem in CLI).
168
+ */
169
+ interface EquipmentStorageAdapter {
170
+ load(): Promise<IEquipment[]>;
171
+ save(equipment: IEquipment): Promise<void>;
172
+ delete(slug: string): Promise<void>;
173
+ }
161
174
  interface EffortResolutionOptions {
162
175
  /** Attribute metrics from /effort/:slug query params or logged execution metrics. */
163
176
  modifiers?: Record<string, string>;
@@ -215,6 +228,124 @@ interface EffortResolverOptions {
215
228
  }
216
229
  declare const DEFAULT_RESOLVER_OPTIONS: Required<EffortResolverOptions>;
217
230
 
231
+ /**
232
+ * Shared exact reference resolver — the single door for authored-label →
233
+ * canonical effort/equipment resolution used by the parser, editor preview,
234
+ * runtime enrichment, and seed/local indexing.
235
+ *
236
+ * Precedence (accepted proposal): explicit JSON ref > exact equipment word
237
+ * prefix + remaining effort (both must resolve uniquely) > whole-label exact
238
+ * (slug/alias) > note defaults (empty-movement fill only) > effort-definition
239
+ * equipment. Fuzzy matching never produces a canonical reference here —
240
+ * unknown/ambiguous/invalid values retain the authored source and carry a
241
+ * visible diagnostic instead of falling back.
242
+ *
243
+ * The index is built once per catalog (hydration), never per statement.
244
+ */
245
+
246
+ /** Catalog collections the resolver resolves against (hydrated from storage/seed). */
247
+ interface ReferenceCatalog {
248
+ efforts: readonly IEffort[];
249
+ equipment: readonly IEquipment[];
250
+ }
251
+ /** Note/workout-level reference defaults (`metrics.*` frontmatter). */
252
+ interface ReferenceResolutionDefaults {
253
+ /** Default effort slug applied when a statement's movement is otherwise missing. */
254
+ effort?: string;
255
+ /** Default equipment slugs applied when the line and effort define none. */
256
+ equipment?: readonly string[];
257
+ }
258
+ /** Result of resolving one authored label. */
259
+ interface ResolvedReferences {
260
+ matched: ReferenceMatchKind;
261
+ /** Full authored label — never rewritten. */
262
+ label: string;
263
+ /** Materialized effort, or null when unresolved. */
264
+ effort: ResolvedEffort | null;
265
+ /** Canonical effort ref, or null. */
266
+ effortRef: ReferenceRef | null;
267
+ /** Ordered deduplicated canonical equipment refs. */
268
+ equipment: ReferenceRef[];
269
+ /** Remaining movement text after the equipment prefix strip (split path). */
270
+ remaining: string;
271
+ /** Unknown/ambiguous/invalid findings — never silently dropped. */
272
+ diagnostics: ReferenceDiagnostic[];
273
+ }
274
+ /** Materialize an effort definition (MET/derivation math) — pass the legacy EffortResolver in hosts. */
275
+ type EffortMaterializer = (effort: IEffort) => ResolvedEffort;
276
+ interface ReferenceIndex {
277
+ /** Resolve an authored movement label (statement effort text or frontmatter value). */
278
+ resolve(label: string, defaults?: ReferenceResolutionDefaults): ResolvedReferences;
279
+ /** Exact slug/alias effort lookup — no fuzzy, never synthetic. */
280
+ resolveEffort(slugOrAlias: string): IEffort | null;
281
+ /** Exact slug/alias equipment lookup — no fuzzy. */
282
+ resolveEquipment(slugOrAlias: string): IEquipment | null;
283
+ /** Materialize a resolved definition (wraps the legacy resolver when provided). */
284
+ materialize(effort: IEffort): ResolvedEffort;
285
+ }
286
+ declare function createReferenceIndex(catalog: ReferenceCatalog, materialize?: EffortMaterializer): ReferenceIndex;
287
+ /**
288
+ * Canonical statement refs for index/analytics projection — the single shared
289
+ * replacement for the per-host `extractEffortSlugs` copies.
290
+ *
291
+ * ONLY validated durable refs are returned: canonical slugs carried on the
292
+ * statement's effort/equipment metrics by the shared resolver at parse time.
293
+ * Unresolved labels yield nothing here (their authored source and diagnostics
294
+ * stay on the statement) — resolve authored labels through
295
+ * `ReferenceIndex.resolve` when projecting un-parsed text.
296
+ */
297
+ declare function extractStatementRefs(statements: readonly ICodeStatement[]): {
298
+ efforts: string[];
299
+ equipment: string[];
300
+ };
301
+ /** Canonical slugify for label→candidate-slug hygiene in host projection code. */
302
+ declare function slugifyRefLabel(label: string): string;
303
+
304
+ interface IScript {
305
+ source: string;
306
+ statements: ICodeStatement[];
307
+ errors?: ParseError[] | undefined;
308
+ getIds(ids: number[]): ICodeStatement[];
309
+ getId(id: number): ICodeStatement | undefined;
310
+ getAt(index: number): ICodeStatement | undefined;
311
+ }
312
+ declare class WhiteboardScript implements IScript {
313
+ source: string;
314
+ statements: ICodeStatement[];
315
+ errors: ParseError[] | undefined;
316
+ private _idMap?;
317
+ constructor(source: string, statements: ICodeStatement[], errors?: ParseError[]);
318
+ /**
319
+ * Gets the ID-to-statement Map, building it lazily on first access.
320
+ * Provides O(1) lookups instead of O(n) find() calls.
321
+ */
322
+ private getIdMap;
323
+ /**
324
+ * Resolves multiple statement IDs to statements.
325
+ * Uses cached Map for O(n) performance instead of O(n²).
326
+ */
327
+ getIds(ids: number[]): ICodeStatement[];
328
+ /**
329
+ * Resolves a single statement ID to a statement.
330
+ * Uses cached Map for O(1) performance instead of O(n).
331
+ */
332
+ getId(id: number): ICodeStatement | undefined;
333
+ /**
334
+ * Gets a statement by its array index.
335
+ */
336
+ getAt(index: number): ICodeStatement | undefined;
337
+ /**
338
+ * Flattens grouped children (number[][]) and resolves to statements.
339
+ * Convenience wrapper for getIds(children.flat()).
340
+ */
341
+ getFlatChildren(children: number[][]): ICodeStatement[];
342
+ /**
343
+ * Resolves grouped children while preserving group structure.
344
+ * Maps each number[] group to ICodeStatement[] group.
345
+ */
346
+ getChildGroups(children: number[][]): ICodeStatement[][];
347
+ }
348
+
218
349
  /**
219
350
  * Minimal executable runtime action shape.
220
351
  *
@@ -514,6 +645,7 @@ interface RuntimeStackOptions extends IRuntimeOptions {
514
645
  hooks?: RuntimeStackHooks;
515
646
  analyticsOptions?: {
516
647
  effortResolver?: IEffortResolver;
648
+ references?: ReferenceIndex;
517
649
  userProfile?: {
518
650
  vo2max?: number;
519
651
  };
@@ -1936,6 +2068,8 @@ interface IAnalyticsEngine {
1936
2068
  interface AnalyticsContext {
1937
2069
  /** Effort resolver for canonical slug and fuzzy alias matching. */
1938
2070
  effortResolver: IEffortResolver;
2071
+ /** Shared reference index for canonical effort/equipment resolution. */
2072
+ references?: ReferenceIndex;
1939
2073
  }
1940
2074
 
1941
2075
  interface IJitCompiler {
@@ -2363,4 +2497,4 @@ declare function getRuntimeNowMs(): number;
2363
2497
  /** Creates an INowProvider that reads the browser sender-clock when available. */
2364
2498
  declare function createBrowserRuntimeNow(): INowProvider;
2365
2499
 
2366
- export { type IRuntimeOptions as $, type AnalyticsContext as A, type BehaviorEventType as B, type CompletionDecision as C, type IRuntimeMemory as D, type EffortResolverOptions as E, TypedMemoryReference as F, type MemorySearchCriteria as G, type IMemoryReference as H, type IEffortResolver as I, type RuntimeStackLogger as J, type StackObserver as K, type StackSnapshot as L, type MemoryTag as M, type StackListener as N, type OutputListener as O, MemoryTypeEnum as P, type IAnchorValue as Q, type ResolvedEffort as R, type SubscribeOptions as S, TimeSpan as T, type Unsubscribe as U, type ButtonConfig as V, WhiteboardScript as W, type IEventHandler as X, type HandlerScope as Y, type IScriptRuntime as Z, type TestableBlockConfig as _, type IEffortRegistry as a, ScriptRuntime as a0, type EventHandlerOptions as a1, type EventCallback as a2, type TimerState as a3, type IRealtimeProcessor as a4, type ISummaryProcessor as a5, type ProjectionResult as a6, type ButtonVariant as a7, type ButtonsState as a8, type ChildrenStatusState as a9, type StackEvent as aA, type TimerDirection as aB, VISIBILITY_ICONS as aC, VISIBILITY_LABELS as aD, createBrowserRuntimeNow as aE, disciplineFactorFor as aF, filterTagsByVisibility as aG, frozenNow as aH, getMetricVisibility as aI, getRuntimeNowMs as aJ, isEffortDiscipline as aK, isFragmentTag as aL, wallClockNow as aM, type CompletionState as aa, DEFAULT_RESOLVER_OPTIONS as ab, DEFAULT_RUNTIME_OPTIONS as ac, DISCIPLINE_FACTORS as ad, type DisplayState as ae, EFFORT_DISCIPLINES as af, EFFORT_REGISTRY_ORIGINS as ag, type EffortBaseAttributes as ah, type EffortDerivation as ai, type EffortDiscipline as aj, type EffortResolvedFrom as ak, type FenceDialect as al, type FragmentDisplayState as am, type FragmentState as an, type IAnalyticsProcessorDescriptor as ao, INTENSITY_TIERS as ap, type IScript as aq, type IntensityTier as ar, type InterceptMode as as, MemoryLocation as at, type MemoryType as au, type MemoryTypeMap as av, type MemoryValueOf as aw, type RoundState as ax, type RuntimeState as ay, type ScriptRuntimeDependencies as az, type IEffort as b, type EffortResolutionOptions as c, type EffortRegistrySource as d, type EffortStorageAdapter as e, type IRuntimeActionable as f, type IEventBus as g, type IRuntimeStack as h, type IRuntimeClock as i, type IJitCompiler as j, type INowProvider as k, type RuntimeStackOptions as l, type RuntimeError as m, type IEvent as n, type IRuntimeAction as o, type IAnalyticsEngine as p, type IRuntimeBlock as q, type IBehaviorContext as r, type BehaviorEventListener as s, type Unsubscribe$1 as t, type OutputOptions as u, type IMemoryLocation as v, type IRuntimeBehavior as w, type IBlockContext as x, type MetricVisibility as y, type BlockLifecycleOptions as z };
2500
+ export { type HandlerScope as $, type AnalyticsContext as A, type BehaviorEventType as B, type IBlockContext as C, type MetricVisibility as D, type EffortResolverOptions as E, type BlockLifecycleOptions as F, type CompletionDecision as G, type IRuntimeMemory as H, type IEquipment as I, TypedMemoryReference as J, type MemorySearchCriteria as K, type IMemoryReference as L, type MemoryTag as M, type RuntimeStackLogger as N, type OutputListener as O, type StackObserver as P, type StackSnapshot as Q, type ReferenceIndex as R, type SubscribeOptions as S, TimeSpan as T, type Unsubscribe as U, type StackListener as V, WhiteboardScript as W, MemoryTypeEnum as X, type IAnchorValue as Y, type ButtonConfig as Z, type IEventHandler as _, type ReferenceResolutionDefaults as a, type IScriptRuntime as a0, type TestableBlockConfig as a1, type IRuntimeOptions as a2, ScriptRuntime as a3, type EventHandlerOptions as a4, type EventCallback as a5, type TimerState as a6, type IRealtimeProcessor as a7, type ISummaryProcessor as a8, type ProjectionResult as a9, type MemoryType as aA, type MemoryTypeMap as aB, type MemoryValueOf as aC, type ReferenceCatalog as aD, type ResolvedReferences as aE, type RoundState as aF, type RuntimeState as aG, type ScriptRuntimeDependencies as aH, type StackEvent as aI, type TimerDirection as aJ, VISIBILITY_ICONS as aK, VISIBILITY_LABELS as aL, createBrowserRuntimeNow as aM, createReferenceIndex as aN, disciplineFactorFor as aO, extractStatementRefs as aP, filterTagsByVisibility as aQ, frozenNow as aR, getMetricVisibility as aS, getRuntimeNowMs as aT, isEffortDiscipline as aU, isFragmentTag as aV, slugifyRefLabel as aW, wallClockNow as aX, type ButtonVariant as aa, type ButtonsState as ab, type ChildrenStatusState as ac, type CompletionState as ad, DEFAULT_RESOLVER_OPTIONS as ae, DEFAULT_RUNTIME_OPTIONS as af, DISCIPLINE_FACTORS as ag, type DisplayState as ah, EFFORT_DISCIPLINES as ai, EFFORT_REGISTRY_ORIGINS as aj, type EffortBaseAttributes as ak, type EffortDerivation as al, type EffortDiscipline as am, type EffortMaterializer as an, type EffortResolvedFrom as ao, type EquipmentStorageAdapter as ap, type FenceDialect as aq, type FragmentDisplayState as ar, type FragmentState as as, type IAnalyticsProcessorDescriptor as at, type IEquipmentRegistry as au, INTENSITY_TIERS as av, type IScript as aw, type IntensityTier as ax, type InterceptMode as ay, MemoryLocation as az, type IEffort as b, type IEffortResolver as c, type IEffortRegistry as d, type EffortResolutionOptions as e, type ResolvedEffort as f, type EffortRegistrySource as g, type EffortStorageAdapter as h, type IRuntimeActionable as i, type IEventBus as j, type IRuntimeStack as k, type IRuntimeClock as l, type IJitCompiler as m, type INowProvider as n, type RuntimeStackOptions as o, type RuntimeError as p, type IEvent as q, type IRuntimeAction as r, type IAnalyticsEngine as s, type IRuntimeBlock as t, type IBehaviorContext as u, type BehaviorEventListener as v, type Unsubscribe$1 as w, type OutputOptions as x, type IMemoryLocation as y, type IRuntimeBehavior as z };