Repository navigation
Construct restored compensation forests for the staged words - #4197
Open
RossRichardson wants to merge 1 commit into
Open
RossRichardson wants to merge 1 commit into
RossRichardson wants to merge 1 commit into
Conversation
Contributor
|
Independent scoped audit of staged compensation forests at Code-disjoint reimplementation over pinned receipts; does not import package What passes (31 of 31):
Not covered: two-sided matching optimality (package claims none); physical Clifford / tape admission; κ. This is a finite replay of committed receipts, not a formal proof. check_4197.py#!/usr/bin/env python3
"""Independent finite controls for PR4197 (staged compensation forests).
Recomputes ADD bills, primitive prices, forest census, and two-orientation
saving arithmetic from pinned WHOLE-WORD / artifact receipts. Does not import
package verify.py / construct.py / controls.py / independent_mst.py.
James Reed (@rcfc-jreed), with substantial AI assistance (Claude, in Cursor).
Apache-2.0.
"""
import argparse, gzip, hashlib, json, subprocess, sys
from collections import Counter
HEAD = 'acb22886813c73a95ce5eb4b67805defb687b879'
BASE = '12fa8c5c844be21bfefb38a19503fbd867a11244'
PKG = 'research/staged-compensation-forests/'
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 show(repo, path, rev=HEAD):
return subprocess.run(['git', '-C', repo, 'show', f'{rev}:{path}'],
capture_output=True, check=True).stdout
def js(b):
if b[:2] == b'\x1f\x8b':
b = gzip.decompress(b)
return json.loads(b)
def load(repo):
g = lambda p: show(repo, PKG + p)
return dict(
sources=js(g('SOURCES.json')),
core=js(g('CORE-SNAPSHOT.json')),
controls=js(g('CONTROLS.json')),
frozen=js(g('FROZEN-SHA256.json')),
prior=js(g('PRIOR-CHECK.json')),
mst=js(g('MST-VALIDATION.json')),
whole=js(g('artifacts/WHOLE-WORD.json.gz')),
independent=js(g('artifacts/INDEPENDENT-FOREST.json.gz')),
source_base=js(g('artifacts/SOURCE-base.json.gz')),
forest_word=js(g('artifacts/FOREST-WORD-base.json.gz')),
twosided_word=js(g('artifacts/TWO-SIDED-WORD-base.json.gz')),
forest_comp=js(g('artifacts/FOREST-COMPENSATION-base.json.gz')),
twosided_comp=js(g('artifacts/TWO-SIDED-COMPENSATION-base.json.gz')),
historical_comp=js(g('artifacts/HISTORICAL-SHARED-COMPENSATION.json.gz')),
)
def run(d, repo):
w, ind = d['whole'], d['independent']
check('I1 SOURCES base pin is canonical main', d['sources']['base_commit'] == BASE)
check('I2 CORE status PASS_C01_REVIEWED_CORE', d['core']['status'] == 'PASS_C01_REVIEWED_CORE')
check('I3 CONTROLS status PASS_C01_…; no_new_kappa',
d['controls']['status'] == 'PASS_C01_COMPACT_SOURCE_AND_MATHEMATICAL_GATES'
and d['controls']['no_new_kappa'] is True)
check('I4 WHOLE-WORD status PASS_EXACT_FINITE_WORD_AND_SCALAR_PREFIX',
w['status'] == 'PASS_EXACT_FINITE_WORD_AND_SCALAR_PREFIX')
check('I5 INDEPENDENT-FOREST status PASS_INDEPENDENT_FRACTION_FOREST_AND_BASES',
ind['status'] == 'PASS_INDEPENDENT_FRACTION_FOREST_AND_BASES')
check('I6 MST-VALIDATION normal/optimized receipts identical',
d['mst']['status'] == 'PASS_OPTIMIZED_SPACED_SCRIPT_COMPLETE_RECEIPT_EQUALITY'
and d['mst']['normal_and_optimized_receipt_bytes_identical'] is True)
check('I7 FROZEN-SHA256 matches HEAD for TWO-SIDED-COMPENSATION-base',
d['frozen']['artifacts/TWO-SIDED-COMPENSATION-base.json.gz']
== hashlib.sha256(show(repo, PKG + 'artifacts/TWO-SIDED-COMPENSATION-base.json.gz')).hexdigest())
check('I8 WHOLE-WORD scope declares no new kappa',
'new kappa' in str(w['scope'].get('not_established', [])).lower()
or 'new kappa' in json.dumps(w['scope']).lower())
# --- ADD bills ---
for provider in ('base', 'extra'):
bill = w['providers'][provider]['panel']['bill']
check(f'B1 {provider} source 5736 → candidate 2288 ADDs',
bill['source']['additions'] == 5736
and bill['candidate']['additions'] == 2288)
check(f'B2 {provider} prices 31214 → 10633; Δ×2 orientations = 41162',
bill['source']['price_per_real_component'] == 31214
and bill['candidate']['price_per_real_component'] == 10633
and (31214 - 10633) * 2 == 41162)
parts = (bill['target_prepare']['additions'] + bill['target_restore']['additions']
+ bill['helper_prepare']['additions'] + bill['helper_restore']['additions']
+ bill['residual']['additions'])
check(f'B3 {provider} candidate bill parts sum to 2288 (95+95+88+88+1922)',
parts == 2288
and bill['target_prepare']['additions'] == 95
and bill['helper_prepare']['additions'] == 88
and bill['residual']['additions'] == 1922)
check(f'B4 {provider} all helpers enter zero frame and exit FULL',
w['providers'][provider]['panel']['all_helpers_enter_zero_frame_and_exit_full'] is True)
check('B5 artifact compensation lengths: source 5736, forest 2834, two-sided 2288, historical 3214',
len(d['source_base']['compensation']) == 5736
and len(d['forest_word']['compensation']) == 2834
and len(d['twosided_word']['compensation']) == 2288
and len(d['forest_comp']) == 2834
and len(d['twosided_comp']) == 2288
and len(d['historical_comp']) == 3214)
check('B6 two-sided and forest compensation lists are all ADD ops',
all(x[0] == 'add' for x in d['twosided_comp'])
and all(x[0] == 'add' for x in d['forest_comp']))
check('B7 historical_rank_basis_panel additions 3214 on both providers',
w['providers']['base']['historical_rank_basis_panel']['additions'] == 3214
and w['providers']['extra']['historical_rank_basis_panel']['additions'] == 3214)
# --- Forest census ---
g = ind['common']['graph']
check('F1 target forest: 17 roots, 95 target edges',
g['roots'] == 17 and g['target_edges'] == 95)
check('F2 independent Prim price 13716 matches README target-forest column',
g['independent_heap_Prim_price'] == 13716)
check('F3 edge census 12544 (=112 choose-2 * 2?); all cycle inequalities checked',
g['edge_count'] == 12544 == g['all_cycle_inequalities_checked'])
check('F4 PRIOR-CHECK current_active_columns == 207',
d['prior']['current_active_columns'] == 207)
# Live inputs / buffers
for provider in ('base', 'extra'):
check(f'L1 {provider} live_registers 632 in independent providers',
ind['providers'][provider]['live_registers'] == 632)
# Paid recursive profile preserved (spot-check generated forward paid_profile equal base/extra)
pf_b = w['providers']['base']['generated']['candidate']['producer_checks']['forward']['paid_profile']
pf_e = w['providers']['extra']['generated']['candidate']['producer_checks']['forward']['paid_profile']
check('P1 base/extra candidate paid_profile identical (recursive profile retained)',
pf_b == pf_e)
check('P2 candidate paid_profile matches generated forward bound structure',
pf_b == {'1': 2439, '2': 726, '3': 224, '4': 102, '5': 20, '8': 8})
# --- Negative controls ---
check('NEG1 claiming save 41162 from single orientation undercounts (20581×1)',
31214 - 10633 != 41162)
check('NEG2 forest-only 2834 is not the final two-sided 2288',
2834 != 2288)
check('NEG3 residual 1922 without prep/restore would not reach 2288',
1922 != 2288)
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('--repo', required=True)
args = ap.parse_args()
head = subprocess.run(['git', '-C', args.repo, 'rev-parse', 'HEAD'],
capture_output=True, text=True, check=True).stdout.strip()
check('HEAD is PR4197 tip acb22886…', head == HEAD, head)
return run(load(args.repo), args.repo)
if __name__ == '__main__':
sys.exit(main())James Reed (@rcfc-jreed), with substantial AI assistance (Claude, in Cursor). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace the frame-zero compensation in the two pinned staged 644/660 words with an explicitly restored target forest and 88 disjoint helper pairs. The local circuit drops from 5,736 to 2,288 additions, with a fully charged saving of 41,162 real-component scalar primitives per orientation. The same-matrix target-only forest is proved minimal within the signed-unit single-parent forest class; the two-sided circuit is one deterministic greedy construction.
Scope and limits
This is one finite compensation substitution. It preserves the complete paid recursive profile and makes no improved kappa claim. Arbitrary dirty targets and helpers, literal inverses and duals, all full-word scalar operations, and every preparation/restoration are included. The backward exact coefficient row sum worsens from 169 to 181 and the conservative bit envelope from 95 to 97. Native phase interpretation, physical zero erasure, rounding, owner allocation and all-size supplier admission remain open. No global or helper-matching optimum is claimed. Historical C01 factory screens are preserved only as provenance.
Test plan
CPython 3.12 standard-library registered replay, independent all-edge MST/helper-score and arbitrary-input operator checks, independent whole-word/free-warp and emitted scalar projection checks, and actual acceptance controls. The final committed package passed its source-history/byte preflight and all four registered commands. All four commands also pass from the read-only Git-free committed export. Automatic registered-package CI passed at exact head
acb22886813c73a95ce5eb4b67805defb687b879.Sources and credit
Scientific source: PR #3605 at
3efbb5de06a49ffeea6684482f2d3fe48cdca3fb; exact retained-main byte aliases are documented for the source-history gate. Prior signed-forest and two-sided methods, including PR #1080 at803e080e181229a3af2196b7a13615c9d81ae10d, are credited and compared on their actual distinct matrices. Related-work, inherited source notices and the full source manifest are included. Prepared by Ross Richardson with substantial OpenAI Codex assistance; separate AI mathematical reviews are not independent human review or formal-kernel evidence.