universal-physics-tensor 0.44.1 → 0.44.2
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 +51 -164
- package/dist/bridges/bridge-equations.d.ts +28 -6
- package/dist/bridges/bridge-equations.d.ts.map +1 -1
- package/dist/bridges/bridge-equations.js +30 -8
- package/dist/bridges/bridge-equations.js.map +1 -1
- package/dist/cli/commands/index.d.ts +1 -0
- package/dist/cli/commands/index.d.ts.map +1 -1
- package/dist/cli/commands/index.js +1 -0
- package/dist/cli/commands/index.js.map +1 -1
- package/dist/cli/commands/probe.d.ts +3 -0
- package/dist/cli/commands/probe.d.ts.map +1 -0
- package/dist/cli/commands/probe.js +169 -0
- package/dist/cli/commands/probe.js.map +1 -0
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +5 -0
- package/dist/cli/main.js.map +1 -1
- package/dist/cli-api.d.ts +1 -0
- package/dist/cli-api.d.ts.map +1 -1
- package/dist/cli-api.js +3 -0
- package/dist/cli-api.js.map +1 -1
- package/dist/composition/probe/backend-protocol.d.ts +31 -0
- package/dist/composition/probe/backend-protocol.d.ts.map +1 -0
- package/dist/composition/probe/backend-protocol.js +83 -0
- package/dist/composition/probe/backend-protocol.js.map +1 -0
- package/dist/composition/probe/candidate-store.d.ts +33 -0
- package/dist/composition/probe/candidate-store.d.ts.map +1 -0
- package/dist/composition/probe/candidate-store.js +110 -0
- package/dist/composition/probe/candidate-store.js.map +1 -0
- package/dist/composition/probe/corpus.d.ts +23 -0
- package/dist/composition/probe/corpus.d.ts.map +1 -0
- package/dist/composition/probe/corpus.js +51 -0
- package/dist/composition/probe/corpus.js.map +1 -0
- package/dist/composition/probe/dataset.d.ts +35 -0
- package/dist/composition/probe/dataset.d.ts.map +1 -0
- package/dist/composition/probe/dataset.js +154 -0
- package/dist/composition/probe/dataset.js.map +1 -0
- package/dist/composition/probe/experiment-design.d.ts +32 -0
- package/dist/composition/probe/experiment-design.d.ts.map +1 -0
- package/dist/composition/probe/experiment-design.js +86 -0
- package/dist/composition/probe/experiment-design.js.map +1 -0
- package/dist/composition/probe/falsify.d.ts +29 -0
- package/dist/composition/probe/falsify.d.ts.map +1 -0
- package/dist/composition/probe/falsify.js +142 -0
- package/dist/composition/probe/falsify.js.map +1 -0
- package/dist/composition/probe/fingerprint.d.ts +20 -0
- package/dist/composition/probe/fingerprint.d.ts.map +1 -0
- package/dist/composition/probe/fingerprint.js +99 -0
- package/dist/composition/probe/fingerprint.js.map +1 -0
- package/dist/composition/probe/fit.d.ts +23 -0
- package/dist/composition/probe/fit.d.ts.map +1 -0
- package/dist/composition/probe/fit.js +92 -0
- package/dist/composition/probe/fit.js.map +1 -0
- package/dist/composition/probe/frontier.d.ts +30 -0
- package/dist/composition/probe/frontier.d.ts.map +1 -0
- package/dist/composition/probe/frontier.js +169 -0
- package/dist/composition/probe/frontier.js.map +1 -0
- package/dist/composition/probe/generator.d.ts +26 -0
- package/dist/composition/probe/generator.d.ts.map +1 -0
- package/dist/composition/probe/generator.js +123 -0
- package/dist/composition/probe/generator.js.map +1 -0
- package/dist/composition/probe/index.d.ts +49 -0
- package/dist/composition/probe/index.d.ts.map +1 -0
- package/dist/composition/probe/index.js +35 -0
- package/dist/composition/probe/index.js.map +1 -0
- package/dist/composition/probe/limits.d.ts +27 -0
- package/dist/composition/probe/limits.d.ts.map +1 -0
- package/dist/composition/probe/limits.js +71 -0
- package/dist/composition/probe/limits.js.map +1 -0
- package/dist/composition/probe/metadata.d.ts +19 -0
- package/dist/composition/probe/metadata.d.ts.map +1 -0
- package/dist/composition/probe/metadata.js +30 -0
- package/dist/composition/probe/metadata.js.map +1 -0
- package/dist/composition/probe/pipeline.d.ts +42 -0
- package/dist/composition/probe/pipeline.d.ts.map +1 -0
- package/dist/composition/probe/pipeline.js +307 -0
- package/dist/composition/probe/pipeline.js.map +1 -0
- package/dist/composition/probe/problem.d.ts +40 -0
- package/dist/composition/probe/problem.d.ts.map +1 -0
- package/dist/composition/probe/problem.js +101 -0
- package/dist/composition/probe/problem.js.map +1 -0
- package/dist/composition/probe/report.d.ts +15 -0
- package/dist/composition/probe/report.d.ts.map +1 -0
- package/dist/composition/probe/report.js +91 -0
- package/dist/composition/probe/report.js.map +1 -0
- package/dist/composition/probe/residual.d.ts +20 -0
- package/dist/composition/probe/residual.d.ts.map +1 -0
- package/dist/composition/probe/residual.js +72 -0
- package/dist/composition/probe/residual.js.map +1 -0
- package/dist/composition/probe/run-manifest.d.ts +24 -0
- package/dist/composition/probe/run-manifest.d.ts.map +1 -0
- package/dist/composition/probe/run-manifest.js +48 -0
- package/dist/composition/probe/run-manifest.js.map +1 -0
- package/dist/composition/probe/scoring.d.ts +19 -0
- package/dist/composition/probe/scoring.d.ts.map +1 -0
- package/dist/composition/probe/scoring.js +55 -0
- package/dist/composition/probe/scoring.js.map +1 -0
- package/dist/composition/probe/search-budget.d.ts +26 -0
- package/dist/composition/probe/search-budget.d.ts.map +1 -0
- package/dist/composition/probe/search-budget.js +36 -0
- package/dist/composition/probe/search-budget.js.map +1 -0
- package/dist/composition/probe/serialize.d.ts +33 -0
- package/dist/composition/probe/serialize.d.ts.map +1 -0
- package/dist/composition/probe/serialize.js +61 -0
- package/dist/composition/probe/serialize.js.map +1 -0
- package/dist/composition/probe/structure.d.ts +51 -0
- package/dist/composition/probe/structure.d.ts.map +1 -0
- package/dist/composition/probe/structure.js +93 -0
- package/dist/composition/probe/structure.js.map +1 -0
- package/dist/composition/probe/types.d.ts +281 -0
- package/dist/composition/probe/types.d.ts.map +1 -0
- package/dist/composition/probe/types.js +23 -0
- package/dist/composition/probe/types.js.map +1 -0
- package/dist/diff/bridge-ast-gradient.d.ts.map +1 -1
- package/dist/diff/bridge-ast-gradient.js +22 -2
- package/dist/diff/bridge-ast-gradient.js.map +1 -1
- package/dist/numerical/geodesic-integrator.d.ts.map +1 -1
- package/dist/numerical/geodesic-integrator.js +85 -14
- package/dist/numerical/geodesic-integrator.js.map +1 -1
- package/dist/numerical/gl4-integrator.d.ts +2 -0
- package/dist/numerical/gl4-integrator.d.ts.map +1 -1
- package/dist/numerical/gl4-integrator.js +318 -141
- package/dist/numerical/gl4-integrator.js.map +1 -1
- package/dist/numerical/weyl-lowering.d.ts.map +1 -1
- package/dist/numerical/weyl-lowering.js +55 -31
- package/dist/numerical/weyl-lowering.js.map +1 -1
- package/package.json +15 -5
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Declared-limit checks for probe candidates.
|
|
3
|
+
*
|
|
4
|
+
* A failed limit is **not automatically fatal**. It is fatal only when the
|
|
5
|
+
* candidate claims the domain in which the limit fails.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
import { evalExpr } from '../expr-eval.js';
|
|
10
|
+
/**
|
|
11
|
+
* Evaluate `prefactor · expr` RMSE on `dataset`. When the candidate does not
|
|
12
|
+
* claim `limit.regime`, a failure is recorded but not fatal.
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export function checkDeclaredLimit(expr, dataset, prefactor, limit, claimsDomain) {
|
|
17
|
+
if (dataset.rows.length === 0) {
|
|
18
|
+
return {
|
|
19
|
+
id: limit.id,
|
|
20
|
+
passed: true,
|
|
21
|
+
claimedDomain: claimsDomain,
|
|
22
|
+
fatal: false,
|
|
23
|
+
detail: `no observations for declared-limit ${limit.id}`,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
let sumSq = 0;
|
|
27
|
+
let n = 0;
|
|
28
|
+
for (const row of dataset.rows) {
|
|
29
|
+
let predicted;
|
|
30
|
+
try {
|
|
31
|
+
predicted = prefactor * evalExpr(expr, row);
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const observed = row[dataset.observable];
|
|
37
|
+
if (!Number.isFinite(predicted) || observed == null || !Number.isFinite(observed))
|
|
38
|
+
continue;
|
|
39
|
+
const err = predicted - observed;
|
|
40
|
+
sumSq += err * err;
|
|
41
|
+
n += 1;
|
|
42
|
+
}
|
|
43
|
+
const rmse = n === 0 ? Number.POSITIVE_INFINITY : Math.sqrt(sumSq / n);
|
|
44
|
+
const scale = Math.max(...dataset.rows.map((r) => Math.abs(r[dataset.observable] ?? 0)), 1e-12);
|
|
45
|
+
const passed = Number.isFinite(rmse) && rmse <= 0.5 * scale;
|
|
46
|
+
const fatal = !passed && claimsDomain;
|
|
47
|
+
return {
|
|
48
|
+
id: limit.id,
|
|
49
|
+
passed,
|
|
50
|
+
claimedDomain: claimsDomain,
|
|
51
|
+
fatal,
|
|
52
|
+
detail: passed
|
|
53
|
+
? `limit ${limit.id} held (rmse=${rmse})`
|
|
54
|
+
: `limit ${limit.id} failed (rmse=${rmse})${fatal ? ' — fatal because candidate claims this domain' : ' — not fatal (domain not claimed)'}`,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/** Run every declared limit. @internal */
|
|
58
|
+
export function checkDeclaredLimits(expr, dataset, prefactor, limits, claimedRegimes = {}) {
|
|
59
|
+
const rows = dataset ?? {
|
|
60
|
+
id: 'empty',
|
|
61
|
+
role: 'falsification-only',
|
|
62
|
+
rows: [],
|
|
63
|
+
observable: '',
|
|
64
|
+
schemaVersion: '0',
|
|
65
|
+
};
|
|
66
|
+
return limits.map((limit) => {
|
|
67
|
+
const claimsDomain = Object.entries(limit.regime).every(([k, v]) => claimedRegimes[k] === v);
|
|
68
|
+
return checkDeclaredLimit(expr, rows, prefactor, limit, claimsDomain);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=limits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limits.js","sourceRoot":"","sources":["../../../src/composition/probe/limits.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAU3C;;;;;GAKG;AACH,MAAM,UAAU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AC;IACxE,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optional scientific-relation metadata overlay.
|
|
3
|
+
*
|
|
4
|
+
* Lives here (not in `src/canonical/`) so probe can import canonical without
|
|
5
|
+
* a cycle. This is **not** a registry: missing keys mean "no overlay", never
|
|
6
|
+
* a fabricated evidence claim.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
import type { ScientificRelationRecord, ScientificRelationRef } from './types.js';
|
|
11
|
+
/** Store overlay metadata for a relation pointer. @internal */
|
|
12
|
+
export declare function setRelationMetadata(record: ScientificRelationRecord): void;
|
|
13
|
+
/** Look up overlay metadata. @internal */
|
|
14
|
+
export declare function getRelationMetadata(ref: ScientificRelationRef): ScientificRelationRecord | undefined;
|
|
15
|
+
/** List overlay records (sorted by kind:id). @internal */
|
|
16
|
+
export declare function listRelationMetadata(): readonly ScientificRelationRecord[];
|
|
17
|
+
/** Test helper: drop every overlay record. @internal */
|
|
18
|
+
export declare function clearRelationMetadata(): void;
|
|
19
|
+
//# sourceMappingURL=metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../../src/composition/probe/metadata.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAQlF,+DAA+D;AAC/D,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,wBAAwB,GAAG,IAAI,CAE1E;AAED,0CAA0C;AAC1C,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,qBAAqB,GACzB,wBAAwB,GAAG,SAAS,CAEtC;AAED,0DAA0D;AAC1D,wBAAgB,oBAAoB,IAAI,SAAS,wBAAwB,EAAE,CAE1E;AAED,wDAAwD;AACxD,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optional scientific-relation metadata overlay.
|
|
3
|
+
*
|
|
4
|
+
* Lives here (not in `src/canonical/`) so probe can import canonical without
|
|
5
|
+
* a cycle. This is **not** a registry: missing keys mean "no overlay", never
|
|
6
|
+
* a fabricated evidence claim.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
const overlay = new Map();
|
|
11
|
+
function keyOf(ref) {
|
|
12
|
+
return `${ref.kind}:${ref.id}`;
|
|
13
|
+
}
|
|
14
|
+
/** Store overlay metadata for a relation pointer. @internal */
|
|
15
|
+
export function setRelationMetadata(record) {
|
|
16
|
+
overlay.set(keyOf(record.ref), record);
|
|
17
|
+
}
|
|
18
|
+
/** Look up overlay metadata. @internal */
|
|
19
|
+
export function getRelationMetadata(ref) {
|
|
20
|
+
return overlay.get(keyOf(ref));
|
|
21
|
+
}
|
|
22
|
+
/** List overlay records (sorted by kind:id). @internal */
|
|
23
|
+
export function listRelationMetadata() {
|
|
24
|
+
return [...overlay.values()].sort((a, b) => keyOf(a.ref).localeCompare(keyOf(b.ref)));
|
|
25
|
+
}
|
|
26
|
+
/** Test helper: drop every overlay record. @internal */
|
|
27
|
+
export function clearRelationMetadata() {
|
|
28
|
+
overlay.clear();
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../../src/composition/probe/metadata.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,MAAM,OAAO,GAAG,IAAI,GAAG,EAAoC,CAAC;AAE5D,SAAS,KAAK,CAAC,GAA0B;IACvC,OAAO,GAAG,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,EAAE,EAAE,CAAC;AACjC,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,mBAAmB,CAAC,MAAgC;IAClE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC;AACzC,CAAC;AAED,0CAA0C;AAC1C,MAAM,UAAU,mBAAmB,CACjC,GAA0B;IAE1B,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AACjC,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,oBAAoB;IAClC,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACxF,CAAC;AAED,wDAAwD;AACxD,MAAM,UAAU,qBAAqB;IACnC,OAAO,CAAC,KAAK,EAAE,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Product B search orchestrator.
|
|
3
|
+
*
|
|
4
|
+
* Identifiability gate → native enumerator → fingerprint dedup → corpus
|
|
5
|
+
* comparison → validate → exploratory fit (never holdout) → holdout →
|
|
6
|
+
* falsify → Pareto. Relation-link / regime gaps abstain (`non-identifiable`)
|
|
7
|
+
* and tell the caller to use `upt discover`.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
import type { ProbeCandidateRecord, ProbeRejectionRecord, SearchBudget, SearchProblem, SearchStopReason, DiscoveryRunManifest } from './types.js';
|
|
12
|
+
import { type CorpusComparisonResult } from './corpus.js';
|
|
13
|
+
import { type FitResult } from './fit.js';
|
|
14
|
+
import { type FalsifyResult } from './falsify.js';
|
|
15
|
+
import { type RankedCandidate } from './scoring.js';
|
|
16
|
+
export interface ProbeSearchOptions {
|
|
17
|
+
readonly budget?: SearchBudget;
|
|
18
|
+
readonly runId?: string;
|
|
19
|
+
readonly repositoryCommit?: string;
|
|
20
|
+
readonly holdoutTol?: number;
|
|
21
|
+
readonly backendArgv?: readonly string[];
|
|
22
|
+
readonly corpusVersion?: string;
|
|
23
|
+
readonly now?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface ProbeSearchResult {
|
|
26
|
+
readonly manifest: DiscoveryRunManifest;
|
|
27
|
+
readonly candidates: readonly ProbeCandidateRecord[];
|
|
28
|
+
readonly ranked: readonly RankedCandidate[];
|
|
29
|
+
readonly rejections: readonly ProbeRejectionRecord[];
|
|
30
|
+
readonly fits: Readonly<Record<string, FitResult>>;
|
|
31
|
+
readonly falsifications: Readonly<Record<string, FalsifyResult>>;
|
|
32
|
+
readonly corpus: Readonly<Record<string, CorpusComparisonResult>>;
|
|
33
|
+
readonly wording: readonly string[];
|
|
34
|
+
readonly stopReason: SearchStopReason;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Run a bounded Product B search. Never mutates Product A catalogs.
|
|
38
|
+
*
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
export declare function runProbeSearch(problem: SearchProblem, opts?: ProbeSearchOptions): Promise<ProbeSearchResult>;
|
|
42
|
+
//# sourceMappingURL=pipeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../../src/composition/probe/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EACV,oBAAoB,EACpB,oBAAoB,EACpB,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,YAAY,CAAC;AAKpB,OAAO,EAA0C,KAAK,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAClG,OAAO,EAAgB,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAIpE,OAAO,EAA8B,KAAK,eAAe,EAAE,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Product B search orchestrator.
|
|
3
|
+
*
|
|
4
|
+
* Identifiability gate → native enumerator → fingerprint dedup → corpus
|
|
5
|
+
* comparison → validate → exploratory fit (never holdout) → holdout →
|
|
6
|
+
* falsify → Pareto. Relation-link / regime gaps abstain (`non-identifiable`)
|
|
7
|
+
* and tell the caller to use `upt discover`.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
import { validate } from '../../dimensional/validator.js';
|
|
12
|
+
import { DEFAULT_SEARCH_BUDGET, SCHEMA_VERSION } from './types.js';
|
|
13
|
+
import { openBudget, budgetStopReason } from './search-budget.js';
|
|
14
|
+
import { generateNative } from './generator.js';
|
|
15
|
+
import { fingerprintExpr, complexityOf, bodyExpression } from './fingerprint.js';
|
|
16
|
+
import { compareToCorpus, corpusRelativeWording } from './corpus.js';
|
|
17
|
+
import { fitPrefactor } from './fit.js';
|
|
18
|
+
import { runFalsification } from './falsify.js';
|
|
19
|
+
import { applyStatus, ProbeCandidateStore } from './candidate-store.js';
|
|
20
|
+
import { openManifest, closeManifest } from './run-manifest.js';
|
|
21
|
+
import { hashCanonical } from './serialize.js';
|
|
22
|
+
import { scoreCandidate, rankPareto } from './scoring.js';
|
|
23
|
+
import { runBackendWorker } from './backend-protocol.js';
|
|
24
|
+
function abstain(problem, opts, reason, wording) {
|
|
25
|
+
const budget = opts.budget ?? DEFAULT_SEARCH_BUDGET;
|
|
26
|
+
const runId = opts.runId ?? `dr-${hashCanonical(problem.gap.id).slice(0, 12)}`;
|
|
27
|
+
const open = openManifest({
|
|
28
|
+
runId,
|
|
29
|
+
repositoryCommit: opts.repositoryCommit ?? 'unknown',
|
|
30
|
+
problem,
|
|
31
|
+
searchBudget: budget,
|
|
32
|
+
startedAt: opts.now,
|
|
33
|
+
});
|
|
34
|
+
const manifest = closeManifest(open, reason, opts.now);
|
|
35
|
+
return {
|
|
36
|
+
manifest,
|
|
37
|
+
candidates: [],
|
|
38
|
+
ranked: [],
|
|
39
|
+
rejections: [],
|
|
40
|
+
fits: {},
|
|
41
|
+
falsifications: {},
|
|
42
|
+
corpus: {},
|
|
43
|
+
wording,
|
|
44
|
+
stopReason: reason,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function gate(problem) {
|
|
48
|
+
if (problem.gap.kind === 'relation-link' || problem.gap.kind === 'regime-transition') {
|
|
49
|
+
return {
|
|
50
|
+
ok: false,
|
|
51
|
+
wording: `${problem.gap.kind} gaps are Product A — use \`upt discover\`, not \`upt probe run\``,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
if (!problem.gap.searchability.searchable) {
|
|
55
|
+
return {
|
|
56
|
+
ok: false,
|
|
57
|
+
wording: problem.gap.searchability.reasons.join('; ') || 'gap is not searchable',
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
if (problem.gap.identifiability.parametric?.status === 'non-identifiable') {
|
|
61
|
+
return {
|
|
62
|
+
ok: false,
|
|
63
|
+
wording: problem.gap.identifiability.parametric.reasons.join('; ') || 'parametrically non-identifiable',
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
return { ok: true };
|
|
67
|
+
}
|
|
68
|
+
function makeGenerated(expr, problem, runId, at, origin, seq) {
|
|
69
|
+
const fp = fingerprintExpr(expr, problem.regimeSignature ?? '', (problem.assumptions ?? []).join('|'));
|
|
70
|
+
return {
|
|
71
|
+
id: `h-${seq}-${fp.canonicalAstHash.slice(0, 10)}`,
|
|
72
|
+
gapId: problem.gap.id,
|
|
73
|
+
body: { kind: 'scalar-expr', expression: expr },
|
|
74
|
+
origin,
|
|
75
|
+
assumptions: problem.assumptions ?? [],
|
|
76
|
+
status: 'generated',
|
|
77
|
+
statusHistory: [
|
|
78
|
+
{ at, from: 'none', to: 'generated', reason: 'enumerator', runId },
|
|
79
|
+
],
|
|
80
|
+
evaluations: [],
|
|
81
|
+
fingerprint: fp,
|
|
82
|
+
complexity: complexityOf(expr),
|
|
83
|
+
schemaVersion: SCHEMA_VERSION,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Run a bounded Product B search. Never mutates Product A catalogs.
|
|
88
|
+
*
|
|
89
|
+
* @internal
|
|
90
|
+
*/
|
|
91
|
+
export async function runProbeSearch(problem, opts = {}) {
|
|
92
|
+
const blocked = gate(problem);
|
|
93
|
+
if (!blocked.ok) {
|
|
94
|
+
return abstain(problem, opts, 'non-identifiable', [blocked.wording]);
|
|
95
|
+
}
|
|
96
|
+
const budget = opts.budget ?? DEFAULT_SEARCH_BUDGET;
|
|
97
|
+
const state = openBudget(budget);
|
|
98
|
+
const runId = opts.runId ?? `dr-${hashCanonical({
|
|
99
|
+
gap: problem.gap.id,
|
|
100
|
+
target: problem.target.name,
|
|
101
|
+
governing: problem.governing.map((g) => g.name),
|
|
102
|
+
}).slice(0, 12)}`;
|
|
103
|
+
const at = opts.now ?? new Date().toISOString();
|
|
104
|
+
const corpusVersion = opts.corpusVersion ?? SCHEMA_VERSION;
|
|
105
|
+
const store = new ProbeCandidateStore();
|
|
106
|
+
const fits = {};
|
|
107
|
+
const falsifications = {};
|
|
108
|
+
const corpus = {};
|
|
109
|
+
const wording = [];
|
|
110
|
+
const seenHash = new Set();
|
|
111
|
+
let seq = 0;
|
|
112
|
+
const raws = [];
|
|
113
|
+
for (const raw of generateNative(problem, state)) {
|
|
114
|
+
raws.push(raw);
|
|
115
|
+
const stop = budgetStopReason(state);
|
|
116
|
+
if (stop)
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
if (opts.backendArgv && opts.backendArgv.length > 0) {
|
|
120
|
+
const remainingMs = Math.max(1, budget.maxWallClockMs - (Date.now() - state.startedAtMs));
|
|
121
|
+
const backend = await runBackendWorker(opts.backendArgv, {
|
|
122
|
+
problemId: problem.gap.id,
|
|
123
|
+
budgetMs: remainingMs,
|
|
124
|
+
variables: problem.governing.map((g) => g.name),
|
|
125
|
+
target: problem.target.name,
|
|
126
|
+
}, { timeoutMs: remainingMs });
|
|
127
|
+
if (!backend.ok) {
|
|
128
|
+
wording.push(`backend abstained: ${backend.error ?? 'unknown error'}`);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
for (const c of backend.candidates) {
|
|
132
|
+
raws.push({
|
|
133
|
+
expression: c.expression,
|
|
134
|
+
monomial: null,
|
|
135
|
+
originNote: c.note ?? 'external-backend',
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const open = openManifest({
|
|
141
|
+
runId,
|
|
142
|
+
repositoryCommit: opts.repositoryCommit ?? 'unknown',
|
|
143
|
+
problem,
|
|
144
|
+
datasetHashes: [
|
|
145
|
+
...(problem.exploratory ? [hashCanonical(problem.exploratory)] : []),
|
|
146
|
+
...(problem.holdout ? [hashCanonical(problem.holdout)] : []),
|
|
147
|
+
],
|
|
148
|
+
searchBudget: budget,
|
|
149
|
+
startedAt: at,
|
|
150
|
+
backendDescriptors: opts.backendArgv
|
|
151
|
+
? [
|
|
152
|
+
{
|
|
153
|
+
protocolVersion: '0',
|
|
154
|
+
backendId: 'native',
|
|
155
|
+
backendVersion: SCHEMA_VERSION,
|
|
156
|
+
capabilities: ['grammar-enumerator'],
|
|
157
|
+
deterministic: 'yes',
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
protocolVersion: '0',
|
|
161
|
+
backendId: opts.backendArgv.join(' '),
|
|
162
|
+
backendVersion: 'external',
|
|
163
|
+
capabilities: ['external-backend'],
|
|
164
|
+
deterministic: 'unknown',
|
|
165
|
+
},
|
|
166
|
+
]
|
|
167
|
+
: undefined,
|
|
168
|
+
});
|
|
169
|
+
for (const raw of raws) {
|
|
170
|
+
const stop = budgetStopReason(state);
|
|
171
|
+
if (stop)
|
|
172
|
+
break;
|
|
173
|
+
const origin = raw.originNote.startsWith('external')
|
|
174
|
+
? { kind: 'external-backend', backendId: 'external', runId }
|
|
175
|
+
: { kind: 'grammar-enumerator', runId };
|
|
176
|
+
seq += 1;
|
|
177
|
+
let rec = makeGenerated(raw.expression, problem, runId, at, origin, seq);
|
|
178
|
+
if (seenHash.has(rec.fingerprint.canonicalAstHash))
|
|
179
|
+
continue;
|
|
180
|
+
seenHash.add(rec.fingerprint.canonicalAstHash);
|
|
181
|
+
store.put(rec);
|
|
182
|
+
const v = validate(bodyExpression(rec.body));
|
|
183
|
+
if (!v.ok || v.inferredDimension === null) {
|
|
184
|
+
rec = applyStatus(rec, 'rejected', 'dimensionally invalid', runId, at);
|
|
185
|
+
store.replace(rec);
|
|
186
|
+
store.rememberRejection({
|
|
187
|
+
fingerprint: rec.fingerprint,
|
|
188
|
+
reason: 'dimensionally invalid',
|
|
189
|
+
context: problem.gap.id,
|
|
190
|
+
timestamp: at,
|
|
191
|
+
});
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
rec = applyStatus(rec, 'structurally-valid', 'validate() ok', runId, at);
|
|
195
|
+
store.replace(rec);
|
|
196
|
+
const corp = compareToCorpus(bodyExpression(rec.body), corpusVersion);
|
|
197
|
+
corpus[rec.id] = corp;
|
|
198
|
+
wording.push(corpusRelativeWording(corp));
|
|
199
|
+
const known = corp.algebraicMatches.length > 0;
|
|
200
|
+
const hasData = (problem.exploratory?.rows.length ?? 0) > 0;
|
|
201
|
+
if (!hasData) {
|
|
202
|
+
rec = applyStatus(rec, known ? 'equivalent-known' : 'insufficient-evidence', known ? corpusRelativeWording(corp) : 'no exploratory observations', runId, at);
|
|
203
|
+
store.replace(rec);
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
state.evaluations += 1;
|
|
207
|
+
let fit;
|
|
208
|
+
try {
|
|
209
|
+
fit = fitPrefactor(bodyExpression(rec.body), problem.exploratory, problem.holdout, opts.holdoutTol ?? 0.15);
|
|
210
|
+
}
|
|
211
|
+
catch (err) {
|
|
212
|
+
rec = applyStatus(rec, 'rejected', err instanceof Error ? err.message : String(err), runId, at);
|
|
213
|
+
store.replace(rec);
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
fits[rec.id] = fit;
|
|
217
|
+
rec = applyStatus(rec, 'empirically-fit', `exploratory RMSE ${fit.exploratoryRmse}`, runId, at);
|
|
218
|
+
store.replace(rec);
|
|
219
|
+
if (!problem.holdout || problem.holdout.rows.length === 0) {
|
|
220
|
+
rec = applyStatus(rec, 'insufficient-evidence', 'no holdout observations', runId, at);
|
|
221
|
+
store.replace(rec);
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
if (!fit.holdoutSupported) {
|
|
225
|
+
rec = applyStatus(rec, 'rejected', `holdout RMSE ${fit.holdoutRmse} exceeds tolerance`, runId, at);
|
|
226
|
+
store.replace(rec);
|
|
227
|
+
store.rememberRejection({
|
|
228
|
+
fingerprint: rec.fingerprint,
|
|
229
|
+
reason: `holdout RMSE ${fit.holdoutRmse}`,
|
|
230
|
+
context: problem.gap.id,
|
|
231
|
+
timestamp: at,
|
|
232
|
+
});
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
rec = applyStatus(rec, 'heldout-supported', `holdout RMSE ${fit.holdoutRmse}`, runId, at);
|
|
236
|
+
store.replace(rec);
|
|
237
|
+
if (known) {
|
|
238
|
+
rec = applyStatus(rec, 'equivalent-known', corpusRelativeWording(corp), runId, at);
|
|
239
|
+
store.replace(rec);
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
const fal = runFalsification({
|
|
243
|
+
expr: bodyExpression(rec.body),
|
|
244
|
+
dataset: problem.holdout,
|
|
245
|
+
prefactor: fit.prefactor,
|
|
246
|
+
claimedRegimes: problem.claimedRegimes,
|
|
247
|
+
limits: problem.limits,
|
|
248
|
+
observationalBoundIds: problem.observationalBoundIds,
|
|
249
|
+
});
|
|
250
|
+
falsifications[rec.id] = fal;
|
|
251
|
+
if (!fal.survived) {
|
|
252
|
+
rec = applyStatus(rec, 'falsified', fal.records.filter((r) => r.outcome === 'fail').map((r) => r.detail).join('; '), runId, at);
|
|
253
|
+
store.replace(rec);
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
rec = applyStatus(rec, 'falsification-survivor', 'all fatal batteries passed', runId, at);
|
|
257
|
+
rec = applyStatus(rec, 'expert-review-required', 'survived batteries; human review required', runId, at);
|
|
258
|
+
store.replace(rec);
|
|
259
|
+
}
|
|
260
|
+
const all = store.all();
|
|
261
|
+
const scored = all.map((record) => {
|
|
262
|
+
const fit = fits[record.id];
|
|
263
|
+
const emp = fit
|
|
264
|
+
? 1 / (1 + fit.exploratoryRmse)
|
|
265
|
+
: record.status === 'equivalent-known'
|
|
266
|
+
? 0.5
|
|
267
|
+
: 0;
|
|
268
|
+
const corp = corpus[record.id];
|
|
269
|
+
const dist = corp && corp.algebraicMatches.length > 0 ? 0 : 1;
|
|
270
|
+
return { record, scores: scoreCandidate(record, emp, dist) };
|
|
271
|
+
});
|
|
272
|
+
const ranked = rankPareto(scored);
|
|
273
|
+
const budgetStop = budgetStopReason(state);
|
|
274
|
+
let stopReason;
|
|
275
|
+
if (budgetStop) {
|
|
276
|
+
stopReason = budgetStop;
|
|
277
|
+
}
|
|
278
|
+
else if (all.length === 0) {
|
|
279
|
+
stopReason = 'no-credible-candidate';
|
|
280
|
+
wording.push('enumerator produced no dimensionally valid candidates');
|
|
281
|
+
}
|
|
282
|
+
else if (hasAnyData(problem) &&
|
|
283
|
+
all.every((c) => c.status === 'rejected' ||
|
|
284
|
+
c.status === 'falsified' ||
|
|
285
|
+
c.status === 'insufficient-evidence')) {
|
|
286
|
+
stopReason = 'no-credible-candidate';
|
|
287
|
+
wording.push('no candidate survived holdout / falsification');
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
stopReason = 'exhausted-space';
|
|
291
|
+
}
|
|
292
|
+
return {
|
|
293
|
+
manifest: closeManifest(open, stopReason, opts.now ?? new Date().toISOString()),
|
|
294
|
+
candidates: all,
|
|
295
|
+
ranked,
|
|
296
|
+
rejections: store.rejectionList(),
|
|
297
|
+
fits,
|
|
298
|
+
falsifications,
|
|
299
|
+
corpus,
|
|
300
|
+
wording,
|
|
301
|
+
stopReason,
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
function hasAnyData(problem) {
|
|
305
|
+
return (problem.exploratory?.rows.length ?? 0) > 0;
|
|
306
|
+
}
|
|
307
|
+
//# sourceMappingURL=pipeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../../src/composition/probe/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAS1D,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAoB,MAAM,oBAAoB,CAAC;AACpF,OAAO,EAAE,cAAc,EAAqB,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAA+B,MAAM,aAAa,CAAC;AAClG,OAAO,EAAE,YAAY,EAAkB,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAsB,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,UAAU,EAAwB,MAAM,cAAc,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAwBzD,SAAS,OAAO,CACd,OAAsB,EACtB,IAAwB,EACxB,MAAwB,EACxB,OAA0B;IAE1B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,qBAAqB,CA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,GAAG,IAAI,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAC/E,UAAU,EAAE,GAAG;QACf,MAAM;QACN,UAAU,EAAE,KAAK,CAAC,aAAa,EAAE;QACjC,IAAI;QACJ,cAAc;QACd,MAAM;QACN,OAAO;QACP,UAAU;KACX,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,OAAsB;IACxC,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Search-problem construction and JSON loading for Product B.
|
|
3
|
+
*
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
import type { ExprNode } from '../../dimensional/ast-types.js';
|
|
7
|
+
import type { DiscrepancyDefinition, FrontierGap, FrontierGapKind, SearchProblem } from './types.js';
|
|
8
|
+
/** Residual / unexplained-observation gap template. @internal */
|
|
9
|
+
export declare function makeResidualGap(id: string, summary: string, kind?: FrontierGapKind): FrontierGap;
|
|
10
|
+
export interface ProblemFile {
|
|
11
|
+
readonly gap?: {
|
|
12
|
+
readonly id?: string;
|
|
13
|
+
readonly kind?: string;
|
|
14
|
+
readonly summary?: string;
|
|
15
|
+
};
|
|
16
|
+
readonly target: {
|
|
17
|
+
readonly name: string;
|
|
18
|
+
readonly dim: string;
|
|
19
|
+
};
|
|
20
|
+
readonly governing: readonly {
|
|
21
|
+
readonly name: string;
|
|
22
|
+
readonly dim: string;
|
|
23
|
+
}[];
|
|
24
|
+
readonly exploratory?: unknown;
|
|
25
|
+
readonly holdout?: unknown;
|
|
26
|
+
readonly observationsPath?: string;
|
|
27
|
+
readonly baseline?: ExprNode;
|
|
28
|
+
readonly discrepancy?: DiscrepancyDefinition;
|
|
29
|
+
readonly assumptions?: readonly string[];
|
|
30
|
+
readonly limits?: SearchProblem['limits'];
|
|
31
|
+
readonly claimedRegimes?: Readonly<Record<string, string>>;
|
|
32
|
+
readonly observationalBoundIds?: readonly string[];
|
|
33
|
+
}
|
|
34
|
+
/** Load a SearchProblem from a JSON file (optionally with inline datasets). @internal */
|
|
35
|
+
export declare function loadSearchProblemFromJson(path: string): SearchProblem;
|
|
36
|
+
/** Build a SearchProblem from an already-parsed problem file. @internal */
|
|
37
|
+
export declare function searchProblemFromFile(raw: ProblemFile, source?: string): SearchProblem;
|
|
38
|
+
/** Load an ExprNode from a JSON file (`{expression}` wrapper or bare node). @internal */
|
|
39
|
+
export declare function parseExprJson(path: string): ExprNode;
|
|
40
|
+
//# sourceMappingURL=problem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"problem.d.ts","sourceRoot":"","sources":["../../../src/composition/probe/problem.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,KAAK,EAEV,qBAAqB,EACrB,WAAW,EACX,eAAe,EAEf,aAAa,EACd,MAAM,YAAY,CAAC;AAmBpB,iEAAiE;AACjE,wBAAgB,eAAe,CAC7B,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,MAAM,EACf,IAAI,GAAE,eAA2C,GAChD,WAAW,CAuBb;AAMD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,GAAG,CAAC,EAAE;QACb,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;KAC3B,CAAC;IACF,QAAQ,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IACjE,QAAQ,CAAC,SAAS,EAAE,SAAS;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC/E,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAC7B,QAAQ,CAAC,WAAW,CAAC,EAAE,qBAAqB,CAAC;IAC7C,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IAC1C,QAAQ,CAAC,cAAc,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC3D,QAAQ,CAAC,qBAAqB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACpD;AAED,yFAAyF;AACzF,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAGrE;AAED,2EAA2E;AAC3E,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,WAAW,EAAE,MAAM,SAAW,GAAG,aAAa,CAmCxF;AAED,yFAAyF;AACzF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAYpD"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Search-problem construction and JSON loading for Product B.
|
|
3
|
+
*
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
import { readFileSync } from 'node:fs';
|
|
7
|
+
import { parseDimensionSpec } from '../../dimensional/dimension-spec.js';
|
|
8
|
+
import { problemFromResidualGap } from './frontier.js';
|
|
9
|
+
import { asDatasetSafe, loadSplitDatasetsFromJson } from './dataset.js';
|
|
10
|
+
function isGapKind(s) {
|
|
11
|
+
return (s === 'prediction-residual' ||
|
|
12
|
+
s === 'relation-link' ||
|
|
13
|
+
s === 'regime-transition' ||
|
|
14
|
+
s === 'parameter-tension' ||
|
|
15
|
+
s === 'assumption-conflict' ||
|
|
16
|
+
s === 'missing-operator' ||
|
|
17
|
+
s === 'unexplained-observation' ||
|
|
18
|
+
s === 'model-disagreement' ||
|
|
19
|
+
s === 'causal-mechanism' ||
|
|
20
|
+
s === 'other');
|
|
21
|
+
}
|
|
22
|
+
/** Residual / unexplained-observation gap template. @internal */
|
|
23
|
+
export function makeResidualGap(id, summary, kind = 'unexplained-observation') {
|
|
24
|
+
if (!id.startsWith('fg-')) {
|
|
25
|
+
throw new RangeError(`makeResidualGap: id must start with 'fg-' (got '${id}')`);
|
|
26
|
+
}
|
|
27
|
+
if (kind === 'relation-link' || kind === 'regime-transition') {
|
|
28
|
+
throw new RangeError(`makeResidualGap: ${kind} is Product A — use upt discover, not probe`);
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
id,
|
|
32
|
+
kind,
|
|
33
|
+
participants: [],
|
|
34
|
+
observations: [],
|
|
35
|
+
regimes: [],
|
|
36
|
+
assumptions: [],
|
|
37
|
+
constraints: [],
|
|
38
|
+
evidence: { summary, sourceIds: [] },
|
|
39
|
+
identifiability: {
|
|
40
|
+
kind: 'parametric',
|
|
41
|
+
parametric: { status: 'unknown', reasons: ['not yet assessed'] },
|
|
42
|
+
},
|
|
43
|
+
searchability: { searchable: true, reasons: ['residual gap'] },
|
|
44
|
+
status: 'identified',
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function varFromJson(raw) {
|
|
48
|
+
return { name: raw.name, dim: parseDimensionSpec(raw.dim) };
|
|
49
|
+
}
|
|
50
|
+
/** Load a SearchProblem from a JSON file (optionally with inline datasets). @internal */
|
|
51
|
+
export function loadSearchProblemFromJson(path) {
|
|
52
|
+
const raw = JSON.parse(readFileSync(path, 'utf8'));
|
|
53
|
+
return searchProblemFromFile(raw, path);
|
|
54
|
+
}
|
|
55
|
+
/** Build a SearchProblem from an already-parsed problem file. @internal */
|
|
56
|
+
export function searchProblemFromFile(raw, source = 'inline') {
|
|
57
|
+
const kindRaw = raw.gap?.kind ?? 'unexplained-observation';
|
|
58
|
+
if (!isGapKind(kindRaw)) {
|
|
59
|
+
throw new RangeError(`unknown gap kind '${kindRaw}'`);
|
|
60
|
+
}
|
|
61
|
+
const gap = makeResidualGap(raw.gap?.id ?? 'fg-inline', raw.gap?.summary ?? `search problem from ${source}`, kindRaw);
|
|
62
|
+
const target = varFromJson(raw.target);
|
|
63
|
+
const governing = raw.governing.map(varFromJson);
|
|
64
|
+
let exploratory;
|
|
65
|
+
let holdout;
|
|
66
|
+
if (raw.observationsPath) {
|
|
67
|
+
const split = loadSplitDatasetsFromJson(raw.observationsPath);
|
|
68
|
+
exploratory = split.exploratory;
|
|
69
|
+
holdout = split.holdout;
|
|
70
|
+
}
|
|
71
|
+
if (raw.exploratory) {
|
|
72
|
+
exploratory = asDatasetSafe(raw.exploratory, `${source}#exploratory`, 'exploratory-fit');
|
|
73
|
+
}
|
|
74
|
+
if (raw.holdout) {
|
|
75
|
+
holdout = asDatasetSafe(raw.holdout, `${source}#holdout`, 'validation-holdout');
|
|
76
|
+
}
|
|
77
|
+
const problem = problemFromResidualGap(gap, target, governing, exploratory, holdout);
|
|
78
|
+
return {
|
|
79
|
+
...problem,
|
|
80
|
+
baseline: raw.baseline,
|
|
81
|
+
discrepancy: raw.discrepancy ?? problem.discrepancy,
|
|
82
|
+
assumptions: raw.assumptions ?? gap.assumptions,
|
|
83
|
+
limits: raw.limits,
|
|
84
|
+
claimedRegimes: raw.claimedRegimes,
|
|
85
|
+
observationalBoundIds: raw.observationalBoundIds,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/** Load an ExprNode from a JSON file (`{expression}` wrapper or bare node). @internal */
|
|
89
|
+
export function parseExprJson(path) {
|
|
90
|
+
const raw = JSON.parse(readFileSync(path, 'utf8'));
|
|
91
|
+
if (raw && typeof raw === 'object' && 'kind' in raw)
|
|
92
|
+
return raw;
|
|
93
|
+
if (raw &&
|
|
94
|
+
typeof raw === 'object' &&
|
|
95
|
+
'expression' in raw &&
|
|
96
|
+
raw.expression) {
|
|
97
|
+
return raw.expression;
|
|
98
|
+
}
|
|
99
|
+
throw new Error(`parseExprJson: ${path} is not an ExprNode JSON object`);
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=problem.js.map
|