@bitcobblers/wod-wiki-lang 0.45.2167 → 0.47.2169

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.
@@ -831,6 +831,8 @@ interface CalculationDefinition {
831
831
  when?: string;
832
832
  whenAst?: ExprNode;
833
833
  variants: CalcVariant[];
834
+ /** Custom statement-level atom dimensions contributed by Property Notes. */
835
+ customAtoms?: Readonly<Record<string, DimVector>>;
834
836
  output?: {
835
837
  nodeId: string | string[];
836
838
  key?: string;
@@ -845,6 +847,176 @@ interface CalculationDefinition {
845
847
  };
846
848
  }
847
849
 
850
+ /**
851
+ * Dimension-aware value model for calc evaluation.
852
+ *
853
+ * Numbers carry a dimension vector and (optionally) the unit they were
854
+ * measured in; arithmetic tracks vectors per spec §5.1. `absent` is the
855
+ * missing-data value: it propagates through arithmetic, reads as `false` in
856
+ * predicates (applicability decision, #848), and is what `has()` probes.
857
+ */
858
+
859
+ type Val = {
860
+ kind: 'number';
861
+ value: number;
862
+ dim: DimVector;
863
+ unit?: string;
864
+ } | {
865
+ kind: 'string';
866
+ value: string;
867
+ } | {
868
+ kind: 'series';
869
+ points: Map<number, number>;
870
+ dim: DimVector;
871
+ unit?: string;
872
+ } | {
873
+ kind: 'period';
874
+ days: number;
875
+ } | {
876
+ kind: 'absent';
877
+ };
878
+ declare const ABSENT: Val;
879
+ declare function num(value: number, dim?: DimVector, unit?: string): Val;
880
+ declare function str(value: string): Val;
881
+ /** Predicate truthiness: absent → false; numbers → ≠ 0; strings → non-empty. */
882
+ declare function truthy(v: Val): boolean;
883
+
884
+ /**
885
+ * Expression evaluator for the composed calculations layer.
886
+ *
887
+ * The core owns arithmetic, comparison/logic, and the scalar function table
888
+ * (min, max, abs, round, floor, ceil, clamp, convert, has). Everything
889
+ * scope-dependent — metric refs, context nodes, stream aggregates, lookup(),
890
+ * WQL atoms — resolves through the EvalContext, so the same evaluator serves
891
+ * segment, workout, and store scopes (spec §3.1).
892
+ */
893
+
894
+ declare class CalcEvalError extends Error {
895
+ constructor(message: string);
896
+ }
897
+ interface EvalContext {
898
+ /** Resolve a ref atom (metric, context node, library node). ABSENT when missing. */
899
+ resolveRef(name: string): Val;
900
+ /**
901
+ * Extension functions (stream aggregates, lookup). Receives evaluated args
902
+ * plus the raw arg nodes (aggregates need the filter node unevaluated).
903
+ * Return undefined to signal "not mine" → CalcEvalError.
904
+ */
905
+ callFunction?(name: string, args: Val[], rawArgs: ExprNode[]): Val | undefined;
906
+ /** Store-scope WQL selections (QueryService). Store scope only. */
907
+ resolveWql?(node: Extract<ExprNode, {
908
+ kind: 'wql';
909
+ }>): Val;
910
+ }
911
+ declare function evaluate(node: ExprNode, ctx: EvalContext): Val;
912
+
913
+ /**
914
+ * Lookup table registry (spec §4).
915
+ *
916
+ * Tables are adapters over heterogeneous sources (effort resolver, static
917
+ * maps, user profile) exposing a uniform single-row lookup contract:
918
+ * `lookup("table", keyExpr, "field")`. Registration is layered —
919
+ * bundled → dialect → user — with later layers replacing earlier ones
920
+ * (mirrors the Dialect Stack's personal-overrides-last rule). Miss behavior
921
+ * is per-table: `absent` yields the absent value; `default-row` yields a
922
+ * synthetic row so calcs never see a miss.
923
+ */
924
+
925
+ interface LookupFieldDef {
926
+ dimension: DimVector;
927
+ type: 'number' | 'string';
928
+ }
929
+ interface ILookupTable {
930
+ readonly id: string;
931
+ readonly fields: Record<string, LookupFieldDef>;
932
+ readonly missPolicy: 'absent' | 'default-row';
933
+ /** Single-row lookup. `absent` tables return undefined on a miss. */
934
+ get(key: string, field: string): Val | undefined;
935
+ }
936
+ type LookupLayer = 'bundled' | 'dialect' | 'user';
937
+ declare class LookupRegistry {
938
+ private readonly tables;
939
+ /** Register a table; a later-or-equal layer replaces the existing entry. */
940
+ register(table: ILookupTable, layer?: LookupLayer): void;
941
+ get(tableId: string): ILookupTable | undefined;
942
+ /** Field dimension for static checking; undefined when table/field unknown. */
943
+ fieldDim(tableId: string, field: string): DimVector | undefined;
944
+ /** Runtime lookup honoring the table's miss policy. */
945
+ lookup(tableId: string, key: string, field: string): Val;
946
+ /**
947
+ * EvalContext `callFunction` implementation for `lookup("table", key, "field")`.
948
+ * Compose with other extension functions (aggregates) at the engine layer.
949
+ */
950
+ readonly callFunction: EvalContext['callFunction'];
951
+ }
952
+
953
+ /**
954
+ * MetricShakeOutQueue — Two-stage dependency-ordered metric evaluation module.
955
+ *
956
+ * Collects static Metrics and statement-level Metric Equations (`metrics:`)
957
+ * plus workout/query Summary Metrics (`summaries:`) across stacked Property
958
+ * Notes in specificity precedence:
959
+ * Statement/Runtime > Inline Tag > Effort > Equipment > Note Frontmatter > Tag Category
960
+ *
961
+ * Stage 1 (`plan`): resolves static metrics and compile-time equations in
962
+ * topological waves, injects compiler hints, and defers equations whose
963
+ * required inputs depend on runtime-only atoms (`elapsed`, `spans`, etc.).
964
+ *
965
+ * Stage 2 (`log`): resolves all remaining equations against the executed
966
+ * statement metrics and emits a structured Skipped-Dependency Diagnostic
967
+ * metric (`origin: 'diagnostic'`, `type: MetricType.Diagnostic`) for any
968
+ * equation whose required inputs remain absent after the fixed-point pass.
969
+ */
970
+
971
+ type PropertySourceLayer = 'statement' | 'tag' | 'effort' | 'equipment' | 'note' | 'category';
972
+ interface PropertyRuleInput {
973
+ readonly layer: Exclude<PropertySourceLayer, 'statement'>;
974
+ readonly sourceSlug: string;
975
+ readonly metrics?: Readonly<Record<string, string | number | readonly string[]>>;
976
+ readonly summaries?: Readonly<Record<string, string>>;
977
+ readonly hints?: Readonly<Record<string, unknown>>;
978
+ }
979
+ interface SkippedDependencyDiagnostic {
980
+ readonly target: string;
981
+ readonly expression: string;
982
+ readonly sourceLayer: Exclude<PropertySourceLayer, 'statement'>;
983
+ readonly sourceSlug: string;
984
+ readonly missing: readonly string[];
985
+ }
986
+ interface ShakeOutResult {
987
+ readonly resolved: readonly string[];
988
+ readonly deferredRuntime: readonly string[];
989
+ readonly diagnostics: readonly SkippedDependencyDiagnostic[];
990
+ readonly inferredDims: Readonly<Record<string, DimVector>>;
991
+ }
992
+ interface ShakeOutQueueOptions {
993
+ readonly stage: 'plan' | 'log';
994
+ readonly sources: readonly PropertyRuleInput[];
995
+ readonly lookups?: LookupRegistry;
996
+ readonly lastEffortSlug?: string;
997
+ }
998
+ /**
999
+ * Extract `metrics:` and `summaries:` maps from a parsed frontmatter record
1000
+ * (supporting both flat `metrics.foo` / `summaries.bar` keys and nested maps).
1001
+ */
1002
+ declare function extractPropertyRulesFromMeta(meta: Readonly<Record<string, unknown>>, layer: Exclude<PropertySourceLayer, 'statement'>, sourceSlug: string): PropertyRuleInput;
1003
+ /**
1004
+ * Extract `PropertyRuleInput` records from a `TagIndex` for the given tag slugs.
1005
+ * Supports both statement-level `metrics` (static or equation) and workout-level
1006
+ * `summaries.<key>` contributions on tags (including nested tags).
1007
+ */
1008
+ declare function extractTagPropertyRules(tags: TagIndex | undefined, slugs: readonly string[]): PropertyRuleInput[];
1009
+ /**
1010
+ * Compile `summaries:` equations across stacked Property Notes into workout-scope
1011
+ * `CalculationDefinition` records. Higher-precedence layers shadow lower layers
1012
+ * when both define the same summary key.
1013
+ */
1014
+ declare function compilePropertySummaryCalcs(sources: readonly PropertyRuleInput[]): CalculationDefinition[];
1015
+ /**
1016
+ * Run the two-stage Metric Shake-Out Queue on a statement's MetricContainer.
1017
+ */
1018
+ declare function runMetricShakeOutQueue(container: MetricContainer, options: ShakeOutQueueOptions): ShakeOutResult;
1019
+
848
1020
  /**
849
1021
  * Factory function type for wrapping blocks in debug mode.
850
1022
  * Receives the original block and returns a wrapped version.
@@ -946,6 +1118,8 @@ interface RuntimeStackOptions extends IRuntimeOptions {
946
1118
  * bundle a profile applies.
947
1119
  */
948
1120
  activeTags?: readonly string[];
1121
+ /** Property Note metric/summary rules active for this run or block. */
1122
+ propertySources?: readonly PropertyRuleInput[];
949
1123
  };
