From cdad0ec4f827138f55d86dcf9521540b615e2b13 Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Fri, 23 Oct 2026 15:31:57 -0500 Subject: [PATCH 1/7] experiments: add exact covariance-only amplitude falsifier pilot --- .../amplitude_mixture_falsifier.py | 218 ++++++++++++++++++ 1 file changed, 218 insertions(+) create mode 100644 experiments/universality/amplitude_mixture_falsifier.py diff --git a/experiments/universality/amplitude_mixture_falsifier.py b/experiments/universality/amplitude_mixture_falsifier.py new file mode 100644 index 000000000..2fe0ebee5 --- /dev/null +++ b/experiments/universality/amplitude_mixture_falsifier.py @@ -0,0 +1,218 @@ +#!/usr/bin/env python3 +"""Exact conditional covariance-only falsifier from one sourced amplitude law. + +Engineering/metamorphic control, not a mathematical review or status authority. +The caller supplies an unverified expected base short-bar count lower bound. +All displayed scalar equalities are exact rational/symbolic identities. +No field sample, barcode algorithm, source code, or remote URL is executed. +""" +from __future__ import annotations + +import argparse +from fractions import Fraction +import json +import re +import sys + +MAX_INPUT = 32 * 1024 +RATIONAL = re.compile(r"(?:0|[1-9][0-9]{0,8})(?:/[1-9][0-9]{0,8})?\Z") +TOP_KEYS = frozenset(("schema_version", "power", "bar_interval", + "base_expected_bar_count_lower_bound", "grid")) +SOURCE = { + "repository": "d6g8k5htny-coder/Math-", + "commit": "9f3fb6918b28e6378c034ebc19e76d432f5391cb", + "path": ("frontiers/gaussian_short_bar_theory_20261017/" + "smooth_gaussian_manifold_admission/PROOF.md"), + "git_blob": "d61fd11a826856baecb4cf4cd8a76ad5c25350dd", + "locator": "section 11, covariance-only amplitude-mixture boundary", +} + + +class SpecRefused(ValueError): + """Do not emit caller data or a parsed path in refusal diagnostics.""" + + +def _refuse(): + raise SpecRefused("AMP_TWIN_REFUSED: invalid-input") + + +def _pairs(items): + result = {} + for key, value in items: + if key in result: + _refuse() + result[key] = value + return result + + +def _bad_number(_token): + _refuse() + + +def load_spec(raw: bytes) -> dict: + """Parse inert, size-limited JSON; reject duplicate keys and JSON floats.""" + if type(raw) is not bytes or not 0 < len(raw) <= MAX_INPUT: + _refuse() + try: + value = json.loads(raw.decode("utf-8", errors="strict"), + object_pairs_hook=_pairs, + parse_constant=_bad_number, + parse_float=_bad_number, + parse_int=_int_token) + except (ValueError, UnicodeError, RecursionError, OverflowError): + _refuse() + if type(value) is not dict or value.keys() != TOP_KEYS: + _refuse() + # The source loader is an acceptance boundary: reject type-correct JSON + # that violates the finite witness contract before returning it to callers. + witness(value) + return value + + +def _int_token(token: str): + if len(token) > 8: + _refuse() + return int(token) + + +def _fraction(value) -> Fraction: + if type(value) is not str or RATIONAL.fullmatch(value) is None: + _refuse() + try: + return Fraction(value) + except (ValueError, ZeroDivisionError): + _refuse() + + +def _show(q: Fraction) -> str: + return str(q.numerator) if q.denominator == 1 else f"{q.numerator}/{q.denominator}" + + +def witness(spec: dict) -> dict: + """Compute only an exact conditional counterexample to covariance transfer. + + R = sqrt(2k+1) U**k, where independent U is uniform on (0,1). + An external premise E N_H([a,b]) >= p > 0 is explicitly unverified. + At t_m = sqrt(2k+1)*b/m**k, E N_(RH)((0,t_m]) >= p/m. + """ + if type(spec) is not dict or spec.keys() != TOP_KEYS: + _refuse() + if type(spec["schema_version"]) is not int or spec["schema_version"] != 1: + _refuse() + k = spec["power"] + if type(k) is not int or not 2 <= k <= 16: + _refuse() + interval = spec["bar_interval"] + if type(interval) is not dict or interval.keys() != {"lower", "upper"}: + _refuse() + a, b = _fraction(interval["lower"]), _fraction(interval["upper"]) + p = _fraction(spec["base_expected_bar_count_lower_bound"]) + if not (0 < a < b and p > 0): + _refuse() + grid = spec["grid"] + if (type(grid) is not list or not 1 <= len(grid) <= 20 + or any(type(m) is not int or not 2 <= m <= 100_000 for m in grid) + or any(x >= y for x, y in zip(grid, grid[1:]))): + _refuse() + + fourth = Fraction((2 * k + 1)**2, 4 * k + 1) + excess = fourth - 1 + growth = Fraction(2 * k, 3) - 1 + if not (fourth > 1 and growth > 0): + _refuse() + ratio_expression = f"{_show(p)} * m^({_show(growth)})" + examples = [ + { + "m": m, + "t_over_sqrt_2kplus1_times_upper_bar": _show(Fraction(1, m**k)), + "probability_R_at_m_threshold": _show(Fraction(1, m)), + "expected_short_bar_count_lower_bound": _show(p / m), + } + for m in grid + ] + return { + "schema_version": 1, + "kind": "CONDITIONAL_COVARIANCE_ONLY_FALSIFIER", + "scientific_effect": "NONE", + "scientific_status_authority": False, + "source_identity": dict(SOURCE), + "source_identity_runtime_verified": False, + "source_pin_meaning": "declared immutable source reference, not runtime Git authentication", + "premise_status": "CALLER_SUPPLIED_NOT_VERIFIED", + "premises": { + "bar_interval_lower": _show(a), + "bar_interval_upper": _show(b), + "expected_base_bar_count_lower_bound": _show(p), + "underlying_field": "centered Gaussian H independent of U; nonzero finite bars required", + }, + "scale_model": { + "definition": "R=sqrt(2*k+1)*U**k; U uniform on (0,1) independent of H", + "integer_power": k, + "small_amplitude_cdf_exponent": _show(Fraction(1, k)), + "second_scale_moment": "1", + "fourth_scale_moment": _show(fourth), + "fourth_scale_moment_minus_one": _show(excess), + "normalized_gaussian_fourth_moment": "3", + "normalized_mixture_fourth_moment": _show(3 * fourth), + "inverse_two_thirds_scale_moment": "DIVERGES", + "same_covariance_for_independent_centered_H": True, + "positive_scale_preserves_each_realization_bar_pairing": True, + }, + "conditional_short_bar_witness": { + "threshold_definition": "t_m=sqrt(2*k+1)*b/m**k", + "comparison_exponent": "2/3", + "relative_lower_bound_ratio_to_threshold_power": ratio_expression, + "growth_exponent": _show(growth), + "positive_divergence_exponent": True, + "grid": examples, + }, + "covariance_only_two_thirds_transfer": "REFUSED_BY_COUNTEREXAMPLE", + "scope_limits": [ + "No actual Gaussian field, physical persistence barcode, or finite-radius count is computed", + "The positive base-bar expectation is an unverified external premise", + "The lower bound does not establish a full non-Gaussian density asymptotic", + "The existing Gaussian theorem and its reviewed hypotheses are not revised", + "An engineering veto is not a theorem-status or independent-review decision", + ], + } + + +EXAMPLE_SPEC = { + "schema_version": 1, + "power": 2, + "bar_interval": {"lower": "1/2", "upper": "3/2"}, + "base_expected_bar_count_lower_bound": "1/4", + "grid": [2, 3, 5, 9], +} + + +def main(argv=None) -> int: + parser = argparse.ArgumentParser(description=__doc__.splitlines()[0], allow_abbrev=False) + source = parser.add_mutually_exclusive_group(required=True) + source.add_argument("--spec", help="inert JSON input file, or '-' for stdin") + source.add_argument("--example", action="store_true", help="print a synthetic example input") + parser.add_argument("--require-covariance-transfer", action="store_true", + help="fail on the invalid covariance-only 2/3 inference") + args = parser.parse_args(argv) + try: + if args.example: + if args.require_covariance_transfer: + _refuse() + result = EXAMPLE_SPEC + else: + if args.spec == "-": + raw = sys.stdin.buffer.read(MAX_INPUT + 1) + else: + with open(args.spec, "rb") as f: + raw = f.read(MAX_INPUT + 1) + result = witness(load_spec(raw)) + except (SpecRefused, OSError, ValueError, OverflowError, RecursionError): + print("AMP_TWIN_REFUSED: invalid-input", file=sys.stderr) + return 2 + sys.stdout.write(json.dumps(result, sort_keys=True, ensure_ascii=True, separators=(",", ":")) + "\n") + # Veto mode makes an impossible covariance-only transfer a machine failure. + return 1 if args.require_covariance_transfer else 0 + + +if __name__ == "__main__": + raise SystemExit(main()) From 3098cd6ddbea69f33ee6882379a917f16d1d52c6 Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Fri, 23 Oct 2026 15:32:30 -0500 Subject: [PATCH 2/7] tests: pin exact amplitude witness and fail-closed inference veto --- tests/test_amplitude_mixture_falsifier.py | 201 ++++++++++++++++++++++ 1 file changed, 201 insertions(+) create mode 100644 tests/test_amplitude_mixture_falsifier.py diff --git a/tests/test_amplitude_mixture_falsifier.py b/tests/test_amplitude_mixture_falsifier.py new file mode 100644 index 000000000..b0bd5086c --- /dev/null +++ b/tests/test_amplitude_mixture_falsifier.py @@ -0,0 +1,201 @@ +"""Adversarial exact controls for the covariance-only amplitude specimen. + +Scientific effect NONE. No field/barcode simulation or source-status acceptance. +""" +from __future__ import annotations + +import copy +from fractions import Fraction +import importlib.util +import json +from pathlib import Path +import subprocess +import sys +import tempfile +import unittest + +ROOT = Path(__file__).resolve().parents[1] +SCRIPT = ROOT / "experiments" / "universality" / "amplitude_mixture_falsifier.py" +SPEC = importlib.util.spec_from_file_location("amplitude_mixture_falsifier", SCRIPT) +engine = importlib.util.module_from_spec(SPEC) +SPEC.loader.exec_module(engine) + + +class ExactAmplitudeTests(unittest.TestCase): + def sample(self): + return copy.deepcopy(engine.EXAMPLE_SPEC) + + def test_second_moment_preserved_fourth_separates(self): + result = engine.witness(self.sample()) + model = result["scale_model"] + self.assertEqual(model["second_scale_moment"], "1") + self.assertEqual(model["fourth_scale_moment"], "25/9") + self.assertEqual(model["normalized_mixture_fourth_moment"], "25/3") + self.assertEqual(model["fourth_scale_moment_minus_one"], "16/9") + self.assertEqual(model["inverse_two_thirds_scale_moment"], "DIVERGES") + self.assertTrue(model["same_covariance_for_independent_centered_H"]) + self.assertNotEqual(model["normalized_mixture_fourth_moment"], + model["normalized_gaussian_fourth_moment"]) + + def test_exact_conditional_witness(self): + r = engine.witness(self.sample()) + self.assertEqual(r["premise_status"], "CALLER_SUPPLIED_NOT_VERIFIED") + self.assertEqual(r["conditional_short_bar_witness"]["growth_exponent"], "1/3") + self.assertEqual(r["conditional_short_bar_witness"]["grid"][0], { + "m": 2, "t_over_sqrt_2kplus1_times_upper_bar": "1/4", + "probability_R_at_m_threshold": "1/2", + "expected_short_bar_count_lower_bound": "1/8", + }) + self.assertEqual(r["conditional_short_bar_witness"]["grid"][-1][ + "expected_short_bar_count_lower_bound"], "1/36") + + def test_general_integer_k_is_exact(self): + obj = self.sample() + obj["power"] = 3 + r = engine.witness(obj) + self.assertEqual(r["scale_model"]["small_amplitude_cdf_exponent"], "1/3") + self.assertEqual(r["scale_model"]["fourth_scale_moment"], "49/13") + self.assertEqual(r["conditional_short_bar_witness"]["growth_exponent"], "1") + self.assertEqual(r["conditional_short_bar_witness"]["grid"][0][ + "t_over_sqrt_2kplus1_times_upper_bar"], "1/8") + + def test_canonical_fractions(self): + obj = self.sample() + obj["bar_interval"] = {"lower": "2/4", "upper": "9/6"} + obj["base_expected_bar_count_lower_bound"] = "4/16" + r = engine.witness(obj) + self.assertEqual(r["premises"]["bar_interval_lower"], "1/2") + self.assertEqual(r["premises"]["bar_interval_upper"], "3/2") + self.assertEqual(r["premises"]["expected_base_bar_count_lower_bound"], "1/4") + + def test_witness_does_not_mutate_input(self): + obj = self.sample() + before = copy.deepcopy(obj) + engine.witness(obj) + self.assertEqual(obj, before) + + def test_invalid_power_and_rationals_refuse(self): + cases = [] + for power in (0, 1, 17, True, 2.0, "2", None): + obj = self.sample() + obj["power"] = power + cases.append(obj) + for bad in ("0", "-1/2", "1/0", "0.2", "nan", "1/01", 1, None): + obj = self.sample() + obj["base_expected_bar_count_lower_bound"] = bad + cases.append(obj) + for obj in cases: + with self.subTest(payload=str(obj)[:60]): + with self.assertRaises(engine.SpecRefused): + engine.witness(obj) + + def test_invalid_intervals_refuse(self): + for a,b in (("1","1"),("2","1"),("0","1"),("1","0")): + with self.subTest(a=a,b=b): + obj=self.sample() + obj["bar_interval"]={"lower":a,"upper":b} + with self.assertRaises(engine.SpecRefused): + engine.witness(obj) + + def test_grid_validation_refuses_empty_repeated_unsorted(self): + for bad in ([],[1],[2,2],[4,3],[True,2],[2,"3"],[2.5],[100001],[2]*21): + with self.subTest(bad=bad): + obj=self.sample() + obj["grid"] = bad + with self.assertRaises(engine.SpecRefused): + engine.witness(obj) + + def test_strict_json_duplicate_unknown_float_nonfinite_refuse(self): + raw_cases = ( + b'{"schema_version":1,"schema_version":1}', + b'{"k":2}', + json.dumps(dict(self.sample(), surprise="http://bad.example")).encode(), + json.dumps(dict(self.sample(), power=2.0)).encode(), + json.dumps(dict(self.sample(), power=None)).encode(), + b'NaN', + b'Infinity', + b'[]', + b'\xff\xfe', + b'0' * (engine.MAX_INPUT + 1), + ) + for raw in raw_cases: + with self.subTest(raw=raw[:35]): + with self.assertRaises(engine.SpecRefused): + engine.load_spec(raw) + + def test_source_identity_and_limits_explicit(self): + obj=engine.witness(self.sample()) + self.assertEqual(obj["scientific_effect"], "NONE") + self.assertFalse(obj["scientific_status_authority"]) + self.assertFalse(obj["source_identity_runtime_verified"]) + self.assertEqual(len(obj["source_identity"]["git_blob"]), 40) + self.assertEqual(obj["covariance_only_two_thirds_transfer"], + "REFUSED_BY_COUNTEREXAMPLE") + self.assertGreaterEqual(len(obj["scope_limits"]), 3) + + +class CLIControls(unittest.TestCase): + def run_program(self, mode=(), args=(), stdin=None): + return subprocess.run([sys.executable,"-B",*mode,"-S",str(SCRIPT),*args], + input=stdin, capture_output=True, timeout=10) + + def test_example_is_inert_and_roundtrips(self): + p=self.run_program(args=("--example",)) + self.assertEqual(p.returncode,0,p.stderr.decode()) + self.assertEqual(json.loads(p.stdout),engine.EXAMPLE_SPEC) + self.assertEqual(p.stderr,b"") + + def test_normal_optimized_identical_stdout(self): + sample=json.dumps(engine.EXAMPLE_SPEC).encode() + a=self.run_program(args=("--spec","-"),stdin=sample) + b=self.run_program(mode=("-O",),args=("--spec","-"),stdin=sample) + self.assertEqual(a.returncode,0,a.stderr.decode()) + self.assertEqual(b.returncode,0,b.stderr.decode()) + self.assertEqual(a.stdout,b.stdout) + self.assertEqual(a.stderr,b"") + self.assertEqual(json.loads(a.stdout)["scale_model"]["fourth_scale_moment"],"25/9") + + def test_require_covariance_transfer_vetoes_both_modes(self): + sample=json.dumps(engine.EXAMPLE_SPEC).encode() + for mode in ((),("-O",)): + with self.subTest(mode=mode): + p=self.run_program(mode=mode,args=("--spec","-", + "--require-covariance-transfer"),stdin=sample) + self.assertEqual(p.returncode,1) + self.assertEqual(p.stderr,b"") + self.assertEqual(json.loads(p.stdout)["covariance_only_two_thirds_transfer"], + "REFUSED_BY_COUNTEREXAMPLE") + + def test_malformed_cli_is_opaque_in_both_modes(self): + raw=b'{"schema_version":1,"url":"https://secret.example/a-key"}' + for mode in ((),("-O",)): + with self.subTest(mode=mode): + p=self.run_program(mode=mode,args=("--spec","-"),stdin=raw) + self.assertEqual(p.returncode,2) + self.assertEqual(p.stdout,b"") + self.assertEqual(p.stderr,b"AMP_TWIN_REFUSED: invalid-input\n") + self.assertNotIn(b"secret",p.stderr) + + def test_input_file_and_stdin_equivalent(self): + raw=json.dumps(engine.EXAMPLE_SPEC).encode() + with tempfile.TemporaryDirectory() as root: + path=Path(root)/"fixture.json" + path.write_bytes(raw) + by_path=self.run_program(args=("--spec",str(path))) + by_stdin=self.run_program(args=("--spec","-"),stdin=raw) + self.assertEqual(by_path.returncode,0) + self.assertEqual(by_path.stdout,by_stdin.stdout) + + def test_mutation_to_constant_scale_breaks_counterexample(self): + # The naive R=1 replacement keeps covariance but has E[R^4]=1. + # That replacement MUST fail the counterexample's 4th-moment witness. + obj=engine.witness(engine.EXAMPLE_SPEC) + self.assertEqual(Fraction(obj["scale_model"]["second_scale_moment"]),1) + actual_fourth=Fraction(obj["scale_model"]["fourth_scale_moment"]) + mutant_fourth=Fraction(1) + self.assertNotEqual(actual_fourth,mutant_fourth) + self.assertGreater(actual_fourth,mutant_fourth) + + +if __name__ == "__main__": + unittest.main() From a700e16656403d30296dffdcdc564f796ff36494 Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Fri, 23 Oct 2026 15:33:15 -0500 Subject: [PATCH 3/7] docs: bind covariance adversary to immutable Gaussian source and explicit limits --- .../AMPLITUDE_MIXTURE_FALSIFIER.md | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 experiments/universality/AMPLITUDE_MIXTURE_FALSIFIER.md diff --git a/experiments/universality/AMPLITUDE_MIXTURE_FALSIFIER.md b/experiments/universality/AMPLITUDE_MIXTURE_FALSIFIER.md new file mode 100644 index 000000000..23c8c034b --- /dev/null +++ b/experiments/universality/AMPLITUDE_MIXTURE_FALSIFIER.md @@ -0,0 +1,72 @@ +# Covariance-matched amplitude falsifier — executable engineering pilot + +**Scientific effect: NONE.** This is a deterministic, standard-library-only *negative control* for a bad mathematical/architectural inference. It neither implements the random field's persistence algorithm nor modifies mathematical status, acceptance, graph nodes, theorem proofs, required checks, or external accounts. + +## The mathematical source is pre-existing + +- The original amplitude-mixture boundary appears in [Math- smooth Gaussian short-bar admission, section 11](https://github.com/d6g8k5htny-coder/Math-/blob/9f3fb6918b28e6378c034ebc19e76d432f5391cb/frontiers/gaussian_short_bar_theory_20261017/smooth_gaussian_manifold_admission/PROOF.md). Exact Math- commit: 9f3fb6918b28e6378c034ebc19e76d432f5391cb; Git blob d61fd11a826856baecb4cf4cd8a76ad5c25350dd. +- An existing [main fold-structural source, section 9](https://github.com/d6g8k5htny-coder/main/blob/be5a458ecb493bc54dd228377c6ce2000f9f21ce/experiments/universality/fold_structural_universality/PROOF.md) gives the explicit small-amplitude count lower-bound argument. Source commit be5a458ecb493bc54dd228377c6ce2000f9f21ce; Git blob 483d779cfdfdcea0bd8d0ec47c9fdaeff485fd4b. +- The broader analytic amplitude crossover and whole-barcode cluster research belongs to [Draft main PR #334](https://github.com/d6g8k5htny-coder/main/pull/334). This tool is one narrower, exact *metamorphic control*; no mathematical authorship, review, or integration is transferred from that draft. + +The program declares the Math- Git source identity in its JSON output, but does not read or authenticate external Git content **at runtime**. A separately pinned source review is still necessary. No source text is executed, fetched from a URL, or silently treated as a theorem acceptance record. + +## One exact family (not a new theorem) + +Let H be a centered Gaussian field and U an independent uniform random variable on the open interval (0,1). Let k be an integer at least 2. Define the positive amplitude + +\[ +R = \sqrt{2k+1}\, U^k,\qquad F=RH. +\] + +The program's moment identities, all exact, are + +\[ +\mathbb E[R^2] = 1,\qquad +\mathbb E[R^4] = \frac{(2k+1)^2}{4k+1} > 1. +\] + +Independence yields identical covariance functions for H and F. But the fourth moment of a normalized Gaussian marginal changes from 3 to three times \(\mathbb E[R^4]\). Positive amplitude preserves each realization's critical-point and elder-pairing topology, while finite persistence lifetimes are multiplied by R. + +For 0=2. + +An **external, unverified** premise must supply an interval 0=2), + +\[ +\mathbb E[N_F((0,t_m])]\ge p/m,\qquad +\frac{p/m}{(t_m/(\sqrt{2k+1}\,b))^{2/3}} +=p\,m^{2k/3-1}\longrightarrow\infty. +\] + +Using the *dimensionless* threshold retains exact fractions; the fixed scale factor does not affect divergence against t^(2/3). This rejects a covariance-only transfer. It does **not** prove a complete alternate non-Gaussian density law. + +## Runtime and negative-control contract + +The CLI accepts one inert, bounded JSON specification or prints a synthetic example; no floating-point evidence is admitted. There are no third-party dependencies and no runtime remote source access or writes. Run from the repository root: + +~~~sh +python -B -S experiments/universality/amplitude_mixture_falsifier.py --example +python -B -S experiments/universality/amplitude_mixture_falsifier.py --spec /path/to/spec.json +python -B -S experiments/universality/amplitude_mixture_falsifier.py --spec /path/to/spec.json --require-covariance-transfer +python -B -S -m unittest discover -s tests -p 'test_amplitude_mixture_falsifier.py' -v +python -B -O -S -m unittest discover -s tests -p 'test_amplitude_mixture_falsifier.py' -v +~~~ + +Synthetic example (not a measured bar intensity): + +~~~json +{"schema_version":1,"power":2,"bar_interval":{"lower":"1/2","upper":"3/2"},"base_expected_bar_count_lower_bound":"1/4","grid":[2,3,5,9]} +~~~ + +A normal run returns one deterministic ASCII JSON line and exits 0. It reports exact rational moments, a conditional short-bar witness grid, an explicitly *unverified* source identity and external premise, a positive exponent gap, and the text REFUSED_BY_COUNTEREXAMPLE for covariance-only 2/3 transfer. + +In the optional --require-covariance-transfer mode the same JSON is returned but exit status is 1: the attempt to infer a universal short-bar exponent from covariance alone is vetoed. Bad schema, unknown fields, duplicate JSON keys, unsupported numeric forms, invalid rationals, nonfinite values, oversized inputs, malformed grids and invalid intervals return exit 2 and an opaque error; caller input is not echoed. + +The unit suite tests normal and optimized Python, independence of output from JSON field order, exact moment identities, sorted rational witness grids, malformed/floated/oversized input, caller-data nonleakage, the explicit inference veto, and a constant-amplitude negative mutation. Those test results are **engineering outcomes**, not standalone mathematical proof or a claim that field/barcode algorithms were exercised. + +## Architectural incorporation boundary + +The machine-readable witness can serve as a *falsification interlock* in a future source-aware dependency or hypothesis checker: if a proposed inference uses equal covariance as sufficient evidence for the Gaussian 2/3 short-bar law, the bounded counterexample requires rejecting that inference. It cannot infer the truth of unrelated claims from the witness and cannot automatically create a graph relation, source-review grade, or scientific status. + +The actual contact, selection, common envelope, near/far population and other hypotheses of a particular field require their own reviewed proofs, exact source identities, and applicable execution/hosted controls. A green unit test cannot discharge them. The sourced amplitude-crossover theorem remains owned by its original authors and reviewers. + +[Owner mandate](https://github.com/d6g8k5htny-coder/main/blob/b665307520948308a53d190d7341bf301df3b3a2/governance/OWNER_MANDATE_20261015.md) · [Delegation](https://github.com/d6g8k5htny-coder/main/blob/main/governance/OP-AUTONOMY-20260923-v2.1.md). From d5bea87ea23c319c6883f4552cfe636edbe6e26a Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Fri, 23 Oct 2026 15:33:55 -0500 Subject: [PATCH 4/7] docs: align stated coverage with actually executed CLI tests --- experiments/universality/AMPLITUDE_MIXTURE_FALSIFIER.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/experiments/universality/AMPLITUDE_MIXTURE_FALSIFIER.md b/experiments/universality/AMPLITUDE_MIXTURE_FALSIFIER.md index 23c8c034b..2d1ba83f8 100644 --- a/experiments/universality/AMPLITUDE_MIXTURE_FALSIFIER.md +++ b/experiments/universality/AMPLITUDE_MIXTURE_FALSIFIER.md @@ -61,7 +61,7 @@ A normal run returns one deterministic ASCII JSON line and exits 0. It reports e In the optional --require-covariance-transfer mode the same JSON is returned but exit status is 1: the attempt to infer a universal short-bar exponent from covariance alone is vetoed. Bad schema, unknown fields, duplicate JSON keys, unsupported numeric forms, invalid rationals, nonfinite values, oversized inputs, malformed grids and invalid intervals return exit 2 and an opaque error; caller input is not echoed. -The unit suite tests normal and optimized Python, independence of output from JSON field order, exact moment identities, sorted rational witness grids, malformed/floated/oversized input, caller-data nonleakage, the explicit inference veto, and a constant-amplitude negative mutation. Those test results are **engineering outcomes**, not standalone mathematical proof or a claim that field/barcode algorithms were exercised. +The unit suite tests normal and optimized Python, deterministic output across interpreter modes and file/stdin routes, exact moment identities, sorted rational witness grids, malformed/floated/oversized input, caller-data nonleakage, the explicit inference veto, and a constant-amplitude negative mutation. Those test results are **engineering outcomes**, not standalone mathematical proof or a claim that field/barcode algorithms were exercised. ## Architectural incorporation boundary From d785aa1aabbe51fd965f376fff4e3eb7febda4d9 Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Fri, 23 Oct 2026 15:37:40 -0500 Subject: [PATCH 5/7] tests: admit amplitude falsifier into existing hosted universality discovery --- .../test_amplitude_mixture_falsifier.py | 201 ++++++++++++++++++ 1 file changed, 201 insertions(+) create mode 100644 experiments/universality/test_amplitude_mixture_falsifier.py diff --git a/experiments/universality/test_amplitude_mixture_falsifier.py b/experiments/universality/test_amplitude_mixture_falsifier.py new file mode 100644 index 000000000..b8c44ff39 --- /dev/null +++ b/experiments/universality/test_amplitude_mixture_falsifier.py @@ -0,0 +1,201 @@ +"""Adversarial exact controls for the covariance-only amplitude specimen. + +Scientific effect NONE. No field/barcode simulation or source-status acceptance. +""" +from __future__ import annotations + +import copy +from fractions import Fraction +import importlib.util +import json +from pathlib import Path +import subprocess +import sys +import tempfile +import unittest + +ROOT = Path(__file__).resolve().parents[2] +SCRIPT = ROOT / "experiments" / "universality" / "amplitude_mixture_falsifier.py" +SPEC = importlib.util.spec_from_file_location("amplitude_mixture_falsifier", SCRIPT) +engine = importlib.util.module_from_spec(SPEC) +SPEC.loader.exec_module(engine) + + +class ExactAmplitudeTests(unittest.TestCase): + def sample(self): + return copy.deepcopy(engine.EXAMPLE_SPEC) + + def test_second_moment_preserved_fourth_separates(self): + result = engine.witness(self.sample()) + model = result["scale_model"] + self.assertEqual(model["second_scale_moment"], "1") + self.assertEqual(model["fourth_scale_moment"], "25/9") + self.assertEqual(model["normalized_mixture_fourth_moment"], "25/3") + self.assertEqual(model["fourth_scale_moment_minus_one"], "16/9") + self.assertEqual(model["inverse_two_thirds_scale_moment"], "DIVERGES") + self.assertTrue(model["same_covariance_for_independent_centered_H"]) + self.assertNotEqual(model["normalized_mixture_fourth_moment"], + model["normalized_gaussian_fourth_moment"]) + + def test_exact_conditional_witness(self): + r = engine.witness(self.sample()) + self.assertEqual(r["premise_status"], "CALLER_SUPPLIED_NOT_VERIFIED") + self.assertEqual(r["conditional_short_bar_witness"]["growth_exponent"], "1/3") + self.assertEqual(r["conditional_short_bar_witness"]["grid"][0], { + "m": 2, "t_over_sqrt_2kplus1_times_upper_bar": "1/4", + "probability_R_at_m_threshold": "1/2", + "expected_short_bar_count_lower_bound": "1/8", + }) + self.assertEqual(r["conditional_short_bar_witness"]["grid"][-1][ + "expected_short_bar_count_lower_bound"], "1/36") + + def test_general_integer_k_is_exact(self): + obj = self.sample() + obj["power"] = 3 + r = engine.witness(obj) + self.assertEqual(r["scale_model"]["small_amplitude_cdf_exponent"], "1/3") + self.assertEqual(r["scale_model"]["fourth_scale_moment"], "49/13") + self.assertEqual(r["conditional_short_bar_witness"]["growth_exponent"], "1") + self.assertEqual(r["conditional_short_bar_witness"]["grid"][0][ + "t_over_sqrt_2kplus1_times_upper_bar"], "1/8") + + def test_canonical_fractions(self): + obj = self.sample() + obj["bar_interval"] = {"lower": "2/4", "upper": "9/6"} + obj["base_expected_bar_count_lower_bound"] = "4/16" + r = engine.witness(obj) + self.assertEqual(r["premises"]["bar_interval_lower"], "1/2") + self.assertEqual(r["premises"]["bar_interval_upper"], "3/2") + self.assertEqual(r["premises"]["expected_base_bar_count_lower_bound"], "1/4") + + def test_witness_does_not_mutate_input(self): + obj = self.sample() + before = copy.deepcopy(obj) + engine.witness(obj) + self.assertEqual(obj, before) + + def test_invalid_power_and_rationals_refuse(self): + cases = [] + for power in (0, 1, 17, True, 2.0, "2", None): + obj = self.sample() + obj["power"] = power + cases.append(obj) + for bad in ("0", "-1/2", "1/0", "0.2", "nan", "1/01", 1, None): + obj = self.sample() + obj["base_expected_bar_count_lower_bound"] = bad + cases.append(obj) + for obj in cases: + with self.subTest(payload=str(obj)[:60]): + with self.assertRaises(engine.SpecRefused): + engine.witness(obj) + + def test_invalid_intervals_refuse(self): + for a,b in (("1","1"),("2","1"),("0","1"),("1","0")): + with self.subTest(a=a,b=b): + obj=self.sample() + obj["bar_interval"]={"lower":a,"upper":b} + with self.assertRaises(engine.SpecRefused): + engine.witness(obj) + + def test_grid_validation_refuses_empty_repeated_unsorted(self): + for bad in ([],[1],[2,2],[4,3],[True,2],[2,"3"],[2.5],[100001],[2]*21): + with self.subTest(bad=bad): + obj=self.sample() + obj["grid"] = bad + with self.assertRaises(engine.SpecRefused): + engine.witness(obj) + + def test_strict_json_duplicate_unknown_float_nonfinite_refuse(self): + raw_cases = ( + b'{"schema_version":1,"schema_version":1}', + b'{"k":2}', + json.dumps(dict(self.sample(), surprise="http://bad.example")).encode(), + json.dumps(dict(self.sample(), power=2.0)).encode(), + json.dumps(dict(self.sample(), power=None)).encode(), + b'NaN', + b'Infinity', + b'[]', + b'\xff\xfe', + b'0' * (engine.MAX_INPUT + 1), + ) + for raw in raw_cases: + with self.subTest(raw=raw[:35]): + with self.assertRaises(engine.SpecRefused): + engine.load_spec(raw) + + def test_source_identity_and_limits_explicit(self): + obj=engine.witness(self.sample()) + self.assertEqual(obj["scientific_effect"], "NONE") + self.assertFalse(obj["scientific_status_authority"]) + self.assertFalse(obj["source_identity_runtime_verified"]) + self.assertEqual(len(obj["source_identity"]["git_blob"]), 40) + self.assertEqual(obj["covariance_only_two_thirds_transfer"], + "REFUSED_BY_COUNTEREXAMPLE") + self.assertGreaterEqual(len(obj["scope_limits"]), 3) + + +class CLIControls(unittest.TestCase): + def run_program(self, mode=(), args=(), stdin=None): + return subprocess.run([sys.executable,"-B",*mode,"-S",str(SCRIPT),*args], + input=stdin, capture_output=True, timeout=10) + + def test_example_is_inert_and_roundtrips(self): + p=self.run_program(args=("--example",)) + self.assertEqual(p.returncode,0,p.stderr.decode()) + self.assertEqual(json.loads(p.stdout),engine.EXAMPLE_SPEC) + self.assertEqual(p.stderr,b"") + + def test_normal_optimized_identical_stdout(self): + sample=json.dumps(engine.EXAMPLE_SPEC).encode() + a=self.run_program(args=("--spec","-"),stdin=sample) + b=self.run_program(mode=("-O",),args=("--spec","-"),stdin=sample) + self.assertEqual(a.returncode,0,a.stderr.decode()) + self.assertEqual(b.returncode,0,b.stderr.decode()) + self.assertEqual(a.stdout,b.stdout) + self.assertEqual(a.stderr,b"") + self.assertEqual(json.loads(a.stdout)["scale_model"]["fourth_scale_moment"],"25/9") + + def test_require_covariance_transfer_vetoes_both_modes(self): + sample=json.dumps(engine.EXAMPLE_SPEC).encode() + for mode in ((),("-O",)): + with self.subTest(mode=mode): + p=self.run_program(mode=mode,args=("--spec","-", + "--require-covariance-transfer"),stdin=sample) + self.assertEqual(p.returncode,1) + self.assertEqual(p.stderr,b"") + self.assertEqual(json.loads(p.stdout)["covariance_only_two_thirds_transfer"], + "REFUSED_BY_COUNTEREXAMPLE") + + def test_malformed_cli_is_opaque_in_both_modes(self): + raw=b'{"schema_version":1,"url":"https://secret.example/a-key"}' + for mode in ((),("-O",)): + with self.subTest(mode=mode): + p=self.run_program(mode=mode,args=("--spec","-"),stdin=raw) + self.assertEqual(p.returncode,2) + self.assertEqual(p.stdout,b"") + self.assertEqual(p.stderr,b"AMP_TWIN_REFUSED: invalid-input\n") + self.assertNotIn(b"secret",p.stderr) + + def test_input_file_and_stdin_equivalent(self): + raw=json.dumps(engine.EXAMPLE_SPEC).encode() + with tempfile.TemporaryDirectory() as root: + path=Path(root)/"fixture.json" + path.write_bytes(raw) + by_path=self.run_program(args=("--spec",str(path))) + by_stdin=self.run_program(args=("--spec","-"),stdin=raw) + self.assertEqual(by_path.returncode,0) + self.assertEqual(by_path.stdout,by_stdin.stdout) + + def test_mutation_to_constant_scale_breaks_counterexample(self): + # The naive R=1 replacement keeps covariance but has E[R^4]=1. + # That replacement MUST fail the counterexample's 4th-moment witness. + obj=engine.witness(engine.EXAMPLE_SPEC) + self.assertEqual(Fraction(obj["scale_model"]["second_scale_moment"]),1) + actual_fourth=Fraction(obj["scale_model"]["fourth_scale_moment"]) + mutant_fourth=Fraction(1) + self.assertNotEqual(actual_fourth,mutant_fourth) + self.assertGreater(actual_fourth,mutant_fourth) + + +if __name__ == "__main__": + unittest.main() From a8a44721ac839640333364e08e6b5350284b424e Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Fri, 23 Oct 2026 15:37:46 -0500 Subject: [PATCH 6/7] tests: remove superseded non-hosted test location --- tests/test_amplitude_mixture_falsifier.py | 201 ---------------------- 1 file changed, 201 deletions(-) delete mode 100644 tests/test_amplitude_mixture_falsifier.py diff --git a/tests/test_amplitude_mixture_falsifier.py b/tests/test_amplitude_mixture_falsifier.py deleted file mode 100644 index b0bd5086c..000000000 --- a/tests/test_amplitude_mixture_falsifier.py +++ /dev/null @@ -1,201 +0,0 @@ -"""Adversarial exact controls for the covariance-only amplitude specimen. - -Scientific effect NONE. No field/barcode simulation or source-status acceptance. -""" -from __future__ import annotations - -import copy -from fractions import Fraction -import importlib.util -import json -from pathlib import Path -import subprocess -import sys -import tempfile -import unittest - -ROOT = Path(__file__).resolve().parents[1] -SCRIPT = ROOT / "experiments" / "universality" / "amplitude_mixture_falsifier.py" -SPEC = importlib.util.spec_from_file_location("amplitude_mixture_falsifier", SCRIPT) -engine = importlib.util.module_from_spec(SPEC) -SPEC.loader.exec_module(engine) - - -class ExactAmplitudeTests(unittest.TestCase): - def sample(self): - return copy.deepcopy(engine.EXAMPLE_SPEC) - - def test_second_moment_preserved_fourth_separates(self): - result = engine.witness(self.sample()) - model = result["scale_model"] - self.assertEqual(model["second_scale_moment"], "1") - self.assertEqual(model["fourth_scale_moment"], "25/9") - self.assertEqual(model["normalized_mixture_fourth_moment"], "25/3") - self.assertEqual(model["fourth_scale_moment_minus_one"], "16/9") - self.assertEqual(model["inverse_two_thirds_scale_moment"], "DIVERGES") - self.assertTrue(model["same_covariance_for_independent_centered_H"]) - self.assertNotEqual(model["normalized_mixture_fourth_moment"], - model["normalized_gaussian_fourth_moment"]) - - def test_exact_conditional_witness(self): - r = engine.witness(self.sample()) - self.assertEqual(r["premise_status"], "CALLER_SUPPLIED_NOT_VERIFIED") - self.assertEqual(r["conditional_short_bar_witness"]["growth_exponent"], "1/3") - self.assertEqual(r["conditional_short_bar_witness"]["grid"][0], { - "m": 2, "t_over_sqrt_2kplus1_times_upper_bar": "1/4", - "probability_R_at_m_threshold": "1/2", - "expected_short_bar_count_lower_bound": "1/8", - }) - self.assertEqual(r["conditional_short_bar_witness"]["grid"][-1][ - "expected_short_bar_count_lower_bound"], "1/36") - - def test_general_integer_k_is_exact(self): - obj = self.sample() - obj["power"] = 3 - r = engine.witness(obj) - self.assertEqual(r["scale_model"]["small_amplitude_cdf_exponent"], "1/3") - self.assertEqual(r["scale_model"]["fourth_scale_moment"], "49/13") - self.assertEqual(r["conditional_short_bar_witness"]["growth_exponent"], "1") - self.assertEqual(r["conditional_short_bar_witness"]["grid"][0][ - "t_over_sqrt_2kplus1_times_upper_bar"], "1/8") - - def test_canonical_fractions(self): - obj = self.sample() - obj["bar_interval"] = {"lower": "2/4", "upper": "9/6"} - obj["base_expected_bar_count_lower_bound"] = "4/16" - r = engine.witness(obj) - self.assertEqual(r["premises"]["bar_interval_lower"], "1/2") - self.assertEqual(r["premises"]["bar_interval_upper"], "3/2") - self.assertEqual(r["premises"]["expected_base_bar_count_lower_bound"], "1/4") - - def test_witness_does_not_mutate_input(self): - obj = self.sample() - before = copy.deepcopy(obj) - engine.witness(obj) - self.assertEqual(obj, before) - - def test_invalid_power_and_rationals_refuse(self): - cases = [] - for power in (0, 1, 17, True, 2.0, "2", None): - obj = self.sample() - obj["power"] = power - cases.append(obj) - for bad in ("0", "-1/2", "1/0", "0.2", "nan", "1/01", 1, None): - obj = self.sample() - obj["base_expected_bar_count_lower_bound"] = bad - cases.append(obj) - for obj in cases: - with self.subTest(payload=str(obj)[:60]): - with self.assertRaises(engine.SpecRefused): - engine.witness(obj) - - def test_invalid_intervals_refuse(self): - for a,b in (("1","1"),("2","1"),("0","1"),("1","0")): - with self.subTest(a=a,b=b): - obj=self.sample() - obj["bar_interval"]={"lower":a,"upper":b} - with self.assertRaises(engine.SpecRefused): - engine.witness(obj) - - def test_grid_validation_refuses_empty_repeated_unsorted(self): - for bad in ([],[1],[2,2],[4,3],[True,2],[2,"3"],[2.5],[100001],[2]*21): - with self.subTest(bad=bad): - obj=self.sample() - obj["grid"] = bad - with self.assertRaises(engine.SpecRefused): - engine.witness(obj) - - def test_strict_json_duplicate_unknown_float_nonfinite_refuse(self): - raw_cases = ( - b'{"schema_version":1,"schema_version":1}', - b'{"k":2}', - json.dumps(dict(self.sample(), surprise="http://bad.example")).encode(), - json.dumps(dict(self.sample(), power=2.0)).encode(), - json.dumps(dict(self.sample(), power=None)).encode(), - b'NaN', - b'Infinity', - b'[]', - b'\xff\xfe', - b'0' * (engine.MAX_INPUT + 1), - ) - for raw in raw_cases: - with self.subTest(raw=raw[:35]): - with self.assertRaises(engine.SpecRefused): - engine.load_spec(raw) - - def test_source_identity_and_limits_explicit(self): - obj=engine.witness(self.sample()) - self.assertEqual(obj["scientific_effect"], "NONE") - self.assertFalse(obj["scientific_status_authority"]) - self.assertFalse(obj["source_identity_runtime_verified"]) - self.assertEqual(len(obj["source_identity"]["git_blob"]), 40) - self.assertEqual(obj["covariance_only_two_thirds_transfer"], - "REFUSED_BY_COUNTEREXAMPLE") - self.assertGreaterEqual(len(obj["scope_limits"]), 3) - - -class CLIControls(unittest.TestCase): - def run_program(self, mode=(), args=(), stdin=None): - return subprocess.run([sys.executable,"-B",*mode,"-S",str(SCRIPT),*args], - input=stdin, capture_output=True, timeout=10) - - def test_example_is_inert_and_roundtrips(self): - p=self.run_program(args=("--example",)) - self.assertEqual(p.returncode,0,p.stderr.decode()) - self.assertEqual(json.loads(p.stdout),engine.EXAMPLE_SPEC) - self.assertEqual(p.stderr,b"") - - def test_normal_optimized_identical_stdout(self): - sample=json.dumps(engine.EXAMPLE_SPEC).encode() - a=self.run_program(args=("--spec","-"),stdin=sample) - b=self.run_program(mode=("-O",),args=("--spec","-"),stdin=sample) - self.assertEqual(a.returncode,0,a.stderr.decode()) - self.assertEqual(b.returncode,0,b.stderr.decode()) - self.assertEqual(a.stdout,b.stdout) - self.assertEqual(a.stderr,b"") - self.assertEqual(json.loads(a.stdout)["scale_model"]["fourth_scale_moment"],"25/9") - - def test_require_covariance_transfer_vetoes_both_modes(self): - sample=json.dumps(engine.EXAMPLE_SPEC).encode() - for mode in ((),("-O",)): - with self.subTest(mode=mode): - p=self.run_program(mode=mode,args=("--spec","-", - "--require-covariance-transfer"),stdin=sample) - self.assertEqual(p.returncode,1) - self.assertEqual(p.stderr,b"") - self.assertEqual(json.loads(p.stdout)["covariance_only_two_thirds_transfer"], - "REFUSED_BY_COUNTEREXAMPLE") - - def test_malformed_cli_is_opaque_in_both_modes(self): - raw=b'{"schema_version":1,"url":"https://secret.example/a-key"}' - for mode in ((),("-O",)): - with self.subTest(mode=mode): - p=self.run_program(mode=mode,args=("--spec","-"),stdin=raw) - self.assertEqual(p.returncode,2) - self.assertEqual(p.stdout,b"") - self.assertEqual(p.stderr,b"AMP_TWIN_REFUSED: invalid-input\n") - self.assertNotIn(b"secret",p.stderr) - - def test_input_file_and_stdin_equivalent(self): - raw=json.dumps(engine.EXAMPLE_SPEC).encode() - with tempfile.TemporaryDirectory() as root: - path=Path(root)/"fixture.json" - path.write_bytes(raw) - by_path=self.run_program(args=("--spec",str(path))) - by_stdin=self.run_program(args=("--spec","-"),stdin=raw) - self.assertEqual(by_path.returncode,0) - self.assertEqual(by_path.stdout,by_stdin.stdout) - - def test_mutation_to_constant_scale_breaks_counterexample(self): - # The naive R=1 replacement keeps covariance but has E[R^4]=1. - # That replacement MUST fail the counterexample's 4th-moment witness. - obj=engine.witness(engine.EXAMPLE_SPEC) - self.assertEqual(Fraction(obj["scale_model"]["second_scale_moment"]),1) - actual_fourth=Fraction(obj["scale_model"]["fourth_scale_moment"]) - mutant_fourth=Fraction(1) - self.assertNotEqual(actual_fourth,mutant_fourth) - self.assertGreater(actual_fourth,mutant_fourth) - - -if __name__ == "__main__": - unittest.main() From 43d089c4b3fbc6330eda962cab18930230e5720f Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Fri, 23 Oct 2026 15:39:07 -0500 Subject: [PATCH 7/7] docs: point amplitude controls to hosted universality test discovery --- experiments/universality/AMPLITUDE_MIXTURE_FALSIFIER.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/experiments/universality/AMPLITUDE_MIXTURE_FALSIFIER.md b/experiments/universality/AMPLITUDE_MIXTURE_FALSIFIER.md index 2d1ba83f8..87011936b 100644 --- a/experiments/universality/AMPLITUDE_MIXTURE_FALSIFIER.md +++ b/experiments/universality/AMPLITUDE_MIXTURE_FALSIFIER.md @@ -47,8 +47,8 @@ The CLI accepts one inert, bounded JSON specification or prints a synthetic exam python -B -S experiments/universality/amplitude_mixture_falsifier.py --example python -B -S experiments/universality/amplitude_mixture_falsifier.py --spec /path/to/spec.json python -B -S experiments/universality/amplitude_mixture_falsifier.py --spec /path/to/spec.json --require-covariance-transfer -python -B -S -m unittest discover -s tests -p 'test_amplitude_mixture_falsifier.py' -v -python -B -O -S -m unittest discover -s tests -p 'test_amplitude_mixture_falsifier.py' -v +python -B -S -m unittest discover -s experiments/universality -p 'test_amplitude_mixture_falsifier.py' -v +python -B -O -S -m unittest discover -s experiments/universality -p 'test_amplitude_mixture_falsifier.py' -v ~~~ Synthetic example (not a measured bar intensity):