From f03400252adaae14eac6f4389e62f59b1628e7aa Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 08:13:57 +0930 Subject: [PATCH 001/159] Add canonical Phase D claim ledger --- claims/claim-ledger.json | 321 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 321 insertions(+) create mode 100644 claims/claim-ledger.json diff --git a/claims/claim-ledger.json b/claims/claim-ledger.json new file mode 100644 index 0000000..e6b62fa --- /dev/null +++ b/claims/claim-ledger.json @@ -0,0 +1,321 @@ +{ + "schema": "COSMO-CLAIMS-D-1", + "evidence_classes": [ + "FORMAL", + "COMPUTATIONAL", + "SCIENTIFIC", + "HYPOTHESIS", + "SYMBOLIC" + ], + "sources": [ + { + "id": "SRC-E8-MATHWORLD", + "kind": "scholarly_reference", + "title": "Gosset Polytope — E8 root polytope", + "url": "https://mathworld.wolfram.com/GossetPolytope.html", + "identifiers": {} + }, + { + "id": "SRC-SPIN8-PTEP-2021", + "kind": "scholarly_article", + "title": "Vertex operator superalgebra/sigma model correspondences: The four-torus case", + "url": "https://academic.oup.com/ptep/article/2021/8/08B102/6353037", + "identifiers": { + "year": "2021" + } + }, + { + "id": "SRC-SIS2-PMID-25590815", + "kind": "peer_reviewed_article", + "title": "Two high-pressure phases of SiS2 as missing links between the extremes of only edge-sharing and only corner-sharing tetrahedra", + "url": "https://pubmed.ncbi.nlm.nih.gov/25590815/", + "identifiers": { + "PMID": "25590815", + "DOI": "10.1021/ic501825r" + } + }, + { + "id": "SRC-HPV16-REFSEQ", + "kind": "official_database", + "title": "Human papillomavirus type 16, complete genome", + "url": "https://www.ncbi.nlm.nih.gov/nuccore/NC_001526.4", + "identifiers": { + "RefSeq": "NC_001526.4" + } + }, + { + "id": "SRC-HPV16-E6E7-PMID-17645777", + "kind": "peer_reviewed_review", + "title": "Basic mechanisms of high-risk human papillomavirus-induced carcinogenesis: Roles of E6 and E7 proteins", + "url": "https://pmc.ncbi.nlm.nih.gov/articles/PMC11158331/", + "identifiers": { + "PMID": "17645777", + "PMCID": "PMC11158331" + } + }, + { + "id": "SRC-HPV-P16-PMC8409095", + "kind": "peer_reviewed_review", + "title": "Biology of HPV Mediated Carcinogenesis and Tumor Progression", + "url": "https://pmc.ncbi.nlm.nih.gov/articles/PMC8409095/", + "identifiers": { + "PMCID": "PMC8409095" + } + } + ], + "claims": [ + { + "id": "COSMO-D-001", + "class": "FORMAL", + "status": "SUPPORTED", + "statement": "For every CosmoLayer, six applications of the authoritative Lean transition return the layer to itself.", + "provenance": [ + { + "path": "cosmovirus.lean", + "anchor": "theorem six_step_periodic", + "role": "kernel_checked_theorem" + } + ], + "sources": [], + "falsification": null, + "boundary": "This is a theorem about the finite state machine only; it is not a physical periodicity claim." + }, + { + "id": "COSMO-D-002", + "class": "FORMAL", + "status": "SUPPORTED", + "statement": "Every authoritative COSMO layer reaches every other layer within one complete six-state orbit.", + "provenance": [ + { + "path": "cosmovirus.lean", + "anchor": "theorem every_layer_reachable", + "role": "kernel_checked_theorem" + } + ], + "sources": [], + "falsification": null, + "boundary": "Reachability is defined inside the project state machine." + }, + { + "id": "COSMO-D-003", + "class": "COMPUTATIONAL", + "status": "SUPPORTED", + "statement": "The Phase B3 Python reference generator deterministically constructs 240 unique E8 roots with rank 8 and squared norm 2, and the canonical table is bound to a reviewed SHA-256.", + "provenance": [ + { + "path": "cosmo_core/e8.py", + "anchor": "def validate_e8_root_system", + "role": "implementation" + }, + { + "path": "tests/test_phase_b3.py", + "anchor": "test_root_system_report_has_rank_eight_and_norm_two", + "role": "regression" + } + ], + "sources": [ + "SRC-E8-MATHWORLD" + ], + "falsification": null, + "boundary": "This is deterministic computational evidence; the local Lean core does not yet formalize the E8 root construction." + }, + { + "id": "COSMO-D-004", + "class": "SCIENTIFIC", + "status": "SUPPORTED", + "statement": "Spin(8) has triality symmetry with an S3 outer automorphism action that permutes its vector and two spinor eight-dimensional representations.", + "provenance": [ + { + "path": "cosmovirus.tex", + "anchor": "Triality automorphism", + "role": "documented_context" + } + ], + "sources": [ + "SRC-SPIN8-PTEP-2021" + ], + "falsification": null, + "boundary": "This mathematical fact does not establish a mechanism connecting Spin(8) triality to HPV, capsids, SiS2, or cosmology." + }, + { + "id": "COSMO-D-005", + "class": "SCIENTIFIC", + "status": "SUPPORTED", + "statement": "The ambient-pressure phase of SiS2 is orthorhombic and contains chains of distorted edge-sharing SiS4 tetrahedra.", + "provenance": [ + { + "path": "cosmovirus.tex", + "anchor": "Silicon disulfide", + "role": "documented_context" + } + ], + "sources": [ + "SRC-SIS2-PMID-25590815" + ], + "falsification": null, + "boundary": "This crystallographic fact does not support COSMO's symbolic substrate or life-code interpretation." + }, + { + "id": "COSMO-D-006", + "class": "SCIENTIFIC", + "status": "SUPPORTED", + "statement": "The NCBI reference sequence used for human papillomavirus type 16 in this ledger is RefSeq NC_001526.4.", + "provenance": [ + { + "path": "CLAIM-LEDGER.md", + "anchor": "NC_001526.4", + "role": "provenance_record" + } + ], + "sources": [ + "SRC-HPV16-REFSEQ" + ], + "falsification": null, + "boundary": "The accession identifies a reference genome; it does not validate COSMO's state-machine use of the HPV16Layer label." + }, + { + "id": "COSMO-D-007", + "class": "SCIENTIFIC", + "status": "SUPPORTED", + "statement": "High-risk HPV E6 and E7 proteins are established carcinogenesis factors; E6 promotes p53 degradation and E7 disrupts pRb/E2F control.", + "provenance": [ + { + "path": "cosmovirus.tex", + "anchor": "Human papillomavirus type 16", + "role": "documented_context" + } + ], + "sources": [ + "SRC-HPV16-E6E7-PMID-17645777" + ], + "falsification": null, + "boundary": "This biomedical mechanism is external scientific context and is not a mechanism for COSMO transitions." + }, + { + "id": "COSMO-D-008", + "class": "SCIENTIFIC", + "status": "SUPPORTED_WITH_SCOPE", + "statement": "p16 immunohistochemistry is used as a surrogate marker for HPV-associated disease in some clinical contexts, but p16 positivity is not identical to direct evidence of active E6/E7 transcription.", + "provenance": [ + { + "path": "cosmovirus.tex", + "anchor": "p16", + "role": "documented_context" + } + ], + "sources": [ + "SRC-HPV-P16-PMC8409095" + ], + "falsification": null, + "boundary": "COSMO must not equate a generic p16-positive label with HPV16 infection or active viral transcription." + }, + { + "id": "COSMO-D-009", + "class": "SYMBOLIC", + "status": "PROJECT_DEFINED", + "statement": "The byte-to-cuneiform labels in COSMO are project-defined symbolic annotations.", + "provenance": [ + { + "path": "cosmovirus.lean", + "anchor": "def cuneiformAnnotation", + "role": "project_definition" + }, + { + "path": "KNOWN_LIMITATIONS.md", + "anchor": "Cuneiform strings are project-defined symbolic annotations", + "role": "scope_boundary" + } + ], + "sources": [], + "falsification": null, + "boundary": "They are not a decipherment, transliteration, translation, archaeological attribution, or historical sentence." + }, + { + "id": "COSMO-D-010", + "class": "SYMBOLIC", + "status": "PROJECT_DEFINED", + "statement": "COSMO's language of undivided cosmic symmetry, life-code substrate, infected reality, and Ouroboros self-causation is symbolic/interpretive vocabulary.", + "provenance": [ + { + "path": "cosmovirus.tex", + "anchor": "Symbolic Interpretation", + "role": "symbolic_section" + } + ], + "sources": [], + "falsification": null, + "boundary": "These phrases are not empirical cosmology, materials science, virology, or causal-mechanism claims." + }, + { + "id": "COSMO-D-011", + "class": "SYMBOLIC", + "status": "PROJECT_DEFINED", + "statement": "The association of Spin(8) triality with HPV capsid branching or trimerization is a symbolic cross-domain association in the current repository.", + "provenance": [ + { + "path": "cosmovirus.tex", + "anchor": "capsid", + "role": "historical_symbolic_mapping" + } + ], + "sources": [], + "falsification": null, + "boundary": "No established biological mechanism connecting Spin(8) triality to HPV capsid assembly is claimed." + }, + { + "id": "COSMO-D-012", + "class": "HYPOTHESIS", + "status": "PROPOSED", + "statement": "A future quantitatively specified mapping from triality-derived features to an HPV/capsid observable could be tested for predictive value against matched controls.", + "provenance": [ + { + "path": "CLAIM-LEDGER.md", + "anchor": "COSMO-D-012", + "role": "hypothesis_definition" + } + ], + "sources": [], + "falsification": "Pre-register the mapping, observable, dataset split, metric, and matched baselines; reject the hypothesis if held-out performance fails the predeclared threshold or is not distinguishable from the controls.", + "boundary": "No such predictive result is currently claimed." + }, + { + "id": "COSMO-D-013", + "class": "SYMBOLIC", + "status": "PROJECT_DEFINED", + "statement": "The use of SiS2Substrate as a COSMO state name is symbolic project vocabulary rather than evidence that silicon disulfide is a biological life-code substrate.", + "provenance": [ + { + "path": "cosmovirus.lean", + "anchor": "SiS2Substrate", + "role": "state_label" + } + ], + "sources": [ + "SRC-SIS2-PMID-25590815" + ], + "falsification": null, + "boundary": "The scientific source supports SiS2 crystal-structure facts only." + }, + { + "id": "COSMO-D-014", + "class": "COMPUTATIONAL", + "status": "SUPPORTED", + "statement": "Within the documented SECDED capability, the Phase B5 software storage pipeline deterministically recovers the original TriadicLattice through bytes, ECC, ACGT, corruption, correction, bytes, and cube reconstruction.", + "provenance": [ + { + "path": "cosmo_core/storage.py", + "anchor": "def recover_cube_storage", + "role": "implementation" + }, + { + "path": "tests/test_phase_b5.py", + "anchor": "test_full_cube_recovers_one_bit_error_in_every_codeword", + "role": "regression" + } + ], + "sources": [], + "falsification": null, + "boundary": "This is a software codec result, not a laboratory DNA-storage or physical Rubik's Cube claim." + } + ] +} From a28f2a8cead7bb836a54d9f568f7cfcd24923adb Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 08:14:00 +0930 Subject: [PATCH 002/159] Add human-readable Phase D claim ledger --- CLAIM-LEDGER.md | 65 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 CLAIM-LEDGER.md diff --git a/CLAIM-LEDGER.md b/CLAIM-LEDGER.md new file mode 100644 index 0000000..c7a68df --- /dev/null +++ b/CLAIM-LEDGER.md @@ -0,0 +1,65 @@ +# COSMO Claim Ledger + +**Schema:** `COSMO-CLAIMS-D-1` + +This ledger is the Phase D authority for classifying cross-domain statements. The machine-readable source is `claims/claim-ledger.json`; CI validates both files together. + +## Evidence classes + +- **FORMAL** — kernel-checked consequences of reviewed Lean definitions. +- **COMPUTATIONAL** — deterministic results of reviewed executable code and regression tests. +- **SCIENTIFIC** — externally sourced scholarly/database statements, stated no more strongly than the cited source supports. +- **HYPOTHESIS** — testable proposals that must include an explicit falsification protocol. +- **SYMBOLIC** — project-defined artistic, mythological, mnemonic, or interpretive mappings with no empirical force. + +A claim may have external context sources without changing its class. In particular, a symbolic mapping does not become scientific merely because one of its component nouns has scientific literature. + +## Scientific source registry + +- **SRC-E8-MATHWORLD** — Wolfram MathWorld, *Gosset Polytope*; documents the 240 vertices/roots of the E8 root polytope. +- **SRC-SPIN8-PTEP-2021** — PTEP 2021 article; states the Spin(8) triality (S_3) outer automorphism and permutation of the three 8-dimensional representations. +- **SRC-SIS2-PMID-25590815** — PMID **25590815**, DOI **10.1021/ic501825r**; describes ambient-pressure SiS2 as orthorhombic chains of distorted edge-sharing SiS4 tetrahedra. +- **SRC-HPV16-REFSEQ** — NCBI RefSeq **NC_001526.4**, human papillomavirus type 16 complete genome. +- **SRC-HPV16-E6E7-PMID-17645777** — PMID **17645777**, PMCID **PMC11158331**; review of high-risk HPV E6/E7 carcinogenesis mechanisms. +- **SRC-HPV-P16-PMC8409095** — PMCID **PMC8409095**; review discussing p16 as a surrogate marker and its limitations relative to direct viral transcription evidence. + +## Claims + +### FORMAL + +- **COSMO-D-001** — Six authoritative state transitions return every `CosmoLayer` to itself. Authority: Lean theorem `six_step_periodic`. +- **COSMO-D-002** — Every authoritative layer reaches every other layer within one six-state orbit. Authority: Lean theorem `every_layer_reachable`. + +### COMPUTATIONAL + +- **COSMO-D-003** — Phase B3 deterministically constructs and validates the 240-root E8 table, rank 8 and norm-2 structure, with reviewed identity binding. +- **COSMO-D-014** — Phase B5 recovers the original `TriadicLattice` through the documented software ECC/ACGT round trip for corruption patterns inside the selected SECDED capability. + +### SCIENTIFIC + +- **COSMO-D-004** — Spin(8) triality has an (S_3) outer automorphism action permuting the vector and two spinor eight-dimensional representations. This does **not** imply a capsid/HPV mechanism. +- **COSMO-D-005** — Ambient-pressure SiS2 is orthorhombic and contains chains of distorted edge-sharing SiS4 tetrahedra. This does **not** establish a biological “life-code” substrate. +- **COSMO-D-006** — HPV16 reference genome provenance in this ledger: NCBI RefSeq **NC_001526.4**. +- **COSMO-D-007** — High-risk HPV E6/E7 have established carcinogenesis roles involving p53 and pRb/E2F control. These facts do **not** define COSMO's transitions. +- **COSMO-D-008** — p16 immunohistochemistry is a context-dependent surrogate marker; p16 positivity is not equivalent to direct evidence of active HPV16 E6/E7 transcription. + +### HYPOTHESIS + +- **COSMO-D-012** — A future quantitatively specified triality-to-HPV/capsid mapping may be tested for predictive value. It currently has **no positive result**. Falsification requires preregistered mapping, observable, data split, metric, controls, and threshold. + +### SYMBOLIC + +- **COSMO-D-009** — Cuneiform annotations are project-defined symbols, not archaeological decipherment or translation. +- **COSMO-D-010** — “Cosmic symmetry”, “life-code”, “infected reality”, and Ouroboros self-causation are symbolic/interpretive vocabulary. +- **COSMO-D-011** — The current triality ↔ HPV capsid branching association is symbolic, not an established biological mechanism. +- **COSMO-D-013** — `SiS2Substrate` is a project state label; the SiS2 literature does not establish a biological substrate role. + +## Governance + +1. New cross-domain public-facing claims must receive a stable `COSMO-D-###` ID before being promoted as Phase D authoritative language. +2. **SCIENTIFIC** claims require at least one external source entry. +3. **HYPOTHESIS** claims require an explicit falsification protocol and may not be phrased as established mechanisms. +4. **SYMBOLIC** claims must state their non-empirical boundary. +5. **FORMAL** and **COMPUTATIONAL** claims must point to reviewed repository evidence. +6. A source about one domain does not validate a cross-domain bridge. +7. Historical PDFs and archived source material remain provenance inputs, not authorities over the ledger. From 4e39077370f7aae6e3975747904219103fff5905 Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 08:14:03 +0930 Subject: [PATCH 003/159] Add claim-ledger CI validator --- scripts/validate-claim-ledger.py | 164 +++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 scripts/validate-claim-ledger.py diff --git a/scripts/validate-claim-ledger.py b/scripts/validate-claim-ledger.py new file mode 100644 index 0000000..7d7bf79 --- /dev/null +++ b/scripts/validate-claim-ledger.py @@ -0,0 +1,164 @@ +#!/usr/bin/env python3 +"""Validate the Phase D COSMO claim ledger and its human-readable index.""" + +from __future__ import annotations + +import json +import re +from pathlib import Path +from typing import Any + +ROOT = Path(__file__).resolve().parents[1] +LEDGER_PATH = ROOT / "claims" / "claim-ledger.json" +INDEX_PATH = ROOT / "CLAIM-LEDGER.md" + +CLASSES = ("FORMAL", "COMPUTATIONAL", "SCIENTIFIC", "HYPOTHESIS", "SYMBOLIC") +CLAIM_ID = re.compile(r"COSMO-D-[0-9]{3}$") +SOURCE_ID = re.compile(r"SRC-[A-Z0-9][A-Z0-9._-]*$") + + +def fail(message: str) -> None: + raise SystemExit(f"claim-ledger validation failed: {message}") + + +def load_json() -> dict[str, Any]: + try: + raw = json.loads(LEDGER_PATH.read_text(encoding="utf-8")) + except (OSError, UnicodeError, json.JSONDecodeError) as exc: + fail(f"cannot read canonical JSON: {exc}") + if not isinstance(raw, dict): + fail("ledger root must be an object") + return raw + + +def require_string(value: object, label: str) -> str: + if not isinstance(value, str) or not value.strip(): + fail(f"{label} must be a non-empty string") + return value + + +def validate_provenance(claim_id: str, entries: object) -> None: + if not isinstance(entries, list) or not entries: + fail(f"{claim_id} must have repository provenance") + for index, item in enumerate(entries): + if not isinstance(item, dict): + fail(f"{claim_id} provenance[{index}] must be an object") + path_text = require_string(item.get("path"), f"{claim_id} provenance path") + anchor = require_string(item.get("anchor"), f"{claim_id} provenance anchor") + require_string(item.get("role"), f"{claim_id} provenance role") + path = ROOT / path_text + try: + text = path.read_text(encoding="utf-8") + except (OSError, UnicodeError) as exc: + fail(f"{claim_id} provenance path {path_text!r} unreadable: {exc}") + if anchor not in text: + fail(f"{claim_id} anchor {anchor!r} not found in {path_text}") + + +def validate() -> None: + ledger = load_json() + if ledger.get("schema") != "COSMO-CLAIMS-D-1": + fail("unexpected schema") + if ledger.get("evidence_classes") != list(CLASSES): + fail("evidence class order or membership changed") + + sources = ledger.get("sources") + claims = ledger.get("claims") + if not isinstance(sources, list) or not isinstance(claims, list): + fail("sources and claims must be arrays") + + source_ids: set[str] = set() + for source in sources: + if not isinstance(source, dict): + fail("source entries must be objects") + source_id = require_string(source.get("id"), "source id") + if SOURCE_ID.fullmatch(source_id) is None: + fail(f"invalid source id {source_id!r}") + if source_id in source_ids: + fail(f"duplicate source id {source_id}") + source_ids.add(source_id) + require_string(source.get("kind"), f"{source_id} kind") + require_string(source.get("title"), f"{source_id} title") + url = require_string(source.get("url"), f"{source_id} url") + if not url.startswith("https://"): + fail(f"{source_id} must use https") + identifiers = source.get("identifiers") + if not isinstance(identifiers, dict): + fail(f"{source_id} identifiers must be an object") + if any( + not isinstance(key, str) + or not isinstance(value, str) + or not key + or not value + for key, value in identifiers.items() + ): + fail(f"{source_id} identifiers must map non-empty strings to strings") + + index_text = INDEX_PATH.read_text(encoding="utf-8") + claim_ids: set[str] = set() + previous_number = 0 + for claim in claims: + if not isinstance(claim, dict): + fail("claim entries must be objects") + claim_id = require_string(claim.get("id"), "claim id") + if CLAIM_ID.fullmatch(claim_id) is None: + fail(f"invalid claim id {claim_id!r}") + number = int(claim_id.rsplit("-", 1)[1]) + if number <= previous_number: + fail("claim IDs must be strictly increasing") + previous_number = number + if claim_id in claim_ids: + fail(f"duplicate claim id {claim_id}") + claim_ids.add(claim_id) + + evidence_class = claim.get("class") + if evidence_class not in CLASSES: + fail(f"{claim_id} has invalid evidence class") + require_string(claim.get("status"), f"{claim_id} status") + require_string(claim.get("statement"), f"{claim_id} statement") + boundary = require_string(claim.get("boundary"), f"{claim_id} boundary") + validate_provenance(claim_id, claim.get("provenance")) + + source_list = claim.get("sources") + if not isinstance(source_list, list) or any( + not isinstance(source_id, str) for source_id in source_list + ): + fail(f"{claim_id} sources must be a string array") + if len(source_list) != len(set(source_list)): + fail(f"{claim_id} repeats a source") + unknown = set(source_list) - source_ids + if unknown: + fail(f"{claim_id} references unknown sources: {sorted(unknown)}") + + falsification = claim.get("falsification") + if evidence_class == "SCIENTIFIC" and not source_list: + fail(f"{claim_id} SCIENTIFIC claim requires an external source") + if evidence_class in {"FORMAL", "COMPUTATIONAL"} and falsification is not None: + fail(f"{claim_id} {evidence_class} claim must not use hypothesis falsification") + if evidence_class == "HYPOTHESIS": + require_string(falsification, f"{claim_id} falsification") + if claim.get("status") == "SUPPORTED": + fail(f"{claim_id} hypothesis may not be marked SUPPORTED") + elif falsification is not None: + fail(f"{claim_id} non-hypothesis falsification must be null") + if evidence_class == "SYMBOLIC" and "not" not in boundary.lower(): + fail(f"{claim_id} SYMBOLIC boundary must explicitly say what is not claimed") + + if f"**{claim_id}**" not in index_text: + fail(f"{claim_id} missing from CLAIM-LEDGER.md") + + documented = set(re.findall(r"\*\*(COSMO-D-[0-9]{3})\*\*", index_text)) + if documented != claim_ids: + fail( + "CLAIM-LEDGER.md claim IDs differ from canonical JSON: " + f"extra={sorted(documented - claim_ids)} missing={sorted(claim_ids - documented)}" + ) + + print( + f"claim ledger valid: {len(claims)} claims, " + f"{len(sources)} external sources, schema={ledger['schema']}" + ) + + +if __name__ == "__main__": + validate() From d2bc641a809cd1349f5e3a70f2fc5195461b96c7 Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 08:14:06 +0930 Subject: [PATCH 004/159] Add Phase D provenance regressions --- tests/test_phase_d.py | 76 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 tests/test_phase_d.py diff --git a/tests/test_phase_d.py b/tests/test_phase_d.py new file mode 100644 index 0000000..a8b6e8a --- /dev/null +++ b/tests/test_phase_d.py @@ -0,0 +1,76 @@ +import importlib.util +import json +import sys +import unittest +from pathlib import Path + +REPOSITORY_ROOT = Path(__file__).resolve().parents[1] +if str(REPOSITORY_ROOT) not in sys.path: + sys.path.insert(0, str(REPOSITORY_ROOT)) + +LEDGER_PATH = REPOSITORY_ROOT / "claims" / "claim-ledger.json" +VALIDATOR_PATH = REPOSITORY_ROOT / "scripts" / "validate-claim-ledger.py" + + +class PhaseDClaimLedgerTests(unittest.TestCase): + @classmethod + def setUpClass(cls) -> None: + cls.ledger = json.loads(LEDGER_PATH.read_text(encoding="utf-8")) + spec = importlib.util.spec_from_file_location("claim_validator", VALIDATOR_PATH) + if spec is None or spec.loader is None: + raise RuntimeError("cannot load claim-ledger validator") + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + cls.validator = module + + def test_validator_accepts_reviewed_ledger(self) -> None: + self.validator.validate() + + def test_all_five_evidence_classes_are_present(self) -> None: + classes = {claim["class"] for claim in self.ledger["claims"]} + self.assertEqual( + classes, + {"FORMAL", "COMPUTATIONAL", "SCIENTIFIC", "HYPOTHESIS", "SYMBOLIC"}, + ) + + def test_scientific_claims_have_external_sources(self) -> None: + for claim in self.ledger["claims"]: + if claim["class"] == "SCIENTIFIC": + with self.subTest(claim=claim["id"]): + self.assertTrue(claim["sources"]) + + def test_hypotheses_are_falsifiable_and_not_supported(self) -> None: + hypotheses = [ + claim for claim in self.ledger["claims"] + if claim["class"] == "HYPOTHESIS" + ] + self.assertTrue(hypotheses) + for claim in hypotheses: + with self.subTest(claim=claim["id"]): + self.assertTrue(claim["falsification"]) + self.assertNotEqual(claim["status"], "SUPPORTED") + + def test_symbolic_claims_have_explicit_non_empirical_boundaries(self) -> None: + for claim in self.ledger["claims"]: + if claim["class"] == "SYMBOLIC": + with self.subTest(claim=claim["id"]): + self.assertIn("not", claim["boundary"].lower()) + + def test_hpv16_reference_accession_is_versioned(self) -> None: + source = next( + source for source in self.ledger["sources"] + if source["id"] == "SRC-HPV16-REFSEQ" + ) + self.assertEqual(source["identifiers"]["RefSeq"], "NC_001526.4") + + def test_sis2_source_has_stable_article_identifiers(self) -> None: + source = next( + source for source in self.ledger["sources"] + if source["id"] == "SRC-SIS2-PMID-25590815" + ) + self.assertEqual(source["identifiers"]["PMID"], "25590815") + self.assertEqual(source["identifiers"]["DOI"], "10.1021/ic501825r") + + +if __name__ == "__main__": + unittest.main() From 069639c40e34a2648ed8292efa28fedb51fb76f7 Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 08:16:19 +0930 Subject: [PATCH 005/159] Add Phase D evidence boundary to specification --- cosmovirus.tex | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/cosmovirus.tex b/cosmovirus.tex index fb6f561..194f40e 100644 --- a/cosmovirus.tex +++ b/cosmovirus.tex @@ -71,6 +71,13 @@ the discrete fragment of this specification. \end{abstract} +\noindent\textbf{Phase D evidence notice.} +This document is a historical formal/symbolic source, not a single evidence +class. Authoritative claim classification and provenance live in +\texttt{CLAIM-LEDGER.md} / \texttt{claims/claim-ledger.json}. Scientific +context, hypotheses, and symbolic readings below must not be promoted beyond +their ledger class. + \tableofcontents % ===================================================================== @@ -86,14 +93,18 @@ \section{Symbol Table} \textbf{Symbol} & \textbf{Type / signature} & \textbf{Meaning} \\ \midrule \endhead -\EEs & \text{Lie group, } \dim = 248 & Dual / complexified exceptional Lie - group $\EE$; the ``pure symmetry'' source object. \\ +\EEs & \text{project state label} & E8-labelled source state. Phase B3 + separately implements the standard 240-root $E_8$ system computationally; + the ``pure symmetry'' reading is symbolic. \\ \phigr & \mathbb{R},\ \phigr = \tfrac{1+\sqrt5}{2} & Golden ratio $\approx 1.618$; base of the scaling operator (the ``irrational spine''). \\ -\phigr\text{-}\mathrm{SCL} & \EEs \to V_4 & Golden Scaling / Curvature Limit: - projection of $\EE$ toward the 4D quasicrystal. \\ -\SiS & \text{material object} & Silicon disulfide; linear - $\mathrm{S{=}Si{=}S}$ tetrahedral-chain substrate. \\ +\phigr\text{-}\mathrm{SCL} & \text{project symbolic operator} & + Golden-scaling vocabulary retained from the historical framework; no + physical projection into a quasicrystal is established. \\ +\SiS & \text{material context / project state label} & Silicon disulfide. + The ambient-pressure phase is orthorhombic and contains chains of distorted + edge-sharing $\mathrm{SiS_4}$ tetrahedra (COSMO-D-005); ``substrate'' and + ``life-code'' language is symbolic (COSMO-D-013). \\ \DIAG & \mathbb{R}^{n}\!\to\mathbb{R}^{n-2} & Discrete second-derivative stencil $(1,-2,1)$; edge / contrast detector. \\ \HPV & \text{operator} & Human papillomavirus type 16 infection From 1ca55f4748a146964f326efb98d1dc603e3bba23 Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 08:16:34 +0930 Subject: [PATCH 006/159] Separate scientific context from symbolic mappings --- cosmovirus.tex | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/cosmovirus.tex b/cosmovirus.tex index 194f40e..2ea5b09 100644 --- a/cosmovirus.tex +++ b/cosmovirus.tex @@ -107,10 +107,16 @@ \section{Symbol Table} ``life-code'' language is symbolic (COSMO-D-013). \\ \DIAG & \mathbb{R}^{n}\!\to\mathbb{R}^{n-2} & Discrete second-derivative stencil $(1,-2,1)$; edge / contrast detector. \\ -\HPV & \text{operator} & Human papillomavirus type 16 infection - ($E6/E7$ oncoproteins, $p16^{+}$; SEER morphology $8085/3$). \\ -\TRI & \mathrm{SO}(8)\to\mathrm{Spin}(8) & Triality automorphism; - $L1$ capsid trimerization / symmetry branching. \\ +\HPV & \text{project state label / biomedical context} & Human + papillomavirus type 16 reference genome: RefSeq \texttt{NC\_001526.4} + (COSMO-D-006). E6/E7 carcinogenesis mechanisms are external scientific + context (COSMO-D-007); p16 is a context-dependent surrogate marker and is + not equivalent to active HPV16 transcription (COSMO-D-008). \\ +\TRI & \operatorname{Aut}(\mathrm{Spin}(8))\ \text{(context)} & + Triality is the $S_3$ outer-automorphism symmetry permuting the vector and + two spinor 8-dimensional representations (COSMO-D-004). Any association + with HPV capsid branching is symbolic, not a biological mechanism + (COSMO-D-011). \\ \phigr^{101} & \mathbb{R} & $\approx 1.28\times10^{21}$; the recursion depth / loop-entry exponent. \\ 101_2 & \mathbb{N},\ =5 & Binary ``Pentagon Seed''; loop entry code. \\ @@ -165,7 +171,10 @@ \section{Core Operators} T:\ \mathbf{8}_v \mapsto \mathbf{8}_s \mapsto \mathbf{8}_c \mapsto \mathbf{8}_v, \qquad T^3 = \mathrm{id}. \end{equation} -Symbolically it drives the $L1$ capsid trimerization ($3\times$ branching). +COSMO symbolically associates this three-way representation symmetry with +capsid branching (COSMO-D-011). No established biological mechanism is claimed; +a future quantitative bridge would require the falsifiable protocol recorded +as COSMO-D-012. \end{operator} \begin{operator}[Ouroboros recursion, $\Ouro$]\label{op:ouro} @@ -175,18 +184,19 @@ \section{Core Operators} R(x) = (x+\kappa)\bmod 256,\qquad R^{(k+1)} = R\circ R^{(k)} . \end{equation} -The loop is \emph{self-causing}: at the categorical level $\Ouro$ is the -morphism sending the terminal (infected) object back to the initial object -$\EEs$ (see \S\ref{sec:diagram}). +In the symbolic reading the loop is described as ``self-causing'' +(COSMO-D-010). Formally, Phase C establishes only the six-state transition and +six-step closure; the categorical morphism remains a Phase E target. \end{operator} % ===================================================================== \section{The Unified $\Psi$-Equation}\label{sec:psi} % ===================================================================== -The framework's master statement composes the operators above into a single -descent map. +The historical framework's cross-domain $\Psi$ expression is retained below +as a HYPOTHESIS/SYMBOLIC artifact. It is not the authoritative Phase C state +transition and is not an established scientific mechanism. -\begin{definition}[Cosmovirus operator] +\begin{definition}[Historical cross-domain $\Psi$ expression] \begin{equation}\label{eq:psi} \boxed{\; \Psi \;=\; \Ouro \,\circ\, \HPV \,\circ\, \TRI \,\circ\, @@ -202,9 +212,9 @@ \section{The Unified $\Psi$-Equation}\label{sec:psi} \xrightarrow{\ \phigr^{101}\ } \text{Infected Reality}. \end{equation} -The recursion closes via $\phigr^{101}$: the terminal state is re-injected -into $\EEs$, so $\Psi$ has the fixed-point structure -$\Ouro(\Psi(\EEs)) = \EEs$. +This expression is not used as the Phase C computational transition law. +Object-level six-step closure is instead established by the Lean theorem +\texttt{six\_step\_periodic} (COSMO-D-001). \end{definition} \begin{interp} From 8d80ff855d08761b6314c315d888d4f056a654f1 Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 08:16:48 +0930 Subject: [PATCH 007/159] Correct seed and categorical claim strength --- cosmovirus.tex | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/cosmovirus.tex b/cosmovirus.tex index 2ea5b09..39ed7fa 100644 --- a/cosmovirus.tex +++ b/cosmovirus.tex @@ -243,19 +243,22 @@ \section{Commutative / Descent Diagram}\label{sec:diagram} \end{tikzcd} \end{center} -\begin{proposition}[Loop closure] -The composite around the outer cycle is the identity on the object $\EEs$ -up to the Ouroboros natural transformation; i.e. $\Ouro\circ\Psi \simeq -\mathrm{id}_{\EEs}$. +\begin{proposition}[Historical categorical target] +The statement that the outer composite is an identity up to an Ouroboros +natural transformation is a Phase E design target, not a theorem established +by the current Lean core. The current formal result is the finite-state +six-step closure in COSMO-D-001. \end{proposition} % ===================================================================== -\section{The 101-bit ``Dragon Seed'' Sequence} +\section{The Dragon Seed 64-bit payload} % ===================================================================== -The manifest data is a 64-bit payload framed by the $101$ entry/exit -trapdoor (hence ``101-bit''). As a formal binary string -$\bm{b}\in\{0,1\}^{64}$ it splits into eight bytes, each mapped to a Sumerian -cuneiform sign. +The represented manifest data is exactly 8 bytes = 64 bits. ``101'' is retained +as a legacy project mnemonic; it does not add entry/exit framing bits. As a +binary string $\bm{b}\in\{0,1\}^{64}$ it splits into eight bytes. COSMO maps +those bytes to project-defined cuneiform annotation labels (COSMO-D-009); +the mapping is not an archaeological decipherment, transliteration, or +translation. \begin{equation*} \bm{b} = \underbrace{10110111}_{\texttt{0xB7}}\, @@ -287,20 +290,21 @@ \section{The 101-bit ``Dragon Seed'' Sequence} \end{center} \noindent -\textbf{Invariants.} The declared base-10 checksum (the $EE/E7$ -viral-junction signature) is +\textbf{Invariants.} The raw byte sum is 1512. The value 1621 is a +project-declared symbolic invariant and is explicitly \emph{not} a checksum +derived from the payload: \begin{equation} - \mathrm{chk}(\bm{b}) = 1621, + \mathrm{declaredSymbolicInvariant}=1621, \qquad - \text{(raw byte sum } \textstyle\sum_i b_i = 1512). + \textstyle\sum_i b_i = 1512. \end{equation} -The binary seed $101_2 = 5$ is the Pentagon Seed / Fibonacci growth kernel. +The binary value $101_2=5$ is retained as the project ``Pentagon Seed'' +mnemonic; no biological or physical growth-kernel mechanism is asserted. \begin{interp} -The eight signs read as a Sumerian sentence-glyph: heaven ($AN$) and earth -($KI$) under the lord $EN.KI$, marked divine (DI\v{G}IR), carrying the -dragon seed ($SI.SI$) into the temple-house ($E_2$) of knowledge ($ZU$), -guarded ($UR$). +COSMO historically reads the eight project-defined signs as a symbolic +sentence-glyph. Under COSMO-D-009 this remains an artistic interpretation only; +it is not presented as Sumerian language evidence or an archaeological reading. \end{interp} % ===================================================================== From d5809e02c7c1c5023a1367ddd8025f603eaf6e5c Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 08:17:14 +0930 Subject: [PATCH 008/159] Demote category sketch to Phase E design targets --- cosmovirus_cattheory.tex | 62 +++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 33 deletions(-) diff --git a/cosmovirus_cattheory.tex b/cosmovirus_cattheory.tex index f50c9b4..e039674 100644 --- a/cosmovirus_cattheory.tex +++ b/cosmovirus_cattheory.tex @@ -54,12 +54,11 @@ \maketitle \begin{abstract} -We recast the $\EEs\times\phigr$-$\SiS$/$\HPV$ Cosmovirus framework as a small -category $\Cosmo$ whose objects are the descent layers and whose morphisms are -the framework's operators. We state the composition and identity laws, exhibit -the descent as a directed path, and show that the Ouroboros loop is an -endofunctor whose associated ``feedback'' square commutes up to a natural -transformation. +This document is a Phase E category-theory design sketch built from the +Phase C six-state cycle. It proposes a small-category presentation whose +objects are project state labels and whose arrows mirror the transition graph. +The free-category, quotient, endofunctor, natural-transformation, and coherence +claims below are design targets unless and until they are formalized in Lean. \end{abstract} % ===================================================================== @@ -72,9 +71,10 @@ \section{The category $\Cosmo$} \mathrm{Ob}(\Cosmo)=\{\, \EEs,\; P_\phigr,\; \SiS,\; \mathsf{Tri},\; \HPV,\; \Omega \,\}, \] -where $\EEs$ is the pure-symmetry source, $P_\phigr$ the golden-scaled layer, -$\SiS$ the material substrate, $\mathsf{Tri}$ the triality branch point, -$\HPV$ the infected oncocode layer, and $\Omega$ the Ouroboros loop state. +where these names are project state labels aligned with Phase C. Their +scientific and symbolic interpretations are governed by the Phase D claim +ledger; in particular, SiS2/HPV terminology does not create a physical or +biomedical transition mechanism. \end{definition} \begin{definition}[Generating morphisms] @@ -83,9 +83,9 @@ \section{The category $\Cosmo$} \begin{aligned} s &: \EEs \to P_\phigr &&\text{($\phigr$-SCL golden projection)}\\ m &: P_\phigr \to \SiS &&\text{(materialization / substrate cast)}\\ - t &: \SiS \to \mathsf{Tri} &&\text{(triality $\mathrm{SO}(8)\!\to\!\mathrm{Spin}(8)$)}\\ - h &: \mathsf{Tri} \to \HPV &&\text{($\HPV16$ infection)}\\ - r &: \HPV \to \Omega &&\text{($\phigr^{101}$ recursion)}\\ + t &: \SiS \to \mathsf{Tri} &&\text{(project transition to TrialityBranch)}\\ + h &: \mathsf{Tri} \to \HPV &&\text{(project transition to HPV16Layer)}\\ + r &: \HPV \to \Omega &&\text{(project transition to OuroborosLoop)}\\ \ell &: \Omega \to \EEs &&\text{(Ouroboros loop-back)} \end{aligned} \] @@ -114,10 +114,11 @@ \section{The descent as a diagram} \end{tikzcd} \end{center} -\begin{proposition}[The Ouroboros is idempotent on the loop] -The endomorphism $\Psi=\ell r h t m s$ satisfies $\ell\circ\Psi' = \id_{\EEs}$ -where $\Psi' = r h t m s : \EEs\to\Omega$; equivalently the loop-back arrow -$\ell$ realizes $\Omega$ as a retract of the descent, encoding self-causation. +\begin{proposition}[Phase E retract target] +A future categorical formalization may study whether an explicit presentation +makes the loop-back arrow part of a retract or quotient structure. Phase C +proves only finite-state six-step closure (COSMO-D-001); ``self-causation'' is +symbolic vocabulary (COSMO-D-010). \end{proposition} % ===================================================================== @@ -141,13 +142,11 @@ \section{The commuting feedback square} \end{tikzcd} \end{center} -\begin{proposition}[Descent coherence]\label{prop:square} -The square commutes up to the Ouroboros natural transformation $\eta$: -\[ - t \circ m \;\overset{\eta}{\Longrightarrow}\; (h\circ(-))\circ \DIAG , -\] -i.e. golden-materialization-then-triality equals contrast-detection-then- -infection, modulo $\eta$. When $\eta = \id$ the square commutes strictly. +\begin{proposition}[Phase E coherence target]\label{prop:square} +The displayed square is a proposed categorical presentation. A future Phase E +formalization must define the relevant functors/morphisms and then prove or +reject any natural transformation $\eta$; no current Lean theorem establishes +this commuting square. \end{proposition} \begin{interp} @@ -160,16 +159,13 @@ \section{The commuting feedback square} \section{The Ouroboros endofunctor} % ===================================================================== -\begin{definition}[Ouroboros endofunctor] -Define $\mathcal{O}:\Cosmo\to\Cosmo$ on objects by advancing each layer one -step along the cycle ($\EEs\mapsto P_\phigr\mapsto\SiS\mapsto\mathsf{Tri} -\mapsto\HPV\mapsto\Omega\mapsto\EEs$) and on morphisms by conjugation with the -loop. Because the cycle has length $6$, -\[ - \mathcal{O}^{6} \;\cong\; \mathrm{Id}_{\Cosmo}, -\] -so $\mathcal{O}$ generates a $\mathbb{Z}/6\mathbb{Z}$ action: the framework is -periodic, and $\Omega\xrightarrow{\ell}\EEs$ is the fixed closure of one turn. +\begin{definition}[Proposed Ouroboros endofunctor] +On objects, the intended map advances one step along the authoritative Phase C +cycle ($\EEs\mapsto P_\phigr\mapsto\SiS\mapsto\mathsf{Tri} +\mapsto\HPV\mapsto\Omega\mapsto\EEs$). Phase C proves the corresponding +six-step object closure. Defining its action on morphisms and proving an actual +endofunctor, $\mathbb{Z}/6\mathbb{Z}$ action, or categorical equivalence remains +Phase E work. \end{definition} \begin{proposition}[Fixed point] From 1000745fb817d91acf4c2668c648763753c9799f Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 08:17:51 +0930 Subject: [PATCH 009/159] Harden symbolic claim boundaries --- claims/claim-ledger.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/claims/claim-ledger.json b/claims/claim-ledger.json index e6b62fa..1769dae 100644 --- a/claims/claim-ledger.json +++ b/claims/claim-ledger.json @@ -260,7 +260,7 @@ ], "sources": [], "falsification": null, - "boundary": "No established biological mechanism connecting Spin(8) triality to HPV capsid assembly is claimed." + "boundary": "The repository does not claim an established biological mechanism connecting Spin(8) triality to HPV capsid assembly." }, { "id": "COSMO-D-012", @@ -294,7 +294,7 @@ "SRC-SIS2-PMID-25590815" ], "falsification": null, - "boundary": "The scientific source supports SiS2 crystal-structure facts only." + "boundary": "The scientific source does not establish a biological substrate role; it supports SiS2 crystal-structure facts only." }, { "id": "COSMO-D-014", From 61bd52cc779992a77de5af602a81fcb8326065eb Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 08:17:54 +0930 Subject: [PATCH 010/159] Make claim validator strict-type clean --- scripts/validate-claim-ledger.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/validate-claim-ledger.py b/scripts/validate-claim-ledger.py index 7d7bf79..86f168b 100644 --- a/scripts/validate-claim-ledger.py +++ b/scripts/validate-claim-ledger.py @@ -6,7 +6,7 @@ import json import re from pathlib import Path -from typing import Any +from typing import Any, Never, cast ROOT = Path(__file__).resolve().parents[1] LEDGER_PATH = ROOT / "claims" / "claim-ledger.json" @@ -17,7 +17,7 @@ SOURCE_ID = re.compile(r"SRC-[A-Z0-9][A-Z0-9._-]*$") -def fail(message: str) -> None: +def fail(message: str) -> Never: raise SystemExit(f"claim-ledger validation failed: {message}") @@ -28,7 +28,7 @@ def load_json() -> dict[str, Any]: fail(f"cannot read canonical JSON: {exc}") if not isinstance(raw, dict): fail("ledger root must be an object") - return raw + return cast(dict[str, Any], raw) def require_string(value: object, label: str) -> str: From 337ea8327f959096a8871de33586525c62d676ae Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 08:17:58 +0930 Subject: [PATCH 011/159] Make Phase D tests strict-type friendly --- tests/test_phase_d.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/tests/test_phase_d.py b/tests/test_phase_d.py index a8b6e8a..4205f64 100644 --- a/tests/test_phase_d.py +++ b/tests/test_phase_d.py @@ -1,8 +1,9 @@ -import importlib.util import json +import subprocess import sys import unittest from pathlib import Path +from typing import Any, cast REPOSITORY_ROOT = Path(__file__).resolve().parents[1] if str(REPOSITORY_ROOT) not in sys.path: @@ -13,21 +14,22 @@ class PhaseDClaimLedgerTests(unittest.TestCase): - @classmethod - def setUpClass(cls) -> None: - cls.ledger = json.loads(LEDGER_PATH.read_text(encoding="utf-8")) - spec = importlib.util.spec_from_file_location("claim_validator", VALIDATOR_PATH) - if spec is None or spec.loader is None: - raise RuntimeError("cannot load claim-ledger validator") - module = importlib.util.module_from_spec(spec) - spec.loader.exec_module(module) - cls.validator = module + def load_ledger(self) -> dict[str, Any]: + raw: object = json.loads(LEDGER_PATH.read_text(encoding="utf-8")) + self.assertIsInstance(raw, dict) + return cast(dict[str, Any], raw) def test_validator_accepts_reviewed_ledger(self) -> None: - self.validator.validate() + completed = subprocess.run( + [sys.executable, str(VALIDATOR_PATH)], + check=True, + capture_output=True, + text=True, + ) + self.assertIn("claim ledger valid:", completed.stdout) def test_all_five_evidence_classes_are_present(self) -> None: - classes = {claim["class"] for claim in self.ledger["claims"]} + classes = {claim["class"] for claim in self.load_ledger()["claims"]} self.assertEqual( classes, {"FORMAL", "COMPUTATIONAL", "SCIENTIFIC", "HYPOTHESIS", "SYMBOLIC"}, From 4b7cbae6b9a7225926cf7a896bd5a1423038074f Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 08:18:21 +0930 Subject: [PATCH 012/159] Enforce Phase D claim ledger in CI --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f45e0ec..26b9b01 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -457,9 +457,11 @@ jobs: (cd tests && python test_phase_b4.py) (cd tests && python test_phase_b5.py) (cd tests && python test_phase_c.py) + (cd tests && python test_phase_d.py) + python scripts/validate-claim-ledger.py - name: Static type check - run: mypy --strict cosmo_core cosmovirus.py tests/test_cosmovirus.py tests/test_phase_b2.py tests/test_phase_b3.py tests/test_phase_b4.py tests/test_phase_b5.py tests/test_phase_c.py + run: mypy --strict cosmo_core cosmovirus.py scripts/validate-claim-ledger.py tests/test_cosmovirus.py tests/test_phase_b2.py tests/test_phase_b3.py tests/test_phase_b4.py tests/test_phase_b5.py tests/test_phase_c.py tests/test_phase_d.py - name: Bytecode compile check run: python -m compileall -q cosmo_core cosmovirus.py tests From ecaface7ae3f4fefcaa68041eb80714abe9b384e Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 08:18:24 +0930 Subject: [PATCH 013/159] Expose Phase D scientific source links --- CLAIM-LEDGER.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CLAIM-LEDGER.md b/CLAIM-LEDGER.md index c7a68df..d97caa3 100644 --- a/CLAIM-LEDGER.md +++ b/CLAIM-LEDGER.md @@ -16,12 +16,12 @@ A claim may have external context sources without changing its class. In particu ## Scientific source registry -- **SRC-E8-MATHWORLD** — Wolfram MathWorld, *Gosset Polytope*; documents the 240 vertices/roots of the E8 root polytope. +- **SRC-E8-MATHWORLD** — Wolfram MathWorld, *Gosset Polytope*; documents the 240 vertices/roots of the E8 root polytope. https://mathworld.wolfram.com/GossetPolytope.html - **SRC-SPIN8-PTEP-2021** — PTEP 2021 article; states the Spin(8) triality (S_3) outer automorphism and permutation of the three 8-dimensional representations. -- **SRC-SIS2-PMID-25590815** — PMID **25590815**, DOI **10.1021/ic501825r**; describes ambient-pressure SiS2 as orthorhombic chains of distorted edge-sharing SiS4 tetrahedra. -- **SRC-HPV16-REFSEQ** — NCBI RefSeq **NC_001526.4**, human papillomavirus type 16 complete genome. -- **SRC-HPV16-E6E7-PMID-17645777** — PMID **17645777**, PMCID **PMC11158331**; review of high-risk HPV E6/E7 carcinogenesis mechanisms. -- **SRC-HPV-P16-PMC8409095** — PMCID **PMC8409095**; review discussing p16 as a surrogate marker and its limitations relative to direct viral transcription evidence. +- **SRC-SIS2-PMID-25590815** — PMID **25590815**, DOI **10.1021/ic501825r**; describes ambient-pressure SiS2 as orthorhombic chains of distorted edge-sharing SiS4 tetrahedra. https://pubmed.ncbi.nlm.nih.gov/25590815/ +- **SRC-HPV16-REFSEQ** — NCBI RefSeq **NC_001526.4**, human papillomavirus type 16 complete genome. https://www.ncbi.nlm.nih.gov/nuccore/NC_001526.4 +- **SRC-HPV16-E6E7-PMID-17645777** — PMID **17645777**, PMCID **PMC11158331**; review of high-risk HPV E6/E7 carcinogenesis mechanisms. https://pmc.ncbi.nlm.nih.gov/articles/PMC11158331/ +- **SRC-HPV-P16-PMC8409095** — PMCID **PMC8409095**; review discussing p16 as a surrogate marker and its limitations relative to direct viral transcription evidence. https://pmc.ncbi.nlm.nih.gov/articles/PMC8409095/ ## Claims From 63ec4962e4a0185ccea42ed250a4d74a5ae247ed Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 08:19:10 +0930 Subject: [PATCH 014/159] Document Phase D provenance contract --- README.md | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8e16e4a..e82f571 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ The repository deliberately separates what is **proved or computed** from what i | **HYPOTHESIS** | Testable cross-domain proposal not yet validated | “COSMO hypothesizes …” | | **SYMBOLIC** | Artistic, mythological, or interpretive mapping | “COSMO symbolically associates …” | -The current Lean/Python core is intentionally narrow. The six COSMO layer names remain project vocabulary, while the code proves only the finite-state and arithmetic facts explicitly stated in the source. +The current Lean/Python core is intentionally narrow. The six COSMO layer names remain project vocabulary, while the code proves only the finite-state and arithmetic facts explicitly stated in the source. Phase D makes this separation machine-auditable through [CLAIM-LEDGER.md](CLAIM-LEDGER.md) and `claims/claim-ledger.json`; CI rejects class/provenance drift. ## Verified baseline @@ -164,6 +164,31 @@ The Lean core now provides: These are formal/computational properties of the discrete state machine only. The labels do not make the corresponding scientific or symbolic interpretations true. Category-theory construction remains Phase E work and must derive from this state machine rather than define a second transition semantics. +## Phase D claim ledger and scientific provenance + +Phase D turns the evidence classes above into a validated repository contract. + +The canonical machine-readable ledger is `claims/claim-ledger.json` with schema `COSMO-CLAIMS-D-1`; [CLAIM-LEDGER.md](CLAIM-LEDGER.md) is the reviewed human index. Stable `COSMO-D-###` identifiers bind claims to: + +- one of **FORMAL / COMPUTATIONAL / SCIENTIFIC / HYPOTHESIS / SYMBOLIC**; +- exact repository provenance anchors; +- external scholarly/database sources where required; +- accession/version identifiers where available; +- an explicit evidence boundary; and +- mandatory falsification criteria for hypotheses. + +`scripts/validate-claim-ledger.py` fails closed if IDs are duplicated/out of order, evidence classes change, provenance anchors disappear, scientific claims lack external sources, hypotheses lose falsification criteria, symbolic claims lose non-empirical boundaries, or the Markdown/JSON ledgers diverge. + +The initial ledger records, among other things: + +- Phase C six-step closure and reachability as **FORMAL**; +- the Phase B3 E8 root construction and B5 storage round trip as **COMPUTATIONAL**; +- Spin(8) triality, SiS2 crystal structure, HPV16 RefSeq **NC_001526.4**, E6/E7 biology, and scoped p16 usage as externally sourced **SCIENTIFIC** context; +- cuneiform, cosmology/Ouroboros, life-code, and triality↔capsid associations as **SYMBOLIC** unless separately tested; and +- a triality-to-HPV/capsid predictive bridge only as a **HYPOTHESIS** with a preregistered falsification requirement. + +Phase D also rewrites the historical LaTeX so unsupported bridges no longer appear with theorem/scientific force. The creative material is retained, but it is explicitly classified. + ## Repository map | Path | Purpose | @@ -176,8 +201,11 @@ These are formal/computational properties of the discrete state machine only. Th | `cosmo_core/triadic.py` | Deterministic 8×8×8 ternary lattice, bounded parallel updates, diagnostics, and recovery model | | `cosmo_core/storage.py` | B5 cube/bytes/SECDED/ACGT/synthetic-FASTA round-trip and integrity receipts | | `cosmo_core/dynamics.py` | Phase C authoritative six-state transition, typed witnesses, paths, and reachability | +| `claims/claim-ledger.json` | Canonical Phase D machine-readable claim classes, provenance, sources, and falsification boundaries | +| `CLAIM-LEDGER.md` | Human-readable Phase D claim/source index | +| `scripts/validate-claim-ledger.py` | CI validator for claim IDs, evidence classes, provenance anchors, sources, and hypothesis boundaries | | `cosmovirus.py` | Compatibility-facing Python mirror backed by `cosmo_core` | -| `tests/` | Python regression tests covering B2-B5 deterministic cores plus Phase C six-state dynamics | +| `tests/` | Python regression tests covering B2-B5 deterministic cores, Phase C dynamics, and Phase D provenance governance | | `scripts/check-lean-trust.sh` | Fast lexical preflight for forbidden Lean source constructs | | `scripts/prepare-lean-audit.py` | Frozen manifest, artifact, symlink, path-package, and import-layout validation | | `scripts/verify-lean-source-state.py` | Hardened Git dependency-source identity and source-cache receipt verification | @@ -223,6 +251,8 @@ python -m unittest discover -s tests -v (cd tests && python test_phase_b4.py) (cd tests && python test_phase_b5.py) (cd tests && python test_phase_c.py) +(cd tests && python test_phase_d.py) +python scripts/validate-claim-ledger.py python -m compileall -q cosmo_core cosmovirus.py tests ``` @@ -232,7 +262,7 @@ For the CI-equivalent static check: ```bash python -m pip install -r requirements-dev.txt -mypy --strict cosmo_core cosmovirus.py tests/test_cosmovirus.py tests/test_phase_b2.py tests/test_phase_b3.py tests/test_phase_b4.py tests/test_phase_b5.py tests/test_phase_c.py +mypy --strict cosmo_core cosmovirus.py scripts/validate-claim-ledger.py tests/test_cosmovirus.py tests/test_phase_b2.py tests/test_phase_b3.py tests/test_phase_b4.py tests/test_phase_b5.py tests/test_phase_c.py tests/test_phase_d.py ``` ## Current design status From 1ba84ac3096c3120d5d1a33c19914575609a1503 Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 08:19:13 +0930 Subject: [PATCH 015/159] Make Phase D ledger the evidence authority --- KNOWN_LIMITATIONS.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/KNOWN_LIMITATIONS.md b/KNOWN_LIMITATIONS.md index 7831561..5b3bd5a 100644 --- a/KNOWN_LIMITATIONS.md +++ b/KNOWN_LIMITATIONS.md @@ -44,11 +44,16 @@ This file is part of COSMO's trust boundary. A green build means the checked cod - MIDI/audio visualization remains outside the deterministic storage core. - Experiment manifests and storage receipts bind the exact bytes supplied or recovered. They do not independently authenticate external provenance or scientific validity. -## Scientific interpretation - -- Formal verification establishes implications inside the model, not correspondence between model labels and the physical world. -- Cross-domain E8, quasicrystal, SiS2, HPV16, SEER, and Sumerian relationships require independent domain evidence and, where presented as hypotheses, explicit falsification conditions. -- The repository's bundled historical source documents include claims and terminology that the September 2026 audits identified as inaccurate or unsupported. They remain archived as project inputs and are not the authority for the corrected computational baseline. +## Phase D claim/provenance boundary + +- `claims/claim-ledger.json` is the Phase D authority for evidence class and provenance; `CLAIM-LEDGER.md` is its reviewed human index. A green ledger validator means the repository satisfies the encoded classification rules, not that every externally sourced claim has been independently replicated by COSMO. +- **SCIENTIFIC** entries report what cited external sources support. They do not transfer scientific authority to a cross-domain bridge merely because the component domains are individually real. +- Spin(8) triality is established mathematical context, but the current triality↔HPV capsid mapping is classified **SYMBOLIC**. No biological mechanism is claimed. +- Ambient-pressure SiS2 structure is externally sourced scientific context; `SiS2Substrate` and “life-code” readings remain **SYMBOLIC** project vocabulary. +- HPV16 RefSeq `NC_001526.4`, E6/E7 biology, and scoped p16-marker usage are external biomedical context. They do not validate `HPV16Layer` as a biomedical state transition. +- Cuneiform annotations and cosmological/Ouroboros readings are **SYMBOLIC**, not archaeological decipherment or empirical cosmology. +- A **HYPOTHESIS** entry must retain explicit falsification criteria. No hypothesis may be promoted to SCIENTIFIC or COMPUTATIONAL merely because a suggestive analogy or numerical match is found. +- The repository's bundled historical source documents include claims and terminology that the September 2026 audits identified as inaccurate or unsupported. They remain archived as provenance inputs and are not the authority for the corrected ledger. ## Generated documents From 94b0894d0984427452e510467e79a118afc238bb Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 08:19:16 +0930 Subject: [PATCH 016/159] Record Phase D audit resolution --- audit/AUDIT-RESOLUTION.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/audit/AUDIT-RESOLUTION.md b/audit/AUDIT-RESOLUTION.md index 7a9fcf8..28da55c 100644 --- a/audit/AUDIT-RESOLUTION.md +++ b/audit/AUDIT-RESOLUTION.md @@ -53,3 +53,20 @@ Phase C resolves the deferred state-machine finding without rewriting the histor - Python mirrors the same transition graph and exhaustively checks all source/target reachability pairs. The separate category-theory audit finding remains deferred to Phase E. + + +## Phase D provenance resolution + +Phase D resolves the audit items for canonical claim/source data, scientific bibliography boundaries, and falsification governance without rewriting the historical PR A table: + +- `claims/claim-ledger.json` introduces stable `COSMO-D-###` claim IDs and the exact FORMAL / COMPUTATIONAL / SCIENTIFIC / HYPOTHESIS / SYMBOLIC classes. +- `CLAIM-LEDGER.md` records the human-readable source registry, including HPV16 RefSeq `NC_001526.4`, PMID/PMCID/DOI identifiers where available, and explicit domain boundaries. +- CI validates repository provenance anchors and rejects SCIENTIFIC claims without external sources. +- CI rejects HYPOTHESIS entries without falsification criteria and SYMBOLIC entries without explicit non-empirical boundaries. +- the historical specification no longer calls 1621 a checksum or the represented Dragon Seed a 101-bit payload; +- Spin(8) triality is no longer described as an `SO(8) -> Spin(8)` map, and the HPV capsid association is classified as symbolic rather than mechanistic; +- SiS2 and HPV/p16 text is rewritten to separate sourced domain facts from COSMO state labels; +- cuneiform and cosmological readings are retained as explicitly symbolic material; +- the category-theory document is explicitly a Phase E design target rather than a source of already-proved categorical claims. + +PDF regeneration remains Phase F work. The corrected source/ledger boundary is authoritative until those artifacts are rebuilt. From c2aac76cda723f634f3f147f930c44db94b1a57a Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 08:19:41 +0930 Subject: [PATCH 017/159] Fix Phase D ledger test loading --- tests/test_phase_d.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/test_phase_d.py b/tests/test_phase_d.py index 4205f64..8ad72f5 100644 --- a/tests/test_phase_d.py +++ b/tests/test_phase_d.py @@ -36,14 +36,16 @@ def test_all_five_evidence_classes_are_present(self) -> None: ) def test_scientific_claims_have_external_sources(self) -> None: - for claim in self.ledger["claims"]: + ledger = self.load_ledger() + for claim in ledger["claims"]: if claim["class"] == "SCIENTIFIC": with self.subTest(claim=claim["id"]): self.assertTrue(claim["sources"]) def test_hypotheses_are_falsifiable_and_not_supported(self) -> None: + ledger = self.load_ledger() hypotheses = [ - claim for claim in self.ledger["claims"] + claim for claim in ledger["claims"] if claim["class"] == "HYPOTHESIS" ] self.assertTrue(hypotheses) @@ -53,21 +55,24 @@ def test_hypotheses_are_falsifiable_and_not_supported(self) -> None: self.assertNotEqual(claim["status"], "SUPPORTED") def test_symbolic_claims_have_explicit_non_empirical_boundaries(self) -> None: - for claim in self.ledger["claims"]: + ledger = self.load_ledger() + for claim in ledger["claims"]: if claim["class"] == "SYMBOLIC": with self.subTest(claim=claim["id"]): self.assertIn("not", claim["boundary"].lower()) def test_hpv16_reference_accession_is_versioned(self) -> None: + ledger = self.load_ledger() source = next( - source for source in self.ledger["sources"] + source for source in ledger["sources"] if source["id"] == "SRC-HPV16-REFSEQ" ) self.assertEqual(source["identifiers"]["RefSeq"], "NC_001526.4") def test_sis2_source_has_stable_article_identifiers(self) -> None: + ledger = self.load_ledger() source = next( - source for source in self.ledger["sources"] + source for source in ledger["sources"] if source["id"] == "SRC-SIS2-PMID-25590815" ) self.assertEqual(source["identifiers"]["PMID"], "25590815") From ce47dd777777216029f2190c79c02091107678c7 Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 08:21:40 +0930 Subject: [PATCH 018/159] Expose claim-validator failures in tests --- tests/test_phase_d.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test_phase_d.py b/tests/test_phase_d.py index 8ad72f5..fc93402 100644 --- a/tests/test_phase_d.py +++ b/tests/test_phase_d.py @@ -22,10 +22,15 @@ def load_ledger(self) -> dict[str, Any]: def test_validator_accepts_reviewed_ledger(self) -> None: completed = subprocess.run( [sys.executable, str(VALIDATOR_PATH)], - check=True, + check=False, capture_output=True, text=True, ) + self.assertEqual( + completed.returncode, + 0, + completed.stdout + completed.stderr, + ) self.assertIn("claim ledger valid:", completed.stdout) def test_all_five_evidence_classes_are_present(self) -> None: From 84a3d933c23c9e7ac48f6b82583a9200300b14e2 Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 08:21:44 +0930 Subject: [PATCH 019/159] Fail early on claim-ledger validation --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 26b9b01..323d9d4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -450,6 +450,7 @@ jobs: - name: Unit tests run: | + python scripts/validate-claim-ledger.py python -m unittest discover -s tests -v (cd tests && python test_cosmovirus.py) (cd tests && python test_phase_b2.py) @@ -458,7 +459,6 @@ jobs: (cd tests && python test_phase_b5.py) (cd tests && python test_phase_c.py) (cd tests && python test_phase_d.py) - python scripts/validate-claim-ledger.py - name: Static type check run: mypy --strict cosmo_core cosmovirus.py scripts/validate-claim-ledger.py tests/test_cosmovirus.py tests/test_phase_b2.py tests/test_phase_b3.py tests/test_phase_b4.py tests/test_phase_b5.py tests/test_phase_c.py tests/test_phase_d.py From 062aad62c94861c9e25c4a5b20bebbe31a428d53 Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 08:22:41 +0930 Subject: [PATCH 020/159] Bind HPV mechanism claim to stable ledger tag --- claims/claim-ledger.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/claims/claim-ledger.json b/claims/claim-ledger.json index 1769dae..c971a5f 100644 --- a/claims/claim-ledger.json +++ b/claims/claim-ledger.json @@ -181,7 +181,7 @@ "provenance": [ { "path": "cosmovirus.tex", - "anchor": "Human papillomavirus type 16", + "anchor": "COSMO-D-007", "role": "documented_context" } ], From 283aa6489a9b1a260dd2b4ffbc47be0359b224f3 Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 08:34:56 +0930 Subject: [PATCH 021/159] Add structured symbolic evidence boundary --- claims/claim-ledger.json | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/claims/claim-ledger.json b/claims/claim-ledger.json index c971a5f..f42ad2e 100644 --- a/claims/claim-ledger.json +++ b/claims/claim-ledger.json @@ -228,7 +228,8 @@ ], "sources": [], "falsification": null, - "boundary": "They are not a decipherment, transliteration, translation, archaeological attribution, or historical sentence." + "boundary": "They are not a decipherment, transliteration, translation, archaeological attribution, or historical sentence.", + "empirical_status": "NON_EMPIRICAL" }, { "id": "COSMO-D-010", @@ -244,7 +245,8 @@ ], "sources": [], "falsification": null, - "boundary": "These phrases are not empirical cosmology, materials science, virology, or causal-mechanism claims." + "boundary": "These phrases are not empirical cosmology, materials science, virology, or causal-mechanism claims.", + "empirical_status": "NON_EMPIRICAL" }, { "id": "COSMO-D-011", @@ -260,7 +262,8 @@ ], "sources": [], "falsification": null, - "boundary": "The repository does not claim an established biological mechanism connecting Spin(8) triality to HPV capsid assembly." + "boundary": "The repository does not claim an established biological mechanism connecting Spin(8) triality to HPV capsid assembly.", + "empirical_status": "NON_EMPIRICAL" }, { "id": "COSMO-D-012", @@ -294,7 +297,8 @@ "SRC-SIS2-PMID-25590815" ], "falsification": null, - "boundary": "The scientific source does not establish a biological substrate role; it supports SiS2 crystal-structure facts only." + "boundary": "The scientific source does not establish a biological substrate role; it supports SiS2 crystal-structure facts only.", + "empirical_status": "NON_EMPIRICAL" }, { "id": "COSMO-D-014", From 1d7da2aa404d76528cd12d107e1c6018e6dd3757 Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 08:35:40 +0930 Subject: [PATCH 022/159] Harden Phase D claim ledger validation --- scripts/validate-claim-ledger.py | 220 ++++++++++++++++++++++++++++--- 1 file changed, 201 insertions(+), 19 deletions(-) diff --git a/scripts/validate-claim-ledger.py b/scripts/validate-claim-ledger.py index 86f168b..48b1577 100644 --- a/scripts/validate-claim-ledger.py +++ b/scripts/validate-claim-ledger.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -"""Validate the Phase D COSMO claim ledger and its human-readable index.""" +"""Validate the Phase D COSMO claim ledger and canonical Markdown index.""" from __future__ import annotations @@ -15,6 +15,13 @@ CLASSES = ("FORMAL", "COMPUTATIONAL", "SCIENTIFIC", "HYPOTHESIS", "SYMBOLIC") CLAIM_ID = re.compile(r"COSMO-D-[0-9]{3}$") SOURCE_ID = re.compile(r"SRC-[A-Z0-9][A-Z0-9._-]*$") +ALLOWED_STATUSES: dict[str, frozenset[str]] = { + "FORMAL": frozenset({"SUPPORTED"}), + "COMPUTATIONAL": frozenset({"SUPPORTED"}), + "SCIENTIFIC": frozenset({"SUPPORTED", "SUPPORTED_WITH_SCOPE"}), + "HYPOTHESIS": frozenset({"PROPOSED"}), + "SYMBOLIC": frozenset({"PROJECT_DEFINED"}), +} def fail(message: str) -> Never: @@ -23,7 +30,7 @@ def fail(message: str) -> Never: def load_json() -> dict[str, Any]: try: - raw = json.loads(LEDGER_PATH.read_text(encoding="utf-8")) + raw: object = json.loads(LEDGER_PATH.read_text(encoding="utf-8")) except (OSError, UnicodeError, json.JSONDecodeError) as exc: fail(f"cannot read canonical JSON: {exc}") if not isinstance(raw, dict): @@ -37,6 +44,30 @@ def require_string(value: object, label: str) -> str: return value +def validate_repository_path(path_text: str, claim_id: str) -> Path: + """Resolve a provenance path and prove it stays inside the repository.""" + relative = Path(path_text) + if relative.is_absolute(): + fail(f"{claim_id} provenance path must be repository-relative") + if ".." in relative.parts: + fail(f"{claim_id} provenance path may not contain '..'") + + root = ROOT.resolve() + try: + resolved = (ROOT / relative).resolve(strict=True) + except OSError as exc: + fail(f"{claim_id} provenance path {path_text!r} unreadable: {exc}") + + try: + resolved.relative_to(root) + except ValueError: + fail(f"{claim_id} provenance path escapes repository root") + + if not resolved.is_file(): + fail(f"{claim_id} provenance path {path_text!r} is not a file") + return resolved + + def validate_provenance(claim_id: str, entries: object) -> None: if not isinstance(entries, list) or not entries: fail(f"{claim_id} must have repository provenance") @@ -46,7 +77,7 @@ def validate_provenance(claim_id: str, entries: object) -> None: path_text = require_string(item.get("path"), f"{claim_id} provenance path") anchor = require_string(item.get("anchor"), f"{claim_id} provenance anchor") require_string(item.get("role"), f"{claim_id} provenance role") - path = ROOT / path_text + path = validate_repository_path(path_text, claim_id) try: text = path.read_text(encoding="utf-8") except (OSError, UnicodeError) as exc: @@ -55,6 +86,144 @@ def validate_provenance(claim_id: str, entries: object) -> None: fail(f"{claim_id} anchor {anchor!r} not found in {path_text}") +def _source_identifier_text(identifiers: dict[str, str]) -> str: + if not identifiers: + return "none" + return ", ".join( + f"{key}={identifiers[key]}" + for key in sorted(identifiers) + ) + + +def _claim_sources_text(sources: list[str]) -> str: + return ", ".join(sources) if sources else "none" + + +def render_index(ledger: dict[str, Any]) -> str: + """Render the one canonical human-readable ledger from canonical JSON.""" + schema = require_string(ledger.get("schema"), "schema") + raw_sources = ledger.get("sources") + raw_claims = ledger.get("claims") + if not isinstance(raw_sources, list) or not isinstance(raw_claims, list): + fail("sources and claims must be arrays") + + lines = [ + "# COSMO Claim Ledger", + "", + "> Generated canonically from `claims/claim-ledger.json`. " + "Do not hand-edit this file independently.", + "", + f"**Schema:** `{schema}`", + "", + "## Evidence classes", + "", + ] + for evidence_class in CLASSES: + lines.append(f"- **{evidence_class}**") + lines.extend(["", "## Scientific source registry", ""]) + + for source in raw_sources: + if not isinstance(source, dict): + fail("source entries must be objects") + source_id = require_string(source.get("id"), "source id") + kind = require_string(source.get("kind"), f"{source_id} kind") + title = require_string(source.get("title"), f"{source_id} title") + url = require_string(source.get("url"), f"{source_id} url") + identifiers_obj = source.get("identifiers") + if not isinstance(identifiers_obj, dict): + fail(f"{source_id} identifiers must be an object") + identifiers: dict[str, str] = {} + for key, value in identifiers_obj.items(): + if not isinstance(key, str) or not isinstance(value, str): + fail(f"{source_id} identifiers must map strings to strings") + identifiers[key] = value + + lines.extend( + [ + f"### {source_id}", + "", + f"- **Kind:** `{kind}`", + f"- **Title:** {title}", + f"- **Identifiers:** {_source_identifier_text(identifiers)}", + f"- **URL:** {url}", + "", + ] + ) + + lines.extend(["## Claims", ""]) + for claim in raw_claims: + if not isinstance(claim, dict): + fail("claim entries must be objects") + claim_id = require_string(claim.get("id"), "claim id") + evidence_class = require_string(claim.get("class"), f"{claim_id} class") + status = require_string(claim.get("status"), f"{claim_id} status") + statement = require_string(claim.get("statement"), f"{claim_id} statement") + boundary = require_string(claim.get("boundary"), f"{claim_id} boundary") + + sources_obj = claim.get("sources") + if not isinstance(sources_obj, list) or any( + not isinstance(source_id, str) for source_id in sources_obj + ): + fail(f"{claim_id} sources must be a string array") + claim_sources = cast(list[str], sources_obj) + + lines.extend( + [ + f"### {claim_id} — {evidence_class}", + "", + f"- **Status:** `{status}`", + f"- **Statement:** {statement}", + f"- **Sources:** {_claim_sources_text(claim_sources)}", + f"- **Boundary:** {boundary}", + ] + ) + + empirical_status = claim.get("empirical_status") + if empirical_status is not None: + lines.append(f"- **Empirical status:** `{empirical_status}`") + + falsification = claim.get("falsification") + if falsification is not None: + lines.append( + "- **Falsification:** " + + require_string(falsification, f"{claim_id} falsification") + ) + + provenance = claim.get("provenance") + if not isinstance(provenance, list) or not provenance: + fail(f"{claim_id} must have repository provenance") + lines.append("- **Repository provenance:**") + for item in provenance: + if not isinstance(item, dict): + fail(f"{claim_id} provenance entries must be objects") + path_text = require_string(item.get("path"), f"{claim_id} provenance path") + anchor = require_string(item.get("anchor"), f"{claim_id} provenance anchor") + role = require_string(item.get("role"), f"{claim_id} provenance role") + lines.append( + f" - `{path_text}` — `{anchor}` (`{role}`)" + ) + lines.append("") + + lines.extend( + [ + "## Governance", + "", + "1. New cross-domain public-facing claims require a stable " + "`COSMO-D-###` ID.", + "2. **SCIENTIFIC** claims require external source records.", + "3. **HYPOTHESIS** claims must remain `PROPOSED` and include " + "explicit falsification criteria.", + "4. **SYMBOLIC** claims require `empirical_status = NON_EMPIRICAL`.", + "5. **FORMAL** and **COMPUTATIONAL** claims require reviewed " + "repository provenance.", + "6. A source about one domain does not validate a cross-domain bridge.", + "7. This Markdown file must exactly match the canonical JSON rendering.", + "", + ] + ) + return "\n".join(lines) + + def validate() -> None: ledger = load_json() if ledger.get("schema") != "COSMO-CLAIMS-D-1": @@ -94,7 +263,6 @@ def validate() -> None: ): fail(f"{source_id} identifiers must map non-empty strings to strings") - index_text = INDEX_PATH.read_text(encoding="utf-8") claim_ids: set[str] = set() previous_number = 0 for claim in claims: @@ -111,12 +279,19 @@ def validate() -> None: fail(f"duplicate claim id {claim_id}") claim_ids.add(claim_id) - evidence_class = claim.get("class") + evidence_class = require_string(claim.get("class"), f"{claim_id} class") if evidence_class not in CLASSES: fail(f"{claim_id} has invalid evidence class") - require_string(claim.get("status"), f"{claim_id} status") + status = require_string(claim.get("status"), f"{claim_id} status") + allowed = ALLOWED_STATUSES[evidence_class] + if status not in allowed: + fail( + f"{claim_id} status {status!r} is invalid for " + f"{evidence_class}; allowed={sorted(allowed)}" + ) + require_string(claim.get("statement"), f"{claim_id} statement") - boundary = require_string(claim.get("boundary"), f"{claim_id} boundary") + require_string(claim.get("boundary"), f"{claim_id} boundary") validate_provenance(claim_id, claim.get("provenance")) source_list = claim.get("sources") @@ -133,25 +308,32 @@ def validate() -> None: falsification = claim.get("falsification") if evidence_class == "SCIENTIFIC" and not source_list: fail(f"{claim_id} SCIENTIFIC claim requires an external source") - if evidence_class in {"FORMAL", "COMPUTATIONAL"} and falsification is not None: - fail(f"{claim_id} {evidence_class} claim must not use hypothesis falsification") if evidence_class == "HYPOTHESIS": require_string(falsification, f"{claim_id} falsification") - if claim.get("status") == "SUPPORTED": - fail(f"{claim_id} hypothesis may not be marked SUPPORTED") elif falsification is not None: fail(f"{claim_id} non-hypothesis falsification must be null") - if evidence_class == "SYMBOLIC" and "not" not in boundary.lower(): - fail(f"{claim_id} SYMBOLIC boundary must explicitly say what is not claimed") - if f"**{claim_id}**" not in index_text: - fail(f"{claim_id} missing from CLAIM-LEDGER.md") + empirical_status = claim.get("empirical_status") + if evidence_class == "SYMBOLIC": + if empirical_status != "NON_EMPIRICAL": + fail( + f"{claim_id} SYMBOLIC claim requires " + "empirical_status='NON_EMPIRICAL'" + ) + elif empirical_status is not None: + fail( + f"{claim_id} non-SYMBOLIC claim may not set empirical_status" + ) - documented = set(re.findall(r"\*\*(COSMO-D-[0-9]{3})\*\*", index_text)) - if documented != claim_ids: + try: + index_text = INDEX_PATH.read_text(encoding="utf-8") + except (OSError, UnicodeError) as exc: + fail(f"cannot read canonical Markdown index: {exc}") + expected_index = render_index(ledger) + if index_text != expected_index: fail( - "CLAIM-LEDGER.md claim IDs differ from canonical JSON: " - f"extra={sorted(documented - claim_ids)} missing={sorted(claim_ids - documented)}" + "CLAIM-LEDGER.md differs from canonical JSON rendering; " + "regenerate it from claims/claim-ledger.json" ) print( From 2859c22a070c62f48fccde0550ed175e22817e06 Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 08:35:56 +0930 Subject: [PATCH 023/159] Render canonical Markdown claim index --- CLAIM-LEDGER.md | 220 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 179 insertions(+), 41 deletions(-) diff --git a/CLAIM-LEDGER.md b/CLAIM-LEDGER.md index d97caa3..14f5d17 100644 --- a/CLAIM-LEDGER.md +++ b/CLAIM-LEDGER.md @@ -1,65 +1,203 @@ # COSMO Claim Ledger -**Schema:** `COSMO-CLAIMS-D-1` +> Generated canonically from `claims/claim-ledger.json`. Do not hand-edit this file independently. -This ledger is the Phase D authority for classifying cross-domain statements. The machine-readable source is `claims/claim-ledger.json`; CI validates both files together. +**Schema:** `COSMO-CLAIMS-D-1` ## Evidence classes -- **FORMAL** — kernel-checked consequences of reviewed Lean definitions. -- **COMPUTATIONAL** — deterministic results of reviewed executable code and regression tests. -- **SCIENTIFIC** — externally sourced scholarly/database statements, stated no more strongly than the cited source supports. -- **HYPOTHESIS** — testable proposals that must include an explicit falsification protocol. -- **SYMBOLIC** — project-defined artistic, mythological, mnemonic, or interpretive mappings with no empirical force. - -A claim may have external context sources without changing its class. In particular, a symbolic mapping does not become scientific merely because one of its component nouns has scientific literature. +- **FORMAL** +- **COMPUTATIONAL** +- **SCIENTIFIC** +- **HYPOTHESIS** +- **SYMBOLIC** ## Scientific source registry -- **SRC-E8-MATHWORLD** — Wolfram MathWorld, *Gosset Polytope*; documents the 240 vertices/roots of the E8 root polytope. https://mathworld.wolfram.com/GossetPolytope.html -- **SRC-SPIN8-PTEP-2021** — PTEP 2021 article; states the Spin(8) triality (S_3) outer automorphism and permutation of the three 8-dimensional representations. -- **SRC-SIS2-PMID-25590815** — PMID **25590815**, DOI **10.1021/ic501825r**; describes ambient-pressure SiS2 as orthorhombic chains of distorted edge-sharing SiS4 tetrahedra. https://pubmed.ncbi.nlm.nih.gov/25590815/ -- **SRC-HPV16-REFSEQ** — NCBI RefSeq **NC_001526.4**, human papillomavirus type 16 complete genome. https://www.ncbi.nlm.nih.gov/nuccore/NC_001526.4 -- **SRC-HPV16-E6E7-PMID-17645777** — PMID **17645777**, PMCID **PMC11158331**; review of high-risk HPV E6/E7 carcinogenesis mechanisms. https://pmc.ncbi.nlm.nih.gov/articles/PMC11158331/ -- **SRC-HPV-P16-PMC8409095** — PMCID **PMC8409095**; review discussing p16 as a surrogate marker and its limitations relative to direct viral transcription evidence. https://pmc.ncbi.nlm.nih.gov/articles/PMC8409095/ +### SRC-E8-MATHWORLD -## Claims +- **Kind:** `scholarly_reference` +- **Title:** Gosset Polytope — E8 root polytope +- **Identifiers:** none +- **URL:** https://mathworld.wolfram.com/GossetPolytope.html -### FORMAL +### SRC-SPIN8-PTEP-2021 -- **COSMO-D-001** — Six authoritative state transitions return every `CosmoLayer` to itself. Authority: Lean theorem `six_step_periodic`. -- **COSMO-D-002** — Every authoritative layer reaches every other layer within one six-state orbit. Authority: Lean theorem `every_layer_reachable`. +- **Kind:** `scholarly_article` +- **Title:** Vertex operator superalgebra/sigma model correspondences: The four-torus case +- **Identifiers:** year=2021 +- **URL:** https://academic.oup.com/ptep/article/2021/8/08B102/6353037 -### COMPUTATIONAL +### SRC-SIS2-PMID-25590815 -- **COSMO-D-003** — Phase B3 deterministically constructs and validates the 240-root E8 table, rank 8 and norm-2 structure, with reviewed identity binding. -- **COSMO-D-014** — Phase B5 recovers the original `TriadicLattice` through the documented software ECC/ACGT round trip for corruption patterns inside the selected SECDED capability. +- **Kind:** `peer_reviewed_article` +- **Title:** Two high-pressure phases of SiS2 as missing links between the extremes of only edge-sharing and only corner-sharing tetrahedra +- **Identifiers:** DOI=10.1021/ic501825r, PMID=25590815 +- **URL:** https://pubmed.ncbi.nlm.nih.gov/25590815/ -### SCIENTIFIC +### SRC-HPV16-REFSEQ -- **COSMO-D-004** — Spin(8) triality has an (S_3) outer automorphism action permuting the vector and two spinor eight-dimensional representations. This does **not** imply a capsid/HPV mechanism. -- **COSMO-D-005** — Ambient-pressure SiS2 is orthorhombic and contains chains of distorted edge-sharing SiS4 tetrahedra. This does **not** establish a biological “life-code” substrate. -- **COSMO-D-006** — HPV16 reference genome provenance in this ledger: NCBI RefSeq **NC_001526.4**. -- **COSMO-D-007** — High-risk HPV E6/E7 have established carcinogenesis roles involving p53 and pRb/E2F control. These facts do **not** define COSMO's transitions. -- **COSMO-D-008** — p16 immunohistochemistry is a context-dependent surrogate marker; p16 positivity is not equivalent to direct evidence of active HPV16 E6/E7 transcription. +- **Kind:** `official_database` +- **Title:** Human papillomavirus type 16, complete genome +- **Identifiers:** RefSeq=NC_001526.4 +- **URL:** https://www.ncbi.nlm.nih.gov/nuccore/NC_001526.4 -### HYPOTHESIS +### SRC-HPV16-E6E7-PMID-17645777 -- **COSMO-D-012** — A future quantitatively specified triality-to-HPV/capsid mapping may be tested for predictive value. It currently has **no positive result**. Falsification requires preregistered mapping, observable, data split, metric, controls, and threshold. +- **Kind:** `peer_reviewed_review` +- **Title:** Basic mechanisms of high-risk human papillomavirus-induced carcinogenesis: Roles of E6 and E7 proteins +- **Identifiers:** PMCID=PMC11158331, PMID=17645777 +- **URL:** https://pmc.ncbi.nlm.nih.gov/articles/PMC11158331/ -### SYMBOLIC +### SRC-HPV-P16-PMC8409095 + +- **Kind:** `peer_reviewed_review` +- **Title:** Biology of HPV Mediated Carcinogenesis and Tumor Progression +- **Identifiers:** PMCID=PMC8409095 +- **URL:** https://pmc.ncbi.nlm.nih.gov/articles/PMC8409095/ + +## Claims -- **COSMO-D-009** — Cuneiform annotations are project-defined symbols, not archaeological decipherment or translation. -- **COSMO-D-010** — “Cosmic symmetry”, “life-code”, “infected reality”, and Ouroboros self-causation are symbolic/interpretive vocabulary. -- **COSMO-D-011** — The current triality ↔ HPV capsid branching association is symbolic, not an established biological mechanism. -- **COSMO-D-013** — `SiS2Substrate` is a project state label; the SiS2 literature does not establish a biological substrate role. +### COSMO-D-001 — FORMAL + +- **Status:** `SUPPORTED` +- **Statement:** For every CosmoLayer, six applications of the authoritative Lean transition return the layer to itself. +- **Sources:** none +- **Boundary:** This is a theorem about the finite state machine only; it is not a physical periodicity claim. +- **Repository provenance:** + - `cosmovirus.lean` — `theorem six_step_periodic` (`kernel_checked_theorem`) + +### COSMO-D-002 — FORMAL + +- **Status:** `SUPPORTED` +- **Statement:** Every authoritative COSMO layer reaches every other layer within one complete six-state orbit. +- **Sources:** none +- **Boundary:** Reachability is defined inside the project state machine. +- **Repository provenance:** + - `cosmovirus.lean` — `theorem every_layer_reachable` (`kernel_checked_theorem`) + +### COSMO-D-003 — COMPUTATIONAL + +- **Status:** `SUPPORTED` +- **Statement:** The Phase B3 Python reference generator deterministically constructs 240 unique E8 roots with rank 8 and squared norm 2, and the canonical table is bound to a reviewed SHA-256. +- **Sources:** SRC-E8-MATHWORLD +- **Boundary:** This is deterministic computational evidence; the local Lean core does not yet formalize the E8 root construction. +- **Repository provenance:** + - `cosmo_core/e8.py` — `def validate_e8_root_system` (`implementation`) + - `tests/test_phase_b3.py` — `test_root_system_report_has_rank_eight_and_norm_two` (`regression`) + +### COSMO-D-004 — SCIENTIFIC + +- **Status:** `SUPPORTED` +- **Statement:** Spin(8) has triality symmetry with an S3 outer automorphism action that permutes its vector and two spinor eight-dimensional representations. +- **Sources:** SRC-SPIN8-PTEP-2021 +- **Boundary:** This mathematical fact does not establish a mechanism connecting Spin(8) triality to HPV, capsids, SiS2, or cosmology. +- **Repository provenance:** + - `cosmovirus.tex` — `Triality automorphism` (`documented_context`) + +### COSMO-D-005 — SCIENTIFIC + +- **Status:** `SUPPORTED` +- **Statement:** The ambient-pressure phase of SiS2 is orthorhombic and contains chains of distorted edge-sharing SiS4 tetrahedra. +- **Sources:** SRC-SIS2-PMID-25590815 +- **Boundary:** This crystallographic fact does not support COSMO's symbolic substrate or life-code interpretation. +- **Repository provenance:** + - `cosmovirus.tex` — `Silicon disulfide` (`documented_context`) + +### COSMO-D-006 — SCIENTIFIC + +- **Status:** `SUPPORTED` +- **Statement:** The NCBI reference sequence used for human papillomavirus type 16 in this ledger is RefSeq NC_001526.4. +- **Sources:** SRC-HPV16-REFSEQ +- **Boundary:** The accession identifies a reference genome; it does not validate COSMO's state-machine use of the HPV16Layer label. +- **Repository provenance:** + - `CLAIM-LEDGER.md` — `NC_001526.4` (`provenance_record`) + +### COSMO-D-007 — SCIENTIFIC + +- **Status:** `SUPPORTED` +- **Statement:** High-risk HPV E6 and E7 proteins are established carcinogenesis factors; E6 promotes p53 degradation and E7 disrupts pRb/E2F control. +- **Sources:** SRC-HPV16-E6E7-PMID-17645777 +- **Boundary:** This biomedical mechanism is external scientific context and is not a mechanism for COSMO transitions. +- **Repository provenance:** + - `cosmovirus.tex` — `COSMO-D-007` (`documented_context`) + +### COSMO-D-008 — SCIENTIFIC + +- **Status:** `SUPPORTED_WITH_SCOPE` +- **Statement:** p16 immunohistochemistry is used as a surrogate marker for HPV-associated disease in some clinical contexts, but p16 positivity is not identical to direct evidence of active E6/E7 transcription. +- **Sources:** SRC-HPV-P16-PMC8409095 +- **Boundary:** COSMO must not equate a generic p16-positive label with HPV16 infection or active viral transcription. +- **Repository provenance:** + - `cosmovirus.tex` — `p16` (`documented_context`) + +### COSMO-D-009 — SYMBOLIC + +- **Status:** `PROJECT_DEFINED` +- **Statement:** The byte-to-cuneiform labels in COSMO are project-defined symbolic annotations. +- **Sources:** none +- **Boundary:** They are not a decipherment, transliteration, translation, archaeological attribution, or historical sentence. +- **Empirical status:** `NON_EMPIRICAL` +- **Repository provenance:** + - `cosmovirus.lean` — `def cuneiformAnnotation` (`project_definition`) + - `KNOWN_LIMITATIONS.md` — `Cuneiform strings are project-defined symbolic annotations` (`scope_boundary`) + +### COSMO-D-010 — SYMBOLIC + +- **Status:** `PROJECT_DEFINED` +- **Statement:** COSMO's language of undivided cosmic symmetry, life-code substrate, infected reality, and Ouroboros self-causation is symbolic/interpretive vocabulary. +- **Sources:** none +- **Boundary:** These phrases are not empirical cosmology, materials science, virology, or causal-mechanism claims. +- **Empirical status:** `NON_EMPIRICAL` +- **Repository provenance:** + - `cosmovirus.tex` — `Symbolic Interpretation` (`symbolic_section`) + +### COSMO-D-011 — SYMBOLIC + +- **Status:** `PROJECT_DEFINED` +- **Statement:** The association of Spin(8) triality with HPV capsid branching or trimerization is a symbolic cross-domain association in the current repository. +- **Sources:** none +- **Boundary:** The repository does not claim an established biological mechanism connecting Spin(8) triality to HPV capsid assembly. +- **Empirical status:** `NON_EMPIRICAL` +- **Repository provenance:** + - `cosmovirus.tex` — `capsid` (`historical_symbolic_mapping`) + +### COSMO-D-012 — HYPOTHESIS + +- **Status:** `PROPOSED` +- **Statement:** A future quantitatively specified mapping from triality-derived features to an HPV/capsid observable could be tested for predictive value against matched controls. +- **Sources:** none +- **Boundary:** No such predictive result is currently claimed. +- **Falsification:** Pre-register the mapping, observable, dataset split, metric, and matched baselines; reject the hypothesis if held-out performance fails the predeclared threshold or is not distinguishable from the controls. +- **Repository provenance:** + - `CLAIM-LEDGER.md` — `COSMO-D-012` (`hypothesis_definition`) + +### COSMO-D-013 — SYMBOLIC + +- **Status:** `PROJECT_DEFINED` +- **Statement:** The use of SiS2Substrate as a COSMO state name is symbolic project vocabulary rather than evidence that silicon disulfide is a biological life-code substrate. +- **Sources:** SRC-SIS2-PMID-25590815 +- **Boundary:** The scientific source does not establish a biological substrate role; it supports SiS2 crystal-structure facts only. +- **Empirical status:** `NON_EMPIRICAL` +- **Repository provenance:** + - `cosmovirus.lean` — `SiS2Substrate` (`state_label`) + +### COSMO-D-014 — COMPUTATIONAL + +- **Status:** `SUPPORTED` +- **Statement:** Within the documented SECDED capability, the Phase B5 software storage pipeline deterministically recovers the original TriadicLattice through bytes, ECC, ACGT, corruption, correction, bytes, and cube reconstruction. +- **Sources:** none +- **Boundary:** This is a software codec result, not a laboratory DNA-storage or physical Rubik's Cube claim. +- **Repository provenance:** + - `cosmo_core/storage.py` — `def recover_cube_storage` (`implementation`) + - `tests/test_phase_b5.py` — `test_full_cube_recovers_one_bit_error_in_every_codeword` (`regression`) ## Governance -1. New cross-domain public-facing claims must receive a stable `COSMO-D-###` ID before being promoted as Phase D authoritative language. -2. **SCIENTIFIC** claims require at least one external source entry. -3. **HYPOTHESIS** claims require an explicit falsification protocol and may not be phrased as established mechanisms. -4. **SYMBOLIC** claims must state their non-empirical boundary. -5. **FORMAL** and **COMPUTATIONAL** claims must point to reviewed repository evidence. +1. New cross-domain public-facing claims require a stable `COSMO-D-###` ID. +2. **SCIENTIFIC** claims require external source records. +3. **HYPOTHESIS** claims must remain `PROPOSED` and include explicit falsification criteria. +4. **SYMBOLIC** claims require `empirical_status = NON_EMPIRICAL`. +5. **FORMAL** and **COMPUTATIONAL** claims require reviewed repository provenance. 6. A source about one domain does not validate a cross-domain bridge. -7. Historical PDFs and archived source material remain provenance inputs, not authorities over the ledger. +7. This Markdown file must exactly match the canonical JSON rendering. From 31794ffac4cb313e0b3c3782862378037caa4a5e Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 08:36:15 +0930 Subject: [PATCH 024/159] Cover Phase D validator hardening --- tests/test_phase_d.py | 47 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/tests/test_phase_d.py b/tests/test_phase_d.py index fc93402..6e23fe2 100644 --- a/tests/test_phase_d.py +++ b/tests/test_phase_d.py @@ -1,7 +1,9 @@ import json +import runpy import subprocess import sys import unittest +from collections.abc import Callable from pathlib import Path from typing import Any, cast @@ -10,6 +12,7 @@ sys.path.insert(0, str(REPOSITORY_ROOT)) LEDGER_PATH = REPOSITORY_ROOT / "claims" / "claim-ledger.json" +INDEX_PATH = REPOSITORY_ROOT / "CLAIM-LEDGER.md" VALIDATOR_PATH = REPOSITORY_ROOT / "scripts" / "validate-claim-ledger.py" @@ -19,6 +22,12 @@ def load_ledger(self) -> dict[str, Any]: self.assertIsInstance(raw, dict) return cast(dict[str, Any], raw) + def load_validator_namespace(self) -> dict[str, Any]: + return cast( + dict[str, Any], + runpy.run_path(str(VALIDATOR_PATH), run_name="claim_validator_test"), + ) + def test_validator_accepts_reviewed_ledger(self) -> None: completed = subprocess.run( [sys.executable, str(VALIDATOR_PATH)], @@ -47,7 +56,7 @@ def test_scientific_claims_have_external_sources(self) -> None: with self.subTest(claim=claim["id"]): self.assertTrue(claim["sources"]) - def test_hypotheses_are_falsifiable_and_not_supported(self) -> None: + def test_hypotheses_are_proposed_and_falsifiable(self) -> None: ledger = self.load_ledger() hypotheses = [ claim for claim in ledger["claims"] @@ -56,15 +65,45 @@ def test_hypotheses_are_falsifiable_and_not_supported(self) -> None: self.assertTrue(hypotheses) for claim in hypotheses: with self.subTest(claim=claim["id"]): + self.assertEqual(claim["status"], "PROPOSED") self.assertTrue(claim["falsification"]) - self.assertNotEqual(claim["status"], "SUPPORTED") - def test_symbolic_claims_have_explicit_non_empirical_boundaries(self) -> None: + def test_symbolic_claims_have_structured_non_empirical_status(self) -> None: ledger = self.load_ledger() for claim in ledger["claims"]: if claim["class"] == "SYMBOLIC": with self.subTest(claim=claim["id"]): - self.assertIn("not", claim["boundary"].lower()) + self.assertEqual( + claim.get("empirical_status"), + "NON_EMPIRICAL", + ) + + def test_provenance_paths_cannot_escape_repository(self) -> None: + namespace = self.load_validator_namespace() + validate_path = cast( + Callable[[str, str], Path], + namespace["validate_repository_path"], + ) + + for path_text in ( + "/etc/os-release", + "../outside.txt", + "claims/../README.md", + ): + with self.subTest(path=path_text): + with self.assertRaises(SystemExit): + validate_path(path_text, "COSMO-D-999") + + def test_markdown_is_exact_canonical_json_rendering(self) -> None: + namespace = self.load_validator_namespace() + render_index = cast( + Callable[[dict[str, Any]], str], + namespace["render_index"], + ) + self.assertEqual( + INDEX_PATH.read_text(encoding="utf-8"), + render_index(self.load_ledger()), + ) def test_hpv16_reference_accession_is_versioned(self) -> None: ledger = self.load_ledger() From 70b138a59fcbe95f7fd31c97e85efce5bc0e4147 Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 08:36:50 +0930 Subject: [PATCH 025/159] Document hardened Phase D validation --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e82f571..23cccd8 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ The repository deliberately separates what is **proved or computed** from what i | **HYPOTHESIS** | Testable cross-domain proposal not yet validated | “COSMO hypothesizes …” | | **SYMBOLIC** | Artistic, mythological, or interpretive mapping | “COSMO symbolically associates …” | -The current Lean/Python core is intentionally narrow. The six COSMO layer names remain project vocabulary, while the code proves only the finite-state and arithmetic facts explicitly stated in the source. Phase D makes this separation machine-auditable through [CLAIM-LEDGER.md](CLAIM-LEDGER.md) and `claims/claim-ledger.json`; CI rejects class/provenance drift. +The current Lean/Python core is intentionally narrow. The six COSMO layer names remain project vocabulary, while the code proves only the finite-state and arithmetic facts explicitly stated in the source. Phase D makes this separation machine-auditable through [CLAIM-LEDGER.md](CLAIM-LEDGER.md) and `claims/claim-ledger.json`; CI rejects class/provenance drift and requires the Markdown index to match the JSON rendering byte-for-byte. ## Verified baseline @@ -177,7 +177,7 @@ The canonical machine-readable ledger is `claims/claim-ledger.json` with schema - an explicit evidence boundary; and - mandatory falsification criteria for hypotheses. -`scripts/validate-claim-ledger.py` fails closed if IDs are duplicated/out of order, evidence classes change, provenance anchors disappear, scientific claims lack external sources, hypotheses lose falsification criteria, symbolic claims lose non-empirical boundaries, or the Markdown/JSON ledgers diverge. +`scripts/validate-claim-ledger.py` fails closed if IDs are duplicated/out of order, evidence classes change, provenance anchors disappear, scientific claims lack external sources, hypotheses leave the `PROPOSED` state or lose falsification criteria, symbolic claims lose `empirical_status = NON_EMPIRICAL`, provenance paths escape the repository, or the Markdown rendering diverges from JSON. The initial ledger records, among other things: From 1689e70b22186d65825a462952df7e1a2e301ff8 Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 08:37:45 +0930 Subject: [PATCH 026/159] Keep Phase D tests strict-type clean --- tests/test_phase_d.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_phase_d.py b/tests/test_phase_d.py index 6e23fe2..e51e23c 100644 --- a/tests/test_phase_d.py +++ b/tests/test_phase_d.py @@ -23,9 +23,9 @@ def load_ledger(self) -> dict[str, Any]: return cast(dict[str, Any], raw) def load_validator_namespace(self) -> dict[str, Any]: - return cast( - dict[str, Any], - runpy.run_path(str(VALIDATOR_PATH), run_name="claim_validator_test"), + return runpy.run_path( + str(VALIDATOR_PATH), + run_name="claim_validator_test", ) def test_validator_accepts_reviewed_ledger(self) -> None: From 1a8336e19c65b021d9ffe05f564199adacbfe846 Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 09:14:45 +0930 Subject: [PATCH 027/159] Reject ambiguous and malformed claim provenance --- scripts/validate-claim-ledger.py | 229 +++++++++++++++++++++++-------- 1 file changed, 174 insertions(+), 55 deletions(-) diff --git a/scripts/validate-claim-ledger.py b/scripts/validate-claim-ledger.py index 48b1577..bd7291e 100644 --- a/scripts/validate-claim-ledger.py +++ b/scripts/validate-claim-ledger.py @@ -15,6 +15,13 @@ CLASSES = ("FORMAL", "COMPUTATIONAL", "SCIENTIFIC", "HYPOTHESIS", "SYMBOLIC") CLAIM_ID = re.compile(r"COSMO-D-[0-9]{3}$") SOURCE_ID = re.compile(r"SRC-[A-Z0-9][A-Z0-9._-]*$") +IDENTIFIER_PATTERNS: dict[str, re.Pattern[str]] = { + "PMID": re.compile(r"[1-9][0-9]{0,7}$"), + "PMCID": re.compile(r"PMC[1-9][0-9]*$"), + "DOI": re.compile(r"10\.[0-9]{4,9}/[^\s]+$"), + "RefSeq": re.compile(r"[A-Z]{2}_[0-9]+\.[0-9]+$"), + "year": re.compile(r"(?:19|20)[0-9]{2}$"), +} ALLOWED_STATUSES: dict[str, frozenset[str]] = { "FORMAL": frozenset({"SUPPORTED"}), "COMPUTATIONAL": frozenset({"SUPPORTED"}), @@ -24,26 +31,88 @@ } +class DuplicateJsonKeyError(ValueError): + """Raised when canonical JSON contains the same object key twice.""" + + def fail(message: str) -> Never: raise SystemExit(f"claim-ledger validation failed: {message}") -def load_json() -> dict[str, Any]: +def reject_duplicate_object_pairs( + pairs: list[tuple[str, Any]], +) -> dict[str, Any]: + """Build one JSON object while rejecting duplicate member names.""" + result: dict[str, Any] = {} + for key, value in pairs: + if key in result: + raise DuplicateJsonKeyError(f"duplicate JSON key {key!r}") + result[key] = value + return result + + +def parse_json_text(text: str) -> dict[str, Any]: + """Parse canonical ledger JSON without last-key-wins ambiguity.""" try: - raw: object = json.loads(LEDGER_PATH.read_text(encoding="utf-8")) - except (OSError, UnicodeError, json.JSONDecodeError) as exc: - fail(f"cannot read canonical JSON: {exc}") + raw: object = json.loads( + text, + object_pairs_hook=reject_duplicate_object_pairs, + ) + except (json.JSONDecodeError, DuplicateJsonKeyError) as exc: + fail(f"invalid canonical JSON: {exc}") if not isinstance(raw, dict): fail("ledger root must be an object") return cast(dict[str, Any], raw) +def load_json() -> dict[str, Any]: + try: + text = LEDGER_PATH.read_text(encoding="utf-8") + except (OSError, UnicodeError) as exc: + fail(f"cannot read canonical JSON: {exc}") + return parse_json_text(text) + + def require_string(value: object, label: str) -> str: if not isinstance(value, str) or not value.strip(): fail(f"{label} must be a non-empty string") return value +def require_inline_string(value: object, label: str) -> str: + """Require text that cannot create new Markdown lines/blocks.""" + text = require_string(value, label) + if any(character in text for character in ("\n", "\r", "\u2028", "\u2029")): + fail(f"{label} must be single-line text") + if any(ord(character) < 32 for character in text): + fail(f"{label} may not contain ASCII control characters") + return text + + +def validate_identifiers(source_id: str, identifiers: object) -> dict[str, str]: + """Validate typed accession/article identifiers used by Phase D sources.""" + if not isinstance(identifiers, dict): + fail(f"{source_id} identifiers must be an object") + + validated: dict[str, str] = {} + for key, value in identifiers.items(): + if not isinstance(key, str): + fail(f"{source_id} identifier names must be strings") + if key not in IDENTIFIER_PATTERNS: + fail(f"{source_id} uses unsupported identifier type {key!r}") + exact_value = require_inline_string( + value, + f"{source_id} identifier {key}", + ) + if IDENTIFIER_PATTERNS[key].fullmatch(exact_value) is None: + fail( + f"{source_id} identifier {key} has invalid syntax: " + f"{exact_value!r}" + ) + validated[key] = exact_value + return validated + + def validate_repository_path(path_text: str, claim_id: str) -> Path: """Resolve a provenance path and prove it stays inside the repository.""" relative = Path(path_text) @@ -74,9 +143,18 @@ def validate_provenance(claim_id: str, entries: object) -> None: for index, item in enumerate(entries): if not isinstance(item, dict): fail(f"{claim_id} provenance[{index}] must be an object") - path_text = require_string(item.get("path"), f"{claim_id} provenance path") - anchor = require_string(item.get("anchor"), f"{claim_id} provenance anchor") - require_string(item.get("role"), f"{claim_id} provenance role") + path_text = require_inline_string( + item.get("path"), + f"{claim_id} provenance path", + ) + anchor = require_inline_string( + item.get("anchor"), + f"{claim_id} provenance anchor", + ) + require_inline_string( + item.get("role"), + f"{claim_id} provenance role", + ) path = validate_repository_path(path_text, claim_id) try: text = path.read_text(encoding="utf-8") @@ -101,7 +179,7 @@ def _claim_sources_text(sources: list[str]) -> str: def render_index(ledger: dict[str, Any]) -> str: """Render the one canonical human-readable ledger from canonical JSON.""" - schema = require_string(ledger.get("schema"), "schema") + schema = require_inline_string(ledger.get("schema"), "schema") raw_sources = ledger.get("sources") raw_claims = ledger.get("claims") if not isinstance(raw_sources, list) or not isinstance(raw_claims, list): @@ -125,18 +203,11 @@ def render_index(ledger: dict[str, Any]) -> str: for source in raw_sources: if not isinstance(source, dict): fail("source entries must be objects") - source_id = require_string(source.get("id"), "source id") - kind = require_string(source.get("kind"), f"{source_id} kind") - title = require_string(source.get("title"), f"{source_id} title") - url = require_string(source.get("url"), f"{source_id} url") - identifiers_obj = source.get("identifiers") - if not isinstance(identifiers_obj, dict): - fail(f"{source_id} identifiers must be an object") - identifiers: dict[str, str] = {} - for key, value in identifiers_obj.items(): - if not isinstance(key, str) or not isinstance(value, str): - fail(f"{source_id} identifiers must map strings to strings") - identifiers[key] = value + source_id = require_inline_string(source.get("id"), "source id") + kind = require_inline_string(source.get("kind"), f"{source_id} kind") + title = require_inline_string(source.get("title"), f"{source_id} title") + url = require_inline_string(source.get("url"), f"{source_id} url") + identifiers = validate_identifiers(source_id, source.get("identifiers")) lines.extend( [ @@ -154,18 +225,36 @@ def render_index(ledger: dict[str, Any]) -> str: for claim in raw_claims: if not isinstance(claim, dict): fail("claim entries must be objects") - claim_id = require_string(claim.get("id"), "claim id") - evidence_class = require_string(claim.get("class"), f"{claim_id} class") - status = require_string(claim.get("status"), f"{claim_id} status") - statement = require_string(claim.get("statement"), f"{claim_id} statement") - boundary = require_string(claim.get("boundary"), f"{claim_id} boundary") + claim_id = require_inline_string(claim.get("id"), "claim id") + evidence_class = require_inline_string( + claim.get("class"), + f"{claim_id} class", + ) + status = require_inline_string( + claim.get("status"), + f"{claim_id} status", + ) + statement = require_inline_string( + claim.get("statement"), + f"{claim_id} statement", + ) + boundary = require_inline_string( + claim.get("boundary"), + f"{claim_id} boundary", + ) sources_obj = claim.get("sources") if not isinstance(sources_obj, list) or any( not isinstance(source_id, str) for source_id in sources_obj ): fail(f"{claim_id} sources must be a string array") - claim_sources = cast(list[str], sources_obj) + claim_sources = [ + require_inline_string( + source_id, + f"{claim_id} source reference", + ) + for source_id in cast(list[str], sources_obj) + ] lines.extend( [ @@ -180,13 +269,22 @@ def render_index(ledger: dict[str, Any]) -> str: empirical_status = claim.get("empirical_status") if empirical_status is not None: - lines.append(f"- **Empirical status:** `{empirical_status}`") + exact_empirical_status = require_inline_string( + empirical_status, + f"{claim_id} empirical_status", + ) + lines.append( + f"- **Empirical status:** `{exact_empirical_status}`" + ) falsification = claim.get("falsification") if falsification is not None: lines.append( "- **Falsification:** " - + require_string(falsification, f"{claim_id} falsification") + + require_inline_string( + falsification, + f"{claim_id} falsification", + ) ) provenance = claim.get("provenance") @@ -196,9 +294,18 @@ def render_index(ledger: dict[str, Any]) -> str: for item in provenance: if not isinstance(item, dict): fail(f"{claim_id} provenance entries must be objects") - path_text = require_string(item.get("path"), f"{claim_id} provenance path") - anchor = require_string(item.get("anchor"), f"{claim_id} provenance anchor") - role = require_string(item.get("role"), f"{claim_id} provenance role") + path_text = require_inline_string( + item.get("path"), + f"{claim_id} provenance path", + ) + anchor = require_inline_string( + item.get("anchor"), + f"{claim_id} provenance anchor", + ) + role = require_inline_string( + item.get("role"), + f"{claim_id} provenance role", + ) lines.append( f" - `{path_text}` — `{anchor}` (`{role}`)" ) @@ -240,35 +347,25 @@ def validate() -> None: for source in sources: if not isinstance(source, dict): fail("source entries must be objects") - source_id = require_string(source.get("id"), "source id") + source_id = require_inline_string(source.get("id"), "source id") if SOURCE_ID.fullmatch(source_id) is None: fail(f"invalid source id {source_id!r}") if source_id in source_ids: fail(f"duplicate source id {source_id}") source_ids.add(source_id) - require_string(source.get("kind"), f"{source_id} kind") - require_string(source.get("title"), f"{source_id} title") - url = require_string(source.get("url"), f"{source_id} url") + require_inline_string(source.get("kind"), f"{source_id} kind") + require_inline_string(source.get("title"), f"{source_id} title") + url = require_inline_string(source.get("url"), f"{source_id} url") if not url.startswith("https://"): fail(f"{source_id} must use https") - identifiers = source.get("identifiers") - if not isinstance(identifiers, dict): - fail(f"{source_id} identifiers must be an object") - if any( - not isinstance(key, str) - or not isinstance(value, str) - or not key - or not value - for key, value in identifiers.items() - ): - fail(f"{source_id} identifiers must map non-empty strings to strings") + validate_identifiers(source_id, source.get("identifiers")) claim_ids: set[str] = set() previous_number = 0 for claim in claims: if not isinstance(claim, dict): fail("claim entries must be objects") - claim_id = require_string(claim.get("id"), "claim id") + claim_id = require_inline_string(claim.get("id"), "claim id") if CLAIM_ID.fullmatch(claim_id) is None: fail(f"invalid claim id {claim_id!r}") number = int(claim_id.rsplit("-", 1)[1]) @@ -279,10 +376,16 @@ def validate() -> None: fail(f"duplicate claim id {claim_id}") claim_ids.add(claim_id) - evidence_class = require_string(claim.get("class"), f"{claim_id} class") + evidence_class = require_inline_string( + claim.get("class"), + f"{claim_id} class", + ) if evidence_class not in CLASSES: fail(f"{claim_id} has invalid evidence class") - status = require_string(claim.get("status"), f"{claim_id} status") + status = require_inline_string( + claim.get("status"), + f"{claim_id} status", + ) allowed = ALLOWED_STATUSES[evidence_class] if status not in allowed: fail( @@ -290,8 +393,14 @@ def validate() -> None: f"{evidence_class}; allowed={sorted(allowed)}" ) - require_string(claim.get("statement"), f"{claim_id} statement") - require_string(claim.get("boundary"), f"{claim_id} boundary") + require_inline_string( + claim.get("statement"), + f"{claim_id} statement", + ) + require_inline_string( + claim.get("boundary"), + f"{claim_id} boundary", + ) validate_provenance(claim_id, claim.get("provenance")) source_list = claim.get("sources") @@ -299,17 +408,27 @@ def validate() -> None: not isinstance(source_id, str) for source_id in source_list ): fail(f"{claim_id} sources must be a string array") - if len(source_list) != len(set(source_list)): + validated_sources = [ + require_inline_string( + source_id, + f"{claim_id} source reference", + ) + for source_id in cast(list[str], source_list) + ] + if len(validated_sources) != len(set(validated_sources)): fail(f"{claim_id} repeats a source") - unknown = set(source_list) - source_ids + unknown = set(validated_sources) - source_ids if unknown: fail(f"{claim_id} references unknown sources: {sorted(unknown)}") falsification = claim.get("falsification") - if evidence_class == "SCIENTIFIC" and not source_list: + if evidence_class == "SCIENTIFIC" and not validated_sources: fail(f"{claim_id} SCIENTIFIC claim requires an external source") if evidence_class == "HYPOTHESIS": - require_string(falsification, f"{claim_id} falsification") + require_inline_string( + falsification, + f"{claim_id} falsification", + ) elif falsification is not None: fail(f"{claim_id} non-hypothesis falsification must be null") From 19f96edbeb0040254c0ceee8f7d359e458f6077b Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 09:14:54 +0930 Subject: [PATCH 028/159] Bind p16 claim to its scoped passage --- claims/claim-ledger.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/claims/claim-ledger.json b/claims/claim-ledger.json index f42ad2e..b0be195 100644 --- a/claims/claim-ledger.json +++ b/claims/claim-ledger.json @@ -199,7 +199,7 @@ "provenance": [ { "path": "cosmovirus.tex", - "anchor": "p16", + "anchor": "COSMO-D-008", "role": "documented_context" } ], From 04242fa68f25a9a33cb3ffd7d05ac1ebcd0e9d37 Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 09:15:14 +0930 Subject: [PATCH 029/159] Regenerate canonical claim index --- CLAIM-LEDGER.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CLAIM-LEDGER.md b/CLAIM-LEDGER.md index 14f5d17..5e06232 100644 --- a/CLAIM-LEDGER.md +++ b/CLAIM-LEDGER.md @@ -129,7 +129,7 @@ - **Sources:** SRC-HPV-P16-PMC8409095 - **Boundary:** COSMO must not equate a generic p16-positive label with HPV16 infection or active viral transcription. - **Repository provenance:** - - `cosmovirus.tex` — `p16` (`documented_context`) + - `cosmovirus.tex` — `COSMO-D-008` (`documented_context`) ### COSMO-D-009 — SYMBOLIC From f31d40025642c46589a30a3e551c4d7ccfb059e2 Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 09:15:39 +0930 Subject: [PATCH 030/159] Cover identifier and JSON ambiguity attacks --- tests/test_phase_d.py | 58 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/tests/test_phase_d.py b/tests/test_phase_d.py index e51e23c..4c7808e 100644 --- a/tests/test_phase_d.py +++ b/tests/test_phase_d.py @@ -105,6 +105,64 @@ def test_markdown_is_exact_canonical_json_rendering(self) -> None: render_index(self.load_ledger()), ) + + def test_identifier_syntax_rejects_malformed_values(self) -> None: + namespace = self.load_validator_namespace() + validate_identifiers = cast( + Callable[[str, object], dict[str, str]], + namespace["validate_identifiers"], + ) + + bad_sets = ( + {"PMID": "not-a-pmid"}, + {"PMCID": " "}, + {"DOI": "10.bad/doi"}, + {"RefSeq": "NC_001526"}, + {"year": "20X1"}, + ) + for identifiers in bad_sets: + with self.subTest(identifiers=identifiers): + with self.assertRaises(SystemExit): + validate_identifiers("SRC-TEST", identifiers) + + def test_duplicate_json_keys_are_rejected(self) -> None: + namespace = self.load_validator_namespace() + parse_json_text = cast( + Callable[[str], dict[str, Any]], + namespace["parse_json_text"], + ) + ambiguous = ( + '{"id":"COSMO-D-012","status":"SUPPORTED",' + '"status":"PROPOSED"}' + ) + with self.assertRaises(SystemExit): + parse_json_text(ambiguous) + + def test_markdown_rendered_fields_must_be_single_line(self) -> None: + namespace = self.load_validator_namespace() + require_inline_string = cast( + Callable[[object, str], str], + namespace["require_inline_string"], + ) + injected = ( + "Legitimate claim text\n\n" + "### COSMO-D-999 — SCIENTIFIC\n" + "- **Status:** `SUPPORTED`" + ) + with self.assertRaises(SystemExit): + require_inline_string(injected, "claim statement") + + def test_p16_provenance_anchor_is_claim_specific(self) -> None: + ledger = self.load_ledger() + claim = next( + claim for claim in ledger["claims"] + if claim["id"] == "COSMO-D-008" + ) + self.assertEqual( + claim["provenance"][0]["anchor"], + "COSMO-D-008", + ) + def test_hpv16_reference_accession_is_versioned(self) -> None: ledger = self.load_ledger() source = next( From 170e4792ec89da4015cd7dc505e009162ee82402 Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 09:52:21 +0930 Subject: [PATCH 031/159] Enforce source and evidence provenance semantics --- scripts/validate-claim-ledger.py | 300 +++++++++++++++++++++++++++---- 1 file changed, 263 insertions(+), 37 deletions(-) diff --git a/scripts/validate-claim-ledger.py b/scripts/validate-claim-ledger.py index bd7291e..e9f6122 100644 --- a/scripts/validate-claim-ledger.py +++ b/scripts/validate-claim-ledger.py @@ -3,10 +3,12 @@ from __future__ import annotations +import html import json import re from pathlib import Path from typing import Any, Never, cast +from urllib.parse import SplitResult, urlsplit ROOT = Path(__file__).resolve().parents[1] LEDGER_PATH = ROOT / "claims" / "claim-ledger.json" @@ -29,6 +31,42 @@ "HYPOTHESIS": frozenset({"PROPOSED"}), "SYMBOLIC": frozenset({"PROJECT_DEFINED"}), } +ALLOWED_SOURCE_KINDS = frozenset( + { + "scholarly_reference", + "scholarly_article", + "peer_reviewed_article", + "peer_reviewed_review", + "official_database", + } +) +ALLOWED_PROVENANCE_ROLES: dict[str, frozenset[str]] = { + "FORMAL": frozenset({"kernel_checked_theorem"}), + "COMPUTATIONAL": frozenset({"implementation", "regression"}), + "SCIENTIFIC": frozenset({"documented_context", "provenance_record"}), + "HYPOTHESIS": frozenset({"hypothesis_definition"}), + "SYMBOLIC": frozenset( + { + "project_definition", + "scope_boundary", + "symbolic_section", + "historical_symbolic_mapping", + "state_label", + } + ), +} +PLACEHOLDER_TEXT = frozenset( + { + "tbd", + "todo", + "n/a", + "na", + "none", + "unknown", + "placeholder", + "later", + } +) class DuplicateJsonKeyError(ValueError): @@ -89,6 +127,31 @@ def require_inline_string(value: object, label: str) -> str: return text +def require_substantive_inline( + value: object, + label: str, + *, + minimum_length: int = 24, +) -> str: + """Reject placeholders where the governance contract requires real criteria.""" + text = require_inline_string(value, label) + if text.strip().lower() in PLACEHOLDER_TEXT: + fail(f"{label} may not be a placeholder") + if len(text.strip()) < minimum_length: + fail(f"{label} must contain substantive criteria") + return text + + +def markdown_text(value: str) -> str: + """Escape raw HTML metacharacters while retaining visible Markdown text.""" + return html.escape(value, quote=False) + + +def markdown_code(value: str) -> str: + """Escape a value before interpolation into a Markdown code span.""" + return markdown_text(value).replace("`", "`") + + def validate_identifiers(source_id: str, identifiers: object) -> dict[str, str]: """Validate typed accession/article identifiers used by Phase D sources.""" if not isinstance(identifiers, dict): @@ -113,6 +176,74 @@ def validate_identifiers(source_id: str, identifiers: object) -> dict[str, str]: return validated +def validate_source_kind(source_id: str, kind: object) -> str: + """Restrict source registry entries to scholarly/database evidence kinds.""" + exact_kind = require_inline_string(kind, f"{source_id} kind") + if exact_kind not in ALLOWED_SOURCE_KINDS: + fail( + f"{source_id} source kind {exact_kind!r} is not an allowed " + "scholarly/database kind" + ) + return exact_kind + + +def validate_source_url(source_id: str, value: object) -> SplitResult: + """Require an absolute navigable HTTPS source URL without credentials.""" + url = require_inline_string(value, f"{source_id} url") + if any(character.isspace() for character in url): + fail(f"{source_id} URL may not contain whitespace") + try: + parsed = urlsplit(url) + _ = parsed.port + except ValueError as exc: + fail(f"{source_id} has malformed URL: {exc}") + if parsed.scheme != "https" or not parsed.hostname: + fail(f"{source_id} must use an absolute HTTPS URL with a hostname") + if parsed.username is not None or parsed.password is not None: + fail(f"{source_id} URL may not contain userinfo") + return parsed + + +def crosscheck_identifiers_with_url( + source_id: str, + parsed: SplitResult, + identifiers: dict[str, str], +) -> None: + """Bind canonical NCBI accessions to the resource named by the source URL.""" + hostname = (parsed.hostname or "").lower() + path = parsed.path.rstrip("/") + + refseq = identifiers.get("RefSeq") + if refseq is not None: + if hostname != "www.ncbi.nlm.nih.gov" or path != f"/nuccore/{refseq}": + fail( + f"{source_id} RefSeq {refseq} does not match canonical " + "NCBI nuccore URL" + ) + + pmcid = identifiers.get("PMCID") + if pmcid is not None: + if ( + hostname != "pmc.ncbi.nlm.nih.gov" + or path != f"/articles/{pmcid}" + ): + fail( + f"{source_id} PMCID {pmcid} does not match canonical PMC URL" + ) + else: + pmid = identifiers.get("PMID") + if pmid is not None: + if hostname != "pubmed.ncbi.nlm.nih.gov" or path != f"/{pmid}": + fail( + f"{source_id} PMID {pmid} does not match canonical " + "PubMed URL" + ) + + year = identifiers.get("year") + if year is not None and f"/{year}/" not in f"{parsed.path}/": + fail(f"{source_id} year {year} does not match the source URL path") + + def validate_repository_path(path_text: str, claim_id: str) -> Path: """Resolve a provenance path and prove it stays inside the repository.""" relative = Path(path_text) @@ -137,9 +268,17 @@ def validate_repository_path(path_text: str, claim_id: str) -> Path: return resolved -def validate_provenance(claim_id: str, entries: object) -> None: +def validate_provenance( + claim_id: str, + evidence_class: str, + entries: object, +) -> set[str]: + """Validate repository evidence and enforce class-appropriate roles.""" if not isinstance(entries, list) or not entries: fail(f"{claim_id} must have repository provenance") + + allowed_roles = ALLOWED_PROVENANCE_ROLES[evidence_class] + roles: set[str] = set() for index, item in enumerate(entries): if not isinstance(item, dict): fail(f"{claim_id} provenance[{index}] must be an object") @@ -151,10 +290,17 @@ def validate_provenance(claim_id: str, entries: object) -> None: item.get("anchor"), f"{claim_id} provenance anchor", ) - require_inline_string( + role = require_inline_string( item.get("role"), f"{claim_id} provenance role", ) + if role not in allowed_roles: + fail( + f"{claim_id} provenance role {role!r} is invalid for " + f"{evidence_class}" + ) + roles.add(role) + path = validate_repository_path(path_text, claim_id) try: text = path.read_text(encoding="utf-8") @@ -163,18 +309,75 @@ def validate_provenance(claim_id: str, entries: object) -> None: if anchor not in text: fail(f"{claim_id} anchor {anchor!r} not found in {path_text}") + if evidence_class == "FORMAL" and "kernel_checked_theorem" not in roles: + fail(f"{claim_id} FORMAL claim requires kernel-checked theorem evidence") + if evidence_class == "COMPUTATIONAL": + required = {"implementation", "regression"} + if not required.issubset(roles): + fail( + f"{claim_id} COMPUTATIONAL claim requires implementation " + "and regression provenance" + ) + return roles + + +def validate_falsification( + claim_id: str, + value: object, +) -> dict[str, Any]: + """Require structured, substantive falsification criteria.""" + if not isinstance(value, dict): + fail(f"{claim_id} falsification must be a structured object") + + expected_keys = {"protocol", "rejection_condition", "controls"} + if set(value) != expected_keys: + fail( + f"{claim_id} falsification keys must be " + f"{sorted(expected_keys)}" + ) + + protocol = require_substantive_inline( + value.get("protocol"), + f"{claim_id} falsification protocol", + minimum_length=40, + ) + rejection_condition = require_substantive_inline( + value.get("rejection_condition"), + f"{claim_id} falsification rejection_condition", + minimum_length=40, + ) + controls_obj = value.get("controls") + if not isinstance(controls_obj, list) or len(controls_obj) < 2: + fail(f"{claim_id} falsification requires at least two controls") + controls = [ + require_substantive_inline( + control, + f"{claim_id} falsification control", + minimum_length=12, + ) + for control in controls_obj + ] + if len(controls) != len(set(controls)): + fail(f"{claim_id} falsification controls must be unique") + + return { + "protocol": protocol, + "rejection_condition": rejection_condition, + "controls": controls, + } + def _source_identifier_text(identifiers: dict[str, str]) -> str: if not identifiers: return "none" return ", ".join( - f"{key}={identifiers[key]}" + f"{markdown_text(key)}={markdown_text(identifiers[key])}" for key in sorted(identifiers) ) def _claim_sources_text(sources: list[str]) -> str: - return ", ".join(sources) if sources else "none" + return ", ".join(markdown_text(source) for source in sources) if sources else "none" def render_index(ledger: dict[str, Any]) -> str: @@ -191,7 +394,7 @@ def render_index(ledger: dict[str, Any]) -> str: "> Generated canonically from `claims/claim-ledger.json`. " "Do not hand-edit this file independently.", "", - f"**Schema:** `{schema}`", + f"**Schema:** `{markdown_code(schema)}`", "", "## Evidence classes", "", @@ -204,19 +407,21 @@ def render_index(ledger: dict[str, Any]) -> str: if not isinstance(source, dict): fail("source entries must be objects") source_id = require_inline_string(source.get("id"), "source id") - kind = require_inline_string(source.get("kind"), f"{source_id} kind") + kind = validate_source_kind(source_id, source.get("kind")) title = require_inline_string(source.get("title"), f"{source_id} title") url = require_inline_string(source.get("url"), f"{source_id} url") + parsed = validate_source_url(source_id, url) identifiers = validate_identifiers(source_id, source.get("identifiers")) + crosscheck_identifiers_with_url(source_id, parsed, identifiers) lines.extend( [ - f"### {source_id}", + f"### {markdown_text(source_id)}", "", - f"- **Kind:** `{kind}`", - f"- **Title:** {title}", + f"- **Kind:** `{markdown_code(kind)}`", + f"- **Title:** {markdown_text(title)}", f"- **Identifiers:** {_source_identifier_text(identifiers)}", - f"- **URL:** {url}", + f"- **URL:** {markdown_text(url)}", "", ] ) @@ -258,12 +463,12 @@ def render_index(ledger: dict[str, Any]) -> str: lines.extend( [ - f"### {claim_id} — {evidence_class}", + f"### {markdown_text(claim_id)} — {markdown_text(evidence_class)}", "", - f"- **Status:** `{status}`", - f"- **Statement:** {statement}", + f"- **Status:** `{markdown_code(status)}`", + f"- **Statement:** {markdown_text(statement)}", f"- **Sources:** {_claim_sources_text(claim_sources)}", - f"- **Boundary:** {boundary}", + f"- **Boundary:** {markdown_text(boundary)}", ] ) @@ -274,17 +479,26 @@ def render_index(ledger: dict[str, Any]) -> str: f"{claim_id} empirical_status", ) lines.append( - f"- **Empirical status:** `{exact_empirical_status}`" + f"- **Empirical status:** `{markdown_code(exact_empirical_status)}`" ) falsification = claim.get("falsification") if falsification is not None: - lines.append( - "- **Falsification:** " - + require_inline_string( - falsification, - f"{claim_id} falsification", - ) + structured = validate_falsification(claim_id, falsification) + lines.extend( + [ + "- **Falsification protocol:** " + + markdown_text(cast(str, structured["protocol"])), + "- **Rejection condition:** " + + markdown_text( + cast(str, structured["rejection_condition"]) + ), + "- **Controls:** " + + "; ".join( + markdown_text(control) + for control in cast(list[str], structured["controls"]) + ), + ] ) provenance = claim.get("provenance") @@ -307,7 +521,9 @@ def render_index(ledger: dict[str, Any]) -> str: f"{claim_id} provenance role", ) lines.append( - f" - `{path_text}` — `{anchor}` (`{role}`)" + f" - `{markdown_code(path_text)}` — " + f"`{markdown_code(anchor)}` " + f"(`{markdown_code(role)}`)" ) lines.append("") @@ -319,10 +535,10 @@ def render_index(ledger: dict[str, Any]) -> str: "`COSMO-D-###` ID.", "2. **SCIENTIFIC** claims require external source records.", "3. **HYPOTHESIS** claims must remain `PROPOSED` and include " - "explicit falsification criteria.", + "structured falsification criteria.", "4. **SYMBOLIC** claims require `empirical_status = NON_EMPIRICAL`.", - "5. **FORMAL** and **COMPUTATIONAL** claims require reviewed " - "repository provenance.", + "5. **FORMAL** and **COMPUTATIONAL** claims require reviewed, " + "class-appropriate repository provenance.", "6. A source about one domain does not validate a cross-domain bridge.", "7. This Markdown file must exactly match the canonical JSON rendering.", "", @@ -344,6 +560,7 @@ def validate() -> None: fail("sources and claims must be arrays") source_ids: set[str] = set() + source_kinds: dict[str, str] = {} for source in sources: if not isinstance(source, dict): fail("source entries must be objects") @@ -353,12 +570,13 @@ def validate() -> None: if source_id in source_ids: fail(f"duplicate source id {source_id}") source_ids.add(source_id) - require_inline_string(source.get("kind"), f"{source_id} kind") + + kind = validate_source_kind(source_id, source.get("kind")) + source_kinds[source_id] = kind require_inline_string(source.get("title"), f"{source_id} title") - url = require_inline_string(source.get("url"), f"{source_id} url") - if not url.startswith("https://"): - fail(f"{source_id} must use https") - validate_identifiers(source_id, source.get("identifiers")) + parsed = validate_source_url(source_id, source.get("url")) + identifiers = validate_identifiers(source_id, source.get("identifiers")) + crosscheck_identifiers_with_url(source_id, parsed, identifiers) claim_ids: set[str] = set() previous_number = 0 @@ -401,7 +619,11 @@ def validate() -> None: claim.get("boundary"), f"{claim_id} boundary", ) - validate_provenance(claim_id, claim.get("provenance")) + validate_provenance( + claim_id, + evidence_class, + claim.get("provenance"), + ) source_list = claim.get("sources") if not isinstance(source_list, list) or any( @@ -422,13 +644,17 @@ def validate() -> None: fail(f"{claim_id} references unknown sources: {sorted(unknown)}") falsification = claim.get("falsification") - if evidence_class == "SCIENTIFIC" and not validated_sources: - fail(f"{claim_id} SCIENTIFIC claim requires an external source") + if evidence_class == "SCIENTIFIC": + if not validated_sources: + fail(f"{claim_id} SCIENTIFIC claim requires an external source") + for source_id in validated_sources: + if source_kinds[source_id] not in ALLOWED_SOURCE_KINDS: + fail( + f"{claim_id} SCIENTIFIC claim uses non-scholarly " + f"source {source_id}" + ) if evidence_class == "HYPOTHESIS": - require_inline_string( - falsification, - f"{claim_id} falsification", - ) + validate_falsification(claim_id, falsification) elif falsification is not None: fail(f"{claim_id} non-hypothesis falsification must be null") From fc1b2992595399b69d60c1d90f9876812f6842f0 Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 09:52:52 +0930 Subject: [PATCH 032/159] Structure falsification and bind symbolic provenance --- claims/claim-ledger.json | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/claims/claim-ledger.json b/claims/claim-ledger.json index b0be195..d92788b 100644 --- a/claims/claim-ledger.json +++ b/claims/claim-ledger.json @@ -239,7 +239,7 @@ "provenance": [ { "path": "cosmovirus.tex", - "anchor": "Symbolic Interpretation", + "anchor": "COSMO-D-010", "role": "symbolic_section" } ], @@ -278,7 +278,14 @@ } ], "sources": [], - "falsification": "Pre-register the mapping, observable, dataset split, metric, and matched baselines; reject the hypothesis if held-out performance fails the predeclared threshold or is not distinguishable from the controls.", + "falsification": { + "protocol": "Pre-register the triality-derived mapping, target observable, dataset split, evaluation metric, matched baselines, and decision threshold before evaluating held-out data.", + "rejection_condition": "Reject the hypothesis if held-out performance fails the predeclared threshold or is not distinguishable from the matched control baselines.", + "controls": [ + "Matched baseline models fixed before held-out evaluation", + "Held-out data excluded from mapping and threshold selection" + ] + }, "boundary": "No such predictive result is currently claimed." }, { From d404ec30a191afdc597f2a6ea44a7072c1b09692 Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 09:53:09 +0930 Subject: [PATCH 033/159] Regenerate claim index after provenance hardening --- CLAIM-LEDGER.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/CLAIM-LEDGER.md b/CLAIM-LEDGER.md index 5e06232..c5d265c 100644 --- a/CLAIM-LEDGER.md +++ b/CLAIM-LEDGER.md @@ -150,7 +150,7 @@ - **Boundary:** These phrases are not empirical cosmology, materials science, virology, or causal-mechanism claims. - **Empirical status:** `NON_EMPIRICAL` - **Repository provenance:** - - `cosmovirus.tex` — `Symbolic Interpretation` (`symbolic_section`) + - `cosmovirus.tex` — `COSMO-D-010` (`symbolic_section`) ### COSMO-D-011 — SYMBOLIC @@ -168,7 +168,9 @@ - **Statement:** A future quantitatively specified mapping from triality-derived features to an HPV/capsid observable could be tested for predictive value against matched controls. - **Sources:** none - **Boundary:** No such predictive result is currently claimed. -- **Falsification:** Pre-register the mapping, observable, dataset split, metric, and matched baselines; reject the hypothesis if held-out performance fails the predeclared threshold or is not distinguishable from the controls. +- **Falsification protocol:** Pre-register the triality-derived mapping, target observable, dataset split, evaluation metric, matched baselines, and decision threshold before evaluating held-out data. +- **Rejection condition:** Reject the hypothesis if held-out performance fails the predeclared threshold or is not distinguishable from the matched control baselines. +- **Controls:** Matched baseline models fixed before held-out evaluation; Held-out data excluded from mapping and threshold selection - **Repository provenance:** - `CLAIM-LEDGER.md` — `COSMO-D-012` (`hypothesis_definition`) @@ -196,8 +198,8 @@ 1. New cross-domain public-facing claims require a stable `COSMO-D-###` ID. 2. **SCIENTIFIC** claims require external source records. -3. **HYPOTHESIS** claims must remain `PROPOSED` and include explicit falsification criteria. +3. **HYPOTHESIS** claims must remain `PROPOSED` and include structured falsification criteria. 4. **SYMBOLIC** claims require `empirical_status = NON_EMPIRICAL`. -5. **FORMAL** and **COMPUTATIONAL** claims require reviewed repository provenance. +5. **FORMAL** and **COMPUTATIONAL** claims require reviewed, class-appropriate repository provenance. 6. A source about one domain does not validate a cross-domain bridge. 7. This Markdown file must exactly match the canonical JSON rendering. From ceddf9e1978b7dced9a562c680c8873194ca5b23 Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 09:53:38 +0930 Subject: [PATCH 034/159] Cover source and evidence provenance hardening --- tests/test_phase_d.py | 119 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) diff --git a/tests/test_phase_d.py b/tests/test_phase_d.py index 4c7808e..3be929a 100644 --- a/tests/test_phase_d.py +++ b/tests/test_phase_d.py @@ -1,5 +1,6 @@ import json import runpy +from copy import deepcopy import subprocess import sys import unittest @@ -163,6 +164,124 @@ def test_p16_provenance_anchor_is_claim_specific(self) -> None: "COSMO-D-008", ) + def test_raw_html_is_escaped_in_canonical_markdown(self) -> None: + namespace = self.load_validator_namespace() + render_index = cast( + Callable[[dict[str, Any]], str], + namespace["render_index"], + ) + ledger = deepcopy(self.load_ledger()) + ledger["claims"][0]["statement"] = "|$)", + lambda match: _blank_non_newlines(match.group(0)), + text, + ) + if not path_text.endswith(".tex"): + return text + + lines: list[str] = [] + for line in text.splitlines(keepends=True): + comment_start: int | None = None + for index, character in enumerate(line): + if character != "%": + continue + backslashes = 0 + cursor = index - 1 + while cursor >= 0 and line[cursor] == "\\": + backslashes += 1 + cursor -= 1 + if backslashes % 2 == 0: + comment_start = index + break + if comment_start is None: + lines.append(line) + continue + lines.append( + line[:comment_start] + + _blank_non_newlines(line[comment_start:]) + ) + return "".join(lines) def validate_public_claim_text( @@ -1084,8 +1138,9 @@ def validate_public_claim_text( text: str, claim_classes: dict[str, str], ) -> None: - """Require each positive cross-domain assertion to carry its own ledger ID.""" - paragraphs = re.split(r"\n\s*\n", text) + """Require each rendered positive cross-domain assertion to carry its own ID.""" + rendered_text = strip_public_nonrendered_comments(path_text, text) + paragraphs = re.split(r"\n\s*\n", rendered_text) for paragraph_number, paragraph in enumerate(paragraphs, start=1): compact = " ".join(paragraph.split()) if not compact: From b3657c6f26741fce67cbffce82a0a31595a5d493 Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 12:17:09 +0930 Subject: [PATCH 058/159] Bind D-004 to supporting triality assertion --- cosmovirus.tex | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cosmovirus.tex b/cosmovirus.tex index 39ed7fa..821c5bf 100644 --- a/cosmovirus.tex +++ b/cosmovirus.tex @@ -165,7 +165,8 @@ \section{Core Operators} \begin{operator}[Triality automorphism, $\TRI$]\label{op:tri} Let $\mathrm{Out}(\mathrm{Spin}(8))\cong S_3$ act on the three -$8$-dimensional representations $(\mathbf{8}_v,\mathbf{8}_s,\mathbf{8}_c)$. +$8$-dimensional representations $(\mathbf{8}_v,\mathbf{8}_s,\mathbf{8}_c)$ +(COSMO-D-004). The triality operator $T$ is the order-3 outer automorphism \begin{equation} T:\ \mathbf{8}_v \mapsto \mathbf{8}_s \mapsto \mathbf{8}_c \mapsto \mathbf{8}_v, From 223dbc237a029c1d983159d18b0848d85f592ab1 Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 12:17:13 +0930 Subject: [PATCH 059/159] Use claim-specific D-004 provenance anchor --- claims/claim-ledger.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/claims/claim-ledger.json b/claims/claim-ledger.json index 8fd3bf8..936e427 100644 --- a/claims/claim-ledger.json +++ b/claims/claim-ledger.json @@ -149,7 +149,7 @@ "provenance": [ { "path": "cosmovirus.tex", - "anchor": "Triality automorphism", + "anchor": "COSMO-D-004", "role": "documented_context" } ], From 04bbe3f511e08ee8c746e70e724717baae69298d Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 12:17:17 +0930 Subject: [PATCH 060/159] Regenerate D-004 provenance anchor --- CLAIM-LEDGER.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CLAIM-LEDGER.md b/CLAIM-LEDGER.md index 7765c33..3d0ea46 100644 --- a/CLAIM-LEDGER.md +++ b/CLAIM-LEDGER.md @@ -106,7 +106,7 @@ - **Sources:** SRC-SPIN8-PTEP-2021 - **Boundary:** This mathematical fact does not establish a mechanism connecting Spin(8) triality to HPV, capsids, SiS2, or cosmology. - **Repository provenance:** - - `cosmovirus.tex` — `Triality automorphism` (`documented_context`) + - `cosmovirus.tex` — `COSMO-D-004` (`documented_context`) ### COSMO-D-005 — SCIENTIFIC From 388e5998008713a2b7764b2d00ae85f36402f68f Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 12:17:36 +0930 Subject: [PATCH 061/159] Add regressions for public claim scanner fixes --- tests/test_phase_d.py | 50 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tests/test_phase_d.py b/tests/test_phase_d.py index 9b48674..30973fb 100644 --- a/tests/test_phase_d.py +++ b/tests/test_phase_d.py @@ -513,6 +513,26 @@ def test_scientific_claim_rejects_unrelated_domain_source(self) -> None: {"SRC-E8-MATHWORLD": "mathematics"}, ) + def test_d004_provenance_anchor_is_claim_specific(self) -> None: + ledger = self.load_ledger() + claim = next( + claim for claim in ledger["claims"] + if claim["id"] == "COSMO-D-004" + ) + self.assertEqual( + claim["provenance"][0]["anchor"], + "COSMO-D-004", + ) + source = (REPOSITORY_ROOT / "cosmovirus.tex").read_text( + encoding="utf-8" + ) + self.assertIn( + "$8$-dimensional representations " + "$(\\mathbf{8}_v,\\mathbf{8}_s,\\mathbf{8}_c)$\n" + "(COSMO-D-004).", + source, + ) + def test_public_cross_domain_assertion_requires_claim_id(self) -> None: namespace = self.load_validator_namespace() validate_public_claim_text = cast( @@ -540,6 +560,13 @@ def test_public_cross_domain_assertion_requires_claim_id(self) -> None: claim_classes, ) + with self.assertRaises(SystemExit): + validate_public_claim_text( + "README.md", + "Spin(8) causes HPV16 capsid assembly.", + claim_classes, + ) + for misbound in ( ( "COSMO-D-004 documents Spin(8) triality. " @@ -607,6 +634,12 @@ def test_public_negation_only_suppresses_its_own_assertion(self) -> None: claim_classes, ) + validate_public_claim_text( + "README.md", + "Triality causes no HPV16 capsid changes.", + claim_classes, + ) + validate_public_claim_text( "README.md", ( @@ -617,6 +650,23 @@ def test_public_negation_only_suppresses_its_own_assertion(self) -> None: claim_classes, ) + def test_public_claim_scan_ignores_nonrendered_comments(self) -> None: + namespace = self.load_validator_namespace() + validate_public_claim_text = cast( + Callable[[str, str, dict[str, str]], None], + namespace["validate_public_claim_text"], + ) + validate_public_claim_text( + "cosmovirus.tex", + "% Triality causes HPV16 capsid assembly.\n", + {}, + ) + validate_public_claim_text( + "README.md", + "\n", + {}, + ) + def test_hpv16_reference_accession_is_versioned(self) -> None: ledger = self.load_ledger() source = next( From 105cdddb649dc1add038983f0967d5f5efe3418e Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 12:56:10 +0930 Subject: [PATCH 062/159] Harden Phase D public and source validation --- scripts/validate-claim-ledger.py | 143 +++++++++++++++++++++++++------ 1 file changed, 117 insertions(+), 26 deletions(-) diff --git a/scripts/validate-claim-ledger.py b/scripts/validate-claim-ledger.py index 29f1864..27c0d49 100644 --- a/scripts/validate-claim-ledger.py +++ b/scripts/validate-claim-ledger.py @@ -5,6 +5,7 @@ import ast import html +import ipaddress import json import re import runpy @@ -37,7 +38,7 @@ "year": re.compile(r"(?:19|20)[0-9]{2}$"), } URL_BOUND_IDENTIFIERS = frozenset({"PMID", "PMCID", "DOI", "RefSeq"}) -PINNED_MULTI_ACCESSION_IDENTIFIERS: dict[str, dict[str, str]] = { +PINNED_REVIEWED_SOURCE_IDENTIFIERS: dict[str, dict[str, str]] = { "SRC-SIS2-PMID-25590815": { "PMID": "25590815", "DOI": "10.1021/ic501825r", @@ -46,6 +47,12 @@ "PMID": "17645777", "PMCID": "PMC11158331", }, + "SRC-HPV16-REFSEQ": { + "RefSeq": "NC_001526.4", + }, + "SRC-HPV-P16-PMC8409095": { + "PMCID": "PMC8409095", + }, } PYTHON_DEF_ANCHOR = re.compile(r"def ([A-Za-z_][A-Za-z0-9_]*)$") ALLOWED_STATUSES: dict[str, frozenset[str]] = { @@ -98,12 +105,7 @@ "later", } ) -PUBLIC_GOVERNED_PATHS = ( - "README.md", - "KNOWN_LIMITATIONS.md", - "cosmovirus.tex", - "cosmovirus_cattheory.tex", -) +PUBLIC_GOVERNED_SUFFIXES = frozenset({".md", ".tex"}) PUBLIC_DOMAIN_PATTERNS: dict[str, re.Pattern[str]] = { "mathematics": re.compile( r"(?:(? str: - """Escape raw HTML metacharacters while retaining visible Markdown text.""" - return html.escape(value, quote=False) + """Escape HTML and active inline-Markdown delimiters in visible text.""" + escaped = html.escape(value, quote=False) + replacements = { + "\\": "\", + "`": "`", + "*": "*", + "[": "[", + "]": "]", + "!": "!", + } + return "".join(replacements.get(character, character) for character in escaped) def markdown_code(value: str) -> str: @@ -298,11 +310,43 @@ def validate_source_url(source_id: str, value: object) -> SplitResult: fail(f"{source_id} has malformed URL: {exc}") if parsed.scheme != "https" or not parsed.hostname: fail(f"{source_id} must use an absolute HTTPS URL with a hostname") + validate_source_hostname(source_id, parsed.hostname) if parsed.username is not None or parsed.password is not None: fail(f"{source_id} URL may not contain userinfo") return parsed +def validate_source_hostname(source_id: str, hostname: str) -> None: + """Require a valid IP literal or DNS hostname for external source URLs.""" + try: + ipaddress.ip_address(hostname) + return + except ValueError: + pass + + try: + ascii_hostname = hostname.encode("idna").decode("ascii") + except UnicodeError as exc: + fail(f"{source_id} hostname is not valid IDNA: {exc}") + + if ( + not ascii_hostname + or len(ascii_hostname) > 253 + or ascii_hostname.startswith(".") + or ascii_hostname.endswith(".") + ): + fail(f"{source_id} has invalid DNS hostname {hostname!r}") + + label_pattern = re.compile( + r"[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?" + ) + labels = ascii_hostname.split(".") + if len(labels) < 2 or any( + label_pattern.fullmatch(label) is None for label in labels + ): + fail(f"{source_id} has invalid DNS hostname {hostname!r}") + + def canonical_identifier_url(identifier_type: str, value: str) -> str: """Return the canonical URL representation for a URL-bound identifier.""" if identifier_type == "PMID": @@ -316,29 +360,30 @@ def canonical_identifier_url(identifier_type: str, value: str) -> str: raise AssertionError(f"identifier type {identifier_type!r} is not URL-bound") -def validate_multi_accession_identity( +def validate_reviewed_source_identity( source_id: str, identifiers: dict[str, str], ) -> None: - """Bind every multi-accession source to one reviewed article identity.""" + """Bind reviewed URL-addressable identifiers to the intended source.""" article_identifiers = { key: value for key, value in identifiers.items() if key in URL_BOUND_IDENTIFIERS } - if len(article_identifiers) <= 1: - return + expected = PINNED_REVIEWED_SOURCE_IDENTIFIERS.get(source_id) - expected = PINNED_MULTI_ACCESSION_IDENTIFIERS.get(source_id) if expected is None: - fail( - f"{source_id} multi-accession record lacks a reviewed " - "crosswalk in the validator" - ) + if len(article_identifiers) > 1: + fail( + f"{source_id} multi-accession record lacks a reviewed " + "crosswalk in the validator" + ) + return + if article_identifiers != expected: fail( - f"{source_id} identifiers do not match the reviewed " - f"multi-accession crosswalk: expected {expected!r}" + f"{source_id} identifiers do not match the reviewed source " + f"identity: expected {expected!r}" ) @@ -844,7 +889,7 @@ def render_index(ledger: dict[str, Any]) -> str: url = require_inline_string(source.get("url"), f"{source_id} url") parsed = validate_source_url(source_id, url) identifiers = validate_identifiers(source_id, source.get("identifiers")) - validate_multi_accession_identity(source_id, identifiers) + validate_reviewed_source_identity(source_id, identifiers) identifier_urls = validate_identifier_urls( source_id, identifiers, @@ -1099,13 +1144,45 @@ def _blank_non_newlines(value: str) -> str: return "".join("\n" if character == "\n" else " " for character in value) +def strip_markdown_fenced_blocks(text: str) -> str: + """Blank fenced code blocks without discarding adjacent rendered prose.""" + lines: list[str] = [] + fence_character: str | None = None + fence_length = 0 + + for line in text.splitlines(keepends=True): + if fence_character is None: + match = re.match(r"^ {0,3}(`{3,}|~{3,})", line) + if match is None: + lines.append(line) + continue + marker = match.group(1) + fence_character = marker[0] + fence_length = len(marker) + lines.append(_blank_non_newlines(line)) + continue + + lines.append(_blank_non_newlines(line)) + closing = re.match( + rf"^ {{0,3}}{re.escape(fence_character)}{{{fence_length},}}\s*$", + line.rstrip("\n"), + ) + if closing is not None: + fence_character = None + fence_length = 0 + + return "".join(lines) + + def strip_public_nonrendered_comments(path_text: str, text: str) -> str: - """Remove Markdown HTML and LaTeX comments before public-claim scanning.""" + """Remove non-rendered comments/code before public-claim scanning.""" text = re.sub( r"|$)", lambda match: _blank_non_newlines(match.group(0)), text, ) + if path_text.endswith(".md"): + text = strip_markdown_fenced_blocks(text) if not path_text.endswith(".tex"): return text @@ -1148,7 +1225,6 @@ def validate_public_claim_text( if ( "\\begin{tabular}" in paragraph or "\\begin{longtable}" in paragraph - or "```" in paragraph or compact.startswith("|") ): continue @@ -1215,9 +1291,24 @@ def validate_scientific_sources( ) +def discover_public_governed_paths(root: Path = ROOT) -> tuple[str, ...]: + """Discover repository-root Markdown/LaTeX documents governed by Phase D.""" + paths = tuple( + sorted( + path.name + for path in root.iterdir() + if path.is_file() + and path.suffix.lower() in PUBLIC_GOVERNED_SUFFIXES + ) + ) + if not paths: + fail("no repository-root public Markdown/LaTeX documents found") + return paths + + def validate_public_documents(claim_classes: dict[str, str]) -> None: - """Apply the public cross-domain claim-ID guard to governed documents.""" - for path_text in PUBLIC_GOVERNED_PATHS: + """Apply the public cross-domain claim-ID guard to discovered documents.""" + for path_text in discover_public_governed_paths(): path = ROOT / path_text try: text = path.read_text(encoding="utf-8") @@ -1258,7 +1349,7 @@ def validate() -> None: require_inline_string(source.get("title"), f"{source_id} title") parsed = validate_source_url(source_id, source.get("url")) identifiers = validate_identifiers(source_id, source.get("identifiers")) - validate_multi_accession_identity(source_id, identifiers) + validate_reviewed_source_identity(source_id, identifiers) identifier_urls = validate_identifier_urls( source_id, identifiers, From 580645f94ae685bd34a1d4b26df1b73f41e4e9c3 Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 12:56:25 +0930 Subject: [PATCH 063/159] Bind D-005 to supporting crystallography assertion --- claims/claim-ledger.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/claims/claim-ledger.json b/claims/claim-ledger.json index 936e427..4f1d018 100644 --- a/claims/claim-ledger.json +++ b/claims/claim-ledger.json @@ -168,7 +168,7 @@ "provenance": [ { "path": "cosmovirus.tex", - "anchor": "Silicon disulfide", + "anchor": "COSMO-D-005", "role": "documented_context" } ], From 3f222fd10814a30fa0adb2737f3a11caa2b800aa Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 12:56:30 +0930 Subject: [PATCH 064/159] Regenerate D-005 provenance anchor --- CLAIM-LEDGER.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CLAIM-LEDGER.md b/CLAIM-LEDGER.md index 3d0ea46..5b15ac8 100644 --- a/CLAIM-LEDGER.md +++ b/CLAIM-LEDGER.md @@ -116,7 +116,7 @@ - **Sources:** SRC-SIS2-PMID-25590815 - **Boundary:** This crystallographic fact does not support COSMO's symbolic substrate or life-code interpretation. - **Repository provenance:** - - `cosmovirus.tex` — `Silicon disulfide` (`documented_context`) + - `cosmovirus.tex` — `COSMO-D-005` (`documented_context`) ### COSMO-D-006 — SCIENTIFIC From 4de5eaffc584029e85f96361bd8b7e6eb5ca1453 Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 12:56:53 +0930 Subject: [PATCH 065/159] Add regressions for current Codex findings --- tests/test_phase_d.py | 116 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 115 insertions(+), 1 deletion(-) diff --git a/tests/test_phase_d.py b/tests/test_phase_d.py index 30973fb..d3dfbba 100644 --- a/tests/test_phase_d.py +++ b/tests/test_phase_d.py @@ -321,7 +321,7 @@ def test_multi_accession_crosswalk_rejects_unrelated_article_ids(self) -> None: namespace = self.load_validator_namespace() validate_crosswalk = cast( Callable[[str, dict[str, str]], None], - namespace["validate_multi_accession_identity"], + namespace["validate_reviewed_source_identity"], ) with self.assertRaises(SystemExit): validate_crosswalk( @@ -667,6 +667,120 @@ def test_public_claim_scan_ignores_nonrendered_comments(self) -> None: {}, ) + def test_d005_provenance_anchor_is_claim_specific(self) -> None: + ledger = self.load_ledger() + claim = next( + claim for claim in ledger["claims"] + if claim["id"] == "COSMO-D-005" + ) + self.assertEqual( + claim["provenance"][0]["anchor"], + "COSMO-D-005", + ) + source = (REPOSITORY_ROOT / "cosmovirus.tex").read_text( + encoding="utf-8" + ) + self.assertIn( + "edge-sharing $\\mathrm{SiS_4}$ tetrahedra (COSMO-D-005)", + source, + ) + + def test_public_claim_scan_keeps_prose_adjacent_to_fenced_blocks(self) -> None: + namespace = self.load_validator_namespace() + validate_public_claim_text = cast( + Callable[[str, str, dict[str, str]], None], + namespace["validate_public_claim_text"], + ) + with self.assertRaises(SystemExit): + validate_public_claim_text( + "README.md", + ( + "Spin(8) triality causes HPV16 capsid assembly.\n" + "```text\n" + "Spin(8) triality causes HPV16 capsid assembly.\n" + "```\n" + ), + {}, + ) + validate_public_claim_text( + "README.md", + ( + "```text\n" + "Spin(8) triality causes HPV16 capsid assembly.\n" + "```\n" + ), + {}, + ) + + def test_public_claim_guard_detects_enabling_language(self) -> None: + namespace = self.load_validator_namespace() + validate_public_claim_text = cast( + Callable[[str, str, dict[str, str]], None], + namespace["validate_public_claim_text"], + ) + with self.assertRaises(SystemExit): + validate_public_claim_text( + "README.md", + "Spin(8) triality enables HPV16 capsid assembly.", + {}, + ) + + def test_single_accession_source_identity_is_pinned(self) -> None: + namespace = self.load_validator_namespace() + validate_identity = cast( + Callable[[str, dict[str, str]], None], + namespace["validate_reviewed_source_identity"], + ) + with self.assertRaises(SystemExit): + validate_identity( + "SRC-HPV16-REFSEQ", + {"RefSeq": "NC_001527.1"}, + ) + validate_identity( + "SRC-HPV16-REFSEQ", + {"RefSeq": "NC_001526.4"}, + ) + + def test_source_url_rejects_invalid_dns_hostname(self) -> None: + namespace = self.load_validator_namespace() + validate_source_url = cast( + Callable[[str, object], Any], + namespace["validate_source_url"], + ) + with self.assertRaises(SystemExit): + validate_source_url("SRC-TEST", "https://.") + + def test_visible_markdown_fields_escape_inline_constructs(self) -> None: + namespace = self.load_validator_namespace() + markdown_text = cast( + Callable[[str], str], + namespace["markdown_text"], + ) + rendered = markdown_text( + "" + ) + self.assertNotIn("![tracking]", rendered) + self.assertIn("![tracking]", rendered) + + def test_public_document_discovery_includes_new_root_documents(self) -> None: + namespace = self.load_validator_namespace() + discover_paths = cast( + Callable[[Path], tuple[str, ...]], + namespace["discover_public_governed_paths"], + ) + with tempfile.TemporaryDirectory() as temporary: + root = Path(temporary) + (root / "README.md").write_text("readme\n", encoding="utf-8") + (root / "NEW_PUBLIC.md").write_text( + "Spin(8) triality causes HPV16 capsid assembly.\n", + encoding="utf-8", + ) + (root / "notes.txt").write_text("not public\n", encoding="utf-8") + self.assertEqual( + discover_paths(root), + ("NEW_PUBLIC.md", "README.md"), + ) + def test_hpv16_reference_accession_is_versioned(self) -> None: ledger = self.load_ledger() source = next( From 418fcc9093a2117171b4eae87dc3fae0aa217855 Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Thu, 24 Sep 2026 12:57:40 +0930 Subject: [PATCH 066/159] Update Markdown escaping regression expectation --- tests/test_phase_d.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_phase_d.py b/tests/test_phase_d.py index d3dfbba..bccb143 100644 --- a/tests/test_phase_d.py +++ b/tests/test_phase_d.py @@ -191,7 +191,7 @@ def test_raw_html_is_escaped_in_canonical_markdown(self) -> None: rendered = render_index(ledger) self.assertNotIn("|$)", - lambda match: _blank_non_newlines(match.group(0)), + "", text, ) if Path(path_text).suffix.lower() in {".md", ".markdown"}: @@ -2517,6 +2610,11 @@ def strip_public_nonrendered_comments(path_text: str, text: str) -> str: text, ) text = strip_latex_disabled_branches(text) + text = re.sub( + r"\\label\s*\{[^{}\n]*\}", + lambda match: _blank_non_newlines(match.group(0)), + text, + ) lines: list[str] = [] for line in text.splitlines(keepends=True): @@ -2642,7 +2740,7 @@ def validate_reviewed_claim_record( """Prevent any field of a reviewed Phase D claim from silently drifting.""" expected = PINNED_REVIEWED_CLAIM_RECORDS.get(claim_id) if expected is None: - return + fail(f"{claim_id} lacks a complete reviewed claim-record binding") if claim != expected: fail(f"{claim_id} differs from its complete reviewed claim record") From 25a190ede9bf4042e5264f42f561ee5c7c83f67d Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Sun, 27 Sep 2026 13:15:45 +0930 Subject: [PATCH 086/159] Add regressions for fresh Phase D review findings --- tests/test_phase_d.py | 110 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/tests/test_phase_d.py b/tests/test_phase_d.py index 89b4340..f25cb57 100644 --- a/tests/test_phase_d.py +++ b/tests/test_phase_d.py @@ -793,6 +793,27 @@ def test_regression_must_exercise_declared_implementation(self) -> None: "test_required_regression", disabled_after_selected_return, ) + unreachable_inside_try = ( + "import unittest\n" + "from cosmo_core.e8 import validate_e8_root_system\n" + "class RegressionEvidence(unittest.TestCase):\n" + " def test_required_regression(self) -> None:\n" + " try:\n" + " return\n" + " validate_e8_root_system()\n" + " finally:\n" + " pass\n" + ) + with self.assertRaises(SystemExit): + validate_connection( + "COSMO-D-003", + "cosmo_core/e8.py", + "def validate_e8_root_system", + "tests/test_regression.py", + "test_required_regression", + unreachable_inside_try, + ) + disabled_by_false_literal_comparison = ( "import unittest\n" "from cosmo_core.e8 import validate_e8_root_system\n" @@ -878,6 +899,23 @@ def test_implementation_provenance_requires_executable_project_source(self) -> N "Phase B3\n", ) + decorator_replacement = ( + "def replace(function):\n" + " def fake() -> None:\n" + " return None\n" + " return fake\n" + "@replace\n" + "def validate_e8_root_system() -> None:\n" + " raise AssertionError('reviewed body must execute')\n" + ) + with self.assertRaises(SystemExit): + validate_implementation( + "COSMO-D-003", + "cosmo_core/e8.py", + "def validate_e8_root_system", + decorator_replacement, + ) + rebound_export = ( "def validate_e8_root_system() -> None:\n" " return None\n" @@ -942,6 +980,11 @@ def test_reviewed_claim_record_rejects_any_field_drift(self) -> None: with self.assertRaises(SystemExit): validate_record("COSMO-D-009", expanded_boundary) + unreviewed = deepcopy(symbolic) + unreviewed["id"] = "COSMO-D-015" + with self.assertRaises(SystemExit): + validate_record("COSMO-D-015", unreviewed) + def test_reviewed_claim_inventory_rejects_deleted_claim(self) -> None: namespace = self.load_validator_namespace() validate_inventory = cast( @@ -1026,6 +1069,11 @@ def test_documentary_anchor_ignores_latex_comments(self) -> None: "\\iffalse hidden\\else COSMO-D-004\\fi\n", ) self.assertIn("COSMO-D-004", visible_else) + label_only = strip_comments( + "sample.tex", + "\\label{COSMO-D-004}\n", + ) + self.assertNotIn("COSMO-D-004", label_only) def test_d004_provenance_anchor_is_claim_specific(self) -> None: ledger = self.load_ledger() @@ -1109,6 +1157,12 @@ def test_public_cross_domain_assertion_requires_claim_id(self) -> None: "Spin(8) triality activates HPV16 capsid assembly.", claim_classes, ) + with self.assertRaises(SystemExit): + validate_public_claim_text( + "README.md", + "Spin(8) triality inhibits HPV16 capsid assembly.", + claim_classes, + ) for causal_verb in ("controls", "regulates", "modulates", "governs"): with self.subTest(causal_verb=causal_verb): @@ -1224,6 +1278,26 @@ def test_public_claim_guard_ignores_html_raw_text_payloads(self) -> None: {}, ) + def test_public_claim_guard_preserves_html_paragraph_boundaries(self) -> None: + namespace = self.load_validator_namespace() + validate_public_claim_text = cast( + Callable[[str, str, dict[str, str]], None], + namespace["validate_public_claim_text"], + ) + claim_classes = { + claim["id"]: claim["class"] + for claim in self.load_ledger()["claims"] + } + with self.assertRaises(SystemExit): + validate_public_claim_text( + "sample.md", + ( + "
COSMO-D-012
\n" + "Spin(8) triality causes HPV16 capsid assembly.
" + ), + claim_classes, + ) + def test_public_claim_guard_handles_quoted_greater_than_in_html(self) -> None: namespace = self.load_validator_namespace() validate_public_claim_text = cast( @@ -1366,6 +1440,24 @@ def test_public_claim_guard_normalizes_latex_formatting(self) -> None: {}, ) + def test_public_e7_math_context_is_not_biomedical(self) -> None: + namespace = self.load_validator_namespace() + validate_public_claim_text = cast( + Callable[[str, str, dict[str, str]], None], + namespace["validate_public_claim_text"], + ) + validate_public_claim_text( + "math.md", + "E8 branching produces E7 representations.", + {}, + ) + with self.assertRaises(SystemExit): + validate_public_claim_text( + "sample.md", + "Spin(8) triality causes E7 protein expression.", + {}, + ) + def test_public_claim_domains_are_proposition_local(self) -> None: namespace = self.load_validator_namespace() validate_public_claim_text = cast( @@ -1417,6 +1509,15 @@ def test_public_negation_only_suppresses_its_own_assertion(self) -> None: "There is no doubt that Spin(8) triality causes HPV16 capsid assembly.", claim_classes, ) + with self.assertRaises(SystemExit): + validate_public_claim_text( + "README.md", + ( + "No caveat changes the fact that Spin(8) triality " + "causes HPV16 capsid assembly." + ), + claim_classes, + ) validate_public_claim_text( "README.md", @@ -1493,6 +1594,15 @@ def test_public_claim_scan_ignores_nonrendered_comments(self) -> None: "\n", {}, ) + with self.assertRaises(SystemExit): + validate_public_claim_text( + "README.md", + ( + "Spin(8) triality " + "causes HPV16 capsid assembly." + ), + {}, + ) def test_d005_provenance_anchor_is_claim_specific(self) -> None: ledger = self.load_ledger() From 05f4afa420283164348003c6da24ad711ec13d57 Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Sun, 27 Sep 2026 13:47:44 +0930 Subject: [PATCH 087/159] Fix latest Phase D evidence and rendering findings --- scripts/validate-claim-ledger.py | 156 ++++++++++++++++++++++++++++--- 1 file changed, 142 insertions(+), 14 deletions(-) diff --git a/scripts/validate-claim-ledger.py b/scripts/validate-claim-ledger.py index fd2ee09..42c3db3 100644 --- a/scripts/validate-claim-ledger.py +++ b/scripts/validate-claim-ledger.py @@ -517,7 +517,8 @@ re.IGNORECASE, ), "biomedicine": re.compile( - r"\b(?:HPV16|HPV|capsid|p16)\b", + r"\b(?:HPV16|HPV|capsid|p16|human\s+papillomavirus" + r"(?:\s+type\s+16)?)\b", re.IGNORECASE, ), "materials_science": re.compile( @@ -538,7 +539,10 @@ "triality": re.compile(r"\btriality\b", re.IGNORECASE), "e8": re.compile(r"\b(?:E8|E_8)\b", re.IGNORECASE), "weyl": re.compile(r"\bWeyl\b", re.IGNORECASE), - "hpv": re.compile(r"\b(?:HPV16|HPV)\b", re.IGNORECASE), + "hpv": re.compile( + r"\b(?:HPV16|HPV|human\s+papillomavirus(?:\s+type\s+16)?)\b", + re.IGNORECASE, + ), "capsid": re.compile(r"\bcapsid\b", re.IGNORECASE), "e6": re.compile(r"\bE6\b", re.IGNORECASE), "e7": re.compile(r"\bE7\b", re.IGNORECASE), @@ -821,6 +825,34 @@ def canonical_identifier_url(identifier_type: str, value: str) -> str: raise AssertionError(f"identifier type {identifier_type!r} is not URL-bound") +SOURCE_RECORD_FIELDS = frozenset( + { + "id", + "kind", + "title", + "url", + "identifiers", + "domain", + "identifier_urls", + } +) + + +def validate_reviewed_source_fields( + source_id: str, + source: dict[str, Any], +) -> None: + """Reject missing or unreviewed fields in canonical source records.""" + actual_fields = set(source) + if actual_fields != SOURCE_RECORD_FIELDS: + missing = sorted(SOURCE_RECORD_FIELDS - actual_fields) + extra = sorted(actual_fields - SOURCE_RECORD_FIELDS) + fail( + f"{source_id} source record fields differ from reviewed schema; " + f"missing={missing}, extra={extra}" + ) + + def validate_reviewed_source_record( source_id: str, kind: str, @@ -1133,6 +1165,12 @@ def locate_unittest_regression( "Phase D requires a synchronously executed unittest method" ) if isinstance(member, ast.FunctionDef) and member.name == anchor: + if member.decorator_list: + fail( + f"{claim_id} regression anchor {anchor!r} must be " + "undecorated so the reviewed method body is the " + "executed unittest method" + ) if function_contains_yield(member): fail( f"{claim_id} regression anchor {anchor!r} may not be " @@ -1212,6 +1250,12 @@ def visit_Call(self, node: ast.Call) -> None: return self.generic_visit(node) + def visit_GeneratorExp(self, node: ast.GeneratorExp) -> None: + # A generator body is deferred. Python evaluates only the outermost + # iterable when the generator object is created. + if node.generators: + self.visit(node.generators[0].iter) + def visit_FunctionDef(self, node: ast.FunctionDef) -> None: return @@ -1391,6 +1435,68 @@ def _static_selected_exit_kind( return None +def _expression_is_obviously_nonraising(expression: ast.expr | None) -> bool: + if expression is None or isinstance(expression, ast.Constant): + return True + if isinstance(expression, (ast.Tuple, ast.List, ast.Set)): + return all( + _expression_is_obviously_nonraising(item) + for item in expression.elts + ) + if isinstance(expression, ast.Dict): + return all( + _expression_is_obviously_nonraising(item) + for item in [*expression.keys, *expression.values] + if item is not None + ) + return False + + +def _assignment_target_is_obviously_safe(target: ast.expr) -> bool: + if isinstance(target, ast.Name): + return True + if isinstance(target, (ast.Tuple, ast.List)): + return all( + _assignment_target_is_obviously_safe(item) + for item in target.elts + ) + return False + + +def _statements_may_raise(statements: list[ast.stmt]) -> bool: + """Return false only for statement sequences that are trivially non-raising.""" + for statement in statements: + if isinstance(statement, (ast.Pass, ast.Break, ast.Continue)): + continue + if isinstance(statement, ast.Return): + if _expression_is_obviously_nonraising(statement.value): + continue + return True + if isinstance(statement, ast.Expr): + if _expression_is_obviously_nonraising(statement.value): + continue + return True + if isinstance(statement, ast.Assign): + if ( + _expression_is_obviously_nonraising(statement.value) + and all( + _assignment_target_is_obviously_safe(target) + for target in statement.targets + ) + ): + continue + return True + if isinstance(statement, ast.AnnAssign): + if ( + _assignment_target_is_obviously_safe(statement.target) + and _expression_is_obviously_nonraising(statement.value) + ): + continue + return True + return True + return False + + def _reachable_statements_call_function( statements: list[ast.stmt], function_name: str, @@ -1492,7 +1598,10 @@ def _reachable_statements_call_function( statement.body, module_constants, ) - if body_exit not in {"return", "break", "continue"}: + if ( + body_exit not in {"return", "break", "continue"} + and _statements_may_raise(statement.body) + ): for handler in statement.handlers: if _reachable_statements_call_function( handler.body, @@ -1500,6 +1609,7 @@ def _reachable_statements_call_function( module_constants, ): return True + if body_exit not in {"return", "break", "continue"}: if _reachable_statements_call_function( statement.orelse, function_name, @@ -1633,6 +1743,18 @@ def visit_Lambda(self, node: ast.Lambda) -> None: def _method_mutates_binding(method: ast.FunctionDef, binding: str) -> bool: + parameters = [ + *method.args.posonlyargs, + *method.args.args, + *method.args.kwonlyargs, + ] + if method.args.vararg is not None: + parameters.append(method.args.vararg) + if method.args.kwarg is not None: + parameters.append(method.args.kwarg) + if any(parameter.arg == binding for parameter in parameters): + return True + finder = _BindingMutationFinder(binding) for statement in method.body: finder.visit(statement) @@ -2032,6 +2154,7 @@ def render_index(ledger: dict[str, Any]) -> str: if not isinstance(source, dict): fail("source entries must be objects") source_id = require_inline_string(source.get("id"), "source id") + validate_reviewed_source_fields(source_id, source) kind = validate_source_kind(source_id, source.get("kind")) source_domain = validate_source_domain(source_id, source.get("domain")) title = require_inline_string(source.get("title"), f"{source_id} title") @@ -2500,8 +2623,11 @@ def normalize_markdown_visible_text(text: str) -> str: def split_public_rendered_blocks(path_text: str, text: str) -> list[str]: - """Keep rendered Markdown block boundaries when binding claim IDs.""" - if Path(path_text).suffix.lower() in {".md", ".markdown"}: + """Keep rendered block boundaries when binding claim IDs.""" + suffix = Path(path_text).suffix.lower() + if suffix == ".tex": + text = re.sub(r"\\par\b", "\n\n", text) + if suffix in {".md", ".markdown"}: text = re.sub( r"(?m)^(?= {0,3}(?:[-+*]|[0-9]+[.)])\s+)", "\n\n", @@ -2633,10 +2759,9 @@ def strip_public_nonrendered_comments(path_text: str, text: str) -> str: if comment_start is None: lines.append(line) continue - lines.append( - line[:comment_start] - + _blank_non_newlines(line[comment_start:]) - ) + # TeX comments consume their terminating physical newline, so + # visible text on the next source line joins directly to this prefix. + lines.append(line[:comment_start]) return "".join(lines) @@ -2646,14 +2771,16 @@ def validate_public_claim_text( claim_classes: dict[str, str], ) -> None: """Require each rendered positive cross-domain assertion to carry its own ID.""" - rendered_text = html.unescape( - strip_public_nonrendered_comments(path_text, text) - ) + rendered_text = strip_public_nonrendered_comments(path_text, text) suffix = Path(path_text).suffix.lower() if suffix in {".md", ".markdown"}: + # Parse source HTML before decoding character references. Encoded + # markup remains visible text rather than becoming raw HTML. rendered_text = normalize_markdown_visible_text(rendered_text) - elif suffix == ".tex": - rendered_text = normalize_latex_visible_text(rendered_text) + else: + rendered_text = html.unescape(rendered_text) + if suffix == ".tex": + rendered_text = normalize_latex_visible_text(rendered_text) paragraphs = split_public_rendered_blocks(path_text, rendered_text) for paragraph_number, paragraph in enumerate(paragraphs, start=1): compact = " ".join(paragraph.split()) @@ -2844,6 +2971,7 @@ def validate() -> None: if source_id in source_ids: fail(f"duplicate source id {source_id}") source_ids.add(source_id) + validate_reviewed_source_fields(source_id, source) kind = validate_source_kind(source_id, source.get("kind")) source_kinds[source_id] = kind From 5a43e8a6d0c305bbe476ee8c617189755626d196 Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Sun, 27 Sep 2026 13:47:47 +0930 Subject: [PATCH 088/159] Add regressions for latest Phase D findings --- tests/test_phase_d.py | 158 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) diff --git a/tests/test_phase_d.py b/tests/test_phase_d.py index f25cb57..1278634 100644 --- a/tests/test_phase_d.py +++ b/tests/test_phase_d.py @@ -357,6 +357,18 @@ def test_identifier_free_reviewed_source_record_is_pinned(self) -> None: "mathematics", ) + def test_reviewed_source_record_rejects_unreviewed_fields(self) -> None: + namespace = self.load_validator_namespace() + validate_fields = cast( + Callable[[str, dict[str, Any]], None], + namespace["validate_reviewed_source_fields"], + ) + source = deepcopy(self.load_ledger()["sources"][0]) + validate_fields(source["id"], source) + source["unreviewed_note"] = "Spin(8) causes HPV16 disease." + with self.assertRaises(SystemExit): + validate_fields(source["id"], source) + def test_reviewed_source_identity_pins_non_url_metadata(self) -> None: namespace = self.load_validator_namespace() validate_identity = cast( @@ -793,6 +805,43 @@ def test_regression_must_exercise_declared_implementation(self) -> None: "test_required_regression", disabled_after_selected_return, ) + unconsumed_generator = ( + "import unittest\n" + "from cosmo_core.e8 import validate_e8_root_system\n" + "class RegressionEvidence(unittest.TestCase):\n" + " def test_required_regression(self) -> None:\n" + " _unused = (validate_e8_root_system(()) for _ in (1,))\n" + ) + with self.assertRaises(SystemExit): + validate_connection( + "COSMO-D-003", + "cosmo_core/e8.py", + "def validate_e8_root_system", + "tests/test_regression.py", + "test_required_regression", + unconsumed_generator, + ) + + unreachable_handler = ( + "import unittest\n" + "from cosmo_core.e8 import validate_e8_root_system\n" + "class RegressionEvidence(unittest.TestCase):\n" + " def test_required_regression(self) -> None:\n" + " try:\n" + " pass\n" + " except Exception:\n" + " validate_e8_root_system(())\n" + ) + with self.assertRaises(SystemExit): + validate_connection( + "COSMO-D-003", + "cosmo_core/e8.py", + "def validate_e8_root_system", + "tests/test_regression.py", + "test_required_regression", + unreachable_handler, + ) + unreachable_inside_try = ( "import unittest\n" "from cosmo_core.e8 import validate_e8_root_system\n" @@ -829,6 +878,27 @@ def test_regression_must_exercise_declared_implementation(self) -> None: "test_required_regression", disabled_by_false_literal_comparison, ) + shadowed_by_parameter = ( + "import unittest\n" + "from collections.abc import Callable\n" + "from cosmo_core.e8 import validate_e8_root_system\n" + "class RegressionEvidence(unittest.TestCase):\n" + " def test_required_regression(\n" + " self,\n" + " validate_e8_root_system: Callable[..., None] = lambda *_: None,\n" + " ) -> None:\n" + " validate_e8_root_system(())\n" + ) + with self.assertRaises(SystemExit): + validate_connection( + "COSMO-D-003", + "cosmo_core/e8.py", + "def validate_e8_root_system", + "tests/test_regression.py", + "test_required_regression", + shadowed_by_parameter, + ) + rebound_by_with_target = ( "import unittest\n" "from contextlib import nullcontext\n" @@ -899,6 +969,29 @@ def test_implementation_provenance_requires_executable_project_source(self) -> N "Phase B3\n", ) + decorated_regression = ( + "import unittest\n" + "from collections.abc import Callable\n" + "from cosmo_core.e8 import validate_e8_root_system\n" + "def replace(function: Callable[..., None]) -> Callable[..., None]:\n" + " def fake(self: unittest.TestCase) -> None:\n" + " return None\n" + " return fake\n" + "class RegressionEvidence(unittest.TestCase):\n" + " @replace\n" + " def test_required_regression(self) -> None:\n" + " validate_e8_root_system(())\n" + ) + with self.assertRaises(SystemExit): + validate_connection( + "COSMO-D-003", + "cosmo_core/e8.py", + "def validate_e8_root_system", + "tests/test_regression.py", + "test_required_regression", + decorated_regression, + ) + decorator_replacement = ( "def replace(function):\n" " def fake() -> None:\n" @@ -1228,6 +1321,22 @@ def test_public_claim_guard_decodes_character_references(self) -> None: with self.assertRaises(SystemExit): validate_public_claim_text("sample.md", encoded, {}) + def test_public_claim_guard_preserves_encoded_html_as_visible_text(self) -> None: + namespace = self.load_validator_namespace() + validate_public_claim_text = cast( + Callable[[str, str, dict[str, str]], None], + namespace["validate_public_claim_text"], + ) + with self.assertRaises(SystemExit): + validate_public_claim_text( + "sample.md", + ( + "<script>Spin(8) triality causes " + "HPV16 capsid assembly.</script>" + ), + {}, + ) + def test_public_claim_guard_normalizes_markdown_rendering(self) -> None: namespace = self.load_validator_namespace() validate_public_claim_text = cast( @@ -1440,6 +1549,26 @@ def test_public_claim_guard_normalizes_latex_formatting(self) -> None: {}, ) + def test_public_latex_paragraph_command_splits_claim_scope(self) -> None: + namespace = self.load_validator_namespace() + validate_public_claim_text = cast( + Callable[[str, str, dict[str, str]], None], + namespace["validate_public_claim_text"], + ) + claim_classes = { + claim["id"]: claim["class"] + for claim in self.load_ledger()["claims"] + } + with self.assertRaises(SystemExit): + validate_public_claim_text( + "sample.tex", + ( + "COSMO-D-012\\par " + "Spin(8) triality causes HPV16 capsid assembly." + ), + claim_classes, + ) + def test_public_e7_math_context_is_not_biomedical(self) -> None: namespace = self.load_validator_namespace() validate_public_claim_text = cast( @@ -1458,6 +1587,22 @@ def test_public_e7_math_context_is_not_biomedical(self) -> None: {}, ) + def test_public_claim_guard_recognizes_spelled_out_hpv16(self) -> None: + namespace = self.load_validator_namespace() + validate_public_claim_text = cast( + Callable[[str, str, dict[str, str]], None], + namespace["validate_public_claim_text"], + ) + with self.assertRaises(SystemExit): + validate_public_claim_text( + "sample.md", + ( + "Spin(8) triality causes human papillomavirus " + "type 16 infection." + ), + {}, + ) + def test_public_claim_domains_are_proposition_local(self) -> None: namespace = self.load_validator_namespace() validate_public_claim_text = cast( @@ -1594,6 +1739,19 @@ def test_public_claim_scan_ignores_nonrendered_comments(self) -> None: "\n", {}, ) + with self.assertRaises(SystemExit): + validate_public_claim_text( + "sample.tex", + ( + "Sp% join\n" + "in(8) tria% join\n" + "lity ca% join\n" + "uses H% join\n" + "PV16 cap% join\n" + "sid assembly." + ), + {}, + ) with self.assertRaises(SystemExit): validate_public_claim_text( "README.md", From 8cf2172daab243b80f340cd2063e47908533c5ca Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Sun, 27 Sep 2026 13:48:38 +0930 Subject: [PATCH 089/159] Fix Phase D decorator regression test harness --- tests/test_phase_d.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test_phase_d.py b/tests/test_phase_d.py index 1278634..173ef78 100644 --- a/tests/test_phase_d.py +++ b/tests/test_phase_d.py @@ -961,6 +961,10 @@ def test_implementation_provenance_requires_executable_project_source(self) -> N Callable[[str, str, str, str], None], namespace["validate_computational_implementation_target"], ) + validate_connection = cast( + Callable[[str, str, str, str, str, str], None], + namespace["validate_computational_evidence_connection"], + ) with self.assertRaises(SystemExit): validate_implementation( "COSMO-D-003", From 77c78fe948987b3558d0ae849728d2f6d9797e51 Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Sun, 27 Sep 2026 14:21:13 +0930 Subject: [PATCH 090/159] Fix latest Phase D execution and rendering findings --- scripts/validate-claim-ledger.py | 161 +++++++++++++++++++++++++++++-- 1 file changed, 152 insertions(+), 9 deletions(-) diff --git a/scripts/validate-claim-ledger.py b/scripts/validate-claim-ledger.py index 42c3db3..6a54695 100644 --- a/scripts/validate-claim-ledger.py +++ b/scripts/validate-claim-ledger.py @@ -1025,6 +1025,35 @@ def strip_lean_comments(text: str) -> str: return "".join(result) +def strip_lean_syntax_quotations(text: str) -> str: + """Blank Lean syntax quotations while preserving line structure.""" + result = list(text) + index = 0 + opener = re.compile(r"`\([A-Za-z_][A-Za-z0-9_]*\|") + while index < len(text): + match = opener.match(text, index) + if match is None: + index += 1 + continue + + cursor = match.end() + depth = 1 + while cursor < len(text) and depth: + character = text[cursor] + if character == "(": + depth += 1 + elif character == ")": + depth -= 1 + cursor += 1 + + end = cursor if depth == 0 else len(text) + for position in range(index, end): + result[position] = "\n" if text[position] == "\n" else " " + index = end + + return "".join(result) + + def protected_lean_sources() -> set[str]: """Execute the protected runner's source-inventory mode.""" try: @@ -1098,7 +1127,8 @@ def validate_formal_provenance_target( "declaration through ':= by'" ) comment_free_text = strip_lean_comments(text) - normalized_source = normalize_lean_declaration(comment_free_text) + declaration_text = strip_lean_syntax_quotations(comment_free_text) + normalized_source = normalize_lean_declaration(declaration_text) normalized_anchor = normalize_lean_declaration(anchor) if normalized_anchor not in normalized_source: fail( @@ -1158,6 +1188,17 @@ def locate_unittest_regression( for node in tree.body: if not isinstance(node, ast.ClassDef): continue + contains_anchor = any( + isinstance(member, (ast.FunctionDef, ast.AsyncFunctionDef)) + and member.name == anchor + for member in node.body + ) + if contains_anchor and node.decorator_list: + fail( + f"{claim_id} regression class {node.name!r} containing " + f"{anchor!r} must be undecorated so the reviewed class is " + "the executed unittest class" + ) for member in node.body: if isinstance(member, ast.AsyncFunctionDef) and member.name == anchor: fail( @@ -1250,6 +1291,37 @@ def visit_Call(self, node: ast.Call) -> None: return self.generic_visit(node) + def _visit_comprehension( + self, + generators: list[ast.comprehension], + body: list[ast.expr], + ) -> None: + for generator in generators: + self.visit(generator.iter) + if self.found: + return + if _static_iterable_has_items(generator.iter) is False: + return + for condition in generator.ifs: + self.visit(condition) + if self.found: + return + if _static_boolean_value(condition, {}) is False: + return + for expression in body: + self.visit(expression) + if self.found: + return + + def visit_ListComp(self, node: ast.ListComp) -> None: + self._visit_comprehension(node.generators, [node.elt]) + + def visit_SetComp(self, node: ast.SetComp) -> None: + self._visit_comprehension(node.generators, [node.elt]) + + def visit_DictComp(self, node: ast.DictComp) -> None: + self._visit_comprehension(node.generators, [node.key, node.value]) + def visit_GeneratorExp(self, node: ast.GeneratorExp) -> None: # A generator body is deferred. Python evaluates only the outermost # iterable when the generator object is created. @@ -1920,6 +1992,11 @@ def validate_computational_regression_target( str(path), run_name=f"_cosmo_claim_regression_{claim_id.replace('-', '_')}", ) + except SystemExit as exc: + fail( + f"{claim_id} cannot load regression evidence {path_text}: " + f"SystemExit({exc.code!r})" + ) except Exception as exc: fail( f"{claim_id} cannot load regression evidence {path_text}: " @@ -2531,7 +2608,7 @@ def strip_markdown_link_destinations(text: str) -> str: class _VisibleHTMLTextParser(HTMLParser): - """Collect rendered inline-HTML text while discarding tags/attributes.""" + """Collect rendered inline-HTML text while discarding hidden/raw subtrees.""" BLOCK_TAGS = frozenset( { @@ -2560,10 +2637,31 @@ class _VisibleHTMLTextParser(HTMLParser): } ) + VOID_TAGS = frozenset( + { + "area", + "base", + "br", + "col", + "embed", + "hr", + "img", + "input", + "link", + "meta", + "param", + "source", + "track", + "wbr", + } + ) + def __init__(self) -> None: super().__init__(convert_charrefs=True) self.parts: list[str] = [] self.raw_text_depth = 0 + self.hidden_depth = 0 + self.open_tags: list[tuple[str, bool]] = [] def _append_block_boundary(self) -> None: if not self.parts or not self.parts[-1].endswith("\n\n"): @@ -2574,31 +2672,63 @@ def handle_starttag( tag: str, attrs: list[tuple[str, str | None]], ) -> None: - del attrs normalized = tag.lower() + hidden_here = any(name.lower() == "hidden" for name, _value in attrs) + + if normalized in self.VOID_TAGS: + if ( + not hidden_here + and self.raw_text_depth == 0 + and self.hidden_depth == 0 + and normalized in self.BLOCK_TAGS + ): + self._append_block_boundary() + return + + self.open_tags.append((normalized, hidden_here)) + if hidden_here: + self.hidden_depth += 1 if normalized in {"script", "style"}: self.raw_text_depth += 1 return - if self.raw_text_depth == 0 and normalized in self.BLOCK_TAGS: + if ( + self.raw_text_depth == 0 + and self.hidden_depth == 0 + and normalized in self.BLOCK_TAGS + ): self._append_block_boundary() + def _close_tag(self, normalized: str) -> None: + for index in range(len(self.open_tags) - 1, -1, -1): + if self.open_tags[index][0] != normalized: + continue + closing = self.open_tags[index:] + del self.open_tags[index:] + for _tag, hidden_here in closing: + if hidden_here and self.hidden_depth: + self.hidden_depth -= 1 + return + def handle_endtag(self, tag: str) -> None: normalized = tag.lower() + was_visible = self.raw_text_depth == 0 and self.hidden_depth == 0 if normalized in {"script", "style"} and self.raw_text_depth: self.raw_text_depth -= 1 - return - if self.raw_text_depth == 0 and normalized in self.BLOCK_TAGS: + self._close_tag(normalized) + if was_visible and normalized in self.BLOCK_TAGS: self._append_block_boundary() def handle_data(self, data: str) -> None: - if self.raw_text_depth == 0: + if self.raw_text_depth == 0 and self.hidden_depth == 0: self.parts.append(data) def handle_entityref(self, name: str) -> None: - self.parts.append(html.unescape(f"&{name};")) + if self.raw_text_depth == 0 and self.hidden_depth == 0: + self.parts.append(html.unescape(f"&{name};")) def handle_charref(self, name: str) -> None: - self.parts.append(html.unescape(f"{name};")) + if self.raw_text_depth == 0 and self.hidden_depth == 0: + self.parts.append(html.unescape(f"{name};")) def strip_inline_html_tags(text: str) -> str: @@ -2611,8 +2741,21 @@ def strip_inline_html_tags(text: str) -> str: return "".join(parser.parts) +def normalize_markdown_code_spans(text: str) -> str: + """Remove inline-code delimiters while preserving their visible content.""" + pattern = re.compile(r"(?s)(? str: """Approximate rendered Markdown text for semantic matching.""" + text = normalize_markdown_code_spans(text) text = strip_inline_html_tags(text) text = re.sub( r"\\([\\`*_{}\[\]()#+\-.!|>~])", From e7035b70512a19eb28d79f9f46982a41342bdaaa Mon Sep 17 00:00:00 2001 From: Trent Slade <73952179+EmergentMonk@users.noreply.github.com> Date: Sun, 27 Sep 2026 14:21:16 +0930 Subject: [PATCH 091/159] Add regressions for latest Codex findings --- tests/test_phase_d.py | 127 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) diff --git a/tests/test_phase_d.py b/tests/test_phase_d.py index 173ef78..db2c145 100644 --- a/tests/test_phase_d.py +++ b/tests/test_phase_d.py @@ -503,6 +503,29 @@ def test_formal_claim_is_bound_to_its_reviewed_theorem(self) -> None: source, ) + def test_formal_anchor_ignores_lean_syntax_quotations(self) -> None: + namespace = self.load_validator_namespace() + validate_formal_target = cast( + Callable[[str, str, str, str], None], + namespace["validate_formal_provenance_target"], + ) + anchor = ( + "theorem six_step_periodic (layer : CosmoLayer) : " + "psiIterate 6 layer = layer := by" + ) + source = ( + "def fakeQuotedEvidence : Lean.Syntax := " + "`(command| theorem six_step_periodic (layer : CosmoLayer) : " + "psiIterate 6 layer = layer := by trivial)\n" + ) + with self.assertRaises(SystemExit): + validate_formal_target( + "COSMO-D-001", + "cosmovirus.lean", + anchor, + source, + ) + def test_formal_target_must_enter_protected_lean_compile_closure(self) -> None: namespace = self.load_validator_namespace() validate_formal_target = cast( @@ -566,6 +589,37 @@ def test_computational_regression_must_execute_without_skip(self) -> None: source, ) + def test_regression_loader_rejects_system_exit(self) -> None: + namespace = self.load_validator_namespace() + validate_regression = cast( + Callable[[str, str, str, Path, str], None], + namespace["validate_computational_regression_target"], + ) + source = ( + "import unittest\n" + "if __name__.startswith('_cosmo_claim_regression_'):\n" + " raise SystemExit(0)\n" + "class RegressionEvidence(unittest.TestCase):\n" + " def test_required_regression(self) -> None:\n" + " self.assertTrue(True)\n" + ) + with tempfile.TemporaryDirectory() as temporary: + path = Path(temporary) / "test_regression.py" + path.write_text(source, encoding="utf-8") + with self.assertRaises(SystemExit) as raised: + validate_regression( + "COSMO-D-999", + "tests/test_regression.py", + "test_required_regression", + path, + source, + ) + self.assertNotEqual(raised.exception.code, 0) + self.assertIn( + "cannot load regression evidence", + str(raised.exception), + ) + def test_async_regression_methods_are_rejected(self) -> None: namespace = self.load_validator_namespace() validate_regression = cast( @@ -805,6 +859,23 @@ def test_regression_must_exercise_declared_implementation(self) -> None: "test_required_regression", disabled_after_selected_return, ) + empty_comprehension = ( + "import unittest\n" + "from cosmo_core.e8 import validate_e8_root_system\n" + "class RegressionEvidence(unittest.TestCase):\n" + " def test_required_regression(self) -> None:\n" + " _unused = [validate_e8_root_system(()) for _ in ()]\n" + ) + with self.assertRaises(SystemExit): + validate_connection( + "COSMO-D-003", + "cosmo_core/e8.py", + "def validate_e8_root_system", + "tests/test_regression.py", + "test_required_regression", + empty_comprehension, + ) + unconsumed_generator = ( "import unittest\n" "from cosmo_core.e8 import validate_e8_root_system\n" @@ -973,6 +1044,32 @@ def test_implementation_provenance_requires_executable_project_source(self) -> N "Phase B3\n", ) + decorated_regression_class = ( + "import unittest\n" + "from collections.abc import Callable\n" + "from cosmo_core.e8 import validate_e8_root_system\n" + "def replace(\n" + " cls: type[unittest.TestCase],\n" + ") -> type[unittest.TestCase]:\n" + " class FakeRegression(unittest.TestCase):\n" + " def test_required_regression(self) -> None:\n" + " return None\n" + " return FakeRegression\n" + "@replace\n" + "class RegressionEvidence(unittest.TestCase):\n" + " def test_required_regression(self) -> None:\n" + " validate_e8_root_system(())\n" + ) + with self.assertRaises(SystemExit): + validate_connection( + "COSMO-D-003", + "cosmo_core/e8.py", + "def validate_e8_root_system", + "tests/test_regression.py", + "test_required_regression", + decorated_regression_class, + ) + decorated_regression = ( "import unittest\n" "from collections.abc import Callable\n" @@ -1354,6 +1451,20 @@ def test_public_claim_guard_normalizes_markdown_rendering(self) -> None: {}, ) + def test_public_claim_guard_normalizes_markdown_code_spans(self) -> None: + namespace = self.load_validator_namespace() + validate_public_claim_text = cast( + Callable[[str, str, dict[str, str]], None], + namespace["validate_public_claim_text"], + ) + with self.assertRaises(SystemExit): + validate_public_claim_text( + "sample.md", + "Sp`in(8)` tr`iality` ca`uses` " + "H`PV16` cap`sid` assembly.", + {}, + ) + def test_public_claim_guard_strips_inline_html_tags(self) -> None: namespace = self.load_validator_namespace() validate_public_claim_text = cast( @@ -1411,6 +1522,22 @@ def test_public_claim_guard_preserves_html_paragraph_boundaries(self) -> None: claim_classes, ) + def test_public_claim_guard_ignores_hidden_html_subtrees(self) -> None: + namespace = self.load_validator_namespace() + validate_public_claim_text = cast( + Callable[[str, str, dict[str, str]], None], + namespace["validate_public_claim_text"], + ) + validate_public_claim_text( + "sample.md", + ( + "