950
1124
  /**
951
1125
  * Sound configuration for this run.
@@ -2817,4 +2991,4 @@ declare function getRuntimeNowMs(): number;
2817
2991
  /** Creates an INowProvider that reads the browser sender-clock when available. */
2818
2992
  declare function createBrowserRuntimeNow(): INowProvider;
2819
2993
 
2820
- export { type IEventHandler 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 SoundProfile as Z, type ButtonConfig as _, type ReferenceResolutionDefaults as a, type SeedPrecedenceTier as a$, type HandlerScope as a0, type IScriptRuntime as a1, type TestableBlockConfig as a2, type IRuntimeOptions as a3, ScriptRuntime as a4, type EventHandlerOptions as a5, type EventCallback as a6, type TimerState as a7, type CalculationDefinition as a8, type IRealtimeProcessor as a9, EFFORT_REGISTRY_ORIGINS as aA, type EffortBaseAttributes as aB, type EffortDerivation as aC, type EffortDiscipline as aD, type EffortMaterializer as aE, type EffortResolvedFrom as aF, type EquipmentStorageAdapter as aG, type FenceDialect as aH, type FragmentDisplayState as aI, type FragmentState as aJ, type IAnalyticsProcessorDescriptor as aK, type IEquipmentRegistry as aL, INTENSITY_TIERS as aM, type IScript as aN, type IntensityTier as aO, type InterceptMode as aP, MemoryLocation as aQ, type MemoryType as aR, type MemoryTypeMap as aS, type MemoryValueOf as aT, NAMED_COMPOUNDS as aU, type ReferenceCatalog as aV, type ResolvedReferences as aW, type RoundState as aX, type RuntimeState as aY, SEED_PRECEDENCE_RANK as aZ, type ScriptRuntimeDependencies as a_, type ISummaryProcessor as aa, type ProjectionResult as ab, type DimVector as ac, type CalcLine as ad, type ExprNode as ae, type CalcScope as af, type BinaryOp as ag, type ButtonVariant as ah, type ButtonsState as ai, type CalcNode as aj, type CalcOrigin as ak, type CalcVariant as al, type ChildrenStatusState as am, type CompletionState as an, DEFAULT_RESOLVER_OPTIONS as ao, DEFAULT_RUNTIME_OPTIONS as ap, DEFAULT_SOUND_PROFILE as aq, DIM_COUNT as ar, DIM_ENERGY as as, DIM_LENGTH as at, DIM_MASS as au, DIM_TIME as av, DIM_ZERO as aw, DISCIPLINE_FACTORS as ax, type DisplayState as ay, EFFORT_DISCIPLINES as az, type IEffort as b, type SoundRule as b0, type SoundTriggerAnchor as b1, type SoundTriggerPoint as b2, type StackEvent as b3, type TimerDirection as b4, VISIBILITY_ICONS as b5, VISIBILITY_LABELS as b6, addDim as b7, compoundName as b8, createBrowserRuntimeNow as b9, createReferenceIndex as ba, dedupeEntitiesByPrecedence as bb, dimEquals as bc, disciplineFactorFor as bd, extractStatementRefs as be, filterTagsByVisibility as bf, formatDim as bg, formatSoundTrigger as bh, frozenNow as bi, getMetricVisibility as bj, getRuntimeNowMs as bk, isDimensionless as bl, isEffortDiscipline as bm, isFragmentTag as bn, parseSoundTrigger as bo, resolveEntityRank as bp, resolveEntityTier as bq, resolveProfileRules as br, resolveSourceRank as bs, resolveSourceTier as bt, slugifyRefLabel as bu, subDim as bv, wallClockNow as bw, 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 };
2994
+ export { type SoundProfile as $, type AnalyticsContext as A, type BehaviorEventType as B, type IMemoryLocation as C, type IRuntimeBehavior as D, type EffortResolverOptions as E, type IBlockContext as F, type MetricVisibility as G, type BlockLifecycleOptions as H, type IEquipment as I, type CompletionDecision as J, type IRuntimeMemory as K, TypedMemoryReference as L, type MemoryTag as M, type MemorySearchCriteria as N, type OutputListener as O, type IMemoryReference as P, type RuntimeStackLogger as Q, type ReferenceIndex as R, type SubscribeOptions as S, TimeSpan as T, type Unsubscribe as U, type StackObserver as V, WhiteboardScript as W, type StackSnapshot as X, type StackListener as Y, MemoryTypeEnum as Z, type IAnchorValue as _, type ReferenceResolutionDefaults as a, type MemoryValueOf as a$, type ButtonConfig as a0, type IEventHandler as a1, type HandlerScope as a2, type IScriptRuntime as a3, type TestableBlockConfig as a4, type IRuntimeOptions as a5, ScriptRuntime as a6, type EventHandlerOptions as a7, type EventCallback as a8, type TimerState as a9, DIM_LENGTH as aA, DIM_MASS as aB, DIM_TIME as aC, DIM_ZERO as aD, DISCIPLINE_FACTORS as aE, type DisplayState as aF, EFFORT_DISCIPLINES as aG, EFFORT_REGISTRY_ORIGINS as aH, type EffortBaseAttributes as aI, type EffortDerivation as aJ, type EffortDiscipline as aK, type EffortMaterializer as aL, type EffortResolvedFrom as aM, type EvalContext as aN, type FenceDialect as aO, type FragmentDisplayState as aP, type FragmentState as aQ, type IAnalyticsProcessorDescriptor as aR, INTENSITY_TIERS as aS, type IScript as aT, type IntensityTier as aU, type InterceptMode as aV, type LookupFieldDef as aW, type LookupLayer as aX, MemoryLocation as aY, type MemoryType as aZ, type MemoryTypeMap as a_, type CalculationDefinition as aa, type PropertyRuleInput as ab, type IRealtimeProcessor as ac, type ISummaryProcessor as ad, type DimVector as ae, type CalcLine as af, type ExprNode as ag, type CalcScope as ah, type ILookupTable as ai, LookupRegistry as aj, type ProjectionResult as ak, ABSENT as al, type BinaryOp as am, type ButtonVariant as an, type ButtonsState as ao, CalcEvalError as ap, type CalcNode as aq, type CalcOrigin as ar, type CalcVariant as as, type ChildrenStatusState as at, type CompletionState as au, DEFAULT_RESOLVER_OPTIONS as av, DEFAULT_RUNTIME_OPTIONS as aw, DEFAULT_SOUND_PROFILE as ax, DIM_COUNT as ay, DIM_ENERGY as az, type IEffort as b, NAMED_COMPOUNDS as b0, type PropertySourceLayer as b1, type ReferenceCatalog as b2, type ResolvedReferences as b3, type RoundState as b4, type RuntimeState as b5, SEED_PRECEDENCE_RANK as b6, type ScriptRuntimeDependencies as b7, type SeedPrecedenceTier as b8, type ShakeOutQueueOptions as b9, getMetricVisibility as bA, getRuntimeNowMs as bB, isDimensionless as bC, isEffortDiscipline as bD, isFragmentTag as bE, num as bF, parseSoundTrigger as bG, resolveEntityRank as bH, resolveEntityTier as bI, resolveProfileRules as bJ, resolveSourceRank as bK, resolveSourceTier as bL, runMetricShakeOutQueue as bM, slugifyRefLabel as bN, str as bO, subDim as bP, truthy as bQ, wallClockNow as bR, type ShakeOutResult as ba, type SkippedDependencyDiagnostic as bb, type SoundRule as bc, type SoundTriggerAnchor as bd, type SoundTriggerPoint as be, type StackEvent as bf, type TimerDirection as bg, VISIBILITY_ICONS as bh, VISIBILITY_LABELS as bi, type Val as bj, addDim as bk, compilePropertySummaryCalcs as bl, compoundName as bm, createBrowserRuntimeNow as bn, createReferenceIndex as bo, dedupeEntitiesByPrecedence as bp, dimEquals as bq, disciplineFactorFor as br, evaluate as bs, extractPropertyRulesFromMeta as bt, extractStatementRefs as bu, extractTagPropertyRules as bv, filterTagsByVisibility as bw, formatDim as bx, formatSoundTrigger as by, frozenNow as bz, type IEffortResolver as c, type IEffortRegistry as d, type EffortResolutionOptions as e, type ResolvedEffort as f, type EffortRegistrySource as g, type IEquipmentRegistry as h, type EquipmentStorageAdapter as i, type EffortStorageAdapter as j, type IRuntimeActionable as k, type IEventBus as l, type IRuntimeStack as m, type IRuntimeClock as n, type IJitCompiler as o, type INowProvider as p, type RuntimeStackOptions as q, type RuntimeError as r, type IEvent as s, type IRuntimeAction as t, type IAnalyticsEngine as u, type IRuntimeBlock as v, type IBehaviorContext as w, type BehaviorEventListener as x, type Unsubscribe$1 as y, type OutputOptions as z };
@@ -831,6 +831,8 @@ interface CalculationDefinition {
831
831
  when?: string;
832
832
  whenAst?: ExprNode;
833
833
  variants: CalcVariant[];
834
+ /** Custom statement-level atom dimensions contributed by Property Notes. */
835
+ customAtoms?: Readonly<Record<string, DimVector>>;
834
836
  output?: {
835
837
  nodeId: string | string[];
836
838
  key?: string;
@@ -845,6 +847,176 @@ interface CalculationDefinition {
845
847
  };
846
848
  }
847
849
 
850
+ /**
851
+ * Dimension-aware value model for calc evaluation.
852
+ *
853
+ * Numbers carry a dimension vector and (optionally) the unit they were
854
+ * measured in; arithmetic tracks vectors per spec §5.1. `absent` is the
855
+ * missing-data value: it propagates through arithmetic, reads as `false` in
856
+ * predicates (applicability decision, #848), and is what `has()` probes.
857
+ */
858
+
859
+ type Val = {
860
+ kind: 'number';
861
+ value: number;
862
+ dim: DimVector;
863
+ unit?: string;
864
+ } | {
865
+ kind: 'string';
866
+ value: string;
867
+ } | {
868
+ kind: 'series';
869
+ points: Map<number, number>;
870
+ dim: DimVector;
871
+ unit?: string;
872
+ } | {
873
+ kind: 'period';
874
+ days: number;
875
+ } | {
876
+ kind: 'absent';
877
+ };
878
+ declare const ABSENT: Val;
879
+ declare function num(value: number, dim?: DimVector, unit?: string): Val;
880
+ declare function str(value: string): Val;
881
+ /** Predicate truthiness: absent → false; numbers → ≠ 0; strings → non-empty. */
882
+ declare function truthy(v: Val): boolean;
883
+
884
+ /**
885
+ * Expression evaluator for the composed calculations layer.
886
+ *
887
+ * The core owns arithmetic, comparison/logic, and the scalar function table
888
+ * (min, max, abs, round, floor, ceil, clamp, convert, has). Everything
889
+ * scope-dependent — metric refs, context nodes, stream aggregates, lookup(),
890
+ * WQL atoms — resolves through the EvalContext, so the same evaluator serves
891
+ * segment, workout, and store scopes (spec §3.1).
892
+ */
893
+
894
+ declare class CalcEvalError extends Error {
895
+ constructor(message: string);
896
+ }
897
+ interface EvalContext {
898
+ /** Resolve a ref atom (metric, context node, library node). ABSENT when missing. */
899
+ resolveRef(name: string): Val;
900
+ /**
901
+ * Extension functions (stream aggregates, lookup). Receives evaluated args
902
+ * plus the raw arg nodes (aggregates need the filter node unevaluated).
903
+ * Return undefined to signal "not mine" → CalcEvalError.
904
+ */
905
+ callFunction?(name: string, args: Val[], rawArgs: ExprNode[]): Val | undefined;
906
+ /** Store-scope WQL selections (QueryService). Store scope only. */
907
+ resolveWql?(node: Extract<ExprNode, {
908
+ kind: 'wql';
909
+ }>): Val;
910
+ }
911
+ declare function evaluate(node: ExprNode, ctx: EvalContext): Val;
912
+
913
+ /**
914
+ * Lookup table registry (spec §4).
915
+ *
916
+ * Tables are adapters over heterogeneous sources (effort resolver, static
917
+ * maps, user profile) exposing a uniform single-row lookup contract:
918
+ * `lookup("table", keyExpr, "field")`. Registration is layered —
919
+ * bundled → dialect → user — with later layers replacing earlier ones
920
+ * (mirrors the Dialect Stack's personal-overrides-last rule). Miss behavior
921
+ * is per-table: `absent` yields the absent value; `default-row` yields a
922
+ * synthetic row so calcs never see a miss.
923
+ */
924
+
925
+ interface LookupFieldDef {
926
+ dimension: DimVector;
927
+ type: 'number' | 'string';
928
+ }
929
+ interface ILookupTable {
930
+ readonly id: string;
931
+ readonly fields: Record<string, LookupFieldDef>;
932
+ readonly missPolicy: 'absent' | 'default-row';
933
+ /** Single-row lookup. `absent` tables return undefined on a miss. */
934
+ get(key: string, field: string): Val | undefined;
935
+ }
936
+ type LookupLayer = 'bundled' | 'dialect' | 'user';
937
+ declare class LookupRegistry {
938
+ private readonly tables;
939
+ /** Register a table; a later-or-equal layer replaces the existing entry. */
940
+ register(table: ILookupTable, layer?: LookupLayer): void;
941
+ get(tableId: string): ILookupTable | undefined;
942
+ /** Field dimension for static checking; undefined when table/field unknown. */
943
+ fieldDim(tableId: string, field: string): DimVector | undefined;
944
+ /** Runtime lookup honoring the table's miss policy. */
945
+ lookup(tableId: string, key: string, field: string): Val;
946
+ /**
947
+ * EvalContext `callFunction` implementation for `lookup("table", key, "field")`.
948
+ * Compose with other extension functions (aggregates) at the engine layer.
949
+ */
950
+ readonly callFunction: EvalContext['callFunction'];
951
+ }
952
+
953
+ /**
954
+ * MetricShakeOutQueue — Two-stage dependency-ordered metric evaluation module.
955
+ *
956
+ * Collects static Metrics and statement-level Metric Equations (`metrics:`)
957
+ * plus workout/query Summary Metrics (`summaries:`) across stacked Property
958
+ * Notes in specificity precedence:
959
+ * Statement/Runtime > Inline Tag > Effort > Equipment > Note Frontmatter > Tag Category
960
+ *
961
+ * Stage 1 (`plan`): resolves static metrics and compile-time equations in
962
+ * topological waves, injects compiler hints, and defers equations whose
963
+ * required inputs depend on runtime-only atoms (`elapsed`, `spans`, etc.).
964
+ *
965
+ * Stage 2 (`log`): resolves all remaining equations against the executed
966
+ * statement metrics and emits a structured Skipped-Dependency Diagnostic
967
+ * metric (`origin: 'diagnostic'`, `type: MetricType.Diagnostic`) for any
968
+ * equation whose required inputs remain absent after the fixed-point pass.
969
+ */
970
+
971
+ type PropertySourceLayer = 'statement' | 'tag' | 'effort' | 'equipment' | 'note' | 'category';
972
+ interface PropertyRuleInput {
973
+ readonly layer: Exclude<PropertySourceLayer, 'statement'>;
974
+ readonly sourceSlug: string;
975
+ readonly metrics?: Readonly<Record<string, string | number | readonly string[]>>;
976
+ readonly summaries?: Readonly<Record<string, string>>;
977
+ readonly hints?: Readonly<Record<string, unknown>>;
978
+ }
979
+ interface SkippedDependencyDiagnostic {
980
+ readonly target: string;
981
+ readonly expression: string;
982
+ readonly sourceLayer: Exclude<PropertySourceLayer, 'statement'>;
983
+ readonly sourceSlug: string;
984
+ readonly missing: readonly string[];
985
+ }
986
+ interface ShakeOutResult {
987
+ readonly resolved: readonly string[];
988
+ readonly deferredRuntime: readonly string[];
989
+ readonly diagnostics: readonly SkippedDependencyDiagnostic[];
990
+ readonly inferredDims: Readonly<Record<string, DimVector>>;
991
+ }
992
+ interface ShakeOutQueueOptions {
993
+ readonly stage: 'plan' | 'log';
994
+ readonly sources: readonly PropertyRuleInput[];
995
+ readonly lookups?: LookupRegistry;
996
+ readonly lastEffortSlug?: string;
997
+ }
998
+ /**
999
+ * Extract `metrics:` and `summaries:` maps from a parsed frontmatter record
1000
+ * (supporting both flat `metrics.foo` / `summaries.bar` keys and nested maps).
1001
+ */
1002
+ declare function extractPropertyRulesFromMeta(meta: Readonly<Record<string, unknown>>, layer: Exclude<PropertySourceLayer, 'statement'>, sourceSlug: string): PropertyRuleInput;
1003
+ /**
1004
+ * Extract `PropertyRuleInput` records from a `TagIndex` for the given tag slugs.
1005
+ * Supports both statement-level `metrics` (static or equation) and workout-level
1006
+ * `summaries.<key>` contributions on tags (including nested tags).
1007
+ */
1008
+ declare function extractTagPropertyRules(tags: TagIndex | undefined, slugs: readonly string[]): PropertyRuleInput[];
1009
+ /**
1010
+ * Compile `summaries:` equations across stacked Property Notes into workout-scope
1011
+ * `CalculationDefinition` records. Higher-precedence layers shadow lower layers
1012
+ * when both define the same summary key.
1013
+ */
1014
+ declare function compilePropertySummaryCalcs(sources: readonly PropertyRuleInput[]): CalculationDefinition[];
1015
+ /**
1016
+ * Run the two-stage Metric Shake-Out Queue on a statement's MetricContainer.
1017
+ */
1018
+ declare function runMetricShakeOutQueue(container: MetricContainer, options: ShakeOutQueueOptions): ShakeOutResult;
1019
+
848
1020
  /**
849
1021
  * Factory function type for wrapping blocks in debug mode.
850
1022
  * Receives the original block and returns a wrapped version.
@@ -946,6 +1118,8 @@ interface RuntimeStackOptions extends IRuntimeOptions {
946
1118
  * bundle a profile applies.
947
1119
  */
948
1120
  activeTags?: readonly string[];
1121
+ /** Property Note metric/summary rules active for this run or block. */
1122
+ propertySources?: readonly PropertyRuleInput[];
949
1123
  };
