universal-physics-tensor 11.0.0 → 12.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -34
- package/data/applied-cases.json +1892 -0
- package/data/applied-cases.schema.json +194 -0
- package/data/atlas/atlas.json +21 -21
- package/data/atlas/atlas.jsonld +1 -1
- package/data/atlas/diffusion.json +5 -5
- package/data/atlas/oscillators.json +7 -7
- package/data/atlas/waves.json +11 -11
- package/data/bridge-catalog.json +20 -4
- package/data/units.json +6 -25
- package/dist/atlas/benchmark/stats.d.ts.map +1 -1
- package/dist/atlas/benchmark/stats.js +6 -20
- package/dist/atlas/benchmark/stats.js.map +1 -1
- package/dist/atlas/physjs-entries.generated.d.ts +13 -4
- package/dist/atlas/physjs-entries.generated.d.ts.map +1 -1
- package/dist/atlas/physjs-entries.generated.js +15 -4
- package/dist/atlas/physjs-entries.generated.js.map +1 -1
- package/dist/atlas/physjs-reviewed.js +2 -2
- package/dist/atlas/physjs-reviewed.js.map +1 -1
- package/dist/cases/catalog-checks.d.ts +10 -0
- package/dist/cases/catalog-checks.d.ts.map +1 -0
- package/dist/cases/catalog-checks.js +241 -0
- package/dist/cases/catalog-checks.js.map +1 -0
- package/dist/cases/catalog.d.ts +83 -0
- package/dist/cases/catalog.d.ts.map +1 -0
- package/dist/cases/catalog.js +118 -0
- package/dist/cases/catalog.js.map +1 -0
- package/dist/cases/engine.d.ts +13 -0
- package/dist/cases/engine.d.ts.map +1 -0
- package/dist/cases/engine.js +179 -0
- package/dist/cases/engine.js.map +1 -0
- package/dist/cases/index.d.ts.map +1 -1
- package/dist/cases/index.js +5 -7
- package/dist/cases/index.js.map +1 -1
- package/dist/cases/methods.d.ts +215 -0
- package/dist/cases/methods.d.ts.map +1 -0
- package/dist/cases/methods.js +743 -0
- package/dist/cases/methods.js.map +1 -0
- package/dist/cases/types.d.ts +12 -0
- package/dist/cases/types.d.ts.map +1 -1
- package/dist/cases/types.js.map +1 -1
- package/dist/cli/args.d.ts +2 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/command.d.ts +3 -0
- package/dist/cli/command.d.ts.map +1 -1
- package/dist/cli/command.js.map +1 -1
- package/dist/cli/commands/_discovery-opts.d.ts +1 -0
- package/dist/cli/commands/_discovery-opts.d.ts.map +1 -1
- package/dist/cli/commands/_discovery-opts.js +1 -0
- package/dist/cli/commands/_discovery-opts.js.map +1 -1
- package/dist/cli/commands/discover.d.ts.map +1 -1
- package/dist/cli/commands/discover.js +116 -71
- package/dist/cli/commands/discover.js.map +1 -1
- package/dist/cli/commands/evaluate.js +2 -2
- package/dist/cli/commands/evaluate.js.map +1 -1
- package/dist/cli/commands/explain.d.ts.map +1 -1
- package/dist/cli/commands/explain.js +22 -2
- package/dist/cli/commands/explain.js.map +1 -1
- package/dist/cli/commands/ground.d.ts.map +1 -1
- package/dist/cli/commands/ground.js +6 -1
- package/dist/cli/commands/ground.js.map +1 -1
- package/dist/cli/commands/map.d.ts.map +1 -1
- package/dist/cli/commands/map.js +9 -6
- package/dist/cli/commands/map.js.map +1 -1
- package/dist/cli/determination.d.ts +1 -0
- package/dist/cli/determination.d.ts.map +1 -1
- package/dist/cli/determination.js.map +1 -1
- package/dist/cli/flag-help.d.ts +1 -0
- package/dist/cli/flag-help.d.ts.map +1 -1
- package/dist/cli/flag-help.js +1 -0
- package/dist/cli/flag-help.js.map +1 -1
- package/dist/cli/graphs.d.ts +2 -0
- package/dist/cli/graphs.d.ts.map +1 -1
- package/dist/cli/graphs.js +1 -0
- package/dist/cli/graphs.js.map +1 -1
- package/dist/cli/main.d.ts +1 -0
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +1 -0
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/output.d.ts +8 -0
- package/dist/cli/output.d.ts.map +1 -1
- package/dist/cli/output.js +8 -0
- package/dist/cli/output.js.map +1 -1
- package/dist/cli/statuses.d.ts.map +1 -1
- package/dist/cli/statuses.js +12 -2
- package/dist/cli/statuses.js.map +1 -1
- package/dist/cli/version.d.ts +1 -0
- package/dist/cli/version.d.ts.map +1 -1
- package/dist/cli/version.js +1 -0
- package/dist/cli/version.js.map +1 -1
- package/dist/cli-api.d.ts +2 -0
- package/dist/cli-api.d.ts.map +1 -1
- package/dist/cli-api.js +2 -0
- package/dist/cli-api.js.map +1 -1
- package/dist/composition/canonical-graph.d.ts +2 -2
- package/dist/composition/canonical-graph.js +2 -2
- package/dist/composition/canonical-graph.js.map +1 -1
- package/dist/composition/consequence.d.ts +15 -5
- package/dist/composition/consequence.d.ts.map +1 -1
- package/dist/composition/consequence.js +6 -4
- package/dist/composition/consequence.js.map +1 -1
- package/dist/composition/discovery.d.ts +78 -14
- package/dist/composition/discovery.d.ts.map +1 -1
- package/dist/composition/discovery.js +73 -23
- package/dist/composition/discovery.js.map +1 -1
- package/dist/composition/expr-eval.d.ts +1 -1
- package/dist/composition/expr-eval.d.ts.map +1 -1
- package/dist/composition/expr-eval.js +4 -4
- package/dist/composition/expr-eval.js.map +1 -1
- package/dist/composition/expr-simplify.d.ts +10 -14
- package/dist/composition/expr-simplify.d.ts.map +1 -1
- package/dist/composition/expr-simplify.js +49 -52
- package/dist/composition/expr-simplify.js.map +1 -1
- package/dist/composition/grounding.d.ts.map +1 -1
- package/dist/composition/grounding.js +19 -7
- package/dist/composition/grounding.js.map +1 -1
- package/dist/composition/mathts-quiet.d.ts +4 -6
- package/dist/composition/mathts-quiet.d.ts.map +1 -1
- package/dist/composition/mathts-quiet.js +4 -14
- package/dist/composition/mathts-quiet.js.map +1 -1
- package/dist/composition/own-equation-magnitude.d.ts +95 -0
- package/dist/composition/own-equation-magnitude.d.ts.map +1 -0
- package/dist/composition/own-equation-magnitude.js +270 -0
- package/dist/composition/own-equation-magnitude.js.map +1 -0
- package/dist/composition/probe/backend-protocol.d.ts +3 -0
- package/dist/composition/probe/backend-protocol.d.ts.map +1 -1
- package/dist/composition/probe/backend-protocol.js.map +1 -1
- package/dist/composition/probe/candidate-store.d.ts +1 -0
- package/dist/composition/probe/candidate-store.d.ts.map +1 -1
- package/dist/composition/probe/candidate-store.js +1 -0
- package/dist/composition/probe/candidate-store.js.map +1 -1
- package/dist/composition/probe/corpus.d.ts +4 -2
- package/dist/composition/probe/corpus.d.ts.map +1 -1
- package/dist/composition/probe/corpus.js +3 -3
- package/dist/composition/probe/corpus.js.map +1 -1
- package/dist/composition/probe/dataset.d.ts +1 -0
- package/dist/composition/probe/dataset.d.ts.map +1 -1
- package/dist/composition/probe/dataset.js.map +1 -1
- package/dist/composition/probe/experiment-design.d.ts +2 -0
- package/dist/composition/probe/experiment-design.d.ts.map +1 -1
- package/dist/composition/probe/experiment-design.js.map +1 -1
- package/dist/composition/probe/falsify.d.ts +2 -0
- package/dist/composition/probe/falsify.d.ts.map +1 -1
- package/dist/composition/probe/falsify.js.map +1 -1
- package/dist/composition/probe/fit.d.ts +1 -0
- package/dist/composition/probe/fit.d.ts.map +1 -1
- package/dist/composition/probe/fit.js.map +1 -1
- package/dist/composition/probe/generator.d.ts +3 -0
- package/dist/composition/probe/generator.d.ts.map +1 -1
- package/dist/composition/probe/generator.js +5 -6
- package/dist/composition/probe/generator.js.map +1 -1
- package/dist/composition/probe/limits.d.ts +1 -0
- package/dist/composition/probe/limits.d.ts.map +1 -1
- package/dist/composition/probe/limits.js.map +1 -1
- package/dist/composition/probe/pipeline.d.ts +5 -0
- package/dist/composition/probe/pipeline.d.ts.map +1 -1
- package/dist/composition/probe/pipeline.js +64 -21
- package/dist/composition/probe/pipeline.js.map +1 -1
- package/dist/composition/probe/power-law.d.ts.map +1 -1
- package/dist/composition/probe/power-law.js +3 -7
- package/dist/composition/probe/power-law.js.map +1 -1
- package/dist/composition/probe/problem.d.ts +1 -0
- package/dist/composition/probe/problem.d.ts.map +1 -1
- package/dist/composition/probe/problem.js.map +1 -1
- package/dist/composition/probe/residual.d.ts +1 -0
- package/dist/composition/probe/residual.d.ts.map +1 -1
- package/dist/composition/probe/residual.js +1 -0
- package/dist/composition/probe/residual.js.map +1 -1
- package/dist/composition/probe/run-manifest.d.ts +1 -0
- package/dist/composition/probe/run-manifest.d.ts.map +1 -1
- package/dist/composition/probe/run-manifest.js.map +1 -1
- package/dist/composition/probe/scalar-search.d.ts +50 -0
- package/dist/composition/probe/scalar-search.d.ts.map +1 -0
- package/dist/composition/probe/scalar-search.js +169 -0
- package/dist/composition/probe/scalar-search.js.map +1 -0
- package/dist/composition/probe/scoring.d.ts +1 -0
- package/dist/composition/probe/scoring.d.ts.map +1 -1
- package/dist/composition/probe/scoring.js.map +1 -1
- package/dist/composition/probe/study.d.ts +2 -2
- package/dist/composition/probe/study.d.ts.map +1 -1
- package/dist/composition/probe/study.js +6 -10
- package/dist/composition/probe/study.js.map +1 -1
- package/dist/composition/probe/t-tail.d.ts +3 -4
- package/dist/composition/probe/t-tail.d.ts.map +1 -1
- package/dist/composition/probe/t-tail.js +7 -10
- package/dist/composition/probe/t-tail.js.map +1 -1
- package/dist/composition/proposed-bridges.d.ts +11 -2
- package/dist/composition/proposed-bridges.d.ts.map +1 -1
- package/dist/composition/proposed-bridges.js +7 -5
- package/dist/composition/proposed-bridges.js.map +1 -1
- package/dist/composition/rational-exponent.d.ts +2 -2
- package/dist/composition/rational-exponent.d.ts.map +1 -1
- package/dist/composition/rational-exponent.js +4 -4
- package/dist/composition/rational-exponent.js.map +1 -1
- package/dist/composition/representative-values.d.ts.map +1 -1
- package/dist/composition/representative-values.js +6 -0
- package/dist/composition/representative-values.js.map +1 -1
- package/dist/composition/retrodiction.d.ts +15 -0
- package/dist/composition/retrodiction.d.ts.map +1 -1
- package/dist/composition/retrodiction.js +10 -3
- package/dist/composition/retrodiction.js.map +1 -1
- package/dist/composition/user-equation.d.ts +1 -0
- package/dist/composition/user-equation.d.ts.map +1 -1
- package/dist/composition/user-equation.js +1 -0
- package/dist/composition/user-equation.js.map +1 -1
- package/dist/core/constants.d.ts +12 -11
- package/dist/core/constants.d.ts.map +1 -1
- package/dist/core/constants.js +24 -21
- package/dist/core/constants.js.map +1 -1
- package/dist/diff/bridge-ast-gradient.d.ts +27 -23
- package/dist/diff/bridge-ast-gradient.d.ts.map +1 -1
- package/dist/diff/bridge-ast-gradient.js +75 -173
- package/dist/diff/bridge-ast-gradient.js.map +1 -1
- package/dist/dimensional/ast-types.d.ts +15 -0
- package/dist/dimensional/ast-types.d.ts.map +1 -1
- package/dist/dimensional/ast-types.js.map +1 -1
- package/dist/dimensional/curvature-composite.d.ts +1 -1
- package/dist/dimensional/curvature-composite.js.map +1 -1
- package/dist/dimensional/exact-scale.d.ts +41 -11
- package/dist/dimensional/exact-scale.d.ts.map +1 -1
- package/dist/dimensional/exact-scale.js +115 -123
- package/dist/dimensional/exact-scale.js.map +1 -1
- package/dist/dimensional/mathts-unit-delegation.d.ts +29 -0
- package/dist/dimensional/mathts-unit-delegation.d.ts.map +1 -0
- package/dist/dimensional/mathts-unit-delegation.js +187 -0
- package/dist/dimensional/mathts-unit-delegation.js.map +1 -0
- package/dist/dimensional/mathts-unit-wrapper.d.ts +33 -0
- package/dist/dimensional/mathts-unit-wrapper.d.ts.map +1 -0
- package/dist/dimensional/mathts-unit-wrapper.js +190 -0
- package/dist/dimensional/mathts-unit-wrapper.js.map +1 -0
- package/dist/dimensional/scalar-lowering.d.ts +21 -0
- package/dist/dimensional/scalar-lowering.d.ts.map +1 -0
- package/dist/dimensional/scalar-lowering.js +45 -0
- package/dist/dimensional/scalar-lowering.js.map +1 -0
- package/dist/dimensional/unit-data.d.ts +5 -1
- package/dist/dimensional/unit-data.d.ts.map +1 -1
- package/dist/dimensional/unit-data.js +28 -4
- package/dist/dimensional/unit-data.js.map +1 -1
- package/dist/dimensional/units.d.ts +2 -0
- package/dist/dimensional/units.d.ts.map +1 -1
- package/dist/dimensional/units.js +59 -3
- package/dist/dimensional/units.js.map +1 -1
- package/dist/dimensional/validator.d.ts +2 -0
- package/dist/dimensional/validator.d.ts.map +1 -1
- package/dist/dimensional/validator.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/numerical/connection-lowering-helpers.d.ts +3 -1
- package/dist/numerical/connection-lowering-helpers.d.ts.map +1 -1
- package/dist/numerical/connection-lowering-helpers.js +11 -15
- package/dist/numerical/connection-lowering-helpers.js.map +1 -1
- package/dist/numerical/pderiv.d.ts.map +1 -1
- package/dist/numerical/pderiv.js +2 -6
- package/dist/numerical/pderiv.js.map +1 -1
- package/dist/numerical/quadrature.js +3 -3
- package/dist/numerical/quadrature.js.map +1 -1
- package/dist/numerical/statistics.js +1 -1
- package/dist/numerical/statistics.js.map +1 -1
- package/dist/numerical/strides.d.ts +3 -2
- package/dist/numerical/strides.d.ts.map +1 -1
- package/dist/numerical/strides.js +3 -10
- package/dist/numerical/strides.js.map +1 -1
- package/package.json +9 -12
- package/dist/cases/brownian-sphere.d.ts +0 -68
- package/dist/cases/brownian-sphere.d.ts.map +0 -1
- package/dist/cases/brownian-sphere.js +0 -355
- package/dist/cases/brownian-sphere.js.map +0 -1
- package/dist/cases/damped-resonator.d.ts +0 -23
- package/dist/cases/damped-resonator.d.ts.map +0 -1
- package/dist/cases/damped-resonator.js +0 -221
- package/dist/cases/damped-resonator.js.map +0 -1
- package/dist/cases/kepler-rv.d.ts +0 -13
- package/dist/cases/kepler-rv.d.ts.map +0 -1
- package/dist/cases/kepler-rv.js +0 -173
- package/dist/cases/kepler-rv.js.map +0 -1
- package/dist/cases/lumped-cooling.d.ts +0 -51
- package/dist/cases/lumped-cooling.d.ts.map +0 -1
- package/dist/cases/lumped-cooling.js +0 -259
- package/dist/cases/lumped-cooling.js.map +0 -1
- package/dist/cases/resistor-noise.d.ts +0 -14
- package/dist/cases/resistor-noise.d.ts.map +0 -1
- package/dist/cases/resistor-noise.js +0 -215
- package/dist/cases/resistor-noise.js.map +0 -1
- package/dist/cases/skin-depth.d.ts +0 -17
- package/dist/cases/skin-depth.d.ts.map +0 -1
- package/dist/cases/skin-depth.js +0 -170
- package/dist/cases/skin-depth.js.map +0 -1
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A magnitude for a quantity from its own equation, for the discovery magnitude gate.
|
|
3
|
+
*
|
|
4
|
+
* The gate (`discovery.ts`, `magnitudeGate`) reads a quantity's magnitude from the sourced
|
|
5
|
+
* representative-value table, else from the value the graph fixes with no anchor input (the
|
|
6
|
+
* target of a source-less equation), else from the anchor. A quantity none of those reach (the
|
|
7
|
+
* Hubble distance, c/H0, whose input the table states but the anchor does not reach) made the gate
|
|
8
|
+
* abstain. This module evaluates such a quantity from an edge into it whose every source is
|
|
9
|
+
* valued: a table value, a registered constant, a no-anchor constant, or a value this module
|
|
10
|
+
* already derived, iterated to a fixed point. It is seeded from the table and the constants only,
|
|
11
|
+
* never from the anchor, so a derived magnitude is not anchor-derived.
|
|
12
|
+
*
|
|
13
|
+
* Three guards, each a refusal the caller sees (`DerivedMagnitudes.refusals`):
|
|
14
|
+
* - precision: a derived value carries σ in decades of log10|value|, propagated from its inputs
|
|
15
|
+
* through the edge's log-elasticities, σ = √(Σ (∂log f/∂log xᵢ)² σᵢ²) (σᵢ is the table row's
|
|
16
|
+
* σ, 0 for a constant, the derived σ for a derived input). The gate uses a value only when σ is
|
|
17
|
+
* at most {@link DEFAULT_SIGMA_DECADES}, the table's own "good to about one order". The FRET
|
|
18
|
+
* efficiency from two 5 nm order-of-magnitude scales is exactly 0.5 and carries 3√2 decades: a
|
|
19
|
+
* number with no magnitude information, which this guard refuses.
|
|
20
|
+
* - agreement: two edges that derive one quantity and differ by more than a relative
|
|
21
|
+
* {@link DERIVED_AGREEMENT} give it no value; no edge wins by its place in the list.
|
|
22
|
+
* - the edge's own evaluation (`evaluateEdge`): a domain refusal, an unset coefficient or a
|
|
23
|
+
* non-finite or zero result gives no value.
|
|
24
|
+
*
|
|
25
|
+
* Seeds are SI (the table's unit) and are converted into each quantity's evaluator convention
|
|
26
|
+
* (`conventionScaleToSI`; `planck-mass-energy` and `vacuum-expectation-value` speak GeV), and every
|
|
27
|
+
* result is converted back to SI.
|
|
28
|
+
*
|
|
29
|
+
* INTERNAL — read by `discovery.ts`; surfaced through `upt discover` and `upt ground`.
|
|
30
|
+
*
|
|
31
|
+
* @module composition/own-equation-magnitude
|
|
32
|
+
*/
|
|
33
|
+
import type { BridgeEdge } from './edge.js';
|
|
34
|
+
import type { QuantityIdentification } from './compose.js';
|
|
35
|
+
import type { RepresentativeValue } from './representative-values.js';
|
|
36
|
+
/**
|
|
37
|
+
* Relative difference above which two edges deriving one quantity disagree. Two encodings of one
|
|
38
|
+
* equation agree to rounding; a factor that differs (2 against 1) is far above it.
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
export declare const DERIVED_AGREEMENT = 1e-9;
|
|
42
|
+
/** A magnitude derived from a quantity's own equation. @internal */
|
|
43
|
+
export interface DerivedMagnitude {
|
|
44
|
+
/** The value in SI (the table's unit), converted back from the evaluator's convention. */
|
|
45
|
+
readonly value: number;
|
|
46
|
+
/** σ in decades of log10|value|, propagated through the edge's log-elasticities. */
|
|
47
|
+
readonly sigmaDecades: number;
|
|
48
|
+
/** The edge that produced it (`identification:<from>` for a registered identification's copy). */
|
|
49
|
+
readonly edge: string;
|
|
50
|
+
/** The names the edge read, sorted. */
|
|
51
|
+
readonly inputs: readonly string[];
|
|
52
|
+
}
|
|
53
|
+
/** Why a quantity reached by an equation has no derived magnitude. @internal */
|
|
54
|
+
export interface DerivedMagnitudeRefusal {
|
|
55
|
+
readonly name: string;
|
|
56
|
+
/**
|
|
57
|
+
* `imprecise`: the propagated σ is above the guard. `disagreeing-edges`: two edges that derive it
|
|
58
|
+
* differ by more than {@link DERIVED_AGREEMENT}. `precision-unknown`: the edge fired at the point
|
|
59
|
+
* but not at the points the elasticity reads, so σ could not be measured.
|
|
60
|
+
*/
|
|
61
|
+
readonly reason: 'imprecise' | 'disagreeing-edges' | 'precision-unknown';
|
|
62
|
+
/** The edges involved, sorted. */
|
|
63
|
+
readonly edges: readonly string[];
|
|
64
|
+
/** The propagated σ, for `imprecise`. */
|
|
65
|
+
readonly sigmaDecades?: number;
|
|
66
|
+
/** One sentence for a reader. */
|
|
67
|
+
readonly detail: string;
|
|
68
|
+
}
|
|
69
|
+
/** The magnitudes the graph derives from the table and the constants, and the refusals. @internal */
|
|
70
|
+
export interface DerivedMagnitudes {
|
|
71
|
+
/** Derived magnitudes the gate may use (σ within the guard), by quantity name. */
|
|
72
|
+
readonly values: ReadonlyMap<string, DerivedMagnitude>;
|
|
73
|
+
/** Every quantity an equation reached that has no usable derived magnitude, sorted by name. */
|
|
74
|
+
readonly refusals: readonly DerivedMagnitudeRefusal[];
|
|
75
|
+
}
|
|
76
|
+
/** What the caller supplies: the sourced table and the no-anchor constants. @internal */
|
|
77
|
+
export interface OwnEquationSeeds {
|
|
78
|
+
/** The sourced representative values, in SI. */
|
|
79
|
+
readonly representativeValues: Readonly<Record<string, RepresentativeValue>>;
|
|
80
|
+
/** The values the graph fixes with no anchor input, in the evaluator's convention (`forwardEvaluate(edges, {}, …)`). */
|
|
81
|
+
readonly constantValues: ReadonlyMap<string, number>;
|
|
82
|
+
/** Identifications honoured as copies, as `forwardEvaluate` honours them. */
|
|
83
|
+
readonly identifications: readonly QuantityIdentification[];
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The magnitudes `edges` derive from the sourced table and the constants, with the refusals. A
|
|
87
|
+
* quantity the table or a constant states is a seed and is never derived. Each round fires every
|
|
88
|
+
* edge from the values of the round before, so the edge list's order decides nothing; a quantity
|
|
89
|
+
* that two edges value differently is withdrawn with everything derived from it, and the fixed
|
|
90
|
+
* point is recomputed without it. A value is assigned from the first of its agreeing edges by id.
|
|
91
|
+
*
|
|
92
|
+
* @internal
|
|
93
|
+
*/
|
|
94
|
+
export declare function deriveOwnEquationMagnitudes(edges: readonly BridgeEdge[], seeds: OwnEquationSeeds, maxSigmaDecades?: number): DerivedMagnitudes;
|
|
95
|
+
//# sourceMappingURL=own-equation-magnit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AC,QAAQ,EAAE,SAAS,uBAAuB,EAAE,CAAC;CACvD;AAiBD,yFAAyF;AACzF,MAAM,WAAW,gBAAgB;IAC/B,gDAAgD;IAChD,QAAQ,CAAC,oBAAoB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAC7E,wHAAwH;IACxH,QAAQ,CAAC,cAAc,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrD,6EAA6E;IAC7E,QAAQ,CAAC,eAAe,EAAE,SAAS,sBAAsB,EAAE,CAAC;CAC7D;AAkGD;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,SAAS,UAAU,EAAE,EAC5B,KAAK,EAAE,gBAAgB,EACvB,eAAe,GAAE,MAA8B,GAC9C,iBAAiB,CAkFnB"}
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A magnitude for a quantity from its own equation, for the discovery magnitude gate.
|
|
3
|
+
*
|
|
4
|
+
* The gate (`discovery.ts`, `magnitudeGate`) reads a quantity's magnitude from the sourced
|
|
5
|
+
* representative-value table, else from the value the graph fixes with no anchor input (the
|
|
6
|
+
* target of a source-less equation), else from the anchor. A quantity none of those reach (the
|
|
7
|
+
* Hubble distance, c/H0, whose input the table states but the anchor does not reach) made the gate
|
|
8
|
+
* abstain. This module evaluates such a quantity from an edge into it whose every source is
|
|
9
|
+
* valued: a table value, a registered constant, a no-anchor constant, or a value this module
|
|
10
|
+
* already derived, iterated to a fixed point. It is seeded from the table and the constants only,
|
|
11
|
+
* never from the anchor, so a derived magnitude is not anchor-derived.
|
|
12
|
+
*
|
|
13
|
+
* Three guards, each a refusal the caller sees (`DerivedMagnitudes.refusals`):
|
|
14
|
+
* - precision: a derived value carries σ in decades of log10|value|, propagated from its inputs
|
|
15
|
+
* through the edge's log-elasticities, σ = √(Σ (∂log f/∂log xᵢ)² σᵢ²) (σᵢ is the table row's
|
|
16
|
+
* σ, 0 for a constant, the derived σ for a derived input). The gate uses a value only when σ is
|
|
17
|
+
* at most {@link DEFAULT_SIGMA_DECADES}, the table's own "good to about one order". The FRET
|
|
18
|
+
* efficiency from two 5 nm order-of-magnitude scales is exactly 0.5 and carries 3√2 decades: a
|
|
19
|
+
* number with no magnitude information, which this guard refuses.
|
|
20
|
+
* - agreement: two edges that derive one quantity and differ by more than a relative
|
|
21
|
+
* {@link DERIVED_AGREEMENT} give it no value; no edge wins by its place in the list.
|
|
22
|
+
* - the edge's own evaluation (`evaluateEdge`): a domain refusal, an unset coefficient or a
|
|
23
|
+
* non-finite or zero result gives no value.
|
|
24
|
+
*
|
|
25
|
+
* Seeds are SI (the table's unit) and are converted into each quantity's evaluator convention
|
|
26
|
+
* (`conventionScaleToSI`; `planck-mass-energy` and `vacuum-expectation-value` speak GeV), and every
|
|
27
|
+
* result is converted back to SI.
|
|
28
|
+
*
|
|
29
|
+
* INTERNAL — read by `discovery.ts`; surfaced through `upt discover` and `upt ground`.
|
|
30
|
+
*
|
|
31
|
+
* @module composition/own-equation-magnitude
|
|
32
|
+
*/
|
|
33
|
+
import { evaluateEdge } from './edge.js';
|
|
34
|
+
import { evaluationInputs, refusesThePoint } from './retrodiction.js';
|
|
35
|
+
import { DEFAULT_SIGMA_DECADES, sigmaDecadesOf } from './representative-values.js';
|
|
36
|
+
import { conventionFactor, conventionScaleToSI } from '../dimensional/unit-convention.js';
|
|
37
|
+
import { CONSTANT_REGISTRY } from '../dimensional/symbolic-constants.js';
|
|
38
|
+
import { centralPartial } from '../numerical/finite-difference.js';
|
|
39
|
+
import { byKey, compareCodepoint } from '../core/compare.js';
|
|
40
|
+
import { formatQuantity } from '../core/format.js';
|
|
41
|
+
/**
|
|
42
|
+
* Relative difference above which two edges deriving one quantity disagree. Two encodings of one
|
|
43
|
+
* equation agree to rounding; a factor that differs (2 against 1) is far above it.
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
export const DERIVED_AGREEMENT = 1e-9;
|
|
47
|
+
/**
|
|
48
|
+
* The half-step, in decades of an input, of the central difference that measures a
|
|
49
|
+
* log-elasticity. A power law's elasticity is exact at any step; for another form the truncation
|
|
50
|
+
* error is of order the step squared.
|
|
51
|
+
*/
|
|
52
|
+
const ELASTICITY_STEP_DECADES = 1e-3;
|
|
53
|
+
/**
|
|
54
|
+
* Decades by which a propagated σ may exceed the guard and still pass: room for the central
|
|
55
|
+
* difference's rounding, so a power law of elasticity 1 on a one-decade input is not refused for a
|
|
56
|
+
* last-bit excess (the Hubble distance's σ measures exactly 1). Far below any σ the guard refuses.
|
|
57
|
+
*/
|
|
58
|
+
const SIGMA_GUARD_SLACK = 1e-9;
|
|
59
|
+
/** The seeds: the table (SI → evaluator unit), then a registered constant that is a graph quantity, then a no-anchor constant. */
|
|
60
|
+
function seedsOf(edges, seeds) {
|
|
61
|
+
const known = new Map();
|
|
62
|
+
for (const [name, rv] of Object.entries(seeds.representativeValues)) {
|
|
63
|
+
if (!(Number.isFinite(rv.value) && rv.value !== 0))
|
|
64
|
+
continue;
|
|
65
|
+
known.set(name, { value: rv.value / conventionScaleToSI(name), sigmaDecades: sigmaDecadesOf(rv) });
|
|
66
|
+
}
|
|
67
|
+
const names = new Set(edges.flatMap((e) => [e.target.name, ...e.sources.map((s) => s.name)]));
|
|
68
|
+
for (const record of CONSTANT_REGISTRY) {
|
|
69
|
+
const name = record.quantity;
|
|
70
|
+
if (name === undefined || !names.has(name) || known.has(name))
|
|
71
|
+
continue;
|
|
72
|
+
known.set(name, { value: record.value / conventionScaleToSI(name), sigmaDecades: 0 });
|
|
73
|
+
}
|
|
74
|
+
for (const [name, value] of seeds.constantValues) {
|
|
75
|
+
if (known.has(name) || !(Number.isFinite(value) && value !== 0))
|
|
76
|
+
continue;
|
|
77
|
+
known.set(name, { value, sigmaDecades: 0 });
|
|
78
|
+
}
|
|
79
|
+
return known;
|
|
80
|
+
}
|
|
81
|
+
/** log10|f| as a function of log10|x_key|, the other inputs held. NaN when the edge refuses. */
|
|
82
|
+
function logResponse(edge, inputs, key) {
|
|
83
|
+
const sign = Math.sign(inputs[key]);
|
|
84
|
+
return (point) => {
|
|
85
|
+
try {
|
|
86
|
+
return Math.log10(Math.abs(evaluateEdge(edge, { ...inputs, [key]: sign * 10 ** point['u'] })));
|
|
87
|
+
}
|
|
88
|
+
catch (err) {
|
|
89
|
+
if (!refusesThePoint(err))
|
|
90
|
+
throw err;
|
|
91
|
+
return Number.NaN;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/** σ of an edge's value from its inputs' σ, through the log-elasticities; undefined when one is not finite. */
|
|
96
|
+
function propagatedSigma(edge, inputs, known) {
|
|
97
|
+
let sum = 0;
|
|
98
|
+
for (const key of Object.keys(inputs).sort(compareCodepoint)) {
|
|
99
|
+
const sigma = known.get(key)?.sigmaDecades ?? 0;
|
|
100
|
+
if (sigma === 0)
|
|
101
|
+
continue;
|
|
102
|
+
const x = inputs[key];
|
|
103
|
+
if (!(Number.isFinite(x) && x !== 0))
|
|
104
|
+
return undefined;
|
|
105
|
+
const elasticity = centralPartial(logResponse(edge, inputs, key), { u: Math.log10(Math.abs(x)) }, 'u', ELASTICITY_STEP_DECADES);
|
|
106
|
+
if (!Number.isFinite(elasticity))
|
|
107
|
+
return undefined;
|
|
108
|
+
sum += elasticity * elasticity * sigma * sigma;
|
|
109
|
+
}
|
|
110
|
+
return Math.sqrt(sum);
|
|
111
|
+
}
|
|
112
|
+
/** Every edge and identification that fires for an unvalued, unblocked target, from `known` as it stands. */
|
|
113
|
+
function firings(edges, idents, known, skip) {
|
|
114
|
+
const out = new Map();
|
|
115
|
+
const push = (target, f) => {
|
|
116
|
+
const list = out.get(target);
|
|
117
|
+
if (list === undefined)
|
|
118
|
+
out.set(target, [f]);
|
|
119
|
+
else
|
|
120
|
+
list.push(f);
|
|
121
|
+
};
|
|
122
|
+
for (const id of idents) {
|
|
123
|
+
const from = known.get(id.from);
|
|
124
|
+
if (from === undefined || skip(id.to))
|
|
125
|
+
continue;
|
|
126
|
+
const value = from.value * conventionFactor(id.from, id.to);
|
|
127
|
+
if (Number.isFinite(value) && value !== 0) {
|
|
128
|
+
push(id.to, { edge: `identification:${id.from}`, value, sigmaDecades: from.sigmaDecades, inputs: [id.from] });
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const values = new Map([...known].map(([name, k]) => [name, k.value]));
|
|
132
|
+
for (const e of edges) {
|
|
133
|
+
if (skip(e.target.name))
|
|
134
|
+
continue;
|
|
135
|
+
if (!e.sources.every((s) => known.has(s.name)))
|
|
136
|
+
continue;
|
|
137
|
+
const inputs = evaluationInputs(e, values);
|
|
138
|
+
let value;
|
|
139
|
+
try {
|
|
140
|
+
value = evaluateEdge(e, inputs);
|
|
141
|
+
}
|
|
142
|
+
catch (err) {
|
|
143
|
+
if (!refusesThePoint(err))
|
|
144
|
+
throw err;
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
if (!(Number.isFinite(value) && value !== 0))
|
|
148
|
+
continue;
|
|
149
|
+
push(e.target.name, { edge: e.id, value, sigmaDecades: propagatedSigma(e, inputs, known), inputs: Object.keys(inputs).sort(compareCodepoint) });
|
|
150
|
+
}
|
|
151
|
+
return out;
|
|
152
|
+
}
|
|
153
|
+
/** The firings sorted by edge id; and whether any two differ by more than {@link DERIVED_AGREEMENT}. */
|
|
154
|
+
function agreement(list) {
|
|
155
|
+
const sorted = [...list].sort(byKey((f) => f.edge));
|
|
156
|
+
const agree = sorted.every((f) => Math.abs(f.value - sorted[0].value) <= DERIVED_AGREEMENT * Math.max(Math.abs(f.value), Math.abs(sorted[0].value)));
|
|
157
|
+
return { sorted, agree };
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* The magnitudes `edges` derive from the sourced table and the constants, with the refusals. A
|
|
161
|
+
* quantity the table or a constant states is a seed and is never derived. Each round fires every
|
|
162
|
+
* edge from the values of the round before, so the edge list's order decides nothing; a quantity
|
|
163
|
+
* that two edges value differently is withdrawn with everything derived from it, and the fixed
|
|
164
|
+
* point is recomputed without it. A value is assigned from the first of its agreeing edges by id.
|
|
165
|
+
*
|
|
166
|
+
* @internal
|
|
167
|
+
*/
|
|
168
|
+
export function deriveOwnEquationMagnitudes(edges, seeds, maxSigmaDecades = DEFAULT_SIGMA_DECADES) {
|
|
169
|
+
const seeded = seedsOf(edges, seeds);
|
|
170
|
+
const disagreeing = new Map();
|
|
171
|
+
for (;;) {
|
|
172
|
+
const unmeasured = new Map();
|
|
173
|
+
const known = new Map(seeded);
|
|
174
|
+
const derived = new Map();
|
|
175
|
+
const skip = (name) => known.has(name) || disagreeing.has(name) || unmeasured.has(name);
|
|
176
|
+
for (;;) {
|
|
177
|
+
const round = firings(edges, seeds.identifications, known, skip);
|
|
178
|
+
if (round.size === 0)
|
|
179
|
+
break;
|
|
180
|
+
for (const target of [...round.keys()].sort(compareCodepoint)) {
|
|
181
|
+
const { sorted, agree } = agreement(round.get(target));
|
|
182
|
+
const edgeIds = sorted.map((f) => f.edge);
|
|
183
|
+
if (!agree) {
|
|
184
|
+
disagreeing.set(target, disagreement(target, sorted));
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
const chosen = sorted[0];
|
|
188
|
+
if (chosen.sigmaDecades === undefined) {
|
|
189
|
+
unmeasured.set(target, {
|
|
190
|
+
name: target,
|
|
191
|
+
reason: 'precision-unknown',
|
|
192
|
+
edges: edgeIds,
|
|
193
|
+
detail: `${chosen.edge} fires at the point but not at the points its log-elasticity reads, so σ was not measured`,
|
|
194
|
+
});
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
derived.set(target, chosen);
|
|
198
|
+
known.set(target, { value: chosen.value, sigmaDecades: chosen.sigmaDecades });
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
// An edge whose sources were valued only after its target was: it must agree with that value.
|
|
202
|
+
const late = [];
|
|
203
|
+
const values = new Map([...known].map(([name, k]) => [name, k.value]));
|
|
204
|
+
for (const [target, chosen] of derived) {
|
|
205
|
+
const all = [chosen];
|
|
206
|
+
for (const e of edges) {
|
|
207
|
+
if (e.target.name !== target || e.id === chosen.edge)
|
|
208
|
+
continue;
|
|
209
|
+
if (!e.sources.every((s) => known.has(s.name)))
|
|
210
|
+
continue;
|
|
211
|
+
try {
|
|
212
|
+
const value = evaluateEdge(e, evaluationInputs(e, values));
|
|
213
|
+
if (Number.isFinite(value) && value !== 0)
|
|
214
|
+
all.push({ edge: e.id, value, sigmaDecades: undefined, inputs: [] });
|
|
215
|
+
}
|
|
216
|
+
catch (err) {
|
|
217
|
+
if (!refusesThePoint(err))
|
|
218
|
+
throw err;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
for (const id of seeds.identifications) {
|
|
222
|
+
if (id.to !== target || `identification:${id.from}` === chosen.edge)
|
|
223
|
+
continue;
|
|
224
|
+
const from = known.get(id.from);
|
|
225
|
+
if (from === undefined)
|
|
226
|
+
continue;
|
|
227
|
+
const value = from.value * conventionFactor(id.from, id.to);
|
|
228
|
+
if (Number.isFinite(value) && value !== 0)
|
|
229
|
+
all.push({ edge: `identification:${id.from}`, value, sigmaDecades: undefined, inputs: [] });
|
|
230
|
+
}
|
|
231
|
+
const { sorted, agree } = agreement(all);
|
|
232
|
+
if (!agree) {
|
|
233
|
+
disagreeing.set(target, disagreement(target, sorted));
|
|
234
|
+
late.push(target);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
if (late.length > 0)
|
|
238
|
+
continue;
|
|
239
|
+
const usable = new Map();
|
|
240
|
+
const refusals = [...disagreeing.values(), ...unmeasured.values()];
|
|
241
|
+
for (const [name, f] of derived) {
|
|
242
|
+
const sigma = f.sigmaDecades;
|
|
243
|
+
if (sigma > maxSigmaDecades + SIGMA_GUARD_SLACK) {
|
|
244
|
+
refusals.push({
|
|
245
|
+
name,
|
|
246
|
+
reason: 'imprecise',
|
|
247
|
+
edges: [f.edge],
|
|
248
|
+
sigmaDecades: sigma,
|
|
249
|
+
detail: `${f.edge} gives ${name} from ${f.inputs.join(', ')} at σ = ${formatQuantity(sigma, 3)} decades, ` +
|
|
250
|
+
`above the ${maxSigmaDecades}-decade precision the gate requires`,
|
|
251
|
+
});
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
usable.set(name, { value: f.value * conventionScaleToSI(name), sigmaDecades: sigma, edge: f.edge, inputs: f.inputs });
|
|
255
|
+
}
|
|
256
|
+
refusals.sort(byKey((r) => r.name));
|
|
257
|
+
return { values: usable, refusals };
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
/** The refusal record of two or more edges that value one quantity differently. */
|
|
261
|
+
function disagreement(name, sorted) {
|
|
262
|
+
return {
|
|
263
|
+
name,
|
|
264
|
+
reason: 'disagreeing-edges',
|
|
265
|
+
edges: sorted.map((f) => f.edge),
|
|
266
|
+
detail: `${sorted.map((f) => `${f.edge} gives ${formatQuantity(f.value, 4)}`).join(', ')}: ` +
|
|
267
|
+
`they differ by more than a relative ${DERIVED_AGREEMENT}, so no edge is taken`,
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
//# sourceMappingURL=own-equation-magnitude.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"own-equation-magnitude.js","sourceRoot":"","sources":["../../src/composition/own-equation-magnitude.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEnF,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAC1F,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,m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AE,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;QACxH,CAAC;QACD,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QACpC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;IACtC,CAAC;AACH,CAAC;AAED,mFAAmF;AACnF,SAAS,YAAY,CAAC,IAAY,EAAE,MAAyB;IAC3D,OAAO;QACL,IAAI;QACJ,MAAM,EAAE,mBAAmB;QAC3B,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QAChC,MAAM,EACJ,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,UAAU,cAAc,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;YACpF,uCAAuC,iBAAiB,uBAAuB;KAClF,CAAC;AACJ,CAAC","sourcesContent":["/**\n * A magnitude for a quantity from its own equation, for the discovery magnitude gate.\n *\n * The gate (`discovery.ts`, `magnitudeGate`) reads a quantity's magnitude from the sourced\n * representative-value table, else from the value the graph fixes with no anchor input (the\n * target of a source-less equation), else from the anchor. A quantity none of those reach (the\n * Hubble distance, c/H0, whose input the table states but the anchor does not reach) made the gate\n * abstain. This module evaluates such a quantity from an edge into it whose every source is\n * valued: a table value, a registered constant, a no-anchor constant, or a value this module\n * already derived, iterated to a fixed point. It is seeded from the table and the constants only,\n * never from the anchor, so a derived magnitude is not anchor-derived.\n *\n * Three guards, each a refusal the caller sees (`DerivedMagnitudes.refusals`):\n * - precision: a derived value carries σ in decades of log10|value|, propagated from its inputs\n * through the edge's log-elasticities, σ = √(Σ (∂log f/∂log xᵢ)² σᵢ²) (σᵢ is the table row's\n * σ, 0 for a constant, the derived σ for a derived input). The gate uses a value only when σ is\n * at most {@link DEFAULT_SIGMA_DECADES}, the table's own \"good to about one order\". The FRET\n * efficiency from two 5 nm order-of-magnitude scales is exactly 0.5 and carries 3√2 decades: a\n * number with no magnitude information, which this guard refuses.\n * - agreement: two edges that derive one quantity and differ by more than a relative\n * {@link DERIVED_AGREEMENT} give it no value; no edge wins by its place in the list.\n * - the edge's own evaluation (`evaluateEdge`): a domain refusal, an unset coefficient or a\n * non-finite or zero result gives no value.\n *\n * Seeds are SI (the table's unit) and are converted into each quantity's evaluator convention\n * (`conventionScaleToSI`; `planck-mass-energy` and `vacuum-expectation-value` speak GeV), and every\n * result is converted back to SI.\n *\n * INTERNAL — read by `discovery.ts`; surfaced through `upt discover` and `upt ground`.\n *\n * @module composition/own-equation-magnitude\n */\n\nimport type { BridgeEdge } from './edge.js';\nimport { evaluateEdge } from './edge.js';\nimport type { QuantityIdentification } from './compose.js';\nimport { evaluationInputs, refusesThePoint } from './retrodiction.js';\nimport { DEFAULT_SIGMA_DECADES, sigmaDecadesOf } from './representative-values.js';\nimport type { RepresentativeValue } from './representative-values.js';\nimport { conventionFactor, conventionScaleToSI } from '../dimensional/unit-convention.js';\nimport { CONSTANT_REGISTRY } from '../dimensional/symbolic-constants.js';\nimport { centralPartial } from '../numerical/finite-difference.js';\nimport { byKey, compareCodepoint } from '../core/compare.js';\nimport { formatQuantity } from '../core/format.js';\n\n/**\n * Relative difference above which two edges deriving one quantity disagree. Two encodings of one\n * equation agree to rounding; a factor that differs (2 against 1) is far above it.\n * @internal\n */\nexport const DERIVED_AGREEMENT = 1e-9;\n\n/**\n * The half-step, in decades of an input, of the central difference that measures a\n * log-elasticity. A power law's elasticity is exact at any step; for another form the truncation\n * error is of order the step squared.\n */\nconst ELASTICITY_STEP_DECADES = 1e-3;\n\n/**\n * Decades by which a propagated σ may exceed the guard and still pass: room for the central\n * difference's rounding, so a power law of elasticity 1 on a one-decade input is not refused for a\n * last-bit excess (the Hubble distance's σ measures exactly 1). Far below any σ the guard refuses.\n */\nconst SIGMA_GUARD_SLACK = 1e-9;\n\n/** A magnitude derived from a quantity's own equation. @internal */\nexport interface DerivedMagnitude {\n /** The value in SI (the table's unit), converted back from the evaluator's convention. */\n readonly value: number;\n /** σ in decades of log10|value|, propagated through the edge's log-elasticities. */\n readonly sigmaDecades: number;\n /** The edge that produced it (`identification:<from>` for a registered identification's copy). */\n readonly edge: string;\n /** The names the edge read, sorted. */\n readonly inputs: readonly string[];\n}\n\n/** Why a quantity reached by an equation has no derived magnitude. @internal */\nexport interface DerivedMagnitudeRefusal {\n readonly name: string;\n /**\n * `imprecise`: the propagated σ is above the guard. `disagreeing-edges`: two edges that derive it\n * differ by more than {@link DERIVED_AGREEMENT}. `precision-unknown`: the edge fired at the point\n * but not at the points the elasticity reads, so σ could not be measured.\n */\n readonly reason: 'imprecise' | 'disagreeing-edges' | 'precision-unknown';\n /** The edges involved, sorted. */\n readonly edges: readonly string[];\n /** The propagated σ, for `imprecise`. */\n readonly sigmaDecades?: number;\n /** One sentence for a reader. */\n readonly detail: string;\n}\n\n/** The magnitudes the graph derives from the table and the constants, and the refusals. @internal */\nexport interface DerivedMagnitudes {\n /** Derived magnitudes the gate may use (σ within the guard), by quantity name. */\n readonly values: ReadonlyMap<string, DerivedMagnitude>;\n /** Every quantity an equation reached that has no usable derived magnitude, sorted by name. */\n readonly refusals: readonly DerivedMagnitudeRefusal[];\n}\n\n/** A known value in the evaluator's convention, with its σ in decades. */\ninterface Known {\n readonly value: number;\n readonly sigmaDecades: number;\n}\n\n/** One edge (or identification) that fired for a target. */\ninterface Firing {\n readonly edge: string;\n readonly value: number;\n /** Undefined when the elasticity could not be measured. */\n readonly sigmaDecades: number | undefined;\n readonly inputs: readonly string[];\n}\n\n/** What the caller supplies: the sourced table and the no-anchor constants. @internal */\nexport interface OwnEquationSeeds {\n /** The sourced representative values, in SI. */\n readonly representativeValues: Readonly<Record<string, RepresentativeValue>>;\n /** The values the graph fixes with no anchor input, in the evaluator's convention (`forwardEvaluate(edges, {}, …)`). */\n readonly constantValues: ReadonlyMap<string, number>;\n /** Identifications honoured as copies, as `forwardEvaluate` honours them. */\n readonly identifications: readonly QuantityIdentification[];\n}\n\n/** The seeds: the table (SI → evaluator unit), then a registered constant that is a graph quantity, then a no-anchor constant. */\nfunction seedsOf(edges: readonly BridgeEdge[], seeds: OwnEquationSeeds): Map<string, Known> {\n const known = new Map<string, Known>();\n for (const [name, rv] of Object.entries(seeds.representativeValues)) {\n if (!(Number.isFinite(rv.value) && rv.value !== 0)) continue;\n known.set(name, { value: rv.value / conventionScaleToSI(name), sigmaDecades: sigmaDecadesOf(rv) });\n }\n const names = new Set(edges.flatMap((e) => [e.target.name, ...e.sources.map((s) => s.name)]));\n for (const record of CONSTANT_REGISTRY) {\n const name = record.quantity;\n if (name === undefined || !names.has(name) || known.has(name)) continue;\n known.set(name, { value: record.value / conventionScaleToSI(name), sigmaDecades: 0 });\n }\n for (const [name, value] of seeds.constantValues) {\n if (known.has(name) || !(Number.isFinite(value) && value !== 0)) continue;\n known.set(name, { value, sigmaDecades: 0 });\n }\n return known;\n}\n\n/** log10|f| as a function of log10|x_key|, the other inputs held. NaN when the edge refuses. */\nfunction logResponse(edge: BridgeEdge, inputs: Readonly<Record<string, number>>, key: string): (point: Record<string, number>) => number {\n const sign = Math.sign(inputs[key]!);\n return (point) => {\n try {\n return Math.log10(Math.abs(evaluateEdge(edge, { ...inputs, [key]: sign * 10 ** point['u']! })));\n } catch (err) {\n if (!refusesThePoint(err)) throw err;\n return Number.NaN;\n }\n };\n}\n\n/** σ of an edge's value from its inputs' σ, through the log-elasticities; undefined when one is not finite. */\nfunction propagatedSigma(edge: BridgeEdge, inputs: Readonly<Record<string, number>>, known: ReadonlyMap<string, Known>): number | undefined {\n let sum = 0;\n for (const key of Object.keys(inputs).sort(compareCodepoint)) {\n const sigma = known.get(key)?.sigmaDecades ?? 0;\n if (sigma === 0) continue;\n const x = inputs[key]!;\n if (!(Number.isFinite(x) && x !== 0)) return undefined;\n const elasticity = centralPartial(logResponse(edge, inputs, key), { u: Math.log10(Math.abs(x)) }, 'u', ELASTICITY_STEP_DECADES);\n if (!Number.isFinite(elasticity)) return undefined;\n sum += elasticity * elasticity * sigma * sigma;\n }\n return Math.sqrt(sum);\n}\n\n/** Every edge and identification that fires for an unvalued, unblocked target, from `known` as it stands. */\nfunction firings(\n edges: readonly BridgeEdge[],\n idents: readonly QuantityIdentification[],\n known: ReadonlyMap<string, Known>,\n skip: (name: string) => boolean,\n): Map<string, Firing[]> {\n const out = new Map<string, Firing[]>();\n const push = (target: string, f: Firing): void => {\n const list = out.get(target);\n if (list === undefined) out.set(target, [f]);\n else list.push(f);\n };\n for (const id of idents) {\n const from = known.get(id.from);\n if (from === undefined || skip(id.to)) continue;\n const value = from.value * conventionFactor(id.from, id.to);\n if (Number.isFinite(value) && value !== 0) {\n push(id.to, { edge: `identification:${id.from}`, value, sigmaDecades: from.sigmaDecades, inputs: [id.from] });\n }\n }\n const values = new Map([...known].map(([name, k]) => [name, k.value]));\n for (const e of edges) {\n if (skip(e.target.name)) continue;\n if (!e.sources.every((s) => known.has(s.name))) continue;\n const inputs = evaluationInputs(e, values);\n let value: number;\n try {\n value = evaluateEdge(e, inputs);\n } catch (err) {\n if (!refusesThePoint(err)) throw err;\n continue;\n }\n if (!(Number.isFinite(value) && value !== 0)) continue;\n push(e.target.name, { edge: e.id, value, sigmaDecades: propagatedSigma(e, inputs, known), inputs: Object.keys(inputs).sort(compareCodepoint) });\n }\n return out;\n}\n\n/** The firings sorted by edge id; and whether any two differ by more than {@link DERIVED_AGREEMENT}. */\nfunction agreement(list: readonly Firing[]): { sorted: Firing[]; agree: boolean } {\n const sorted = [...list].sort(byKey((f) => f.edge));\n const agree = sorted.every(\n (f) => Math.abs(f.value - sorted[0]!.value) <= DERIVED_AGREEMENT * Math.max(Math.abs(f.value), Math.abs(sorted[0]!.value)),\n );\n return { sorted, agree };\n}\n\n/**\n * The magnitudes `edges` derive from the sourced table and the constants, with the refusals. A\n * quantity the table or a constant states is a seed and is never derived. Each round fires every\n * edge from the values of the round before, so the edge list's order decides nothing; a quantity\n * that two edges value differently is withdrawn with everything derived from it, and the fixed\n * point is recomputed without it. A value is assigned from the first of its agreeing edges by id.\n *\n * @internal\n */\nexport function deriveOwnEquationMagnitudes(\n edges: readonly BridgeEdge[],\n seeds: OwnEquationSeeds,\n maxSigmaDecades: number = DEFAULT_SIGMA_DECADES,\n): DerivedMagnitudes {\n const seeded = seedsOf(edges, seeds);\n const disagreeing = new Map<string, DerivedMagnitudeRefusal>();\n for (;;) {\n const unmeasured = new Map<string, DerivedMagnitudeRefusal>();\n const known = new Map(seeded);\n const derived = new Map<string, Firing>();\n const skip = (name: string): boolean => known.has(name) || disagreeing.has(name) || unmeasured.has(name);\n for (;;) {\n const round = firings(edges, seeds.identifications, known, skip);\n if (round.size === 0) break;\n for (const target of [...round.keys()].sort(compareCodepoint)) {\n const { sorted, agree } = agreement(round.get(target)!);\n const edgeIds = sorted.map((f) => f.edge);\n if (!agree) {\n disagreeing.set(target, disagreement(target, sorted));\n continue;\n }\n const chosen = sorted[0]!;\n if (chosen.sigmaDecades === undefined) {\n unmeasured.set(target, {\n name: target,\n reason: 'precision-unknown',\n edges: edgeIds,\n detail: `${chosen.edge} fires at the point but not at the points its log-elasticity reads, so σ was not measured`,\n });\n continue;\n }\n derived.set(target, chosen);\n known.set(target, { value: chosen.value, sigmaDecades: chosen.sigmaDecades });\n }\n }\n // An edge whose sources were valued only after its target was: it must agree with that value.\n const late: string[] = [];\n const values = new Map([...known].map(([name, k]) => [name, k.value]));\n for (const [target, chosen] of derived) {\n const all: Firing[] = [chosen];\n for (const e of edges) {\n if (e.target.name !== target || e.id === chosen.edge) continue;\n if (!e.sources.every((s) => known.has(s.name))) continue;\n try {\n const value = evaluateEdge(e, evaluationInputs(e, values));\n if (Number.isFinite(value) && value !== 0) all.push({ edge: e.id, value, sigmaDecades: undefined, inputs: [] });\n } catch (err) {\n if (!refusesThePoint(err)) throw err;\n }\n }\n for (const id of seeds.identifications) {\n if (id.to !== target || `identification:${id.from}` === chosen.edge) continue;\n const from = known.get(id.from);\n if (from === undefined) continue;\n const value = from.value * conventionFactor(id.from, id.to);\n if (Number.isFinite(value) && value !== 0) all.push({ edge: `identification:${id.from}`, value, sigmaDecades: undefined, inputs: [] });\n }\n const { sorted, agree } = agreement(all);\n if (!agree) {\n disagreeing.set(target, disagreement(target, sorted));\n late.push(target);\n }\n }\n if (late.length > 0) continue;\n const usable = new Map<string, DerivedMagnitude>();\n const refusals: DerivedMagnitudeRefusal[] = [...disagreeing.values(), ...unmeasured.values()];\n for (const [name, f] of derived) {\n const sigma = f.sigmaDecades!;\n if (sigma > maxSigmaDecades + SIGMA_GUARD_SLACK) {\n refusals.push({\n name,\n reason: 'imprecise',\n edges: [f.edge],\n sigmaDecades: sigma,\n detail:\n `${f.edge} gives ${name} from ${f.inputs.join(', ')} at σ = ${formatQuantity(sigma, 3)} decades, ` +\n `above the ${maxSigmaDecades}-decade precision the gate requires`,\n });\n continue;\n }\n usable.set(name, { value: f.value * conventionScaleToSI(name), sigmaDecades: sigma, edge: f.edge, inputs: f.inputs });\n }\n refusals.sort(byKey((r) => r.name));\n return { values: usable, refusals };\n }\n}\n\n/** The refusal record of two or more edges that value one quantity differently. */\nfunction disagreement(name: string, sorted: readonly Firing[]): DerivedMagnitudeRefusal {\n return {\n name,\n reason: 'disagreeing-edges',\n edges: sorted.map((f) => f.edge),\n detail:\n `${sorted.map((f) => `${f.edge} gives ${formatQuantity(f.value, 4)}`).join(', ')}: ` +\n `they differ by more than a relative ${DERIVED_AGREEMENT}, so no edge is taken`,\n };\n}\n"]}
|
|
@@ -7,17 +7,20 @@
|
|
|
7
7
|
* @internal
|
|
8
8
|
*/
|
|
9
9
|
import type { ExprNode } from '../../dimensional/ast-types.js';
|
|
10
|
+
/** One request line that the search sends to an expression-search backend worker. */
|
|
10
11
|
export interface BackendRequest {
|
|
11
12
|
readonly problemId: string;
|
|
12
13
|
readonly budgetMs: number;
|
|
13
14
|
readonly variables: readonly string[];
|
|
14
15
|
readonly target: string;
|
|
15
16
|
}
|
|
17
|
+
/** One candidate expression that an expression-search backend worker returns. */
|
|
16
18
|
export interface BackendCandidate {
|
|
17
19
|
readonly expression: ExprNode;
|
|
18
20
|
readonly prefactor?: number;
|
|
19
21
|
readonly note?: string;
|
|
20
22
|
}
|
|
23
|
+
/** The parsed reply of a backend worker: its candidates, or an error. */
|
|
21
24
|
export interface BackendResponse {
|
|
22
25
|
readonly ok: boolean;
|
|
23
26
|
readonly candidates: readonly BackendCandidate[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backend-protocol.d.ts","sourceRoot":"","sources":["../../../src/composition/probe/backend-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAE/D,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,UAAU,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACjD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CAC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AAU,GAAuB,EAAE,CAAC;IAC1C,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QACvC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC;YAAE,SAAS;QACvC,MAAM,CAAC,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;QAC1B,IAAI,CAAC,CAAC,EAAE,CAAC;YACP,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,KAAK,EAAE,0BAA0B,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC;QAC9F,CAAC;QACD,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;AAClC,CAAC","sourcesContent":["/**\n * Optional NDJSON worker protocol for expression-search backends.\n *\n * Spawn with an **argv array** (no shell). Timeout + kill. Schema-validate\n * output. **No vendored Python** — CI uses `tests/fixtures/discovery-workers/echo-worker.mjs`.\n *\n * @internal\n */\n\nimport { spawn } from 'node:child_process';\nimport type { ExprNode } from '../../dimensional/ast-types.js';\n\n/** One request line that the search sends to an expression-search backend worker. */\nexport interface BackendRequest {\n readonly problemId: string;\n readonly budgetMs: number;\n readonly variables: readonly string[];\n readonly target: string;\n}\n\n/** One candidate expression that an expression-search backend worker returns. */\nexport interface BackendCandidate {\n readonly expression: ExprNode;\n readonly prefactor?: number;\n readonly note?: string;\n}\n\n/** The parsed reply of a backend worker: its candidates, or an error. */\nexport interface BackendResponse {\n readonly ok: boolean;\n readonly candidates: readonly BackendCandidate[];\n readonly error?: string;\n}\n\nfunction isExprNode(value: unknown): value is ExprNode {\n if (!value || typeof value !== 'object') return false;\n const kind = (value as { kind?: unknown }).kind;\n return typeof kind === 'string' && kind.length > 0;\n}\n\nfunction parseLine(line: string): BackendCandidate | null {\n let parsed: unknown;\n try {\n parsed = JSON.parse(line);\n } catch {\n return null;\n }\n if (!parsed || typeof parsed !== 'object') return null;\n const obj = parsed as { expression?: unknown; prefactor?: unknown; note?: unknown };\n if (!isExprNode(obj.expression)) return null;\n const prefactor =\n typeof obj.prefactor === 'number' && Number.isFinite(obj.prefactor) ? obj.prefactor : undefined;\n const note = typeof obj.note === 'string' ? obj.note : undefined;\n return { expression: obj.expression, prefactor, note };\n}\n\n/**\n * The part of a launched worker process that {@link runBackendWorker} uses. A `node:child_process`\n * `ChildProcess` satisfies it; the interface keeps Node types out of this module's declarations.\n * @internal\n */\nexport interface WorkerProcess {\n readonly stdin: { write(chunk: string): unknown; end(): unknown } | null;\n readonly stdout: { on(event: 'data', listener: (chunk: Uint8Array) => void): unknown } | null;\n readonly stderr: { on(event: 'data', listener: (chunk: Uint8Array) => void): unknown } | null;\n on(event: 'error', listener: (err: Error) => void): unknown;\n on(event: 'close', listener: (code: number | null, signal: string | null) => void): unknown;\n kill(signal: 'SIGKILL'): unknown;\n}\n\n/** Launches a worker process. The default is `node:child_process` `spawn`. @internal */\nexport type WorkerLauncher = (\n command: string,\n args: readonly string[],\n options: { cwd?: string; stdio: ['pipe', 'pipe', 'pipe']; windowsHide: boolean },\n) => WorkerProcess;\n\n/**\n * Run an untrusted NDJSON worker. Never uses a shell.\n *\n * The timeout starts when the launcher returns, so it includes the worker's own start-up time.\n * `opts.spawn` replaces the process launcher; tests use it to drive the exit paths without a real\n * process. @internal\n */\nexport async function runBackendWorker(\n argv: readonly string[],\n request: BackendRequest,\n opts: { timeoutMs?: number; cwd?: string; spawn?: WorkerLauncher } = {},\n): Promise<BackendResponse> {\n if (argv.length === 0) {\n return { ok: false, candidates: [], error: 'empty argv' };\n }\n const timeoutMs = opts.timeoutMs ?? request.budgetMs;\n const launch: WorkerLauncher = opts.spawn ?? spawn;\n const child = launch(argv[0]!, argv.slice(1), {\n cwd: opts.cwd,\n stdio: ['pipe', 'pipe', 'pipe'],\n windowsHide: true,\n });\n\n const chunks: Uint8Array[] = [];\n const errChunks: Uint8Array[] = [];\n child.stdout?.on('data', (d) => chunks.push(d));\n child.stderr?.on('data', (d) => errChunks.push(d));\n\n const killer = setTimeout(() => {\n child.kill('SIGKILL');\n }, timeoutMs);\n\n const stdinPayload = `${JSON.stringify(request)}\\n`;\n child.stdin?.write(stdinPayload);\n child.stdin?.end();\n\n const exit = await new Promise<{ code: number | null; signal: string | null; spawnError?: string }>((resolve) => {\n child.on('error', (err) => resolve({ code: 1, signal: null, spawnError: err.message }));\n child.on('close', (code, signal) => resolve({ code, signal }));\n });\n clearTimeout(killer);\n\n if (exit.signal === 'SIGKILL') {\n return { ok: false, candidates: [], error: `worker timed out after ${timeoutMs}ms` };\n }\n if (exit.code !== 0) {\n const err = exit.spawnError ?? Buffer.concat(errChunks).toString('utf8').trim();\n return {\n ok: false,\n candidates: [],\n error: err || `worker exited ${exit.code}`,\n };\n }\n\n const text = Buffer.concat(chunks).toString('utf8');\n const candidates: BackendCandidate[] = [];\n for (const line of text.split(/\\r?\\n/)) {\n if (line.trim().length === 0) continue;\n const c = parseLine(line);\n if (!c) {\n return { ok: false, candidates: [], error: `malformed NDJSON line: ${line.slice(0, 200)}` };\n }\n candidates.push(c);\n }\n return { ok: true, candidates };\n}\n"]}
|
|
@@ -16,6 +16,7 @@ export declare function canTransition(from: ProbeCandidateStatus | 'none', to: P
|
|
|
16
16
|
export declare function applyStatus(record: ProbeCandidateRecord, to: ProbeCandidateStatus, reason: string, runId: string, at?: string): ProbeCandidateRecord;
|
|
17
17
|
/** Pipeline order index; terminals sort last. @internal */
|
|
18
18
|
export declare function statusRank(s: ProbeCandidateStatus): number;
|
|
19
|
+
/** The in-memory store of probe candidate records and their rejections. */
|
|
19
20
|
export declare class ProbeCandidateStore {
|
|
20
21
|
private readonly byId;
|
|
21
22
|
private readonly rejections;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"candidate-store.d.ts","sourceRoot":"","sources":["../../../src/composition/probe/candidate-store.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EAErB,MAAM,YAAY,CAAC;AAgDpB,+DAA+D;AAC/D,wBAAgB,aAAa,CAC3B,IAAI,EAAE,oBAAoB,GAAG,MAAM,EACnC,EAAE,EAAE,oBAAoB,GACvB,OAAO,CAET;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,oBAAoB,EAC5B,EAAE,EAAE,oBAAoB,EACxB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,EAAE,SAA2B,GAC5B,oBAAoB,CAgBtB;AAED,2DAA2D;AAC3D,wBAAgB,UAAU,CAAC,CAAC,EAAE,oBAAoB,GAAG,MAAM,CAG1D;AAED,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA2C;IAChE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA8B;IAEzD,yEAAyE;IACzE,GAAG,CAAC,MAAM,EAAE,oBAAoB,GAAG,IAAI,CAKtC;IAED,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,oBAAoB,GAAG,SAAS,CAEhD;IAED,6CAA6C;IAC7C,OAAO,CAAC,MAAM,EAAE,oBAAoB,GAAG,IAAI,CAE1C;IAED,GAAG,IAAI,SAAS,oBAAoB,EAAE,CAErC;IAED,iBAAiB,CAAC,GAAG,EAAE,oBAAoB,GAAG,IAAI,CAEjD;IAED,sFAAsF;IACtF,UAAU,CAAC,gBAAgB,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAI7D;IAED,aAAa,IAAI,SAAS,oBAAoB,EAAE,CAE/C;CACF"}
|
|
1
|
+
{"version":3,"file":"candidate-store.d.ts","sourceRoot":"","sources":["../../../src/composition/probe/candidate-store.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EAErB,MAAM,YAAY,CAAC;AAgDpB,+DAA+D;AAC/D,wBAAgB,aAAa,CAC3B,IAAI,EAAE,oBAAoB,GAAG,MAAM,EACnC,EAAE,EAAE,oBAAoB,GACvB,OAAO,CAET;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,oBAAoB,EAC5B,EAAE,EAAE,oBAAoB,EACxB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,EAAE,SAA2B,GAC5B,oBAAoB,CAgBtB;AAED,2DAA2D;AAC3D,wBAAgB,UAAU,CAAC,CAAC,EAAE,oBAAoB,GAAG,MAAM,CAG1D;AAED,2EAA2E;AAC3E,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA2C;IAChE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA8B;IAEzD,yEAAyE;IACzE,GAAG,CAAC,MAAM,EAAE,oBAAoB,GAAG,IAAI,CAKtC;IAED,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,oBAAoB,GAAG,SAAS,CAEhD;IAED,6CAA6C;IAC7C,OAAO,CAAC,MAAM,EAAE,oBAAoB,GAAG,IAAI,CAE1C;IAED,GAAG,IAAI,SAAS,oBAAoB,EAAE,CAErC;IAED,iBAAiB,CAAC,GAAG,EAAE,oBAAoB,GAAG,IAAI,CAEjD;IAED,sFAAsF;IACtF,UAAU,CAAC,gBAAgB,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAI7D;IAED,aAAa,IAAI,SAAS,oBAAoB,EAAE,CAE/C;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"candidate-store.js","sourceRoot":"","sources":["../../../src/composition/probe/candidate-store.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,MAAM,KAAK,GAAoC;IAC7C,WAAW;IACX,oBAAoB;IACpB,iBAAiB;IACjB,mBAAmB;IACnB,wBA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E,MAAM,CAAC,CAAC;IACnC,CAAC;IAED,GAAG,CAAC,EAAU;QACZ,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC3B,CAAC;IAED,6CAA6C;IAC7C,OAAO,CAAC,MAA4B;QAClC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IACnC,CAAC;IAED,GAAG;QACD,OAAO,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IACjC,CAAC;IAED,iBAAiB,CAAC,GAAyB;QACzC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;IAED,sFAAsF;IACtF,UAAU,CAAC,gBAAwB,EAAE,OAAe;QAClD,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CACzB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,gBAAgB,KAAK,gBAAgB,IAAI,CAAC,CAAC,OAAO,KAAK,OAAO,CACpF,CAAC;IACJ,CAAC;IAED,aAAa;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;CACF","sourcesContent":["/**\n * Append-only Product B candidate store + rejection registry.\n * Product A adjudications stay in `adjudication.ts`.\n *\n * @module composition/probe/candidate-store\n */\n\nimport type {\n ProbeCandidateRecord,\n ProbeCandidateStatus,\n ProbeRejectionRecord,\n StatusEvent,\n} from './types.js';\n\nconst ORDER: readonly ProbeCandidateStatus[] = [\n 'generated',\n 'structurally-valid',\n 'empirically-fit',\n 'heldout-supported',\n 'falsification-survivor',\n 'expert-review-required',\n];\n\nconst TERMINAL: ReadonlySet<ProbeCandidateStatus> = new Set([\n 'rejected',\n 'falsified',\n 'equivalent-known',\n 'insufficient-evidence',\n 'expert-review-required',\n]);\n\nconst ALLOWED: ReadonlyMap<ProbeCandidateStatus | 'none', ReadonlySet<ProbeCandidateStatus>> =\n new Map([\n ['none', new Set<ProbeCandidateStatus>(['generated'])],\n ['generated', new Set<ProbeCandidateStatus>(['structurally-valid', 'rejected'])],\n [\n 'structurally-valid',\n new Set<ProbeCandidateStatus>([\n 'empirically-fit',\n 'equivalent-known',\n 'insufficient-evidence',\n 'rejected',\n ]),\n ],\n [\n 'empirically-fit',\n new Set<ProbeCandidateStatus>(['heldout-supported', 'insufficient-evidence', 'rejected']),\n ],\n [\n 'heldout-supported',\n new Set<ProbeCandidateStatus>([\n 'falsification-survivor',\n 'falsified',\n 'rejected',\n 'equivalent-known',\n ]),\n ],\n ['falsification-survivor', new Set<ProbeCandidateStatus>(['expert-review-required'])],\n ]);\n\n/** True when `to` is a legal successor of `from`. @internal */\nexport function canTransition(\n from: ProbeCandidateStatus | 'none',\n to: ProbeCandidateStatus,\n): boolean {\n return ALLOWED.get(from)?.has(to) === true;\n}\n\n/**\n * Append a status event. Throws if the transition skips a required gate.\n * Current `status` is always the last event's `to`.\n *\n * @internal\n */\nexport function applyStatus(\n record: ProbeCandidateRecord,\n to: ProbeCandidateStatus,\n reason: string,\n runId: string,\n at = new Date().toISOString(),\n): ProbeCandidateRecord {\n const from = record.statusHistory.length === 0 ? 'none' : record.status;\n if (TERMINAL.has(record.status) && record.status !== 'falsification-survivor') {\n throw new RangeError(\n `applyStatus: terminal status '${record.status}' cannot transition to '${to}'`,\n );\n }\n if (!canTransition(from, to)) {\n throw new RangeError(`applyStatus: illegal transition ${String(from)} → ${to}`);\n }\n const event: StatusEvent = { at, from, to, reason, runId };\n return {\n ...record,\n status: to,\n statusHistory: [...record.statusHistory, event],\n };\n}\n\n/** Pipeline order index; terminals sort last. @internal */\nexport function statusRank(s: ProbeCandidateStatus): number {\n const i = ORDER.indexOf(s);\n return i >= 0 ? i : -1;\n}\n\nexport class ProbeCandidateStore {\n private readonly byId = new Map<string, ProbeCandidateRecord>();\n private readonly rejections: ProbeRejectionRecord[] = [];\n\n /** Insert a freshly generated record (must be `generated`). @internal */\n put(record: ProbeCandidateRecord): void {\n if (this.byId.has(record.id)) {\n throw new RangeError(`ProbeCandidateStore: duplicate id '${record.id}'`);\n }\n this.byId.set(record.id, record);\n }\n\n get(id: string): ProbeCandidateRecord | undefined {\n return this.byId.get(id);\n }\n\n /** Replace after `applyStatus`. @internal */\n replace(record: ProbeCandidateRecord): void {\n this.byId.set(record.id, record);\n }\n\n all(): readonly ProbeCandidateRecord[] {\n return [...this.byId.values()];\n }\n\n rememberRejection(rec: ProbeRejectionRecord): void {\n this.rejections.push(rec);\n }\n\n /** True when an equivalent fingerprint was rejected in the same context. @internal */\n isRejected(canonicalAstHash: string, context: string): boolean {\n return this.rejections.some(\n (r) => r.fingerprint.canonicalAstHash === canonicalAstHash && r.context === context,\n );\n }\n\n rejectionList(): readonly ProbeRejectionRecord[] {\n return this.rejections;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"candidate-store.js","sourceRoot":"","sources":["../../../src/composition/probe/candidate-store.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,MAAM,KAAK,GAAoC;IAC7C,WAAW;IACX,oBAAoB;IACpB,iBAAiB;IACjB,mBAAmB;IACnB,wBAAwB;IACxB,wBAAwB;CACzB,CAAC;AAEF,MAAM,QAAQ,GAAsC,IAAI,GAAG,CAAC;IAC1D,UAAU;IACV,WAAW;IACX,kBAAkB;IAClB,uBAAuB;IACvB,wBAAwB;CACzB,CAAC,CAAC;AAEH,MAAM,OAAO,GACX,IAAI,GAAG,CAAC;IACN,CAAC,MAAM,EAAE,IAAI,GAAG,CAAuB,CAAC,WAAW,CAAC,CAAC,CAAC;IACtD,CAAC,WAAW,EAAE,IAAI,GAAG,CAAuB,CAAC,oBAAoB,EAAE,UAAU,CAAC,CAAC,CAAC;IAChF;QACE,oBAAoB;QACpB,IAAI,GAAG,CAAuB;YAC5B,iBAAiB;YACjB,kBAAkB;YAClB,uBAAuB;YACvB,UAAU;SACX,CAAC;KACH;IACD;QACE,iBAAiB;QACjB,IAAI,GA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,gBAAwB,EAAE,OAAe;QAClD,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CACzB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,gBAAgB,KAAK,gBAAgB,IAAI,CAAC,CAAC,OAAO,KAAK,OAAO,CACpF,CAAC;IACJ,CAAC;IAED,aAAa;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;CACF","sourcesContent":["/**\n * Append-only Product B candidate store + rejection registry.\n * Product A adjudications stay in `adjudication.ts`.\n *\n * @module composition/probe/candidate-store\n */\n\nimport type {\n ProbeCandidateRecord,\n ProbeCandidateStatus,\n ProbeRejectionRecord,\n StatusEvent,\n} from './types.js';\n\nconst ORDER: readonly ProbeCandidateStatus[] = [\n 'generated',\n 'structurally-valid',\n 'empirically-fit',\n 'heldout-supported',\n 'falsification-survivor',\n 'expert-review-required',\n];\n\nconst TERMINAL: ReadonlySet<ProbeCandidateStatus> = new Set([\n 'rejected',\n 'falsified',\n 'equivalent-known',\n 'insufficient-evidence',\n 'expert-review-required',\n]);\n\nconst ALLOWED: ReadonlyMap<ProbeCandidateStatus | 'none', ReadonlySet<ProbeCandidateStatus>> =\n new Map([\n ['none', new Set<ProbeCandidateStatus>(['generated'])],\n ['generated', new Set<ProbeCandidateStatus>(['structurally-valid', 'rejected'])],\n [\n 'structurally-valid',\n new Set<ProbeCandidateStatus>([\n 'empirically-fit',\n 'equivalent-known',\n 'insufficient-evidence',\n 'rejected',\n ]),\n ],\n [\n 'empirically-fit',\n new Set<ProbeCandidateStatus>(['heldout-supported', 'insufficient-evidence', 'rejected']),\n ],\n [\n 'heldout-supported',\n new Set<ProbeCandidateStatus>([\n 'falsification-survivor',\n 'falsified',\n 'rejected',\n 'equivalent-known',\n ]),\n ],\n ['falsification-survivor', new Set<ProbeCandidateStatus>(['expert-review-required'])],\n ]);\n\n/** True when `to` is a legal successor of `from`. @internal */\nexport function canTransition(\n from: ProbeCandidateStatus | 'none',\n to: ProbeCandidateStatus,\n): boolean {\n return ALLOWED.get(from)?.has(to) === true;\n}\n\n/**\n * Append a status event. Throws if the transition skips a required gate.\n * Current `status` is always the last event's `to`.\n *\n * @internal\n */\nexport function applyStatus(\n record: ProbeCandidateRecord,\n to: ProbeCandidateStatus,\n reason: string,\n runId: string,\n at = new Date().toISOString(),\n): ProbeCandidateRecord {\n const from = record.statusHistory.length === 0 ? 'none' : record.status;\n if (TERMINAL.has(record.status) && record.status !== 'falsification-survivor') {\n throw new RangeError(\n `applyStatus: terminal status '${record.status}' cannot transition to '${to}'`,\n );\n }\n if (!canTransition(from, to)) {\n throw new RangeError(`applyStatus: illegal transition ${String(from)} → ${to}`);\n }\n const event: StatusEvent = { at, from, to, reason, runId };\n return {\n ...record,\n status: to,\n statusHistory: [...record.statusHistory, event],\n };\n}\n\n/** Pipeline order index; terminals sort last. @internal */\nexport function statusRank(s: ProbeCandidateStatus): number {\n const i = ORDER.indexOf(s);\n return i >= 0 ? i : -1;\n}\n\n/** The in-memory store of probe candidate records and their rejections. */\nexport class ProbeCandidateStore {\n private readonly byId = new Map<string, ProbeCandidateRecord>();\n private readonly rejections: ProbeRejectionRecord[] = [];\n\n /** Insert a freshly generated record (must be `generated`). @internal */\n put(record: ProbeCandidateRecord): void {\n if (this.byId.has(record.id)) {\n throw new RangeError(`ProbeCandidateStore: duplicate id '${record.id}'`);\n }\n this.byId.set(record.id, record);\n }\n\n get(id: string): ProbeCandidateRecord | undefined {\n return this.byId.get(id);\n }\n\n /** Replace after `applyStatus`. @internal */\n replace(record: ProbeCandidateRecord): void {\n this.byId.set(record.id, record);\n }\n\n all(): readonly ProbeCandidateRecord[] {\n return [...this.byId.values()];\n }\n\n rememberRejection(rec: ProbeRejectionRecord): void {\n this.rejections.push(rec);\n }\n\n /** True when an equivalent fingerprint was rejected in the same context. @internal */\n isRejected(canonicalAstHash: string, context: string): boolean {\n return this.rejections.some(\n (r) => r.fingerprint.canonicalAstHash === canonicalAstHash && r.context === context,\n );\n }\n\n rejectionList(): readonly ProbeRejectionRecord[] {\n return this.rejections;\n }\n}\n"]}
|
|
@@ -5,10 +5,12 @@
|
|
|
5
5
|
* @module composition/probe/corpus
|
|
6
6
|
*/
|
|
7
7
|
import type { ExprNode } from '../../dimensional/ast-types.js';
|
|
8
|
+
/** One corpus entry that matches an expression, with the layer that holds it. */
|
|
8
9
|
export interface CorpusMatch {
|
|
9
10
|
readonly id: string;
|
|
10
11
|
readonly layer: 'canonical' | 'bridge';
|
|
11
12
|
}
|
|
13
|
+
/** The result of comparing one expression with the in-repo corpus. */
|
|
12
14
|
export interface CorpusComparisonResult {
|
|
13
15
|
readonly corpusId: string;
|
|
14
16
|
readonly corpusVersion: string;
|
|
@@ -16,8 +18,8 @@ export interface CorpusComparisonResult {
|
|
|
16
18
|
readonly algebraicMatches: readonly CorpusMatch[];
|
|
17
19
|
readonly searchedAt: string;
|
|
18
20
|
}
|
|
19
|
-
/** Compare an expression to the in-repo L- and B-layers. @internal */
|
|
20
|
-
export declare function compareToCorpus(expr: ExprNode, corpusVersion: string): CorpusComparisonResult;
|
|
21
|
+
/** Compare an expression to the in-repo L- and B-layers. `searchedAt` is the run's pinned time; default now. @internal */
|
|
22
|
+
export declare function compareToCorpus(expr: ExprNode, corpusVersion: string, searchedAt?: string): CorpusComparisonResult;
|
|
21
23
|
/**
|
|
22
24
|
* Compare a FITTED prefactor with the prefactor of each corpus relation the
|
|
23
25
|
* candidate is algebraically equivalent to. `normalForm` matches up to a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"corpus.d.ts","sourceRoot":"","sources":["../../../src/composition/probe/corpus.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAW/D,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,QAAQ,CAAC;CAC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E,CA0CV;AAED,oDAAoD;AACpD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,sBAAsB,GAAG,MAAM,CAM5E"}
|
|
@@ -13,8 +13,8 @@ import { equals } from '../../dimensional/algebra.js';
|
|
|
13
13
|
import { canonicalPrefactor } from '../canonical-prefactors.js';
|
|
14
14
|
import { constantRatio, fixedPoint } from '../../canonical/fixed-points.js';
|
|
15
15
|
const CORPUS_ID = 'upt-l-layer+b-layer';
|
|
16
|
-
/** Compare an expression to the in-repo L- and B-layers. @internal */
|
|
17
|
-
export function compareToCorpus(expr, corpusVersion) {
|
|
16
|
+
/** Compare an expression to the in-repo L- and B-layers. `searchedAt` is the run's pinned time; default now. @internal */
|
|
17
|
+
export function compareToCorpus(expr, corpusVersion, searchedAt = new Date().toISOString()) {
|
|
18
18
|
const form = normalForm(expr);
|
|
19
19
|
const algebraic = [];
|
|
20
20
|
for (const ce of CANONICAL_EQUATIONS) {
|
|
@@ -41,7 +41,7 @@ export function compareToCorpus(expr, corpusVersion) {
|
|
|
41
41
|
corpusVersion,
|
|
42
42
|
exactMatches: [],
|
|
43
43
|
algebraicMatches: algebraic,
|
|
44
|
-
searchedAt
|
|
44
|
+
searchedAt,
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
/**
|