Skip to content

Audit CRT reservoir placement and split-axis coordinate descriptors - #4174

Open
kumagi wants to merge 1 commit into
CrocSwap:mainfrom
kumagi:research/contribution-20261020-sixth
Open

kumagi wants to merge 1 commit into
CrocSwap:mainfrom
kumagi:research/contribution-20261020-sixth

Conversation

@kumagi

@kumagi kumagi commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

PR4100's CRT switch controls can read an entire left child. Its borrowed-field placement therefore needs more than avoidance of the target axes: it must preserve those dense dependencies after coordinate exchanges. This adds a constructive audit of CRT.md §3, including the root's inactive-quarter choice and axes split by placement.

The quantified proof covers the original mixed-width domain and constants. It gives at most 25,600 batches per synchronized switch layer, three mutually disjoint field exchanges plus their inverses, and at most d+12 coordinate fragments. Full dirty-state restoration is conditional on the completed repaired switch's all-address contract. The allocator and verifier make the coordinates and counterexamples independently inspectable.

Validation on Python 3.12.13:

  • Registered ordinary and optimized replay passed: 104,864 production descriptor plans / 524,288 active-axis visits; all 4,096 dirty addresses of a separate reduced root-axis caller; 28,672 layer conjugations; 86,016 omission checks; forward/inverse composition; six semantic controls.
  • Package metadata and pins, committed-byte/source-history preflight, and deterministic export integrity passed.
  • Git-free optimized export replay reproduced the receipt without changing exported bytes; modified predecessor source bytes were rejected.

The large run is a descriptor census. The finite caller is a root-axis projection using ideal completed-switch endpoints, not a raw compact-macro replay. No complete control evaluator, ordinary-callee implementation, last-K tail, sorting tariff, numerical claim, full CRT/multiplication theorem, or new κ is asserted. The selected frontier is unchanged.

Starts independently from canonical main 12fa8c5c844be21bfefb38a19503fbd867a11244 under priority revision 7. PR4169's repair result is complementary context, not an executable dependency. Canonical coordination: Discussion #4173. Open next question: bind split-axis descriptors to the actual fixed-tape E(p,ell) evaluator and account for scans, exchanges, erasure and head returns.

Credit: Cinna Davis's PR4100 supplies the audited construction; Vlado Vojdanovski's PR1673 and Jose Manuel's physical support router supply the predecessor exchange/recoloring methods. Retained compact/routing lineage is credited in the package. Prepared by Hiroki KUMAZAKI (@kumagi) with substantial OpenAI Codex assistance; new work Apache-2.0. This is not independent human review or formal proof-assistant verification.

@rcfc-jreed

Copy link
Copy Markdown
Contributor

Independent scoped audit of the CRT reservoir placement package at 5fec853f: no defect found in the finite production-census / caller-fixture / seal layer

Code-disjoint reimplementation; does not import package verify.py / allocator.py. Package bytes from head 5fec853f0c048871de3b8098d1e30d4ee19cda23 via GitHub contents API. CLAIM.

What passes (13 of 13):

  1. Pins / seals. Base 12fa8c5c…. RESULT PASS_CRT_RESERVOIR_PLACEMENT; VERIFY ready. Five SOURCES inputs authenticate (sha256 + git blob).
  2. Production layout arithmetic. Alternating 24/23 widths → L=1540096; G=64(ell+ceil(log2(p+2)))=3072; r_max=floor(L/(100G))=5; H=15360. Tree: 16 levels × ceil(d/10)=6554 → 104864 batches; active_axis_visits=d·levels/2=524288.
  3. Finite caller structure. Moduli [3,5,7,11], widths [2,3,3,4], L=12, H=1, 4096 addresses; conjugations 7·4096; borrowed-field checks 3·conjugations; six named semantic failure controls + four input rejections.
  4. Scope honesty. Limitations exclude full CRT, multiplication theorem, and new κ.

Not covered: live iter_plans schedule re-hash / plan-by-plan reservoir disjointness; ordinary exchange machine; full CRT / multiplication theorem; new κ.

This is a finite replay of committed receipts, not a formal proof.

