Merge remote-tracking branch 'origin/main' into codex/optimize-runtime-ux
# Conflicts: # frontend/src/mastra/index.ts
This commit is contained in:
@@ -36,6 +36,14 @@ def test_sync_policy_encodes_research_first_commercial_mature_rule() -> None:
|
||||
assert policy["sync_model"] == "research_validates_commercial_receives_mature"
|
||||
assert policy["directional_gates"]["research_to_commercial"]["source_required"] == "validated_in_research"
|
||||
assert policy["directional_gates"]["research_to_commercial"]["target_required"] == "commercial_safe"
|
||||
assert set(policy["research_repo_exclusions"]) >= {
|
||||
"commercial_credits",
|
||||
"billing",
|
||||
"subscriptions",
|
||||
"payment",
|
||||
"account_entitlements",
|
||||
"service_role_runtime",
|
||||
}
|
||||
assert "references/cross_project_contract/fixture_manifest.v1.json" in policy["shared_files"]
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from scripts.day_level_holdout_template import build_template
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
def test_holdout_template_is_nontechnical_and_validator_compatible_shape() -> None:
|
||||
template = build_template()
|
||||
annotation = template["annotation"]
|
||||
|
||||
for token in [
|
||||
"case_id",
|
||||
"subject",
|
||||
"domain",
|
||||
"label",
|
||||
"start",
|
||||
"end",
|
||||
"event_absent_assertion",
|
||||
"source_url",
|
||||
"adjudicator",
|
||||
"independent_human_reviewed",
|
||||
"frozen_before_scoring",
|
||||
]:
|
||||
assert token in annotation
|
||||
|
||||
assert "Do not use old control dates" in " ".join(template["instructions"])
|
||||
assert annotation["source_url"] == "https://"
|
||||
assert annotation["independent_human_reviewed"] is True
|
||||
|
||||
|
||||
def test_holdout_template_cli_writes_json(tmp_path: Path) -> None:
|
||||
output = tmp_path / "template.json"
|
||||
|
||||
subprocess.run(
|
||||
[sys.executable, str(ROOT / "scripts" / "day_level_holdout_template.py"), "--output", str(output)],
|
||||
check=True,
|
||||
text=True,
|
||||
)
|
||||
|
||||
data = json.loads(output.read_text(encoding="utf-8"))
|
||||
assert data["template_type"] == "day_level_holdout_annotation_v3"
|
||||
assert data["annotation"]["label"] == "target_event|no_target_event"
|
||||
@@ -0,0 +1,24 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
DOC = ROOT / "docs" / "research" / "real_case_timing_optimization_audit_2026_07_19.md"
|
||||
|
||||
|
||||
def test_real_case_timing_audit_separates_positive_replay_from_specificity() -> None:
|
||||
text = DOC.read_text(encoding="utf-8")
|
||||
|
||||
for token in [
|
||||
"Positive-event replay is healthy",
|
||||
"known positive events only",
|
||||
"does not verify day/month predictive specificity",
|
||||
"Day-level negative holdout remains empty",
|
||||
"status = awaiting_independent_labels",
|
||||
"day_level_holdout_v3_pilot_source_queue_2026_07_19.json",
|
||||
"not a holdout manifest",
|
||||
"production_tuning_allowed = false",
|
||||
"claim_status = exploratory_unvalidated",
|
||||
"Forbidden UX: packaging candidate dates as verified event promises",
|
||||
]:
|
||||
assert token in text
|
||||
@@ -0,0 +1,63 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from scripts.shadbala_av_component_registry import build_registry
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
ARBITRATION = ROOT / "references" / "oracle" / "three_engine_mismatch_arbitration_2026_07_19.json"
|
||||
|
||||
|
||||
def test_component_registry_groups_shadbala_and_av_mismatches_without_truth_upgrade() -> None:
|
||||
registry = build_registry(ARBITRATION)
|
||||
|
||||
assert registry["scope"] == "shadbala_av_component_provenance_registry"
|
||||
assert registry["truth_policy"] == "method_variant_not_majority_vote"
|
||||
assert registry["status"] == "classified_unresolved"
|
||||
assert registry["production_tuning_allowed"] is False
|
||||
assert registry["summary"]["source_mismatch_count"] == 60
|
||||
assert registry["summary"]["registry_count"] >= 4
|
||||
|
||||
categories = {row["category"] for row in registry["registry"]}
|
||||
assert "shadbala_formula_variant" in categories
|
||||
assert "derived_total_from_component_variants" in categories
|
||||
assert "ashtakavarga_table_or_contributor_variant" in categories
|
||||
|
||||
for row in registry["registry"]:
|
||||
assert row["allowed_claim"] in {
|
||||
"current_target_observation_only",
|
||||
"component_method_variant",
|
||||
"table_variant",
|
||||
"derived_total_blocked_until_components_close",
|
||||
}
|
||||
assert row["unit_contract"]
|
||||
assert row["next_evidence_required"]
|
||||
|
||||
|
||||
def test_component_registry_json_artifact_matches_source_counts() -> None:
|
||||
artifact = ROOT / "references" / "oracle" / "shadbala_av_component_provenance_registry_2026_07_19.json"
|
||||
data = json.loads(artifact.read_text(encoding="utf-8"))
|
||||
|
||||
assert data["summary"]["source_mismatch_count"] == 60
|
||||
assert data["summary"]["category_counts"]["shadbala_formula_variant"] == 35
|
||||
assert data["summary"]["category_counts"]["derived_total_from_component_variants"] == 7
|
||||
assert data["summary"]["category_counts"]["ashtakavarga_table_or_contributor_variant"] == 8
|
||||
assert data["production_tuning_allowed"] is False
|
||||
|
||||
|
||||
def test_component_provenance_markdown_report_is_human_readable() -> None:
|
||||
report = ROOT / "docs" / "research" / "shadbala_av_component_provenance_report_2026_07_19.md"
|
||||
text = report.read_text(encoding="utf-8")
|
||||
|
||||
for token in [
|
||||
"Shadbala / AV component provenance report",
|
||||
"method_variant_not_majority_vote",
|
||||
"Production tuning: `false`",
|
||||
"`shadbala_formula_variant`",
|
||||
"`derived_total_from_component_variants`",
|
||||
"`ashtakavarga_table_or_contributor_variant`",
|
||||
"Total Rupa/Virupa cannot be arbitrated until component units close",
|
||||
"Next source-evidence queue",
|
||||
]:
|
||||
assert token in text
|
||||
@@ -0,0 +1,42 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
PLAN = ROOT / "docs" / "research" / "shadbala_av_normative_benchmark_plan_2026_07_19.md"
|
||||
|
||||
|
||||
def test_shadbala_av_plan_keeps_current_closure_separate_from_global_truth() -> None:
|
||||
text = PLAN.read_text(encoding="utf-8")
|
||||
|
||||
for token in [
|
||||
"current target set: `external_verified`",
|
||||
"`can_claim_shadbala_absolute_closure = true`",
|
||||
"`production_tuning_allowed = false`",
|
||||
"must not claim universal Shadbala or AV truth",
|
||||
"60 mismatches, 60 classified, 0 unclassified",
|
||||
"no majority vote",
|
||||
]:
|
||||
assert token in text
|
||||
|
||||
|
||||
def test_shadbala_av_plan_requires_component_units_and_license_boundaries() -> None:
|
||||
text = PLAN.read_text(encoding="utf-8")
|
||||
|
||||
for token in [
|
||||
"VP Jain",
|
||||
"Xalen",
|
||||
"PyJHora/JHora",
|
||||
"jyotishganit",
|
||||
"Virupa vs Rupa must be explicit",
|
||||
"`sthana`",
|
||||
"`dig`",
|
||||
"`kala`",
|
||||
"`chesta`",
|
||||
"`naisargika`",
|
||||
"`drik`",
|
||||
"`total_rupa`",
|
||||
"AGPL implementation code",
|
||||
"Independent ephemeris mode",
|
||||
]:
|
||||
assert token in text
|
||||
@@ -33,3 +33,15 @@ def test_vedastro_only_d2_difference_is_endpoint_semantics(tmp_path: Path) -> No
|
||||
row = arbitrate_manifest(path)["rows"][0]
|
||||
assert row["category"] == "endpoint_or_varga_semantics"
|
||||
assert row["differing_engines"] == ["VedAstro"]
|
||||
|
||||
|
||||
def test_commercial_receives_mismatch_status_not_raw_truth_upgrade() -> None:
|
||||
report = json.loads((ROOT / "references/oracle/three_engine_mismatch_arbitration_2026_07_19.json").read_text(encoding="utf-8"))
|
||||
markdown = (ROOT / "docs/research/three_engine_mismatch_arbitration_2026_07_19.md").read_text(encoding="utf-8")
|
||||
|
||||
assert report["mismatch_count"] == 60
|
||||
assert report["classified_count"] == 60
|
||||
assert report["unclassified_count"] == 0
|
||||
assert report["truth_policy"] == "no_majority_vote"
|
||||
assert "commercial_sync: `status_and_claim_boundary_only`" in markdown
|
||||
assert "Do not copy raw research debt into commercial runtime" in markdown
|
||||
|
||||
@@ -0,0 +1,193 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from scripts.day_level_holdout_validator import validate
|
||||
from scripts.day_level_negative_holdout_intake import append_annotation
|
||||
from scripts.timing_ranker_blind_eval import evaluate
|
||||
|
||||
|
||||
def test_holdout_validator_rejects_non_independent_and_prohibited_rows(tmp_path: Path) -> None:
|
||||
manifest = {
|
||||
"prohibited_tuning_data": ["old_controls.json"],
|
||||
"frozen_gate": {"minimum_independent_cases": 1, "minimum_independent_negative_intervals": 1},
|
||||
"annotations": [
|
||||
{
|
||||
"case_id": "case-1",
|
||||
"domain": "career",
|
||||
"label": "no_target_event",
|
||||
"start": "2020-01-01",
|
||||
"end": "2020-01-07",
|
||||
"source_url": "https://example.org/timeline",
|
||||
"adjudicator": "same_person",
|
||||
"time_uncertainty_days": 0,
|
||||
"independent_human_reviewed": False,
|
||||
"source_path": "old_controls.json",
|
||||
}
|
||||
],
|
||||
}
|
||||
path = tmp_path / "holdout.json"
|
||||
path.write_text(json.dumps(manifest), encoding="utf-8")
|
||||
|
||||
report = validate(path)
|
||||
|
||||
assert report["status"] == "awaiting_independent_labels"
|
||||
assert report["production_tuning_allowed"] is False
|
||||
assert {error["error"] for error in report["errors"]} >= {
|
||||
"not_independently_human_reviewed",
|
||||
"prohibited_tuning_source",
|
||||
}
|
||||
|
||||
|
||||
def test_blind_eval_requires_positive_windows_to_rank_above_negative_windows(tmp_path: Path) -> None:
|
||||
manifest = {
|
||||
"frozen_gate": {
|
||||
"minimum_positive_top_3_rate": 0.6,
|
||||
"minimum_specificity": 0.6,
|
||||
"minimum_independent_cases": 1,
|
||||
"minimum_independent_negative_intervals": 1,
|
||||
},
|
||||
"annotations": [
|
||||
{
|
||||
"case_id": "case-1",
|
||||
"domain": "career",
|
||||
"label": "target_event",
|
||||
"start": "2020-01-01",
|
||||
"end": "2020-01-07",
|
||||
"source_url": "https://example.org/event",
|
||||
"adjudicator": "reviewer-a",
|
||||
"time_uncertainty_days": 0,
|
||||
"independent_human_reviewed": True,
|
||||
},
|
||||
{
|
||||
"case_id": "case-1-neg",
|
||||
"domain": "career",
|
||||
"label": "no_target_event",
|
||||
"start": "2020-02-01",
|
||||
"end": "2020-02-07",
|
||||
"source_url": "https://example.org/non-event",
|
||||
"adjudicator": "reviewer-b",
|
||||
"time_uncertainty_days": 0,
|
||||
"independent_human_reviewed": True,
|
||||
},
|
||||
],
|
||||
}
|
||||
candidates = {
|
||||
"candidate_windows": [
|
||||
{"case_id": "case-1", "start": "2020-01-01", "end": "2020-01-07", "score": 0.90},
|
||||
{"case_id": "case-1-neg", "start": "2020-02-01", "end": "2020-02-07", "score": 0.20},
|
||||
]
|
||||
}
|
||||
manifest_path = tmp_path / "holdout.json"
|
||||
candidates_path = tmp_path / "candidates.json"
|
||||
manifest_path.write_text(json.dumps(manifest), encoding="utf-8")
|
||||
candidates_path.write_text(json.dumps(candidates), encoding="utf-8")
|
||||
|
||||
report = evaluate(manifest_path, candidates_path)
|
||||
|
||||
assert report["status"] == "pass"
|
||||
assert report["claim_status"] == "calibrated_day_level"
|
||||
assert report["production_tuning_allowed"] is True
|
||||
assert report["positive_top_3_rate"] == 1.0
|
||||
assert report["specificity"] == 1.0
|
||||
|
||||
|
||||
def test_blind_eval_blocks_when_negative_scores_outrank_positive_scores(tmp_path: Path) -> None:
|
||||
manifest = {
|
||||
"frozen_gate": {
|
||||
"minimum_positive_top_3_rate": 0.6,
|
||||
"minimum_specificity": 0.6,
|
||||
"minimum_independent_cases": 1,
|
||||
"minimum_independent_negative_intervals": 1,
|
||||
},
|
||||
"annotations": [
|
||||
{
|
||||
"case_id": "positive",
|
||||
"domain": "marriage",
|
||||
"label": "target_event",
|
||||
"start": "2020-01-01",
|
||||
"end": "2020-01-07",
|
||||
"source_url": "https://example.org/event",
|
||||
"adjudicator": "reviewer-a",
|
||||
"time_uncertainty_days": 0,
|
||||
"independent_human_reviewed": True,
|
||||
},
|
||||
{
|
||||
"case_id": "negative",
|
||||
"domain": "marriage",
|
||||
"label": "no_target_event",
|
||||
"start": "2020-02-01",
|
||||
"end": "2020-02-07",
|
||||
"source_url": "https://example.org/non-event",
|
||||
"adjudicator": "reviewer-b",
|
||||
"time_uncertainty_days": 0,
|
||||
"independent_human_reviewed": True,
|
||||
},
|
||||
],
|
||||
}
|
||||
candidates = {
|
||||
"candidate_windows": [
|
||||
{"case_id": "positive", "start": "2020-01-01", "end": "2020-01-07", "score": 0.10},
|
||||
{"case_id": "negative", "start": "2020-02-01", "end": "2020-02-07", "score": 0.95},
|
||||
]
|
||||
}
|
||||
manifest_path = tmp_path / "holdout.json"
|
||||
candidates_path = tmp_path / "candidates.json"
|
||||
manifest_path.write_text(json.dumps(manifest), encoding="utf-8")
|
||||
candidates_path.write_text(json.dumps(candidates), encoding="utf-8")
|
||||
|
||||
report = evaluate(manifest_path, candidates_path)
|
||||
|
||||
assert report["status"] == "blocked"
|
||||
assert report["claim_status"] == "exploratory_unvalidated"
|
||||
assert report["production_tuning_allowed"] is False
|
||||
assert "specificity_below_gate" in report["blockers"]
|
||||
|
||||
|
||||
def test_negative_holdout_intake_appends_valid_independent_label(tmp_path: Path) -> None:
|
||||
path = tmp_path / "holdout.json"
|
||||
path.write_text(json.dumps({"annotations": [], "prohibited_tuning_data": []}), encoding="utf-8")
|
||||
|
||||
report = append_annotation(
|
||||
path,
|
||||
{
|
||||
"case_id": "case-2-neg",
|
||||
"domain": "career",
|
||||
"label": "no_target_event",
|
||||
"start": "2020-03-01",
|
||||
"end": "2020-03-31",
|
||||
"source_url": "https://example.org/biography",
|
||||
"adjudicator": "reviewer-c",
|
||||
"time_uncertainty_days": 0,
|
||||
"independent_human_reviewed": True,
|
||||
},
|
||||
)
|
||||
|
||||
saved = json.loads(path.read_text(encoding="utf-8"))
|
||||
assert report["appended"] is True
|
||||
assert saved["annotations"][0]["case_id"] == "case-2-neg"
|
||||
assert saved["annotations"][0]["frozen_before_scoring"] is True
|
||||
|
||||
|
||||
def test_negative_holdout_intake_rejects_non_independent_label(tmp_path: Path) -> None:
|
||||
path = tmp_path / "holdout.json"
|
||||
path.write_text(json.dumps({"annotations": []}), encoding="utf-8")
|
||||
|
||||
report = append_annotation(
|
||||
path,
|
||||
{
|
||||
"case_id": "bad",
|
||||
"domain": "career",
|
||||
"label": "no_target_event",
|
||||
"start": "2020-03-01",
|
||||
"end": "2020-03-31",
|
||||
"source_url": "https://example.org/biography",
|
||||
"adjudicator": "reviewer-c",
|
||||
"time_uncertainty_days": 0,
|
||||
"independent_human_reviewed": False,
|
||||
},
|
||||
)
|
||||
|
||||
assert report["appended"] is False
|
||||
assert report["errors"][0]["error"] == "not_independently_human_reviewed"
|
||||
@@ -0,0 +1,35 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
DOC = ROOT / "docs" / "research" / "vedastro_identity_closure_plan_2026_07_19.md"
|
||||
|
||||
|
||||
def test_vedastro_identity_plan_keeps_hosted_output_observation_only() -> None:
|
||||
text = DOC.read_text(encoding="utf-8")
|
||||
|
||||
for token in [
|
||||
"VedAstro hosted API remains observation-only",
|
||||
"build identity, method semantics, and deployment version are not archived",
|
||||
"does not prove which side is true",
|
||||
"tune production predictions from hosted output with unknown build identity",
|
||||
"silently prefer VedAstro or local output by majority vote",
|
||||
]:
|
||||
assert token in text
|
||||
|
||||
|
||||
def test_vedastro_identity_plan_requires_self_host_supply_chain_fields() -> None:
|
||||
text = DOC.read_text(encoding="utf-8")
|
||||
|
||||
for token in [
|
||||
"source commit",
|
||||
"NuGet package hash",
|
||||
"DLL SHA-256",
|
||||
"assembly version",
|
||||
"public method inventory",
|
||||
"container image digest",
|
||||
"required_self_host_evidence",
|
||||
"truth_upgrade_gate",
|
||||
]:
|
||||
assert token in text
|
||||
@@ -0,0 +1,33 @@
|
||||
from pathlib import Path
|
||||
|
||||
from scripts.vedastro_reproducible_build_probe import build_identity
|
||||
|
||||
|
||||
def test_build_identity_binds_source_and_container_inputs(tmp_path: Path) -> None:
|
||||
(tmp_path / "API").mkdir()
|
||||
(tmp_path / "API/Dockerfile").write_text(
|
||||
"FROM example/sdk:7@sha256:" + "a" * 64 + " AS build\nFROM build AS final\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
(tmp_path / "API/API.csproj").write_text("<Project />\n", encoding="utf-8")
|
||||
report = build_identity(tmp_path, source_commit="1f3a464", image_inspect=None)
|
||||
|
||||
assert report["source_commit"] == "1f3a464"
|
||||
assert len(report["dockerfile_sha256"]) == 64
|
||||
assert report["base_images"] == ["example/sdk:7@sha256:" + "a" * 64]
|
||||
assert len(report["project_file_hashes"]["API/API.csproj"]) == 64
|
||||
assert report["status"] == "source_pinned_image_not_built"
|
||||
|
||||
|
||||
def test_build_identity_records_built_image_digest(tmp_path: Path) -> None:
|
||||
(tmp_path / "API").mkdir()
|
||||
(tmp_path / "API/Dockerfile").write_text("FROM example/sdk:7\n", encoding="utf-8")
|
||||
report = build_identity(
|
||||
tmp_path,
|
||||
source_commit="abc123",
|
||||
image_inspect={"Id": "sha256:" + "b" * 64, "RepoDigests": ["repo@sha256:" + "c" * 64]},
|
||||
)
|
||||
|
||||
assert report["status"] == "reproducible_candidate_built"
|
||||
assert report["image_id"] == "sha256:" + "b" * 64
|
||||
assert report["repo_digests"] == ["repo@sha256:" + "c" * 64]
|
||||
Reference in New Issue
Block a user