universal-physics-tensor 10.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 +39 -36
- package/bin/upt.mjs +13 -1
- package/data/applied-cases.json +1892 -0
- package/data/applied-cases.schema.json +194 -0
- package/data/atlas/atlas.json +25 -25
- package/data/atlas/atlas.jsonld +1 -1
- package/data/atlas/diffusion.json +6 -6
- package/data/atlas/oscillators.json +7 -7
- package/data/atlas/waves.json +14 -14
- package/data/atlas/witness-results.json +11 -11
- package/data/bridge-catalog.json +389 -230
- package/data/bridge-catalog.schema.json +45 -7
- package/data/units.json +6 -25
- package/dist/atlas/applicability.d.ts.map +1 -1
- package/dist/atlas/applicability.js +21 -15
- package/dist/atlas/applicability.js.map +1 -1
- package/dist/atlas/benchmark/hybrid-retrieval.d.ts +9 -1
- package/dist/atlas/benchmark/hybrid-retrieval.d.ts.map +1 -1
- package/dist/atlas/benchmark/hybrid-retrieval.js +15 -13
- package/dist/atlas/benchmark/hybrid-retrieval.js.map +1 -1
- package/dist/atlas/benchmark/loader.js +2 -2
- package/dist/atlas/benchmark/loader.js.map +1 -1
- package/dist/atlas/benchmark/stats.d.ts +2 -2
- package/dist/atlas/benchmark/stats.d.ts.map +1 -1
- package/dist/atlas/benchmark/stats.js +9 -15
- package/dist/atlas/benchmark/stats.js.map +1 -1
- package/dist/atlas/catalog-formal-ref.d.ts +26 -3
- package/dist/atlas/catalog-formal-ref.d.ts.map +1 -1
- package/dist/atlas/catalog-formal-ref.js +52 -5
- package/dist/atlas/catalog-formal-ref.js.map +1 -1
- package/dist/atlas/chain-pipeline.d.ts.map +1 -1
- package/dist/atlas/chain-pipeline.js +7 -8
- package/dist/atlas/chain-pipeline.js.map +1 -1
- package/dist/atlas/diffusion/bridges-closure.d.ts +0 -4
- package/dist/atlas/diffusion/bridges-closure.d.ts.map +1 -1
- package/dist/atlas/diffusion/bridges-closure.js +8 -12
- package/dist/atlas/diffusion/bridges-closure.js.map +1 -1
- package/dist/atlas/diffusion/bridges.d.ts.map +1 -1
- package/dist/atlas/diffusion/bridges.js +27 -39
- package/dist/atlas/diffusion/bridges.js.map +1 -1
- package/dist/atlas/diffusion/dimensions.d.ts +6 -14
- package/dist/atlas/diffusion/dimensions.d.ts.map +1 -1
- package/dist/atlas/diffusion/dimensions.js +8 -16
- package/dist/atlas/diffusion/dimensions.js.map +1 -1
- package/dist/atlas/diffusion/models.d.ts +3 -3
- package/dist/atlas/diffusion/models.d.ts.map +1 -1
- package/dist/atlas/diffusion/models.js +5 -10
- package/dist/atlas/diffusion/models.js.map +1 -1
- package/dist/atlas/diffusion/numerics.d.ts +16 -4
- package/dist/atlas/diffusion/numerics.d.ts.map +1 -1
- package/dist/atlas/diffusion/numerics.js +38 -24
- package/dist/atlas/diffusion/numerics.js.map +1 -1
- package/dist/atlas/link-prediction.d.ts +106 -3
- package/dist/atlas/link-prediction.d.ts.map +1 -1
- package/dist/atlas/link-prediction.js +212 -66
- package/dist/atlas/link-prediction.js.map +1 -1
- package/dist/atlas/oscillators/bridges-coarse.d.ts.map +1 -1
- package/dist/atlas/oscillators/bridges-coarse.js +7 -11
- package/dist/atlas/oscillators/bridges-coarse.js.map +1 -1
- package/dist/atlas/oscillators/bridges-exact.d.ts.map +1 -1
- package/dist/atlas/oscillators/bridges-exact.js +6 -7
- package/dist/atlas/oscillators/bridges-exact.js.map +1 -1
- package/dist/atlas/oscillators/bridges-limits.d.ts +3 -16
- package/dist/atlas/oscillators/bridges-limits.d.ts.map +1 -1
- package/dist/atlas/oscillators/bridges-limits.js +23 -34
- package/dist/atlas/oscillators/bridges-limits.js.map +1 -1
- package/dist/atlas/oscillators/dimensions.d.ts +9 -21
- package/dist/atlas/oscillators/dimensions.d.ts.map +1 -1
- package/dist/atlas/oscillators/dimensions.js +9 -21
- package/dist/atlas/oscillators/dimensions.js.map +1 -1
- package/dist/atlas/oscillators/limit-witnesses.d.ts +2 -2
- package/dist/atlas/oscillators/limit-witnesses.d.ts.map +1 -1
- package/dist/atlas/oscillators/limit-witnesses.js +17 -15
- package/dist/atlas/oscillators/limit-witnesses.js.map +1 -1
- package/dist/atlas/oscillators/models.d.ts.map +1 -1
- package/dist/atlas/oscillators/models.js +2 -6
- package/dist/atlas/oscillators/models.js.map +1 -1
- package/dist/atlas/oscillators/pendulum-motion.d.ts +29 -6
- package/dist/atlas/oscillators/pendulum-motion.d.ts.map +1 -1
- package/dist/atlas/oscillators/pendulum-motion.js +60 -40
- package/dist/atlas/oscillators/pendulum-motion.js.map +1 -1
- package/dist/atlas/oscillators/phase-translation.d.ts +0 -11
- package/dist/atlas/oscillators/phase-translation.d.ts.map +1 -1
- package/dist/atlas/oscillators/phase-translation.js +3 -4
- package/dist/atlas/oscillators/phase-translation.js.map +1 -1
- package/dist/atlas/oscillators/position-translation.d.ts +68 -7
- package/dist/atlas/oscillators/position-translation.d.ts.map +1 -1
- package/dist/atlas/oscillators/position-translation.js +123 -12
- package/dist/atlas/oscillators/position-translation.js.map +1 -1
- package/dist/atlas/oscillators/rejections.d.ts +0 -2
- package/dist/atlas/oscillators/rejections.d.ts.map +1 -1
- package/dist/atlas/oscillators/rejections.js +0 -7
- package/dist/atlas/oscillators/rejections.js.map +1 -1
- package/dist/atlas/physjs-entries.generated.d.ts +35 -25
- package/dist/atlas/physjs-entries.generated.d.ts.map +1 -1
- package/dist/atlas/physjs-entries.generated.js +37 -25
- package/dist/atlas/physjs-entries.generated.js.map +1 -1
- package/dist/atlas/physjs-ref.d.ts +34 -31
- package/dist/atlas/physjs-ref.d.ts.map +1 -1
- package/dist/atlas/physjs-ref.js +55 -53
- package/dist/atlas/physjs-ref.js.map +1 -1
- package/dist/atlas/physjs-reviewed.d.ts +1 -1
- package/dist/atlas/physjs-reviewed.js +15 -15
- package/dist/atlas/physjs-reviewed.js.map +1 -1
- package/dist/atlas/poster/statements.d.ts +0 -19
- package/dist/atlas/poster/statements.d.ts.map +1 -1
- package/dist/atlas/poster/statements.js +1 -1
- package/dist/atlas/poster/statements.js.map +1 -1
- package/dist/atlas/proof-target.d.ts +1 -1
- package/dist/atlas/proof-target.js +1 -1
- package/dist/atlas/proof-target.js.map +1 -1
- package/dist/atlas/regime.d.ts +1 -1
- package/dist/atlas/regime.d.ts.map +1 -1
- package/dist/atlas/regime.js +1 -1
- package/dist/atlas/regime.js.map +1 -1
- package/dist/atlas/text-overlap.d.ts +23 -0
- package/dist/atlas/text-overlap.d.ts.map +1 -0
- package/dist/atlas/text-overlap.js +41 -0
- package/dist/atlas/text-overlap.js.map +1 -0
- package/dist/atlas/waves/bridges-closure.d.ts.map +1 -1
- package/dist/atlas/waves/bridges-closure.js +2 -6
- package/dist/atlas/waves/bridges-closure.js.map +1 -1
- package/dist/atlas/waves/bridges.d.ts.map +1 -1
- package/dist/atlas/waves/bridges.js +32 -48
- package/dist/atlas/waves/bridges.js.map +1 -1
- package/dist/atlas/waves/models.d.ts +5 -6
- package/dist/atlas/waves/models.d.ts.map +1 -1
- package/dist/atlas/waves/models.js +7 -13
- package/dist/atlas/waves/models.js.map +1 -1
- package/dist/atlas/waves/numerics.d.ts.map +1 -1
- package/dist/atlas/waves/numerics.js +10 -3
- package/dist/atlas/waves/numerics.js.map +1 -1
- package/dist/atlas/witness-numeric.d.ts +30 -0
- package/dist/atlas/witness-numeric.d.ts.map +1 -1
- package/dist/atlas/witness-numeric.js +53 -0
- package/dist/atlas/witness-numeric.js.map +1 -1
- package/dist/atlas/witness-specs.d.ts.map +1 -1
- package/dist/atlas/witness-specs.js +19 -0
- package/dist/atlas/witness-specs.js.map +1 -1
- package/dist/atlas/witness-symbolic.d.ts +75 -3
- package/dist/atlas/witness-symbolic.d.ts.map +1 -1
- package/dist/atlas/witness-symbolic.js +116 -10
- package/dist/atlas/witness-symbolic.js.map +1 -1
- package/dist/bridges/catalog-load.d.ts.map +1 -1
- package/dist/bridges/catalog-load.js +13 -8
- package/dist/bridges/catalog-load.js.map +1 -1
- package/dist/bridges/catalog-types.d.ts +26 -2
- package/dist/bridges/catalog-types.d.ts.map +1 -1
- package/dist/bridges/catalog-types.js +11 -1
- package/dist/bridges/catalog-types.js.map +1 -1
- package/dist/bridges/evaluation-errors.d.ts +31 -1
- package/dist/bridges/evaluation-errors.d.ts.map +1 -1
- package/dist/bridges/evaluation-errors.js +20 -2
- package/dist/bridges/evaluation-errors.js.map +1 -1
- package/dist/bridges/evaluator-inputs.d.ts.map +1 -1
- package/dist/bridges/evaluator-inputs.js +7 -5
- package/dist/bridges/evaluator-inputs.js.map +1 -1
- package/dist/bridges/evaluators.d.ts.map +1 -1
- package/dist/bridges/evaluators.js +27 -12
- package/dist/bridges/evaluators.js.map +1 -1
- package/dist/bridges/expr-parse.d.ts +11 -0
- package/dist/bridges/expr-parse.d.ts.map +1 -1
- package/dist/bridges/expr-parse.js +14 -5
- package/dist/bridges/expr-parse.js.map +1 -1
- package/dist/bridges/holds.d.ts +35 -3
- package/dist/bridges/holds.d.ts.map +1 -1
- package/dist/bridges/holds.js +117 -23
- package/dist/bridges/holds.js.map +1 -1
- package/dist/bridges/notices.d.ts.map +1 -1
- package/dist/bridges/notices.js +5 -5
- package/dist/bridges/notices.js.map +1 -1
- package/dist/bridges/relation-eval.d.ts +4 -4
- package/dist/bridges/relation-eval.d.ts.map +1 -1
- package/dist/bridges/relation-eval.js +15 -16
- package/dist/bridges/relation-eval.js.map +1 -1
- package/dist/bridges/sensitivity.d.ts.map +1 -1
- package/dist/bridges/sensitivity.js +3 -3
- package/dist/bridges/sensitivity.js.map +1 -1
- package/dist/bridges/validity.d.ts +33 -0
- package/dist/bridges/validity.d.ts.map +1 -0
- package/dist/bridges/validity.js +67 -0
- package/dist/bridges/validity.js.map +1 -0
- package/dist/canonical/entries/atomic.js +1 -3
- package/dist/canonical/entries/atomic.js.map +1 -1
- package/dist/canonical/entries/condensed-matter.d.ts.map +1 -1
- package/dist/canonical/entries/condensed-matter.js +4 -5
- package/dist/canonical/entries/condensed-matter.js.map +1 -1
- package/dist/canonical/entries/dimensional-classics.d.ts.map +1 -1
- package/dist/canonical/entries/dimensional-classics.js +3 -4
- package/dist/canonical/entries/dimensional-classics.js.map +1 -1
- package/dist/canonical/entries/electromagnetism.d.ts.map +1 -1
- package/dist/canonical/entries/electromagnetism.js +4 -10
- package/dist/canonical/entries/electromagnetism.js.map +1 -1
- package/dist/canonical/entries/fluids-waves.d.ts.map +1 -1
- package/dist/canonical/entries/fluids-waves.js +3 -7
- package/dist/canonical/entries/fluids-waves.js.map +1 -1
- package/dist/canonical/entries/mechanics.d.ts.map +1 -1
- package/dist/canonical/entries/mechanics.js +4 -6
- package/dist/canonical/entries/mechanics.js.map +1 -1
- package/dist/canonical/entries/nonmonomial.d.ts.map +1 -1
- package/dist/canonical/entries/nonmonomial.js +9 -17
- package/dist/canonical/entries/nonmonomial.js.map +1 -1
- package/dist/canonical/entries/relativity.d.ts.map +1 -1
- package/dist/canonical/entries/relativity.js +6 -6
- package/dist/canonical/entries/relativity.js.map +1 -1
- package/dist/canonical/entries/thermo-nuclear-cosmo.d.ts.map +1 -1
- package/dist/canonical/entries/thermo-nuclear-cosmo.js +6 -10
- package/dist/canonical/entries/thermo-nuclear-cosmo.js.map +1 -1
- package/dist/canonical/fixed-points.d.ts +94 -0
- package/dist/canonical/fixed-points.d.ts.map +1 -0
- package/dist/canonical/fixed-points.js +81 -0
- package/dist/canonical/fixed-points.js.map +1 -0
- package/dist/canonical/linkage.d.ts.map +1 -1
- package/dist/canonical/linkage.js +25 -44
- package/dist/canonical/linkage.js.map +1 -1
- package/dist/canonical/normal-form.d.ts.map +1 -1
- package/dist/canonical/normal-form.js +5 -11
- package/dist/canonical/normal-form.js.map +1 -1
- package/dist/canonical/structural.d.ts +21 -21
- package/dist/canonical/structural.d.ts.map +1 -1
- package/dist/canonical/structural.js +40 -19
- package/dist/canonical/structural.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/quadrature.d.ts +7 -9
- package/dist/cases/quadrature.d.ts.map +1 -1
- package/dist/cases/quadrature.js +28 -32
- package/dist/cases/quadrature.js.map +1 -1
- 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 +25 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +30 -8
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/bindings.d.ts.map +1 -1
- package/dist/cli/bindings.js +5 -4
- package/dist/cli/bindings.js.map +1 -1
- package/dist/cli/command.d.ts +11 -1
- package/dist/cli/command.d.ts.map +1 -1
- package/dist/cli/command.js.map +1 -1
- package/dist/cli/commands/_atlas-map.d.ts +0 -9
- package/dist/cli/commands/_atlas-map.d.ts.map +1 -1
- package/dist/cli/commands/_atlas-map.js +8 -18
- package/dist/cli/commands/_atlas-map.js.map +1 -1
- package/dist/cli/commands/_atlas-route.d.ts.map +1 -1
- package/dist/cli/commands/_atlas-route.js +6 -2
- package/dist/cli/commands/_atlas-route.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 +9 -9
- package/dist/cli/commands/_discovery-opts.js.map +1 -1
- package/dist/cli/commands/atlas.d.ts.map +1 -1
- package/dist/cli/commands/atlas.js +8 -5
- package/dist/cli/commands/atlas.js.map +1 -1
- package/dist/cli/commands/audit.d.ts.map +1 -1
- package/dist/cli/commands/audit.js +8 -1
- package/dist/cli/commands/audit.js.map +1 -1
- package/dist/cli/commands/axes.d.ts.map +1 -1
- package/dist/cli/commands/axes.js +20 -1
- package/dist/cli/commands/axes.js.map +1 -1
- package/dist/cli/commands/confront.d.ts.map +1 -1
- package/dist/cli/commands/confront.js +8 -14
- package/dist/cli/commands/confront.js.map +1 -1
- package/dist/cli/commands/derive.d.ts.map +1 -1
- package/dist/cli/commands/derive.js +22 -22
- package/dist/cli/commands/derive.js.map +1 -1
- package/dist/cli/commands/discover.d.ts.map +1 -1
- package/dist/cli/commands/discover.js +122 -73
- package/dist/cli/commands/discover.js.map +1 -1
- package/dist/cli/commands/eval.d.ts.map +1 -1
- package/dist/cli/commands/eval.js +1 -0
- package/dist/cli/commands/eval.js.map +1 -1
- package/dist/cli/commands/evaluate.d.ts.map +1 -1
- package/dist/cli/commands/evaluate.js +67 -39
- 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 +24 -3
- 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 +7 -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 +84 -11
- package/dist/cli/commands/map.js.map +1 -1
- package/dist/cli/commands/metric.d.ts.map +1 -1
- package/dist/cli/commands/metric.js +12 -9
- package/dist/cli/commands/metric.js.map +1 -1
- package/dist/cli/commands/path.d.ts +10 -0
- package/dist/cli/commands/path.d.ts.map +1 -1
- package/dist/cli/commands/path.js +25 -3
- package/dist/cli/commands/path.js.map +1 -1
- package/dist/cli/commands/probe.d.ts.map +1 -1
- package/dist/cli/commands/probe.js +59 -16
- package/dist/cli/commands/probe.js.map +1 -1
- package/dist/cli/commands/regime.d.ts.map +1 -1
- package/dist/cli/commands/regime.js +1 -0
- package/dist/cli/commands/regime.js.map +1 -1
- package/dist/cli/commands/retrieve.d.ts.map +1 -1
- package/dist/cli/commands/retrieve.js +1 -0
- package/dist/cli/commands/retrieve.js.map +1 -1
- package/dist/cli/commands/search.d.ts.map +1 -1
- package/dist/cli/commands/search.js +1 -0
- package/dist/cli/commands/search.js.map +1 -1
- package/dist/cli/commands/symbolic.d.ts.map +1 -1
- package/dist/cli/commands/symbolic.js +19 -28
- package/dist/cli/commands/symbolic.js.map +1 -1
- package/dist/cli/commands/testplan.d.ts.map +1 -1
- package/dist/cli/commands/testplan.js +4 -2
- package/dist/cli/commands/testplan.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/expr-print.d.ts +0 -2
- package/dist/cli/expr-print.d.ts.map +1 -1
- package/dist/cli/expr-print.js +7 -31
- package/dist/cli/expr-print.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 +8 -0
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +19 -3
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/numeric-flag.d.ts +12 -0
- package/dist/cli/numeric-flag.d.ts.map +1 -0
- package/dist/cli/numeric-flag.js +44 -0
- package/dist/cli/numeric-flag.js.map +1 -0
- package/dist/cli/output.d.ts +28 -0
- package/dist/cli/output.d.ts.map +1 -1
- package/dist/cli/output.js +23 -0
- package/dist/cli/output.js.map +1 -1
- package/dist/cli/record-reach.js +2 -2
- package/dist/cli/record-reach.js.map +1 -1
- package/dist/cli/record-tables.d.ts.map +1 -1
- package/dist/cli/record-tables.js +6 -5
- package/dist/cli/record-tables.js.map +1 -1
- package/dist/cli/record.d.ts +1 -5
- package/dist/cli/record.d.ts.map +1 -1
- package/dist/cli/record.js +9 -8
- package/dist/cli/record.js.map +1 -1
- package/dist/cli/search-index.d.ts.map +1 -1
- package/dist/cli/search-index.js +7 -6
- package/dist/cli/search-index.js.map +1 -1
- package/dist/cli/statuses.d.ts +0 -2
- package/dist/cli/statuses.d.ts.map +1 -1
- package/dist/cli/statuses.js +12 -9
- package/dist/cli/statuses.js.map +1 -1
- package/dist/cli/stored-results.d.ts +7 -0
- package/dist/cli/stored-results.d.ts.map +1 -0
- package/dist/cli/stored-results.js +23 -0
- package/dist/cli/stored-results.js.map +1 -0
- package/dist/cli/version.d.ts +1 -0
- package/dist/cli/version.d.ts.map +1 -1
- package/dist/cli/version.js +8 -5
- package/dist/cli/version.js.map +1 -1
- package/dist/cli-api.d.ts +36 -5
- package/dist/cli-api.d.ts.map +1 -1
- package/dist/cli-api.js +30 -4
- package/dist/cli-api.js.map +1 -1
- package/dist/composition/algebraic-equivalence.d.ts +43 -0
- package/dist/composition/algebraic-equivalence.d.ts.map +1 -0
- package/dist/composition/algebraic-equivalence.js +115 -0
- package/dist/composition/algebraic-equivalence.js.map +1 -0
- package/dist/composition/axes.d.ts +0 -6
- package/dist/composition/axes.d.ts.map +1 -1
- package/dist/composition/axes.js +6 -6
- package/dist/composition/axes.js.map +1 -1
- package/dist/composition/axis-audit.d.ts +47 -20
- package/dist/composition/axis-audit.d.ts.map +1 -1
- package/dist/composition/axis-audit.js +82 -9
- package/dist/composition/axis-audit.js.map +1 -1
- package/dist/composition/bridge-analysis.d.ts +17 -0
- package/dist/composition/bridge-analysis.d.ts.map +1 -1
- package/dist/composition/bridge-analysis.js +102 -55
- package/dist/composition/bridge-analysis.js.map +1 -1
- package/dist/composition/canonical-compare.d.ts +40 -0
- package/dist/composition/canonical-compare.d.ts.map +1 -1
- package/dist/composition/canonical-compare.js +122 -24
- package/dist/composition/canonical-compare.js.map +1 -1
- package/dist/composition/canonical-graph.d.ts +3 -3
- package/dist/composition/canonical-graph.d.ts.map +1 -1
- package/dist/composition/canonical-graph.js +11 -38
- package/dist/composition/canonical-graph.js.map +1 -1
- package/dist/composition/canonical-json.js +2 -2
- package/dist/composition/canonical-json.js.map +1 -1
- package/dist/composition/catalog-graph.d.ts.map +1 -1
- package/dist/composition/catalog-graph.js +2 -5
- package/dist/composition/catalog-graph.js.map +1 -1
- package/dist/composition/chain-candidate.d.ts +8 -0
- package/dist/composition/chain-candidate.d.ts.map +1 -1
- package/dist/composition/chain-candidate.js +9 -2
- package/dist/composition/chain-candidate.js.map +1 -1
- package/dist/composition/chain-match.d.ts +6 -3
- package/dist/composition/chain-match.d.ts.map +1 -1
- package/dist/composition/chain-match.js +4 -1
- package/dist/composition/chain-match.js.map +1 -1
- package/dist/composition/chain-result.d.ts.map +1 -1
- package/dist/composition/chain-result.js +2 -14
- package/dist/composition/chain-result.js.map +1 -1
- package/dist/composition/compose-symbolic.d.ts.map +1 -1
- package/dist/composition/compose-symbolic.js +3 -2
- package/dist/composition/compose-symbolic.js.map +1 -1
- package/dist/composition/compose.d.ts.map +1 -1
- package/dist/composition/compose.js +13 -5
- package/dist/composition/compose.js.map +1 -1
- package/dist/composition/composition-recovery.d.ts.map +1 -1
- package/dist/composition/composition-recovery.js +4 -7
- package/dist/composition/composition-recovery.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 +129 -9
- package/dist/composition/discovery.d.ts.map +1 -1
- package/dist/composition/discovery.js +171 -67
- package/dist/composition/discovery.js.map +1 -1
- package/dist/composition/edge.d.ts +21 -2
- package/dist/composition/edge.d.ts.map +1 -1
- package/dist/composition/edge.js +23 -1
- package/dist/composition/edge.js.map +1 -1
- package/dist/composition/enumerate.d.ts.map +1 -1
- package/dist/composition/enumerate.js +18 -3
- package/dist/composition/enumerate.js.map +1 -1
- package/dist/composition/evaluate-relation.d.ts +35 -11
- package/dist/composition/evaluate-relation.d.ts.map +1 -1
- package/dist/composition/evaluate-relation.js +60 -39
- package/dist/composition/evaluate-relation.js.map +1 -1
- package/dist/composition/explain.d.ts +3 -12
- package/dist/composition/explain.d.ts.map +1 -1
- package/dist/composition/explain.js +7 -20
- package/dist/composition/explain.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 +6 -15
- package/dist/composition/expr-eval.js.map +1 -1
- package/dist/composition/expr-simplify.d.ts +26 -14
- package/dist/composition/expr-simplify.d.ts.map +1 -1
- package/dist/composition/expr-simplify.js +64 -72
- package/dist/composition/expr-simplify.js.map +1 -1
- package/dist/composition/formula-shape.d.ts +23 -4
- package/dist/composition/formula-shape.d.ts.map +1 -1
- package/dist/composition/formula-shape.js +57 -17
- package/dist/composition/formula-shape.js.map +1 -1
- package/dist/composition/graph-structure.d.ts +98 -0
- package/dist/composition/graph-structure.d.ts.map +1 -0
- package/dist/composition/graph-structure.js +167 -0
- package/dist/composition/graph-structure.js.map +1 -0
- package/dist/composition/graph-viz-svg.d.ts.map +1 -1
- package/dist/composition/graph-viz-svg.js +1 -1
- package/dist/composition/graph-viz-svg.js.map +1 -1
- package/dist/composition/graph-viz.d.ts.map +1 -1
- package/dist/composition/graph-viz.js +8 -37
- package/dist/composition/graph-viz.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/identifiability.d.ts +91 -4
- package/dist/composition/identifiability.d.ts.map +1 -1
- package/dist/composition/identifiability.js +363 -6
- package/dist/composition/identifiability.js.map +1 -1
- package/dist/composition/index.d.ts +8 -4
- package/dist/composition/index.d.ts.map +1 -1
- package/dist/composition/index.js +3 -2
- package/dist/composition/index.js.map +1 -1
- package/dist/composition/mathts-quiet.d.ts +7 -8
- package/dist/composition/mathts-quiet.d.ts.map +1 -1
- package/dist/composition/mathts-quiet.js +7 -16
- package/dist/composition/mathts-quiet.js.map +1 -1
- package/dist/composition/mathts-scalar-symbols.d.ts.map +1 -1
- package/dist/composition/mathts-scalar-symbols.js +2 -1
- package/dist/composition/mathts-scalar-symbols.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 +8 -4
- package/dist/composition/probe/corpus.d.ts.map +1 -1
- package/dist/composition/probe/corpus.js +23 -12
- package/dist/composition/probe/corpus.js.map +1 -1
- package/dist/composition/probe/dataset.d.ts +18 -0
- package/dist/composition/probe/dataset.d.ts.map +1 -1
- package/dist/composition/probe/dataset.js +95 -50
- package/dist/composition/probe/dataset.js.map +1 -1
- package/dist/composition/probe/experiment-design.d.ts +7 -1
- package/dist/composition/probe/experiment-design.d.ts.map +1 -1
- package/dist/composition/probe/experiment-design.js +44 -24
- 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 +2 -0
- package/dist/composition/probe/falsify.js.map +1 -1
- package/dist/composition/probe/fit.d.ts +7 -0
- package/dist/composition/probe/fit.d.ts.map +1 -1
- package/dist/composition/probe/fit.js +46 -22
- package/dist/composition/probe/fit.js.map +1 -1
- package/dist/composition/probe/frontier.d.ts.map +1 -1
- package/dist/composition/probe/frontier.js +33 -15
- package/dist/composition/probe/frontier.js.map +1 -1
- package/dist/composition/probe/generator.d.ts +30 -1
- package/dist/composition/probe/generator.d.ts.map +1 -1
- package/dist/composition/probe/generator.js +58 -36
- package/dist/composition/probe/generator.js.map +1 -1
- package/dist/composition/probe/index.d.ts +14 -0
- package/dist/composition/probe/index.d.ts.map +1 -1
- package/dist/composition/probe/index.js +6 -0
- package/dist/composition/probe/index.js.map +1 -1
- package/dist/composition/probe/limits.d.ts +25 -1
- package/dist/composition/probe/limits.d.ts.map +1 -1
- package/dist/composition/probe/limits.js +53 -11
- 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 +73 -24
- package/dist/composition/probe/pipeline.js.map +1 -1
- package/dist/composition/probe/power-law.d.ts +121 -0
- package/dist/composition/probe/power-law.d.ts.map +1 -0
- package/dist/composition/probe/power-law.js +251 -0
- package/dist/composition/probe/power-law.js.map +1 -0
- package/dist/composition/probe/problem.d.ts +8 -4
- package/dist/composition/probe/problem.d.ts.map +1 -1
- package/dist/composition/probe/problem.js +177 -49
- package/dist/composition/probe/problem.js.map +1 -1
- package/dist/composition/probe/report.js +1 -1
- package/dist/composition/probe/report.js.map +1 -1
- package/dist/composition/probe/residual.d.ts +7 -1
- package/dist/composition/probe/residual.d.ts.map +1 -1
- package/dist/composition/probe/residual.js +10 -7
- 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/structure.d.ts +82 -17
- package/dist/composition/probe/structure.d.ts.map +1 -1
- package/dist/composition/probe/structure.js +129 -55
- package/dist/composition/probe/structure.js.map +1 -1
- package/dist/composition/probe/study.d.ts +31 -9
- package/dist/composition/probe/study.d.ts.map +1 -1
- package/dist/composition/probe/study.js +235 -184
- package/dist/composition/probe/study.js.map +1 -1
- package/dist/composition/probe/t-tail.d.ts +16 -0
- package/dist/composition/probe/t-tail.d.ts.map +1 -0
- package/dist/composition/probe/t-tail.js +29 -0
- package/dist/composition/probe/t-tail.js.map +1 -0
- package/dist/composition/probe/types.d.ts +3 -0
- package/dist/composition/probe/types.d.ts.map +1 -1
- package/dist/composition/probe/types.js.map +1 -1
- package/dist/composition/proposed-bridges.d.ts +52 -12
- package/dist/composition/proposed-bridges.d.ts.map +1 -1
- package/dist/composition/proposed-bridges.js +107 -60
- package/dist/composition/proposed-bridges.js.map +1 -1
- package/dist/composition/quantity-clusters.d.ts +48 -0
- package/dist/composition/quantity-clusters.d.ts.map +1 -0
- package/dist/composition/quantity-clusters.js +98 -0
- package/dist/composition/quantity-clusters.js.map +1 -0
- package/dist/composition/rational-exponent.d.ts +40 -0
- package/dist/composition/rational-exponent.d.ts.map +1 -0
- package/dist/composition/rational-exponent.js +65 -0
- package/dist/composition/rational-exponent.js.map +1 -0
- package/dist/composition/representative-values.d.ts +22 -0
- package/dist/composition/representative-values.d.ts.map +1 -1
- package/dist/composition/representative-values.js +29 -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 +12 -4
- 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 +3 -2
- package/dist/composition/user-equation.js.map +1 -1
- package/dist/core/assignment.d.ts +19 -0
- package/dist/core/assignment.d.ts.map +1 -0
- package/dist/core/assignment.js +19 -0
- package/dist/core/assignment.js.map +1 -0
- package/dist/core/compare.d.ts +32 -0
- package/dist/core/compare.d.ts.map +1 -0
- package/dist/core/compare.js +46 -0
- package/dist/core/compare.js.map +1 -0
- package/dist/core/constants.d.ts +42 -41
- package/dist/core/constants.d.ts.map +1 -1
- package/dist/core/constants.js +71 -51
- package/dist/core/constants.js.map +1 -1
- package/dist/core/data-file.d.ts +7 -0
- package/dist/core/data-file.d.ts.map +1 -1
- package/dist/core/data-file.js +17 -0
- package/dist/core/data-file.js.map +1 -1
- package/dist/core/format.d.ts +36 -0
- package/dist/core/format.d.ts.map +1 -0
- package/dist/core/format.js +39 -0
- package/dist/core/format.js.map +1 -0
- package/dist/core/hash.d.ts +14 -0
- package/dist/core/hash.d.ts.map +1 -0
- package/dist/core/hash.js +17 -0
- package/dist/core/hash.js.map +1 -0
- package/dist/core/json-schema.d.ts +2 -0
- package/dist/core/json-schema.d.ts.map +1 -1
- package/dist/core/json-schema.js +14 -13
- package/dist/core/json-schema.js.map +1 -1
- package/dist/core/labeled-tensor.d.ts.map +1 -1
- package/dist/core/labeled-tensor.js +0 -8
- package/dist/core/labeled-tensor.js.map +1 -1
- package/dist/core/mathts-read.d.ts +25 -0
- package/dist/core/mathts-read.d.ts.map +1 -0
- package/dist/core/mathts-read.js +51 -0
- package/dist/core/mathts-read.js.map +1 -0
- package/dist/core/tensor.d.ts.map +1 -1
- package/dist/core/tensor.js +24 -0
- package/dist/core/tensor.js.map +1 -1
- package/dist/core/types.d.ts +5 -5
- 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/diff/bridge-gradient.d.ts +19 -6
- package/dist/diff/bridge-gradient.d.ts.map +1 -1
- package/dist/diff/bridge-gradient.js +19 -11
- package/dist/diff/bridge-gradient.js.map +1 -1
- package/dist/diff/bridge-specs.d.ts.map +1 -1
- package/dist/diff/bridge-specs.js +3 -0
- package/dist/diff/bridge-specs.js.map +1 -1
- package/dist/dimensional/algebra.d.ts +18 -0
- package/dist/dimensional/algebra.d.ts.map +1 -1
- package/dist/dimensional/algebra.js +41 -1
- package/dist/dimensional/algebra.js.map +1 -1
- package/dist/dimensional/ast-builders.d.ts +7 -0
- package/dist/dimensional/ast-builders.d.ts.map +1 -1
- package/dist/dimensional/ast-builders.js +11 -0
- package/dist/dimensional/ast-builders.js.map +1 -1
- package/dist/dimensional/ast-leaves.d.ts +81 -0
- package/dist/dimensional/ast-leaves.d.ts.map +1 -0
- package/dist/dimensional/ast-leaves.js +146 -0
- package/dist/dimensional/ast-leaves.js.map +1 -0
- 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/buckingham.d.ts.map +1 -1
- package/dist/dimensional/buckingham.js +15 -27
- package/dist/dimensional/buckingham.js.map +1 -1
- package/dist/dimensional/constant-rows.js +9 -9
- package/dist/dimensional/constant-rows.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/dimension-inference.d.ts.map +1 -1
- package/dist/dimensional/dimension-inference.js +1 -2
- package/dist/dimensional/dimension-inference.js.map +1 -1
- package/dist/dimensional/errors.d.ts +1 -1
- package/dist/dimensional/errors.d.ts.map +1 -1
- package/dist/dimensional/errors.js +1 -15
- package/dist/dimensional/errors.js.map +1 -1
- package/dist/dimensional/exact-scale.d.ts +24 -11
- package/dist/dimensional/exact-scale.d.ts.map +1 -1
- package/dist/dimensional/exact-scale.js +122 -130
- package/dist/dimensional/exact-scale.js.map +1 -1
- package/dist/dimensional/gauge-field.d.ts.map +1 -1
- package/dist/dimensional/gauge-field.js +2 -2
- package/dist/dimensional/gauge-field.js.map +1 -1
- package/dist/dimensional/hyphen-names.d.ts +12 -2
- package/dist/dimensional/hyphen-names.d.ts.map +1 -1
- package/dist/dimensional/hyphen-names.js +44 -19
- package/dist/dimensional/hyphen-names.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/metric.d.ts.map +1 -1
- package/dist/dimensional/metric.js +0 -1
- package/dist/dimensional/metric.js.map +1 -1
- 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/symbolic-constants.d.ts +9 -0
- package/dist/dimensional/symbolic-constants.d.ts.map +1 -1
- package/dist/dimensional/symbolic-constants.js +13 -1
- package/dist/dimensional/symbolic-constants.js.map +1 -1
- package/dist/dimensional/types.d.ts +36 -0
- package/dist/dimensional/types.d.ts.map +1 -1
- package/dist/dimensional/types.js +45 -7
- package/dist/dimensional/types.js.map +1 -1
- 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 +30 -6
- 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.d.ts +9 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -4
- package/dist/index.js.map +1 -1
- package/dist/numerical/christoffel-flat.d.ts.map +1 -1
- package/dist/numerical/christoffel-flat.js +3 -2
- package/dist/numerical/christoffel-flat.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/covariant-eikonal.d.ts.map +1 -1
- package/dist/numerical/covariant-eikonal.js +34 -11
- package/dist/numerical/covariant-eikonal.js.map +1 -1
- package/dist/numerical/curvature-lowering-helpers.js +3 -2
- package/dist/numerical/curvature-lowering-helpers.js.map +1 -1
- package/dist/numerical/errors.d.ts.map +1 -1
- package/dist/numerical/errors.js +0 -3
- package/dist/numerical/errors.js.map +1 -1
- package/dist/numerical/finite-difference.d.ts +22 -0
- package/dist/numerical/finite-difference.d.ts.map +1 -0
- package/dist/numerical/finite-difference.js +27 -0
- package/dist/numerical/finite-difference.js.map +1 -0
- package/dist/numerical/geodesic-integrator.d.ts.map +1 -1
- package/dist/numerical/geodesic-integrator.js +22 -14
- package/dist/numerical/geodesic-integrator.js.map +1 -1
- package/dist/numerical/geometrized.d.ts.map +1 -1
- package/dist/numerical/geometrized.js +0 -1
- package/dist/numerical/geometrized.js.map +1 -1
- package/dist/numerical/mathts-engine.d.ts.map +1 -1
- package/dist/numerical/mathts-engine.js +10 -24
- package/dist/numerical/mathts-engine.js.map +1 -1
- package/dist/numerical/metric-inverse.d.ts.map +1 -1
- package/dist/numerical/metric-inverse.js +83 -46
- package/dist/numerical/metric-inverse.js.map +1 -1
- package/dist/numerical/null-ray-integrator.d.ts +2 -1
- package/dist/numerical/null-ray-integrator.d.ts.map +1 -1
- package/dist/numerical/null-ray-integrator.js +12 -12
- package/dist/numerical/null-ray-integrator.js.map +1 -1
- package/dist/numerical/painleve-gullstrand-metric.js +2 -2
- package/dist/numerical/painleve-gullstrand-metric.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/perihelion-finder.d.ts +0 -36
- package/dist/numerical/perihelion-finder.d.ts.map +1 -1
- package/dist/numerical/perihelion-finder.js +41 -87
- package/dist/numerical/perihelion-finder.js.map +1 -1
- package/dist/numerical/quadrature.d.ts.map +1 -1
- package/dist/numerical/quadrature.js +11 -13
- package/dist/numerical/quadrature.js.map +1 -1
- package/dist/numerical/rk4-trajectory.d.ts +10 -0
- package/dist/numerical/rk4-trajectory.d.ts.map +1 -0
- package/dist/numerical/rk4-trajectory.js +37 -0
- package/dist/numerical/rk4-trajectory.js.map +1 -0
- package/dist/numerical/schwarzschild.d.ts +14 -0
- package/dist/numerical/schwarzschild.d.ts.map +1 -0
- package/dist/numerical/schwarzschild.js +17 -0
- package/dist/numerical/schwarzschild.js.map +1 -0
- package/dist/numerical/spacetime-metrics.d.ts +12 -0
- package/dist/numerical/spacetime-metrics.d.ts.map +1 -1
- package/dist/numerical/spacetime-metrics.js +72 -56
- package/dist/numerical/spacetime-metrics.js.map +1 -1
- package/dist/numerical/statistics.d.ts +24 -0
- package/dist/numerical/statistics.d.ts.map +1 -0
- package/dist/numerical/statistics.js +52 -0
- package/dist/numerical/statistics.js.map +1 -0
- 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/dist/numerical/tensor-engine.d.ts +21 -0
- package/dist/numerical/tensor-engine.d.ts.map +1 -1
- package/dist/numerical/tensor-engine.js +12 -0
- package/dist/numerical/tensor-engine.js.map +1 -1
- package/dist/relations/regime.d.ts +10 -0
- package/dist/relations/regime.d.ts.map +1 -1
- package/dist/relations/regime.js +18 -1
- package/dist/relations/regime.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 -354
- 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 -224
- 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 -172
- package/dist/cases/kepler-rv.js.map +0 -1
- package/dist/cases/lumped-cooling.d.ts +0 -46
- package/dist/cases/lumped-cooling.d.ts.map +0 -1
- package/dist/cases/lumped-cooling.js +0 -261
- 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 -21
- package/dist/cases/skin-depth.d.ts.map +0 -1
- package/dist/cases/skin-depth.js +0 -174
- package/dist/cases/skin-depth.js.map +0 -1
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map structure from graph algorithms, over the QUANTITY graph of a composition graph.
|
|
3
|
+
*
|
|
4
|
+
* The quantity graph has one node per canonical quantity name (`quantityCanonicalizer`). Two
|
|
5
|
+
* quantities are linked, undirected, when they occur in one equation together (sources and
|
|
6
|
+
* target), weighted by how many equations hold both. A directed arc runs from each source
|
|
7
|
+
* quantity to its equation's target. Three readings of it, each stated for what it is:
|
|
8
|
+
*
|
|
9
|
+
* - {@link communitiesOf} — LAYOUT communities of the largest component (MathTS
|
|
10
|
+
* `louvainCommunities`, a modularity heuristic). A community is where a drawing may place
|
|
11
|
+
* quantities near each other. It is never a physics claim: two quantities in one community
|
|
12
|
+
* share equations, which the map already showed; a community boundary is not a regime
|
|
13
|
+
* boundary and not a cluster of related physics.
|
|
14
|
+
* - {@link derivationCycles} — strongly connected components (MathTS
|
|
15
|
+
* `stronglyConnectedComponents`) of the directed source→target graph: the sets of quantities
|
|
16
|
+
* each of which can be derived from the others round a loop. That is where over-determination
|
|
17
|
+
* lives, and where `retrodict` has two routes to compare.
|
|
18
|
+
* - {@link rankHubs} — betweenness centrality (MathTS `betweennessCentrality`, normalised),
|
|
19
|
+
* ON DEMAND ONLY: Brandes' algorithm is O(n·m) per call over about five hundred quantity nodes,
|
|
20
|
+
* so the default `upt map` path does not call it. A hub by betweenness is a cut quantity of
|
|
21
|
+
* the drawing, not a central quantity of physics.
|
|
22
|
+
*
|
|
23
|
+
* @module composition/graph-structure
|
|
24
|
+
*/
|
|
25
|
+
import type { BridgeEdge } from './edge.js';
|
|
26
|
+
/** The label every community report and printout carries, so a reader never takes a layout for physics. @internal */
|
|
27
|
+
export declare const COMMUNITY_METHOD: 'layout communities (Louvain, heuristic)';
|
|
28
|
+
/** The quantity graph of a composition graph. @internal */
|
|
29
|
+
export interface QuantityGraph {
|
|
30
|
+
/** Canonical quantity names, in first-seen order; the index of each is its node. */
|
|
31
|
+
readonly names: readonly string[];
|
|
32
|
+
/** Symmetric co-occurrence weights: `undirected[i][j]` is the number of equations holding both. */
|
|
33
|
+
readonly undirected: number[][];
|
|
34
|
+
/** Directed arcs: `directed[i][j]` is 1 when an equation derives `j` from a source set containing `i`. */
|
|
35
|
+
readonly directed: number[][];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Build the quantity graph of `edges` (canonical names). An equation whose target is also one of
|
|
39
|
+
* its sources contributes no self-arc and no self-link.
|
|
40
|
+
*
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
43
|
+
export declare function quantityGraph(edges: readonly BridgeEdge[]): QuantityGraph;
|
|
44
|
+
/** One layout community: a set of quantities a drawing may place together. @internal */
|
|
45
|
+
export interface LayoutCommunity {
|
|
46
|
+
/** Sorted canonical quantity names. */
|
|
47
|
+
readonly quantities: readonly string[];
|
|
48
|
+
readonly size: number;
|
|
49
|
+
}
|
|
50
|
+
/** The community report of the largest connected component. @internal */
|
|
51
|
+
export interface CommunityReport {
|
|
52
|
+
/** Always {@link COMMUNITY_METHOD}: the reading is a layout heuristic. */
|
|
53
|
+
readonly method: typeof COMMUNITY_METHOD;
|
|
54
|
+
/** Quantity nodes in the largest component (0 on an empty graph). */
|
|
55
|
+
readonly componentSize: number;
|
|
56
|
+
/** Communities, largest first, then by first quantity. */
|
|
57
|
+
readonly communities: readonly LayoutCommunity[];
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Layout communities (Louvain, heuristic) of the largest component's quantity graph, over the
|
|
61
|
+
* co-occurrence weights. MathTS's Louvain is deterministic (no seed is taken, none is offered)
|
|
62
|
+
* and not guaranteed optimal. Presented as layout, never as physics: see the module note.
|
|
63
|
+
*
|
|
64
|
+
* @internal
|
|
65
|
+
*/
|
|
66
|
+
export declare function communitiesOf(edges: readonly BridgeEdge[]): CommunityReport;
|
|
67
|
+
/** One derivation cycle: quantities each derivable from the others round a loop, and the equations closing it. @internal */
|
|
68
|
+
export interface DerivationCycle {
|
|
69
|
+
/** Sorted canonical quantity names of the strongly connected component (at least two). */
|
|
70
|
+
readonly quantities: readonly string[];
|
|
71
|
+
/** Ids of the equations with a source and the target inside the component, in graph order. */
|
|
72
|
+
readonly edges: readonly string[];
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The derivation cycles of `edges`: strongly connected components of size two or more in the
|
|
76
|
+
* directed source→target quantity graph (MathTS `stronglyConnectedComponents`). An equation
|
|
77
|
+
* whose target is one of its own sources is not a cycle. Largest first, then by first quantity.
|
|
78
|
+
*
|
|
79
|
+
* @internal
|
|
80
|
+
*/
|
|
81
|
+
export declare function derivationCycles(edges: readonly BridgeEdge[]): DerivationCycle[];
|
|
82
|
+
/** One quantity's hub rank. @internal */
|
|
83
|
+
export interface HubRank {
|
|
84
|
+
readonly quantity: string;
|
|
85
|
+
/** Normalised betweenness centrality in the undirected quantity graph: 0 for a leaf, 1 for the centre of a star. */
|
|
86
|
+
readonly betweenness: number;
|
|
87
|
+
/** Distinct quantities it shares an equation with. */
|
|
88
|
+
readonly degree: number;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Rank quantities by betweenness centrality (MathTS `betweennessCentrality`, Brandes, normalised
|
|
92
|
+
* by `(n−1)(n−2)`), highest first, ties by name. ON DEMAND ONLY: not called by the default map
|
|
93
|
+
* path. A graph of fewer than three quantities has no interior path, so every score is 0.
|
|
94
|
+
*
|
|
95
|
+
* @internal
|
|
96
|
+
*/
|
|
97
|
+
export declare function rankHubs(edges: readonly BridgeEdge[]): Promise<HubRank[]>;
|
|
98
|
+
//# sourceMappingURL=graph-structure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph-structure.d.ts","sourceRoot":"","sources":["../../src/composition/graph-structure.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAQH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAG5C,qHAAqH;AACrH,eAAO,MAAM,gBAAgB,EAAG,yCAAkD,CAAC;AAEnF,2DAA2D;AAC3D,MAAM,WAAW,aAAa;IAC5B,oFAAoF;IACpF,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,mGAAmG;IACnG,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,CAAC;IAChC,0GAA0G;IAC1G,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,CAAC;CAC/B;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,E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of a composition graph.
|
|
3
|
+
*
|
|
4
|
+
* The quantity graph has one node per canonical quantity name (`quantityCanonicalizer`). Two
|
|
5
|
+
* quantities are linked, undirected, when they occur in one equation together (sources and
|
|
6
|
+
* target), weighted by how many equations hold both. A directed arc runs from each source
|
|
7
|
+
* quantity to its equation's target. Three readings of it, each stated for what it is:
|
|
8
|
+
*
|
|
9
|
+
* - {@link communitiesOf} — LAYOUT communities of the largest component (MathTS
|
|
10
|
+
* `louvainCommunities`, a modularity heuristic). A community is where a drawing may place
|
|
11
|
+
* quantities near each other. It is never a physics claim: two quantities in one community
|
|
12
|
+
* share equations, which the map already showed; a community boundary is not a regime
|
|
13
|
+
* boundary and not a cluster of related physics.
|
|
14
|
+
* - {@link derivationCycles} — strongly connected components (MathTS
|
|
15
|
+
* `stronglyConnectedComponents`) of the directed source→target graph: the sets of quantities
|
|
16
|
+
* each of which can be derived from the others round a loop. That is where over-determination
|
|
17
|
+
* lives, and where `retrodict` has two routes to compare.
|
|
18
|
+
* - {@link rankHubs} — betweenness centrality (MathTS `betweennessCentrality`, normalised),
|
|
19
|
+
* ON DEMAND ONLY: Brandes' algorithm is O(n·m) per call over about five hundred quantity nodes,
|
|
20
|
+
* so the default `upt map` path does not call it. A hub by betweenness is a cut quantity of
|
|
21
|
+
* the drawing, not a central quantity of physics.
|
|
22
|
+
*
|
|
23
|
+
* @module composition/graph-structure
|
|
24
|
+
*/
|
|
25
|
+
import { betweennessCentrality, connectedComponents, louvainCommunities, stronglyConnectedComponents, } from '@danielsimonjr/mathts-functions';
|
|
26
|
+
import { quantityCanonicalizer } from './quantity-clusters.js';
|
|
27
|
+
/** The label every community report and printout carries, so a reader never takes a layout for physics. @internal */
|
|
28
|
+
export const COMMUNITY_METHOD = 'layout communities (Louvain, heuristic)';
|
|
29
|
+
/**
|
|
30
|
+
* Build the quantity graph of `edges` (canonical names). An equation whose target is also one of
|
|
31
|
+
* its sources contributes no self-arc and no self-link.
|
|
32
|
+
*
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
export function quantityGraph(edges) {
|
|
36
|
+
const canon = quantityCanonicalizer();
|
|
37
|
+
const index = new Map();
|
|
38
|
+
const names = [];
|
|
39
|
+
const nodeOf = (raw) => {
|
|
40
|
+
const name = canon(raw);
|
|
41
|
+
let i = index.get(name);
|
|
42
|
+
if (i === undefined) {
|
|
43
|
+
i = names.length;
|
|
44
|
+
names.push(name);
|
|
45
|
+
index.set(name, i);
|
|
46
|
+
}
|
|
47
|
+
return i;
|
|
48
|
+
};
|
|
49
|
+
const members = edges.map((e) => ({
|
|
50
|
+
sources: [...new Set(e.sources.map((s) => nodeOf(s.name)))],
|
|
51
|
+
target: nodeOf(e.target.name),
|
|
52
|
+
}));
|
|
53
|
+
const n = names.length;
|
|
54
|
+
const undirected = Array.from({ length: n }, () => new Array(n).fill(0));
|
|
55
|
+
const directed = Array.from({ length: n }, () => new Array(n).fill(0));
|
|
56
|
+
for (const m of members) {
|
|
57
|
+
const all = [...new Set([...m.sources, m.target])];
|
|
58
|
+
for (let a = 0; a < all.length; a++) {
|
|
59
|
+
for (let b = a + 1; b < all.length; b++) {
|
|
60
|
+
undirected[all[a]][all[b]] += 1;
|
|
61
|
+
undirected[all[b]][all[a]] += 1;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
for (const s of m.sources)
|
|
65
|
+
if (s !== m.target)
|
|
66
|
+
directed[s][m.target] = 1;
|
|
67
|
+
}
|
|
68
|
+
return { names, undirected, directed };
|
|
69
|
+
}
|
|
70
|
+
/** 0/1 copy of a weighted adjacency. */
|
|
71
|
+
function binary(weighted) {
|
|
72
|
+
return weighted.map((row) => row.map((w) => (w > 0 ? 1 : 0)));
|
|
73
|
+
}
|
|
74
|
+
/** The connected components of the undirected quantity graph, largest first, each sorted by node index. */
|
|
75
|
+
function undirectedComponents(g) {
|
|
76
|
+
if (g.names.length === 0)
|
|
77
|
+
return [];
|
|
78
|
+
const comps = connectedComponents(binary(g.undirected)).map((c) => [...c].sort((a, b) => a - b));
|
|
79
|
+
comps.sort((a, b) => b.length - a.length || g.names[a[0]].localeCompare(g.names[b[0]]));
|
|
80
|
+
return comps;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Layout communities (Louvain, heuristic) of the largest component's quantity graph, over the
|
|
84
|
+
* co-occurrence weights. MathTS's Louvain is deterministic (no seed is taken, none is offered)
|
|
85
|
+
* and not guaranteed optimal. Presented as layout, never as physics: see the module note.
|
|
86
|
+
*
|
|
87
|
+
* @internal
|
|
88
|
+
*/
|
|
89
|
+
export function communitiesOf(edges) {
|
|
90
|
+
const g = quantityGraph(edges);
|
|
91
|
+
const comps = undirectedComponents(g);
|
|
92
|
+
if (comps.length === 0)
|
|
93
|
+
return { method: COMMUNITY_METHOD, componentSize: 0, communities: [] };
|
|
94
|
+
const largest = comps[0];
|
|
95
|
+
const sub = largest.map((i) => largest.map((j) => g.undirected[i][j]));
|
|
96
|
+
const partition = louvainCommunities(sub);
|
|
97
|
+
const communities = partition.map((group) => {
|
|
98
|
+
const quantities = group.map((k) => g.names[largest[k]]).sort();
|
|
99
|
+
return { quantities, size: quantities.length };
|
|
100
|
+
});
|
|
101
|
+
communities.sort((a, b) => b.size - a.size || a.quantities[0].localeCompare(b.quantities[0]));
|
|
102
|
+
return { method: COMMUNITY_METHOD, componentSize: largest.length, communities };
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The derivation cycles of `edges`: strongly connected components of size two or more in the
|
|
106
|
+
* directed source→target quantity graph (MathTS `stronglyConnectedComponents`). An equation
|
|
107
|
+
* whose target is one of its own sources is not a cycle. Largest first, then by first quantity.
|
|
108
|
+
*
|
|
109
|
+
* @internal
|
|
110
|
+
*/
|
|
111
|
+
export function derivationCycles(edges) {
|
|
112
|
+
const g = quantityGraph(edges);
|
|
113
|
+
if (g.names.length === 0)
|
|
114
|
+
return [];
|
|
115
|
+
const canon = quantityCanonicalizer();
|
|
116
|
+
const index = new Map(g.names.map((name, i) => [name, i]));
|
|
117
|
+
const cycles = [];
|
|
118
|
+
for (const scc of stronglyConnectedComponents(g.directed)) {
|
|
119
|
+
if (scc.length < 2)
|
|
120
|
+
continue;
|
|
121
|
+
const inside = new Set(scc);
|
|
122
|
+
const quantities = scc.map((i) => g.names[i]).sort();
|
|
123
|
+
const closing = edges
|
|
124
|
+
.filter((e) => {
|
|
125
|
+
const t = index.get(canon(e.target.name));
|
|
126
|
+
if (t === undefined || !inside.has(t))
|
|
127
|
+
return false;
|
|
128
|
+
return e.sources.some((s) => {
|
|
129
|
+
const si = index.get(canon(s.name));
|
|
130
|
+
return si !== undefined && si !== t && inside.has(si);
|
|
131
|
+
});
|
|
132
|
+
})
|
|
133
|
+
.map((e) => e.id);
|
|
134
|
+
cycles.push({ quantities, edges: closing });
|
|
135
|
+
}
|
|
136
|
+
cycles.sort((a, b) => b.quantities.length - a.quantities.length || a.quantities[0].localeCompare(b.quantities[0]));
|
|
137
|
+
return cycles;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Rank quantities by betweenness centrality (MathTS `betweennessCentrality`, Brandes, normalised
|
|
141
|
+
* by `(n−1)(n−2)`), highest first, ties by name. ON DEMAND ONLY: not called by the default map
|
|
142
|
+
* path. A graph of fewer than three quantities has no interior path, so every score is 0.
|
|
143
|
+
*
|
|
144
|
+
* @internal
|
|
145
|
+
*/
|
|
146
|
+
export async function rankHubs(edges) {
|
|
147
|
+
const g = quantityGraph(edges);
|
|
148
|
+
const n = g.names.length;
|
|
149
|
+
const adjacency = binary(g.undirected);
|
|
150
|
+
const degree = adjacency.map((row) => row.reduce((acc, x) => acc + x, 0));
|
|
151
|
+
let scores;
|
|
152
|
+
if (n < 3) {
|
|
153
|
+
scores = new Array(n).fill(0);
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
const result = await betweennessCentrality(adjacency, { directed: false, normalized: true });
|
|
157
|
+
const centrality = result.centrality;
|
|
158
|
+
if (!(centrality instanceof Float64Array) || centrality.length !== n) {
|
|
159
|
+
throw new TypeError(`betweennessCentrality returned ${String(centrality)} for ${n} nodes`);
|
|
160
|
+
}
|
|
161
|
+
scores = Array.from(centrality);
|
|
162
|
+
}
|
|
163
|
+
const ranks = g.names.map((quantity, i) => ({ quantity, betweenness: scores[i], degree: degree[i] }));
|
|
164
|
+
ranks.sort((a, b) => b.betweenness - a.betweenness || a.quantity.localeCompare(b.quantity));
|
|
165
|
+
return ranks;
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=graph-structure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph-structure.js","sourceRoot":"","sources":["../../src/composition/graph-structure.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAClB,2BAA2B,GAC5B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,qHAAqH;AACrH,MAAM,CAAC,MAAM,gBAAgB,GAAG,yCAAkD,CAAC;AAYnF;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,KAA4B;IACxD,MAAM,KAAK,GAAG,qBAAqB,EAAE,CAAC;IACtC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;IACxC,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,MAAM,MAAM,GAAG,CAAC,GAAW,EAAU,EAAE;QACrC,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;QACxB,IAAI,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACxB,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;YACpB,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC;YACjB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACjB,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,C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,EAAE,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC1E,IAAI,MAAgB,CAAC;IACrB,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACV,MAAM,GAAG,IAAI,KAAK,CAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACxC,CAAC;SAAM,CAAC;QACN,MAAM,MAAM,GAAG,MAAM,qBAAqB,CAAC,SAAS,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;QAC7F,MAAM,UAAU,GAAY,MAAM,CAAC,UAAU,CAAC;QAC9C,IAAI,CAAC,CAAC,UAAU,YAAY,YAAY,CAAC,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACrE,MAAM,IAAI,SAAS,CAAC,kCAAkC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAC7F,CAAC;QACD,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAClC,CAAC;IACD,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACtG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,GAAG,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC5F,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/**\n * Map structure from graph algorithms, over the QUANTITY graph of a composition graph.\n *\n * The quantity graph has one node per canonical quantity name (`quantityCanonicalizer`). Two\n * quantities are linked, undirected, when they occur in one equation together (sources and\n * target), weighted by how many equations hold both. A directed arc runs from each source\n * quantity to its equation's target. Three readings of it, each stated for what it is:\n *\n * - {@link communitiesOf} — LAYOUT communities of the largest component (MathTS\n * `louvainCommunities`, a modularity heuristic). A community is where a drawing may place\n * quantities near each other. It is never a physics claim: two quantities in one community\n * share equations, which the map already showed; a community boundary is not a regime\n * boundary and not a cluster of related physics.\n * - {@link derivationCycles} — strongly connected components (MathTS\n * `stronglyConnectedComponents`) of the directed source→target graph: the sets of quantities\n * each of which can be derived from the others round a loop. That is where over-determination\n * lives, and where `retrodict` has two routes to compare.\n * - {@link rankHubs} — betweenness centrality (MathTS `betweennessCentrality`, normalised),\n * ON DEMAND ONLY: Brandes' algorithm is O(n·m) per call over about five hundred quantity nodes,\n * so the default `upt map` path does not call it. A hub by betweenness is a cut quantity of\n * the drawing, not a central quantity of physics.\n *\n * @module composition/graph-structure\n */\n\nimport {\n betweennessCentrality,\n connectedComponents,\n louvainCommunities,\n stronglyConnectedComponents,\n} from '@danielsimonjr/mathts-functions';\nimport type { BridgeEdge } from './edge.js';\nimport { quantityCanonicalizer } from './quantity-clusters.js';\n\n/** The label every community report and printout carries, so a reader never takes a layout for physics. @internal */\nexport const COMMUNITY_METHOD = 'layout communities (Louvain, heuristic)' as const;\n\n/** The quantity graph of a composition graph. @internal */\nexport interface QuantityGraph {\n /** Canonical quantity names, in first-seen order; the index of each is its node. */\n readonly names: readonly string[];\n /** Symmetric co-occurrence weights: `undirected[i][j]` is the number of equations holding both. */\n readonly undirected: number[][];\n /** Directed arcs: `directed[i][j]` is 1 when an equation derives `j` from a source set containing `i`. */\n readonly directed: number[][];\n}\n\n/**\n * Build the quantity graph of `edges` (canonical names). An equation whose target is also one of\n * its sources contributes no self-arc and no self-link.\n *\n * @internal\n */\nexport function quantityGraph(edges: readonly BridgeEdge[]): QuantityGraph {\n const canon = quantityCanonicalizer();\n const index = new Map<string, number>();\n const names: string[] = [];\n const nodeOf = (raw: string): number => {\n const name = canon(raw);\n let i = index.get(name);\n if (i === undefined) {\n i = names.length;\n names.push(name);\n index.set(name, i);\n }\n return i;\n };\n const members = edges.map((e) => ({\n sources: [...new Set(e.sources.map((s) => nodeOf(s.name)))],\n target: nodeOf(e.target.name),\n }));\n const n = names.length;\n const undirected = Array.from({ length: n }, () => new Array<number>(n).fill(0));\n const directed = Array.from({ length: n }, () => new Array<number>(n).fill(0));\n for (const m of members) {\n const all = [...new Set([...m.sources, m.target])];\n for (let a = 0; a < all.length; a++) {\n for (let b = a + 1; b < all.length; b++) {\n undirected[all[a]][all[b]] += 1;\n undirected[all[b]][all[a]] += 1;\n }\n }\n for (const s of m.sources) if (s !== m.target) directed[s][m.target] = 1;\n }\n return { names, undirected, directed };\n}\n\n/** One layout community: a set of quantities a drawing may place together. @internal */\nexport interface LayoutCommunity {\n /** Sorted canonical quantity names. */\n readonly quantities: readonly string[];\n readonly size: number;\n}\n\n/** The community report of the largest connected component. @internal */\nexport interface CommunityReport {\n /** Always {@link COMMUNITY_METHOD}: the reading is a layout heuristic. */\n readonly method: typeof COMMUNITY_METHOD;\n /** Quantity nodes in the largest component (0 on an empty graph). */\n readonly componentSize: number;\n /** Communities, largest first, then by first quantity. */\n readonly communities: readonly LayoutCommunity[];\n}\n\n/** 0/1 copy of a weighted adjacency. */\nfunction binary(weighted: readonly (readonly number[])[]): number[][] {\n return weighted.map((row) => row.map((w) => (w > 0 ? 1 : 0)));\n}\n\n/** The connected components of the undirected quantity graph, largest first, each sorted by node index. */\nfunction undirectedComponents(g: QuantityGraph): number[][] {\n if (g.names.length === 0) return [];\n const comps = connectedComponents(binary(g.undirected)).map((c) => [...c].sort((a, b) => a - b));\n comps.sort((a, b) => b.length - a.length || g.names[a[0]].localeCompare(g.names[b[0]]));\n return comps;\n}\n\n/**\n * Layout communities (Louvain, heuristic) of the largest component's quantity graph, over the\n * co-occurrence weights. MathTS's Louvain is deterministic (no seed is taken, none is offered)\n * and not guaranteed optimal. Presented as layout, never as physics: see the module note.\n *\n * @internal\n */\nexport function communitiesOf(edges: readonly BridgeEdge[]): CommunityReport {\n const g = quantityGraph(edges);\n const comps = undirectedComponents(g);\n if (comps.length === 0) return { method: COMMUNITY_METHOD, componentSize: 0, communities: [] };\n const largest = comps[0];\n const sub = largest.map((i) => largest.map((j) => g.undirected[i][j]));\n const partition = louvainCommunities(sub);\n const communities: LayoutCommunity[] = partition.map((group) => {\n const quantities = group.map((k) => g.names[largest[k]]).sort();\n return { quantities, size: quantities.length };\n });\n communities.sort((a, b) => b.size - a.size || a.quantities[0].localeCompare(b.quantities[0]));\n return { method: COMMUNITY_METHOD, componentSize: largest.length, communities };\n}\n\n/** One derivation cycle: quantities each derivable from the others round a loop, and the equations closing it. @internal */\nexport interface DerivationCycle {\n /** Sorted canonical quantity names of the strongly connected component (at least two). */\n readonly quantities: readonly string[];\n /** Ids of the equations with a source and the target inside the component, in graph order. */\n readonly edges: readonly string[];\n}\n\n/**\n * The derivation cycles of `edges`: strongly connected components of size two or more in the\n * directed source→target quantity graph (MathTS `stronglyConnectedComponents`). An equation\n * whose target is one of its own sources is not a cycle. Largest first, then by first quantity.\n *\n * @internal\n */\nexport function derivationCycles(edges: readonly BridgeEdge[]): DerivationCycle[] {\n const g = quantityGraph(edges);\n if (g.names.length === 0) return [];\n const canon = quantityCanonicalizer();\n const index = new Map(g.names.map((name, i) => [name, i]));\n const cycles: DerivationCycle[] = [];\n for (const scc of stronglyConnectedComponents(g.directed)) {\n if (scc.length < 2) continue;\n const inside = new Set(scc);\n const quantities = scc.map((i) => g.names[i]).sort();\n const closing = edges\n .filter((e) => {\n const t = index.get(canon(e.target.name));\n if (t === undefined || !inside.has(t)) return false;\n return e.sources.some((s) => {\n const si = index.get(canon(s.name));\n return si !== undefined && si !== t && inside.has(si);\n });\n })\n .map((e) => e.id);\n cycles.push({ quantities, edges: closing });\n }\n cycles.sort((a, b) => b.quantities.length - a.quantities.length || a.quantities[0].localeCompare(b.quantities[0]));\n return cycles;\n}\n\n/** One quantity's hub rank. @internal */\nexport interface HubRank {\n readonly quantity: string;\n /** Normalised betweenness centrality in the undirected quantity graph: 0 for a leaf, 1 for the centre of a star. */\n readonly betweenness: number;\n /** Distinct quantities it shares an equation with. */\n readonly degree: number;\n}\n\n/**\n * Rank quantities by betweenness centrality (MathTS `betweennessCentrality`, Brandes, normalised\n * by `(n−1)(n−2)`), highest first, ties by name. ON DEMAND ONLY: not called by the default map\n * path. A graph of fewer than three quantities has no interior path, so every score is 0.\n *\n * @internal\n */\nexport async function rankHubs(edges: readonly BridgeEdge[]): Promise<HubRank[]> {\n const g = quantityGraph(edges);\n const n = g.names.length;\n const adjacency = binary(g.undirected);\n const degree = adjacency.map((row) => row.reduce((acc, x) => acc + x, 0));\n let scores: number[];\n if (n < 3) {\n scores = new Array<number>(n).fill(0);\n } else {\n const result = await betweennessCentrality(adjacency, { directed: false, normalized: true });\n const centrality: unknown = result.centrality;\n if (!(centrality instanceof Float64Array) || centrality.length !== n) {\n throw new TypeError(`betweennessCentrality returned ${String(centrality)} for ${n} nodes`);\n }\n scores = Array.from(centrality);\n }\n const ranks = g.names.map((quantity, i) => ({ quantity, betweenness: scores[i], degree: degree[i] }));\n ranks.sort((a, b) => b.betweenness - a.betweenness || a.quantity.localeCompare(b.quantity));\n return ranks;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph-viz-svg.d.ts","sourceRoot":"","sources":["../../src/composition/graph-viz-svg.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;
|
|
1
|
+
{"version":3,"file":"graph-viz-svg.d.ts","sourceRoot":"","sources":["../../src/composition/graph-viz-svg.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH;;;;;;GAMG;AACH,qBAAa,2BAA4B,SAAQ,KAAK;IACpD,YACE,OAAO,SAC8B,EAItC;CACF;AAWD;;;;;;GAMG;AACH,wBAAsB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CASjE"}
|
|
@@ -34,7 +34,7 @@ export class SvgRendererUnavailableError extends Error {
|
|
|
34
34
|
export async function renderDotToSvg(dot) {
|
|
35
35
|
let viz;
|
|
36
36
|
try {
|
|
37
|
-
viz =
|
|
37
|
+
viz = await import('@viz-js/viz');
|
|
38
38
|
}
|
|
39
39
|
catch {
|
|
40
40
|
throw new SvgRendererUnavailableError();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph-viz-svg.js","sourceRoot":"","sources":["../../src/composition/graph-viz-svg.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;
|
|
1
|
+
{"version":3,"file":"graph-viz-svg.js","sourceRoot":"","sources":["../../src/composition/graph-viz-svg.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH;;;;;;GAMG;AACH,MAAM,OAAO,2BAA4B,SAAQ,KAAK;IACpD,YACE,OAAO,GAAG,+DAA+D;QACvE,mCAAmC;QAErC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,6BAA6B,CAAC;IAC5C,CAAC;CACF;AAWD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,GAAW;IAC9C,IAAI,GAAc,CAAC;IACnB,IAAI,CAAC;QACH,GAAG,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,CAAC;IACpC,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,2BAA2B,EAAE,CAAC;IAC1C,CAAC;IACD,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,QAAQ,EAAE,CAAC;IACtC,OAAO,QAAQ,CAAC,YAAY,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;AACvD,CAAC","sourcesContent":["/**\n * SVG rendering for the physics map — render Graphviz DOT source to an SVG\n * string via the optional **`@viz-js/viz`** peer (the real Graphviz compiled to\n * WebAssembly: same `dot` output, in-process, no native binary, no subprocess).\n *\n * Kept separate from `graph-viz.ts` so that module stays pure, synchronous, and\n * dependency-free (text only). The optional-renderer concern — a lazy dynamic\n * import with graceful fallback, mirroring `numerical/formula-registry.ts`'s\n * MathTS-peer pattern — lives here.\n *\n * @module composition/graph-viz-svg\n */\n\nimport type { Viz } from '@viz-js/viz';\n\n/**\n * Thrown by {@link renderDotToSvg} when the optional `@viz-js/viz` peer is not\n * installed. The message names the install command and the no-install\n * alternative.\n *\n * @public\n */\nexport class SvgRendererUnavailableError extends Error {\n constructor(\n message = 'SVG rendering needs the optional renderer: npm i @viz-js/viz ' +\n '(or use --format=dot | dot -Tsvg)',\n ) {\n super(message);\n this.name = 'SvgRendererUnavailableError';\n }\n}\n\n/**\n * The part of `@viz-js/viz` this module uses: `instance()` resolves the renderer, whose\n * `renderString` is the peer's own declared type. The peer's types are a devDependency, so the\n * dynamic import is typed without a cast; at runtime the peer stays optional.\n */\ninterface VizModule {\n instance(): Promise<Viz>;\n}\n\n/**\n * Render Graphviz DOT source (e.g. {@link buildVizModel}'s `toDot()`) to an SVG\n * document string. Lazy-loads the optional `@viz-js/viz` peer.\n *\n * @throws {SvgRendererUnavailableError} if the peer is not installed.\n * @public\n */\nexport async function renderDotToSvg(dot: string): Promise<string> {\n let viz: VizModule;\n try {\n viz = await import('@viz-js/viz');\n } catch {\n throw new SvgRendererUnavailableError();\n }\n const renderer = await viz.instance();\n return renderer.renderString(dot, { format: 'svg' });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph-viz.d.ts","sourceRoot":"","sources":["../../src/composition/graph-viz.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAEvE;;;;;;GAMG;AACH,MAAM,MAAM,SAA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AE,cAAc,CAAC;IACrC,8EAA8E;IAC9E,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,SAAS,IAAI,MAAM,CAAC;IACpB,KAAK,IAAI,MAAM,CAAC;CACjB;AAqBD;;;;4DAI4D;AAC5D,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,GAAG,WAAW,CAW5D;AAgCD;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,SAAS,UAAU,EAAE,EAC5B,IAAI,EAAE,IAAI,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,GAAG,gBAAgB,CAAC,GACjE;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAA;CAAE,CA4BjE;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,GAAG,IAAI,CAUvE;AA8MD;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,SAAS,UAAU,EAAE,EAC5B,IAAI,GAAE,UAAe,GACpB,QAAQ,CA4DV"}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
*
|
|
19
19
|
* @module composition/graph-viz
|
|
20
20
|
*/
|
|
21
|
-
import {
|
|
21
|
+
import { clusterBySharedKeys, quantityCanonicalizer } from './quantity-clusters.js';
|
|
22
22
|
/**
|
|
23
23
|
* Every `VizStatus`, as VALUES.
|
|
24
24
|
*
|
|
@@ -147,43 +147,17 @@ export function formatFilterLegend(stats) {
|
|
|
147
147
|
`${stats.droppedNotMatching} dropped (did not match); ` +
|
|
148
148
|
`${stats.droppedMissingMetadata} dropped (no overlay metadata)`);
|
|
149
149
|
}
|
|
150
|
-
/** Quantity-name canonicalizer from `QUANTITY_IDENTIFICATIONS` (matches `linkageMap`). */
|
|
151
|
-
function makeCanon() {
|
|
152
|
-
const alias = new Map(QUANTITY_IDENTIFICATIONS.map((id) => [id.from, id.to]));
|
|
153
|
-
return (n) => alias.get(n) ?? n;
|
|
154
|
-
}
|
|
155
150
|
/** Distinct canonical quantity names of a junction (sources ∪ target). */
|
|
156
151
|
function quantitiesOf(j) {
|
|
157
152
|
return [...new Set([...j.sources, j.target])];
|
|
158
153
|
}
|
|
159
|
-
/**
|
|
154
|
+
/**
|
|
155
|
+
* Component grouping of junctions sharing a (canonical) quantity: the shared partition of
|
|
156
|
+
* `quantity-clusters.ts`, in the order the map always drew (largest first, then by first
|
|
157
|
+
* junction id; input order inside). The anchoring rule below is this module's own.
|
|
158
|
+
*/
|
|
160
159
|
function componentsOf(junctions) {
|
|
161
|
-
|
|
162
|
-
const find = (x) => parent[x] === x ? x : (parent[x] = find(parent[x]));
|
|
163
|
-
const union = (a, b) => {
|
|
164
|
-
parent[find(a)] = find(b);
|
|
165
|
-
};
|
|
166
|
-
const qToJunctions = new Map();
|
|
167
|
-
junctions.forEach((j, i) => {
|
|
168
|
-
for (const qty of quantitiesOf(j)) {
|
|
169
|
-
const arr = qToJunctions.get(qty) ?? [];
|
|
170
|
-
arr.push(i);
|
|
171
|
-
qToJunctions.set(qty, arr);
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
for (const idxs of qToJunctions.values()) {
|
|
175
|
-
for (let k = 1; k < idxs.length; k++)
|
|
176
|
-
union(idxs[0], idxs[k]);
|
|
177
|
-
}
|
|
178
|
-
const groups = new Map();
|
|
179
|
-
junctions.forEach((_, i) => {
|
|
180
|
-
const r = find(i);
|
|
181
|
-
const arr = groups.get(r) ?? [];
|
|
182
|
-
arr.push(i);
|
|
183
|
-
groups.set(r, arr);
|
|
184
|
-
});
|
|
185
|
-
const clusters = [...groups.values()].map((idxs) => {
|
|
186
|
-
const js = idxs.map((i) => junctions[i]);
|
|
160
|
+
return clusterBySharedKeys(junctions, quantitiesOf, (j) => j.id).map((js) => {
|
|
187
161
|
const quantities = [...new Set(js.flatMap(quantitiesOf))].sort();
|
|
188
162
|
return {
|
|
189
163
|
junctionIds: js.map((j) => j.id),
|
|
@@ -197,9 +171,6 @@ function componentsOf(junctions) {
|
|
|
197
171
|
anchored: js.some((j) => j.status === 'law' || j.status === 'established'),
|
|
198
172
|
};
|
|
199
173
|
});
|
|
200
|
-
// Deterministic: largest first, then by first junction id.
|
|
201
|
-
clusters.sort((a, b) => b.size - a.size || a.junctionIds[0].localeCompare(b.junctionIds[0]));
|
|
202
|
-
return clusters;
|
|
203
174
|
}
|
|
204
175
|
/** A stable, collision-free id factory mapping arbitrary keys to safe ids. */
|
|
205
176
|
function idFactory(prefix) {
|
|
@@ -355,7 +326,7 @@ function emitDot(clusters, byId, title, legend) {
|
|
|
355
326
|
* @public
|
|
356
327
|
*/
|
|
357
328
|
export function buildVizModel(edges, opts = {}) {
|
|
358
|
-
const canon =
|
|
329
|
+
const canon = quantityCanonicalizer();
|
|
359
330
|
const normalize = (j) => ({
|
|
360
331
|
...j,
|
|
361
332
|
sources: j.sources.map(canon),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph-viz.js","sourceRoot":"","sources":["../../src/composition/graph-viz.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAoBxD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAyB;IACpD,KAAK;IACL,aAAa;IACb,aAAa;IACb,oBAAoB;IACpB,UAAU;IACV,MAAM;IACN,QAAQ;IACR,aAAa;CACd,CAAC;AAqIF,iFAAiF;AACjF,MAAM,YAAY,GAEd;IACF,GAAG,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,sBAAsB;IAClF,WAAW,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,uBAAuB;IAC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;KAC1D,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Physics-map visualization — turn the composition hypergraph into Mermaid and\n * Graphviz-DOT **source text**.\n *\n * The graph is bipartite in the drawing: round nodes are *quantities*\n * (`mass`, `temperature`, …) and box nodes are *equations* — laws, bridges, or\n * proposed relations — each an n-ary junction (its source quantities point in,\n * its target points out). This makes \"equations as junctions\" literal and draws\n * n-ary edges faithfully (a single Mermaid/DOT edge can only connect two nodes).\n *\n * The model computes its own connected components over the junctions — so a\n * `--proposed` overlay participates in the clustering — and groups each component\n * into its own subgraph so the genuinely disjointed map stays legible. For the\n * pure-`BridgeEdge` case the component count matches the authoritative\n * {@link linkageMap} (pinned by a drift-guard test).\n *\n * Pure string production: no file I/O (the CLI is the only file-touching layer).\n *\n * @module composition/graph-viz\n */\n\nimport type { BridgeEdge } from './edge.js';\nimport { QUANTITY_IDENTIFICATIONS } from './compose.js';\nimport type { EvidenceTag, RelationType } from '../relations/types.js';\n\n/**\n * Epistemic status of a junction — drives node colour/shape. Bridges carry\n * their catalog confidence; `law` is a diagonal/established-physics edge;\n * `proposed` is a machine-derived, unadjudicated relation (rendered quarantined).\n *\n * @public\n */\nexport type VizStatus =\n | 'law'\n | 'established'\n | 'speculative'\n | 'highly-speculative'\n | 'proposed'\n | 'user'\n | 'poster'\n | 'association';\n\n/**\n * Every `VizStatus`, as VALUES.\n *\n * Exists so the union can be pinned at RUNTIME. `VizStatus` is a type: the\n * public-surface test pins its NAME and nothing pins its MEMBERS, so widening\n * it is invisible to every existing test. This array is what the three places\n * a status must be registered are checked against — `STATUS_STYLE` (a compile\n * error when incomplete), `STATUSES_IN_ORDER` (a plain array that would\n * SILENTLY omit a Mermaid `classDef`), and the published surface.\n *\n * @internal\n */\nexport const ALL_VIZ_STATUSES: readonly VizStatus[] = [\n 'law',\n 'established',\n 'speculative',\n 'highly-speculative',\n 'proposed',\n 'user',\n 'poster',\n 'association',\n];\n\n/**\n * A normalized equation junction: n source quantities → 1 target. The render\n * model's unit of \"equation\", decoupled from both `BridgeEdge` and the internal\n * `ProposedBridge` type (the CLI converts each into this shape).\n *\n * @public\n */\nexport interface VizJunction {\n /** Graph id, e.g. `'be-42'` or `'IC-…'`. */\n readonly id: string;\n /** Short human label. */\n readonly label: string;\n readonly status: VizStatus;\n /** Source quantity names. */\n readonly sources: readonly string[];\n /** Target quantity name. */\n readonly target: string;\n /**\n * The Atlas Phase 1 relation TYPE this junction's edge records, when one was\n * recorded. Absent means \"nobody has audited this edge\", which is a\n * different statement from \"this edge is not an approximation\" — the\n * filtering in {@link buildVizModel} keeps the two apart and counts them\n * separately.\n */\n readonly relation?: RelationType;\n /**\n * The catalog id this junction's edge cross-references, when it has one.\n * Carried so evidence can be DERIVED at read time; no evidence tag is ever\n * stored on a junction.\n */\n readonly beId?: number | null;\n}\n\n/**\n * Why junctions were left out of a filtered map.\n *\n * The two dropped counts are SEPARATE on purpose. An edge dropped for not\n * matching the filter answered the question; an edge dropped for carrying no\n * overlay never got asked. Folding them together would let an unaudited graph\n * render as a complete answer to a question nobody could put to it.\n *\n * @public\n */\nexport interface VizFilterStats {\n /** Junctions considered, before filtering. */\n readonly total: number;\n /** Junctions rendered. */\n readonly kept: number;\n /** Dropped because their recorded metadata did not match the filter. */\n readonly droppedNotMatching: number;\n /** Dropped because they carry no metadata the filter could read. */\n readonly droppedMissingMetadata: number;\n /** The `relation` filter in force, if any. */\n readonly relation?: RelationType;\n /** The `evidence` filter in force, if any. */\n readonly evidence?: EvidenceTag;\n}\n\n/**\n * One connected component of the bipartite graph.\n *\n * @public\n */\nexport interface VizCluster {\n /** Junction ids in this component. */\n readonly junctionIds: readonly string[];\n /** Distinct (canonical) quantity names touched by this component. */\n readonly quantities: readonly string[];\n /** Number of junctions (the cluster \"size\", matching `linkageMap`). */\n readonly size: number;\n /** Contains a `law`/`established` junction (anchored to known physics). */\n readonly anchored: boolean;\n}\n\n/**\n * Options for {@link buildVizModel}.\n *\n * @public\n */\nexport interface VizOptions {\n /** Diagram title (used as the graph label). */\n readonly title?: string;\n /** Already-normalized extra junctions to overlay (e.g. proposed relations). */\n readonly extraJunctions?: readonly VizJunction[];\n /**\n * Keep only junctions whose recorded relation is this type.\n *\n * ⚠ Setting ANY filter changes what a missing overlay MEANS. Unfiltered, an\n * edge with no `relation` is kept — the map is about connectivity and an\n * unaudited edge still connects. Filtered, it is dropped, because it cannot\n * be shown to satisfy the filter. The count of those drops is reported\n * separately in {@link VizFilterStats} and printed in the legend.\n */\n readonly relation?: RelationType;\n /**\n * Keep only junctions whose DERIVED evidence set contains this tag.\n *\n * Evidence is never stored. It is derived from the catalog row named by the\n * junction's `beId`, every time it is asked for; a junction with no numeric\n * `beId` cannot be evaluated and counts as LACKING metadata, not as\n * non-matching.\n */\n readonly evidence?: EvidenceTag;\n /**\n * The derivation used when `evidence` is set. The catalog derivation lives\n * with the CLI (`cli/map-evidence.ts`), which passes it. This module does\n * not import that derivation. A junction with a numeric `beId` and no\n * function here cannot be evaluated, and the filter throws rather than\n * rendering an unfiltered map as a filtered one. A junction with no numeric\n * `beId` is lacking metadata and does not call the function.\n */\n readonly deriveEvidence?: (beId: number) => ReadonlySet<EvidenceTag>;\n}\n\n/**\n * The render model: normalized junctions, their connected components, and the\n * two serializers.\n *\n * @public\n */\nexport interface VizModel {\n readonly junctions: readonly VizJunction[];\n readonly clusters: readonly VizCluster[];\n /** What filtering did. Present even when no filter was set (all kept). */\n readonly filterStats: VizFilterStats;\n /** One-line legend describing the filter, or `null` when none is in force. */\n readonly filterLegend: string | null;\n toMermaid(): string;\n toDot(): string;\n}\n\n/** Fill colour + dashed flag per status. Tweak here to restyle the whole map. */\nconst STATUS_STYLE: Readonly<\n Record<VizStatus, { readonly fill: string; readonly stroke: string; readonly dashed: boolean }>\n> = {\n law: { fill: '#cfe3f7', stroke: '#3a6ea5', dashed: false }, // textbook law — blue\n established: { fill: '#cde7d3', stroke: '#3f8f5b', dashed: false }, // solid bridge — green\n speculative: { fill: '#fdebc8', stroke: '#c9881b', dashed: false }, // amber\n 'highly-speculative': { fill: '#f5c6c6', stroke: '#c0392b', dashed: false }, // red\n proposed: { fill: '#e6e6e6', stroke: '#888888', dashed: true }, // unadjudicated — grey dashed\n user: { fill: '#e9d8fd', stroke: '#6b46c1', dashed: false }, // user-supplied — violet\n // Poster index (Atlas Phase 3). A derivation is a SOLID box: it is a stated\n // claim with a recorded relation, not an unadjudicated guess like `proposed`.\n poster: { fill: '#dbe7ff', stroke: '#4c6ef5', dashed: false }, // indigo\n // An association is DASHED because it asserts no relation at all\n // (`atlas/association.ts`): the dash is the only thing in the drawing that\n // says \"this line is a resemblance, not a claim\". Do not make it solid.\n association: { fill: '#f3f0e7', stroke: '#8d7b4f', dashed: true }, // khaki dashed\n};\n\n/** Map a `BridgeEdge` to a `VizJunction` (raw quantity names).\n *\n * The display label is the compact catalog id (`BE-<n>`) when the edge is\n * catalog-backed, else the edge's own label — a *map* reads better with short\n * junction names; the full formula stays in the catalog. */\nexport function edgeToJunction(edge: BridgeEdge): VizJunction {\n const status: VizStatus = edge.kind === 'law' ? 'law' : edge.confidence;\n return {\n id: edge.id,\n label: edge.beId != null ? `BE-${edge.beId}` : edge.label,\n status,\n sources: edge.sources.map((s) => s.name),\n target: edge.target.name,\n ...(edge.relation ? { relation: edge.relation.type } : {}),\n beId: edge.beId,\n };\n}\n\n/** How one junction fared against the filters. */\ntype FilterVerdict = 'keep' | 'not-matching' | 'missing-metadata';\n\n/** The overlay a filter reads off a junction or an edge. */\ninterface OverlayView {\n readonly relation?: RelationType;\n readonly beId?: number | null;\n}\n\nfunction judge(\n item: OverlayView,\n opts: Pick<VizOptions, 'relation' | 'evidence' | 'deriveEvidence'>,\n): FilterVerdict {\n if (opts.relation !== undefined) {\n if (item.relation === undefined) return 'missing-metadata';\n if (item.relation !== opts.relation) return 'not-matching';\n }\n if (opts.evidence !== undefined) {\n if (item.beId == null) return 'missing-metadata';\n const derive = opts.deriveEvidence;\n if (derive === undefined) {\n throw new Error(\n 'evidence filter has no deriveEvidence function; catalog derivation is not in this module',\n );\n }\n if (!derive(item.beId).has(opts.evidence)) return 'not-matching';\n }\n return 'keep';\n}\n\n/**\n * Apply the same filters `buildVizModel` applies, to a raw edge list — so the\n * TEXT map and the visual map can never disagree about what a filter selects.\n *\n * @internal — CLI support, reached through `src/cli-api.ts`.\n */\nexport function filterEdges(\n edges: readonly BridgeEdge[],\n opts: Pick<VizOptions, 'relation' | 'evidence' | 'deriveEvidence'>,\n): { readonly kept: BridgeEdge[]; readonly stats: VizFilterStats } {\n const kept: BridgeEdge[] = [];\n let droppedNotMatching = 0;\n let droppedMissingMetadata = 0;\n for (const e of edges) {\n switch (judge({ relation: e.relation?.type, beId: e.beId }, opts)) {\n case 'keep':\n kept.push(e);\n break;\n case 'not-matching':\n droppedNotMatching += 1;\n break;\n case 'missing-metadata':\n droppedMissingMetadata += 1;\n break;\n }\n }\n return {\n kept,\n stats: {\n total: edges.length,\n kept: kept.length,\n droppedNotMatching,\n droppedMissingMetadata,\n ...(opts.relation !== undefined ? { relation: opts.relation } : {}),\n ...(opts.evidence !== undefined ? { evidence: opts.evidence } : {}),\n },\n };\n}\n\n/**\n * The legend line. It always states the lacking-metadata count, including when\n * it is zero: a printed `0` says the graph was checked and nothing was hidden,\n * whereas an omitted line says nothing at all.\n *\n * @internal — CLI support, reached through `src/cli-api.ts`.\n */\nexport function formatFilterLegend(stats: VizFilterStats): string | null {\n const terms: string[] = [];\n if (stats.relation !== undefined) terms.push(`relation=${stats.relation}`);\n if (stats.evidence !== undefined) terms.push(`evidence=${stats.evidence}`);\n if (terms.length === 0) return null;\n return (\n `filter: ${terms.join(' ')} — ${stats.kept} of ${stats.total} kept; ` +\n `${stats.droppedNotMatching} dropped (did not match); ` +\n `${stats.droppedMissingMetadata} dropped (no overlay metadata)`\n );\n}\n\n/** Quantity-name canonicalizer from `QUANTITY_IDENTIFICATIONS` (matches `linkageMap`). */\nfunction makeCanon(): (name: string) => string {\n const alias = new Map(QUANTITY_IDENTIFICATIONS.map((id) => [id.from, id.to]));\n return (n) => alias.get(n) ?? n;\n}\n\n/** Distinct canonical quantity names of a junction (sources ∪ target). */\nfunction quantitiesOf(j: VizJunction): string[] {\n return [...new Set([...j.sources, j.target])];\n}\n\n/** Union-find component grouping of junctions sharing a (canonical) quantity. */\nfunction componentsOf(junctions: readonly VizJunction[]): VizCluster[] {\n const parent = junctions.map((_, i) => i);\n const find = (x: number): number =>\n parent[x] === x ? x : (parent[x] = find(parent[x]));\n const union = (a: number, b: number): void => {\n parent[find(a)] = find(b);\n };\n\n const qToJunctions = new Map<string, number[]>();\n junctions.forEach((j, i) => {\n for (const qty of quantitiesOf(j)) {\n const arr = qToJunctions.get(qty) ?? [];\n arr.push(i);\n qToJunctions.set(qty, arr);\n }\n });\n for (const idxs of qToJunctions.values()) {\n for (let k = 1; k < idxs.length; k++) union(idxs[0], idxs[k]);\n }\n\n const groups = new Map<number, number[]>();\n junctions.forEach((_, i) => {\n const r = find(i);\n const arr = groups.get(r) ?? [];\n arr.push(i);\n groups.set(r, arr);\n });\n\n const clusters = [...groups.values()].map((idxs): VizCluster => {\n const js = idxs.map((i) => junctions[i]);\n const quantities = [...new Set(js.flatMap(quantitiesOf))].sort();\n return {\n junctionIds: js.map((j) => j.id),\n quantities,\n size: js.length,\n // DELIBERATE: only `law` and `established` anchor. A `poster`,\n // `association`, `proposed` or `user` junction never does — the poster\n // index maps claims and their supports, it does not assert that any of\n // them is textbook physics. Widening this would make an unanchored\n // cluster read as anchored the moment a poster overlay touched it.\n anchored: js.some((j) => j.status === 'law' || j.status === 'established'),\n };\n });\n // Deterministic: largest first, then by first junction id.\n clusters.sort(\n (a, b) => b.size - a.size || a.junctionIds[0].localeCompare(b.junctionIds[0]),\n );\n return clusters;\n}\n\n/** A stable, collision-free id factory mapping arbitrary keys to safe ids. */\nfunction idFactory(prefix: string): (key: string) => string {\n const seen = new Map<string, string>();\n const used = new Set<string>();\n return (key) => {\n const cached = seen.get(key);\n if (cached) return cached;\n const base = `${prefix}_${key.replace(/[^A-Za-z0-9]/g, '_')}`;\n let id = base;\n let n = 1;\n while (used.has(id)) id = `${base}_${n++}`;\n used.add(id);\n seen.set(key, id);\n return id;\n };\n}\n\n/** Escape a label for Mermaid `[\"…\"]` — XML-entity-encode the characters that\n * break the quoted form or are read as entities (`&`, `\"`, `<`, `>`). */\nconst mmLabel = (s: string): string =>\n s\n .replace(/\\r\\n|\\r|\\n/g, ' ')\n .replace(/&/g, '&')\n .replace(/\"/g, '"')\n .replace(/</g, '<')\n .replace(/>/g, '>');\n/** Escape a label for a DOT double-quoted string. */\nconst dotLabel = (s: string): string =>\n s.replace(/\\r\\n|\\r|\\n/g, ' ').replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"');\n\n/**\n * Mermaid `classDef` emission order.\n *\n * ⚠ A plain array, so a status MISSING here does not fail to compile — it\n * silently omits that status's `classDef` and the node renders unstyled. That\n * is why `ALL_VIZ_STATUSES` exists and why a test compares the two sets.\n */\nconst STATUSES_IN_ORDER: readonly VizStatus[] = [\n 'law',\n 'established',\n 'speculative',\n 'highly-speculative',\n 'proposed',\n 'user',\n 'poster',\n 'association',\n];\n\n/**\n * Drive a format-specific cluster renderer over the standard layout, identical\n * for both emitters: multi-junction components first (each its own subgraph,\n * keyed `0`,`1`,…, labelled `anchored cluster (n)` / `cluster (n)`), then a\n * single `iso` subgraph collecting all singletons. The callback owns all\n * per-format string production; this owns only the traversal and labelling.\n */\nfunction forEachClusterGroup(\n clusters: readonly VizCluster[],\n renderCluster: (label: string, junctionIds: readonly string[], key: string) => void,\n): void {\n const multi = clusters.filter((c) => c.size > 1);\n const singletons = clusters.filter((c) => c.size === 1);\n multi.forEach((c, i) =>\n renderCluster(`${c.anchored ? 'anchored ' : ''}cluster (${c.size})`, c.junctionIds, String(i)),\n );\n if (singletons.length) {\n renderCluster(\n `isolated (${singletons.length})`,\n singletons.flatMap((c) => c.junctionIds),\n 'iso',\n );\n }\n}\n\nfunction emitMermaid(\n clusters: readonly VizCluster[],\n byId: ReadonlyMap<string, VizJunction>,\n title: string,\n legend: string | null,\n): string {\n const qid = idFactory('q');\n const jid = idFactory('j');\n const usedStatuses = new Set<VizStatus>();\n const out: string[] = [`flowchart LR`, `%% ${title}`];\n // The legend is a comment AND a rendered node: a comment alone disappears in\n // every renderer, and a filtered map that does not say it is filtered reads\n // as the whole graph.\n if (legend !== null) out.push(`%% ${legend}`);\n\n const renderCluster = (label: string, junctionIds: readonly string[], key: string): void => {\n out.push(` subgraph cl_${key}[\"${mmLabel(label)}\"]`);\n out.push(` direction LR`);\n const declared = new Set<string>();\n const declareQ = (name: string): string => {\n const id = qid(name);\n if (!declared.has(id)) {\n out.push(` ${id}([\"${mmLabel(name)}\"]):::qty`);\n declared.add(id);\n }\n return id;\n };\n for (const id of junctionIds) {\n const j = byId.get(id)!;\n usedStatuses.add(j.status);\n const jId = jid(j.id);\n out.push(` ${jId}[\"${mmLabel(j.label)}\"]:::${j.status}`);\n for (const s of j.sources) out.push(` ${declareQ(s)} --> ${jId}`);\n out.push(` ${jId} --> ${declareQ(j.target)}`);\n }\n out.push(` end`);\n };\n\n forEachClusterGroup(clusters, renderCluster);\n\n if (legend !== null) out.push(` legend[\"${mmLabel(legend)}\"]:::legend`);\n\n for (const st of STATUSES_IN_ORDER) {\n if (!usedStatuses.has(st)) continue;\n const { fill, stroke, dashed } = STATUS_STYLE[st];\n out.push(\n ` classDef ${st} fill:${fill},stroke:${stroke}${dashed ? ',stroke-dasharray:4 3' : ''}`,\n );\n }\n out.push(` classDef qty fill:#ffffff,stroke:#999999`);\n if (legend !== null) out.push(` classDef legend fill:#ffffff,stroke:#333333`);\n return out.join('\\n') + '\\n';\n}\n\nfunction emitDot(\n clusters: readonly VizCluster[],\n byId: ReadonlyMap<string, VizJunction>,\n title: string,\n legend: string | null,\n): string {\n const qid = idFactory('q');\n const jid = idFactory('j');\n const out: string[] = [\n `digraph PhysicsMap {`,\n // DOT's label is a single quoted string and `dotLabel` collapses newlines,\n // so the legend joins the title on one line rather than being dropped.\n ` label=\"${dotLabel(legend === null ? title : `${title} — ${legend}`)}\";`,\n ` rankdir=LR;`,\n ` node [fontname=\"Helvetica\"];`,\n ];\n\n const renderCluster = (label: string, junctionIds: readonly string[], key: string): void => {\n out.push(` subgraph cluster_${key} {`);\n out.push(` label=\"${dotLabel(label)}\";`);\n const declared = new Set<string>();\n const declareQ = (name: string): string => {\n const id = qid(name);\n if (!declared.has(id)) {\n out.push(` ${id} [shape=ellipse,label=\"${dotLabel(name)}\"];`);\n declared.add(id);\n }\n return id;\n };\n for (const id of junctionIds) {\n const j = byId.get(id)!;\n const jId = jid(j.id);\n const { fill, stroke, dashed } = STATUS_STYLE[j.status];\n const style = dashed ? 'filled,dashed' : 'filled';\n out.push(\n ` ${jId} [shape=box,style=\"${style}\",fillcolor=\"${fill}\",color=\"${stroke}\",label=\"${dotLabel(\n j.label,\n )}\"];`,\n );\n for (const s of j.sources) out.push(` ${declareQ(s)} -> ${jId};`);\n out.push(` ${jId} -> ${declareQ(j.target)};`);\n }\n out.push(` }`);\n };\n\n forEachClusterGroup(clusters, renderCluster);\n out.push(`}`);\n return out.join('\\n') + '\\n';\n}\n\n/**\n * Build the bipartite, clustered render model from a graph (+ optional overlay).\n * Quantity names are canonicalized via `QUANTITY_IDENTIFICATIONS` so the\n * clustering matches the authoritative {@link linkageMap}.\n *\n * @public\n */\nexport function buildVizModel(\n edges: readonly BridgeEdge[],\n opts: VizOptions = {},\n): VizModel {\n const canon = makeCanon();\n const normalize = (j: VizJunction): VizJunction => ({\n ...j,\n sources: j.sources.map(canon),\n target: canon(j.target),\n });\n const all: VizJunction[] = [\n ...edges.map((e) => normalize(edgeToJunction(e))),\n ...(opts.extraJunctions ?? []).map(normalize),\n ];\n // Filtering is applied to the OVERLAY junctions too. A proposed or\n // user-supplied junction carries no relation and no beId, so a filtered map\n // drops it as lacking metadata — the same rule as any other edge, and the\n // count says so out loud rather than letting the overlay vanish quietly.\n const junctions: VizJunction[] = [];\n let droppedNotMatching = 0;\n let droppedMissingMetadata = 0;\n for (const j of all) {\n switch (judge(j, opts)) {\n case 'keep':\n junctions.push(j);\n break;\n case 'not-matching':\n droppedNotMatching += 1;\n break;\n case 'missing-metadata':\n droppedMissingMetadata += 1;\n break;\n }\n }\n const filterStats: VizFilterStats = {\n total: all.length,\n kept: junctions.length,\n droppedNotMatching,\n droppedMissingMetadata,\n ...(opts.relation !== undefined ? { relation: opts.relation } : {}),\n ...(opts.evidence !== undefined ? { evidence: opts.evidence } : {}),\n };\n const filterLegend = formatFilterLegend(filterStats);\n // A duplicate junction id (e.g. a proposed overlay colliding with an edge id)\n // would silently drop one from the rendered output — make it a loud error.\n const byId = new Map<string, VizJunction>();\n for (const j of junctions) {\n if (byId.has(j.id)) {\n throw new Error(`buildVizModel: duplicate junction id '${j.id}'`);\n }\n byId.set(j.id, j);\n }\n const clusters = componentsOf(junctions);\n const title = opts.title ?? 'UPT physics map';\n\n return {\n junctions,\n clusters,\n filterStats,\n filterLegend,\n toMermaid: () => emitMermaid(clusters, byId, title, filterLegend),\n toDot: () => emitDot(clusters, byId, title, filterLegend),\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"graph-viz.js","sourceRoot":"","sources":["../../src/composition/graph-viz.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAoBpF;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAyB;IACpD,KAAK;IACL,aAAa;IACb,aAAa;IACb,oBAAoB;IACpB,UAAU;IACV,MAAM;IACN,QAAQ;IACR,aAAa;CACd,CAAC;AAqIF,iFAAiF;AACjF,MAAM,YAAY,GAEd;IACF,GAAG,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,sBAAsB;IAClF,WAAW,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AAC;IACD,MAAM,QAAQ,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;IACzC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,iBAAiB,CAAC;IAE9C,OAAO;QACL,SAAS;QACT,QAAQ;QACR,WAAW;QACX,YAAY;QACZ,SAAS,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,CAAC;QACjE,KAAK,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,CAAC;KAC1D,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Physics-map visualization — turn the composition hypergraph into Mermaid and\n * Graphviz-DOT **source text**.\n *\n * The graph is bipartite in the drawing: round nodes are *quantities*\n * (`mass`, `temperature`, …) and box nodes are *equations* — laws, bridges, or\n * proposed relations — each an n-ary junction (its source quantities point in,\n * its target points out). This makes \"equations as junctions\" literal and draws\n * n-ary edges faithfully (a single Mermaid/DOT edge can only connect two nodes).\n *\n * The model computes its own connected components over the junctions — so a\n * `--proposed` overlay participates in the clustering — and groups each component\n * into its own subgraph so the genuinely disjointed map stays legible. For the\n * pure-`BridgeEdge` case the component count matches the authoritative\n * {@link linkageMap} (pinned by a drift-guard test).\n *\n * Pure string production: no file I/O (the CLI is the only file-touching layer).\n *\n * @module composition/graph-viz\n */\n\nimport type { BridgeEdge } from './edge.js';\nimport { clusterBySharedKeys, quantityCanonicalizer } from './quantity-clusters.js';\nimport type { EvidenceTag, RelationType } from '../relations/types.js';\n\n/**\n * Epistemic status of a junction — drives node colour/shape. Bridges carry\n * their catalog confidence; `law` is a diagonal/established-physics edge;\n * `proposed` is a machine-derived, unadjudicated relation (rendered quarantined).\n *\n * @public\n */\nexport type VizStatus =\n | 'law'\n | 'established'\n | 'speculative'\n | 'highly-speculative'\n | 'proposed'\n | 'user'\n | 'poster'\n | 'association';\n\n/**\n * Every `VizStatus`, as VALUES.\n *\n * Exists so the union can be pinned at RUNTIME. `VizStatus` is a type: the\n * public-surface test pins its NAME and nothing pins its MEMBERS, so widening\n * it is invisible to every existing test. This array is what the three places\n * a status must be registered are checked against — `STATUS_STYLE` (a compile\n * error when incomplete), `STATUSES_IN_ORDER` (a plain array that would\n * SILENTLY omit a Mermaid `classDef`), and the published surface.\n *\n * @internal\n */\nexport const ALL_VIZ_STATUSES: readonly VizStatus[] = [\n 'law',\n 'established',\n 'speculative',\n 'highly-speculative',\n 'proposed',\n 'user',\n 'poster',\n 'association',\n];\n\n/**\n * A normalized equation junction: n source quantities → 1 target. The render\n * model's unit of \"equation\", decoupled from both `BridgeEdge` and the internal\n * `ProposedBridge` type (the CLI converts each into this shape).\n *\n * @public\n */\nexport interface VizJunction {\n /** Graph id, e.g. `'be-42'` or `'IC-…'`. */\n readonly id: string;\n /** Short human label. */\n readonly label: string;\n readonly status: VizStatus;\n /** Source quantity names. */\n readonly sources: readonly string[];\n /** Target quantity name. */\n readonly target: string;\n /**\n * The Atlas Phase 1 relation TYPE this junction's edge records, when one was\n * recorded. Absent means \"nobody has audited this edge\", which is a\n * different statement from \"this edge is not an approximation\" — the\n * filtering in {@link buildVizModel} keeps the two apart and counts them\n * separately.\n */\n readonly relation?: RelationType;\n /**\n * The catalog id this junction's edge cross-references, when it has one.\n * Carried so evidence can be DERIVED at read time; no evidence tag is ever\n * stored on a junction.\n */\n readonly beId?: number | null;\n}\n\n/**\n * Why junctions were left out of a filtered map.\n *\n * The two dropped counts are SEPARATE on purpose. An edge dropped for not\n * matching the filter answered the question; an edge dropped for carrying no\n * overlay never got asked. Folding them together would let an unaudited graph\n * render as a complete answer to a question nobody could put to it.\n *\n * @public\n */\nexport interface VizFilterStats {\n /** Junctions considered, before filtering. */\n readonly total: number;\n /** Junctions rendered. */\n readonly kept: number;\n /** Dropped because their recorded metadata did not match the filter. */\n readonly droppedNotMatching: number;\n /** Dropped because they carry no metadata the filter could read. */\n readonly droppedMissingMetadata: number;\n /** The `relation` filter in force, if any. */\n readonly relation?: RelationType;\n /** The `evidence` filter in force, if any. */\n readonly evidence?: EvidenceTag;\n}\n\n/**\n * One connected component of the bipartite graph.\n *\n * @public\n */\nexport interface VizCluster {\n /** Junction ids in this component. */\n readonly junctionIds: readonly string[];\n /** Distinct (canonical) quantity names touched by this component. */\n readonly quantities: readonly string[];\n /** Number of junctions (the cluster \"size\", matching `linkageMap`). */\n readonly size: number;\n /** Contains a `law`/`established` junction (anchored to known physics). */\n readonly anchored: boolean;\n}\n\n/**\n * Options for {@link buildVizModel}.\n *\n * @public\n */\nexport interface VizOptions {\n /** Diagram title (used as the graph label). */\n readonly title?: string;\n /** Already-normalized extra junctions to overlay (e.g. proposed relations). */\n readonly extraJunctions?: readonly VizJunction[];\n /**\n * Keep only junctions whose recorded relation is this type.\n *\n * ⚠ Setting ANY filter changes what a missing overlay MEANS. Unfiltered, an\n * edge with no `relation` is kept — the map is about connectivity and an\n * unaudited edge still connects. Filtered, it is dropped, because it cannot\n * be shown to satisfy the filter. The count of those drops is reported\n * separately in {@link VizFilterStats} and printed in the legend.\n */\n readonly relation?: RelationType;\n /**\n * Keep only junctions whose DERIVED evidence set contains this tag.\n *\n * Evidence is never stored. It is derived from the catalog row named by the\n * junction's `beId`, every time it is asked for; a junction with no numeric\n * `beId` cannot be evaluated and counts as LACKING metadata, not as\n * non-matching.\n */\n readonly evidence?: EvidenceTag;\n /**\n * The derivation used when `evidence` is set. The catalog derivation lives\n * with the CLI (`cli/map-evidence.ts`), which passes it. This module does\n * not import that derivation. A junction with a numeric `beId` and no\n * function here cannot be evaluated, and the filter throws rather than\n * rendering an unfiltered map as a filtered one. A junction with no numeric\n * `beId` is lacking metadata and does not call the function.\n */\n readonly deriveEvidence?: (beId: number) => ReadonlySet<EvidenceTag>;\n}\n\n/**\n * The render model: normalized junctions, their connected components, and the\n * two serializers.\n *\n * @public\n */\nexport interface VizModel {\n readonly junctions: readonly VizJunction[];\n readonly clusters: readonly VizCluster[];\n /** What filtering did. Present even when no filter was set (all kept). */\n readonly filterStats: VizFilterStats;\n /** One-line legend describing the filter, or `null` when none is in force. */\n readonly filterLegend: string | null;\n toMermaid(): string;\n toDot(): string;\n}\n\n/** Fill colour + dashed flag per status. Tweak here to restyle the whole map. */\nconst STATUS_STYLE: Readonly<\n Record<VizStatus, { readonly fill: string; readonly stroke: string; readonly dashed: boolean }>\n> = {\n law: { fill: '#cfe3f7', stroke: '#3a6ea5', dashed: false }, // textbook law — blue\n established: { fill: '#cde7d3', stroke: '#3f8f5b', dashed: false }, // solid bridge — green\n speculative: { fill: '#fdebc8', stroke: '#c9881b', dashed: false }, // amber\n 'highly-speculative': { fill: '#f5c6c6', stroke: '#c0392b', dashed: false }, // red\n proposed: { fill: '#e6e6e6', stroke: '#888888', dashed: true }, // unadjudicated — grey dashed\n user: { fill: '#e9d8fd', stroke: '#6b46c1', dashed: false }, // user-supplied — violet\n // Poster index (Atlas Phase 3). A derivation is a SOLID box: it is a stated\n // claim with a recorded relation, not an unadjudicated guess like `proposed`.\n poster: { fill: '#dbe7ff', stroke: '#4c6ef5', dashed: false }, // indigo\n // An association is DASHED because it asserts no relation at all\n // (`atlas/association.ts`): the dash is the only thing in the drawing that\n // says \"this line is a resemblance, not a claim\". Do not make it solid.\n association: { fill: '#f3f0e7', stroke: '#8d7b4f', dashed: true }, // khaki dashed\n};\n\n/** Map a `BridgeEdge` to a `VizJunction` (raw quantity names).\n *\n * The display label is the compact catalog id (`BE-<n>`) when the edge is\n * catalog-backed, else the edge's own label — a *map* reads better with short\n * junction names; the full formula stays in the catalog. */\nexport function edgeToJunction(edge: BridgeEdge): VizJunction {\n const status: VizStatus = edge.kind === 'law' ? 'law' : edge.confidence;\n return {\n id: edge.id,\n label: edge.beId != null ? `BE-${edge.beId}` : edge.label,\n status,\n sources: edge.sources.map((s) => s.name),\n target: edge.target.name,\n ...(edge.relation ? { relation: edge.relation.type } : {}),\n beId: edge.beId,\n };\n}\n\n/** How one junction fared against the filters. */\ntype FilterVerdict = 'keep' | 'not-matching' | 'missing-metadata';\n\n/** The overlay a filter reads off a junction or an edge. */\ninterface OverlayView {\n readonly relation?: RelationType;\n readonly beId?: number | null;\n}\n\nfunction judge(\n item: OverlayView,\n opts: Pick<VizOptions, 'relation' | 'evidence' | 'deriveEvidence'>,\n): FilterVerdict {\n if (opts.relation !== undefined) {\n if (item.relation === undefined) return 'missing-metadata';\n if (item.relation !== opts.relation) return 'not-matching';\n }\n if (opts.evidence !== undefined) {\n if (item.beId == null) return 'missing-metadata';\n const derive = opts.deriveEvidence;\n if (derive === undefined) {\n throw new Error(\n 'evidence filter has no deriveEvidence function; catalog derivation is not in this module',\n );\n }\n if (!derive(item.beId).has(opts.evidence)) return 'not-matching';\n }\n return 'keep';\n}\n\n/**\n * Apply the same filters `buildVizModel` applies, to a raw edge list — so the\n * TEXT map and the visual map can never disagree about what a filter selects.\n *\n * @internal — CLI support, reached through `src/cli-api.ts`.\n */\nexport function filterEdges(\n edges: readonly BridgeEdge[],\n opts: Pick<VizOptions, 'relation' | 'evidence' | 'deriveEvidence'>,\n): { readonly kept: BridgeEdge[]; readonly stats: VizFilterStats } {\n const kept: BridgeEdge[] = [];\n let droppedNotMatching = 0;\n let droppedMissingMetadata = 0;\n for (const e of edges) {\n switch (judge({ relation: e.relation?.type, beId: e.beId }, opts)) {\n case 'keep':\n kept.push(e);\n break;\n case 'not-matching':\n droppedNotMatching += 1;\n break;\n case 'missing-metadata':\n droppedMissingMetadata += 1;\n break;\n }\n }\n return {\n kept,\n stats: {\n total: edges.length,\n kept: kept.length,\n droppedNotMatching,\n droppedMissingMetadata,\n ...(opts.relation !== undefined ? { relation: opts.relation } : {}),\n ...(opts.evidence !== undefined ? { evidence: opts.evidence } : {}),\n },\n };\n}\n\n/**\n * The legend line. It always states the lacking-metadata count, including when\n * it is zero: a printed `0` says the graph was checked and nothing was hidden,\n * whereas an omitted line says nothing at all.\n *\n * @internal — CLI support, reached through `src/cli-api.ts`.\n */\nexport function formatFilterLegend(stats: VizFilterStats): string | null {\n const terms: string[] = [];\n if (stats.relation !== undefined) terms.push(`relation=${stats.relation}`);\n if (stats.evidence !== undefined) terms.push(`evidence=${stats.evidence}`);\n if (terms.length === 0) return null;\n return (\n `filter: ${terms.join(' ')} — ${stats.kept} of ${stats.total} kept; ` +\n `${stats.droppedNotMatching} dropped (did not match); ` +\n `${stats.droppedMissingMetadata} dropped (no overlay metadata)`\n );\n}\n\n/** Distinct canonical quantity names of a junction (sources ∪ target). */\nfunction quantitiesOf(j: VizJunction): string[] {\n return [...new Set([...j.sources, j.target])];\n}\n\n/**\n * Component grouping of junctions sharing a (canonical) quantity: the shared partition of\n * `quantity-clusters.ts`, in the order the map always drew (largest first, then by first\n * junction id; input order inside). The anchoring rule below is this module's own.\n */\nfunction componentsOf(junctions: readonly VizJunction[]): VizCluster[] {\n return clusterBySharedKeys(junctions, quantitiesOf, (j) => j.id).map((js): VizCluster => {\n const quantities = [...new Set(js.flatMap(quantitiesOf))].sort();\n return {\n junctionIds: js.map((j) => j.id),\n quantities,\n size: js.length,\n // DELIBERATE: only `law` and `established` anchor. A `poster`,\n // `association`, `proposed` or `user` junction never does — the poster\n // index maps claims and their supports, it does not assert that any of\n // them is textbook physics. Widening this would make an unanchored\n // cluster read as anchored the moment a poster overlay touched it.\n anchored: js.some((j) => j.status === 'law' || j.status === 'established'),\n };\n });\n}\n\n/** A stable, collision-free id factory mapping arbitrary keys to safe ids. */\nfunction idFactory(prefix: string): (key: string) => string {\n const seen = new Map<string, string>();\n const used = new Set<string>();\n return (key) => {\n const cached = seen.get(key);\n if (cached) return cached;\n const base = `${prefix}_${key.replace(/[^A-Za-z0-9]/g, '_')}`;\n let id = base;\n let n = 1;\n while (used.has(id)) id = `${base}_${n++}`;\n used.add(id);\n seen.set(key, id);\n return id;\n };\n}\n\n/** Escape a label for Mermaid `[\"…\"]` — XML-entity-encode the characters that\n * break the quoted form or are read as entities (`&`, `\"`, `<`, `>`). */\nconst mmLabel = (s: string): string =>\n s\n .replace(/\\r\\n|\\r|\\n/g, ' ')\n .replace(/&/g, '&')\n .replace(/\"/g, '"')\n .replace(/</g, '<')\n .replace(/>/g, '>');\n/** Escape a label for a DOT double-quoted string. */\nconst dotLabel = (s: string): string =>\n s.replace(/\\r\\n|\\r|\\n/g, ' ').replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"');\n\n/**\n * Mermaid `classDef` emission order.\n *\n * ⚠ A plain array, so a status MISSING here does not fail to compile — it\n * silently omits that status's `classDef` and the node renders unstyled. That\n * is why `ALL_VIZ_STATUSES` exists and why a test compares the two sets.\n */\nconst STATUSES_IN_ORDER: readonly VizStatus[] = [\n 'law',\n 'established',\n 'speculative',\n 'highly-speculative',\n 'proposed',\n 'user',\n 'poster',\n 'association',\n];\n\n/**\n * Drive a format-specific cluster renderer over the standard layout, identical\n * for both emitters: multi-junction components first (each its own subgraph,\n * keyed `0`,`1`,…, labelled `anchored cluster (n)` / `cluster (n)`), then a\n * single `iso` subgraph collecting all singletons. The callback owns all\n * per-format string production; this owns only the traversal and labelling.\n */\nfunction forEachClusterGroup(\n clusters: readonly VizCluster[],\n renderCluster: (label: string, junctionIds: readonly string[], key: string) => void,\n): void {\n const multi = clusters.filter((c) => c.size > 1);\n const singletons = clusters.filter((c) => c.size === 1);\n multi.forEach((c, i) =>\n renderCluster(`${c.anchored ? 'anchored ' : ''}cluster (${c.size})`, c.junctionIds, String(i)),\n );\n if (singletons.length) {\n renderCluster(\n `isolated (${singletons.length})`,\n singletons.flatMap((c) => c.junctionIds),\n 'iso',\n );\n }\n}\n\nfunction emitMermaid(\n clusters: readonly VizCluster[],\n byId: ReadonlyMap<string, VizJunction>,\n title: string,\n legend: string | null,\n): string {\n const qid = idFactory('q');\n const jid = idFactory('j');\n const usedStatuses = new Set<VizStatus>();\n const out: string[] = [`flowchart LR`, `%% ${title}`];\n // The legend is a comment AND a rendered node: a comment alone disappears in\n // every renderer, and a filtered map that does not say it is filtered reads\n // as the whole graph.\n if (legend !== null) out.push(`%% ${legend}`);\n\n const renderCluster = (label: string, junctionIds: readonly string[], key: string): void => {\n out.push(` subgraph cl_${key}[\"${mmLabel(label)}\"]`);\n out.push(` direction LR`);\n const declared = new Set<string>();\n const declareQ = (name: string): string => {\n const id = qid(name);\n if (!declared.has(id)) {\n out.push(` ${id}([\"${mmLabel(name)}\"]):::qty`);\n declared.add(id);\n }\n return id;\n };\n for (const id of junctionIds) {\n const j = byId.get(id)!;\n usedStatuses.add(j.status);\n const jId = jid(j.id);\n out.push(` ${jId}[\"${mmLabel(j.label)}\"]:::${j.status}`);\n for (const s of j.sources) out.push(` ${declareQ(s)} --> ${jId}`);\n out.push(` ${jId} --> ${declareQ(j.target)}`);\n }\n out.push(` end`);\n };\n\n forEachClusterGroup(clusters, renderCluster);\n\n if (legend !== null) out.push(` legend[\"${mmLabel(legend)}\"]:::legend`);\n\n for (const st of STATUSES_IN_ORDER) {\n if (!usedStatuses.has(st)) continue;\n const { fill, stroke, dashed } = STATUS_STYLE[st];\n out.push(\n ` classDef ${st} fill:${fill},stroke:${stroke}${dashed ? ',stroke-dasharray:4 3' : ''}`,\n );\n }\n out.push(` classDef qty fill:#ffffff,stroke:#999999`);\n if (legend !== null) out.push(` classDef legend fill:#ffffff,stroke:#333333`);\n return out.join('\\n') + '\\n';\n}\n\nfunction emitDot(\n clusters: readonly VizCluster[],\n byId: ReadonlyMap<string, VizJunction>,\n title: string,\n legend: string | null,\n): string {\n const qid = idFactory('q');\n const jid = idFactory('j');\n const out: string[] = [\n `digraph PhysicsMap {`,\n // DOT's label is a single quoted string and `dotLabel` collapses newlines,\n // so the legend joins the title on one line rather than being dropped.\n ` label=\"${dotLabel(legend === null ? title : `${title} — ${legend}`)}\";`,\n ` rankdir=LR;`,\n ` node [fontname=\"Helvetica\"];`,\n ];\n\n const renderCluster = (label: string, junctionIds: readonly string[], key: string): void => {\n out.push(` subgraph cluster_${key} {`);\n out.push(` label=\"${dotLabel(label)}\";`);\n const declared = new Set<string>();\n const declareQ = (name: string): string => {\n const id = qid(name);\n if (!declared.has(id)) {\n out.push(` ${id} [shape=ellipse,label=\"${dotLabel(name)}\"];`);\n declared.add(id);\n }\n return id;\n };\n for (const id of junctionIds) {\n const j = byId.get(id)!;\n const jId = jid(j.id);\n const { fill, stroke, dashed } = STATUS_STYLE[j.status];\n const style = dashed ? 'filled,dashed' : 'filled';\n out.push(\n ` ${jId} [shape=box,style=\"${style}\",fillcolor=\"${fill}\",color=\"${stroke}\",label=\"${dotLabel(\n j.label,\n )}\"];`,\n );\n for (const s of j.sources) out.push(` ${declareQ(s)} -> ${jId};`);\n out.push(` ${jId} -> ${declareQ(j.target)};`);\n }\n out.push(` }`);\n };\n\n forEachClusterGroup(clusters, renderCluster);\n out.push(`}`);\n return out.join('\\n') + '\\n';\n}\n\n/**\n * Build the bipartite, clustered render model from a graph (+ optional overlay).\n * Quantity names are canonicalized via `QUANTITY_IDENTIFICATIONS` so the\n * clustering matches the authoritative {@link linkageMap}.\n *\n * @public\n */\nexport function buildVizModel(\n edges: readonly BridgeEdge[],\n opts: VizOptions = {},\n): VizModel {\n const canon = quantityCanonicalizer();\n const normalize = (j: VizJunction): VizJunction => ({\n ...j,\n sources: j.sources.map(canon),\n target: canon(j.target),\n });\n const all: VizJunction[] = [\n ...edges.map((e) => normalize(edgeToJunction(e))),\n ...(opts.extraJunctions ?? []).map(normalize),\n ];\n // Filtering is applied to the OVERLAY junctions too. A proposed or\n // user-supplied junction carries no relation and no beId, so a filtered map\n // drops it as lacking metadata — the same rule as any other edge, and the\n // count says so out loud rather than letting the overlay vanish quietly.\n const junctions: VizJunction[] = [];\n let droppedNotMatching = 0;\n let droppedMissingMetadata = 0;\n for (const j of all) {\n switch (judge(j, opts)) {\n case 'keep':\n junctions.push(j);\n break;\n case 'not-matching':\n droppedNotMatching += 1;\n break;\n case 'missing-metadata':\n droppedMissingMetadata += 1;\n break;\n }\n }\n const filterStats: VizFilterStats = {\n total: all.length,\n kept: junctions.length,\n droppedNotMatching,\n droppedMissingMetadata,\n ...(opts.relation !== undefined ? { relation: opts.relation } : {}),\n ...(opts.evidence !== undefined ? { evidence: opts.evidence } : {}),\n };\n const filterLegend = formatFilterLegend(filterStats);\n // A duplicate junction id (e.g. a proposed overlay colliding with an edge id)\n // would silently drop one from the rendered output — make it a loud error.\n const byId = new Map<string, VizJunction>();\n for (const j of junctions) {\n if (byId.has(j.id)) {\n throw new Error(`buildVizModel: duplicate junction id '${j.id}'`);\n }\n byId.set(j.id, j);\n }\n const clusters = componentsOf(junctions);\n const title = opts.title ?? 'UPT physics map';\n\n return {\n junctions,\n clusters,\n filterStats,\n filterLegend,\n toMermaid: () => emitMermaid(clusters, byId, title, filterLegend),\n toDot: () => emitDot(clusters, byId, title, filterLegend),\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grounding.d.ts","sourceRoot":"","sources":["../../src/composition/grounding.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"grounding.d.ts","sourceRoot":"","sources":["../../src/composition/grounding.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,0EAA0E;AAC1E,MAAM,WAAW,kBAAkB;IACjC,mEAAmE;IACnE,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,oFAAoF;IACpF,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,eAAe,EAAE,KAAK,CAAC;IAChC;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAC,UAAU,EAAE,KAAK,CAAC;C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