fix(rectification): bump scoring identity to scoring-10 for functional profile v2; dated contract by generation (BUG-1181)
Functional roles feed the *_functional_*_auxiliary rules, so57782aeachanges candidate scores for identical input (memoization fixture 12:00: 8.6274 -> 8.4977). Per the "scoring semantics change => bump ALGORITHM_VERSION" precedent (scoring-7 -> 8 -> 9), the identity moves to scoring-10; policy v3, input contract v5 and Skill versions are unchanged, history is not relabeled. Five frontend sites and one SQL guard tested `=== "...scoring-9"` for the dated candidate-window contract; they now use isDatedScoringAlgorithmVersion / a generation regex (>= 9). Migration 20261002010000 only recreates validate_dated_rectification_candidate (one-line guard change). Memoization golden v2 written by the test's own write_golden; v1 (scoring-8) frozen by sha256. Real-engine scoring-10 cross-midnight golden added. Research records re-frozen per ERR-110 (label functional_v2_2026_10_02) and scripts/functional_benefics.py added to the frozen production identity (ERR-114:57782aeachanged scores without tripping it). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N4f2nya58RoRu4yEmJgRGE
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
57782aea8a
commit
3733b9787b
@@ -0,0 +1,118 @@
|
||||
{
|
||||
"record_version": "reported-offset-native-candidate-date-v3",
|
||||
"frozen_at_utc": "2026-10-02T04:23:24.916174+00:00",
|
||||
"ayanamsa": "raman",
|
||||
"node_mode": "mean",
|
||||
"radii_minutes": [
|
||||
15,
|
||||
30,
|
||||
60
|
||||
],
|
||||
"offsets_minutes": [
|
||||
-30,
|
||||
-20,
|
||||
-15,
|
||||
-10,
|
||||
-8,
|
||||
-5,
|
||||
-3,
|
||||
0,
|
||||
3,
|
||||
5,
|
||||
8,
|
||||
10,
|
||||
15,
|
||||
20,
|
||||
30
|
||||
],
|
||||
"minute_step": 1,
|
||||
"dataset": "references/real_case_calibration/minute_rectification_holdout_v3.json",
|
||||
"dataset_sha256": "45aa76ab79dfc6c6404b6252083e1aa5c7e2e2b7de811fc11042a8ad2da3f0ea",
|
||||
"dataset_benchmark_id": "minute_rectification_fact_ranker_v4_holdout_v3",
|
||||
"implementation_sha256": "c913c6f061458fb682f6d520ae08b2d64d6f6cee20ccd1abd7e6c43d5a41685d",
|
||||
"implementation_sha256_prefix": "c913c6f061458fb6",
|
||||
"historical_artifacts_manifest_sha256": "6102a26a840be207b5858b3a4c0509274468ae9071e86d308cbbac7371d6864e",
|
||||
"production_scoring_files": [
|
||||
"scripts/active_rectification_event_engine.py",
|
||||
"scripts/active_rectification_events.py",
|
||||
"scripts/ashtakavarga.py",
|
||||
"scripts/dasha_analyzer.py",
|
||||
"scripts/divisional_charts_extended.py",
|
||||
"scripts/domain_calculation_service.py",
|
||||
"scripts/functional_benefics.py",
|
||||
"scripts/jaimini.py",
|
||||
"scripts/minute_rectification_fact_ranker_v4.py",
|
||||
"scripts/minute_rectification_feature_facts_v4.py",
|
||||
"scripts/narayana_dasha.py",
|
||||
"scripts/rectification/api_service.py",
|
||||
"scripts/rectification/candidate_contrast.py",
|
||||
"scripts/rectification/candidate_window.py",
|
||||
"scripts/rectification/case_holdout.py",
|
||||
"scripts/rectification/contracts.py",
|
||||
"scripts/rectification/dasha_transition_proximity.py",
|
||||
"scripts/rectification/decision_policy.py",
|
||||
"scripts/rectification/event_probes.py",
|
||||
"scripts/rectification/refinement_packet.py",
|
||||
"scripts/rectification/scoring_service.py",
|
||||
"scripts/shadbala.py",
|
||||
"scripts/varga.py"
|
||||
],
|
||||
"production_scoring_sha256": "01f2d36e715801242c9bf657d70a017a77b46761a100ceeb9fd8369cd39f2c0e",
|
||||
"research_files": [
|
||||
"scripts/research/reported_offset_sweep.py",
|
||||
"scripts/research/cluster_width_lib.py",
|
||||
"scripts/research/probe_supply_after_six.py",
|
||||
"scripts/research/sealed_holdout_rerun.py",
|
||||
"scripts/minute_rectification_blind_eval.py",
|
||||
"scripts/minute_rectification_fact_blind_eval_v4.py",
|
||||
"scripts/minute_rectification_holdout_validator.py"
|
||||
],
|
||||
"research_implementation_sha256": "a2d555508e2a4063fffdabc14463da546e2cef090c8e2bbd4ecff288942e9e95",
|
||||
"file_sha256": {
|
||||
"scripts/active_rectification_event_engine.py": "cdc0e68edc770a2a1810fbdb68cbfd46dcd50b267c739c496fcc078c5e26b5b4",
|
||||
"scripts/active_rectification_events.py": "03e333ccf1103caf685dfe50fe890ab1793e945037085f50ce834a4a3b232222",
|
||||
"scripts/ashtakavarga.py": "cc32776674cf60713634a360a6f09774b3af0ec5d0f650687f52b79597b0dfbe",
|
||||
"scripts/dasha_analyzer.py": "5e53b1b4d4c7414c08dd0e7716f120a63c70ec3428ec93547f64d55c580da0e1",
|
||||
"scripts/divisional_charts_extended.py": "73bd50a83ac444830940184d0988cea621855f91db76a3f1a232014b992eacea",
|
||||
"scripts/domain_calculation_service.py": "9ee955874eea806c7b56f4246d90009c02ee8318b8f3dfe1d7132b1c0b4262e1",
|
||||
"scripts/functional_benefics.py": "cbaac3b8c09b97f8724b5300e9a402cbf77089af6c7db8788550d40fd35ac57b",
|
||||
"scripts/jaimini.py": "b98bf965603dd2e3cc871fe40f3c8184731a701875ca50fef3ca68e9682eda81",
|
||||
"scripts/minute_rectification_blind_eval.py": "07aa30d8bad3278669495d5fea8be937aaf6367c8af980ff4f2fe9aa84ccc6ff",
|
||||
"scripts/minute_rectification_fact_blind_eval_v4.py": "bdf460e3467208e8b87345c5beb2128f3e22de7eeffd68f72b281b3ad9affc92",
|
||||
"scripts/minute_rectification_fact_ranker_v4.py": "f1a0d8d2482cd754d2e7f253a9606b0373519435a2bf58cfc3753e2b9ae0fb76",
|
||||
"scripts/minute_rectification_feature_facts_v4.py": "3d899a2cdd4825b8e32062443d487edcd2173a4ea55a36eb9f3abe587c0faf0f",
|
||||
"scripts/minute_rectification_holdout_validator.py": "b60b1c752e58672beaee8b36eb3b2348169726cda070ec969db0f13e7ed715af",
|
||||
"scripts/narayana_dasha.py": "7ff2c3238cd113b11b815e14b41967bd8e486ff62e36650e55613b9c79d1bfe3",
|
||||
"scripts/rectification/api_service.py": "e316ced0f3796d0378a0fe1aad950ee25922ae8afd53add578ed59ca8b2f0f79",
|
||||
"scripts/rectification/candidate_contrast.py": "eee7da71c0574a08876404b78ca111153fa95fb83ace82b9fdca141d1992e273",
|
||||
"scripts/rectification/candidate_window.py": "2fbc5058b12049b15fca375cdc125b8283e19f9f3e4bedcc291e344501891bef",
|
||||
"scripts/rectification/case_holdout.py": "fe0e699b617d9e216acdfeff87af4221c1d6f4c101bf33e1dbf14e2bcd75a8b5",
|
||||
"scripts/rectification/contracts.py": "c6dc6bd230e38f9f2126c224aae9ddbd6415304c15340f8c7cd3f06f6ef3160f",
|
||||
"scripts/rectification/dasha_transition_proximity.py": "0afba494aa12899621173c3cc941c6c1d0be9cec0bdf4c4a1c9bcd004ab22de8",
|
||||
"scripts/rectification/decision_policy.py": "d845896428e0f49f8b5ae946aff6203492e7383d387acf122cb0b7a523b0af28",
|
||||
"scripts/rectification/event_probes.py": "9bbadc246e6b8e94bb047522c3e5645613f508b3473ef40b38a207c77fdad58c",
|
||||
"scripts/rectification/refinement_packet.py": "dbeea5aa780889785ce850f3881e8b7f67bb44594e9bc382c65b2e730884a2f4",
|
||||
"scripts/rectification/scoring_service.py": "4f13c6a78d2dda55454ac20e4091fce280e3626ecfe8a9d723217ef3ebc05d02",
|
||||
"scripts/research/cluster_width_lib.py": "1d8f2ffa7795d62069deebb2de8e16749317037d4ed3f24a2c0092676e5cfcc6",
|
||||
"scripts/research/probe_supply_after_six.py": "098a5b4398d6f8d996917d809c2fc922ad64031d3b70660f8ef7c876aba92438",
|
||||
"scripts/research/reported_offset_sweep.py": "f2acca1c5d5307b013e098cc28c803348bf9207d318a27733fb7735b9640dd7f",
|
||||
"scripts/research/sealed_holdout_rerun.py": "f49eae74e27ecf1c417b3a6423eeb473ce8c8c565a5b7c8768ddb407659e3592",
|
||||
"scripts/shadbala.py": "912e0e6d169c2172aab85f71e4347e3e39193020777b43825b775d906400956b",
|
||||
"scripts/varga.py": "4331de5a25ea08729af91aae863943c4223183937f419d52dc63fd6fe7f27be6"
|
||||
},
|
||||
"hash_scope": "explicit_identity_file_sets_not_a_transitive_dependency_lock",
|
||||
"scorer": "native_event_contribution_matrix_not_shadow_fact_ranker",
|
||||
"delivery": "initial_signature_clusters_peak_gap_lt_8_envelope_no_answers_no_elimination",
|
||||
"rank": "score_desc_then_sha256(benchmark_id:case_id:candidate_time)",
|
||||
"grid": "every_minute_inclusive_not_production_two_minute_sampling",
|
||||
"cross_midnight": "date_aware_candidates_distance_and_native_single_matrix",
|
||||
"evaluator_sha256": "f2acca1c5d5307b013e098cc28c803348bf9207d318a27733fb7735b9640dd7f",
|
||||
"replay_revision": "native_candidate_date_v3",
|
||||
"supersedes": "candidate_date_grouped_v2_identity_and_path_not_assumed_numerically_wrong",
|
||||
"is_blind_evaluation": false,
|
||||
"truth_hidden_from_ranker": true,
|
||||
"official_valid_independent_blind": false,
|
||||
"official_blind_trial_count": 0,
|
||||
"results_previously_seen": true,
|
||||
"must_not_use_for_tuning": true
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,116 @@
|
||||
{
|
||||
"record_version": "exposed-v3-fixed-protocol-cross-midnight-rerun-v2",
|
||||
"extended_identity": {
|
||||
"historical_artifacts_manifest_sha256": "6102a26a840be207b5858b3a4c0509274468ae9071e86d308cbbac7371d6864e",
|
||||
"production_scoring_files": [
|
||||
"scripts/active_rectification_event_engine.py",
|
||||
"scripts/active_rectification_events.py",
|
||||
"scripts/ashtakavarga.py",
|
||||
"scripts/dasha_analyzer.py",
|
||||
"scripts/divisional_charts_extended.py",
|
||||
"scripts/domain_calculation_service.py",
|
||||
"scripts/functional_benefics.py",
|
||||
"scripts/jaimini.py",
|
||||
"scripts/minute_rectification_fact_ranker_v4.py",
|
||||
"scripts/minute_rectification_feature_facts_v4.py",
|
||||
"scripts/narayana_dasha.py",
|
||||
"scripts/rectification/api_service.py",
|
||||
"scripts/rectification/candidate_contrast.py",
|
||||
"scripts/rectification/candidate_window.py",
|
||||
"scripts/rectification/case_holdout.py",
|
||||
"scripts/rectification/contracts.py",
|
||||
"scripts/rectification/dasha_transition_proximity.py",
|
||||
"scripts/rectification/decision_policy.py",
|
||||
"scripts/rectification/event_probes.py",
|
||||
"scripts/rectification/refinement_packet.py",
|
||||
"scripts/rectification/scoring_service.py",
|
||||
"scripts/shadbala.py",
|
||||
"scripts/varga.py"
|
||||
],
|
||||
"production_scoring_sha256": "01f2d36e715801242c9bf657d70a017a77b46761a100ceeb9fd8369cd39f2c0e",
|
||||
"research_files": [
|
||||
"scripts/research/reported_offset_sweep.py",
|
||||
"scripts/research/cluster_width_lib.py",
|
||||
"scripts/research/probe_supply_after_six.py",
|
||||
"scripts/research/sealed_holdout_rerun.py",
|
||||
"scripts/minute_rectification_blind_eval.py",
|
||||
"scripts/minute_rectification_fact_blind_eval_v4.py",
|
||||
"scripts/minute_rectification_holdout_validator.py"
|
||||
],
|
||||
"research_implementation_sha256": "a2d555508e2a4063fffdabc14463da546e2cef090c8e2bbd4ecff288942e9e95",
|
||||
"file_sha256": {
|
||||
"scripts/active_rectification_event_engine.py": "cdc0e68edc770a2a1810fbdb68cbfd46dcd50b267c739c496fcc078c5e26b5b4",
|
||||
"scripts/active_rectification_events.py": "03e333ccf1103caf685dfe50fe890ab1793e945037085f50ce834a4a3b232222",
|
||||
"scripts/ashtakavarga.py": "cc32776674cf60713634a360a6f09774b3af0ec5d0f650687f52b79597b0dfbe",
|
||||
"scripts/dasha_analyzer.py": "5e53b1b4d4c7414c08dd0e7716f120a63c70ec3428ec93547f64d55c580da0e1",
|
||||
"scripts/divisional_charts_extended.py": "73bd50a83ac444830940184d0988cea621855f91db76a3f1a232014b992eacea",
|
||||
"scripts/domain_calculation_service.py": "9ee955874eea806c7b56f4246d90009c02ee8318b8f3dfe1d7132b1c0b4262e1",
|
||||
"scripts/functional_benefics.py": "cbaac3b8c09b97f8724b5300e9a402cbf77089af6c7db8788550d40fd35ac57b",
|
||||
"scripts/jaimini.py": "b98bf965603dd2e3cc871fe40f3c8184731a701875ca50fef3ca68e9682eda81",
|
||||
"scripts/minute_rectification_blind_eval.py": "07aa30d8bad3278669495d5fea8be937aaf6367c8af980ff4f2fe9aa84ccc6ff",
|
||||
"scripts/minute_rectification_fact_blind_eval_v4.py": "bdf460e3467208e8b87345c5beb2128f3e22de7eeffd68f72b281b3ad9affc92",
|
||||
"scripts/minute_rectification_fact_ranker_v4.py": "f1a0d8d2482cd754d2e7f253a9606b0373519435a2bf58cfc3753e2b9ae0fb76",
|
||||
"scripts/minute_rectification_feature_facts_v4.py": "3d899a2cdd4825b8e32062443d487edcd2173a4ea55a36eb9f3abe587c0faf0f",
|
||||
"scripts/minute_rectification_holdout_validator.py": "b60b1c752e58672beaee8b36eb3b2348169726cda070ec969db0f13e7ed715af",
|
||||
"scripts/narayana_dasha.py": "7ff2c3238cd113b11b815e14b41967bd8e486ff62e36650e55613b9c79d1bfe3",
|
||||
"scripts/rectification/api_service.py": "e316ced0f3796d0378a0fe1aad950ee25922ae8afd53add578ed59ca8b2f0f79",
|
||||
"scripts/rectification/candidate_contrast.py": "eee7da71c0574a08876404b78ca111153fa95fb83ace82b9fdca141d1992e273",
|
||||
"scripts/rectification/candidate_window.py": "2fbc5058b12049b15fca375cdc125b8283e19f9f3e4bedcc291e344501891bef",
|
||||
"scripts/rectification/case_holdout.py": "fe0e699b617d9e216acdfeff87af4221c1d6f4c101bf33e1dbf14e2bcd75a8b5",
|
||||
"scripts/rectification/contracts.py": "c6dc6bd230e38f9f2126c224aae9ddbd6415304c15340f8c7cd3f06f6ef3160f",
|
||||
"scripts/rectification/dasha_transition_proximity.py": "0afba494aa12899621173c3cc941c6c1d0be9cec0bdf4c4a1c9bcd004ab22de8",
|
||||
"scripts/rectification/decision_policy.py": "d845896428e0f49f8b5ae946aff6203492e7383d387acf122cb0b7a523b0af28",
|
||||
"scripts/rectification/event_probes.py": "9bbadc246e6b8e94bb047522c3e5645613f508b3473ef40b38a207c77fdad58c",
|
||||
"scripts/rectification/refinement_packet.py": "dbeea5aa780889785ce850f3881e8b7f67bb44594e9bc382c65b2e730884a2f4",
|
||||
"scripts/rectification/scoring_service.py": "4f13c6a78d2dda55454ac20e4091fce280e3626ecfe8a9d723217ef3ebc05d02",
|
||||
"scripts/research/cluster_width_lib.py": "1d8f2ffa7795d62069deebb2de8e16749317037d4ed3f24a2c0092676e5cfcc6",
|
||||
"scripts/research/probe_supply_after_six.py": "098a5b4398d6f8d996917d809c2fc922ad64031d3b70660f8ef7c876aba92438",
|
||||
"scripts/research/reported_offset_sweep.py": "f2acca1c5d5307b013e098cc28c803348bf9207d318a27733fb7735b9640dd7f",
|
||||
"scripts/research/sealed_holdout_rerun.py": "f49eae74e27ecf1c417b3a6423eeb473ce8c8c565a5b7c8768ddb407659e3592",
|
||||
"scripts/shadbala.py": "912e0e6d169c2172aab85f71e4347e3e39193020777b43825b775d906400956b",
|
||||
"scripts/varga.py": "4331de5a25ea08729af91aae863943c4223183937f419d52dc63fd6fe7f27be6"
|
||||
},
|
||||
"hash_scope": "explicit_identity_file_sets_not_a_transitive_dependency_lock"
|
||||
},
|
||||
"production_identity_scope": "context_only_shadow_scorer_does_not_call_transition_proximity",
|
||||
"frozen_at_utc": "2026-10-02T04:23:10.231688+00:00",
|
||||
"dataset_path": "references/real_case_calibration/minute_rectification_holdout_v3.json",
|
||||
"dataset_sha256": "45aa76ab79dfc6c6404b6252083e1aa5c7e2e2b7de811fc11042a8ad2da3f0ea",
|
||||
"algorithm_version": "birth-time-event-fact-ranker-v4-shadow",
|
||||
"implementation_sha256": "c913c6f061458fb682f6d520ae08b2d64d6f6cee20ccd1abd7e6c43d5a41685d",
|
||||
"files": [
|
||||
"scripts/active_rectification_event_engine.py",
|
||||
"scripts/active_rectification_events.py",
|
||||
"scripts/ashtakavarga.py",
|
||||
"scripts/dasha_analyzer.py",
|
||||
"scripts/divisional_charts_extended.py",
|
||||
"scripts/domain_calculation_service.py",
|
||||
"scripts/jaimini.py",
|
||||
"scripts/minute_rectification_fact_ranker_v4.py",
|
||||
"scripts/minute_rectification_feature_facts_v4.py",
|
||||
"scripts/narayana_dasha.py",
|
||||
"scripts/shadbala.py",
|
||||
"scripts/varga.py"
|
||||
],
|
||||
"historical_frozen_sha256": "f41c298dd6cdcebe7a93e632f7191954be7987f6012ca2a34cecb6e447fbf196",
|
||||
"evaluator_sha256": "f49eae74e27ecf1c417b3a6423eeb473ce8c8c565a5b7c8768ddb407659e3592",
|
||||
"ayanamsa": "raman",
|
||||
"node_mode": "mean",
|
||||
"candidate_radius_minutes": [
|
||||
10
|
||||
],
|
||||
"minute_step": 1,
|
||||
"release_metrics": {
|
||||
"top_1_rate_minimum": 0.6,
|
||||
"top_3_rate_minimum": 0.85,
|
||||
"mean_absolute_minute_error_maximum": 2.0,
|
||||
"false_confirmation_rate_maximum": 0.05,
|
||||
"correct_insufficient_evidence_rejection_rate_minimum": 0.9
|
||||
},
|
||||
"results_previously_seen": true,
|
||||
"official_valid_independent_blind": false,
|
||||
"must_not_use_for_tuning": true,
|
||||
"tie_breaker": "sha256(benchmark_id:case_id:candidate_time); published minute is never passed to the ranker",
|
||||
"metric_rank_definition": "competition_rank_1_plus_strictly_higher_scores_legacy_protocol",
|
||||
"extra_metric_rank_definition": "score_desc_then_existing_opaque_sha256_total_order"
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -20,6 +20,23 @@ export type DatedCandidateRange = Readonly<{
|
||||
midnight_side_pending?: boolean;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* Scoring generations that carry the dated candidate-window contract. scoring-9
|
||||
* introduced it (BUG-982/983) and every later generation keeps it; compare the
|
||||
* generation number, never one literal, so a version bump (scoring-10 for the
|
||||
* functional benefic / malefic profile v2, BUG-1181) cannot silently turn new
|
||||
* results into legacy same-day ones. Mirrors the SQL guard in
|
||||
* 20261002010000_rectification_dated_algorithm_generation.sql.
|
||||
*/
|
||||
export const FIRST_DATED_SCORING_GENERATION = 9;
|
||||
const SCORING_ALGORITHM_VERSION = /^rectification-v5-matrix-scoring-([1-9][0-9]*)$/;
|
||||
|
||||
export function isDatedScoringAlgorithmVersion(value: unknown): boolean {
|
||||
if (typeof value !== "string") return false;
|
||||
const match = SCORING_ALGORITHM_VERSION.exec(value);
|
||||
return match !== null && Number(match[1]) >= FIRST_DATED_SCORING_GENERATION;
|
||||
}
|
||||
|
||||
export function parseCandidateIntervals(value: unknown): readonly CandidateInterval[] | null {
|
||||
if (!Array.isArray(value) || value.length < 1 || value.length > 2) return null;
|
||||
const rows: CandidateInterval[] = [];
|
||||
|
||||
@@ -26,7 +26,7 @@ import { questionContractVersionIsCompatible } from "./probe-question-contract";
|
||||
import { resolveAyanamsa } from "../../ayanamsa.ts";
|
||||
import { candidateSegmentMetadata } from "./segment-contract.ts";
|
||||
import type { AscendantSignature } from "../core/segment-summary.ts";
|
||||
import { requestCandidateIntervals, readCandidatePosition, type CandidatePosition, type DatedCandidateRange } from "../core/candidate-window.ts";
|
||||
import { isDatedScoringAlgorithmVersion, requestCandidateIntervals, readCandidatePosition, type CandidatePosition, type DatedCandidateRange } from "../core/candidate-window.ts";
|
||||
import { parseBlockScanPayload, type BlockScanBlock } from "./block-scan.ts";
|
||||
import { recordEngineCallTiming, reportTurnProgress } from "./turn-instrumentation.ts";
|
||||
|
||||
@@ -987,7 +987,7 @@ export async function runV9CandidateScore(input: {
|
||||
}): Promise<V9EngineScoreResult> {
|
||||
const data = await postEngine("/api/rectification/v5/score", engineRequestBody(input), 60_000, { busyRetry: true });
|
||||
const datedRange = { ...input.candidateRange, candidate_intervals: requestCandidateIntervals(input.baselineBirthSnapshot, input.candidateRange) };
|
||||
const dated = data.algorithm_version === "rectification-v5-matrix-scoring-9";
|
||||
const dated = isDatedScoringAlgorithmVersion(data.algorithm_version);
|
||||
const metadata = candidateSegmentMetadata(data);
|
||||
const candidates = readCandidates(data.candidate_decisions, datedRange, dated).map((candidate) => ({ ...candidate, ...metadata.byTime.get(candidate.time) }));
|
||||
const receipt = readDecisionReceipt(data.decision_receipt, candidates);
|
||||
@@ -1028,7 +1028,7 @@ export async function runV9Diagnostics(input: {
|
||||
}): Promise<V9EngineDiagnostics> {
|
||||
const data = await postEngine("/api/rectification/v5/diagnostics", engineRequestBody(input));
|
||||
const datedRange = { ...input.candidateRange, candidate_intervals: requestCandidateIntervals(input.baselineBirthSnapshot, input.candidateRange) };
|
||||
const dated = data.algorithm_version === "rectification-v5-matrix-scoring-9";
|
||||
const dated = isDatedScoringAlgorithmVersion(data.algorithm_version);
|
||||
const metadata = candidateSegmentMetadata(data);
|
||||
const candidates = readCandidates(data.candidate_decisions, datedRange, dated).map((candidate) => ({ ...candidate, ...metadata.byTime.get(candidate.time) }));
|
||||
const receipt = readDecisionReceipt(data.decision_receipt, candidates);
|
||||
@@ -1071,7 +1071,7 @@ export async function runV9Diagnostics(input: {
|
||||
// Keep the receipt default aligned with Python's ALGORITHM_VERSION; persisted
|
||||
// receipts retain their original identity (this is not a Skill/open gate).
|
||||
export const v9EngineVersion = (): string =>
|
||||
process.env.RECTIFICATION_ENGINE_VERSION?.trim() || "rectification-v5-matrix-scoring-9";
|
||||
process.env.RECTIFICATION_ENGINE_VERSION?.trim() || "rectification-v5-matrix-scoring-10";
|
||||
|
||||
export type V9RangeReading = Readonly<{
|
||||
stableThemes: readonly string[];
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
import { shouldForceMinuteAfterSubBlocks } from "./block-scan.ts";
|
||||
import { segmentOrderEnabledFor } from "../core/segment-probe-order.ts";
|
||||
import { isDatedScoringAlgorithmVersion } from "../core/candidate-window.ts";
|
||||
import { scanCaseSegments } from "./segment-scan.ts";
|
||||
import { targetChartsForDomain } from "../core/segment-summary.ts";
|
||||
import { buildProductCaseInferenceState } from "./product-inference.ts";
|
||||
@@ -178,7 +179,7 @@ export async function scoreAndPersistCurrentEvidence(input: {
|
||||
if (!candidateRange) throw new RectificationToolServiceError("case_range_missing");
|
||||
const compute = await loadV9CaseCompute(input.accounting, input.userId, input.caseId);
|
||||
const liveIdentity = await readV9EngineScoringIdentity();
|
||||
if (scoringIdentityIsTrusted(liveIdentity) && liveIdentity.algorithmVersion === "rectification-v5-matrix-scoring-9" && !candidateRange.candidate_intervals) {
|
||||
if (scoringIdentityIsTrusted(liveIdentity) && isDatedScoringAlgorithmVersion(liveIdentity.algorithmVersion) && !candidateRange.candidate_intervals) {
|
||||
candidateRange = await ensureV9DatedWindow(input.accounting, input.userId, input.caseId);
|
||||
}
|
||||
if (candidateRange.midnight_side_pending === true && scoringIdentityIsTrusted(liveIdentity)) {
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
import { createHash } from "node:crypto";
|
||||
import { segmentCandidateFields } from "./segment-contract.ts";
|
||||
import { parseSavedCivilFields } from "./saved-civil-fields.ts";
|
||||
import { candidatePositionFields, readCandidatePosition, parseCandidateIntervals, type CandidatePosition, type DatedCandidateRange } from "../core/candidate-window.ts";
|
||||
import { candidatePositionFields, isDatedScoringAlgorithmVersion, readCandidatePosition, parseCandidateIntervals, type CandidatePosition, type DatedCandidateRange } from "../core/candidate-window.ts";
|
||||
import { assertV9ResultWritable, assertV9WindowWritable } from "./result-identity.ts";
|
||||
import type { AdoptedCredibleRangePayload } from "../../report-candidate-range.ts";
|
||||
import {
|
||||
@@ -530,7 +530,7 @@ export function parseV9CandidateSnapshot(value: unknown): V9CandidateSnapshot |
|
||||
|| tiedMinuteCount === null || !Number.isInteger(tiedMinuteCount) || tiedMinuteCount < 1
|
||||
) return null;
|
||||
const position = readCandidatePosition(candidate);
|
||||
if ((row.algorithm_version === "rectification-v5-matrix-scoring-9" || candidate.candidate_date !== undefined) && !position) return null;
|
||||
if ((isDatedScoringAlgorithmVersion(row.algorithm_version) || candidate.candidate_date !== undefined) && !position) return null;
|
||||
seenIds.add(candidateId);
|
||||
candidates.push({
|
||||
candidateId,
|
||||
@@ -633,7 +633,7 @@ export async function loadV9CaseDossier(
|
||||
? { resultId: latest.resultId, candidateId, date, time, contract: "segment-v1" as const } : null;
|
||||
// The old confirmation SQL uses the persisted baseline date for a wholly legacy contract.
|
||||
// Do not infer that civil date from the scan, current profile or a matching clock.
|
||||
const legacy = segmentSelection && latest.algorithmVersion !== "rectification-v5-matrix-scoring-9"
|
||||
const legacy = segmentSelection && !isDatedScoringAlgorithmVersion(latest.algorithmVersion)
|
||||
&& !Object.hasOwn(latest.decisionReceipt ?? {}, "candidate_window_contract")
|
||||
&& !Object.hasOwn(latest.decisionReceipt ?? {}, "candidate_intervals")
|
||||
&& latest.candidates.every(candidate => candidate.candidate_date === undefined)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { readCandidatePosition, parseWindowIntervals, type CandidatePosition, type WindowInterval } from "./rectification-agentic/core/candidate-window.ts";
|
||||
import { isDatedScoringAlgorithmVersion, readCandidatePosition, parseWindowIntervals, type CandidatePosition, type WindowInterval } from "./rectification-agentic/core/candidate-window.ts";
|
||||
import type {
|
||||
DashaAgreement,
|
||||
EventDashaLedgerRow,
|
||||
@@ -370,7 +370,7 @@ export function parseRectificationCandidateResult(value: unknown): Rectification
|
||||
const clusterStart = time(candidate.clusterStart ?? candidate.cluster_start);
|
||||
const clusterEnd = time(candidate.clusterEnd ?? candidate.cluster_end);
|
||||
const position = readCandidatePosition(candidate);
|
||||
if ((candidate.candidate_date !== undefined || snapshot.algorithmVersion === "rectification-v5-matrix-scoring-9") && !position) return null;
|
||||
if ((candidate.candidate_date !== undefined || isDatedScoringAlgorithmVersion(snapshot.algorithmVersion)) && !position) return null;
|
||||
candidates.push({
|
||||
...(position ?? {}),
|
||||
...(position?.cluster_intervals ? { clusterIntervals: position.cluster_intervals } : {}),
|
||||
|
||||
+180
@@ -0,0 +1,180 @@
|
||||
-- BUG-1181: the scoring algorithm identity moves to rectification-v5-matrix-scoring-10
|
||||
-- (functional benefic / malefic profile v2 changes candidate scores for identical
|
||||
-- input). scoring-9 introduced the dated candidate-window contract and every later
|
||||
-- generation keeps it, so this guard compares the generation (>= 9) instead of one
|
||||
-- literal: a bump must not let a partial new contract pass as a legacy same-day
|
||||
-- result. Function body otherwise byte-identical to 20260920020000_adopted_birth_date.sql;
|
||||
-- no table, column, grant or historical row changes (create or replace keeps the
|
||||
-- existing owner and the revoke from 20260920020000).
|
||||
|
||||
create or replace function public.validate_dated_rectification_candidate(
|
||||
p_case public.agentic_rectification_cases,
|
||||
p_result public.agentic_rectification_results,
|
||||
p_candidate public.agentic_rectification_candidates,
|
||||
p_inference jsonb
|
||||
) returns date language plpgsql security definer set search_path = '' as $$
|
||||
declare
|
||||
v_receipt jsonb := p_result.decision_receipt;
|
||||
v_windows jsonb;
|
||||
v_payload jsonb;
|
||||
v_item jsonb;
|
||||
v_interval jsonb;
|
||||
v_window jsonb;
|
||||
v_first timestamp;
|
||||
v_at timestamp;
|
||||
v_start timestamp;
|
||||
v_end timestamp;
|
||||
v_previous timestamp;
|
||||
v_date date;
|
||||
v_expected text;
|
||||
v_count integer;
|
||||
v_union pg_catalog.tsmultirange;
|
||||
v_credible pg_catalog.tsmultirange;
|
||||
v_expected_credible jsonb;
|
||||
v_credible_ranges pg_catalog.tsrange[] := array[]::pg_catalog.tsrange[];
|
||||
v_top text;
|
||||
begin
|
||||
if v_receipt ->> 'candidate_window_contract' is distinct from 'dated-v1' then
|
||||
-- A partial new contract must never silently become a legacy same-day result.
|
||||
if coalesce(p_result.algorithm_version, '') ~ '^rectification-v5-matrix-scoring-(9|[1-9][0-9]+)$'
|
||||
or v_receipt ? 'candidate_window_contract' or v_receipt ? 'candidate_intervals'
|
||||
or p_candidate.candidate_payload ? 'candidate_date'
|
||||
or coalesce(p_inference ->> 'candidate_set_id', '') like 'dated-v1:%' then
|
||||
raise exception 'agentic_rectification_candidate_state_inconsistent';
|
||||
end if;
|
||||
return null;
|
||||
end if;
|
||||
v_windows := v_receipt -> 'candidate_intervals';
|
||||
if jsonb_typeof(v_windows) is distinct from 'array' or jsonb_array_length(v_windows) = 0
|
||||
or v_windows is distinct from p_case.candidate_range -> 'candidate_intervals'
|
||||
or jsonb_typeof(v_receipt -> 'candidate_timezone_offset') is distinct from 'number'
|
||||
or (v_receipt ->> 'candidate_timezone_offset')::double precision is distinct from
|
||||
(p_case.baseline_birth_snapshot ->> 'timezone_offset')::double precision
|
||||
or coalesce(v_receipt ->> 'candidate_timezone_id', '') is distinct from
|
||||
coalesce(p_case.baseline_birth_snapshot ->> 'timezone_id', '')
|
||||
or jsonb_typeof(p_inference -> 'candidates') is distinct from 'array'
|
||||
or jsonb_typeof(p_inference -> 'credible_intervals') is distinct from 'array'
|
||||
or p_inference ->> 'range_start' is distinct from p_case.candidate_range ->> 'start_time'
|
||||
or p_inference ->> 'range_end' is distinct from p_case.candidate_range ->> 'end_time' then
|
||||
raise exception 'agentic_rectification_candidate_state_inconsistent';
|
||||
end if;
|
||||
for v_window in select value from jsonb_array_elements(v_windows) loop
|
||||
if coalesce(v_window ->> 'start_at', '') !~ '^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$'
|
||||
or coalesce(v_window ->> 'end_at', '') !~ '^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$' then
|
||||
raise exception 'agentic_rectification_candidate_state_inconsistent';
|
||||
end if;
|
||||
v_start := (v_window ->> 'start_at')::timestamp;
|
||||
v_end := (v_window ->> 'end_at')::timestamp;
|
||||
if v_end < v_start or v_start <= v_previous then
|
||||
raise exception 'agentic_rectification_candidate_state_inconsistent';
|
||||
end if;
|
||||
v_first := coalesce(v_first, v_start);
|
||||
v_previous := v_end;
|
||||
end loop;
|
||||
select count(*), 'dated-v1:' || (p_case.candidate_range ->> 'start_time') || '-' ||
|
||||
(p_case.candidate_range ->> 'end_time') || ':' || string_agg(
|
||||
(candidate_payload ->> 'candidate_date') || 'T' || to_char(candidate_time, 'HH24:MI') || '@' ||
|
||||
(candidate_payload ->> 'window_index') || '@' || (candidate_payload ->> 'window_offset_minutes') || '@' ||
|
||||
(candidate_payload ->> 'segment_index'), ',' order by (candidate_payload ->> 'window_index')::integer)
|
||||
into v_count, v_expected from public.agentic_rectification_candidates where result_id = p_result.id;
|
||||
if v_count = 0 or jsonb_array_length(p_inference -> 'candidates') <> v_count
|
||||
or p_inference ->> 'candidate_set_id' is distinct from v_expected
|
||||
or (select count(distinct value ->> 'window_index') from jsonb_array_elements(p_inference -> 'candidates')) <> v_count then
|
||||
raise exception 'agentic_rectification_candidate_state_inconsistent';
|
||||
end if;
|
||||
for v_item in select value from jsonb_array_elements(p_inference -> 'candidates') loop
|
||||
select candidate_payload into v_payload from public.agentic_rectification_candidates
|
||||
where result_id = p_result.id and to_char(candidate_time, 'HH24:MI') = v_item ->> 'time';
|
||||
if not found or coalesce(v_item ->> 'candidate_date', '') !~ '^\d{4}-\d{2}-\d{2}$'
|
||||
or coalesce(v_item ->> 'window_index', '') !~ '^\d+$'
|
||||
or coalesce(v_item ->> 'window_offset_minutes', '') !~ '^\d+$'
|
||||
or coalesce(v_item ->> 'segment_index', '') !~ '^\d+$'
|
||||
or v_item -> 'candidate_date' is distinct from v_payload -> 'candidate_date'
|
||||
or v_item -> 'window_index' is distinct from v_payload -> 'window_index'
|
||||
or v_item -> 'window_offset_minutes' is distinct from v_payload -> 'window_offset_minutes'
|
||||
or v_item -> 'segment_index' is distinct from v_payload -> 'segment_index'
|
||||
or v_item -> 'cluster_intervals' is distinct from v_payload -> 'cluster_intervals'
|
||||
or coalesce(v_item ->> 'status', '') not in ('active', 'equivalent', 'winner', 'eliminated')
|
||||
or jsonb_typeof(v_item -> 'probability') is distinct from 'number'
|
||||
or jsonb_typeof(v_item -> 'posterior_score') is distinct from 'number'
|
||||
or jsonb_typeof(v_item -> 'cluster_intervals') is distinct from 'array'
|
||||
or jsonb_array_length(v_item -> 'cluster_intervals') = 0 then
|
||||
raise exception 'agentic_rectification_candidate_state_inconsistent';
|
||||
end if;
|
||||
v_at := ((v_item ->> 'candidate_date') || 'T' || (v_item ->> 'time'))::timestamp;
|
||||
v_window := v_windows -> (v_item ->> 'segment_index')::integer;
|
||||
if v_window is null or v_at < (v_window ->> 'start_at')::timestamp or v_at > (v_window ->> 'end_at')::timestamp
|
||||
or extract(epoch from (v_at - v_first)) / 60 <> (v_item ->> 'window_offset_minutes')::integer then
|
||||
raise exception 'agentic_rectification_candidate_state_inconsistent';
|
||||
end if;
|
||||
if not exists (select 1 from jsonb_array_elements(v_item -> 'cluster_intervals') x
|
||||
where x -> 'segment_index' = v_item -> 'segment_index'
|
||||
and (v_item ->> 'window_index')::integer between (x ->> 'start_index')::integer and (x ->> 'end_index')::integer
|
||||
and v_at between (x ->> 'start_at')::timestamp and (x ->> 'end_at')::timestamp) then
|
||||
raise exception 'agentic_rectification_candidate_state_inconsistent';
|
||||
end if;
|
||||
for v_interval in select value from jsonb_array_elements(v_item -> 'cluster_intervals') loop
|
||||
v_start := (v_interval ->> 'start_at')::timestamp;
|
||||
v_end := (v_interval ->> 'end_at')::timestamp;
|
||||
v_window := v_windows -> (v_interval ->> 'segment_index')::integer;
|
||||
if v_start is null or v_end is null or v_window is null or v_end < v_start
|
||||
or v_start < (v_window ->> 'start_at')::timestamp or v_end > (v_window ->> 'end_at')::timestamp
|
||||
or (v_interval ->> 'start_offset_minutes')::integer is distinct from (extract(epoch from (v_start - v_first)) / 60)::integer
|
||||
or (v_interval ->> 'end_offset_minutes')::integer is distinct from (extract(epoch from (v_end - v_first)) / 60)::integer
|
||||
or coalesce(v_interval ->> 'start_index', '') !~ '^\d+$'
|
||||
or coalesce(v_interval ->> 'end_index', '') !~ '^\d+$'
|
||||
or (v_interval ->> 'end_index')::integer < (v_interval ->> 'start_index')::integer then
|
||||
raise exception 'agentic_rectification_candidate_state_inconsistent';
|
||||
end if;
|
||||
end loop;
|
||||
end loop;
|
||||
-- Historical credible semantics envelope active clusters within each declared segment,
|
||||
-- but never bridge separate declared segments.
|
||||
select range_agg(tsrange(first_at, last_at + interval '1 minute', '[)')),
|
||||
jsonb_agg(jsonb_build_object('segment_index', segment_index,
|
||||
'start_index', first_index, 'end_index', last_index,
|
||||
'start_offset_minutes', (extract(epoch from (first_at - v_first)) / 60)::integer,
|
||||
'end_offset_minutes', (extract(epoch from (last_at - v_first)) / 60)::integer,
|
||||
'start_at', to_char(first_at, 'YYYY-MM-DD"T"HH24:MI'),
|
||||
'end_at', to_char(last_at, 'YYYY-MM-DD"T"HH24:MI')) order by first_index)
|
||||
into v_union, v_expected_credible
|
||||
from (
|
||||
select (part ->> 'segment_index')::integer as segment_index,
|
||||
min((part ->> 'start_index')::integer) as first_index,
|
||||
max((part ->> 'end_index')::integer) as last_index,
|
||||
min((part ->> 'start_at')::timestamp) as first_at,
|
||||
max((part ->> 'end_at')::timestamp) as last_at
|
||||
from jsonb_array_elements(p_inference -> 'candidates') candidate,
|
||||
lateral jsonb_array_elements(candidate -> 'cluster_intervals') part
|
||||
where candidate ->> 'status' <> 'eliminated'
|
||||
and (select (value ->> 'posterior_score')::numeric from jsonb_array_elements(p_inference -> 'candidates')
|
||||
where value ->> 'status' <> 'eliminated'
|
||||
order by (value ->> 'probability')::numeric desc, (value ->> 'posterior_score')::numeric desc,
|
||||
(value ->> 'window_index')::integer limit 1) - (candidate ->> 'posterior_score')::numeric < 8
|
||||
group by (part ->> 'segment_index')::integer
|
||||
) segments;
|
||||
for v_interval in select value from jsonb_array_elements(p_inference -> 'credible_intervals') loop
|
||||
v_start := (v_interval ->> 'start_at')::timestamp;
|
||||
v_end := (v_interval ->> 'end_at')::timestamp;
|
||||
if v_start is null or v_end is null or v_end < v_start then
|
||||
raise exception 'agentic_rectification_candidate_state_inconsistent';
|
||||
end if;
|
||||
v_credible_ranges := array_append(v_credible_ranges, tsrange(v_start, v_end + interval '1 minute', '[)'));
|
||||
end loop;
|
||||
select range_agg(x) into v_credible from unnest(v_credible_ranges) x;
|
||||
select value ->> 'time' into v_top from jsonb_array_elements(p_inference -> 'candidates')
|
||||
where value ->> 'status' <> 'eliminated'
|
||||
order by (value ->> 'probability')::numeric desc, (value ->> 'posterior_score')::numeric desc,
|
||||
(value ->> 'window_index')::integer limit 1;
|
||||
if v_union is null or v_credible is distinct from v_union
|
||||
or p_inference -> 'credible_intervals' is distinct from v_expected_credible
|
||||
or p_inference ->> 'representative_time' is distinct from v_top
|
||||
or not exists (select 1 from jsonb_array_elements(p_inference -> 'candidates')
|
||||
where value ->> 'time' = to_char(p_candidate.candidate_time, 'HH24:MI') and value ->> 'status' <> 'eliminated') then
|
||||
raise exception 'agentic_rectification_candidate_state_inconsistent';
|
||||
end if;
|
||||
v_date := (p_candidate.candidate_payload ->> 'candidate_date')::date;
|
||||
if v_date is null then raise exception 'agentic_rectification_candidate_state_inconsistent'; end if;
|
||||
return v_date;
|
||||
end;
|
||||
$$;
|
||||
@@ -1,195 +1,217 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import test from "node:test";
|
||||
import { closeLocalPostgresDataPool, createLocalPostgresDataClient } from "../src/lib/db/local-postgres-client-core.ts";
|
||||
import { startPostgresFixture } from "./helpers/postgres-fixture.ts";
|
||||
|
||||
const docker = spawnSync("docker", ["version"], { stdio: "ignore" }).status === 0;
|
||||
const runner = fileURLToPath(new URL("../scripts/db-migrate.mjs", import.meta.url));
|
||||
|
||||
// Fictional SQL boundary fixture. Permission booleans are controlled setup, not evidence
|
||||
// that any real engine sample passed confirmation/holdout gates.
|
||||
for (const declaration of [{ date: "2000-06-15", time: "00:10", offset: -1 }, { date: "2000-06-14", time: "23:59", offset: 0 }]) {
|
||||
test(`dated adoption ${declaration.time} persists date/spec atomically and rejects malformed candidates`, { skip: !docker && "docker unavailable" }, async () => {
|
||||
const fixture = startPostgresFixture();
|
||||
const url = fixture.connectionUrl("service_runtime", "service-runtime-test-password");
|
||||
try {
|
||||
const migration = spawnSync(process.execPath, [runner], { encoding: "utf8", env: {
|
||||
...process.env, SCHEMA_DATABASE_URL: fixture.connectionUrl("schema_owner", "schema-owner-test-password"),
|
||||
} });
|
||||
assert.equal(migration.status, 0, migration.stderr);
|
||||
const userId = randomUUID(), sessionId = randomUUID(), caseId = randomUUID();
|
||||
const snapshot = {
|
||||
birth_date: declaration.date, reported_birth_time: declaration.time, active_birth_time: null,
|
||||
birth_time_source: "family_exact", birth_time_period: null,
|
||||
uncertainty_before_minutes: 15, uncertainty_after_minutes: 15,
|
||||
latitude: 40, longitude: -74, timezone_id: "America/New_York", timezone_offset: -4,
|
||||
};
|
||||
const intervals = [{ start_at: "2000-06-14T23:55", end_at: "2000-06-15T00:25" }];
|
||||
const range = { start_time: "23:55", end_time: "00:25", candidate_intervals: intervals };
|
||||
const cluster = [{ segment_index: 0, start_index: 0, end_index: 16, start_offset_minutes: 0,
|
||||
end_offset_minutes: 16, start_at: "2000-06-14T23:55", end_at: "2000-06-15T00:11" }];
|
||||
const candidates = [
|
||||
{ time: "23:55", candidate_date: "2000-06-14", window_index: 0, window_offset_minutes: 0, segment_index: 0 },
|
||||
{ time: "00:11", candidate_date: "2000-06-15", window_index: 16, window_offset_minutes: 16, segment_index: 0 },
|
||||
].map((row, i) => ({ ...row, id: row.time, rank: i + 1, relative_support: 50, tied_minute_count: 1,
|
||||
probability: i ? 0.4 : 0.6, posterior_score: i ? 55 : 60, status: "active",
|
||||
cluster_range: [row.time, row.time], cluster_intervals: [{ segment_index: 0,
|
||||
start_index: row.window_index, end_index: row.window_index,
|
||||
start_offset_minutes: row.window_offset_minutes, end_offset_minutes: row.window_offset_minutes,
|
||||
start_at: `${row.candidate_date}T${row.time}`, end_at: `${row.candidate_date}T${row.time}` }] }));
|
||||
const inference = {
|
||||
revision: 0, range_start: "23:55", range_end: "00:25",
|
||||
candidate_set_id: "dated-v1:23:55-00:25:2000-06-14T23:55@0@0@0,2000-06-15T00:11@16@16@0",
|
||||
candidates, representative_time: "23:55", credible_range: ["23:55", "00:11"], credible_intervals: cluster,
|
||||
};
|
||||
fixture.psqlAs("identity_runtime", "identity-runtime-test-password", `
|
||||
insert into identity.users(id,name,email,email_verified) values ('${userId}','Synthetic Midnight Fixture','${userId}@example.invalid',true);
|
||||
`);
|
||||
fixture.psql(`
|
||||
update public.profiles set birth_date='${declaration.date}',reported_birth_time='${declaration.time}',birth_time_source='family_exact',
|
||||
birth_time_status='reported',uncertainty_before_minutes=15,uncertainty_after_minutes=15,
|
||||
latitude=40,longitude=-74,timezone_id='America/New_York',timezone_offset=-4 where id='${userId}';
|
||||
insert into public.chat_sessions(id,user_id,title,theme,session_type,messages)
|
||||
values('${sessionId}','${userId}','Synthetic boundary','general','birth_time_rectification','[]');
|
||||
insert into public.agentic_rectification_cases(id,user_id,session_id,status,skill_name,skill_version,
|
||||
baseline_profile_fingerprint,baseline_birth_snapshot,candidate_range)
|
||||
values('${caseId}','${userId}','${sessionId}','candidate_ready','jyotish-birth-time-rectification','9.0.0',
|
||||
'${"a".repeat(64)}','${JSON.stringify(snapshot)}','${JSON.stringify(range)}');
|
||||
`);
|
||||
const service = createLocalPostgresDataClient(url, null, "service_role");
|
||||
const persisted = await service.rpc("persist_agentic_rectification_candidate_v2", {
|
||||
p_user_id: userId, p_case_id: caseId, p_engine_result_id: "synthetic-dated-boundary",
|
||||
p_evidence_ledger_fingerprint: "b".repeat(64), p_candidate_range_fingerprint: "c".repeat(64),
|
||||
p_skill_version: "9.0.0", p_algorithm_version: "synthetic-boundary-v1",
|
||||
p_event_contract_version: "rectification-event-contract-v2", p_decision_policy_version: "rectification-candidate-policy-v2",
|
||||
p_candidate_range: range, p_candidates: candidates,
|
||||
p_decision_receipt: { display_allowed: true, accept_allowed: true, confirm_allowed: true,
|
||||
representative_time: "23:55", overall_confidence: "low", margin_percent: 1,
|
||||
candidate_window_contract: "dated-v1", candidate_intervals: intervals,
|
||||
candidate_timezone_offset: -4, candidate_timezone_id: "America/New_York", inference_state: inference },
|
||||
p_execution_ledger: [{ phase: "candidate.score", status: "completed", engine: "synthetic-boundary" }],
|
||||
});
|
||||
assert.equal(persisted.error, null, JSON.stringify(persisted.error));
|
||||
const row = persisted.data as { result_id: string; candidates: { time: string; candidate_id: string }[] };
|
||||
const candidateId = row.candidates.find(c => c.time === "23:55")!.candidate_id;
|
||||
const nextId = row.candidates.find(c => c.time === "00:11")!.candidate_id;
|
||||
const accept = (id = candidateId, requestId = randomUUID()) => service.rpc("accept_agentic_rectification_candidate_for_case_v2", {
|
||||
p_user_id: userId, p_case_id: caseId, p_result_id: row.result_id, p_candidate_id: id, p_request_id: requestId,
|
||||
});
|
||||
assert.ok((await service.rpc("accept_agentic_rectification_candidate_for_case_v2", {
|
||||
p_user_id: randomUUID(), p_case_id: caseId, p_result_id: row.result_id, p_candidate_id: candidateId, p_request_id: randomUUID(),
|
||||
})).error, "dated candidate remains ownership scoped");
|
||||
fixture.psql(`update public.profiles set reported_birth_time='00:12' where id='${userId}'`);
|
||||
assert.ok((await accept()).error, "changed declaration invalidates dated candidates");
|
||||
fixture.psql(`update public.profiles set reported_birth_time='${declaration.time}' where id='${userId}';
|
||||
update public.agentic_rectification_results set invalidated_at=null where id='${row.result_id}';
|
||||
update public.agentic_rectification_cases set status='candidate_ready' where id='${caseId}'`);
|
||||
fixture.psql(`update public.agentic_rectification_candidates set candidate_payload=candidate_payload-'candidate_date' where id='${candidateId}'`);
|
||||
assert.ok((await accept()).error, "dated payload without date must fail closed");
|
||||
fixture.psql(`update public.agentic_rectification_candidates set candidate_payload=candidate_payload || '{"candidate_date":"2000-06-14"}' where id='${candidateId}'`);
|
||||
for (const patch of [
|
||||
{ candidate_date: "2000-06-16" }, { window_offset_minutes: 500 }, { segment_index: 7 },
|
||||
]) {
|
||||
fixture.psql(`update public.agentic_rectification_candidates set candidate_payload=candidate_payload || '${JSON.stringify(patch)}' where id='${candidateId}'`);
|
||||
assert.ok((await accept()).error, "candidate membership cannot be forged");
|
||||
fixture.psql(`update public.agentic_rectification_candidates set candidate_payload='${JSON.stringify(candidates[0])}' where id='${candidateId}'`);
|
||||
}
|
||||
fixture.psql(`update public.agentic_rectification_results set decision_receipt=jsonb_set(decision_receipt,'{candidate_timezone_offset}','-5') where id='${row.result_id}'`);
|
||||
assert.ok((await accept()).error, "candidate offset must match frozen calculation baseline");
|
||||
fixture.psql(`update public.agentic_rectification_results set decision_receipt=jsonb_set(decision_receipt,'{candidate_timezone_offset}','-4') where id='${row.result_id}'`);
|
||||
for (const patch of [{ segment_index: 7 }, { start_index: 3 }, { end_offset_minutes: 500 }]) {
|
||||
const malformed = { ...inference, credible_intervals: [{ ...cluster[0], ...patch }] };
|
||||
fixture.psql(`update public.agentic_rectification_results set decision_receipt=jsonb_set(decision_receipt,'{inference_state}','${JSON.stringify(malformed)}') where id='${row.result_id}'`);
|
||||
assert.ok((await accept()).error, "credible metadata must match the dated cluster envelope");
|
||||
}
|
||||
fixture.psql(`update public.agentic_rectification_results set decision_receipt=jsonb_set(decision_receipt,'{inference_state}','${JSON.stringify(inference)}') where id='${row.result_id}'`);
|
||||
const originalReceipt = fixture.psql(`select decision_receipt from public.agentic_rectification_results where id='${row.result_id}'`);
|
||||
fixture.psql(`update public.agentic_rectification_results set algorithm_version='rectification-v5-matrix-scoring-9',
|
||||
decision_receipt=decision_receipt-'candidate_window_contract'-'candidate_intervals'-'inference_state' where id='${row.result_id}';
|
||||
update public.agentic_rectification_candidates set candidate_payload=candidate_payload-'candidate_date'-'window_index'-'window_offset_minutes'-'segment_index'-'cluster_intervals' where result_id='${row.result_id}'`);
|
||||
const rejectsNewIdentity = fixture.psql(`do $$ begin
|
||||
begin
|
||||
perform public.validate_dated_rectification_candidate(c,r,p,null)
|
||||
from public.agentic_rectification_cases c, public.agentic_rectification_results r, public.agentic_rectification_candidates p
|
||||
where c.id='${caseId}' and r.id='${row.result_id}' and p.id='${candidateId}';
|
||||
raise exception 'expected_rejection_missing';
|
||||
exception when others then
|
||||
if sqlerrm <> 'agentic_rectification_candidate_state_inconsistent' then raise; end if;
|
||||
end;
|
||||
end $$; select 'rejected';`);
|
||||
assert.match(rejectsNewIdentity, /rejected/);
|
||||
fixture.psql(`update public.agentic_rectification_results set algorithm_version='synthetic-boundary-v1',decision_receipt='${originalReceipt}' where id='${row.result_id}';
|
||||
update public.agentic_rectification_candidates set candidate_payload='${JSON.stringify(candidates[0])}' where id='${candidateId}';
|
||||
update public.agentic_rectification_candidates set candidate_payload='${JSON.stringify(candidates[1])}' where id='${nextId}'`);
|
||||
const splitWindows = [
|
||||
{ start_at: "2000-06-14T23:55", end_at: "2000-06-14T23:59" },
|
||||
{ start_at: "2000-06-15T00:05", end_at: "2000-06-15T00:25" },
|
||||
];
|
||||
const splitCandidates = candidates.map((c, i) => ({ ...c, segment_index: i,
|
||||
cluster_intervals: c.cluster_intervals.map(part => ({ ...part, segment_index: i })) }));
|
||||
const splitInference = { ...inference, candidates: splitCandidates, credible_range: null,
|
||||
credible_intervals: splitCandidates.flatMap(c => c.cluster_intervals),
|
||||
candidate_set_id: inference.candidate_set_id.replace("00:11@16@16@0", "00:11@16@16@1") };
|
||||
fixture.psql(`update public.agentic_rectification_cases set candidate_range=jsonb_set(candidate_range,'{candidate_intervals}','${JSON.stringify(splitWindows)}') where id='${caseId}';
|
||||
update public.agentic_rectification_results set decision_receipt=jsonb_set(jsonb_set(decision_receipt,'{candidate_intervals}','${JSON.stringify(splitWindows)}'),'{inference_state}','${JSON.stringify({ ...splitInference, credible_intervals: cluster })}') where id='${row.result_id}';
|
||||
update public.agentic_rectification_candidates set candidate_payload='${JSON.stringify(splitCandidates[1])}' where id='${nextId}'`);
|
||||
assert.ok((await accept()).error, "credible envelope must not bridge separate declared segments");
|
||||
fixture.psql(`update public.agentic_rectification_results set decision_receipt=jsonb_set(decision_receipt,'{inference_state}','${JSON.stringify(splitInference)}') where id='${row.result_id}'`);
|
||||
assert.equal((await accept()).error, null, "separate credible segments remain adoptable");
|
||||
const reportRange = await service.rpc("read_report_candidate_range", { p_user_id: userId, p_rectification_case_id: caseId });
|
||||
assert.equal(reportRange.error, null);
|
||||
assert.deepEqual((reportRange.data as Record<string, unknown>).candidate_intervals, splitInference.credible_intervals);
|
||||
fixture.psql(`update public.agentic_rectification_cases set candidate_range='${JSON.stringify(range)}' where id='${caseId}';
|
||||
update public.agentic_rectification_results set decision_receipt='${originalReceipt}' where id='${row.result_id}';
|
||||
update public.agentic_rectification_candidates set candidate_payload='${JSON.stringify(candidates[1])}' where id='${nextId}'`);
|
||||
// A still-active candidate outside the existing separation lead is not in the credible union.
|
||||
const weakInference = { ...inference, candidates: candidates.map((c, i) => i ? { ...c, posterior_score: 40 } : c),
|
||||
credible_intervals: candidates[0].cluster_intervals, credible_range: ["23:55", "23:55"] };
|
||||
fixture.psql(`update public.agentic_rectification_results set decision_receipt=jsonb_set(decision_receipt,'{inference_state}','${JSON.stringify(weakInference)}') where id='${row.result_id}'`);
|
||||
assert.equal((await accept()).error, null, "separation lead excludes weak active candidate");
|
||||
fixture.psql(`update public.agentic_rectification_results set decision_receipt=jsonb_set(decision_receipt,'{inference_state}','${JSON.stringify(inference)}') where id='${row.result_id}'`);
|
||||
const requestId = randomUUID();
|
||||
const accepted = await accept(candidateId, requestId);
|
||||
assert.equal(accepted.error, null, JSON.stringify(accepted.error));
|
||||
assert.equal((accepted.data as Record<string, unknown>).saved_date, "2000-06-14");
|
||||
assert.equal((accepted.data as Record<string, unknown>).day_offset, declaration.offset);
|
||||
assert.equal(fixture.psql(`select birth_date || ':' || active_birth_date || ':' || active_birth_timezone_offset from public.profiles where id='${userId}'`), `${declaration.date}:2000-06-14:-4`);
|
||||
assert.equal((await accept(candidateId, requestId)).error, null);
|
||||
const switched = await accept(nextId);
|
||||
assert.equal(switched.error, null, JSON.stringify(switched.error));
|
||||
assert.equal((switched.data as Record<string, unknown>).saved_date, "2000-06-15");
|
||||
assert.equal((switched.data as Record<string, unknown>).day_offset, declaration.offset + 1);
|
||||
assert.equal(fixture.psql(`select adopted_credible_range->>'representative_date' || 'T' || (adopted_credible_range->>'representative_time') from public.agentic_rectification_cases where id='${caseId}'`), "2000-06-15T00:11");
|
||||
assert.equal((await accept()).error, null);
|
||||
const turnId = randomUUID();
|
||||
fixture.psql(`insert into public.agentic_rectification_turns(id,case_id,model_name,user_message,assistant_message,status)
|
||||
values('${turnId}','${caseId}','synthetic','Confirm synthetic boundary','Synthetic acknowledgment','completed')`);
|
||||
const confirmed = await service.rpc("confirm_agentic_rectification_candidate_for_case_v2", {
|
||||
p_user_id: userId, p_case_id: caseId, p_result_id: row.result_id, p_candidate_id: candidateId,
|
||||
p_request_id: randomUUID(), p_source_turn_id: turnId, p_consent_quote: "Confirm synthetic boundary",
|
||||
});
|
||||
assert.equal(confirmed.error, null, JSON.stringify(confirmed.error));
|
||||
assert.equal((confirmed.data as Record<string, unknown>).saved_date, "2000-06-14");
|
||||
fixture.psql(`delete from public.agentic_rectification_candidate_decisions where case_id='${caseId}';
|
||||
update public.agentic_rectification_results set selected_candidate_id=null where case_id='${caseId}';
|
||||
delete from public.agentic_rectification_candidates where case_id='${caseId}';
|
||||
delete from public.agentic_rectification_cases where id='${caseId}'`);
|
||||
assert.equal(fixture.psql(`select active_birth_date || ':' || (active_birth_provenance->>'candidate_id') from public.profiles where id='${userId}'`), `2000-06-14:${candidateId}`);
|
||||
for (const mutation of ["active_birth_time='23:56'", "birth_time_status='reported'", "timezone_offset=-5", "birth_date='2000-06-16'"]) {
|
||||
fixture.psql(`update public.profiles set birth_time_status='accepted',active_birth_time='23:55' where id='${userId}';
|
||||
update public.profiles set active_birth_date='2000-06-14',active_birth_timezone_offset=-4,active_birth_provenance='{"contract":"dated-v1"}' where id='${userId}';
|
||||
update public.profiles set ${mutation} where id='${userId}'`);
|
||||
assert.equal(fixture.psql(`select (active_birth_date is null and active_birth_timezone_offset is null and active_birth_provenance is null)::text from public.profiles where id='${userId}'`), "true", mutation);
|
||||
}
|
||||
fixture.psql(`update public.profiles set birth_date='2000-06-16' where id='${userId}'`);
|
||||
assert.equal(fixture.psql(`select (active_birth_date is null and active_birth_timezone_offset is null and active_birth_provenance is null)::text from public.profiles where id='${userId}'`), "true");
|
||||
} finally {
|
||||
await closeLocalPostgresDataPool(url);
|
||||
fixture.stop();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
import assert from "node:assert/strict";
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import test from "node:test";
|
||||
import { closeLocalPostgresDataPool, createLocalPostgresDataClient } from "../src/lib/db/local-postgres-client-core.ts";
|
||||
import { startPostgresFixture } from "./helpers/postgres-fixture.ts";
|
||||
|
||||
const docker = spawnSync("docker", ["version"], { stdio: "ignore" }).status === 0;
|
||||
const runner = fileURLToPath(new URL("../scripts/db-migrate.mjs", import.meta.url));
|
||||
|
||||
// Fictional SQL boundary fixture. Permission booleans are controlled setup, not evidence
|
||||
// that any real engine sample passed confirmation/holdout gates.
|
||||
for (const declaration of [{ date: "2000-06-15", time: "00:10", offset: -1 }, { date: "2000-06-14", time: "23:59", offset: 0 }]) {
|
||||
test(`dated adoption ${declaration.time} persists date/spec atomically and rejects malformed candidates`, { skip: !docker && "docker unavailable" }, async () => {
|
||||
const fixture = startPostgresFixture();
|
||||
const url = fixture.connectionUrl("service_runtime", "service-runtime-test-password");
|
||||
try {
|
||||
const migration = spawnSync(process.execPath, [runner], { encoding: "utf8", env: {
|
||||
...process.env, SCHEMA_DATABASE_URL: fixture.connectionUrl("schema_owner", "schema-owner-test-password"),
|
||||
} });
|
||||
assert.equal(migration.status, 0, migration.stderr);
|
||||
const userId = randomUUID(), sessionId = randomUUID(), caseId = randomUUID();
|
||||
const snapshot = {
|
||||
birth_date: declaration.date, reported_birth_time: declaration.time, active_birth_time: null,
|
||||
birth_time_source: "family_exact", birth_time_period: null,
|
||||
uncertainty_before_minutes: 15, uncertainty_after_minutes: 15,
|
||||
latitude: 40, longitude: -74, timezone_id: "America/New_York", timezone_offset: -4,
|
||||
};
|
||||
const intervals = [{ start_at: "2000-06-14T23:55", end_at: "2000-06-15T00:25" }];
|
||||
const range = { start_time: "23:55", end_time: "00:25", candidate_intervals: intervals };
|
||||
const cluster = [{ segment_index: 0, start_index: 0, end_index: 16, start_offset_minutes: 0,
|
||||
end_offset_minutes: 16, start_at: "2000-06-14T23:55", end_at: "2000-06-15T00:11" }];
|
||||
const candidates = [
|
||||
{ time: "23:55", candidate_date: "2000-06-14", window_index: 0, window_offset_minutes: 0, segment_index: 0 },
|
||||
{ time: "00:11", candidate_date: "2000-06-15", window_index: 16, window_offset_minutes: 16, segment_index: 0 },
|
||||
].map((row, i) => ({ ...row, id: row.time, rank: i + 1, relative_support: 50, tied_minute_count: 1,
|
||||
probability: i ? 0.4 : 0.6, posterior_score: i ? 55 : 60, status: "active",
|
||||
cluster_range: [row.time, row.time], cluster_intervals: [{ segment_index: 0,
|
||||
start_index: row.window_index, end_index: row.window_index,
|
||||
start_offset_minutes: row.window_offset_minutes, end_offset_minutes: row.window_offset_minutes,
|
||||
start_at: `${row.candidate_date}T${row.time}`, end_at: `${row.candidate_date}T${row.time}` }] }));
|
||||
const inference = {
|
||||
revision: 0, range_start: "23:55", range_end: "00:25",
|
||||
candidate_set_id: "dated-v1:23:55-00:25:2000-06-14T23:55@0@0@0,2000-06-15T00:11@16@16@0",
|
||||
candidates, representative_time: "23:55", credible_range: ["23:55", "00:11"], credible_intervals: cluster,
|
||||
};
|
||||
fixture.psqlAs("identity_runtime", "identity-runtime-test-password", `
|
||||
insert into identity.users(id,name,email,email_verified) values ('${userId}','Synthetic Midnight Fixture','${userId}@example.invalid',true);
|
||||
`);
|
||||
fixture.psql(`
|
||||
update public.profiles set birth_date='${declaration.date}',reported_birth_time='${declaration.time}',birth_time_source='family_exact',
|
||||
birth_time_status='reported',uncertainty_before_minutes=15,uncertainty_after_minutes=15,
|
||||
latitude=40,longitude=-74,timezone_id='America/New_York',timezone_offset=-4 where id='${userId}';
|
||||
insert into public.chat_sessions(id,user_id,title,theme,session_type,messages)
|
||||
values('${sessionId}','${userId}','Synthetic boundary','general','birth_time_rectification','[]');
|
||||
insert into public.agentic_rectification_cases(id,user_id,session_id,status,skill_name,skill_version,
|
||||
baseline_profile_fingerprint,baseline_birth_snapshot,candidate_range)
|
||||
values('${caseId}','${userId}','${sessionId}','candidate_ready','jyotish-birth-time-rectification','9.0.0',
|
||||
'${"a".repeat(64)}','${JSON.stringify(snapshot)}','${JSON.stringify(range)}');
|
||||
`);
|
||||
const service = createLocalPostgresDataClient(url, null, "service_role");
|
||||
const persisted = await service.rpc("persist_agentic_rectification_candidate_v2", {
|
||||
p_user_id: userId, p_case_id: caseId, p_engine_result_id: "synthetic-dated-boundary",
|
||||
p_evidence_ledger_fingerprint: "b".repeat(64), p_candidate_range_fingerprint: "c".repeat(64),
|
||||
p_skill_version: "9.0.0", p_algorithm_version: "synthetic-boundary-v1",
|
||||
p_event_contract_version: "rectification-event-contract-v2", p_decision_policy_version: "rectification-candidate-policy-v2",
|
||||
p_candidate_range: range, p_candidates: candidates,
|
||||
p_decision_receipt: { display_allowed: true, accept_allowed: true, confirm_allowed: true,
|
||||
representative_time: "23:55", overall_confidence: "low", margin_percent: 1,
|
||||
candidate_window_contract: "dated-v1", candidate_intervals: intervals,
|
||||
candidate_timezone_offset: -4, candidate_timezone_id: "America/New_York", inference_state: inference },
|
||||
p_execution_ledger: [{ phase: "candidate.score", status: "completed", engine: "synthetic-boundary" }],
|
||||
});
|
||||
assert.equal(persisted.error, null, JSON.stringify(persisted.error));
|
||||
const row = persisted.data as { result_id: string; candidates: { time: string; candidate_id: string }[] };
|
||||
const candidateId = row.candidates.find(c => c.time === "23:55")!.candidate_id;
|
||||
const nextId = row.candidates.find(c => c.time === "00:11")!.candidate_id;
|
||||
const accept = (id = candidateId, requestId = randomUUID()) => service.rpc("accept_agentic_rectification_candidate_for_case_v2", {
|
||||
p_user_id: userId, p_case_id: caseId, p_result_id: row.result_id, p_candidate_id: id, p_request_id: requestId,
|
||||
});
|
||||
assert.ok((await service.rpc("accept_agentic_rectification_candidate_for_case_v2", {
|
||||
p_user_id: randomUUID(), p_case_id: caseId, p_result_id: row.result_id, p_candidate_id: candidateId, p_request_id: randomUUID(),
|
||||
})).error, "dated candidate remains ownership scoped");
|
||||
fixture.psql(`update public.profiles set reported_birth_time='00:12' where id='${userId}'`);
|
||||
assert.ok((await accept()).error, "changed declaration invalidates dated candidates");
|
||||
fixture.psql(`update public.profiles set reported_birth_time='${declaration.time}' where id='${userId}';
|
||||
update public.agentic_rectification_results set invalidated_at=null where id='${row.result_id}';
|
||||
update public.agentic_rectification_cases set status='candidate_ready' where id='${caseId}'`);
|
||||
fixture.psql(`update public.agentic_rectification_candidates set candidate_payload=candidate_payload-'candidate_date' where id='${candidateId}'`);
|
||||
assert.ok((await accept()).error, "dated payload without date must fail closed");
|
||||
fixture.psql(`update public.agentic_rectification_candidates set candidate_payload=candidate_payload || '{"candidate_date":"2000-06-14"}' where id='${candidateId}'`);
|
||||
for (const patch of [
|
||||
{ candidate_date: "2000-06-16" }, { window_offset_minutes: 500 }, { segment_index: 7 },
|
||||
]) {
|
||||
fixture.psql(`update public.agentic_rectification_candidates set candidate_payload=candidate_payload || '${JSON.stringify(patch)}' where id='${candidateId}'`);
|
||||
assert.ok((await accept()).error, "candidate membership cannot be forged");
|
||||
fixture.psql(`update public.agentic_rectification_candidates set candidate_payload='${JSON.stringify(candidates[0])}' where id='${candidateId}'`);
|
||||
}
|
||||
fixture.psql(`update public.agentic_rectification_results set decision_receipt=jsonb_set(decision_receipt,'{candidate_timezone_offset}','-5') where id='${row.result_id}'`);
|
||||
assert.ok((await accept()).error, "candidate offset must match frozen calculation baseline");
|
||||
fixture.psql(`update public.agentic_rectification_results set decision_receipt=jsonb_set(decision_receipt,'{candidate_timezone_offset}','-4') where id='${row.result_id}'`);
|
||||
for (const patch of [{ segment_index: 7 }, { start_index: 3 }, { end_offset_minutes: 500 }]) {
|
||||
const malformed = { ...inference, credible_intervals: [{ ...cluster[0], ...patch }] };
|
||||
fixture.psql(`update public.agentic_rectification_results set decision_receipt=jsonb_set(decision_receipt,'{inference_state}','${JSON.stringify(malformed)}') where id='${row.result_id}'`);
|
||||
assert.ok((await accept()).error, "credible metadata must match the dated cluster envelope");
|
||||
}
|
||||
fixture.psql(`update public.agentic_rectification_results set decision_receipt=jsonb_set(decision_receipt,'{inference_state}','${JSON.stringify(inference)}') where id='${row.result_id}'`);
|
||||
const originalReceipt = fixture.psql(`select decision_receipt from public.agentic_rectification_results where id='${row.result_id}'`);
|
||||
fixture.psql(`update public.agentic_rectification_results set algorithm_version='rectification-v5-matrix-scoring-9',
|
||||
decision_receipt=decision_receipt-'candidate_window_contract'-'candidate_intervals'-'inference_state' where id='${row.result_id}';
|
||||
update public.agentic_rectification_candidates set candidate_payload=candidate_payload-'candidate_date'-'window_index'-'window_offset_minutes'-'segment_index'-'cluster_intervals' where result_id='${row.result_id}'`);
|
||||
const rejectsNewIdentity = fixture.psql(`do $$ begin
|
||||
begin
|
||||
perform public.validate_dated_rectification_candidate(c,r,p,null)
|
||||
from public.agentic_rectification_cases c, public.agentic_rectification_results r, public.agentic_rectification_candidates p
|
||||
where c.id='${caseId}' and r.id='${row.result_id}' and p.id='${candidateId}';
|
||||
raise exception 'expected_rejection_missing';
|
||||
exception when others then
|
||||
if sqlerrm <> 'agentic_rectification_candidate_state_inconsistent' then raise; end if;
|
||||
end;
|
||||
end $$; select 'rejected';`);
|
||||
assert.match(rejectsNewIdentity, /rejected/);
|
||||
// BUG-1181: scoring-10 (and later) keeps the dated contract; a stripped receipt is rejected,
|
||||
// while a pre-dated generation (scoring-8) stays a legacy same-day result (null).
|
||||
const setVersion = (version: string) => fixture.psql(`update public.agentic_rectification_results set algorithm_version='${version}' where id='${row.result_id}'`);
|
||||
const rejects = () => fixture.psql(`do $$ begin
|
||||
begin
|
||||
perform public.validate_dated_rectification_candidate(c,r,p,null)
|
||||
from public.agentic_rectification_cases c, public.agentic_rectification_results r, public.agentic_rectification_candidates p
|
||||
where c.id='${caseId}' and r.id='${row.result_id}' and p.id='${candidateId}';
|
||||
raise exception 'expected_rejection_missing';
|
||||
exception when others then
|
||||
if sqlerrm <> 'agentic_rectification_candidate_state_inconsistent' then raise; end if;
|
||||
end;
|
||||
end $$; select 'rejected';`);
|
||||
for (const version of ["rectification-v5-matrix-scoring-10", "rectification-v5-matrix-scoring-11"]) {
|
||||
setVersion(version);
|
||||
assert.match(rejects(), /rejected/, `${version} must not pass as legacy`);
|
||||
}
|
||||
setVersion("rectification-v5-matrix-scoring-8");
|
||||
const legacy = fixture.psql(`select coalesce(public.validate_dated_rectification_candidate(c,r,p,null)::text, 'legacy-null')
|
||||
from public.agentic_rectification_cases c, public.agentic_rectification_results r, public.agentic_rectification_candidates p
|
||||
where c.id='${caseId}' and r.id='${row.result_id}' and p.id='${candidateId}'`);
|
||||
assert.match(legacy, /legacy-null/, "pre-dated generations stay legacy same-day results");
|
||||
fixture.psql(`update public.agentic_rectification_results set algorithm_version='synthetic-boundary-v1',decision_receipt='${originalReceipt}' where id='${row.result_id}';
|
||||
update public.agentic_rectification_candidates set candidate_payload='${JSON.stringify(candidates[0])}' where id='${candidateId}';
|
||||
update public.agentic_rectification_candidates set candidate_payload='${JSON.stringify(candidates[1])}' where id='${nextId}'`);
|
||||
const splitWindows = [
|
||||
{ start_at: "2000-06-14T23:55", end_at: "2000-06-14T23:59" },
|
||||
{ start_at: "2000-06-15T00:05", end_at: "2000-06-15T00:25" },
|
||||
];
|
||||
const splitCandidates = candidates.map((c, i) => ({ ...c, segment_index: i,
|
||||
cluster_intervals: c.cluster_intervals.map(part => ({ ...part, segment_index: i })) }));
|
||||
const splitInference = { ...inference, candidates: splitCandidates, credible_range: null,
|
||||
credible_intervals: splitCandidates.flatMap(c => c.cluster_intervals),
|
||||
candidate_set_id: inference.candidate_set_id.replace("00:11@16@16@0", "00:11@16@16@1") };
|
||||
fixture.psql(`update public.agentic_rectification_cases set candidate_range=jsonb_set(candidate_range,'{candidate_intervals}','${JSON.stringify(splitWindows)}') where id='${caseId}';
|
||||
update public.agentic_rectification_results set decision_receipt=jsonb_set(jsonb_set(decision_receipt,'{candidate_intervals}','${JSON.stringify(splitWindows)}'),'{inference_state}','${JSON.stringify({ ...splitInference, credible_intervals: cluster })}') where id='${row.result_id}';
|
||||
update public.agentic_rectification_candidates set candidate_payload='${JSON.stringify(splitCandidates[1])}' where id='${nextId}'`);
|
||||
assert.ok((await accept()).error, "credible envelope must not bridge separate declared segments");
|
||||
fixture.psql(`update public.agentic_rectification_results set decision_receipt=jsonb_set(decision_receipt,'{inference_state}','${JSON.stringify(splitInference)}') where id='${row.result_id}'`);
|
||||
assert.equal((await accept()).error, null, "separate credible segments remain adoptable");
|
||||
const reportRange = await service.rpc("read_report_candidate_range", { p_user_id: userId, p_rectification_case_id: caseId });
|
||||
assert.equal(reportRange.error, null);
|
||||
assert.deepEqual((reportRange.data as Record<string, unknown>).candidate_intervals, splitInference.credible_intervals);
|
||||
fixture.psql(`update public.agentic_rectification_cases set candidate_range='${JSON.stringify(range)}' where id='${caseId}';
|
||||
update public.agentic_rectification_results set decision_receipt='${originalReceipt}' where id='${row.result_id}';
|
||||
update public.agentic_rectification_candidates set candidate_payload='${JSON.stringify(candidates[1])}' where id='${nextId}'`);
|
||||
// A still-active candidate outside the existing separation lead is not in the credible union.
|
||||
const weakInference = { ...inference, candidates: candidates.map((c, i) => i ? { ...c, posterior_score: 40 } : c),
|
||||
credible_intervals: candidates[0].cluster_intervals, credible_range: ["23:55", "23:55"] };
|
||||
fixture.psql(`update public.agentic_rectification_results set decision_receipt=jsonb_set(decision_receipt,'{inference_state}','${JSON.stringify(weakInference)}') where id='${row.result_id}'`);
|
||||
assert.equal((await accept()).error, null, "separation lead excludes weak active candidate");
|
||||
fixture.psql(`update public.agentic_rectification_results set decision_receipt=jsonb_set(decision_receipt,'{inference_state}','${JSON.stringify(inference)}') where id='${row.result_id}'`);
|
||||
const requestId = randomUUID();
|
||||
const accepted = await accept(candidateId, requestId);
|
||||
assert.equal(accepted.error, null, JSON.stringify(accepted.error));
|
||||
assert.equal((accepted.data as Record<string, unknown>).saved_date, "2000-06-14");
|
||||
assert.equal((accepted.data as Record<string, unknown>).day_offset, declaration.offset);
|
||||
assert.equal(fixture.psql(`select birth_date || ':' || active_birth_date || ':' || active_birth_timezone_offset from public.profiles where id='${userId}'`), `${declaration.date}:2000-06-14:-4`);
|
||||
assert.equal((await accept(candidateId, requestId)).error, null);
|
||||
const switched = await accept(nextId);
|
||||
assert.equal(switched.error, null, JSON.stringify(switched.error));
|
||||
assert.equal((switched.data as Record<string, unknown>).saved_date, "2000-06-15");
|
||||
assert.equal((switched.data as Record<string, unknown>).day_offset, declaration.offset + 1);
|
||||
assert.equal(fixture.psql(`select adopted_credible_range->>'representative_date' || 'T' || (adopted_credible_range->>'representative_time') from public.agentic_rectification_cases where id='${caseId}'`), "2000-06-15T00:11");
|
||||
assert.equal((await accept()).error, null);
|
||||
const turnId = randomUUID();
|
||||
fixture.psql(`insert into public.agentic_rectification_turns(id,case_id,model_name,user_message,assistant_message,status)
|
||||
values('${turnId}','${caseId}','synthetic','Confirm synthetic boundary','Synthetic acknowledgment','completed')`);
|
||||
const confirmed = await service.rpc("confirm_agentic_rectification_candidate_for_case_v2", {
|
||||
p_user_id: userId, p_case_id: caseId, p_result_id: row.result_id, p_candidate_id: candidateId,
|
||||
p_request_id: randomUUID(), p_source_turn_id: turnId, p_consent_quote: "Confirm synthetic boundary",
|
||||
});
|
||||
assert.equal(confirmed.error, null, JSON.stringify(confirmed.error));
|
||||
assert.equal((confirmed.data as Record<string, unknown>).saved_date, "2000-06-14");
|
||||
fixture.psql(`delete from public.agentic_rectification_candidate_decisions where case_id='${caseId}';
|
||||
update public.agentic_rectification_results set selected_candidate_id=null where case_id='${caseId}';
|
||||
delete from public.agentic_rectification_candidates where case_id='${caseId}';
|
||||
delete from public.agentic_rectification_cases where id='${caseId}'`);
|
||||
assert.equal(fixture.psql(`select active_birth_date || ':' || (active_birth_provenance->>'candidate_id') from public.profiles where id='${userId}'`), `2000-06-14:${candidateId}`);
|
||||
for (const mutation of ["active_birth_time='23:56'", "birth_time_status='reported'", "timezone_offset=-5", "birth_date='2000-06-16'"]) {
|
||||
fixture.psql(`update public.profiles set birth_time_status='accepted',active_birth_time='23:55' where id='${userId}';
|
||||
update public.profiles set active_birth_date='2000-06-14',active_birth_timezone_offset=-4,active_birth_provenance='{"contract":"dated-v1"}' where id='${userId}';
|
||||
update public.profiles set ${mutation} where id='${userId}'`);
|
||||
assert.equal(fixture.psql(`select (active_birth_date is null and active_birth_timezone_offset is null and active_birth_provenance is null)::text from public.profiles where id='${userId}'`), "true", mutation);
|
||||
}
|
||||
fixture.psql(`update public.profiles set birth_date='2000-06-16' where id='${userId}'`);
|
||||
assert.equal(fixture.psql(`select (active_birth_date is null and active_birth_timezone_offset is null and active_birth_provenance is null)::text from public.profiles where id='${userId}'`), "true");
|
||||
} finally {
|
||||
await closeLocalPostgresDataPool(url);
|
||||
fixture.stop();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
+5097
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,75 @@
|
||||
// BUG-1181: the dated candidate-window contract belongs to scoring generation 9 and
|
||||
// every later one. The bump to scoring-10 (functional benefic / malefic profile v2)
|
||||
// must not turn new results into legacy same-day results anywhere in the stack.
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync, readdirSync } from "node:fs";
|
||||
import test from "node:test";
|
||||
|
||||
import { FIRST_DATED_SCORING_GENERATION, isDatedScoringAlgorithmVersion } from "../src/lib/rectification-agentic/core/candidate-window.ts";
|
||||
import { v9EngineVersion } from "../src/lib/rectification-agentic/v9/engine-client.ts";
|
||||
import { resultIdentityView } from "../src/lib/rectification-agentic/v9/result-identity.ts";
|
||||
import { parseV9CaseDossier } from "../src/lib/rectification-agentic/v9/tool-service.ts";
|
||||
import { dossierFixture } from "./rectification-v9-test-support.ts";
|
||||
|
||||
test("dated contract is a generation threshold, not one literal", () => {
|
||||
assert.equal(FIRST_DATED_SCORING_GENERATION, 9);
|
||||
for (const version of ["rectification-v5-matrix-scoring-9", "rectification-v5-matrix-scoring-10", "rectification-v5-matrix-scoring-11", "rectification-v5-matrix-scoring-100"]) {
|
||||
assert.equal(isDatedScoringAlgorithmVersion(version), true, version);
|
||||
}
|
||||
for (const version of ["rectification-v5-matrix-scoring-8", "rectification-v5-matrix-scoring-1", "rectification-v5-matrix-scoring-09",
|
||||
"rectification-v5", "rectification-v5-matrix-scoring-10 ", "x-rectification-v5-matrix-scoring-10", "", null, undefined, 10]) {
|
||||
assert.equal(isDatedScoringAlgorithmVersion(version), false, String(version));
|
||||
}
|
||||
});
|
||||
|
||||
test("receipt default and Python identity agree on scoring-10", (t) => {
|
||||
const saved = process.env.RECTIFICATION_ENGINE_VERSION;
|
||||
delete process.env.RECTIFICATION_ENGINE_VERSION;
|
||||
t.after(() => { if (saved === undefined) delete process.env.RECTIFICATION_ENGINE_VERSION; else process.env.RECTIFICATION_ENGINE_VERSION = saved; });
|
||||
assert.equal(v9EngineVersion(), "rectification-v5-matrix-scoring-10");
|
||||
const python = readFileSync(new URL("../../scripts/rectification/scoring_service.py", import.meta.url), "utf8");
|
||||
assert.match(python, /^ALGORITHM_VERSION = "rectification-v5-matrix-scoring-10"$/m);
|
||||
});
|
||||
|
||||
test("no source file compares the algorithm identity with a scoring-N literal", () => {
|
||||
const roots = ["../src/lib/", "../src/mastra/", "../src/app/"];
|
||||
const hits: string[] = [];
|
||||
const walk = (url: URL) => {
|
||||
for (const entry of readdirSync(url, { withFileTypes: true })) {
|
||||
const child = new URL(entry.name + (entry.isDirectory() ? "/" : ""), url);
|
||||
if (entry.isDirectory()) walk(child);
|
||||
else if (/\.(ts|tsx)$/.test(entry.name)) {
|
||||
const text = readFileSync(child, "utf8");
|
||||
for (const line of text.split("\n")) if (/[!=]==?\s*"rectification-v5-matrix-scoring-\d+"/.test(line)) hits.push(`${child.pathname}: ${line.trim()}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
for (const root of roots) walk(new URL(root, import.meta.url));
|
||||
assert.deepEqual(hits, []);
|
||||
});
|
||||
|
||||
test("SQL guard compares the generation too (migration 20261002010000)", () => {
|
||||
const sql = readFileSync(new URL("../supabase/migrations/20261002010000_rectification_dated_algorithm_generation.sql", import.meta.url), "utf8");
|
||||
assert.match(sql, /create or replace function public\.validate_dated_rectification_candidate\(/);
|
||||
assert.match(sql, /coalesce\(p_result\.algorithm_version, ''\) ~ '\^rectification-v5-matrix-scoring-\(9\|\[1-9\]\[0-9\]\+\)\$'/);
|
||||
assert.doesNotMatch(sql, /algorithm_version = 'rectification-v5-matrix-scoring-9'/);
|
||||
// Only the function body changes: no table, column, grant or data statements.
|
||||
assert.doesNotMatch(sql, /^\s*(alter|drop|insert|update|delete|grant|revoke|create table|create index)\b/im);
|
||||
});
|
||||
|
||||
test("a scoring-9 history opens read-only under scoring-10 and offers a recompare (BUG-621 / BUG-984 pattern)", () => {
|
||||
// Real native scoring-9 dated golden as the persisted latest result; only the live identity differs.
|
||||
const historical = JSON.parse(readFileSync(new URL("./fixtures/rectification-midnight-date-anchor.delivery.native.json", import.meta.url), "utf8")).response;
|
||||
assert.equal(historical.algorithm_version, "rectification-v5-matrix-scoring-9");
|
||||
const latest = { ...historical, candidates: historical.candidate_decisions };
|
||||
const dossier = parseV9CaseDossier(dossierFixture({ stage: "minute", latestResult: latest }));
|
||||
assert.ok(dossier);
|
||||
assert.equal(dossier.latestResult?.algorithmVersion, "rectification-v5-matrix-scoring-9", "history keeps its own identity");
|
||||
const policyVersion = historical.decision_policy_version;
|
||||
const underTen = resultIdentityView(dossier, { algorithmVersion: "rectification-v5-matrix-scoring-10", policyVersion });
|
||||
assert.deepEqual([underTen.read_only, underTen.can_recompare, underTen.algorithm_version], [true, true, "rectification-v5-matrix-scoring-9"]);
|
||||
const underNine = resultIdentityView(dossier, { algorithmVersion: "rectification-v5-matrix-scoring-9", policyVersion });
|
||||
assert.deepEqual([underNine.read_only, underNine.can_recompare], [false, false]);
|
||||
// Its candidates still parse as dated (generation >= 9), so the opened history keeps civil dates.
|
||||
assert.ok(dossier.latestResult!.candidates.every((candidate) => typeof candidate.candidate_date === "string"));
|
||||
});
|
||||
@@ -31,10 +31,18 @@ const golden = JSON.parse(readFileSync(new URL(
|
||||
// Historical golden identity stays fixed; it must not be relabeled as the live engine.
|
||||
const CURRENT = "rectification-v5-matrix-scoring-8";
|
||||
const PREVIOUS = "rectification-v5-matrix-scoring-7";
|
||||
const LIVE_CURRENT = "rectification-v5-matrix-scoring-9";
|
||||
// 原值: LIVE_CURRENT = "rectification-v5-matrix-scoring-9"(liveGolden 同时充当「当前版本」)
|
||||
// 新值: LIVE_CURRENT = "...-scoring-10";scoring-9 的 dated golden 留作历史(DATED_HISTORICAL),
|
||||
// 当前版本另有真实引擎生成的 scoring-10 dated golden(currentGolden)
|
||||
// 原因: 功能吉凶 v2 改变同输入分数,按「打分语义变化必须 bump」升算法身份(BUG-1181)
|
||||
const LIVE_CURRENT = "rectification-v5-matrix-scoring-10";
|
||||
const DATED_HISTORICAL = "rectification-v5-matrix-scoring-9";
|
||||
const liveGolden = JSON.parse(readFileSync(new URL(
|
||||
"./fixtures/rectification-midnight-date-anchor.delivery.native.json", import.meta.url,
|
||||
), "utf8"));
|
||||
const currentGolden = JSON.parse(readFileSync(new URL(
|
||||
"./fixtures/rectification-midnight-date-anchor.delivery.scoring-10.native.json", import.meta.url,
|
||||
), "utf8"));
|
||||
const envKeys = [
|
||||
"RECTIFICATION_ENGINE_VERSION", "RECTIFICATION_ALGORITHM_VERSION",
|
||||
"RECTIFICATION_DECISION_POLICY_VERSION",
|
||||
@@ -61,15 +69,18 @@ test("receipt default matches the cross-midnight native scoring version without
|
||||
assert.equal(golden.score.algorithm_version, CURRENT);
|
||||
assert.equal(golden.versions.algorithm_version, CURRENT);
|
||||
const python = readFileSync(new URL("../../scripts/rectification/scoring_service.py", import.meta.url), "utf8");
|
||||
assert.match(python, /ALGORITHM_VERSION = "rectification-v5-matrix-scoring-9"/);
|
||||
assert.equal(liveGolden.response.algorithm_version, LIVE_CURRENT);
|
||||
assert.match(python, /ALGORITHM_VERSION = "rectification-v5-matrix-scoring-10"/);
|
||||
assert.equal(liveGolden.response.algorithm_version, DATED_HISTORICAL);
|
||||
assert.equal(currentGolden.response.algorithm_version, LIVE_CURRENT);
|
||||
const fingerprints = { evidenceLedgerFingerprint: "e".repeat(64), candidateRangeFingerprint: "c".repeat(64) };
|
||||
const live = {
|
||||
algorithmVersion: liveGolden.response.algorithm_version,
|
||||
policyVersion: liveGolden.response.decision_policy_version,
|
||||
algorithmVersion: currentGolden.response.algorithm_version,
|
||||
policyVersion: currentGolden.response.decision_policy_version,
|
||||
};
|
||||
const historical = { ...fingerprints, algorithmVersion: CURRENT, policyVersion: golden.versions.decision_policy_version };
|
||||
assert.equal(cachedEngineScoreIsReusable(historical, fingerprints, live), false);
|
||||
// BUG-1181: a scoring-9 cache (old functional grouping) is not current under scoring-10.
|
||||
assert.equal(cachedEngineScoreIsReusable({ ...historical, algorithmVersion: DATED_HISTORICAL }, fingerprints, live), false);
|
||||
assert.equal(cachedEngineScoreIsReusable({ ...historical, algorithmVersion: LIVE_CURRENT }, fingerprints, live), true);
|
||||
assert.equal(historical.algorithmVersion, CURRENT, "checking live identity never relabels history");
|
||||
// A receipt default must not become an environment override for cache identity.
|
||||
|
||||
@@ -97,8 +97,10 @@ for (const option of ["A", "B", "C", "skip_probe"] as const) test(`D1 initial no
|
||||
assert.equal(midnightSideChoice(current.case.candidate_range), null);
|
||||
});
|
||||
|
||||
test("native golden crosses engine parsing, inference and dated delivery without reanchoring", async () => {
|
||||
const golden = JSON.parse(readFileSync(new URL("./fixtures/rectification-midnight-date-anchor.delivery.native.json", import.meta.url), "utf8"));
|
||||
// BUG-1181: the scoring-10 golden (real engine, functional profile v2) must parse as dated too;
|
||||
// a literal "=== scoring-9" check would have turned it into a legacy same-day result.
|
||||
for (const fixture of ["rectification-midnight-date-anchor.delivery.native.json", "rectification-midnight-date-anchor.delivery.scoring-10.native.json"]) test(`native golden crosses engine parsing, inference and dated delivery without reanchoring (${fixture})`, async () => {
|
||||
const golden = JSON.parse(readFileSync(new URL(`./fixtures/${fixture}`, import.meta.url), "utf8"));
|
||||
const originalFetch = globalThis.fetch;
|
||||
globalThis.fetch = (async () => new Response(JSON.stringify(golden.response), { status: 200 })) as typeof fetch;
|
||||
try {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"dataset_path": "references/real_case_calibration/minute_rectification_holdout_v3.json",
|
||||
"report_path": "references/real_case_calibration/minute_rectification_holdout_v3_report.json",
|
||||
"source_audit_status": "corrected_known_date_errors",
|
||||
"evaluated_on": "2026-09-29",
|
||||
"evaluated_on": "2026-10-02",
|
||||
"evaluated_on_scope": "latest_fixed_protocol_rerun_not_historical_runtime_metrics",
|
||||
"historical_source_audit_status": "invalidated_after_replay",
|
||||
"report_status": "invalidated_after_source_audit",
|
||||
@@ -34,6 +34,7 @@
|
||||
"scripts/dasha_analyzer.py",
|
||||
"scripts/divisional_charts_extended.py",
|
||||
"scripts/domain_calculation_service.py",
|
||||
"scripts/functional_benefics.py",
|
||||
"scripts/jaimini.py",
|
||||
"scripts/minute_rectification_fact_ranker_v4.py",
|
||||
"scripts/minute_rectification_feature_facts_v4.py",
|
||||
@@ -51,7 +52,7 @@
|
||||
"scripts/shadbala.py",
|
||||
"scripts/varga.py"
|
||||
],
|
||||
"production_scoring_sha256": "8320162e860e83a78834dbecc016d9d7d507981245e21a0336ec4342bb4a284b",
|
||||
"production_scoring_sha256": "01f2d36e715801242c9bf657d70a017a77b46761a100ceeb9fd8369cd39f2c0e",
|
||||
"research_files": [
|
||||
"scripts/research/reported_offset_sweep.py",
|
||||
"scripts/research/cluster_width_lib.py",
|
||||
@@ -61,7 +62,7 @@
|
||||
"scripts/minute_rectification_fact_blind_eval_v4.py",
|
||||
"scripts/minute_rectification_holdout_validator.py"
|
||||
],
|
||||
"research_implementation_sha256": "349564fc80be0f48e58a6fe4390d0d6cb564cca4f973870af44454a735d2c135",
|
||||
"research_implementation_sha256": "a2d555508e2a4063fffdabc14463da546e2cef090c8e2bbd4ecff288942e9e95",
|
||||
"file_sha256": {
|
||||
"scripts/active_rectification_event_engine.py": "cdc0e68edc770a2a1810fbdb68cbfd46dcd50b267c739c496fcc078c5e26b5b4",
|
||||
"scripts/active_rectification_events.py": "03e333ccf1103caf685dfe50fe890ab1793e945037085f50ce834a4a3b232222",
|
||||
@@ -69,6 +70,7 @@
|
||||
"scripts/dasha_analyzer.py": "5e53b1b4d4c7414c08dd0e7716f120a63c70ec3428ec93547f64d55c580da0e1",
|
||||
"scripts/divisional_charts_extended.py": "73bd50a83ac444830940184d0988cea621855f91db76a3f1a232014b992eacea",
|
||||
"scripts/domain_calculation_service.py": "9ee955874eea806c7b56f4246d90009c02ee8318b8f3dfe1d7132b1c0b4262e1",
|
||||
"scripts/functional_benefics.py": "cbaac3b8c09b97f8724b5300e9a402cbf77089af6c7db8788550d40fd35ac57b",
|
||||
"scripts/jaimini.py": "b98bf965603dd2e3cc871fe40f3c8184731a701875ca50fef3ca68e9682eda81",
|
||||
"scripts/minute_rectification_blind_eval.py": "07aa30d8bad3278669495d5fea8be937aaf6367c8af980ff4f2fe9aa84ccc6ff",
|
||||
"scripts/minute_rectification_fact_blind_eval_v4.py": "bdf460e3467208e8b87345c5beb2128f3e22de7eeffd68f72b281b3ad9affc92",
|
||||
@@ -85,11 +87,11 @@
|
||||
"scripts/rectification/decision_policy.py": "d845896428e0f49f8b5ae946aff6203492e7383d387acf122cb0b7a523b0af28",
|
||||
"scripts/rectification/event_probes.py": "9bbadc246e6b8e94bb047522c3e5645613f508b3473ef40b38a207c77fdad58c",
|
||||
"scripts/rectification/refinement_packet.py": "dbeea5aa780889785ce850f3881e8b7f67bb44594e9bc382c65b2e730884a2f4",
|
||||
"scripts/rectification/scoring_service.py": "4940f47c5fcc0843b3f79692c1044cc871e738a866aa8cb96a4757998afa3921",
|
||||
"scripts/rectification/scoring_service.py": "4f13c6a78d2dda55454ac20e4091fce280e3626ecfe8a9d723217ef3ebc05d02",
|
||||
"scripts/research/cluster_width_lib.py": "1d8f2ffa7795d62069deebb2de8e16749317037d4ed3f24a2c0092676e5cfcc6",
|
||||
"scripts/research/probe_supply_after_six.py": "098a5b4398d6f8d996917d809c2fc922ad64031d3b70660f8ef7c876aba92438",
|
||||
"scripts/research/reported_offset_sweep.py": "4d0f1f331046516c7f365eaa7bf70c8428d5e30b8841dc717dfa7df6a5a7d438",
|
||||
"scripts/research/sealed_holdout_rerun.py": "c3a5d0827d86e59a5cc82224e244ad109f35711a41c2ba30bc1edea7bdc4624f",
|
||||
"scripts/research/reported_offset_sweep.py": "f2acca1c5d5307b013e098cc28c803348bf9207d318a27733fb7735b9640dd7f",
|
||||
"scripts/research/sealed_holdout_rerun.py": "f49eae74e27ecf1c417b3a6423eeb473ce8c8c565a5b7c8768ddb407659e3592",
|
||||
"scripts/shadbala.py": "912e0e6d169c2172aab85f71e4347e3e39193020777b43825b775d906400956b",
|
||||
"scripts/varga.py": "4331de5a25ea08729af91aae863943c4223183937f419d52dc63fd6fe7f27be6"
|
||||
},
|
||||
@@ -98,7 +100,7 @@
|
||||
"matches_metrics_scorer": false,
|
||||
"official_eval_implementation_hash_matches": false,
|
||||
"official_eval_trial_count": 0,
|
||||
"source_report": "docs/research/sealed_holdout_rerun_quality_wording_2026_09_29.json",
|
||||
"source_report": "docs/research/sealed_holdout_rerun_functional_v2_2026_10_02.json",
|
||||
"fixed_protocol_rerun_trial_count": 20,
|
||||
"fixed_protocol_rerun_hash_matches": true,
|
||||
"metrics": {
|
||||
@@ -111,6 +113,101 @@
|
||||
}
|
||||
},
|
||||
"current_tree_fixed_protocol_rerun": {
|
||||
"evaluated_on": "2026-10-02",
|
||||
"report_path": "docs/research/sealed_holdout_rerun_functional_v2_2026_10_02.json",
|
||||
"freeze_record_path": "docs/research/sealed_holdout_rerun_functional_v2_2026_10_02.freeze.json",
|
||||
"implementation_sha256": "c913c6f061458fb682f6d520ae08b2d64d6f6cee20ccd1abd7e6c43d5a41685d",
|
||||
"extended_identity": {
|
||||
"historical_artifacts_manifest_sha256": "6102a26a840be207b5858b3a4c0509274468ae9071e86d308cbbac7371d6864e",
|
||||
"production_scoring_files": [
|
||||
"scripts/active_rectification_event_engine.py",
|
||||
"scripts/active_rectification_events.py",
|
||||
"scripts/ashtakavarga.py",
|
||||
"scripts/dasha_analyzer.py",
|
||||
"scripts/divisional_charts_extended.py",
|
||||
"scripts/domain_calculation_service.py",
|
||||
"scripts/functional_benefics.py",
|
||||
"scripts/jaimini.py",
|
||||
"scripts/minute_rectification_fact_ranker_v4.py",
|
||||
"scripts/minute_rectification_feature_facts_v4.py",
|
||||
"scripts/narayana_dasha.py",
|
||||
"scripts/rectification/api_service.py",
|
||||
"scripts/rectification/candidate_contrast.py",
|
||||
"scripts/rectification/candidate_window.py",
|
||||
"scripts/rectification/case_holdout.py",
|
||||
"scripts/rectification/contracts.py",
|
||||
"scripts/rectification/dasha_transition_proximity.py",
|
||||
"scripts/rectification/decision_policy.py",
|
||||
"scripts/rectification/event_probes.py",
|
||||
"scripts/rectification/refinement_packet.py",
|
||||
"scripts/rectification/scoring_service.py",
|
||||
"scripts/shadbala.py",
|
||||
"scripts/varga.py"
|
||||
],
|
||||
"production_scoring_sha256": "01f2d36e715801242c9bf657d70a017a77b46761a100ceeb9fd8369cd39f2c0e",
|
||||
"research_files": [
|
||||
"scripts/research/reported_offset_sweep.py",
|
||||
"scripts/research/cluster_width_lib.py",
|
||||
"scripts/research/probe_supply_after_six.py",
|
||||
"scripts/research/sealed_holdout_rerun.py",
|
||||
"scripts/minute_rectification_blind_eval.py",
|
||||
"scripts/minute_rectification_fact_blind_eval_v4.py",
|
||||
"scripts/minute_rectification_holdout_validator.py"
|
||||
],
|
||||
"research_implementation_sha256": "a2d555508e2a4063fffdabc14463da546e2cef090c8e2bbd4ecff288942e9e95",
|
||||
"file_sha256": {
|
||||
"scripts/active_rectification_event_engine.py": "cdc0e68edc770a2a1810fbdb68cbfd46dcd50b267c739c496fcc078c5e26b5b4",
|
||||
"scripts/active_rectification_events.py": "03e333ccf1103caf685dfe50fe890ab1793e945037085f50ce834a4a3b232222",
|
||||
"scripts/ashtakavarga.py": "cc32776674cf60713634a360a6f09774b3af0ec5d0f650687f52b79597b0dfbe",
|
||||
"scripts/dasha_analyzer.py": "5e53b1b4d4c7414c08dd0e7716f120a63c70ec3428ec93547f64d55c580da0e1",
|
||||
"scripts/divisional_charts_extended.py": "73bd50a83ac444830940184d0988cea621855f91db76a3f1a232014b992eacea",
|
||||
"scripts/domain_calculation_service.py": "9ee955874eea806c7b56f4246d90009c02ee8318b8f3dfe1d7132b1c0b4262e1",
|
||||
"scripts/functional_benefics.py": "cbaac3b8c09b97f8724b5300e9a402cbf77089af6c7db8788550d40fd35ac57b",
|
||||
"scripts/jaimini.py": "b98bf965603dd2e3cc871fe40f3c8184731a701875ca50fef3ca68e9682eda81",
|
||||
"scripts/minute_rectification_blind_eval.py": "07aa30d8bad3278669495d5fea8be937aaf6367c8af980ff4f2fe9aa84ccc6ff",
|
||||
"scripts/minute_rectification_fact_blind_eval_v4.py": "bdf460e3467208e8b87345c5beb2128f3e22de7eeffd68f72b281b3ad9affc92",
|
||||
"scripts/minute_rectification_fact_ranker_v4.py": "f1a0d8d2482cd754d2e7f253a9606b0373519435a2bf58cfc3753e2b9ae0fb76",
|
||||
"scripts/minute_rectification_feature_facts_v4.py": "3d899a2cdd4825b8e32062443d487edcd2173a4ea55a36eb9f3abe587c0faf0f",
|
||||
"scripts/minute_rectification_holdout_validator.py": "b60b1c752e58672beaee8b36eb3b2348169726cda070ec969db0f13e7ed715af",
|
||||
"scripts/narayana_dasha.py": "7ff2c3238cd113b11b815e14b41967bd8e486ff62e36650e55613b9c79d1bfe3",
|
||||
"scripts/rectification/api_service.py": "e316ced0f3796d0378a0fe1aad950ee25922ae8afd53add578ed59ca8b2f0f79",
|
||||
"scripts/rectification/candidate_contrast.py": "eee7da71c0574a08876404b78ca111153fa95fb83ace82b9fdca141d1992e273",
|
||||
"scripts/rectification/candidate_window.py": "2fbc5058b12049b15fca375cdc125b8283e19f9f3e4bedcc291e344501891bef",
|
||||
"scripts/rectification/case_holdout.py": "fe0e699b617d9e216acdfeff87af4221c1d6f4c101bf33e1dbf14e2bcd75a8b5",
|
||||
"scripts/rectification/contracts.py": "c6dc6bd230e38f9f2126c224aae9ddbd6415304c15340f8c7cd3f06f6ef3160f",
|
||||
"scripts/rectification/dasha_transition_proximity.py": "0afba494aa12899621173c3cc941c6c1d0be9cec0bdf4c4a1c9bcd004ab22de8",
|
||||
"scripts/rectification/decision_policy.py": "d845896428e0f49f8b5ae946aff6203492e7383d387acf122cb0b7a523b0af28",
|
||||
"scripts/rectification/event_probes.py": "9bbadc246e6b8e94bb047522c3e5645613f508b3473ef40b38a207c77fdad58c",
|
||||
"scripts/rectification/refinement_packet.py": "dbeea5aa780889785ce850f3881e8b7f67bb44594e9bc382c65b2e730884a2f4",
|
||||
"scripts/rectification/scoring_service.py": "4f13c6a78d2dda55454ac20e4091fce280e3626ecfe8a9d723217ef3ebc05d02",
|
||||
"scripts/research/cluster_width_lib.py": "1d8f2ffa7795d62069deebb2de8e16749317037d4ed3f24a2c0092676e5cfcc6",
|
||||
"scripts/research/probe_supply_after_six.py": "098a5b4398d6f8d996917d809c2fc922ad64031d3b70660f8ef7c876aba92438",
|
||||
"scripts/research/reported_offset_sweep.py": "f2acca1c5d5307b013e098cc28c803348bf9207d318a27733fb7735b9640dd7f",
|
||||
"scripts/research/sealed_holdout_rerun.py": "f49eae74e27ecf1c417b3a6423eeb473ce8c8c565a5b7c8768ddb407659e3592",
|
||||
"scripts/shadbala.py": "912e0e6d169c2172aab85f71e4347e3e39193020777b43825b775d906400956b",
|
||||
"scripts/varga.py": "4331de5a25ea08729af91aae863943c4223183937f419d52dc63fd6fe7f27be6"
|
||||
},
|
||||
"hash_scope": "explicit_identity_file_sets_not_a_transitive_dependency_lock"
|
||||
},
|
||||
"scorer_frozen_before_rerun": true,
|
||||
"source_audit_status": "corrected_known_date_errors",
|
||||
"trial_count": 20,
|
||||
"official_valid_independent_blind": false,
|
||||
"is_blind_evaluation": false,
|
||||
"truth_hidden_from_ranker": true,
|
||||
"results_previously_seen": true,
|
||||
"must_not_claim_as_release_metrics": true,
|
||||
"must_not_use_for_tuning": true,
|
||||
"verified_minute_claim_allowed": false,
|
||||
"metric_gates_passed": false,
|
||||
"events_per_case": 3,
|
||||
"boundary": "Three-event low-information protocol, not a mathematical accuracy lower bound and not representative of real sessions. Historical v3/v4 exposure cannot be undone by freezing today's scorer. No tuning or release claims.",
|
||||
"report_sha256": "0138a730eff4fba1325689adfdb37427ed006eb1ee60994431749f4b615dda0c",
|
||||
"freeze_record_sha256": "2c802655428b209fe027e2d3632e845b937478ecdc0709b59cbbd72724cea33d",
|
||||
"replay_started_at_utc": "2026-10-02T04:23:10.353143+00:00",
|
||||
"replay_finished_at_utc": "2026-10-02T04:23:13.490679+00:00"
|
||||
},
|
||||
"previous_fixed_protocol_rerun": {
|
||||
"evaluated_on": "2026-09-29",
|
||||
"report_path": "docs/research/sealed_holdout_rerun_quality_wording_2026_09_29.json",
|
||||
"freeze_record_path": "docs/research/sealed_holdout_rerun_quality_wording_2026_09_29.freeze.json",
|
||||
@@ -197,108 +294,15 @@
|
||||
"verified_minute_claim_allowed": false,
|
||||
"metric_gates_passed": false,
|
||||
"events_per_case": 3,
|
||||
"boundary": "Three-event low-information protocol, not a mathematical accuracy lower bound and not representative of real sessions. Historical v3/v4 exposure cannot be undone by freezing today's scorer. No tuning or release claims.",
|
||||
"boundary": "Previously exposed v3 shadow fixed-protocol rerun after the BUG-1088 wording re-freeze. Superseded by the 2026-10-02 functional profile v2 re-freeze (BUG-1181: ALGORITHM_VERSION scoring-10, scripts/functional_benefics.py added to the production identity); shadow trials identical; report and freeze preserved byte-for-byte.",
|
||||
"report_sha256": "a82e5cde947a7cc4eb6adb70c17cce02c4dd9348966b03decedf78b804f49dd0",
|
||||
"freeze_record_sha256": "d4ce155223e186efa6f0e60103e2ab6e0c9bfbb196fc0e016f1212e1730ac343",
|
||||
"replay_started_at_utc": "2026-09-29T00:45:30.638089+00:00",
|
||||
"replay_finished_at_utc": "2026-09-29T00:45:32.743041+00:00"
|
||||
},
|
||||
"previous_fixed_protocol_rerun": {
|
||||
"evaluated_on": "2026-09-20",
|
||||
"report_path": "docs/research/sealed_holdout_rerun_midnight_anchor_2026_09_21.json",
|
||||
"freeze_record_path": "docs/research/sealed_holdout_rerun_midnight_anchor_2026_09_21.freeze.json",
|
||||
"implementation_sha256": "c913c6f061458fb682f6d520ae08b2d64d6f6cee20ccd1abd7e6c43d5a41685d",
|
||||
"extended_identity": {
|
||||
"historical_artifacts_manifest_sha256": "6102a26a840be207b5858b3a4c0509274468ae9071e86d308cbbac7371d6864e",
|
||||
"production_scoring_files": [
|
||||
"scripts/active_rectification_event_engine.py",
|
||||
"scripts/active_rectification_events.py",
|
||||
"scripts/ashtakavarga.py",
|
||||
"scripts/dasha_analyzer.py",
|
||||
"scripts/divisional_charts_extended.py",
|
||||
"scripts/domain_calculation_service.py",
|
||||
"scripts/jaimini.py",
|
||||
"scripts/minute_rectification_fact_ranker_v4.py",
|
||||
"scripts/minute_rectification_feature_facts_v4.py",
|
||||
"scripts/narayana_dasha.py",
|
||||
"scripts/rectification/api_service.py",
|
||||
"scripts/rectification/candidate_contrast.py",
|
||||
"scripts/rectification/candidate_window.py",
|
||||
"scripts/rectification/case_holdout.py",
|
||||
"scripts/rectification/contracts.py",
|
||||
"scripts/rectification/dasha_transition_proximity.py",
|
||||
"scripts/rectification/decision_policy.py",
|
||||
"scripts/rectification/event_probes.py",
|
||||
"scripts/rectification/refinement_packet.py",
|
||||
"scripts/rectification/scoring_service.py",
|
||||
"scripts/shadbala.py",
|
||||
"scripts/varga.py"
|
||||
],
|
||||
"production_scoring_sha256": "102f3bce580ebf917f36724722ebc841de88a119c4787b8ea5e9e21339261768",
|
||||
"research_files": [
|
||||
"scripts/research/reported_offset_sweep.py",
|
||||
"scripts/research/cluster_width_lib.py",
|
||||
"scripts/research/probe_supply_after_six.py",
|
||||
"scripts/research/sealed_holdout_rerun.py",
|
||||
"scripts/minute_rectification_blind_eval.py",
|
||||
"scripts/minute_rectification_fact_blind_eval_v4.py",
|
||||
"scripts/minute_rectification_holdout_validator.py"
|
||||
],
|
||||
"research_implementation_sha256": "f6c06b348a809f7316351914a92157485ff5e42dc5691873dbf58864b0f31d13",
|
||||
"file_sha256": {
|
||||
"scripts/active_rectification_event_engine.py": "cdc0e68edc770a2a1810fbdb68cbfd46dcd50b267c739c496fcc078c5e26b5b4",
|
||||
"scripts/active_rectification_events.py": "03e333ccf1103caf685dfe50fe890ab1793e945037085f50ce834a4a3b232222",
|
||||
"scripts/ashtakavarga.py": "cc32776674cf60713634a360a6f09774b3af0ec5d0f650687f52b79597b0dfbe",
|
||||
"scripts/dasha_analyzer.py": "5e53b1b4d4c7414c08dd0e7716f120a63c70ec3428ec93547f64d55c580da0e1",
|
||||
"scripts/divisional_charts_extended.py": "73bd50a83ac444830940184d0988cea621855f91db76a3f1a232014b992eacea",
|
||||
"scripts/domain_calculation_service.py": "9ee955874eea806c7b56f4246d90009c02ee8318b8f3dfe1d7132b1c0b4262e1",
|
||||
"scripts/jaimini.py": "b98bf965603dd2e3cc871fe40f3c8184731a701875ca50fef3ca68e9682eda81",
|
||||
"scripts/minute_rectification_blind_eval.py": "07aa30d8bad3278669495d5fea8be937aaf6367c8af980ff4f2fe9aa84ccc6ff",
|
||||
"scripts/minute_rectification_fact_blind_eval_v4.py": "bdf460e3467208e8b87345c5beb2128f3e22de7eeffd68f72b281b3ad9affc92",
|
||||
"scripts/minute_rectification_fact_ranker_v4.py": "f1a0d8d2482cd754d2e7f253a9606b0373519435a2bf58cfc3753e2b9ae0fb76",
|
||||
"scripts/minute_rectification_feature_facts_v4.py": "3d899a2cdd4825b8e32062443d487edcd2173a4ea55a36eb9f3abe587c0faf0f",
|
||||
"scripts/minute_rectification_holdout_validator.py": "b60b1c752e58672beaee8b36eb3b2348169726cda070ec969db0f13e7ed715af",
|
||||
"scripts/narayana_dasha.py": "7ff2c3238cd113b11b815e14b41967bd8e486ff62e36650e55613b9c79d1bfe3",
|
||||
"scripts/rectification/api_service.py": "e316ced0f3796d0378a0fe1aad950ee25922ae8afd53add578ed59ca8b2f0f79",
|
||||
"scripts/rectification/candidate_contrast.py": "eee7da71c0574a08876404b78ca111153fa95fb83ace82b9fdca141d1992e273",
|
||||
"scripts/rectification/candidate_window.py": "2fbc5058b12049b15fca375cdc125b8283e19f9f3e4bedcc291e344501891bef",
|
||||
"scripts/rectification/case_holdout.py": "fe0e699b617d9e216acdfeff87af4221c1d6f4c101bf33e1dbf14e2bcd75a8b5",
|
||||
"scripts/rectification/contracts.py": "c6dc6bd230e38f9f2126c224aae9ddbd6415304c15340f8c7cd3f06f6ef3160f",
|
||||
"scripts/rectification/dasha_transition_proximity.py": "0afba494aa12899621173c3cc941c6c1d0be9cec0bdf4c4a1c9bcd004ab22de8",
|
||||
"scripts/rectification/decision_policy.py": "d845896428e0f49f8b5ae946aff6203492e7383d387acf122cb0b7a523b0af28",
|
||||
"scripts/rectification/event_probes.py": "45478ee3fdc36dc36e1a602bee5dd0627a5464275e370e64adb5826fe2aa58f5",
|
||||
"scripts/rectification/refinement_packet.py": "dbeea5aa780889785ce850f3881e8b7f67bb44594e9bc382c65b2e730884a2f4",
|
||||
"scripts/rectification/scoring_service.py": "4940f47c5fcc0843b3f79692c1044cc871e738a866aa8cb96a4757998afa3921",
|
||||
"scripts/research/cluster_width_lib.py": "1d8f2ffa7795d62069deebb2de8e16749317037d4ed3f24a2c0092676e5cfcc6",
|
||||
"scripts/research/probe_supply_after_six.py": "098a5b4398d6f8d996917d809c2fc922ad64031d3b70660f8ef7c876aba92438",
|
||||
"scripts/research/reported_offset_sweep.py": "4898c605b745cba5c67311149fdfe0e2e1af7c620a41a172e746be55b19a84b3",
|
||||
"scripts/research/sealed_holdout_rerun.py": "5d26d782648bbef42b5dcfe603ef2cbe697b317df6000f7c9c3fa0272504b027",
|
||||
"scripts/shadbala.py": "912e0e6d169c2172aab85f71e4347e3e39193020777b43825b775d906400956b",
|
||||
"scripts/varga.py": "4331de5a25ea08729af91aae863943c4223183937f419d52dc63fd6fe7f27be6"
|
||||
},
|
||||
"hash_scope": "explicit_identity_file_sets_not_a_transitive_dependency_lock"
|
||||
},
|
||||
"scorer_frozen_before_rerun": true,
|
||||
"source_audit_status": "corrected_known_date_errors",
|
||||
"trial_count": 20,
|
||||
"official_valid_independent_blind": false,
|
||||
"is_blind_evaluation": false,
|
||||
"truth_hidden_from_ranker": true,
|
||||
"results_previously_seen": true,
|
||||
"must_not_claim_as_release_metrics": true,
|
||||
"must_not_use_for_tuning": true,
|
||||
"verified_minute_claim_allowed": false,
|
||||
"metric_gates_passed": false,
|
||||
"events_per_case": 3,
|
||||
"boundary": "Previously exposed v3 shadow fixed-protocol rerun after BUG-981 midnight date anchor. Superseded by the 2026-09-29 BUG-1088 wording re-freeze; report and freeze preserved byte-for-byte.",
|
||||
"report_sha256": "05458f29215d9784623f1b05f09ef590915caf46a87947f0af31dcae85808620",
|
||||
"freeze_record_sha256": "9b9bb4b9093a9987e84f04f50b3291ceca23691f89b1d5800c81652aec13824e",
|
||||
"replay_started_at_utc": "2026-09-20T17:01:53.362316+00:00",
|
||||
"replay_finished_at_utc": "2026-09-20T17:01:56.147759+00:00",
|
||||
"replay_finished_at_utc": "2026-09-29T00:45:32.743041+00:00",
|
||||
"previous_fixed_protocol_rerun": {
|
||||
"report_path": "docs/research/sealed_holdout_rerun_cross_midnight_2026_09_20.json",
|
||||
"freeze_record_path": "docs/research/sealed_holdout_rerun_cross_midnight_2026_09_20.final.freeze.json",
|
||||
"superseded_reason": "New production identity (BUG-981 midnight date anchor); prior report and freeze preserved byte-for-byte."
|
||||
"report_path": "docs/research/sealed_holdout_rerun_midnight_anchor_2026_09_21.json",
|
||||
"freeze_record_path": "docs/research/sealed_holdout_rerun_midnight_anchor_2026_09_21.freeze.json",
|
||||
"superseded_reason": "BUG-1088 wording-only re-freeze of event_probes.py; prior report and freeze preserved byte-for-byte."
|
||||
}
|
||||
},
|
||||
"current_tree_unfrozen_diagnostic": {
|
||||
@@ -319,10 +323,10 @@
|
||||
"verified_minute_claim_allowed": false
|
||||
},
|
||||
"current_tree_reported_offset_replay": {
|
||||
"report_path": "docs/research/reported_offset_quality_wording_2026_09_29.json",
|
||||
"report_sha256": "45f3c2afdcd4d59b59d01a42e872318c125bafad162c578ed2808d43e5b58aca",
|
||||
"freeze_record_path": "docs/research/reported_offset_quality_wording_2026_09_29.freeze.json",
|
||||
"freeze_record_sha256": "7f6d015545b655d8e6b5e96d979c032cedbff904757fa3a89e996710e3fa21a2",
|
||||
"report_path": "docs/research/reported_offset_functional_v2_2026_10_02.json",
|
||||
"report_sha256": "d5bacd0422dece57acb0ebb913a1a849b058751290faebebe9dea0e0198ed930",
|
||||
"freeze_record_path": "docs/research/reported_offset_functional_v2_2026_10_02.freeze.json",
|
||||
"freeze_record_sha256": "0c584207674106597afc129d89c7f395e3aa624954b9b59358ab29d8a75373b7",
|
||||
"scope": "reported_offset_sensitivity_not_product_accuracy",
|
||||
"trial_count": 900,
|
||||
"official_valid_independent_blind": false,
|
||||
@@ -331,10 +335,10 @@
|
||||
"must_not_claim_as_release_metrics": true
|
||||
},
|
||||
"previous_reported_offset_replay": {
|
||||
"report_path": "docs/research/reported_offset_midnight_anchor_2026_09_21.json",
|
||||
"report_sha256": "093d50953d7772f037401b99517b8dcaf2a1b20aa3e8ae2e692d83c6510dd02f",
|
||||
"freeze_record_path": "docs/research/reported_offset_midnight_anchor_2026_09_21.freeze.json",
|
||||
"freeze_record_sha256": "73848f421b133f53578dd0e0713f24fbb38a2bcf3b27609398b1ba98dbfc224c",
|
||||
"superseded_reason": "BUG-1088 wording-only re-freeze of event_probes.py; 900 trials and summary identical; prior report and freeze preserved byte-for-byte."
|
||||
"report_path": "docs/research/reported_offset_quality_wording_2026_09_29.json",
|
||||
"report_sha256": "45f3c2afdcd4d59b59d01a42e872318c125bafad162c578ed2808d43e5b58aca",
|
||||
"freeze_record_path": "docs/research/reported_offset_quality_wording_2026_09_29.freeze.json",
|
||||
"freeze_record_sha256": "7f6d015545b655d8e6b5e96d979c032cedbff904757fa3a89e996710e3fa21a2",
|
||||
"superseded_reason": "BUG-1181 functional profile v2 (scores change) and scoring-10 identity; 230 of 900 native trials changed; prior report and freeze preserved byte-for-byte."
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,12 @@ from scripts.rectification.dasha_transition_proximity import merge_transition_pr
|
||||
from scripts.rectification.contracts import LifeEvent, RectificationRequest, is_scoreable_event
|
||||
from scripts.rectification.case_holdout import holdout_event_ids
|
||||
|
||||
ALGORITHM_VERSION = "rectification-v5-matrix-scoring-9"
|
||||
# scoring-10 (2026-10-02, BUG-1181): functional benefic / malefic profile v2
|
||||
# (bphs_ch34_general_with_sign_exceptions_v2, 57782aea) feeds the
|
||||
# *_functional_benefic_auxiliary / *_functional_malefic_auxiliary rules, so identical
|
||||
# input scores differently; cached scoring-9 results must not be reused as
|
||||
# current. The dated candidate-window contract is unchanged (scoring-9+).
|
||||
ALGORITHM_VERSION = "rectification-v5-matrix-scoring-10"
|
||||
INPUT_CONTRACT_VERSION = "rectification-calculation-spec-v5"
|
||||
PRECISION_WEIGHTS = {
|
||||
"day": 1.0,
|
||||
|
||||
@@ -30,8 +30,8 @@ from scripts.research.sealed_holdout_rerun import (
|
||||
OFFSETS = (-30, -20, -15, -10, -8, -5, -3, 0, 3, 5, 8, 10, 15, 20, 30)
|
||||
RADII = (15, 30, 60)
|
||||
MINUTE_STEP = 1
|
||||
FREEZE = ROOT / "docs/research/reported_offset_quality_wording_2026_09_29.freeze.json"
|
||||
REPORT = ROOT / "docs/research/reported_offset_quality_wording_2026_09_29.json"
|
||||
FREEZE = ROOT / "docs/research/reported_offset_functional_v2_2026_10_02.freeze.json"
|
||||
REPORT = ROOT / "docs/research/reported_offset_functional_v2_2026_10_02.json"
|
||||
LEGACY_REPORT = ROOT / "docs/research/reported_offset_2026_09_20.json"
|
||||
|
||||
|
||||
|
||||
@@ -27,8 +27,8 @@ from scripts.minute_rectification_feature_facts_v4 import build_feature_fact_row
|
||||
from scripts.minute_rectification_holdout_validator import validate
|
||||
|
||||
DATASET = ROOT / "references/real_case_calibration/minute_rectification_holdout_v3.json"
|
||||
FREEZE = ROOT / "docs/research/sealed_holdout_rerun_quality_wording_2026_09_29.freeze.json"
|
||||
REPORT = ROOT / "docs/research/sealed_holdout_rerun_quality_wording_2026_09_29.json"
|
||||
FREEZE = ROOT / "docs/research/sealed_holdout_rerun_functional_v2_2026_10_02.freeze.json"
|
||||
REPORT = ROOT / "docs/research/sealed_holdout_rerun_functional_v2_2026_10_02.json"
|
||||
LEGACY_REPORT = ROOT / "docs/research/sealed_holdout_rerun_2026_09_20.json"
|
||||
ARCHIVE = ROOT / "docs/research/history/rectification_pre_cross_midnight_2026_09_20"
|
||||
PRODUCTION_FILES = [
|
||||
@@ -42,6 +42,9 @@ PRODUCTION_FILES = [
|
||||
"scripts/rectification/decision_policy.py",
|
||||
"scripts/rectification/refinement_packet.py",
|
||||
"scripts/rectification/api_service.py",
|
||||
# BUG-1181: functional roles feed *_functional_*_auxiliary scoring rules;
|
||||
# 57782aea changed scores without tripping this identity.
|
||||
"scripts/functional_benefics.py",
|
||||
]
|
||||
RESEARCH_FILES = [
|
||||
"scripts/research/reported_offset_sweep.py",
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -31,7 +31,9 @@ def test_fixed_scoring_identity_is_exposed_without_changing_input_contract():
|
||||
ALGORITHM_VERSION, INPUT_CONTRACT_VERSION, calculation_spec, sha256,
|
||||
)
|
||||
|
||||
assert engine_scoring_versions()["algorithm_version"] == ALGORITHM_VERSION == "rectification-v5-matrix-scoring-9"
|
||||
# 原值: "rectification-v5-matrix-scoring-9";新值: "...-scoring-10";原因: 功能吉凶 v2 改变同输入分数,
|
||||
# 按「打分语义变化必须 bump」先例升算法身份(BUG-1181);输入合同 v5 与日期窗合同不变。
|
||||
assert engine_scoring_versions()["algorithm_version"] == ALGORITHM_VERSION == "rectification-v5-matrix-scoring-10"
|
||||
assert INPUT_CONTRACT_VERSION == "rectification-calculation-spec-v5"
|
||||
request = {"birth_date": "2000-03-01", "start_time": "00:00", "end_time": "00:02",
|
||||
"lat": 0.0, "lon": 0.0, "tz": 0.0, "events": []}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Memoization for candidate-minute invariants in the rectification engine.
|
||||
|
||||
Golden payload in tests/golden/rectification_engine_memoization_v1.json was
|
||||
Historical golden tests/golden/rectification_engine_memoization_v1.json was
|
||||
produced from origin/staging @ a8d29d1b before any memoization landed.
|
||||
On 2026-09-20 only two identity leaves were refreshed from the real engine:
|
||||
representative_candidate_id 85ca5490-07ab-54b7-acf0-59385f705015 ->
|
||||
@@ -8,6 +8,17 @@ e8c11277-022c-519c-95e9-6a0a04e8bf23, and snapshot algorithm_version
|
||||
rectification-v5-matrix-scoring-7 -> rectification-v5-matrix-scoring-8.
|
||||
The authorized cross-midnight version bump changes UUID identity, not this
|
||||
same-day fixture's scores. Historical numeric values and feature hashes remain.
|
||||
That file is now frozen (sha256 pinned below) and no longer the comparison
|
||||
target: scoring-8/9 scores belong to the old functional benefic / malefic
|
||||
grouping.
|
||||
|
||||
Current golden tests/golden/rectification_engine_memoization_v2.json
|
||||
(2026-10-02, BUG-1181) was written by ``write_golden`` from the real engine at
|
||||
57782aea (functional profile bphs_ch34_general_with_sign_exceptions_v2) with
|
||||
ALGORITHM_VERSION rectification-v5-matrix-scoring-10. Scores move for the same
|
||||
input (candidate 12:00: 8.6274 -> 8.4977), which is why the algorithm identity
|
||||
was bumped; it already carries the dated-v1 receipt metadata. Never rewrite it
|
||||
in place: a future scoring change adds a v3 file and freezes this one.
|
||||
|
||||
Do not compare that payload with a whole-structure ``==``. Cross-machine
|
||||
libm / pyswisseph rounding already drifted ``margin_percent`` by 1.1e-3
|
||||
@@ -47,10 +58,15 @@ import scripts.rectification.scoring_service as scoring_service
|
||||
import shadbala
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
GOLDEN_PATH = ROOT / "tests" / "golden" / "rectification_engine_memoization_v1.json"
|
||||
GOLDEN_PATH = ROOT / "tests" / "golden" / "rectification_engine_memoization_v2.json"
|
||||
HISTORICAL_GOLDEN_PATH = ROOT / "tests" / "golden" / "rectification_engine_memoization_v1.json"
|
||||
HISTORICAL_GOLDEN_SHA256 = "6266e448d7dad204b264cbe8f9bcf4c36e02286794764a94edb9e2ce4d0e3015"
|
||||
CURRENT_ALGORITHM_VERSION = "rectification-v5-matrix-scoring-10"
|
||||
FROZEN_TODAY = date(2026, 9, 16)
|
||||
TIMING_KEYS = frozenset({"column_compare_ms"})
|
||||
SOURCE_COMMIT = "a8d29d1b6cc37ff865ddec6c8bccdf9aa889ee53"
|
||||
HISTORICAL_SOURCE_COMMIT = "a8d29d1b6cc37ff865ddec6c8bccdf9aa889ee53"
|
||||
# Engine code of the v2 golden; the scoring-10 label is the BUG-1181 commit on top.
|
||||
SOURCE_COMMIT = "57782aea8ae28f5dd165a08d221ec27dbef391f8"
|
||||
CACHE_LAYER_KEYS = (
|
||||
"ashtakavarga_result",
|
||||
"shadbala_result",
|
||||
@@ -233,8 +249,8 @@ def _contexts_with_layer_cache_cleared(contexts: list[dict[str, Any]]) -> list[d
|
||||
return cleared
|
||||
|
||||
|
||||
def _assert_dated_payload_against_historical_golden(actual: dict[str, Any], expected: dict[str, Any]) -> None:
|
||||
"""Keep the scoring-8 golden immutable; validate exactly the scoring-9 additions."""
|
||||
def _assert_dated_payload_against_golden(actual: dict[str, Any], expected: dict[str, Any]) -> None:
|
||||
"""Compare with the scoring-10 golden; identity is spelled out, not trusted."""
|
||||
metadata = {
|
||||
"candidate_window_contract": "dated-v1",
|
||||
"candidate_intervals": [{"start_at": "1990-01-01T12:00", "end_at": "1990-01-01T12:02"}],
|
||||
@@ -242,14 +258,13 @@ def _assert_dated_payload_against_historical_golden(actual: dict[str, Any], expe
|
||||
"candidate_timezone_id": "",
|
||||
}
|
||||
receipt = actual["decision_receipt"]
|
||||
historical_receipt = expected["decision_receipt"]
|
||||
assert not set(metadata).intersection(historical_receipt), "historical fixture must not be relabeled"
|
||||
assert set(receipt) == set(historical_receipt) | set(metadata)
|
||||
golden_receipt = expected["decision_receipt"]
|
||||
assert set(receipt) == set(golden_receipt), f"receipt keys {set(receipt) ^ set(golden_receipt)!r}"
|
||||
for key, value in metadata.items():
|
||||
assert receipt[key] == value, key
|
||||
assert expected["candidate_feature_snapshot"]["algorithm_version"] == "rectification-v5-matrix-scoring-8"
|
||||
assert actual["candidate_feature_snapshot"]["algorithm_version"] == "rectification-v5-matrix-scoring-9"
|
||||
assert historical_receipt["representative_candidate_id"] == "e8c11277-022c-519c-95e9-6a0a04e8bf23"
|
||||
assert golden_receipt[key] == value, key
|
||||
assert expected["candidate_feature_snapshot"]["algorithm_version"] == CURRENT_ALGORITHM_VERSION
|
||||
assert actual["candidate_feature_snapshot"]["algorithm_version"] == CURRENT_ALGORITHM_VERSION
|
||||
# Independently spell out the result/candidate UUID namespace formula. Do not
|
||||
# call the production identity helper or accept any arbitrary UUID string.
|
||||
identity_request = {
|
||||
@@ -259,23 +274,33 @@ def _assert_dated_payload_against_historical_golden(actual: dict[str, Any], expe
|
||||
fingerprint = hashlib.sha256(json.dumps(
|
||||
identity_request, ensure_ascii=True, sort_keys=True, separators=(",", ":"),
|
||||
).encode()).hexdigest()
|
||||
result_id = uuid5(NAMESPACE_URL, f"rectification-v5-matrix-scoring-9:{fingerprint}")
|
||||
representative_time = historical_receipt["representative_time"]
|
||||
result_id = uuid5(NAMESPACE_URL, f"{CURRENT_ALGORITHM_VERSION}:{fingerprint}")
|
||||
representative_time = golden_receipt["representative_time"]
|
||||
candidate_id = uuid5(NAMESPACE_URL, f"rectification-candidate-policy-v3:{result_id}:{representative_time}")
|
||||
assert golden_receipt["representative_candidate_id"] == str(candidate_id)
|
||||
assert receipt["representative_candidate_id"] == str(candidate_id)
|
||||
projected = {**actual, "decision_receipt": {
|
||||
**{key: value for key, value in receipt.items() if key not in metadata},
|
||||
"representative_candidate_id": historical_receipt["representative_candidate_id"],
|
||||
}}
|
||||
# BUG-733/985: fingerprints hash unrounded floats; do not turn the
|
||||
# historical snapshot into a cross-process exact-hash contract.
|
||||
_assert_memoization_payloads(projected, expected)
|
||||
# snapshot into a cross-process exact-hash contract.
|
||||
_assert_memoization_payloads(actual, expected)
|
||||
|
||||
|
||||
def test_historical_scoring_8_golden_is_frozen_and_no_longer_current() -> None:
|
||||
"""BUG-1181: the old golden stays byte-identical; current scores moved, hence scoring-10."""
|
||||
raw = HISTORICAL_GOLDEN_PATH.read_bytes()
|
||||
assert hashlib.sha256(raw).hexdigest() == HISTORICAL_GOLDEN_SHA256
|
||||
historical = json.loads(raw)
|
||||
assert historical["source_commit"] == HISTORICAL_SOURCE_COMMIT
|
||||
assert historical["candidate_feature_snapshot"]["algorithm_version"] == "rectification-v5-matrix-scoring-8"
|
||||
current = json.loads(GOLDEN_PATH.read_text(encoding="utf-8"))
|
||||
assert current["source_commit"] == SOURCE_COMMIT
|
||||
with pytest.raises(AssertionError):
|
||||
_assert_memoization_payloads(current, historical)
|
||||
|
||||
|
||||
def test_score_candidates_matches_baseline_golden() -> None:
|
||||
expected = json.loads(GOLDEN_PATH.read_text(encoding="utf-8"))
|
||||
actual = json.loads(json.dumps(_golden_payload(), ensure_ascii=True))
|
||||
_assert_dated_payload_against_historical_golden(actual, expected)
|
||||
_assert_dated_payload_against_golden(actual, expected)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("field,value", [
|
||||
@@ -290,11 +315,11 @@ def test_score_candidates_matches_baseline_golden() -> None:
|
||||
def test_dated_golden_projection_rejects_metadata_identity_and_gate_mutations(field, value) -> None:
|
||||
expected = json.loads(GOLDEN_PATH.read_text(encoding="utf-8"))
|
||||
actual = json.loads(json.dumps(_golden_payload(), ensure_ascii=True))
|
||||
_assert_dated_payload_against_historical_golden(actual, expected)
|
||||
_assert_dated_payload_against_golden(actual, expected)
|
||||
assert actual["decision_receipt"].get(field) != value
|
||||
actual["decision_receipt"][field] = value
|
||||
with pytest.raises(AssertionError):
|
||||
_assert_dated_payload_against_historical_golden(actual, expected)
|
||||
_assert_dated_payload_against_golden(actual, expected)
|
||||
|
||||
|
||||
def test_golden_float_shift_of_1e_minus_2_fails() -> None:
|
||||
|
||||
@@ -20,7 +20,8 @@ class RelativeSupportScaleTest(unittest.TestCase):
|
||||
def test_holdout_gate_keeps_proportional_default(self) -> None:
|
||||
self.assertEqual(POLICY_VERSION, "rectification-candidate-policy-v3")
|
||||
# Explicit date windows: scoring identity -8 -> -9, not a prior/policy change.
|
||||
self.assertEqual(ALGORITHM_VERSION, "rectification-v5-matrix-scoring-9")
|
||||
# 原值: -9;新值: -10;原因: 功能吉凶 v2 改变打分(BUG-1181),策略 v3 与相对支持口径不变。
|
||||
self.assertEqual(ALGORITHM_VERSION, "rectification-v5-matrix-scoring-10")
|
||||
self.assertEqual(RELATIVE_SUPPORT_MODE, "proportional")
|
||||
|
||||
def test_offset_top_two_lead_is_at_least_proportional(self) -> None:
|
||||
|
||||
@@ -12,6 +12,7 @@ from tests.test_reported_offset_research import ( # noqa: F401
|
||||
from tests.test_sealed_holdout_contract_freshness import ( # noqa: F401
|
||||
test_changed_frozen_identity_fails_before_any_replay,
|
||||
test_contract_tracks_actual_current_scorer_and_dataset_audit,
|
||||
test_functional_roles_are_part_of_the_production_identity,
|
||||
test_fixed_protocol_rerun_is_auditable_but_never_independent_blind,
|
||||
test_frozen_record_matches_dataset_scorer_and_evaluator_bytes,
|
||||
test_extended_identity_drift_rejected_even_when_legacy_hash_unchanged,
|
||||
|
||||
@@ -25,6 +25,8 @@ IDENTITY_FORBIDDEN_PREFIXES = (
|
||||
"docs/research/reported_offset_midnight_anchor_2026_09_21",
|
||||
"docs/research/sealed_holdout_rerun_quality_wording_2026_09_29",
|
||||
"docs/research/reported_offset_quality_wording_2026_09_29",
|
||||
"docs/research/sealed_holdout_rerun_functional_v2_2026_10_02",
|
||||
"docs/research/reported_offset_functional_v2_2026_10_02",
|
||||
"docs/research/history/",
|
||||
"artifacts/",
|
||||
)
|
||||
@@ -52,6 +54,14 @@ def test_midnight_date_anchor_modules_remain_in_extended_identity():
|
||||
)
|
||||
|
||||
|
||||
def test_functional_roles_are_part_of_the_production_identity():
|
||||
"""BUG-1181: functional benefic / malefic roles feed the event matrix, so a
|
||||
change there must invalidate the frozen records like any scorer change."""
|
||||
identity = implementation_identity()
|
||||
assert "scripts/functional_benefics.py" in PRODUCTION_FILES
|
||||
assert identity["file_sha256"]["scripts/functional_benefics.py"] == file_sha256(ROOT / "scripts/functional_benefics.py")
|
||||
|
||||
|
||||
def test_contract_tracks_actual_current_scorer_and_dataset_audit():
|
||||
dataset = read(DATASET)
|
||||
contract = read(ROOT / "references/rectification_sealed_holdout.v1.json")
|
||||
|
||||
Reference in New Issue
Block a user