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 @@
|
|
|
1
|
+
{"version":3,"file":"problem.js","sourceRoot":"","sources":["../../../src/composition/probe/problem.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAUzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAExE,SAAS,SAAS,CAAC,CAAS;IAC1B,OAAO,CACL,CAAC,KAAK,qBAAqB;QAC3B,CAAC,KAAK,eAAe;QACrB,CAAC,KAAK,mBAAmB;QACzB,CAAC,KAAK,mBAAmB;QACzB,CAAC,KAAK,qBAAqB;QAC3B,CAAC,KAAK,kBAAkB;QACxB,CAAC,KAAK,yBAAyB;QAC/B,CAAC,KAAK,oBAAoB;QAC1B,CAAC,KAAK,kBAAkB;QACxB,CAAC,KAAK,OAAO,CACd,CAAC;AACJ,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,eAAe,CAC7B,EAAU,EACV,OAAe,EACf,OAAwB,yBAAyB;IAEjD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,UAAU,CAAC,mDAAmD,EAAE,IAAI,CAAC,CAAC;IAClF,CAAC;IACD,IAAI,IAAI,KAAK,eAAe,IAAI,IAAI,KAAK,mBAAmB,EAAE,CAAC;QAC7D,MAAM,IAAI,UAAU,CAAC,oBA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qB;KACjD,CAAC;AACJ,CAAC;AAED,yFAAyF;AACzF,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAyC,CAAC;IAC3F,IAAI,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,MAAM,IAAI,GAAG;QAAE,OAAO,GAAe,CAAC;IAC5E,IACE,GAAG;QACH,OAAO,GAAG,KAAK,QAAQ;QACvB,YAAY,IAAI,GAAG;QAClB,GAAiC,CAAC,UAAU,EAC7C,CAAC;QACD,OAAQ,GAAgC,CAAC,UAAU,CAAC;IACtD,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,kBAAkB,IAAI,iCAAiC,CAAC,CAAC;AAC3E,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scientist-facing probe reports. Never prints a status stronger than the
|
|
3
|
+
* stored candidate status. Novelty wording is always corpus-relative.
|
|
4
|
+
*
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
import type { ProbeSearchResult } from './pipeline.js';
|
|
8
|
+
import type { FrontierGap } from './types.js';
|
|
9
|
+
/** Format a Product B search result. @internal */
|
|
10
|
+
export declare function formatProbeReport(result: ProbeSearchResult): string;
|
|
11
|
+
/** Format a frontier scan. @internal */
|
|
12
|
+
export declare function formatFrontierScan(gaps: readonly FrontierGap[]): string;
|
|
13
|
+
/** Format a single gap. @internal */
|
|
14
|
+
export declare function formatFrontierGap(gap: FrontierGap): string;
|
|
15
|
+
//# sourceMappingURL=report.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../../src/composition/probe/report.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAA8C,MAAM,YAAY,CAAC;AAwB1F,kDAAkD;AAClD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,CAgCnE;AAED,wCAAwC;AACxC,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,SAAS,WAAW,EAAE,GAAG,MAAM,CAcvE;AAED,qCAAqC;AACrC,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,WAAW,GAAG,MAAM,CAS1D"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scientist-facing probe reports. Never prints a status stronger than the
|
|
3
|
+
* stored candidate status. Novelty wording is always corpus-relative.
|
|
4
|
+
*
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
import { bodyExpression } from './fingerprint.js';
|
|
8
|
+
import { corpusRelativeWording } from './corpus.js';
|
|
9
|
+
const STATUS_LINE = {
|
|
10
|
+
generated: 'generated (not yet validated)',
|
|
11
|
+
'structurally-valid': 'structurally valid (not yet fit)',
|
|
12
|
+
'empirically-fit': 'fit on exploratory data only (holdout not passed)',
|
|
13
|
+
'heldout-supported': 'supported on locked holdout (not yet falsified)',
|
|
14
|
+
'falsification-survivor': 'survived declared falsification batteries',
|
|
15
|
+
'expert-review-required': 'requires expert review — not a published discovery',
|
|
16
|
+
rejected: 'rejected',
|
|
17
|
+
falsified: 'falsified',
|
|
18
|
+
'equivalent-known': 'algebraically equivalent to a known corpus relation (not novel)',
|
|
19
|
+
'insufficient-evidence': 'insufficient evidence (no data or no holdout)',
|
|
20
|
+
};
|
|
21
|
+
function exprSummary(record) {
|
|
22
|
+
const expr = bodyExpression(record.body);
|
|
23
|
+
try {
|
|
24
|
+
return JSON.stringify(expr);
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return record.id;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/** Format a Product B search result. @internal */
|
|
31
|
+
export function formatProbeReport(result) {
|
|
32
|
+
const lines = [];
|
|
33
|
+
lines.push(`upt probe — experimental expression/residual search [run ${result.manifest.runId}]`);
|
|
34
|
+
lines.push('⚠ Product B is experimental. `upt discover` remains the quantity-identification funnel.');
|
|
35
|
+
lines.push(` stop: ${result.stopReason}`);
|
|
36
|
+
lines.push(` candidates: ${result.candidates.length} · rejections: ${result.rejections.length}`);
|
|
37
|
+
if (result.wording.length > 0) {
|
|
38
|
+
lines.push('');
|
|
39
|
+
for (const w of result.wording.slice(0, 8))
|
|
40
|
+
lines.push(` ${w}`);
|
|
41
|
+
}
|
|
42
|
+
lines.push('');
|
|
43
|
+
if (result.ranked.length === 0) {
|
|
44
|
+
lines.push(' no candidates to rank.');
|
|
45
|
+
return lines.join('\n');
|
|
46
|
+
}
|
|
47
|
+
lines.push(' ranked (Pareto front first; scores are not a discovery claim):');
|
|
48
|
+
for (const item of result.ranked) {
|
|
49
|
+
const rec = item.record;
|
|
50
|
+
const mark = item.pareto ? '●' : '·';
|
|
51
|
+
const fit = result.fits[rec.id];
|
|
52
|
+
const fitBit = fit
|
|
53
|
+
? ` ĉ=${fit.prefactor.toPrecision(4)} RMSE_ex=${fit.exploratoryRmse.toPrecision(3)}` +
|
|
54
|
+
(fit.holdoutRmse != null ? ` RMSE_ho=${fit.holdoutRmse.toPrecision(3)}` : '')
|
|
55
|
+
: '';
|
|
56
|
+
lines.push(` ${mark} ${rec.id} [${STATUS_LINE[rec.status]}] validity=${item.scores.validity.toFixed(2)} emp=${item.scores.empirical.toFixed(2)} parsimony=${item.scores.parsimony.toFixed(2)}${fitBit}`);
|
|
57
|
+
const corp = result.corpus[rec.id];
|
|
58
|
+
if (corp)
|
|
59
|
+
lines.push(` ${corpusRelativeWording(corp)}`);
|
|
60
|
+
lines.push(` ${exprSummary(rec).slice(0, 180)}`);
|
|
61
|
+
}
|
|
62
|
+
return lines.join('\n');
|
|
63
|
+
}
|
|
64
|
+
/** Format a frontier scan. @internal */
|
|
65
|
+
export function formatFrontierScan(gaps) {
|
|
66
|
+
const lines = [];
|
|
67
|
+
lines.push('upt probe scan — typed frontier gaps');
|
|
68
|
+
lines.push('⚠ relation-link / regime-transition gaps are Product A review surfaces (`upt discover`).');
|
|
69
|
+
lines.push(` ${gaps.length} gap(s)\n`);
|
|
70
|
+
for (const g of gaps) {
|
|
71
|
+
const search = g.searchability.searchable ? 'searchable' : 'not-searchable';
|
|
72
|
+
lines.push(` ${g.id} [${g.kind} / ${search}]`);
|
|
73
|
+
lines.push(` ${g.evidence.summary}`);
|
|
74
|
+
if (!g.searchability.searchable) {
|
|
75
|
+
lines.push(` → ${g.searchability.reasons.join('; ')}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return lines.join('\n');
|
|
79
|
+
}
|
|
80
|
+
/** Format a single gap. @internal */
|
|
81
|
+
export function formatFrontierGap(gap) {
|
|
82
|
+
return [
|
|
83
|
+
`upt probe show ${gap.id}`,
|
|
84
|
+
` kind: ${gap.kind}`,
|
|
85
|
+
` status: ${gap.status}`,
|
|
86
|
+
` searchable: ${gap.searchability.searchable} (${gap.searchability.reasons.join('; ')})`,
|
|
87
|
+
` identifiability: ${gap.identifiability.kind} ${gap.identifiability.parametric?.status ?? ''}`,
|
|
88
|
+
` ${gap.evidence.summary}`,
|
|
89
|
+
].join('\n');
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=report.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.js","sourceRoot":"","sources":["../../../src/composition/probe/report.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAIpD,MAAM,WAAW,GAAyC;IACxD,SAAS,EAAE,+BAA+B;IAC1C,oBAAoB,EAAE,kCAAkC;IACxD,iBAAiB,EAAE,mDAAmD;IACtE,mBAAmB,EAAE,iDAAiD;IACtE,wBAAwB,EAAE,2CAA2C;IACrE,wBAAw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AAE,EAAE;QAC1B,WAAW,GAAG,CAAC,IAAI,EAAE;QACrB,aAAa,GAAG,CAAC,MAAM,EAAE;QACzB,iBAAiB,GAAG,CAAC,aAAa,CAAC,UAAU,KAAK,GAAG,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;QACzF,sBAAsB,GAAG,CAAC,eAAe,CAAC,IAAI,IAAI,GAAG,CAAC,eAAe,CAAC,UAAU,EAAE,MAAM,IAAI,EAAE,EAAE;QAChG,KAAK,GAAG,CAAC,QAAQ,CAAC,OAAO,EAAE;KAC5B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Explicit residual / discrepancy evaluation. Does not replace
|
|
3
|
+
* `residualInSigma` on the confrontation spine.
|
|
4
|
+
*
|
|
5
|
+
* @module composition/probe/residual
|
|
6
|
+
*/
|
|
7
|
+
import type { DiscrepancyDefinition, DiscrepancyKind } from './types.js';
|
|
8
|
+
export declare class ResidualError extends Error {
|
|
9
|
+
constructor(message: string);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Scalar discrepancy. Covariance-standardized with a non-diagonal Σ is
|
|
13
|
+
* unsupported and throws rather than silently using diagonal σ.
|
|
14
|
+
*
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export declare function scalarDiscrepancy(observed: number, predicted: number, kind: DiscrepancyKind, scale?: number): number;
|
|
18
|
+
/** RMSE of a discrepancy over paired samples. @internal */
|
|
19
|
+
export declare function rmse(observed: readonly number[], predicted: readonly number[], def: DiscrepancyDefinition, scale?: number): number;
|
|
20
|
+
//# sourceMappingURL=residual.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"residual.d.ts","sourceRoot":"","sources":["../../../src/composition/probe/residual.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEzE,qBAAa,aAAc,SAAQ,KAAK;gBAC1B,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,eAAe,EACrB,KAAK,SAAI,GACR,MAAM,CAyCR;AAED,2DAA2D;AAC3D,wBAAgB,IAAI,CAClB,QAAQ,EAAE,SAAS,MAAM,EAAE,EAC3B,SAAS,EAAE,SAAS,MAAM,EAAE,EAC5B,GAAG,EAAE,qBAAqB,EAC1B,KAAK,SAAI,GACR,MAAM,CAUR"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Explicit residual / discrepancy evaluation. Does not replace
|
|
3
|
+
* `residualInSigma` on the confrontation spine.
|
|
4
|
+
*
|
|
5
|
+
* @module composition/probe/residual
|
|
6
|
+
*/
|
|
7
|
+
export class ResidualError extends Error {
|
|
8
|
+
constructor(message) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.name = 'ResidualError';
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Scalar discrepancy. Covariance-standardized with a non-diagonal Σ is
|
|
15
|
+
* unsupported and throws rather than silently using diagonal σ.
|
|
16
|
+
*
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export function scalarDiscrepancy(observed, predicted, kind, scale = 1) {
|
|
20
|
+
if (!Number.isFinite(observed) || !Number.isFinite(predicted)) {
|
|
21
|
+
throw new ResidualError('scalarDiscrepancy: observed and predicted must be finite');
|
|
22
|
+
}
|
|
23
|
+
switch (kind) {
|
|
24
|
+
case 'additive':
|
|
25
|
+
return observed - predicted;
|
|
26
|
+
case 'relative': {
|
|
27
|
+
const s = scale !== 0 && Number.isFinite(scale) ? scale : Math.abs(predicted) || 1;
|
|
28
|
+
return (observed - predicted) / s;
|
|
29
|
+
}
|
|
30
|
+
case 'log-ratio': {
|
|
31
|
+
if (!(observed > 0 && predicted > 0)) {
|
|
32
|
+
throw new ResidualError('log-ratio residual requires positive observed and predicted');
|
|
33
|
+
}
|
|
34
|
+
return Math.log(observed / predicted);
|
|
35
|
+
}
|
|
36
|
+
case 'standardized': {
|
|
37
|
+
if (!(scale > 0 && Number.isFinite(scale))) {
|
|
38
|
+
throw new ResidualError('standardized residual requires positive finite sigma');
|
|
39
|
+
}
|
|
40
|
+
return (observed - predicted) / scale;
|
|
41
|
+
}
|
|
42
|
+
case 'likelihood': {
|
|
43
|
+
if (!(scale > 0))
|
|
44
|
+
throw new ResidualError('likelihood residual requires positive sigma');
|
|
45
|
+
const z = (observed - predicted) / scale;
|
|
46
|
+
return 0.5 * z * z + Math.log(scale * Math.sqrt(2 * Math.PI));
|
|
47
|
+
}
|
|
48
|
+
case 'vector':
|
|
49
|
+
case 'tensor':
|
|
50
|
+
case 'distributional':
|
|
51
|
+
case 'operator':
|
|
52
|
+
case 'custom':
|
|
53
|
+
throw new ResidualError(`${kind} discrepancy is not implemented on the scalar path — abstain`);
|
|
54
|
+
default: {
|
|
55
|
+
const _never = kind;
|
|
56
|
+
return _never;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/** RMSE of a discrepancy over paired samples. @internal */
|
|
61
|
+
export function rmse(observed, predicted, def, scale = 1) {
|
|
62
|
+
if (observed.length !== predicted.length || observed.length === 0) {
|
|
63
|
+
throw new ResidualError('rmse: nonempty equal-length samples required');
|
|
64
|
+
}
|
|
65
|
+
let acc = 0;
|
|
66
|
+
for (let i = 0; i < observed.length; i++) {
|
|
67
|
+
const r = scalarDiscrepancy(observed[i], predicted[i], def.kind, scale);
|
|
68
|
+
acc += r * r;
|
|
69
|
+
}
|
|
70
|
+
return Math.sqrt(acc / observed.length);
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=residual.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1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EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACzC,MAAM,CAAC,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACxE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;IACf,CAAC;IACD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Discovery-run manifest construction (schema v0).
|
|
3
|
+
*
|
|
4
|
+
* @module composition/probe/run-manifest
|
|
5
|
+
*/
|
|
6
|
+
import type { DiscoveryBackendDescriptor, DiscoveryRunManifest, EnvironmentFingerprint, SearchBudget, SearchStopReason } from './types.js';
|
|
7
|
+
/** Capture host environment. @internal */
|
|
8
|
+
export declare function captureEnvironment(): EnvironmentFingerprint;
|
|
9
|
+
export interface ManifestDraft {
|
|
10
|
+
readonly runId: string;
|
|
11
|
+
readonly repositoryCommit: string;
|
|
12
|
+
readonly problem: unknown;
|
|
13
|
+
readonly datasetHashes?: readonly string[];
|
|
14
|
+
readonly backendDescriptors?: readonly DiscoveryBackendDescriptor[];
|
|
15
|
+
readonly randomSeeds?: Readonly<Record<string, string | number>>;
|
|
16
|
+
readonly tolerances?: Readonly<Record<string, number>>;
|
|
17
|
+
readonly searchBudget?: SearchBudget;
|
|
18
|
+
readonly startedAt?: string;
|
|
19
|
+
}
|
|
20
|
+
/** Open a run manifest (completedAt / stopReason filled at close). @internal */
|
|
21
|
+
export declare function openManifest(draft: ManifestDraft): DiscoveryRunManifest;
|
|
22
|
+
/** Close a manifest with stop reason and completion time. @internal */
|
|
23
|
+
export declare function closeManifest(open: DiscoveryRunManifest, stopReason: SearchStopReason, completedAt?: string): DiscoveryRunManifest;
|
|
24
|
+
//# sourceMappingURL=run-manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-manifest.d.ts","sourceRoot":"","sources":["../../../src/composition/probe/run-manifest.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,0BAA0B,EAC1B,oBAAoB,EACpB,sBAAsB,EACtB,YAAY,EACZ,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAIpB,0CAA0C;AAC1C,wBAAgB,kBAAkB,IAAI,sBAAsB,CAM3D;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3C,QAAQ,CAAC,kBAAkB,CAAC,EAAE,SAAS,0BAA0B,EAAE,CAAC;IACpE,QAAQ,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC;IACjE,QAAQ,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACvD,QAAQ,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC;IACrC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,gFAAgF;AAChF,wBAAgB,YAAY,CAAC,KAAK,EAAE,aAAa,GAAG,oBAAoB,CA0BvE;AAED,uEAAuE;AACvE,wBAAgB,aAAa,CAC3B,IAAI,EAAE,oBAAoB,EAC1B,UAAU,EAAE,gBAAgB,EAC5B,WAAW,SAA2B,GACrC,oBAAoB,CAEtB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Discovery-run manifest construction (schema v0).
|
|
3
|
+
*
|
|
4
|
+
* @module composition/probe/run-manifest
|
|
5
|
+
*/
|
|
6
|
+
import { DEFAULT_SEARCH_BUDGET, SCHEMA_VERSION } from './types.js';
|
|
7
|
+
import { hashCanonical } from './serialize.js';
|
|
8
|
+
/** Capture host environment. @internal */
|
|
9
|
+
export function captureEnvironment() {
|
|
10
|
+
return {
|
|
11
|
+
node: process.versions.node,
|
|
12
|
+
platform: process.platform,
|
|
13
|
+
arch: process.arch,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/** Open a run manifest (completedAt / stopReason filled at close). @internal */
|
|
17
|
+
export function openManifest(draft) {
|
|
18
|
+
if (!draft.runId.startsWith('dr-')) {
|
|
19
|
+
throw new RangeError(`openManifest: runId must start with 'dr-' (got '${draft.runId}')`);
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
schemaVersion: SCHEMA_VERSION,
|
|
23
|
+
runId: draft.runId,
|
|
24
|
+
repositoryCommit: draft.repositoryCommit,
|
|
25
|
+
problemHash: hashCanonical(draft.problem),
|
|
26
|
+
datasetHashes: draft.datasetHashes ?? [],
|
|
27
|
+
backendDescriptors: draft.backendDescriptors ?? [
|
|
28
|
+
{
|
|
29
|
+
protocolVersion: '0',
|
|
30
|
+
backendId: 'native',
|
|
31
|
+
backendVersion: SCHEMA_VERSION,
|
|
32
|
+
capabilities: ['grammar-enumerator'],
|
|
33
|
+
deterministic: 'yes',
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
randomSeeds: draft.randomSeeds ?? {},
|
|
37
|
+
tolerances: draft.tolerances ?? { holdoutRmse: 0.15 },
|
|
38
|
+
environment: captureEnvironment(),
|
|
39
|
+
searchBudget: draft.searchBudget ?? DEFAULT_SEARCH_BUDGET,
|
|
40
|
+
startedAt: draft.startedAt ?? new Date().toISOString(),
|
|
41
|
+
nondeterminism: [],
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/** Close a manifest with stop reason and completion time. @internal */
|
|
45
|
+
export function closeManifest(open, stopReason, completedAt = new Date().toISOString()) {
|
|
46
|
+
return { ...open, stopReason, completedAt };
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=run-manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-manifest.js","sourceRoot":"","sources":["../../../src/composition/probe/run-manifest.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,0CAA0C;AAC1C,MAAM,UAAU,kBAAkB;IAChC,OAAO;QACL,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,IAAI;QAC3B,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,IAAI,EAAE,OAAO,CAAC,IAAI;KACnB,CAAC;AACJ,CAAC;AAcD,gFAAgF;AAChF,MAAM,UAAU,YAAY,CAAC,KAAoB;IAC/C,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QACnC,MAAM,IAAI,UAAU,CAAC,mDAAmD,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC;IAC3F,CAAC;IACD,OAAO;QACL,aAAa,EAAE,cAAc;QAC7B,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;QACxC,WAAW,EAAE,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC;QACzC,aAAa,EAAE,KAAK,CAAC,aAAa,IAAI,EAAE;QACxC,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,IAAI;YAC9C;gBACE,eAAe,EAAE,GAAG;gBACpB,SAAS,EAAE,QAAQ;gBACnB,cAAc,EAAE,cAAc;gBAC9B,YAAY,EAAE,CAAC,oBAAoB,CAAC;gBACpC,aAAa,EAAE,KAAK;aACrB;SACF;QACD,WAAW,EAAE,KAAK,CAAC,WAAW,IAAI,EAAE;QACpC,UAAU,EAAE,KAAK,CAAC,UAAU,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE;QACrD,WAAW,EAAE,kBAAkB,EAAE;QACjC,YAAY,EAAE,KAAK,CAAC,YAAY,IAAI,qBAAqB;QACzD,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACtD,cAAc,EAAE,EAAE;KACnB,CAAC;AACJ,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,aAAa,CAC3B,IAA0B,EAC1B,UAA4B,EAC5B,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;IAEtC,OAAO,EAAE,GAAG,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pareto scoring for probe candidates. Does not touch `VettedCandidate.score`.
|
|
3
|
+
*
|
|
4
|
+
* @module composition/probe/scoring
|
|
5
|
+
*/
|
|
6
|
+
import type { ProbeCandidateRecord, ScoreVector } from './types.js';
|
|
7
|
+
/** Build a score vector. @internal */
|
|
8
|
+
export declare function scoreCandidate(record: ProbeCandidateRecord, empirical?: number, corpusDistance?: number): ScoreVector;
|
|
9
|
+
export interface RankedCandidate {
|
|
10
|
+
readonly record: ProbeCandidateRecord;
|
|
11
|
+
readonly scores: ScoreVector;
|
|
12
|
+
readonly pareto: boolean;
|
|
13
|
+
}
|
|
14
|
+
/** Pareto front (non-dominated) plus the rest, stable by id. @internal */
|
|
15
|
+
export declare function rankPareto(items: readonly {
|
|
16
|
+
record: ProbeCandidateRecord;
|
|
17
|
+
scores: ScoreVector;
|
|
18
|
+
}[]): RankedCandidate[];
|
|
19
|
+
//# sourceMappingURL=scoring.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scoring.d.ts","sourceRoot":"","sources":["../../../src/composition/probe/scoring.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAOpE,sCAAsC;AACtC,wBAAgB,cAAc,CAC5B,MAAM,EAAE,oBAAoB,EAC5B,SAAS,SAAI,EACb,cAAc,SAAI,GACjB,WAAW,CAgBb;AAkBD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAC;IACtC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAED,0EAA0E;AAC1E,wBAAgB,UAAU,CACxB,KAAK,EAAE,SAAS;IAAE,MAAM,EAAE,oBAAoB,CAAC;IAAC,MAAM,EAAE,WAAW,CAAA;CAAE,EAAE,GACtE,eAAe,EAAE,CASnB"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pareto scoring for probe candidates. Does not touch `VettedCandidate.score`.
|
|
3
|
+
*
|
|
4
|
+
* @module composition/probe/scoring
|
|
5
|
+
*/
|
|
6
|
+
function clamp01(x) {
|
|
7
|
+
if (!Number.isFinite(x))
|
|
8
|
+
return 0;
|
|
9
|
+
return Math.min(1, Math.max(0, x));
|
|
10
|
+
}
|
|
11
|
+
/** Build a score vector. @internal */
|
|
12
|
+
export function scoreCandidate(record, empirical = 0, corpusDistance = 1) {
|
|
13
|
+
const parsimony = clamp01(1 / (1 + record.complexity.astNodes / 8));
|
|
14
|
+
const validity = record.fingerprint.dimensionalSignature === 'invalid' ? 0 : 1;
|
|
15
|
+
const robustness = record.status === 'falsification-survivor' ||
|
|
16
|
+
record.status === 'expert-review-required'
|
|
17
|
+
? 1
|
|
18
|
+
: record.status === 'heldout-supported'
|
|
19
|
+
? 0.7
|
|
20
|
+
: 0.2;
|
|
21
|
+
return {
|
|
22
|
+
validity,
|
|
23
|
+
empirical: clamp01(empirical),
|
|
24
|
+
parsimony,
|
|
25
|
+
corpusDistance: clamp01(corpusDistance),
|
|
26
|
+
robustness,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function dominates(a, b) {
|
|
30
|
+
const keys = [
|
|
31
|
+
'validity',
|
|
32
|
+
'empirical',
|
|
33
|
+
'parsimony',
|
|
34
|
+
'corpusDistance',
|
|
35
|
+
'robustness',
|
|
36
|
+
];
|
|
37
|
+
let better = false;
|
|
38
|
+
for (const k of keys) {
|
|
39
|
+
if (a[k] < b[k] - 1e-12)
|
|
40
|
+
return false;
|
|
41
|
+
if (a[k] > b[k] + 1e-12)
|
|
42
|
+
better = true;
|
|
43
|
+
}
|
|
44
|
+
return better;
|
|
45
|
+
}
|
|
46
|
+
/** Pareto front (non-dominated) plus the rest, stable by id. @internal */
|
|
47
|
+
export function rankPareto(items) {
|
|
48
|
+
return items
|
|
49
|
+
.map((it) => ({
|
|
50
|
+
...it,
|
|
51
|
+
pareto: !items.some((other) => other.record.id !== it.record.id && dominates(other.scores, it.scores)),
|
|
52
|
+
}))
|
|
53
|
+
.sort((a, b) => Number(b.pareto) - Number(a.pareto) || a.record.id.localeCompare(b.record.id));
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=scoring.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scoring.js","sourceRoot":"","sources":["../../../src/composition/probe/scoring.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,SAAS,OAAO,CAAC,CAAS;IACxB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC;IAClC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACrC,CAAC;AAED,sCAAsC;AACtC,MAAM,UAAU,cAAc,CAC5B,MAA4B,EAC5B,SAAS,GAAG,CAAC,EACb,cAAc,GAAG,CAAC;IAEl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,GAAG,EAAE;QACL,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CACjB,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,MAAM,CAAC,EAAE,IAAI,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,CAClF;KACF,CAAC,CAAC;SACF,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;AACnG,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Search-budget accounting for Product B. Product A (`rankDiscoveries`) is
|
|
3
|
+
* already finite and must not grow AST-depth caps.
|
|
4
|
+
*
|
|
5
|
+
* @module composition/probe/search-budget
|
|
6
|
+
*/
|
|
7
|
+
import type { SearchBudget, SearchStopReason } from './types.js';
|
|
8
|
+
import { DEFAULT_SEARCH_BUDGET } from './types.js';
|
|
9
|
+
export { DEFAULT_SEARCH_BUDGET };
|
|
10
|
+
/** Mutable counters for one run. @internal */
|
|
11
|
+
export interface BudgetState {
|
|
12
|
+
readonly budget: SearchBudget;
|
|
13
|
+
readonly startedAtMs: number;
|
|
14
|
+
candidates: number;
|
|
15
|
+
evaluations: number;
|
|
16
|
+
}
|
|
17
|
+
/** Open a budget clock. @internal */
|
|
18
|
+
export declare function openBudget(budget?: SearchBudget): BudgetState;
|
|
19
|
+
/**
|
|
20
|
+
* First violated stop reason, or `undefined` if the search may continue.
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
export declare function budgetStopReason(state: BudgetState): SearchStopReason | undefined;
|
|
24
|
+
/** True when another candidate may be emitted. @internal */
|
|
25
|
+
export declare function canEmitCandidate(state: BudgetState): boolean;
|
|
26
|
+
//# sourceMappingURL=search-budget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-budget.d.ts","sourceRoot":"","sources":["../../../src/composition/probe/search-budget.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD,OAAO,EAAE,qBAAqB,EAAE,CAAC;AAEjC,8CAA8C;AAC9C,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,qCAAqC;AACrC,wBAAgB,UAAU,CAAC,MAAM,GAAE,YAAoC,GAAG,WAAW,CAOpF;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,GAAG,gBAAgB,GAAG,SAAS,CAMjF;AAED,4DAA4D;AAC5D,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAE5D"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Search-budget accounting for Product B. Product A (`rankDiscoveries`) is
|
|
3
|
+
* already finite and must not grow AST-depth caps.
|
|
4
|
+
*
|
|
5
|
+
* @module composition/probe/search-budget
|
|
6
|
+
*/
|
|
7
|
+
import { DEFAULT_SEARCH_BUDGET } from './types.js';
|
|
8
|
+
export { DEFAULT_SEARCH_BUDGET };
|
|
9
|
+
/** Open a budget clock. @internal */
|
|
10
|
+
export function openBudget(budget = DEFAULT_SEARCH_BUDGET) {
|
|
11
|
+
return {
|
|
12
|
+
budget,
|
|
13
|
+
startedAtMs: Date.now(),
|
|
14
|
+
candidates: 0,
|
|
15
|
+
evaluations: 0,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* First violated stop reason, or `undefined` if the search may continue.
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
export function budgetStopReason(state) {
|
|
23
|
+
const { budget } = state;
|
|
24
|
+
if (state.candidates >= budget.maxCandidates)
|
|
25
|
+
return 'candidate-limit';
|
|
26
|
+
if (state.evaluations >= budget.maxEvaluations)
|
|
27
|
+
return 'evaluation-limit';
|
|
28
|
+
if (Date.now() - state.startedAtMs >= budget.maxWallClockMs)
|
|
29
|
+
return 'time-limit';
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
/** True when another candidate may be emitted. @internal */
|
|
33
|
+
export function canEmitCandidate(state) {
|
|
34
|
+
return budgetStopReason(state) === undefined;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=search-budget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-budget.js","sourceRoot":"","sources":["../../../src/composition/probe/search-budget.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD,OAAO,EAAE,qBAAqB,EAAE,CAAC;AAUjC,qCAAqC;AACrC,MAAM,UAAU,UAAU,CAAC,SAAuB,qBAAqB;IACrE,OAAO;QACL,MAAM;QACN,WAAW,EAAE,IAAI,CAAC,GAAG,EAAE;QACvB,UAAU,EAAE,CAAC;QACb,WAAW,EAAE,CAAC;KACf,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAkB;IACjD,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;IACzB,IAAI,KAAK,CAAC,UAAU,IAAI,MAAM,CAAC,aAAa;QAAE,OAAO,iBAAiB,CAAC;IACvE,IAAI,KAAK,CAAC,WAAW,IAAI,MAAM,CAAC,cAAc;QAAE,OAAO,kBAAkB,CAAC;IAC1E,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,WAAW,IAAI,MAAM,CAAC,cAAc;QAAE,OAAO,YAAY,CAAC;IACjF,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,4DAA4D;AAC5D,MAAM,UAAU,gBAAgB,CAAC,KAAkB;IACjD,OAAO,gBAAgB,CAAC,KAAK,CAAC,KAAK,SAAS,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical JSON serialization and hashing for Product B probe artifacts.
|
|
3
|
+
*
|
|
4
|
+
* Object keys are sorted lexicographically; `undefined` properties are omitted;
|
|
5
|
+
* arrays keep encounter order. A `Date` (if somehow passed) serializes as
|
|
6
|
+
* ISO-8601 rather than as an empty object — `Object.keys(date)` is empty, so
|
|
7
|
+
* the object walk is skipped for dates.
|
|
8
|
+
*
|
|
9
|
+
* Hashes use SHA-256 over this canonical form. Experimental — not a public
|
|
10
|
+
* API stability surface (`src/index.ts` does not re-export this module).
|
|
11
|
+
*
|
|
12
|
+
* @module composition/probe/serialize
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Deterministic JSON string: sorted object keys, `undefined` omitted, arrays
|
|
16
|
+
* in encounter order. `Date` values become ISO-8601 strings.
|
|
17
|
+
*
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
export declare function canonicalJson(value: unknown): string;
|
|
21
|
+
/**
|
|
22
|
+
* SHA-256 digest of `text` as lowercase hex.
|
|
23
|
+
*
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export declare function sha256Hex(text: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* SHA-256 of {@link canonicalJson} applied to `value`.
|
|
29
|
+
*
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
export declare function hashCanonical(value: unknown): string;
|
|
33
|
+
//# sourceMappingURL=serialize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../../src/composition/probe/serialize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAGpD;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEpD"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical JSON serialization and hashing for Product B probe artifacts.
|
|
3
|
+
*
|
|
4
|
+
* Object keys are sorted lexicographically; `undefined` properties are omitted;
|
|
5
|
+
* arrays keep encounter order. A `Date` (if somehow passed) serializes as
|
|
6
|
+
* ISO-8601 rather than as an empty object — `Object.keys(date)` is empty, so
|
|
7
|
+
* the object walk is skipped for dates.
|
|
8
|
+
*
|
|
9
|
+
* Hashes use SHA-256 over this canonical form. Experimental — not a public
|
|
10
|
+
* API stability surface (`src/index.ts` does not re-export this module).
|
|
11
|
+
*
|
|
12
|
+
* @module composition/probe/serialize
|
|
13
|
+
*/
|
|
14
|
+
import { createHash } from 'node:crypto';
|
|
15
|
+
/**
|
|
16
|
+
* Deterministic JSON string: sorted object keys, `undefined` omitted, arrays
|
|
17
|
+
* in encounter order. `Date` values become ISO-8601 strings.
|
|
18
|
+
*
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export function canonicalJson(value) {
|
|
22
|
+
const json = JSON.stringify(canonicalize(value));
|
|
23
|
+
return json === undefined ? 'null' : json;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* SHA-256 digest of `text` as lowercase hex.
|
|
27
|
+
*
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
export function sha256Hex(text) {
|
|
31
|
+
return createHash('sha256').update(text, 'utf8').digest('hex');
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* SHA-256 of {@link canonicalJson} applied to `value`.
|
|
35
|
+
*
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
38
|
+
export function hashCanonical(value) {
|
|
39
|
+
return sha256Hex(canonicalJson(value));
|
|
40
|
+
}
|
|
41
|
+
function canonicalize(value) {
|
|
42
|
+
if (value === null || typeof value !== 'object') {
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
45
|
+
if (value instanceof Date) {
|
|
46
|
+
return value.toISOString();
|
|
47
|
+
}
|
|
48
|
+
if (Array.isArray(value)) {
|
|
49
|
+
return value.map((item) => (item === undefined ? null : canonicalize(item)));
|
|
50
|
+
}
|
|
51
|
+
const obj = value;
|
|
52
|
+
const sorted = {};
|
|
53
|
+
for (const key of Object.keys(obj).sort()) {
|
|
54
|
+
const item = obj[key];
|
|
55
|
+
if (item === undefined)
|
|
56
|
+
continue;
|
|
57
|
+
sorted[key] = canonicalize(item);
|
|
58
|
+
}
|
|
59
|
+
return sorted;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=serialize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialize.js","sourceRoot":"","sources":["../../../src/composition/probe/serialize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;IACjD,OAAO,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,OAAO,UAA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: recover a synthetic signal or honestly abstain. Never flips
|
|
5
|
+
* `axes.ts` `gated`.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export interface ChangepointInput {
|
|
10
|
+
readonly x: readonly number[];
|
|
11
|
+
readonly y: readonly number[];
|
|
12
|
+
}
|
|
13
|
+
export interface ChangepointResult {
|
|
14
|
+
readonly index: number | null;
|
|
15
|
+
readonly score: number;
|
|
16
|
+
readonly abstained: boolean;
|
|
17
|
+
readonly reason?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Two-mean changepoint: scan split index maximizing |μ_left − μ_right|.
|
|
21
|
+
* Abstains on short series or when the best split is weaker than `minScore`.
|
|
22
|
+
*
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
export declare function detectMeanChangepoint(input: ChangepointInput, minScore?: number): ChangepointResult;
|
|
26
|
+
export interface ScaleSymmetryInput {
|
|
27
|
+
readonly x: readonly number[];
|
|
28
|
+
readonly y: readonly number[];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Ordinary-least-squares log-log slope. Abstains if x or y are non-positive.
|
|
32
|
+
*
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
export declare function estimateScaleExponent(input: ScaleSymmetryInput): {
|
|
36
|
+
exponent: number | null;
|
|
37
|
+
abstained: boolean;
|
|
38
|
+
reason?: string;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Finite-difference conservation probe: mean |ΔQ/Δt| ≈ 0.
|
|
42
|
+
*
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
export declare function probeConservation(q: readonly number[], t: readonly number[], atol?: number): {
|
|
46
|
+
conserved: boolean;
|
|
47
|
+
meanAbsRate: number;
|
|
48
|
+
abstained: boolean;
|
|
49
|
+
reason?: string;
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=structure.d.ts.map
|
|
@@ -0,0 +1 @@
|
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