From 2544813dbb32bea44d2df8eff8b18340bd3d209e Mon Sep 17 00:00:00 2001 From: JoyboyBrian <122925040+JoyboyBrian@users.noreply.github.com> Date: Sat, 24 Oct 2026 20:58:37 -0700 Subject: [PATCH 1/2] Bind actual Gaussian RHS pair to physical block layout and return --- .../physical-boundary-rhs-caller/PROOF.md | 168 +++++++++++++++ .../physical-boundary-rhs-caller/README.md | 66 ++++++ .../physical-boundary-rhs-caller/RESULT.json | 204 ++++++++++++++++++ .../physical-boundary-rhs-caller/SOURCES.json | 144 +++++++++++++ .../physical-boundary-rhs-caller/TASK.json | 86 ++++++++ .../VALIDATION.md | 25 +++ .../physical-boundary-rhs-caller/VERIFY.json | 49 +++++ .../physical-boundary-rhs-caller/caller.py | 47 ++++ .../physical-boundary-rhs-caller/controls.py | 75 +++++++ .../physical-boundary-rhs-caller/fixture.py | 86 ++++++++ .../rhs_layout.py | 101 +++++++++ .../physical-boundary-rhs-caller/verify.py | 186 ++++++++++++++++ 12 files changed, 1237 insertions(+) create mode 100644 research/physical-boundary-rhs-caller/PROOF.md create mode 100644 research/physical-boundary-rhs-caller/README.md create mode 100644 research/physical-boundary-rhs-caller/RESULT.json create mode 100644 research/physical-boundary-rhs-caller/SOURCES.json create mode 100644 research/physical-boundary-rhs-caller/TASK.json create mode 100644 research/physical-boundary-rhs-caller/VALIDATION.md create mode 100644 research/physical-boundary-rhs-caller/VERIFY.json create mode 100644 research/physical-boundary-rhs-caller/caller.py create mode 100644 research/physical-boundary-rhs-caller/controls.py create mode 100644 research/physical-boundary-rhs-caller/fixture.py create mode 100644 research/physical-boundary-rhs-caller/rhs_layout.py create mode 100644 research/physical-boundary-rhs-caller/verify.py diff --git a/research/physical-boundary-rhs-caller/PROOF.md b/research/physical-boundary-rhs-caller/PROOF.md new file mode 100644 index 0000000000..e7253e1e92 --- /dev/null +++ b/research/physical-boundary-rhs-caller/PROOF.md @@ -0,0 +1,168 @@ +# Actual two-component Gaussian RHS boundary + +JoyboyBrian, substantial OpenAI Codex assistance. Apache-2.0. + +## Decision and exact source boundary + +NARROW the explicit `physical-boundary-pages` handoff to its missing RHS +layout, using the actual `Core.gather` and `Core.first_cell` methods at base +32890bc5de034ab8fc93ac88ead7279a6a416d04. The predecessor has a complete +inverse-block consumer and a charged classical kernel. It has no actual RHS +layout adapter. A separate seven-product kernel does not solve this boundary. +This contribution removes that missing adapter for the real and imaginary +components of **one** actual Core invocation. It is not a many-field supplier. + +The exact first-pass contract is the one in `gaussian_core.py`: read the +complete complex source, validate its disk bound in the real pass, select and +scale the listed rows, execute each interior solve, subtract its boundary +couplings, and round the resulting RHS once. `first_pass_pair` invokes those +unchanged methods and retains their full row/count/page-extent checks. It +parks the first component while producing the second, and erases each selected +interior stream after its first pass. Borrowed source and page heads return. +The caller has not yet run its second-cell reconstruction or normalization. + +The exact reference for the executed fixture is LU(round_P(S)), with S the +Schur complement of its supplied exact principal matrix. The block page +producer computes exact inverses of these factors and rounds once, unchanged. +The fixture is adapted from Jose Manuel's supplied-factor consumer check at +p=4, P=16, width=32; it is not a production Gaussian catalogue or an analytic +precision certificate. The nontrivial five-row fixture selects [0,1,3,4,5] +from six complex rows, has three interior rows, and yields two boundary rows. +Both actual interior calls execute. A one-row fixture exercises incomplete +rows and incomplete component columns at B=4. B=1 exercises separate batches. + +## Quantified layout proposition + +Let n,B,w be positive encoded integers. Let two distinct borrowed tapes hold +exactly n literal w-bit records each, in the actual Core real and imaginary +boundary-row order. These records are opaque to this adapter; it does not +interpret a sign, magnitude, or numerical grid. Metadata and payload tapes +are disjoint, every supplied payload head is at the first body cell (head 1), +and every supplied tape is a valid complete canonical stream. Entry heads +are checked before layout reads. The fixed scratch pool has sufficient free +roles for the declared Count operations and output leases. +Let K=ceil(n/B), N=KB, J=ceil(2/B), and A=NJ B w. + +`pack` returns, for batch b, row i, local column j, the record from component +bB+j and row i when i= 0 else Q(0)) + for i in reversed(range(len(boundary))): + for j in range(i+1, i+band+1): + put(high[i][j] if j < len(boundary) else Q(0)) + put(reciprocal[i]) + for real, imaginary in target: + put(real, source, input_width, p) + put(imaginary, source, input_width, p) + page.rewind() + source.rewind() + expected = [] + for component in (0, 1): + b = [target[i][component] for i in selection] + y = reference.apply(factors, [b[i] for i in inside], reference.counter()) if inside else [] + expected.append([rounding(b[i]-sum((rounding(matrix[i][j])*y[k] for k,j in enumerate(inside)), Q())) for i in boundary]) + return page, source, exact_low, exact_high, expected, width, bits diff --git a/research/physical-boundary-rhs-caller/rhs_layout.py b/research/physical-boundary-rhs-caller/rhs_layout.py new file mode 100644 index 0000000000..0ff4ff26c5 --- /dev/null +++ b/research/physical-boundary-rhs-caller/rhs_layout.py @@ -0,0 +1,101 @@ +"""Physical two-component Gaussian RHS layout. JoyboyBrian / Codex; Apache-2.0.""" +from cardinal_counts import Count, positive +from encoded import compare +from boundary_pages import ceiling_division +from router_metadata import indices, owned +from session import borrowed_tape +from words import BLANK, need + + +def bit_scan(source, width, destination=None, zero=False): + for _ in indices(width): + value = source.read() + need(value in (0, 1) and (not zero or value == 0), 'literal RHS bits and zero padding') + if destination is not None: + destination.append(value) + source.step(1) + + +def zeros(destination, width): + for _ in indices(width): + destination.append(0) + + +def validate(ports, metadata): + physical = [borrowed_tape(t) for t in ports] + need(len({id(t) for t in physical}) == len(physical), 'distinct layout payload ports') + need(all(t.head == 1 for t in physical), 'canonical layout entry heads') + need(all(borrowed_tape(c.tape) not in physical for c in metadata), 'separate layout metadata') + for c in metadata: + positive(c) + return physical + + +def pack(real, imaginary, rows, block, width, pool): + """Borrow two n-record streams; return one owned padded batch stream.""" + sources = validate((real, imaginary), (rows, block, width)) + output = pool.acquire() + success = False + try: + with owned(Count.literal(2), ceiling_division(rows, block)) as (two, blocks): + with owned(ceiling_division(two, block), Count.product(blocks, block)) as (batches, padded): + for batch in indices(batches): + for source in sources: + source.rewind() + with owned(Count.product(batch, block)) as (start,): + for row in indices(padded): + for offset in indices(block): + with owned(Count(start)) as (column,): + column.add(offset) + if compare(row, rows) < 0 and compare(column, two) < 0: + bit_scan(sources[0] if column.zero() else sources[1], width, output) + else: + zeros(output, width) + # At B=1 the unselected component still needs a complete extent check. + for source in sources: + source.rewind() + for _ in indices(rows): + bit_scan(source, width) + need(source.read() == BLANK, 'complete component RHS extent') + source.rewind() + output.rewind() + success = True + return output + finally: + for source in sources: + source.rewind() + if not success: + output.clear() + + +def unpack(source, rows, block, width, pool): + """Borrow a protected return; recover two owned scalar RHS streams.""" + source, = validate((source,), (rows, block, width)) + outputs = [] + success = False + try: + outputs.append(pool.acquire()) + outputs.append(pool.acquire()) + source.rewind() + with owned(Count.literal(2), ceiling_division(rows, block)) as (two, blocks): + with owned(ceiling_division(two, block), Count.product(blocks, block)) as (batches, padded): + for batch in indices(batches): + with owned(Count.product(batch, block)) as (start,): + for row in indices(padded): + for offset in indices(block): + with owned(Count(start)) as (column,): + column.add(offset) + if compare(row, rows) < 0 and compare(column, two) < 0: + bit_scan(source, width, outputs[0] if column.zero() else outputs[1]) + else: + bit_scan(source, width, zero=True) + need(source.read() == BLANK, 'complete padded RHS return extent') + for out in outputs: + out.rewind() + success = True + return tuple(outputs) + finally: + source.rewind() + if not success: + for out in outputs: + out.clear() diff --git a/research/physical-boundary-rhs-caller/verify.py b/research/physical-boundary-rhs-caller/verify.py new file mode 100644 index 0000000000..952b114d12 --- /dev/null +++ b/research/physical-boundary-rhs-caller/verify.py @@ -0,0 +1,186 @@ +"""Source-bound actual caller composition and independent Fraction oracle.""" +import argparse +from contextlib import contextmanager +from fractions import Fraction as Q +import hashlib +import importlib.util +import json +from pathlib import Path +import sys + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parent.parent + + +def need(ok, message): + if not ok: + raise ValueError(message) + + +def load(name, path): + spec = importlib.util.spec_from_file_location(name, path) + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + return module + + +def authenticate(): + for row in json.loads((HERE / 'SOURCES.json').read_text())['files']: + if row['usage'] == 'input': + need(hashlib.sha256((ROOT / row['path']).read_bytes()).hexdigest() == row['sha256'], 'source bytes: '+row['path']) + + +def case(length, block_size): + from cardinal_counts import Count + from check_support import no_decode + from gaussian_core import Core + from gaussian_matrix import Matrix + from gaussian_rationals import Rational + from records import Tape + from ring_check_words import body, decode + from ring_words import Signed, read_signed + from router_metadata import owned + from session import initialize_marker, erase_marker, sealed_constructors, borrowed_tape + from words import BLANK + import boundary_pages + from fixture import fixture + from caller import first_pass_pair + from rhs_layout import pack, unpack + + tapes = [] + original_init = Tape.__init__ + def track(tape): + original_init(tape) + tapes.append(tape) + Tape.__init__ = track + try: + core, consumer = Core(), boundary_pages.BoundaryPages() + page, source, lower, upper, reference_rhs, width_int, precision_int = fixture(length) + dirty = Tape() + for value in (1, 0, 1, 1, 0, 1, 0): + dirty.append(value) + dirty.rewind() + protected = (page, source, dirty) + saved = [(bytes(t.cells), t.head) for t in protected] + def meter(): + return [sum(getattr(t.meter, key) for t in tapes) for key in ('reads','writes','moves')] + def delta(start): + return [a-b for a,b in zip(meter(),start)] + def values(tape, count, width): + out = [] + tape.rewind() + for _ in range(count): + with owned(read_signed(tape, width)) as (value,): + out.append(Q((-1 if value.negative else 1)*decode(value.magnitude), 1 << precision_int)) + need(tape.read() == BLANK, 'exact decoded extent') + tape.rewind() + return out + for tape in core.pool.tapes: + initialize_marker(tape) + outputs, header, pages, matrices, packed, returned, scattered = (), None, (), [], None, None, () + phases = {} + with owned(Count.literal(block_size), Count.literal(2)) as (block, two): + try: + with sealed_constructors(), core.scope.installed(): + start = meter() + with no_decode(): + outputs, header = first_pass_pair(core, page, source) + phases['actual_first_pass_pair'] = delta(start) + n = len(lower) + need([values(t,n,header.width) for t in outputs] == reference_rhs, 'actual Core RHS equals independent first-pass oracle') + def make(value): + return Rational(Signed(Count.literal(abs(value.numerator)), value < 0), Count.literal(value.denominator)) + matrices = [Matrix(header.boundary_length, header.boundary_length, core.pool, + lambda i,j,a=a: make(a[decode(i)][decode(j)])) for a in (lower,upper)] + start = meter() + with no_decode(): + pages = boundary_pages.prepare_pages(*matrices, block, header.width, header.P, core.pool) + phases['exact_reference_page_setup'] = delta(start) + start = meter() + with no_decode(): + packed = pack(*outputs, header.boundary_length, block, header.width, core.pool) + phases['pack'] = delta(start) + snapshot = [body(borrowed_tape(t)) for t in (*pages,packed,*outputs)] + start = meter() + with core.scope.suspended(), no_decode(): + returned = consumer.run(*pages, packed, header.boundary_length, two, block, header.width, header.P) + phases['unchanged_boundary_consumer'] = delta(start) + start = meter() + with no_decode(): + scattered = unpack(returned, header.boundary_length, block, header.width, core.pool) + phases['unpack'] = delta(start) + actual = [values(t,n,header.width) for t in scattered] + oracle = load('boundary_independent_oracle', ROOT/'research/physical-boundary-pages/verify.py') + data = [list(row) for row in zip(*reference_rhs)] + expected_padded = oracle.oracle(lower, upper, data, block_size, precision_int) + padded_rows = ((n+block_size-1)//block_size)*block_size + expected = [[],[]] + for batch in range((2+block_size-1)//block_size): + for row in range(padded_rows): + for col in range(block_size): + j=batch*block_size+col + if row Date: Sat, 24 Oct 2026 21:00:28 -0700 Subject: [PATCH 2/2] Verify RHS caller source failures and cold export reproducibility --- .../physical-boundary-rhs-caller/README.md | 1 + .../VALIDATION.md | 26 +++++++-- .../physical-boundary-rhs-caller/VERIFY.json | 11 ++++ .../test_integrity.py | 57 +++++++++++++++++++ 4 files changed, 90 insertions(+), 5 deletions(-) create mode 100644 research/physical-boundary-rhs-caller/test_integrity.py diff --git a/research/physical-boundary-rhs-caller/README.md b/research/physical-boundary-rhs-caller/README.md index f4cb693136..d52c7a02c1 100644 --- a/research/physical-boundary-rhs-caller/README.md +++ b/research/physical-boundary-rhs-caller/README.md @@ -34,6 +34,7 @@ Run with Python 3.12 and the standard library: ```sh python3.12 -I -B research/physical-boundary-rhs-caller/verify.py python3.12 -I -O -B research/physical-boundary-rhs-caller/verify.py +python3.12 -I -O -B research/physical-boundary-rhs-caller/test_integrity.py python3.12 -B scripts/research_package.py --package research/physical-boundary-rhs-caller ``` diff --git a/research/physical-boundary-rhs-caller/VALIDATION.md b/research/physical-boundary-rhs-caller/VALIDATION.md index 61f953b80d..d59ebf3fba 100644 --- a/research/physical-boundary-rhs-caller/VALIDATION.md +++ b/research/physical-boundary-rhs-caller/VALIDATION.md @@ -1,6 +1,6 @@ # Validation and limits -Author execution: macOS arm64, CPython3.12, base +Author execution: macOS arm64, CPython3.12.2 (Clang15.0.0), base 32890bc5de034ab8fc93ac88ead7279a6a416d04. No new dependencies. The initial P8 fixture allowed the rounded consumer to equal its RHS. Before @@ -13,13 +13,29 @@ resolved by the specific `rhs_layout` name. A checker initially compared entire retained output capacity with logical input length; it now compares logical bodies and independently requires all retained work backing to be erased. -Executed so far: +Executed: - `python3.12 -I -B research/physical-boundary-rhs-caller/verify.py --write` - `python3.12 -B scripts/research_package.py --package research/physical-boundary-rhs-caller --check-only` -All three actual calls and final source/control checks passed. Registered -normal/optimized replay and committed export results are recorded in the next -reproducibility update. No hosted CI, production Gaussian preparation, full +- `python3.12 -B scripts/research_package.py --package research/physical-boundary-rhs-caller` passed the unchanged normal and optimized scientific commands. +- `python3.12 -I -O -B research/physical-boundary-rhs-caller/test_integrity.py` passed four actual CLI controls in10.59seconds: changed source, missing source, Boolean-valued width in the typed receipt, and missing receipt. Both receipt failures execute the real optimized program first. +- `python3.12 -B scripts/check_research_commit.py --package research/physical-boundary-rhs-caller --check-source-history` passed at2544813dbb32bea44d2df8eff8b18340bd3d209e. +- The official committed exporter and offline integrity checker passed with explicit `--input-ref 32890bc5de034ab8fc93ac88ead7279a6a416d04`; the first archive had30files and was about52MiB. All declared runtime source files come from that base. +- Actual Git-free extraction of that archive passed `python3.12 -I -O -B .../verify.py` in5.21seconds. No `.git`, network or installed third-party packages were available to its source loaders. + +The second commit adds the CLI controls and registers that same tested command; +the scientific implementation, proof, receipt and reviewed source hashes are +unchanged from the first commit. Final publication-head export/preflight are +read-only checks recorded with the handoff, not reasons to alter frozen receipts. + +A separate Codex agent reviewed the actual source/caller, proof, cost/backing, +reference and cleanup boundaries, and independently ran the optimized5-row +R2B2 case with all9layout controls. It reported no blocking findings after +canonical-head validation and partial-acquisition cleanup were fixed. This is +AI peer review, not independent human acceptance. Proof SHA256: +`d8a1bac7b6180110396b9c9257f4ea2e75df86d2c4563a70c3fef9d7880f548f`. + +All three actual calls and final source/control checks passed. No hosted CI, production Gaussian preparation, full Core second-pass integration, selected-frontier replay or formal proof kernel has run. No inherited numerical theorem is independently accepted by this note. diff --git a/research/physical-boundary-rhs-caller/VERIFY.json b/research/physical-boundary-rhs-caller/VERIFY.json index cac56fa0a2..8f18c717b6 100644 --- a/research/physical-boundary-rhs-caller/VERIFY.json +++ b/research/physical-boundary-rhs-caller/VERIFY.json @@ -44,6 +44,17 @@ ], "timeout_seconds": 60, "checks": "Actual first-pass pair, unchanged rounded block consumer, physical layout/return, independent oracle and corruption controls optimized" + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-B", + "{package}/test_integrity.py" + ], + "timeout_seconds": 60, + "checks": "Actual optimized CLI rejects changed/missing source and malformed/missing receipt in Git-free relocation" } ] } diff --git a/research/physical-boundary-rhs-caller/test_integrity.py b/research/physical-boundary-rhs-caller/test_integrity.py new file mode 100644 index 0000000000..b6cf6f5c0a --- /dev/null +++ b/research/physical-boundary-rhs-caller/test_integrity.py @@ -0,0 +1,57 @@ +"""Real optimized CLI rejection controls in a relocated Git-free input closure.""" +import json +from pathlib import Path +import shutil +import subprocess +import sys +import tempfile + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parent.parent +PACKAGE = Path('research/physical-boundary-rhs-caller') + + +def need(ok, message): + if not ok: + raise ValueError(message) + + +def main(): + with tempfile.TemporaryDirectory(prefix='rhs-integrity-') as directory: + root = Path(directory) + package = root / PACKAGE + package.mkdir(parents=True) + for path in HERE.iterdir(): + if path.is_file(): + shutil.copyfile(path, package / path.name) + manifest = json.loads((HERE / 'VERIFY.json').read_text()) + for name in manifest['inputs']: + target = root / name + target.parent.mkdir(parents=True, exist_ok=True) + shutil.copyfile(ROOT / name, target) + command = [sys.executable, '-I', '-O', '-B', str(package / 'verify.py')] + def rejects(fragment): + result = subprocess.run(command, cwd=root, text=True, capture_output=True, timeout=30) + need(result.returncode != 0 and fragment in result.stderr, 'actual optimized rejection: '+fragment) + source = root / 'research/physical-gaussian-core/gaussian_core.py' + original = source.read_bytes() + source.write_bytes(original + b'\n# changed bound source\n') + rejects('source bytes: research/physical-gaussian-core/gaussian_core.py') + source.unlink() + rejects('FileNotFoundError') + source.write_bytes(original) + receipt = package / 'RESULT.json' + original_receipt = receipt.read_bytes() + data = json.loads(original_receipt) + data['cases'][0]['width'] = True + receipt.write_text(json.dumps(data)) + rejects('typed receipt') + receipt.unlink() + rejects('FileNotFoundError') + receipt.write_bytes(original_receipt) + need(not (root / '.git').exists(), 'actual Git-free control relocation') + print('PASS_RHS_CLI_INTEGRITY_CONTROLS changed-source missing-source typed-receipt missing-receipt') + + +if __name__ == '__main__': + main()