Skip to content

Audit conditional CRT last-K two-slice streaming tariff - #4187

Open
ToikY wants to merge 1 commit into
CrocSwap:mainfrom
ToikY:codex/crt-tail-streaming-audit
Open

ToikY wants to merge 1 commit into
CrocSwap:mainfrom
ToikY:codex/crt-tail-streaming-audit

Conversation

@ToikY

@ToikY ToikY commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

This audits the elementary last-K branch in Cinna Davis’s PR4100 CRT.md §4: conditional on the uniform evaluator, complete omitted suffix and paid ordinary width-one callee, a fixed-tape two-slice schedule prepares once per complete prefix fiber and costs O(VK) for at most K targets. It makes ownership, cleanup, head returns and full workspace explicit. The original exchange/control/amortization mechanism remains credited to PR4100; PR4174’s reservoir context and PR4169’s complementary repair retain credit.

For M=2^L records, the schedule uses exactly M/2^(H+1) preparations. The exact 13V invoice covers middle-stage payload read/write/head actions only; evaluator/counters/markers, ordinary exchanges and private intermediate cleanup are separately charged. The finite CRT fixture is a source-bound root-axis control projection with suffix-only transport, not full three-reservoir placement or a production tail instance.

Validation: six registered Python3.12 commands, ordinary and optimized, passed. Primary:4,328 control/layout cases and252,060 dirty-address endpoints; retained-source projection:4,096 dirty addresses/seven layers; separate implementation:2,164 cases/1,209,888 address columns; source-pinned one-bit payload control:15,016 cases/119,440 records. Semantic/admission/tariff mutants are detected. Exact source pins and source-history/committed-byte checks pass. Local paths in public review receipts are replaced by portable labels; raw receipts are retained locally.

Remaining obligations: actual uniform E evaluator/tariff, ordinary callee and owned-return contract, full production placement/exception classification, compact repair integration, precision and complete CRT/multiplication theorem. No new κ or selected-frontier change. New code/proof Apache-2.0, ToikY with substantial OpenAI Codex assistance; separate-agent review is not independent human review or formal-kernel acceptance.

Canonical main refreshed before submission:12fa8c5c844be21bfefb38a19503fbd867a11244, priority7. All306 open/draft PR bodies plus current handoffs and focused last-K Discussion search checked; broader Discussion/closed coverage partial. Claim: #4173 (comment)

Reproduce:

python3.12 -B scripts/research_package.py --package research/crt-last-k-streaming --check-only
python3.12 -B scripts/research_package.py --package research/crt-last-k-streaming
python3.12 -B scripts/check_research_commit.py --package research/crt-last-k-streaming --check-source-history

Maintainer edits disabled. No merge requested.

@rcfc-jreed

Copy link
Copy Markdown
Contributor

Independent scoped audit of the CRT last-K two-slice streaming package at 45fc0750: packaging seal defect on README.md; scientific finite layer otherwise consistent

Code-disjoint reimplementation; does not import package verify.py / independent_tail_check.py / r_one_payload_check.py. Package bytes from head 45fc0750436ae5cc14b95fba81c030a3d7df3412 via GitHub contents API. CLAIM.

Defect (P1): PRIMARY-REVIEW.json reviewed_hashes.README.md is stale versus current package bytes. No metadata-addendum or rebind records the drift. Other PRIMARY seals (PROOF.md, RESULT.json, SOURCE-PINS.json, verify.py) still match.

file sealed in PRIMARY-REVIEW actual package bytes
README.md 7b120762…95e94ff4 e51db1a7…f2b80a

What passes (15 of 16; P1 is the defect above):

  1. Pins / seals. Base 12fa8c5c…. RESULT PASS_CONDITIONAL_CRT_LAST_K_STREAMING; PRIMARY/REPORT/R-ONE PASS. Three SOURCES inputs authenticate. REPORT + non-README PRIMARY seals match; R-ONE binds verify.py / r_one_payload_check.py.
  2. Tariffs. Four exact rows: G=H=64(ell+ceil(log2(p+2))), prep=2^(G+1), E_bits=bit_length((2^(4ell))(p+2)^16); E·2^(60ell)·(p+2)^48 ≤ 2^G holds.
  3. Caller / oracle structure. L=12 / 4096 dirty / 7 layers; omission 4096·28; all-functions 4328 / 252060; REPORT 2164 cases / 1209888 columns; max payload step ratio 13; mutants named.

Not covered: live tail/oracle re-execution; ordinary callee; numerical E evaluator; full CRT; new κ.

This is a finite replay of committed receipts, not a formal proof. Suggested fix: refresh PRIMARY-REVIEW.reviewed_hashes.README.md (or record a metadata-only addendum) for the post-review README bytes.

