@knights-eye-chess/ai-analysis 0.0.0-stage → 0.1.0-dev.17
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/LICENSE +235 -0
- package/LICENSING.md +26 -0
- package/NOTICE +5 -0
- package/NPM-PUBLISHING.md +28 -0
- package/README.md +139 -2
- package/SOURCE-ORIGIN.json +16 -0
- package/THIRD_PARTY_NOTICES.md +18 -0
- package/build.mjs +22 -0
- package/dist/answer-pipeline.test.mjs +375 -0
- package/dist/chunk-PLKNJRPF.js +10662 -0
- package/dist/chunk-XQDZJOYD.js +2515 -0
- package/dist/index.js +146 -0
- package/dist/owner-tests/chess-reasoning-compact-search-preparation.test.mjs +963 -0
- package/dist/owner-tests/mechanism-encoding.test.mjs +529 -0
- package/dist/owner-tests/move-mechanism-facts.test.mjs +396 -0
- package/dist/owner-tests/pipeline-host-preparation.test.mjs +10556 -0
- package/dist/owner-tests/position-preparation.test.mjs +625 -0
- package/dist/owner-tests/preparation-consolidation.test.mjs +1052 -0
- package/dist/owner-tests/prose-reference-admission.test.mjs +1770 -0
- package/dist/owner-tests/score-comparison-notices.test.mjs +240 -0
- package/dist/owner-tests/simple-engine-presentation.test.mjs +233 -0
- package/dist/owner-tests/tool-input-loop-guard.test.mjs +78 -0
- package/dist/research.js +2274 -0
- package/dist/runtime-closure.json +103 -0
- package/dist/shared-runtime-closure.json +39 -0
- package/dist/shared.js +152 -0
- package/dist/types/ai-request-failure.d.ts +14 -0
- package/dist/types/ai-request-limits.d.ts +4 -0
- package/dist/types/ai-routing-diagnostics.d.ts +14 -0
- package/dist/types/chess-reasoning/ablation-adaptive-evidence-loop.d.ts +127 -0
- package/dist/types/chess-reasoning/ablation-adaptive-runtime.d.ts +178 -0
- package/dist/types/chess-reasoning/ablation-direct-synthesis.d.ts +1030 -0
- package/dist/types/chess-reasoning/ablation-evidence-bundle.d.ts +185 -0
- package/dist/types/chess-reasoning/ablation-evidence-capture.d.ts +37 -0
- package/dist/types/chess-reasoning/ablation-lean-direct-runtime.d.ts +193 -0
- package/dist/types/chess-reasoning/ablation-model-facing-evidence.d.ts +38 -0
- package/dist/types/chess-reasoning/ablation-transport-correction.d.ts +13 -0
- package/dist/types/chess-reasoning/ai-sdk-runtime-support.d.ts +93 -0
- package/dist/types/chess-reasoning/answer-host-contracts.d.ts +59 -0
- package/dist/types/chess-reasoning/answer-model-connector.d.ts +68 -0
- package/dist/types/chess-reasoning/answer-pipeline-exports.d.ts +98 -0
- package/dist/types/chess-reasoning/answer-pipeline.d.ts +41 -0
- package/dist/types/chess-reasoning/answer-reference-validation.d.ts +40 -0
- package/dist/types/chess-reasoning/answer-tool-host.d.ts +8 -0
- package/dist/types/chess-reasoning/branch-expansion-policy.d.ts +13 -0
- package/dist/types/chess-reasoning/branch-expansion.d.ts +39 -0
- package/dist/types/chess-reasoning/causal-claim-checks.d.ts +21 -0
- package/dist/types/chess-reasoning/chess-reference-dictionary.d.ts +13 -0
- package/dist/types/chess-reasoning/classification-question-target.d.ts +22 -0
- package/dist/types/chess-reasoning/classification-reassessment.d.ts +31 -0
- package/dist/types/chess-reasoning/compact-search-preparation.d.ts +7 -0
- package/dist/types/chess-reasoning/concept-registry.d.ts +99 -0
- package/dist/types/chess-reasoning/conversation-context.d.ts +12 -0
- package/dist/types/chess-reasoning/engine-search-failure.d.ts +7 -0
- package/dist/types/chess-reasoning/evidence-citation-normalization.d.ts +9 -0
- package/dist/types/chess-reasoning/evidence-licenses.d.ts +57 -0
- package/dist/types/chess-reasoning/evidence-selector-contract.d.ts +5 -0
- package/dist/types/chess-reasoning/existing-analysis-context.d.ts +104 -0
- package/dist/types/chess-reasoning/fact-observation-provider.d.ts +15 -0
- package/dist/types/chess-reasoning/fact-provider.d.ts +111 -0
- package/dist/types/chess-reasoning/fresh-engine-pv-witnesses.d.ts +67 -0
- package/dist/types/chess-reasoning/historical-prose.d.ts +23 -0
- package/dist/types/chess-reasoning/idea-graph.d.ts +34 -0
- package/dist/types/chess-reasoning/initial-search-plan.d.ts +37 -0
- package/dist/types/chess-reasoning/lossless-evidence-sharing.d.ts +18 -0
- package/dist/types/chess-reasoning/matched-comparison.d.ts +10 -0
- package/dist/types/chess-reasoning/material-accounting.d.ts +80 -0
- package/dist/types/chess-reasoning/material-format.d.ts +4 -0
- package/dist/types/chess-reasoning/mechanical-fact-provider.d.ts +33 -0
- package/dist/types/chess-reasoning/mechanical-ray-facts.d.ts +19 -0
- package/dist/types/chess-reasoning/mechanism-presentation.d.ts +9 -0
- package/dist/types/chess-reasoning/move-mechanism-facts.d.ts +45 -0
- package/dist/types/chess-reasoning/native-answer-connector.d.ts +4 -0
- package/dist/types/chess-reasoning/opening-source-contracts.d.ts +54 -0
- package/dist/types/chess-reasoning/opening-source-credits.d.ts +16 -0
- package/dist/types/chess-reasoning/opponent-threat-preparation.d.ts +7 -0
- package/dist/types/chess-reasoning/piece-identities.d.ts +11 -0
- package/dist/types/chess-reasoning/poc-contracts.d.ts +1026 -0
- package/dist/types/chess-reasoning/poc-hypotheses.d.ts +74 -0
- package/dist/types/chess-reasoning/poc-move-witnesses.d.ts +13 -0
- package/dist/types/chess-reasoning/poc-observations.d.ts +23 -0
- package/dist/types/chess-reasoning/poc-piece-refs.d.ts +12 -0
- package/dist/types/chess-reasoning/poc-plan-model.d.ts +45 -0
- package/dist/types/chess-reasoning/poc-semantic-text.d.ts +8 -0
- package/dist/types/chess-reasoning/poc-tools.d.ts +81 -0
- package/dist/types/chess-reasoning/portable-answer-runtime.d.ts +291 -0
- package/dist/types/chess-reasoning/position-analysis-contracts.d.ts +31 -0
- package/dist/types/chess-reasoning/position-analysis-scope.d.ts +3 -0
- package/dist/types/chess-reasoning/preparation-consolidation.d.ts +21 -0
- package/dist/types/chess-reasoning/production-observation-provider.d.ts +16 -0
- package/dist/types/chess-reasoning/question-routing.d.ts +326 -0
- package/dist/types/chess-reasoning/recorded-main-line.d.ts +37 -0
- package/dist/types/chess-reasoning/recorded-position-tools.d.ts +11 -0
- package/dist/types/chess-reasoning/recorded-reference-context.d.ts +13 -0
- package/dist/types/chess-reasoning/recorded-selected-classification.d.ts +36 -0
- package/dist/types/chess-reasoning/reference-limits.d.ts +2 -0
- package/dist/types/chess-reasoning/research-exports.d.ts +197 -0
- package/dist/types/chess-reasoning/saved-score-presentation.d.ts +14 -0
- package/dist/types/chess-reasoning/score-comparison-notices.d.ts +33 -0
- package/dist/types/chess-reasoning/server-simple-policy.d.ts +31 -0
- package/dist/types/chess-reasoning/simple-agent-config.d.ts +73 -0
- package/dist/types/chess-reasoning/simple-board-analysis.d.ts +85 -0
- package/dist/types/chess-reasoning/simple-compact-evidence.d.ts +7 -0
- package/dist/types/chess-reasoning/simple-completion.d.ts +23 -0
- package/dist/types/chess-reasoning/simple-engine-presentation.d.ts +3 -0
- package/dist/types/chess-reasoning/simple-evidence-preparation.d.ts +17 -0
- package/dist/types/chess-reasoning/simple-evidence-view.d.ts +17 -0
- package/dist/types/chess-reasoning/simple-explanation-coverage.d.ts +90 -0
- package/dist/types/chess-reasoning/simple-fact-delivery.d.ts +43 -0
- package/dist/types/chess-reasoning/simple-fallback-premise.d.ts +5 -0
- package/dist/types/chess-reasoning/simple-prose-references.d.ts +108 -0
- package/dist/types/chess-reasoning/simple-runtime-version.d.ts +1 -0
- package/dist/types/chess-reasoning/stable.d.ts +2 -0
- package/dist/types/chess-reasoning/tool-input-loop-guard.d.ts +5 -0
- package/dist/types/chess-reasoning/types.d.ts +180 -0
- package/dist/types/chess-reasoning/visible-support-lines.d.ts +12 -0
- package/dist/types/chess-reasoning/wikibooks-index.d.ts +30 -0
- package/dist/types/chess-reasoning/wikibooks-tool-context.d.ts +10 -0
- package/dist/types/player-perspective.d.ts +16 -0
- package/dist/types/shared-exports.d.ts +22 -0
- package/docs/API.md +82 -0
- package/docs/OWNERSHIP-ADOPTION.md +35 -0
- package/docs/OWNERSHIP-DRIFT.json +55 -0
- package/docs/RESEARCH-API.md +28 -0
- package/licenses/third-party/INVENTORY.json +202 -0
- package/licenses/third-party/ai-7.0.85/LICENSE +13 -0
- package/licenses/third-party/ai-sdk--gateway-4.0.69/LICENSE +13 -0
- package/licenses/third-party/ai-sdk--provider-4.0.9/LICENSE +13 -0
- package/licenses/third-party/ai-sdk--provider-utils-5.0.34/APACHE-2.0.txt +73 -0
- package/licenses/third-party/ai-sdk--provider-utils-5.0.34/src/to-json-schema/zod3-to-json-schema/LICENSE +16 -0
- package/licenses/third-party/chess.js-1.4.0/LICENSE +23 -0
- package/licenses/third-party/eventsource-parser-3.1.1/LICENSE +21 -0
- package/licenses/third-party/json-schema-0.4.0/LICENSE +195 -0
- package/licenses/third-party/standard-schema--spec-1.1.0/LICENSE +21 -0
- package/licenses/third-party/types--json-schema-7.0.15/LICENSE +21 -0
- package/licenses/third-party/types--node-22.19.19/LICENSE +21 -0
- package/licenses/third-party/undici-7.30.0/LICENSE +21 -0
- package/licenses/third-party/undici-7.30.0/lib/web/fetch/LICENSE +21 -0
- package/licenses/third-party/undici-types-6.21.0/LICENSE +21 -0
- package/licenses/third-party/vercel--oidc-3.2.0/LICENSE +202 -0
- package/licenses/third-party/workflow--serde-4.1.0/APACHE-2.0.txt +73 -0
- package/licenses/third-party/workflow--serde-4.1.0/LICENSE.md +3 -0
- package/licenses/third-party/zod-4.6.5/LICENSE +21 -0
- package/npm-release.json +5 -0
- package/package.json +72 -4
- package/scripts/check-release-tooling.mjs +22 -0
- package/scripts/pack.mjs +68 -0
- package/scripts/publish-reviewed.mjs +85 -0
- package/scripts/release-tooling.json +13 -0
- package/scripts/update-dependency.mjs +44 -0
- package/scripts/verify-release.mjs +52 -0
- package/src/ai-request-failure.ts +34 -0
- package/src/ai-request-limits.ts +4 -0
- package/src/ai-routing-diagnostics.ts +33 -0
- package/src/chess-reasoning/ablation-adaptive-evidence-loop.ts +515 -0
- package/src/chess-reasoning/ablation-adaptive-runtime.ts +924 -0
- package/src/chess-reasoning/ablation-direct-synthesis.ts +1128 -0
- package/src/chess-reasoning/ablation-evidence-bundle.ts +726 -0
- package/src/chess-reasoning/ablation-evidence-capture.ts +513 -0
- package/src/chess-reasoning/ablation-lean-direct-runtime.ts +670 -0
- package/src/chess-reasoning/ablation-model-facing-evidence.ts +212 -0
- package/src/chess-reasoning/ablation-transport-correction.ts +106 -0
- package/src/chess-reasoning/ai-sdk-runtime-support.ts +381 -0
- package/src/chess-reasoning/answer-host-contracts.ts +10 -0
- package/src/chess-reasoning/answer-model-connector.ts +83 -0
- package/src/chess-reasoning/answer-pipeline-exports.ts +98 -0
- package/src/chess-reasoning/answer-pipeline.ts +195 -0
- package/src/chess-reasoning/answer-reference-validation.ts +124 -0
- package/src/chess-reasoning/answer-tool-host.ts +10 -0
- package/src/chess-reasoning/branch-expansion-policy.ts +32 -0
- package/src/chess-reasoning/branch-expansion.ts +80 -0
- package/src/chess-reasoning/causal-claim-checks.ts +256 -0
- package/src/chess-reasoning/chess-reference-dictionary.ts +21 -0
- package/src/chess-reasoning/classification-question-target.ts +30 -0
- package/src/chess-reasoning/classification-reassessment.ts +34 -0
- package/src/chess-reasoning/compact-search-preparation.ts +125 -0
- package/src/chess-reasoning/concept-registry.ts +275 -0
- package/src/chess-reasoning/conversation-context.ts +29 -0
- package/src/chess-reasoning/engine-search-failure.ts +11 -0
- package/src/chess-reasoning/evidence-citation-normalization.ts +15 -0
- package/src/chess-reasoning/evidence-licenses.ts +166 -0
- package/src/chess-reasoning/evidence-selector-contract.ts +5 -0
- package/src/chess-reasoning/existing-analysis-context.ts +544 -0
- package/src/chess-reasoning/fact-observation-provider.ts +134 -0
- package/src/chess-reasoning/fact-provider.ts +250 -0
- package/src/chess-reasoning/fresh-engine-pv-witnesses.ts +128 -0
- package/src/chess-reasoning/historical-prose.ts +116 -0
- package/src/chess-reasoning/idea-graph.ts +224 -0
- package/src/chess-reasoning/initial-search-plan.ts +115 -0
- package/src/chess-reasoning/lossless-evidence-sharing.ts +135 -0
- package/src/chess-reasoning/matched-comparison.ts +40 -0
- package/src/chess-reasoning/material-accounting.ts +55 -0
- package/src/chess-reasoning/material-format.ts +47 -0
- package/src/chess-reasoning/mechanical-fact-provider.ts +1602 -0
- package/src/chess-reasoning/mechanical-ray-facts.ts +123 -0
- package/src/chess-reasoning/mechanism-presentation.ts +94 -0
- package/src/chess-reasoning/move-mechanism-facts.ts +185 -0
- package/src/chess-reasoning/native-answer-connector.ts +13 -0
- package/src/chess-reasoning/opening-source-contracts.ts +47 -0
- package/src/chess-reasoning/opening-source-credits.ts +53 -0
- package/src/chess-reasoning/opponent-threat-preparation.ts +98 -0
- package/src/chess-reasoning/piece-identities.ts +159 -0
- package/src/chess-reasoning/poc-contracts.ts +1097 -0
- package/src/chess-reasoning/poc-hypotheses.ts +759 -0
- package/src/chess-reasoning/poc-move-witnesses.ts +170 -0
- package/src/chess-reasoning/poc-observations.ts +611 -0
- package/src/chess-reasoning/poc-piece-refs.ts +62 -0
- package/src/chess-reasoning/poc-plan-model.ts +345 -0
- package/src/chess-reasoning/poc-semantic-text.ts +10 -0
- package/src/chess-reasoning/poc-tools.ts +978 -0
- package/src/chess-reasoning/portable-answer-runtime.ts +684 -0
- package/src/chess-reasoning/position-analysis-contracts.ts +88 -0
- package/src/chess-reasoning/position-analysis-scope.ts +20 -0
- package/src/chess-reasoning/preparation-consolidation.ts +91 -0
- package/src/chess-reasoning/production-observation-provider.ts +41 -0
- package/src/chess-reasoning/question-routing.ts +332 -0
- package/src/chess-reasoning/recorded-main-line.ts +55 -0
- package/src/chess-reasoning/recorded-position-tools.ts +78 -0
- package/src/chess-reasoning/recorded-reference-context.ts +44 -0
- package/src/chess-reasoning/recorded-selected-classification.ts +54 -0
- package/src/chess-reasoning/reference-limits.ts +2 -0
- package/src/chess-reasoning/research-exports.ts +197 -0
- package/src/chess-reasoning/saved-score-presentation.ts +6 -0
- package/src/chess-reasoning/score-comparison-notices.ts +115 -0
- package/src/chess-reasoning/server-simple-policy.ts +75 -0
- package/src/chess-reasoning/simple-agent-config.ts +58 -0
- package/src/chess-reasoning/simple-board-analysis.ts +57 -0
- package/src/chess-reasoning/simple-compact-evidence.ts +79 -0
- package/src/chess-reasoning/simple-completion.ts +37 -0
- package/src/chess-reasoning/simple-engine-presentation.ts +95 -0
- package/src/chess-reasoning/simple-evidence-preparation.ts +32 -0
- package/src/chess-reasoning/simple-evidence-view.ts +69 -0
- package/src/chess-reasoning/simple-explanation-coverage.ts +118 -0
- package/src/chess-reasoning/simple-fact-delivery.ts +52 -0
- package/src/chess-reasoning/simple-fallback-premise.ts +65 -0
- package/src/chess-reasoning/simple-prose-references.ts +528 -0
- package/src/chess-reasoning/simple-runtime-version.ts +2 -0
- package/src/chess-reasoning/stable.ts +18 -0
- package/src/chess-reasoning/tool-input-loop-guard.ts +38 -0
- package/src/chess-reasoning/types.ts +195 -0
- package/src/chess-reasoning/visible-support-lines.ts +44 -0
- package/src/chess-reasoning/wikibooks-index.ts +56 -0
- package/src/chess-reasoning/wikibooks-tool-context.ts +91 -0
- package/src/player-perspective.ts +41 -0
- package/src/shared-exports.ts +23 -0
- package/test/answer-pipeline.test.mjs +375 -0
- package/test/owner/chess-reasoning-compact-search-preparation.test.mjs +111 -0
- package/test/owner/mechanism-encoding.test.mjs +78 -0
- package/test/owner/move-mechanism-facts.test.mjs +105 -0
- package/test/owner/pipeline-host-preparation.test.mjs +115 -0
- package/test/owner/position-preparation.test.mjs +22 -0
- package/test/owner/preparation-consolidation.test.mjs +74 -0
- package/test/owner/prose-reference-admission.test.mjs +26 -0
- package/test/owner/score-comparison-notices.test.mjs +116 -0
- package/test/owner/simple-engine-presentation.test.mjs +50 -0
- package/test/owner/tool-input-loop-guard.test.mjs +25 -0
- package/test-types.mts +23 -0
- package/tsconfig.json +22 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { savedScorePresentation } from './saved-score-presentation';
|
|
2
|
+
import { Chess } from "chess.js";
|
|
3
|
+
import type { RecordedMainLine, RecordedMoveAnalysis } from "./answer-host-contracts";
|
|
4
|
+
import { REASONING_POC_VERSION, reasoningContextHash, type ReasoningPositionContext, type ReasoningEvidenceRecord } from "./poc-contracts";
|
|
5
|
+
|
|
6
|
+
/** Recorded moves are legal witnesses, never best-play/score or intent evidence. */
|
|
7
|
+
function validRecordedAnalysis(value: RecordedMoveAnalysis | undefined, before: string, after: string, uci: string): value is RecordedMoveAnalysis {
|
|
8
|
+
if (!value || value.version !== "recorded-move-analysis/1" || value.fenBefore !== before || value.fenAfter !== after || value.moveUci !== uci) return false;
|
|
9
|
+
const boundedText = (s: unknown, max: number) => typeof s === "string" && s.length > 0 && s.length <= max && /^[a-zA-Z0-9@._/ +:-]+$/.test(s);
|
|
10
|
+
const depth = (n: unknown) => Number.isInteger(n) && (n as number) > 0 && (n as number) <= 256;
|
|
11
|
+
const score = (n: unknown) => n === null || (typeof n === "number" && Number.isFinite(n) && Math.abs(n) <= 1_000_000);
|
|
12
|
+
return boundedText(value.engine, 64) && boundedText(value.classification, 40) && depth(value.actualDepth)
|
|
13
|
+
&& depth(value.requestedDepth) && Number.isInteger(value.classifierVersion) && value.classifierVersion > 0 && value.classifierVersion <= 100_000
|
|
14
|
+
&& [value.beforeCp, value.afterCp, value.lossCp, value.mateBefore, value.mateAfter].every(score);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function recordedMainLineResult(line: RecordedMainLine, context: ReasoningPositionContext) {
|
|
18
|
+
if (!line || !Array.isArray(line.moves) || line.moves.length > 512 || !Number.isInteger(line.selectedIndex) || line.selectedIndex < -1
|
|
19
|
+
|| !Number.isInteger(line.totalPlies) || line.totalPlies < line.moves.length || line.selectedIndex >= line.totalPlies || line.truncated !== (line.totalPlies > line.moves.length)) throw Error("Invalid recorded main line.");
|
|
20
|
+
const atStart = context.kind === "position";
|
|
21
|
+
if (atStart && (line.selectedAtStart !== true || line.selectedIndex !== -1 || line.startFen !== context.fenAfter)) throw Error("Recorded starting-position scope mismatch.");
|
|
22
|
+
if (!atStart && line.selectedAtStart) throw Error("Recorded anchor kind mismatch.");
|
|
23
|
+
const chess = new Chess(line.startFen);
|
|
24
|
+
// A branch has no selected main-line index, so its root must be checked directly.
|
|
25
|
+
// Legacy move contexts omit historyStartFen and replay from the standard start.
|
|
26
|
+
const historyRoot = new Chess(atStart ? context.fenAfter : context.historyStartFen).fen();
|
|
27
|
+
if (chess.fen() !== historyRoot) throw Error("Recorded main-line root mismatch.");
|
|
28
|
+
const rows: Array<[number, string, number, number, number, string, number | null, number | null, number | null, number | null, number | null]> = [];
|
|
29
|
+
const moves = line.moves.map((item, index) => {
|
|
30
|
+
if (!/^[a-h][1-8][a-h][1-8][qrbn]?$/.test(item.uci)) throw Error("Invalid recorded move.");
|
|
31
|
+
const before = chess.fen(), move = chess.move({ from: item.uci.slice(0, 2), to: item.uci.slice(2, 4), promotion: item.uci.slice(4) || undefined });
|
|
32
|
+
if (move.san !== item.san) throw Error("Recorded SAN mismatch.");
|
|
33
|
+
if (index === line.selectedIndex && (before !== context.fenBefore || chess.fen() !== context.fenAfter || item.uci !== context.moveUci
|
|
34
|
+
|| index !== context.historyUci.length || line.moves.slice(0, index).some((m, i) => m.uci !== context.historyUci[i]))) throw Error("Recorded question scope mismatch.");
|
|
35
|
+
const a = item.analysis;
|
|
36
|
+
if (validRecordedAnalysis(a, before, chess.fen(), item.uci)) { const score=savedScorePresentation(a); rows.push([index + 1, a.engine, a.actualDepth,
|
|
37
|
+
a.requestedDepth, a.classifierVersion, a.classification, score.beforeCp, score.afterCp, score.lossCp, score.mateBefore, score.mateAfter]); }
|
|
38
|
+
return { uci: item.uci, san: move.san, moveNumber: Number(before.split(" ")[5]), color: move.color };
|
|
39
|
+
});
|
|
40
|
+
const continuation = atStart ? moves.map(move => move.uci) : line.selectedIndex >= 0 && line.selectedIndex < moves.length ? moves.slice(line.selectedIndex + 1).map(move => move.uci) : [];
|
|
41
|
+
const contextHash = reasoningContextHash(context);
|
|
42
|
+
const evidence: ReasoningEvidenceRecord[] = continuation.length ? [{ schemaVersion: REASONING_POC_VERSION,
|
|
43
|
+
id: `evidence:recorded-main-line:${contextHash}:${continuation.slice(0, 32).join("-")}`, contextHash, kind: "fact", source: "loaded-game-main-line", proofStrength: "observed",
|
|
44
|
+
licenses: ["chess.legality", "chess.identity"], summary: "Legally replayed recorded main-line continuation; not an engine recommendation or proof of intent.",
|
|
45
|
+
data: { authority: "legal-exact", scope: "sequence-legality-and-identity", phase: "after" },
|
|
46
|
+
coverage: { complete: false, covered: [], unresolved: ["No optimality or human-intent claim."] },
|
|
47
|
+
replay: { fen: context.fenAfter, movesUci: continuation.slice(0, 32) } }] : [];
|
|
48
|
+
return { contextHash, evidence, recordedAnalysis: { source: "Current loaded game's stored per-move analysis snapshots", authority: "attributed-existing-analysis",
|
|
49
|
+
scorePerspective: "mover-at-each-recorded-ply", units: "centipawns; mate separate", coverage: { analyzedPlies: rows.length, totalPlies: line.totalPlies, complete: !line.truncated && rows.length === line.totalPlies },
|
|
50
|
+
columns: ["ply", "engine", "reportedDepth", "recordedRequestedDepth", "classifierVersion", "classification", "beforeCp", "afterCp", "lossCp", "mateBefore", "mateAfter"], rows,
|
|
51
|
+
limitations: ["reportedDepth is the stored classification depth, not a verified root-search depth; recordedRequestedDepth is the board setting recorded when classified.", "Matching stored edge analyses are included even when their engine, classifier version or dependency fingerprint is no longer current; missing or invalid plies have no analysis row.", "Scores are from the mover's perspective at each row's ply: positive favors that move's color; lossCp is a saved before/after search delta for that mover, not a controlled regret comparison. Mate-related/sentinel centipawn fields are null; use mateBefore/mateAfter. Best or Forced labels can coexist with search-score changes.", "Classification is a historical decision from the reported classifier version, not necessarily current policy or proof of its explanation. Saved scores may differ from fresh searches.", ...(line.truncated ? ["Analysis is limited to the first 512 recorded plies."] : [])] },
|
|
52
|
+
recordedMainLine: { source: "Current loaded game's recorded primary line (may contain user edits)", startFen: line.startFen, moves,
|
|
53
|
+
selectedIndex: line.selectedIndex, selectedAtStart: atStart, selectedOnMainLine: atStart || line.selectedIndex >= 0, totalPlies: line.totalPlies, truncated: line.truncated, pgn: chess.pgn() },
|
|
54
|
+
limitations: ["PGN is reconstructed from recorded moves; original headers, clocks and result metadata are not included.", "Recorded play is not engine evidence of best play, force, safety or human intent.", ...(!atStart && line.selectedIndex < 0 ? ["The question is on a branch; this main line is not its continuation."] : []), ...(line.truncated ? ["Only the first 512 plies are returned."] : [])] };
|
|
55
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Chess } from 'chess.js';
|
|
2
|
+
import type { RecordedMainLine } from './answer-host-contracts';
|
|
3
|
+
import { recordedMainLineResult } from './recorded-main-line';
|
|
4
|
+
import { createPocToolHost, type PocToolHostOptions } from './poc-tools';
|
|
5
|
+
import { reasoningContextHash, type ReasoningPositionContext, type ReasoningToolDescriptor, type ReasoningToolSet, type ReasoningToolResult } from './poc-contracts';
|
|
6
|
+
import { stableHash } from './stable';
|
|
7
|
+
|
|
8
|
+
export const RECORDED_POSITION_TOOLS = ['analyze_game_position', 'test_game_line'] as const;
|
|
9
|
+
export const isRecordedPositionTool = (name: string) => (RECORDED_POSITION_TOOLS as readonly string[]).includes(name);
|
|
10
|
+
const moves = { type:'array', maxItems:32, items:{type:'string',maxLength:5,pattern:'^[a-h][1-8][a-h][1-8][qrbn]?$'} };
|
|
11
|
+
const common = { ply:{type:'integer',minimum:0,maximum:512}, depth:{type:'integer',minimum:18,maximum:18}, minimumPvPlies:{type:'integer',minimum:1,maximum:32} };
|
|
12
|
+
export const RECORDED_POSITION_DESCRIPTORS: ReasoningToolDescriptor[] = [
|
|
13
|
+
{name:'analyze_game_position',category:'probe',description:'analyze_game_position',inputSchema:{type:'object',additionalProperties:false,required:['ply'],properties:{...common,rootMoves:{...moves,minItems:1,maxItems:6},multiPv:{type:'integer',minimum:1,maximum:3}}}},
|
|
14
|
+
{name:'test_game_line',category:'probe',description:'test_game_line',inputSchema:{type:'object',additionalProperties:false,required:['ply','movesUci'],properties:{...common,movesUci:{...moves,minItems:1},analyzeFinal:{type:'boolean'},compareFinalMovesUci:{...moves,minItems:1,maxItems:6},inspectPlies:{type:'array',maxItems:8,items:{type:'integer',minimum:1,maximum:32}},inspectSquares:{type:'array',maxItems:12,items:{type:'string',maxLength:2,pattern:'^[a-h][1-8]$'}}}}},
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
/** No caller supplied FEN. Every root is an exact occurrence in the frozen record. */
|
|
18
|
+
export function recordedPositionContext(line: RecordedMainLine, ply: number): ReasoningPositionContext {
|
|
19
|
+
if (!Number.isInteger(ply) || ply < 0 || ply > line.moves.length) throw Object.assign(Error(`ply must be between 0 and ${line.moves.length}; 0 is the initial position`),{code:'invalid-recorded-ply',field:'ply',expected:`integer 0..${line.moves.length}`});
|
|
20
|
+
const chess=new Chess(line.startFen), prefix=line.moves.slice(0,ply);
|
|
21
|
+
let before=chess.fen();
|
|
22
|
+
for(const item of prefix){before=chess.fen(); const m=chess.move({from:item.uci.slice(0,2),to:item.uci.slice(2,4),promotion:item.uci.slice(4)||undefined}); if(m.san!==item.san)throw Error('recorded-SAN-mismatch');}
|
|
23
|
+
const id=`recorded:${stableHash({startFen:line.startFen,moves:line.moves.map(m=>m.uci)})}:${ply}`;
|
|
24
|
+
return ply===0 ? {kind:'position',nodeId:id,historyStartFen:line.startFen,historyUci:[],fenBefore:chess.fen(),fenAfter:chess.fen(),moveUci:'',moveSan:''}
|
|
25
|
+
: {nodeId:id,historyStartFen:line.startFen,historyUci:prefix.slice(0,-1).map(m=>m.uci),fenBefore:before,fenAfter:chess.fen(),moveUci:prefix.at(-1)!.uci,moveSan:prefix.at(-1)!.san};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function withRecordedPositionTools(selected: ReasoningPositionContext, base: ReasoningToolSet, options: PocToolHostOptions, getLine: (signal?:AbortSignal)=>Promise<RecordedMainLine>): ReasoningToolSet {
|
|
29
|
+
const hash=reasoningContextHash(selected);
|
|
30
|
+
let frozen: RecordedMainLine | undefined;
|
|
31
|
+
return {
|
|
32
|
+
reservesSearchAtDispatch:true,
|
|
33
|
+
descriptors:()=>[...base.descriptors(),...RECORDED_POSITION_DESCRIPTORS],
|
|
34
|
+
seedEvidence:records=>base.seedEvidence?.(records),
|
|
35
|
+
async execute(name,args,signal,execution){
|
|
36
|
+
if(!isRecordedPositionTool(name))return base.execute(name,args,signal,execution);
|
|
37
|
+
signal?.throwIfAborted();
|
|
38
|
+
if(args.contextHash!==hash || typeof args.callId!=='string')throw Error('stale-recorded-tool-envelope');
|
|
39
|
+
if(!frozen){const line=structuredClone(await getLine(signal));recordedMainLineResult(line,selected);frozen=line;}
|
|
40
|
+
signal?.throwIfAborted();
|
|
41
|
+
const root=recordedPositionContext(frozen,Number(args.ply)), rootHash=reasoningContextHash(root);
|
|
42
|
+
// Never carry a selected-edge leading alternative into another root.
|
|
43
|
+
const host=createPocToolHost(root,{...options,leadingAlternative:undefined});
|
|
44
|
+
const board=new Chess(root.fenAfter);
|
|
45
|
+
const tool=name==='test_game_line'?'test_line':args.rootMoves?'compare_moves':board.isCheckmate()||board.isStalemate()?'inspect_position':'explore_continuations';
|
|
46
|
+
const request={contextHash:rootHash,callId:args.callId,phase:'after',depth:args.depth??18,minimumPvPlies:args.minimumPvPlies??10,
|
|
47
|
+
...(tool==='test_line'?{movesUci:args.movesUci,analyzeFinal:args.analyzeFinal,compareFinalMovesUci:args.compareFinalMovesUci,inspectSquares:args.inspectSquares,inspectPlies:args.inspectPlies}:tool==='compare_moves'?{movesUci:args.rootMoves}:{multiPv:args.multiPv??3})};
|
|
48
|
+
const result=await host.execute(tool,request,signal,execution);
|
|
49
|
+
const recordedPosition={recordHash:stableHash({startFen:frozen.startFen,moves:frozen.moves.map(m=>m.uci)}),ply:Number(args.ply),startFen:frozen.startFen,fen:root.fenAfter,historyUci:frozen.moves.slice(0,Number(args.ply)).map(m=>m.uci),rootContextHash:rootHash,
|
|
50
|
+
nextRecordedMove:frozen.moves[Number(args.ply)]?.san??null,scope:'position after exactly ply recorded half-moves; independent of board selection'};
|
|
51
|
+
return {...result,tool:name,contextHash:hash,data:{recordedPosition,details:result.data},
|
|
52
|
+
evidence:result.evidence.map(e=>({...e,id:`evidence:game:${hash}:${rootHash}:${e.id.replaceAll(':','-')}`,contextHash:hash,data:{recordedPosition,details:e.data}})),
|
|
53
|
+
limitations:[...result.limitations,'Historical root: phases and piece identities inside details refer only to recordedPosition. Use game:PLY:uci,uci links for this exact recorded ply and witnessed local path; selected before/after links cannot address this root.']} satisfies ReasoningToolResult;
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Request-local exact successful result reuse, including automatically prepared searches. */
|
|
59
|
+
export function memoizeToolResults(host: ReasoningToolSet): ReasoningToolSet {
|
|
60
|
+
const cache=new Map<string,ReasoningToolResult>();
|
|
61
|
+
return {...host,async execute(name,args,signal,execution){
|
|
62
|
+
signal?.throwIfAborted();
|
|
63
|
+
const {callId,...input}=args;
|
|
64
|
+
const key=JSON.stringify([name,Object.keys(input).sort().map(k=>[k,input[k]])]);
|
|
65
|
+
const old=cache.get(key);
|
|
66
|
+
if(old)return {...structuredClone(old),callId:String(callId),durationMs:0,limitations:[...old.limitations,'Reused the exact successful request-local result; no new engine search.']};
|
|
67
|
+
const result=await host.execute(name,args,signal,execution);
|
|
68
|
+
signal?.throwIfAborted();
|
|
69
|
+
const short=result.evidence.some(e=>{
|
|
70
|
+
const d=(e.data.recordedPosition?e.data.details:e.data) as Record<string,unknown>;
|
|
71
|
+
const minimum=Number((d.searchScope as Record<string,unknown>|undefined)?.minimumPvPlies??1);
|
|
72
|
+
return Array.isArray(d.lines)&&d.lines.some(line=>line.pv.length<minimum&&line.pvCompletion?.status!=='terminal');
|
|
73
|
+
});
|
|
74
|
+
// A short legal line is valid evidence, but not coverage for a longer request.
|
|
75
|
+
if(result.support==='supported' && result.evidence.length && !short)cache.set(key,structuredClone(result));
|
|
76
|
+
return result;
|
|
77
|
+
}};
|
|
78
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Chess } from 'chess.js';
|
|
2
|
+
import { reasoningContextHash, type ReasoningPositionContext } from './poc-contracts';
|
|
3
|
+
|
|
4
|
+
/** Reconstruct an occurrence from its ordered history, never from a FEN guess. */
|
|
5
|
+
export function historyPositionContext(startFen: string, history: string[]): ReasoningPositionContext {
|
|
6
|
+
if (!Array.isArray(history) || history.length > 512) throw Error('Invalid recorded history');
|
|
7
|
+
const board = new Chess(startFen); let before = board.fen(), san = '';
|
|
8
|
+
for (const uci of history) {
|
|
9
|
+
if (typeof uci !== 'string' || !/^[a-h][1-8][a-h][1-8][qrbn]?$/.test(uci)) throw Error('Invalid recorded move');
|
|
10
|
+
before = board.fen(); san = board.move({from:uci.slice(0,2),to:uci.slice(2,4),promotion:uci[4]}).san;
|
|
11
|
+
}
|
|
12
|
+
return history.length ? {nodeId:'recorded-reference',historyStartFen:startFen,historyUci:history.slice(0,-1),fenBefore:before,fenAfter:board.fen(),moveUci:history.at(-1)!,moveSan:san}
|
|
13
|
+
: {kind:'position',nodeId:'recorded-reference',historyStartFen:startFen,historyUci:[],fenBefore:board.fen(),fenAfter:board.fen(),moveUci:'',moveSan:''};
|
|
14
|
+
}
|
|
15
|
+
export function recordedEvidenceContext(selected: ReasoningPositionContext, value: unknown): ReasoningPositionContext {
|
|
16
|
+
const p=value as {startFen:string;historyUci:string[];ply:number;fen:string;rootContextHash:string;recordHash:string};
|
|
17
|
+
if (!p || p.startFen !== (selected.historyStartFen ?? new Chess().fen()) || !Array.isArray(p.historyUci) || p.ply !== p.historyUci.length) throw Error('Invalid recorded scope');
|
|
18
|
+
const root=historyPositionContext(p.startFen,p.historyUci);
|
|
19
|
+
if (typeof p.recordHash !== 'string' || reasoningContextHash({...root,nodeId:`recorded:${p.recordHash}:${p.ply}`}) !== p.rootContextHash) throw Error('Recorded identity mismatch');
|
|
20
|
+
if (root.fenAfter !== p.fen) throw Error('Recorded root mismatch');
|
|
21
|
+
return root;
|
|
22
|
+
}
|
|
23
|
+
export function recordedNavigation(context: ReasoningPositionContext, recorded?: ReasoningPositionContext) {
|
|
24
|
+
return recorded ? {anchorEdgeId:`recorded-reference:${reasoningContextHash(recorded)}`,context:recorded} : {context};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Reject contradictory engine scope before promoting its paths to navigation/theory. */
|
|
28
|
+
export function recordedDetailsMatch(root: ReasoningPositionContext, value: unknown): boolean {
|
|
29
|
+
try {
|
|
30
|
+
const d=value as {phase?:string;played?:{uci:string;san?:string}[];finalFen?:string;searchScope?:{fen?:string};lines?:{pv:string[];rootMove:string;scoreScope?:{fen?:string}}[]};
|
|
31
|
+
if (!d || (d.phase !== undefined && d.phase !== 'after')) return false;
|
|
32
|
+
const board=new Chess(root.fenAfter);
|
|
33
|
+
if(d.played)for(const move of d.played) {
|
|
34
|
+
const m=board.move({from:move.uci.slice(0,2),to:move.uci.slice(2,4),promotion:move.uci[4]});
|
|
35
|
+
if(move.san!==undefined && move.san!==m.san)return false;
|
|
36
|
+
}
|
|
37
|
+
if(d.finalFen!==undefined && board.fen()!==d.finalFen)return false;
|
|
38
|
+
if(d.searchScope?.fen!==undefined && d.searchScope.fen!==board.fen())return false;
|
|
39
|
+
if(d.lines)for(const line of d.lines) {
|
|
40
|
+
if(!Array.isArray(line.pv) || line.rootMove!==line.pv[0] || (line.scoreScope?.fen!==undefined && line.scoreScope.fen!==board.fen()))return false;
|
|
41
|
+
}
|
|
42
|
+
return true;
|
|
43
|
+
} catch { return false; }
|
|
44
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Chess } from 'chess.js';
|
|
2
|
+
import type { RecordedMainLine } from './answer-host-contracts';
|
|
3
|
+
import { recordedMainLineResult } from './recorded-main-line';
|
|
4
|
+
import { REASONING_POC_VERSION, reasoningContextHash, validateReasoningPositionContext, type ReasoningPositionContext, type ReasoningEvidenceRecord } from './poc-contracts';
|
|
5
|
+
import { EVIDENCE_LICENSE } from './evidence-licenses';
|
|
6
|
+
import { stableHash } from './stable';
|
|
7
|
+
|
|
8
|
+
/** A historical badge is not a refreshed board analysis or a new classification. */
|
|
9
|
+
export function recordedSelectedClassification(context: ReasoningPositionContext, line: RecordedMainLine | undefined) {
|
|
10
|
+
if (context.kind === 'position' || !line || line.selectedAtStart || !Array.isArray(line.moves)
|
|
11
|
+
|| !Number.isInteger(line.selectedIndex) || line.selectedIndex < 0 || line.selectedIndex >= line.moves.length
|
|
12
|
+
|| line.selectedIndex !== context.historyUci.length || line.moves.length > 512
|
|
13
|
+
|| line.startFen !== (context.historyStartFen ?? new Chess().fen())) return undefined;
|
|
14
|
+
try {
|
|
15
|
+
validateReasoningPositionContext(context);
|
|
16
|
+
const selected = line.moves[line.selectedIndex];
|
|
17
|
+
if (selected.san !== context.moveSan || selected.uci !== context.moveUci) return undefined;
|
|
18
|
+
// Replay only the observed prefix. Neither validation nor output requires future play.
|
|
19
|
+
const prefix = line.moves.slice(0, line.selectedIndex + 1);
|
|
20
|
+
const validated = recordedMainLineResult({...line, moves: prefix, totalPlies: prefix.length, truncated: false}, context);
|
|
21
|
+
const row = validated.recordedAnalysis.rows.find(item => item[0] === line.selectedIndex + 1);
|
|
22
|
+
if (!row) return undefined;
|
|
23
|
+
const [ply, engine, recordedDepth, requestedDepth, classifierVersion, classification,
|
|
24
|
+
beforeCp, afterCp, lossCp, mateBefore, mateAfter] = row;
|
|
25
|
+
const snapshot = {
|
|
26
|
+
version: 'recorded-selected-classification/1' as const,
|
|
27
|
+
authority: 'historical-reported-label-only',
|
|
28
|
+
source: 'loaded-game-stored-selected-move-analysis',
|
|
29
|
+
position: { fenBefore: context.fenBefore, fenAfter: context.fenAfter, moveUci: context.moveUci, moveSan: context.moveSan, ply },
|
|
30
|
+
classification, classifierVersion, engine, reportedDepth: recordedDepth, recordedRequestedDepth: requestedDepth,
|
|
31
|
+
freshlyRecomputed: false,
|
|
32
|
+
savedEvaluation: { perspective: 'selected-mover', units: 'centipawns; mate separate', beforeCp, afterCp, lossCp, mateBefore, mateAfter },
|
|
33
|
+
limitations: [
|
|
34
|
+
'This is the recorded classification under the supplied historical classifier version, not necessarily the current app badge or current policy.',
|
|
35
|
+
'Preparation and subsequent engine searches do not recompute this stored label. Prefer a separately supplied refreshed board classification when available.',
|
|
36
|
+
'The label is not proof of its chess explanation. Saved scores may differ from fresh searches; lossCp is a saved search delta, not a matched comparison.',
|
|
37
|
+
'No future recorded moves, alternative candidates or other moves\' classifications are included.',
|
|
38
|
+
],
|
|
39
|
+
};
|
|
40
|
+
const contextHash = reasoningContextHash(context);
|
|
41
|
+
const record: ReasoningEvidenceRecord = {
|
|
42
|
+
schemaVersion: REASONING_POC_VERSION, id: `evidence:recorded-selected-classification:${stableHash({contextHash,snapshot})}`,
|
|
43
|
+
contextHash, kind: 'context', source: snapshot.source, proofStrength: null,
|
|
44
|
+
summary: `The stored analysis labelled ${context.moveSan} ${classification} under classifier version ${classifierVersion}; this is historical reported context, not a new classification.`,
|
|
45
|
+
data: snapshot, coverage: {complete:false, covered:['historical-selected-classification'], unresolved:['current-policy-classification','causal-explanation']},
|
|
46
|
+
replay: {fen:context.fenBefore,moveUci:context.moveUci}, licenses:[EVIDENCE_LICENSE.ATTENTION_AFFORDANCE],
|
|
47
|
+
};
|
|
48
|
+
return { record, snapshot: {...snapshot, evidenceId:record.id} };
|
|
49
|
+
} catch {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export type RecordedSelectedClassification = ReturnType<typeof recordedSelectedClassification>;
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/** Experimental evidence and replay surface. See docs/RESEARCH-API.md. */
|
|
2
|
+
export {SIMPLE_SYSTEM,SIMPLE_REFERENCE_INSTRUCTIONS,SIMPLE_STOPPING_GUIDANCE,SIMPLE_PURPOSE_GUIDANCE,SIMPLE_SEARCH_BREADTH_GUIDANCE,SIMPLE_SECTION_GUIDANCE,SIMPLE_CONTENT_SELECTION_GUIDANCE,SIMPLE_EXAMPLE_GUIDANCE,COMPACT_ENGINE_INSTRUCTIONS,FACT_DELIVERY_INSTRUCTIONS,OPENING_SOURCE_INSTRUCTIONS,SIMPLE_BOARD_ANALYSIS_GUIDANCE,SIMPLE_EXPLANATION_GUIDANCE,stabilizeSimplePolicy,MECHANISM_FACT_INSTRUCTIONS,CONVERSATION_CONTEXT_INSTRUCTIONS} from './server-simple-policy';
|
|
3
|
+
export type {SimplePolicyOptions} from './server-simple-policy';
|
|
4
|
+
export {enrichAblationEvidenceBundleWithAdmittedCaptureResponses,CAPTURE_RESPONSE_FACT_KIND,COMPLETED_TOOL_REPLAY_ADMISSION_KEY} from './ablation-evidence-capture';
|
|
5
|
+
export {ABLATION_EVIDENCE_BUNDLE_VERSION,validateAblationEvidenceClosureBundle,PRECOMMITTED_PROBE_ATTRIBUTION_CATEGORIES,validateAblationProbeTelemetry,createAblationEvidenceClosureBundle,enrichAblationEvidenceClosureBundle,ABLATION_PROBE_TELEMETRY_VERSION,createAblationProbeTelemetry,ablationHistoryThroughTargetHash,precommittedProbeAttributionCategories} from './ablation-evidence-bundle';
|
|
6
|
+
export type {AblationEvidenceClosureBundle,ProbeAttributionCategory,AblationProbeTelemetry,AblationEvidenceClosureCoverage,AblationProbeEffect} from './ablation-evidence-bundle';
|
|
7
|
+
export {createDefaultObservationProvider,DETERMINISTIC_OBSERVATION_PROVIDER_VERSION,QUESTION_SALIENCE_POLICY_VERSION,DeterministicObservationProvider,CompositeObservationProvider,QuestionConditionedSaliencePolicy} from './poc-observations';
|
|
8
|
+
export {stableHash,stableJson} from './stable';
|
|
9
|
+
export {ABLATION_DIRECT_SYNTHESIS_VERSION,DIRECT_SYNTHESIS_PROPOSAL_JSON_SCHEMA,materializeDirectSynthesis,parseDirectSynthesisProposal} from './ablation-direct-synthesis';
|
|
10
|
+
export type {DirectSynthesisArtifact,DirectSynthesisIssue} from './ablation-direct-synthesis';
|
|
11
|
+
export {projectAblationEvidenceForModel,compactLeanEvidencePacket} from './ablation-model-facing-evidence';
|
|
12
|
+
export {bytes,emitObservableTrace,numericUsage,AI_SDK_ANSWER_OBLIGATION_RUNTIME,reasoningMetrics,requestId,AI_SDK_CRITIC_RUNTIME,classifyReasoningCriticHarnessRejection,AI_SDK_DISCOURSE_RUNTIME,abortSource,classifyRuntimeFailure,deepestError,AI_SDK_GRAPH_PLANNING_RUNTIME,GraphSelectionHarnessRejection,classifyGraphSelectionHarnessRejection,AI_SDK_GRAPH_SELECTION_RUNTIME,AI_SDK_HYPOTHESIS_RUNTIME,HypothesisProviderRuntimeFailure,classifyProviderHypothesisRejection,AI_SDK_RENDER_RUNTIME,AI_SDK_REPAIR_RUNTIME,AI_SDK_PURPOSE_PROBE_RUNTIME,AI_SDK_RESOLUTION_AUDIT_RUNTIME,AI_SDK_REASONING_RUNTIME,AI_SDK_TERMINAL_REVIEW_RUNTIME,DETERMINISTIC_DISCOURSE_RUNTIME,CriticResolutionAuditHarnessRejection,HypothesisHarnessRejection,HypothesisReviewHarnessRejection,TerminalReviewHarnessRejection,ReasoningCriticHarnessRejection,ReasoningWorkflowFailure,classifyGraphSelectionRuntimeFailure,classifyHypothesisHarnessRejection,observableTraceMessages} from './ai-sdk-runtime-support';
|
|
13
|
+
export type {ObservableLlmTraceSink,SanitizedHttpAttempt,ObservableLlmTraceEvent} from './ai-sdk-runtime-support';
|
|
14
|
+
export {AblationTransportCorrectionError,assertTransportOnlyDirectCorrection,isTransportCorrectableDirectSynthesisIssues} from './ablation-transport-correction';
|
|
15
|
+
export {effectiveLicensesForRecord,EVIDENCE_LICENSE,licensesSemanticChessGrounding,withEvidenceLicenses,evidenceLicenseInput,maximumEvidenceLicenses,validateEvidenceLicenseClaims,effectiveEvidenceLicenses,licensesBoundedRouteRelevance} from './evidence-licenses';
|
|
16
|
+
export type {EvidenceLicense,EvidenceLicenseInput,LicensableEvidenceRecord} from './evidence-licenses';
|
|
17
|
+
export {REFERENCE_DOMAINS,PARTICIPANT_ROLES,hasConcept,participantIds,DEFAULT_CONCEPT_REGISTRY,ENTITY_TYPES,RELATION_TYPES,ATTRIBUTE_KEYS,CONCEPT_KEYS,participant,conceptDefinition,createConceptRegistry,extendConceptRegistry,conceptsOf,primaryConcept,stringListAttribute} from './concept-registry';
|
|
18
|
+
export type {CaptureActor,ConceptLifecycle,ConceptRegistry,ConceptDefinition} from './concept-registry';
|
|
19
|
+
export {collectReasoningMoveWitnesses,reasoningEvidenceReplayStartPhase} from './poc-move-witnesses';
|
|
20
|
+
export type {ReasoningMoveWitness} from './poc-move-witnesses';
|
|
21
|
+
export {createPocIdentityTimeline,canonicalPieceLabel,pieceIdentity,squareForPiece,pieceIdAt} from './poc-piece-refs';
|
|
22
|
+
export type {PocIdentityTimeline} from './poc-piece-refs';
|
|
23
|
+
export {ABLATION_B_PRIME_TRIGGER_VALUES,runAblationAdaptiveDirect,ABLATION_ADAPTIVE_RUNTIME_VERSION,ABLATION_B_SYSTEM,prepareAblationAdaptiveEvidenceForStagedReference,AdaptiveAblationPreconditionError,deriveAblationBPrimeTriggers} from './ablation-adaptive-runtime';
|
|
24
|
+
export type {AblationBPrimeTrigger,AblationAdaptiveArm,AblationAdaptiveResult,AblationAdaptiveRuntimeOptions,AdaptiveEvidenceLoopResult,AblationAdaptiveCallDiagnostic,AdaptiveEvidenceLoop} from './ablation-adaptive-runtime';
|
|
25
|
+
export {ABLATION_ADAPTIVE_EVIDENCE_LOOP_VERSION,ModelOwnedAdaptiveEvidenceLoop,retainedEvidenceCatalogue} from './ablation-adaptive-evidence-loop';
|
|
26
|
+
export type {AdaptiveEvidenceToolExecutor} from './ablation-adaptive-evidence-loop';
|
|
27
|
+
export {ABLATION_LEAN_DIRECT_RUNTIME_VERSION,projectLeanDirectEvidence,projectLeanEpisodeEvidence,runLeanDirect,ABLATION_LEAN_DIRECT_PROPOSAL_VERSION,LEAN_DIRECT_PROPOSAL_JSON_SCHEMA,ablationLeanDirectSystem,materializeLeanDirectProposal} from './ablation-lean-direct-runtime';
|
|
28
|
+
export type {LeanDirectCallDiagnostic,LeanDirectResult,LeanDirectRuntimeOptions} from './ablation-lean-direct-runtime';
|
|
29
|
+
export type {LeanDirectEvidenceSelector} from './evidence-selector-contract';
|
|
30
|
+
export type {PositionAnalysisCacheProvenance,PocToolHostOptions} from './poc-tools';
|
|
31
|
+
export {isTerminalEntity,createSemanticEntity,createSemanticRelation,createIdeaGraph,extendIdeaGraph,forkIdeaGraph,graphIdentityCompatible,openEntityCount} from './idea-graph';
|
|
32
|
+
export type {CreateSemanticEntityInput,CreateSemanticRelationInput} from './idea-graph';
|
|
33
|
+
export {CHESS_REASONING_SCHEMA_VERSION,CHESS_REASONING_POLICY_VERSION} from './types';
|
|
34
|
+
export type {ConceptKey,EntityId,ReasoningToolResponse,SemanticMoveRecord,CandidateGenerationReport,IdentityState,PieceId,SemanticCandidate,ProofStrength,SemanticParticipant,SemanticValue,SemanticEntity,SemanticRelation,CandidateDisposition,EvidenceRecord,ProbeBudget,IdeaGraph,BranchId,EvidenceId,CandidateId,RegistryKey,ConceptCoverage,SemanticScalar,SemanticAttributes,SemanticReference,PieceIdentity,MoveIdentityDelta,ProposalReason,SemanticTransition,ToolSupport} from './types';
|
|
35
|
+
export {EXPLAIN_PLAN_SELECTION_DESCRIPTOR,RECORD_HYPOTHESES_DESCRIPTOR,HypothesisLedger,REVIEW_HYPOTHESES_DESCRIPTOR,validateHypothesisAcceptancePolicies,assertDirectedDestinationAnchors} from './poc-hypotheses';
|
|
36
|
+
export type {ExplainPlanSelection,InternalExplainPlanRequest} from './poc-hypotheses';
|
|
37
|
+
export {RAW_CHESS_TEXT,SEMANTIC_TEXT_JSON_PATTERN,RAW_CHESS_TEXT_PATTERN_SOURCE} from './poc-semantic-text';
|
|
38
|
+
export {priorConversationMessages} from './conversation-context';
|
|
39
|
+
export type {PriorConversationMessage} from './conversation-context';
|
|
40
|
+
export {chessSquareColor,CHESS_REFERENCE_DICTIONARY} from './chess-reference-dictionary';
|
|
41
|
+
export {EXISTING_ANALYSIS_CONTEXT_MODE,normalizeExistingAnalysisContext,EXISTING_ANALYSIS_CONTEXT_VERSION,LEGACY_EXISTING_ANALYSIS_CONTEXT_VERSION,CANONICAL_EDGE_ANALYSIS_SNAPSHOT_VERSION,EXISTING_ANALYSIS_RECORD_VERSION,MATERIAL_OFFER_SET_VERSION,EXISTING_ANALYSIS_OBSERVATION_PROVIDER_ID,ANALYSIS_CONTEXT_PROVENANCE_TIER,ExistingAnalysisObservationProvider} from './existing-analysis-context';
|
|
42
|
+
export type {ExistingAnalysisContextMode,AnalysisContextProvenanceTier,MaterialOfferCandidateSummary,MaterialOfferSet,ExistingAnalysisRecord,ExistingAnalysisContext} from './existing-analysis-context';
|
|
43
|
+
export {scopePositionAnalysis} from './position-analysis-scope';
|
|
44
|
+
export {classificationTargetAtSelection} from './classification-question-target';
|
|
45
|
+
export {recordedMainLineResult} from './recorded-main-line';
|
|
46
|
+
export {applyIdentityMove,createIdentityState,forkIdentityState} from './piece-identities';
|
|
47
|
+
export {CLASSIFICATION_REASSESSMENT_GUIDANCE,classificationReassessment} from './classification-reassessment';
|
|
48
|
+
export {MATCHED_COMPARISON_GUIDANCE,matchedRootComparison} from './matched-comparison';
|
|
49
|
+
export {CHESS_FACT_REQUEST_VERSION,CHESS_FACT_RESULT_VERSION,CHESS_FACT_SCHEMA_VERSION,validateChessFactRecord,validateChessFactRequest,assertFactProofWithinAuthority,isChessFactAuthority,chessFactRecordLicenses,maximumFactProofStrength,factProofStrength,factCoverageSupportsAbsence} from './fact-provider';
|
|
50
|
+
export type {ChessFactCapability,ChessFactRecord,ChessFactResult,ChessFactAuthority,ChessFactCoverage,ChessFactPhase,ChessFactProvider,ChessFactRequest,ChessFactEngineProvenance,ChessFactOmission} from './fact-provider';
|
|
51
|
+
export {createMechanicalFactRequest,MechanicalChessFactProvider,squaresBetween,deriveAdmittedCaptureResponseAvailabilityFact,MECHANICAL_CHESS_FACT_PROVIDER_ID,MECHANICAL_CHESS_FACT_PROVIDER_VERSION} from './mechanical-fact-provider';
|
|
52
|
+
export type {AdmittedCaptureResponseAvailabilityFact,AdmittedCaptureResponseAvailabilityInput} from './mechanical-fact-provider';
|
|
53
|
+
export {moveMechanismFacts} from './move-mechanism-facts';
|
|
54
|
+
export {simpleUsageForTrace,SIMPLE_TOOL_AGENT_VERSION,SIMPLE_DISCLOSURE} from './portable-answer-runtime';
|
|
55
|
+
export type {SimpleAgentDiagnostic} from './portable-answer-runtime';
|
|
56
|
+
export {withRecordedPositionTools,memoizeToolResults,RECORDED_POSITION_DESCRIPTORS,recordedPositionContext} from './recorded-position-tools';
|
|
57
|
+
export {EXPLANATION_REVIEW_SCHEMA,validateExplanationReview,explanationCoverage,explanationSummary,planningEvidence,explanationBranches} from './simple-explanation-coverage';
|
|
58
|
+
export {compactSimpleEngineResult,compactSimpleToolResult,simplePastHistory,compactSimpleInitialPacket,SIMPLE_EVIDENCE_VIEW_VERSION,simpleInitialEvidenceView} from './simple-evidence-view';
|
|
59
|
+
export {recordedNavigation,historyPositionContext} from './recorded-reference-context';
|
|
60
|
+
export {validateAnswerReferences} from './answer-reference-validation';
|
|
61
|
+
export {withBranchPreparation,selectBranchHost,BRANCH_EXPANSION_OPTIONS} from './branch-expansion-policy';
|
|
62
|
+
export {expandPrincipalBranches} from './branch-expansion';
|
|
63
|
+
export {checkCausalClaims} from './causal-claim-checks';
|
|
64
|
+
export {ChessFactObservationProvider,FACT_OBSERVATION_ADAPTER_VERSION} from './fact-observation-provider';
|
|
65
|
+
export type {ChessFactObservationProviderOptions} from './fact-observation-provider';
|
|
66
|
+
export {projectCompactEngineEvidence,expandCompactEngineEvidence} from './simple-compact-evidence';
|
|
67
|
+
export {compactPreparedSearchResult,compactSearchRecord} from './compact-search-preparation';
|
|
68
|
+
export {evidenceFallback} from './simple-completion';
|
|
69
|
+
export {projectEnginePresentation} from './simple-engine-presentation';
|
|
70
|
+
export {materialAtPosition,materialAlongLine,materialForVariations} from './material-accounting';
|
|
71
|
+
export {resolveAndSelectPlan,parseExplainPlanRequest} from './poc-plan-model';
|
|
72
|
+
export type {PlanEntityHypothesis,PlanRelationHypothesis,PlanHypothesisSet,ExplainPlanRequest,ResolvedPlanExplanation} from './poc-plan-model';
|
|
73
|
+
export {prepareSimpleEvidence} from './simple-evidence-preparation';
|
|
74
|
+
export {forcedWinPremiseFallback} from './simple-fallback-premise';
|
|
75
|
+
export {simpleBoardAnalysis} from './simple-board-analysis';
|
|
76
|
+
export {preparedMoveComparison} from './initial-search-plan';
|
|
77
|
+
export {normalizedEvidenceCitations} from './evidence-citation-normalization';
|
|
78
|
+
export {savedScorePresentation} from './saved-score-presentation';
|
|
79
|
+
export {scoreComparisonNotices} from './score-comparison-notices';
|
|
80
|
+
export {projectMaterial,DEFAULT_MATERIAL_FORMAT} from './material-format';
|
|
81
|
+
export type {MaterialFormat} from './material-format';
|
|
82
|
+
export {expandMechanismPresentation,compactMechanism} from './mechanism-presentation';
|
|
83
|
+
export {SimpleFactDelivery} from './simple-fact-delivery';
|
|
84
|
+
export {consolidatePreparedSearches} from './preparation-consolidation';
|
|
85
|
+
export {recordedSelectedClassification} from './recorded-selected-classification';
|
|
86
|
+
export {createToolInputLoopGuard} from './tool-input-loop-guard';
|
|
87
|
+
export {visibleSupportLines} from './visible-support-lines';
|
|
88
|
+
export {wikibooksTargetsForTool} from './wikibooks-tool-context';
|
|
89
|
+
export {prepareOpponentThreats} from './opponent-threat-preparation';
|
|
90
|
+
export type {SaliencePolicy} from './poc-contracts';
|
|
91
|
+
export type {ValidatedReasoningAnswer} from './poc-contracts';
|
|
92
|
+
export type {ReasoningRuntimeDiagnostic} from './poc-contracts';
|
|
93
|
+
export type {ReasoningSemanticPreservationSignal} from './poc-contracts';
|
|
94
|
+
export {REASONING_POC_MAX_CRITIC_OUTPUT_TOKENS} from './poc-contracts';
|
|
95
|
+
export type {ReasoningHypothesisRecord} from './poc-contracts';
|
|
96
|
+
export type {ReasoningObservationCoverage} from './poc-contracts';
|
|
97
|
+
export {ModelRuntimeFailure} from './poc-contracts';
|
|
98
|
+
export {REASONING_POC_MAX_DISCOURSE_OUTPUT_TOKENS} from './poc-contracts';
|
|
99
|
+
export type {ModelDiscoursePlanRequest} from './poc-contracts';
|
|
100
|
+
export type {ModelDiscoursePlanResult} from './poc-contracts';
|
|
101
|
+
export type {ReasoningHarnessPhase} from './poc-contracts';
|
|
102
|
+
export {REASONING_POC_MAX_HYPOTHESIS_OUTPUT_TOKENS} from './poc-contracts';
|
|
103
|
+
export {REASONING_POC_MAX_OUTPUT_TOKENS} from './poc-contracts';
|
|
104
|
+
export {REASONING_POC_RESERVED_MANDATORY_STEPS} from './poc-contracts';
|
|
105
|
+
export type {HypothesisProviderInput} from './poc-contracts';
|
|
106
|
+
export type {ModelRunRequest} from './poc-contracts';
|
|
107
|
+
export type {ReasoningChallengeDecision} from './poc-contracts';
|
|
108
|
+
export {REASONING_POC_MAX_GRAPH_SELECTION_OUTPUT_TOKENS} from './poc-contracts';
|
|
109
|
+
export type {HypothesisProvider} from './poc-contracts';
|
|
110
|
+
export type {HypothesisProviderResult} from './poc-contracts';
|
|
111
|
+
export {REASONING_POC_MAX_RENDER_OUTPUT_TOKENS} from './poc-contracts';
|
|
112
|
+
export type {ModelDraftRepairRequest} from './poc-contracts';
|
|
113
|
+
export type {ModelDraftRepairResult} from './poc-contracts';
|
|
114
|
+
export type {ModelRenderRequest} from './poc-contracts';
|
|
115
|
+
export type {ModelRenderResult} from './poc-contracts';
|
|
116
|
+
export type {ReasoningDraft} from './poc-contracts';
|
|
117
|
+
export type {ReasoningModelNarrativeSegment} from './poc-contracts';
|
|
118
|
+
export type {ReasoningNarrativeSegment} from './poc-contracts';
|
|
119
|
+
export type {ReasoningReferenceScope} from './poc-contracts';
|
|
120
|
+
export type {ReasoningRenderDraft} from './poc-contracts';
|
|
121
|
+
export {REASONING_POC_MAX_PURPOSE_PROBE_OUTPUT_TOKENS} from './poc-contracts';
|
|
122
|
+
export {REASONING_POC_MAX_RESOLUTION_AUDIT_OUTPUT_TOKENS} from './poc-contracts';
|
|
123
|
+
export {REASONING_POC_MAX_TERMINAL_REVIEW_OUTPUT_TOKENS} from './poc-contracts';
|
|
124
|
+
export {REASONING_POC_CRITIC_CORRECTION_ALLOWANCE} from './poc-contracts';
|
|
125
|
+
export {REASONING_POC_PURPOSE_PROBE_ALLOWANCE} from './poc-contracts';
|
|
126
|
+
export {REASONING_POC_REVISION_EVIDENCE_ALLOWANCE} from './poc-contracts';
|
|
127
|
+
export type {ModelRunResult} from './poc-contracts';
|
|
128
|
+
export type {ModelSemanticStageReplayRequest} from './poc-contracts';
|
|
129
|
+
export type {ModelSemanticStageReplayResult} from './poc-contracts';
|
|
130
|
+
export type {BoardAnnotation} from './poc-contracts';
|
|
131
|
+
export type {ReasoningClaim} from './poc-contracts';
|
|
132
|
+
export type {ReasoningCheckpointReferenceBindings} from './poc-contracts';
|
|
133
|
+
export type {ReasoningDemonstration} from './poc-contracts';
|
|
134
|
+
export type {ReasoningDefenseCoverage} from './poc-contracts';
|
|
135
|
+
export type {ReasoningDraftDemonstration} from './poc-contracts';
|
|
136
|
+
export type {ReasoningGraphReference} from './poc-contracts';
|
|
137
|
+
export type {ReasoningPieceReferenceForm} from './poc-contracts';
|
|
138
|
+
export type {ReasoningValidationIssue} from './poc-contracts';
|
|
139
|
+
export type {ResolvedReasoningNarrativeSegment} from './poc-contracts';
|
|
140
|
+
export type {ValidatedReasoningClaim} from './poc-contracts';
|
|
141
|
+
export type {ReasoningCheckpoint} from './poc-contracts';
|
|
142
|
+
export {REASONING_DISCOURSE_PLAN_VERSION} from './poc-contracts';
|
|
143
|
+
export type {ReasoningDiscourseDemonstrationIntent} from './poc-contracts';
|
|
144
|
+
export type {ReasoningDiscourseParagraph} from './poc-contracts';
|
|
145
|
+
export type {ReasoningDiscoursePlan} from './poc-contracts';
|
|
146
|
+
export type {ReasoningDiscoursePlanDraft} from './poc-contracts';
|
|
147
|
+
export type {ReasoningHypothesisRelationRecord} from './poc-contracts';
|
|
148
|
+
export {REASONING_POC_MAX_HYPOTHESIS_BATCHES} from './poc-contracts';
|
|
149
|
+
export type {ReasoningCompletionStage} from './poc-contracts';
|
|
150
|
+
export type {ReasoningAudience} from './poc-contracts';
|
|
151
|
+
export type {ReasoningGraphRequirements} from './poc-contracts';
|
|
152
|
+
export type {ReasoningRenderMetrics} from './poc-contracts';
|
|
153
|
+
export type {ReasoningToolTrace} from './poc-contracts';
|
|
154
|
+
export type {ReasoningPieceKind} from './poc-contracts';
|
|
155
|
+
export type {ReasoningObservationDecision} from './poc-contracts';
|
|
156
|
+
export type {ReasoningInteractionCoverage} from './poc-contracts';
|
|
157
|
+
export type {ReasoningNarrativeOutcome} from './poc-contracts';
|
|
158
|
+
export type {ReasoningCriticFinding} from './poc-contracts';
|
|
159
|
+
export type {ReasoningCriticFindingResolution} from './poc-contracts';
|
|
160
|
+
export type {ReasoningCriticResolutionAudit} from './poc-contracts';
|
|
161
|
+
export type {ReasoningCheckpointEvidenceSummary} from './poc-contracts';
|
|
162
|
+
export type {ReasoningModelDraft} from './poc-contracts';
|
|
163
|
+
export type {ReasoningSemanticReplayStage} from './poc-contracts';
|
|
164
|
+
export type {ReasoningEvidenceKind} from './poc-contracts';
|
|
165
|
+
export type {ReasoningToolSupport} from './poc-contracts';
|
|
166
|
+
export type {ReasoningHypothesisProvenance} from './poc-contracts';
|
|
167
|
+
export type {ReasoningProbeRecipe} from './poc-contracts';
|
|
168
|
+
export type {ReasoningRankedObservation} from './poc-contracts';
|
|
169
|
+
export type {ReasoningHypothesisRelationProposal} from './poc-contracts';
|
|
170
|
+
export type {ReasoningAnchorRequirement} from './poc-contracts';
|
|
171
|
+
export type {ReasoningHypothesisProposal} from './poc-contracts';
|
|
172
|
+
export type {ReasoningHypothesisStatus} from './poc-contracts';
|
|
173
|
+
export type {ReasoningHypothesisDecision} from './poc-contracts';
|
|
174
|
+
export type {ReasoningObservationDispositionState} from './poc-contracts';
|
|
175
|
+
export type {ReasoningChallengeObservationAudit} from './poc-contracts';
|
|
176
|
+
export type {ReasoningCriticFindingKind} from './poc-contracts';
|
|
177
|
+
export type {ReasoningCriticFindingResolutionDisposition} from './poc-contracts';
|
|
178
|
+
export type {ReasoningCriticResolutionAuditDecision} from './poc-contracts';
|
|
179
|
+
export type {ReasoningClaimKind} from './poc-contracts';
|
|
180
|
+
export type {ReasoningMoveInput} from './poc-contracts';
|
|
181
|
+
export type {ResolvedReasoningMove} from './poc-contracts';
|
|
182
|
+
export type {ReasoningClaimScope} from './poc-contracts';
|
|
183
|
+
export type {ReasoningModelDraftClaim} from './poc-contracts';
|
|
184
|
+
export type {ReasoningModelDraftDemonstration} from './poc-contracts';
|
|
185
|
+
export type {ReasoningRenderNarrativeSegment} from './poc-contracts';
|
|
186
|
+
export type {ReasoningRenderDraftClaim} from './poc-contracts';
|
|
187
|
+
export type {ReasoningRenderDraftDemonstration} from './poc-contracts';
|
|
188
|
+
export type {ReasoningDiscourseRole} from './poc-contracts';
|
|
189
|
+
export type {ReasoningDiscourseRelationAction} from './poc-contracts';
|
|
190
|
+
export type {ReasoningStructuralOutcome} from './poc-contracts';
|
|
191
|
+
export {selectSimpleModel} from './simple-agent-config';
|
|
192
|
+
export {SIMPLE_EXTENSION_CONFIGS} from './simple-agent-config';
|
|
193
|
+
export {SIMPLE_VENDOR_CONFIGS} from './simple-agent-config';
|
|
194
|
+
export {EVALUATED_ASTRA_CONFIG} from './simple-agent-config';
|
|
195
|
+
export {EVIDENCE_SHARING_INSTRUCTIONS} from './lossless-evidence-sharing';
|
|
196
|
+
export {EVIDENCE_SHARING_GUIDANCE_CHARS} from './lossless-evidence-sharing';
|
|
197
|
+
export * from './answer-pipeline-exports';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Stored numeric mate sentinels are bookkeeping, never centipawn evidence. */
|
|
2
|
+
export function savedScorePresentation(a: {beforeCp:number|null;afterCp:number|null;lossCp:number|null;mateBefore:number|null;mateAfter:number|null}) {
|
|
3
|
+
const finiteCp=(cp:number|null,mate:number|null)=>mate!==null || cp!==null&&Math.abs(cp)>=100000 ? null : cp;
|
|
4
|
+
const beforeCp=finiteCp(a.beforeCp,a.mateBefore),afterCp=finiteCp(a.afterCp,a.mateAfter);
|
|
5
|
+
return {beforeCp,afterCp,lossCp:a.mateBefore!==null||a.mateAfter!==null||beforeCp===null||afterCp===null||a.lossCp===9999?null:a.lossCp,mateBefore:a.mateBefore,mateAfter:a.mateAfter};
|
|
6
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { ReasoningEvidenceRecord } from './poc-contracts';
|
|
2
|
+
import { matchedRootComparison } from './matched-comparison';
|
|
3
|
+
import type { PositionAnalysisResult } from './poc-tools';
|
|
4
|
+
|
|
5
|
+
const object = (value: unknown): Record<string, unknown> | null =>
|
|
6
|
+
value !== null && typeof value === 'object' && !Array.isArray(value) ? value as Record<string, unknown> : null;
|
|
7
|
+
const finite = (value: unknown): value is number => typeof value === 'number' && Number.isFinite(value);
|
|
8
|
+
const strings = (value: unknown): string[] => Array.isArray(value) ? value.filter((v): v is string => typeof v === 'string') : [];
|
|
9
|
+
type Score = { unit: 'centipawns' | 'mate-in-moves'; value: number };
|
|
10
|
+
type Observation = {
|
|
11
|
+
evidenceId: string; source: string; score: Score; reportedDepth: number | null; actualDepth: number | null;
|
|
12
|
+
requestedDepth: number | null; requestedMultiPv: number | null;
|
|
13
|
+
rootScope: 'restricted' | 'unrestricted'; requestedRootMoves: string[];
|
|
14
|
+
cacheProvenance: string; sourceCacheProvenance: string;
|
|
15
|
+
engine: string | null; engineBuild: string | null;
|
|
16
|
+
scoreProvenance?: Record<string, unknown>;
|
|
17
|
+
};
|
|
18
|
+
export type ScoreComparisonNotice = {
|
|
19
|
+
fen: string; rootMove: string; perspective: 'white' | 'black';
|
|
20
|
+
disagreementKind: 'centipawn-variation' | 'mate-status-disagreement' | 'opposite-mate-sign' | 'mate-distance-variation';
|
|
21
|
+
observations: Observation[]; preferredWithinSearchComparisonEvidenceIds: string[];
|
|
22
|
+
interpretation: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
function disagreementKind(observations: Observation[]): ScoreComparisonNotice['disagreementKind'] {
|
|
26
|
+
const mates = observations.filter(observation => observation.score.unit === 'mate-in-moves').map(observation => observation.score.value);
|
|
27
|
+
if (mates.length !== observations.length) return mates.length ? 'mate-status-disagreement' : 'centipawn-variation';
|
|
28
|
+
if (mates.some(value => value > 0) && mates.some(value => value < 0)) return 'opposite-mate-sign';
|
|
29
|
+
return 'mate-distance-variation';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const sharedInterpretation = 'Different search results for the same root move; equal requested depth does not make their search scope, actual depth, cache or search history equivalent. Preserve each scoped score. For relative move comparisons prefer alternatives covered together at the same actual depth in the identified comparison records; this supports a relative claim within that search, not independent confirmation or rejection of a mate result. Do not combine scores from separate searches into a move-loss estimate. This notice alone does not require another search.';
|
|
33
|
+
const interpretationFor = (kind: ScoreComparisonNotice['disagreementKind']): string => {
|
|
34
|
+
const qualification = kind === 'mate-status-disagreement'
|
|
35
|
+
? 'Mate status differs: a centipawn score in another search does not refute its mating continuation, and mate distances cannot be converted to centipawns. '
|
|
36
|
+
: kind === 'opposite-mate-sign'
|
|
37
|
+
? 'The mate signs oppose, indicating different reported mating sides; retain each search scope and inspect the underlying continuations. '
|
|
38
|
+
: kind === 'mate-distance-variation'
|
|
39
|
+
? 'The searches report different mate distances; mate distances are not centipawns. '
|
|
40
|
+
: 'The searches report different centipawn evaluations. ';
|
|
41
|
+
return qualification + sharedInterpretation;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
function originatingRootDepth(line: Record<string, unknown>, search: Record<string, unknown>, fen: string): number | null {
|
|
45
|
+
const provenance = object(line.scoreProvenance);
|
|
46
|
+
if (provenance) return provenance.kind === 'root-search' && provenance.fen === fen &&
|
|
47
|
+
finite(provenance.originatingDepth) && Number.isInteger(provenance.originatingDepth) && provenance.originatingDepth > 0
|
|
48
|
+
&& provenance.originatingDepth === line.depth ? provenance.originatingDepth : null;
|
|
49
|
+
// Old direct engine records predate scoreProvenance. Widget display-cache
|
|
50
|
+
// depths may instead describe a later position and cannot be promoted here.
|
|
51
|
+
const source = search.sourceCacheProvenance ?? search.cacheProvenance;
|
|
52
|
+
return source === 'engine' && finite(line.depth) && Number.isInteger(line.depth) && line.depth > 0 ? line.depth : null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Presentation-only qualification. Does not reconcile numeric truth or initiate searches. */
|
|
56
|
+
export function scoreComparisonNotices(records: readonly ReasoningEvidenceRecord[]): ScoreComparisonNotice[] {
|
|
57
|
+
const groups = new Map<string, { fen: string; rootMove: string; perspective: 'white' | 'black'; observations: Observation[]; matched: Set<string> }>();
|
|
58
|
+
for (const record of records) {
|
|
59
|
+
const wrapper = object(record.data);
|
|
60
|
+
const data = object(wrapper?.details) ?? wrapper;
|
|
61
|
+
const search = object(data?.searchScope);
|
|
62
|
+
if (!data || !search || typeof search.fen !== 'string' || !Array.isArray(data.lines)) continue;
|
|
63
|
+
const fen = search.fen;
|
|
64
|
+
const perspective = fen.split(' ')[1] === 'w' ? 'white' : fen.split(' ')[1] === 'b' ? 'black' : null;
|
|
65
|
+
if (!perspective) continue;
|
|
66
|
+
const roots = strings(search.requestedRootMoves);
|
|
67
|
+
const lines = data.lines.map(object).filter((line): line is Record<string, unknown> => !!line);
|
|
68
|
+
const scoped = (line: Record<string, unknown>) => {
|
|
69
|
+
const scope = object(line.scoreScope);
|
|
70
|
+
return scope?.fen === fen && scope.perspective === perspective && scope.positiveMeans === 'advantage for perspective color';
|
|
71
|
+
};
|
|
72
|
+
// A restricted probe is useful for relative comparisons only if all requested
|
|
73
|
+
// alternatives were returned with a common actual depth and explicit root scope.
|
|
74
|
+
const comparedRoots = roots.length ? roots : lines.map(line => String(line.rootMove));
|
|
75
|
+
const matched = (!roots.length || record.coverage?.complete === true && roots.every(root => record.coverage!.covered.includes(root))) &&
|
|
76
|
+
matchedRootComparison({...data,command:search.command,cacheProvenance:search.cacheProvenance,sourceCacheProvenance:search.sourceCacheProvenance} as unknown as PositionAnalysisResult,fen,comparedRoots).status === 'matched';
|
|
77
|
+
for (const line of lines) {
|
|
78
|
+
if (typeof line.rootMove !== 'string' || !scoped(line)) continue;
|
|
79
|
+
const scope = object(line.scoreScope)!;
|
|
80
|
+
let score: Score;
|
|
81
|
+
if (finite(line.matePly) && scope.matePlyUnit === 'signed mate-in-moves (legacy field name, not plies)') {
|
|
82
|
+
score = { unit: 'mate-in-moves', value: line.matePly };
|
|
83
|
+
} else if (line.matePly == null && finite(line.scoreCp) && Math.abs(line.scoreCp) < 100000 && scope.scoreCpUnit === 'centipawns') {
|
|
84
|
+
score = { unit: 'centipawns', value: line.scoreCp };
|
|
85
|
+
} else continue;
|
|
86
|
+
const key = JSON.stringify([fen, line.rootMove, perspective]);
|
|
87
|
+
let group = groups.get(key);
|
|
88
|
+
if (!group) { group = { fen, rootMove: line.rootMove, perspective, observations: [], matched: new Set() }; groups.set(key, group); }
|
|
89
|
+
// Reusing an evidence record is not a second independent evaluation.
|
|
90
|
+
if (group.observations.some(observation => observation.evidenceId === record.id)) continue;
|
|
91
|
+
group.observations.push({ evidenceId: record.id, source: record.source, score,
|
|
92
|
+
reportedDepth: finite(line.depth) ? line.depth : null,
|
|
93
|
+
actualDepth: originatingRootDepth(line, search, fen),
|
|
94
|
+
requestedDepth: finite(search.requestedDepth) ? search.requestedDepth : null,
|
|
95
|
+
requestedMultiPv: finite(search.requestedMultiPv) ? search.requestedMultiPv : null,
|
|
96
|
+
rootScope: roots.length ? 'restricted' : 'unrestricted', requestedRootMoves: roots,
|
|
97
|
+
cacheProvenance: typeof search.cacheProvenance === 'string' ? search.cacheProvenance : 'unreported',
|
|
98
|
+
sourceCacheProvenance: typeof search.sourceCacheProvenance === 'string' ? search.sourceCacheProvenance : 'unreported',
|
|
99
|
+
engine: typeof data.engine === 'string' ? data.engine : null,
|
|
100
|
+
engineBuild: typeof data.engineBuild === 'string' ? data.engineBuild : null,
|
|
101
|
+
...(object(line.scoreProvenance) ? { scoreProvenance: line.scoreProvenance as Record<string, unknown> } : {}),
|
|
102
|
+
});
|
|
103
|
+
if (matched && comparedRoots.includes(line.rootMove)) group.matched.add(record.id);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return [...groups.values()].filter(group => new Set(group.observations.map(observation => JSON.stringify(observation.score))).size > 1)
|
|
107
|
+
.map(group => {
|
|
108
|
+
const kind = disagreementKind(group.observations);
|
|
109
|
+
return { fen: group.fen, rootMove: group.rootMove, perspective: group.perspective,
|
|
110
|
+
disagreementKind: kind,
|
|
111
|
+
observations: group.observations, preferredWithinSearchComparisonEvidenceIds: [...group.matched],
|
|
112
|
+
interpretation: interpretationFor(kind),
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
}
|