check_4174.py
#!/usr/bin/env python3
"""Independent finite controls for PR4174 (CRT reservoir placement).

Recomputes production layout constants and RESULT census arithmetic; authenticates
SOURCES inputs. Does not import package verify.py / allocator.py.

Package head 5fec853f0c048871de3b8098d1e30d4ee19cda23; deps at base 12fa8c5c….

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

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

HEAD = "5fec853f0c048871de3b8098d1e30d4ee19cda23"
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 ceil_log2(n: int) -> int:
    return (n - 1).bit_length()


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 run(pkg: Path, deps: Path):
    sources = json.loads((pkg / "SOURCES.json").read_text())
    task = json.loads((pkg / "TASK.json").read_text())
    verify = json.loads((pkg / "VERIFY.json").read_text())
    result = json.loads((pkg / "RESULT.json").read_text())

    check("I1 SOURCES/TASK/RESULT base_commit == 12fa8c5c…",
          sources["base_commit"] == BASE == task["base_commit"] == result["base_commit"])
    check("I2 RESULT PASS_CRT_RESERVOIR_PLACEMENT; VERIFY ready",
          result["result"] == "PASS_CRT_RESERVOIR_PLACEMENT"
          and verify["status"] == "ready")

    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"] == 5, bad)

    prod = result["production"]
    d, ell, p, L = prod["d"], prod["ell"], prod["p"], prod["L"]
    # alternating 24,23 widths
    widths_sum = (d // 2) * (ell + (ell - 1))
    G = 64 * (ell + ceil_log2(p + 2))
    r_max = L // (100 * G)
    H = r_max * G
    levels = int(math.log2(d))
    per_level = -(-d // 10)  # ceil(d/10)
    total_batches = levels * per_level

    check("P1 production L = (d/2)*(24+23) for alternating widths; d=65536 power of two ≥51200",
          L == widths_sum == 1540096
          and d == 65536 and (d & (d - 1)) == 0 and d >= 51200
          and prod["width_pattern"] == "24,23 repeated")
    check("P2 G=64(ell+ceil(log2(p+2)))=3072; r_max=floor(L/(100G))=5; H=15360",
          G == prod["G"] == 3072
          and r_max == prod["r_max"] == 5
          and H == prod["H"] == 15360
          and ell == 24 and p == 9240576)
    check("P3 tree_levels=log2(d)=16; batches/level=ceil(d/10)=6554; total_batches=104864",
          prod["tree_levels"] == levels == 16
          and prod["batches_per_level"] == [per_level] * levels
          and per_level == 6554
          and prod["total_batches"] == total_batches == 104864)
    check("P4 active_axis_visits == d * tree_levels / 2 == 524288",
          prod["active_axis_visits"] == d * levels // 2 == 524288)
    check("P5 max_extra_descriptor_fragments == 7; schedule_sha256 is 64 hex chars",
          prod["max_extra_descriptor_fragments"] == 7
          and len(prod["schedule_sha256"]) == 64
          and all(c in "0123456789abcdef" for c in prod["schedule_sha256"]))

    call = result["finite_caller"]
    check("C1 finite_caller: L=12, H=1, 4096 addresses; conjugations=7*4096; borrowed=3*conjugations",
          call["L"] == 12 and call["H"] == 1
          and call["all_dirty_addresses"] == 4096
          and call["layers"] == 7
          and call["single_layer_conjugations"] == 7 * 4096 == 28672
          and call["borrowed_field_omission_checks"] == 3 * 28672 == 86016
          and call["forward_steps"] == call["inverse_steps"] == 28672
          and call["moduli"] == [3, 5, 7, 11]
          and call["widths"] == [2, 3, 3, 4]
          and call["root_target_axis"] == 3
          and call["reservoir_axis"] == 2)
    check("C2 payload_permutation_sha256 present; six semantic failure controls named",
          len(call["payload_permutation_sha256"]) == 64
          and len(call["semantic_failure_controls"]) == 6
          and {c["name"] for c in call["semantic_failure_controls"]} >= {
              "root reservoir intersects full left-child dependency",
              "overlapping source/destination rejected",
              "stale coordinate descriptors",
              "global bit used as middle-field bit",
              "split axis read as one contiguous slice",
              "third inverse exchange omitted",
          })
    check("C3 four input_rejections present (small geometry / non-power-of-two / width / ell)",
          len(result["input_rejections"]) == 4
          and any("small geometry" in x for x in result["input_rejections"]))

    check("NEG1 limitations exclude full CRT / multiplication theorem / new kappa",
          any("new kappa" in x.lower() for x in result["limitations"])
          and any("multiplication theorem" in x.lower() for x in result["limitations"]))

    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).

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