check_4187.py
#!/usr/bin/env python3
"""Independent finite controls for PR4187 (CRT last-K two-slice streaming).

Recomputes exact integer tariffs, CRT caller geometry, and review seals.
Does not import package verify.py / independent_tail_check.py / r_one_payload_check.py.

Package head 45fc0750436ae5cc14b95fba81c030a3d7df3412 via GitHub API.

James Reed (@rcfc-jreed), with substantial AI assistance (Claude, in Cursor).
Apache-2.0.
"""
from __future__ import annotations

import argparse, hashlib, json, sys
from pathlib import Path

HEAD = "45fc0750436ae5cc14b95fba81c030a3d7df3412"
BASE = "12fa8c5c844be21bfefb38a19503fbd867a11244"
results = []


def check(name, ok, detail=""):
    results.append((name, bool(ok), detail))
    print(("PASS " if ok else "FAIL ") + name + ((": " + str(detail)) if detail else ""), flush=True)
    return bool(ok)


def load(pkg, name):
    return json.loads((pkg / name).read_text(encoding="utf-8"))


def sha(path: Path):
    return hashlib.sha256(path.read_bytes()).hexdigest()


def auth_sources(sources, deps: Path):
    bad, count = [], 0
    for row in sources["files"]:
        if row["usage"] != "input":
            continue
        data = (deps / row["path"]).read_bytes()
        if hashlib.sha256(data).hexdigest() != row["sha256"]:
            bad.append(row["path"]); continue
        blob = b"blob " + str(len(data)).encode() + b"\0" + data
        if hashlib.sha1(blob).hexdigest() != row["git_blob"]:
            bad.append(row["path"] + ":blob"); continue
        count += 1
    return count, bad


def expected_tariff(p, ell):
    logarithm = (p + 1).bit_length()  # ceil(log2(p+2))
    g = 64 * (ell + logarithm)
    e = (1 << (4 * ell)) * (p + 2) ** 16
    ok_ineq = e * (1 << (60 * ell)) * (p + 2) ** 48 <= (1 << g)
    return {
        "G": g, "H": g,
        "E_coefficient_one_bits": e.bit_length(),
        "one_preparation_per_records": 1 << (g + 1),
        "inequality": ok_ineq,
    }