950
1124
  /**
951
1125
  * Sound configuration for this run.
@@ -2817,4 +2991,4 @@ declare function getRuntimeNowMs(): number;
2817
2991
  /** Creates an INowProvider that reads the browser sender-clock when available. */
2818
2992
  declare function createBrowserRuntimeNow(): INowProvider;
2819
2993
 
2820
- export { type IEventHandler 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 SoundProfile as Z, type ButtonConfig as _, type ReferenceResolutionDefaults as a, type SeedPrecedenceTier as a$, type HandlerScope as a0, type IScriptRuntime as a1, type TestableBlockConfig as a2, type IRuntimeOptions as a3, ScriptRuntime as a4, type EventHandlerOptions as a5, type EventCallback as a6, type TimerState as a7, type CalculationDefinition as a8, type IRealtimeProcessor as a9, EFFORT_REGISTRY_ORIGINS as aA, type EffortBaseAttributes as aB, type EffortDerivation as aC, type EffortDiscipline as aD, type EffortMaterializer as aE, type EffortResolvedFrom as aF, type EquipmentStorageAdapter as aG, type FenceDialect as aH, type FragmentDisplayState as aI, type FragmentState as aJ, type IAnalyticsProcessorDescriptor as aK, type IEquipmentRegistry as aL, INTENSITY_TIERS as aM, type IScript as aN, type IntensityTier as aO, type InterceptMode as aP, MemoryLocation as aQ, type MemoryType as aR, type MemoryTypeMap as aS, type MemoryValueOf as aT, NAMED_COMPOUNDS as aU, type ReferenceCatalog as aV, type ResolvedReferences as aW, type RoundState as aX, type RuntimeState as aY, SEED_PRECEDENCE_RANK as aZ, type ScriptRuntimeDependencies as a_, type ISummaryProcessor as aa, type ProjectionResult as ab, type DimVector as ac, type CalcLine as ad, type ExprNode as ae, type CalcScope as af, type BinaryOp as ag, type ButtonVariant as ah, type ButtonsState as ai, type CalcNode as aj, type CalcOrigin as ak, type CalcVariant as al, type ChildrenStatusState as am, type CompletionState as an, DEFAULT_RESOLVER_OPTIONS as ao, DEFAULT_RUNTIME_OPTIONS as ap, DEFAULT_SOUND_PROFILE as aq, DIM_COUNT as ar, DIM_ENERGY as as, DIM_LENGTH as at, DIM_MASS as au, DIM_TIME as av, DIM_ZERO as aw, DISCIPLINE_FACTORS as ax, type DisplayState as ay, EFFORT_DISCIPLINES as az, type IEffort as b, type SoundRule as b0, type SoundTriggerAnchor as b1, type SoundTriggerPoint as b2, type StackEvent as b3, type TimerDirection as b4, VISIBILITY_ICONS as b5, VISIBILITY_LABELS as b6, addDim as b7, compoundName as b8, createBrowserRuntimeNow as b9, createReferenceIndex as ba, dedupeEntitiesByPrecedence as bb, dimEquals as bc, disciplineFactorFor as bd, extractStatementRefs as be, filterTagsByVisibility as bf, formatDim as bg, formatSoundTrigger as bh, frozenNow as bi, getMetricVisibility as bj, getRuntimeNowMs as bk, isDimensionless as bl, isEffortDiscipline as bm, isFragmentTag as bn, parseSoundTrigger as bo, resolveEntityRank as bp, resolveEntityTier as bq, resolveProfileRules as br, resolveSourceRank as bs, resolveSourceTier as bt, slugifyRefLabel as bu, subDim as bv, wallClockNow as bw, 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 };
2994
+ export { type SoundProfile as $, type AnalyticsContext as A, type BehaviorEventType as B, type IMemoryLocation as C, type IRuntimeBehavior as D, type EffortResolverOptions as E, type IBlockContext as F, type MetricVisibility as G, type BlockLifecycleOptions as H, type IEquipment as I, type CompletionDecision as J, type IRuntimeMemory as K, TypedMemoryReference as L, type MemoryTag as M, type MemorySearchCriteria as N, type OutputListener as O, type IMemoryReference as P, type RuntimeStackLogger as Q, type ReferenceIndex as R, type SubscribeOptions as S, TimeSpan as T, type Unsubscribe as U, type StackObserver as V, WhiteboardScript as W, type StackSnapshot as X, type StackListener as Y, MemoryTypeEnum as Z, type IAnchorValue as _, type ReferenceResolutionDefaults as a, type MemoryValueOf as a$, type ButtonConfig as a0, type IEventHandler as a1, type HandlerScope as a2, type IScriptRuntime as a3, type TestableBlockConfig as a4, type IRuntimeOptions as a5, ScriptRuntime as a6, type EventHandlerOptions as a7, type EventCallback as a8, type TimerState as a9, DIM_LENGTH as aA, DIM_MASS as aB, DIM_TIME as aC, DIM_ZERO as aD, DISCIPLINE_FACTORS as aE, type DisplayState as aF, EFFORT_DISCIPLINES as aG, EFFORT_REGISTRY_ORIGINS as aH, type EffortBaseAttributes as aI, type EffortDerivation as aJ, type EffortDiscipline as aK, type EffortMaterializer as aL, type EffortResolvedFrom as aM, type EvalContext as aN, type FenceDialect as aO, type FragmentDisplayState as aP, type FragmentState as aQ, type IAnalyticsProcessorDescriptor as aR, INTENSITY_TIERS as aS, type IScript as aT, type IntensityTier as aU, type InterceptMode as aV, type LookupFieldDef as aW, type LookupLayer as aX, MemoryLocation as aY, type MemoryType as aZ, type MemoryTypeMap as a_, type CalculationDefinition as aa, type PropertyRuleInput as ab, type IRealtimeProcessor as ac, type ISummaryProcessor as ad, type DimVector as ae, type CalcLine as af, type ExprNode as ag, type CalcScope as ah, type ILookupTable as ai, LookupRegistry as aj, type ProjectionResult as ak, ABSENT as al, type BinaryOp as am, type ButtonVariant as an, type ButtonsState as ao, CalcEvalError as ap, type CalcNode as aq, type CalcOrigin as ar, type CalcVariant as as, type ChildrenStatusState as at, type CompletionState as au, DEFAULT_RESOLVER_OPTIONS as av, DEFAULT_RUNTIME_OPTIONS as aw, DEFAULT_SOUND_PROFILE as ax, DIM_COUNT as ay, DIM_ENERGY as az, type IEffort as b, NAMED_COMPOUNDS as b0, type PropertySourceLayer as b1, type ReferenceCatalog as b2, type ResolvedReferences as b3, type RoundState as b4, type RuntimeState as b5, SEED_PRECEDENCE_RANK as b6, type ScriptRuntimeDependencies as b7, type SeedPrecedenceTier as b8, type ShakeOutQueueOptions as b9, getMetricVisibility as bA, getRuntimeNowMs as bB, isDimensionless as bC, isEffortDiscipline as bD, isFragmentTag as bE, num as bF, parseSoundTrigger as bG, resolveEntityRank as bH, resolveEntityTier as bI, resolveProfileRules as bJ, resolveSourceRank as bK, resolveSourceTier as bL, runMetricShakeOutQueue as bM, slugifyRefLabel as bN, str as bO, subDim as bP, truthy as bQ, wallClockNow as bR, type ShakeOutResult as ba, type SkippedDependencyDiagnostic as bb, type SoundRule as bc, type SoundTriggerAnchor as bd, type SoundTriggerPoint as be, type StackEvent as bf, type TimerDirection as bg, VISIBILITY_ICONS as bh, VISIBILITY_LABELS as bi, type Val as bj, addDim as bk, compilePropertySummaryCalcs as bl, compoundName as bm, createBrowserRuntimeNow as bn, createReferenceIndex as bo, dedupeEntitiesByPrecedence as bp, dimEquals as bq, disciplineFactorFor as br, evaluate as bs, extractPropertyRulesFromMeta as bt, extractStatementRefs as bu, extractTagPropertyRules as bv, filterTagsByVisibility as bw, formatDim as bx, formatSoundTrigger as by, frozenNow as bz, type IEffortResolver as c, type IEffortRegistry as d, type EffortResolutionOptions as e, type ResolvedEffort as f, type EffortRegistrySource as g, type IEquipmentRegistry as h, type EquipmentStorageAdapter as i, type EffortStorageAdapter as j, type IRuntimeActionable as k, type IEventBus as l, type IRuntimeStack as m, type IRuntimeClock as n, type IJitCompiler as o, type INowProvider as p, type RuntimeStackOptions as q, type RuntimeError as r, type IEvent as s, type IRuntimeAction as t, type IAnalyticsEngine as u, type IRuntimeBlock as v, type IBehaviorContext as w, type BehaviorEventListener as x, type Unsubscribe$1 as y, type OutputOptions as z };