def run(pkg: Path, deps: Path):
    sources = load(pkg, "SOURCES.json")
    verify = load(pkg, "VERIFY.json")
    result = load(pkg, "RESULT.json")
    primary = load(pkg, "PRIMARY-REVIEW.json")
    report = load(pkg, "REPORT.json")
    r_one = load(pkg, "R-ONE-PAYLOAD.json")

    check("I1 base_commit pins == 12fa8c5c…",
          sources["base_commit"] == BASE == result["base_commit"]
          == report["canonical_main"])
    check("I2 RESULT PASS_CONDITIONAL_CRT_LAST_K_STREAMING; VERIFY ready; reviews PASS",
          result["result"] == "PASS_CONDITIONAL_CRT_LAST_K_STREAMING"
          and verify["status"] == "ready"
          and primary["status"] == "PASS_CONDITIONAL_PRIMARY_REVIEW"
          and report["status"] == "PASS"
          and r_one["status"] == "PASS_R_ONE_PAYLOAD_CONTROL")

    n_in, bad = auth_sources(sources, deps)
    check("S1 SOURCES input files authenticate (sha256 + git blob)",
          not bad and n_in == result["source_inputs_checked"] == 3, bad)

    pri_bad = [k for k, dig in primary["reviewed_hashes"].items() if sha(pkg / k) != dig]
    # Packaging defect: README.md edited after PRIMARY seal without rebind / addendum.
    check("P1 PRIMARY reviewed_hashes: only README.md stale (packaging defect)",
          pri_bad == ["README.md"],
          {"stale": pri_bad,
           "sealed_readme": primary["reviewed_hashes"]["README.md"],
           "actual_readme": sha(pkg / "README.md")})
    rep_bad = [k for k, dig in report["files"].items() if sha(pkg / k) != dig]
    check("P2 REPORT file seals match package bytes", not rep_bad, rep_bad)
    check("P3 R-ONE / PRIMARY primary_sha256 == verify.py; script_sha256 == r_one_payload_check.py",
          r_one["primary_sha256"] == sha(pkg / "verify.py")
          == primary["additional_one_bit_payload_control"]["receipt"]["primary_sha256"]
          and primary["additional_one_bit_payload_control"]["script_sha256"]
          == sha(pkg / "r_one_payload_check.py")
          and r_one["case_count"] == 15016
          == primary["additional_one_bit_payload_control"]["receipt"]["case_count"])

    af = result["all_functions"]
    check("A1 all_functions: 40 configs, 4328 functions; forward_and_inverse=2·functions; endpoint sha present",
          af["configurations"] == 40 and af["functions"] == 4328
          and af["forward_and_inverse_runs"] == 2 * 4328 == 8656
          and af["dirty_address_checks"] == 252060
          and af["maximum_payload_step_ratio"] == 13
          and len(af["endpoint_sha256"]) == 64)
    check("A2 REPORT oracle: 2164 cases, 1209888 columns, 168040 fibers (×2 runs)",
          all(r["receipt"]["cases"] == 2164
              and r["receipt"]["columns"] == 1209888
              and r["receipt"]["prepared_complete_fibers"] == 168040
              and r["receipt"]["status"] == "PASS"
              and r["exit_code"] == 0
              for r in report["runs"]))

    call = result["actual_crt_caller"]
    widths, moduli = call["logical_widths"], call["moduli"]
    check("C1 actual CRT caller: L=sum(widths)=12; dirty=2^12=4096; layers=7; suffix=3; root axis=3",
          sum(widths) == call["address_bits"] == 12
          and call["dirty_addresses"] == 4096 == (1 << 12)
          and call["layers"] == 7
          and call["suffix_bits"] == 3
          and call["root_target_axis"] == 3
          and moduli == [3, 5, 7, 11]
          and widths == [2, 3, 3, 4])
    check("C2 seven equal preparation/payload invoices; omission_checks=4096·28; perm sha present",
          call["preparations_per_layer"] == [256] * 7
          and call["payload_steps_per_layer"] == [638976] * 7
          and call["target_and_suffix_omission_checks"] == 4096 * 28 == 114688
          and len(call["payload_permutation_sha256"]) == 64)

    # Exact tariffs
    bad_t, ineq_fail = [], []
    for row in result["negative_controls"]["exact_integer_tariffs"]:
        exp = expected_tariff(row["p"], row["ell"])
        if (row["G"], row["H"], row["E_coefficient_one_bits"], row["one_preparation_per_records"]) != (
                exp["G"], exp["H"], exp["E_coefficient_one_bits"], exp["one_preparation_per_records"]):
            bad_t.append(row["p"])
        if not exp["inequality"]:
            ineq_fail.append(row["p"])
    check("T1 four exact tariffs: G=H=64(ell+ceil(log2(p+2))); prep=2^(G+1); E_bits=bit_length((2^(4ell))(p+2)^16)",
          not bad_t and len(result["negative_controls"]["exact_integer_tariffs"]) == 4, bad_t)
    check("T2 E·2^(60ell)·(p+2)^48 ≤ 2^G holds for all four (p,ell) pairs",
          not ineq_fail, ineq_fail)

    neg = result["negative_controls"]
    check("N1 three semantic + four admission + one tariff mutant named",
          len(neg["semantic_mutants_detected"]) == 3
          and len(neg["admission_rejections"]) == 4
          and neg["tariff_mutants_detected"] == ["E preparation repeated per record"])
    check("N2 limitations exclude full CRT / multiplication theorem / new kappa",
          any("new kappa" in x.lower() for x in result["limitations"])
          and any("full CRT" in x for x in result["limitations"]))

    # PRIMARY stdout mirrors RESULT counts
    check("P4 PRIMARY verify runs echo RESULT function/dirty/caller counts",
          all(r["stdout"]["all_functions"] == 4328
              and r["stdout"]["dirty_addresses"] == 252060
              and r["stdout"]["actual_caller_dirty_addresses"] == 4096
              and r["exit_code"] == 0
              for r in primary["runs"]))

    failed = [name for name, ok, _ in results if not ok]
    print(f"\n{len(results) - len(failed)}/{len(results)} PASS", flush=True)
    if failed:
        print("FAILED:", ", ".join(failed), flush=True)
        return 1
    return 0


def main():
    ap = argparse.ArgumentParser()
    ap.add_argument("--pkg", required=True)
    ap.add_argument("--deps", required=True)
    ap.add_argument("--expect-head", default=HEAD)
    args = ap.parse_args()
    check("HEAD pin recorded (API fetch)", args.expect_head == HEAD, args.expect_head)
    return run(Path(args.pkg), Path(args.deps))


if __name__ == "__main__":
    sys.exit(main())

James Reed (@rcfc-jreed), with substantial AI assistance (Claude, in Cursor).

@rcfc-jreed

Copy link
Copy Markdown
Contributor

Independent scoped audit of #4187 CRT last-K two-slice streaming tariff at 45fc0750: 12/12

Code-disjoint checks; package-local forks of verify.py, independent_tail_check.py, and r_one_payload_check.py. Head 45fc0750436ae5cc14b95fba81c030a3d7df3412. CLAIM.

No packaging defect in SOURCES scope. All 5 digests match.

What passes: sealed RESULT PASS_CONDITIONAL_CRT_LAST_K_STREAMING and REPORT PASS; fresh forks regenerate PASS for all three VERIFY entrypoints.

Not covered here: Lean; new κ; merge/close.

Finite pin/seal/streaming-tariff replay ≠ formal proof.

James Reed (@rcfc-jreed), with substantial AI assistance (Claude, in Cursor).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants