From 0d720354a47457212b160492824f5116f9dde267 Mon Sep 17 00:00:00 2001 From: Ali Romman <226877337+aliromman@users.noreply.github.com> Date: Sat, 24 Oct 2026 15:13:41 -0500 Subject: [PATCH] Add source-bound feedback for original helper query bank --- .../COMPLETION-INVOICE.json | 23 + .../PORTABILITY.json | 23 + .../original-helper-query-feedback/PROOF.md | 146 ++++++ .../original-helper-query-feedback/README.md | 106 +++++ .../RESULT.json | 189 ++++++++ .../SOURCE-INVOICE.json | 23 + .../SOURCES.json | 72 +++ .../original-helper-query-feedback/TASK.json | 102 +++++ .../VALIDATION.md | 61 +++ .../VERIFY.json | 40 ++ .../original-helper-query-feedback/verify.py | 424 ++++++++++++++++++ 11 files changed, 1209 insertions(+) create mode 100644 research/original-helper-query-feedback/COMPLETION-INVOICE.json create mode 100644 research/original-helper-query-feedback/PORTABILITY.json create mode 100644 research/original-helper-query-feedback/PROOF.md create mode 100644 research/original-helper-query-feedback/README.md create mode 100644 research/original-helper-query-feedback/RESULT.json create mode 100644 research/original-helper-query-feedback/SOURCE-INVOICE.json create mode 100644 research/original-helper-query-feedback/SOURCES.json create mode 100644 research/original-helper-query-feedback/TASK.json create mode 100644 research/original-helper-query-feedback/VALIDATION.md create mode 100644 research/original-helper-query-feedback/VERIFY.json create mode 100644 research/original-helper-query-feedback/verify.py diff --git a/research/original-helper-query-feedback/COMPLETION-INVOICE.json b/research/original-helper-query-feedback/COMPLETION-INVOICE.json new file mode 100644 index 0000000000..c67e42f5da --- /dev/null +++ b/research/original-helper-query-feedback/COMPLETION-INVOICE.json @@ -0,0 +1,23 @@ +{ + "schema": "integer-mult-recursive-invoice/v1", + "contract": { + "model": "mixed-target-unnormalized-power-v1", + "rank_semantics": "H_r costs r^(1-C); every autonomous helper is counted once; common unchanged main outputs cancel", + "ambient_rank": 9, + "boundary": "One original forward FULL, before feedback: compare original helper returns with complete independent helper return decoding. Main endpoint and source ordinary operations are common." + }, + "paid": { + "1": 2207, + "2": 412, + "3": 510, + "4": 127, + "5": 66, + "8": 8 + }, + "targets": { + "4": 2, + "7": 7, + "8": 41, + "9": 358 + } +} diff --git a/research/original-helper-query-feedback/PORTABILITY.json b/research/original-helper-query-feedback/PORTABILITY.json new file mode 100644 index 0000000000..9edbfe9575 --- /dev/null +++ b/research/original-helper-query-feedback/PORTABILITY.json @@ -0,0 +1,23 @@ +{ + "status": "PASS_READ_ONLY_GIT_FREE_EXPORT", + "python": "Python 3.12.14", + "files": 18, + "all_hashes_unchanged": true, + "empty_path": true, + "checks": [ + { + "optimized": false, + "exit_code": 0, + "seconds": 5.203, + "stdout": "PASS_UNCODED_FORWARD_EARLY_QUERY_FEEDBACK {\"feedback_shears\": 5, \"original_inputs\": 632, \"owned_inputs\": 226, \"rejected_controls\": 7, \"replacement_cuts\": 112}", + "stderr": "" + }, + { + "optimized": true, + "exit_code": 0, + "seconds": 5.089, + "stdout": "PASS_UNCODED_FORWARD_EARLY_QUERY_FEEDBACK {\"feedback_shears\": 5, \"original_inputs\": 632, \"owned_inputs\": 226, \"rejected_controls\": 7, \"replacement_cuts\": 112}", + "stderr": "" + } + ] +} diff --git a/research/original-helper-query-feedback/PROOF.md b/research/original-helper-query-feedback/PROOF.md new file mode 100644 index 0000000000..064cf65f6d --- /dev/null +++ b/research/original-helper-query-feedback/PROOF.md @@ -0,0 +1,146 @@ +# Original-forward helper-query feedback + +## Source and input contract + +The source is the original forward native word with 632 arbitrary independent +persistent inputs: 112 x fields, 112 y fields and 408 helper fields. Its moving- +frame endpoint is `(x,y+x,h)`. Its eight center calls and owned temporary remain. +The verifier replays all source endpoint rows and checks that its 358 cold-helper +first departures equal the complete matrix T from PR5388. All 112 selected +first events, owners, frames and ranks agree with that bank. This comparison +uses the original word, not the center-free producer consumed by PR5388. + +Let xi be the independent cold-helper coordinates and let w=D_K xi. The +predecessor's in-place scalar program applies T inverse. Its original first +query at selected slot j has physical frame E_j and argument K_j xi_j. +The monomial words K_j and O_j satisfy + +```text +O_j E_j K_j = Q, K_j R = R K_j, +Q^2 = X_central, Q^4 = I. +``` + +Every displayed identity is checked with its signed Clifford tableau and exact +zero-state amplitudes. Q squared is an ordinary Pauli permutation. All scalar +coefficients remain outside tensor powers. The fixed native lift applies each +operator identity to the active axes and preserves arbitrary spectator data. +Thus the identities hold at every allowed positive fiber width under the +inherited native implementation and cost assumptions. + +The 112 adapted H1 children are relocated to an entrance prologue, before +T inverse. For each selected coordinate, copy w_j into a cleared raw field, +execute its actual adapted source child, copy that physical result into a +cleared observation field, and apply O_j to the observation. The source child +is relocated, not duplicated. The three live values are then + +```text +w_j = K_j xi_j +raw_j = E_j K_j xi_j +obs_j = Q xi_j. +``` + +## One exact feedback shear + +For h different from k, change `xi_k` to `xi_k+Q xi_h`. Keep the three live +representations consistent by these changes: + +```text +w_k += K_k obs_h +obs_k += Q^2 K_h^-1 w_h +raw_k += O_k^-1 Q^2 K_h^-1 w_h. +``` + +The first is K_k times the required argument increment. The second is Q times +that increment. For the third, the query identity gives + +```text +O_k^-1 Q^2 = E_k K_k Q. +``` + +Hence the raw increment is the actual query E_k applied to the new argument. +No new Gaussian query is needed: K_k, Q squared, K_h inverse and O_k inverse +are monomial maps. The verifier checks their Fourier rank, literal compilation, +signed tableaux and absolute phases. Merely changing w_k would leave the held +raw result and observation stale. + +Use one owned scratch field a for the following literal sequence: + +```text +CLEAR a; COPY a <- obs_h; apply K_k to a; ADD w_k += a; +CLEAR a; COPY a <- w_h; apply Q^2 K_h^-1 to a; ADD obs_k += a; +apply O_k^-1 to a; ADD raw_k += a; CLEAR a. +``` + +Chart changes on a come from the stated physical monomial maps. They are not +free nonzero retags. The source field h is unchanged during this shear because +h differs from k. Therefore the sequence preserves the three displayed +invariants and is an invertible elementary change on the xi coordinates. +Induction proves the same fact for any finite ordered sequence. It permits a +later shear to read or change a coordinate used by an earlier shear. + +## Resume the original source and return every field + +After all feedback, apply the unchanged T inverse program to w. At each of the +112 original query cuts, the persistent field is again w_j in chart zero. +Its stored raw field is E_j w_j. Replace that original child by a whole-field +swap, including its chart tag, then clear only the owned duplicate. This puts +the persistent field in exactly the physical state that the source child +would produce on the updated independent input. + +The first-departure rows have no main-input coefficient. Each prefix identity +holds on every helper column, so it remains true after this operator-valued +linear substitution. Induction through the replacement cuts proves the entire +original source endpoint on the changed inputs. Every other source operation, +including all eight centers and inherited phase/adapter records, is retained. +The source never reads the separately held observations. + +The source leaves each helper in its old physical output chart. Apply the +predecessor's 26 H5 and six H1 completion recipes to the non-full cold returns. +All 358 cold fields now have the same full-R chart. Apply the scalar program T +and the selected K inverses. The source proof gives the final cold outputs +`R S(Q) xi`, where S(Q) is the ordered feedback shear word. The other 50 helpers +retain their original jobs. The main source endpoint is unchanged. Clear all +owned observations after their last use; raw fields and scratch already hold +zero. No persistent input direction is erased. + +S(Q) is invertible, but it depends on Q. This proof does not supply an ordinary +inverse decoder for S(Q). Consequently it does not permit independent H9 target +credit on the original xi inputs. A completed caller must consume or remove +this code and prove its own targets. The copied observations add no independent +productive input or job. + +## Exact accounting and verification + +The original paid profile is `{1:2201,2:412,3:510,4:127,5:40,8:8}`. Relocation +and feedback preserve that profile. Return completion adds six H1 and 26 H5. +The final paid profile is `{1:2207,2:412,3:510,4:127,5:66,8:8}`. With no feedback, +the autonomous helper profile changes from `{4:28,7:7,8:47,9:326}` to +`{4:2,7:7,8:41,9:358}`. Before feedback this is a legitimate source-bound +completion comparison. Its signed difference is positive at every concave +hinge below rank nine and zero in rank mass. It is a strict cost increase +for 0= 632, 'No persistent erasure') + rows[slot], charts[slot] = {}, chart + ordinary['owned_clear'] += 1 + + def copy(dst, src): + need(dst >= 633 and not rows[dst], 'Owned COPY needs a cleared target') + rows[dst], charts[dst] = rows[src].copy(), charts[src] + ordinary['owned_copy'] += 1 + + for q in queries: + j, owner = q['query_index'], q['native_role'] + rows[owner] = act(rows[owner], KBASE+j) + rawslot, obs = raw_start+j, obs_start+j + clear(rawslot, 0) + copy(rawslot, owner) + event = source['programs']['forward'][q['source_event']] + need(event[0] == 'climb' and event[2:] == [owner,0,q['first_chart'],1], 'Exact relocated native H1') + charts[rawslot] = q['first_chart'] + paid[1] += 1 + clear(obs, q['first_chart']) + copy(obs, rawslot) + rows[obs] = act(core.identity(owner), QSYM) + charts[obs] = 0 + + def invariant(j): + q = queries[j] + w, r, o = rows[q['native_role']], rows[raw_start+j], rows[obs_start+j] + need(w == r, 'Held raw argument matches current helper coordinate') + need(o == act(w, QSYM, -(KBASE+j)), 'Observation matches current helper coordinate') + need(charts[raw_start+j] == q['first_chart'], 'Held raw physical chart') + + for index, (h, k) in enumerate(feedbacks): + for j in (h,k): + invariant(j) + wh, wk = queries[h]['native_role'], queries[k]['native_role'] + if not (mutation == "dirty_scratch" and index == 0): + clear(scratch, 0) + copy(scratch, obs_start+h) + rows[scratch] = act(rows[scratch], KBASE+k) + ordinary['monomial_map'] += 1 + core.add(rows[wk], rows[scratch], F(1)) + ordinary['scalar_add'] += 1 + clear(scratch, 0) + copy(scratch, wh) + symbols = (QSYM, -(KBASE+h)) if mutation == "one_Q" and index == 0 else (QSYM, QSYM, -(KBASE+h)) + rows[scratch] = act(rows[scratch], *symbols) + ordinary['monomial_map'] += 1 + if not (mutation == "stale_observation" and index == 0): + core.add(rows[obs_start+k], rows[scratch], F(1)) + ordinary['scalar_add'] += 1 + # The exact physical identity above changes the declared chart here. + rows[scratch] = act(rows[wh], KBASE+k, QSYM, -(KBASE+h)) + charts[scratch] = queries[k]['first_chart'] + ordinary['monomial_map'] += 1 + if not (mutation == "stale_raw" and index == 0): + core.add(rows[raw_start+k], rows[scratch], F(1)) + ordinary['scalar_add'] += 1 + if not (mutation == "live_scratch" and index == len(feedbacks) - 1): + clear(scratch, 0) + for j in (h,k): + invariant(j) + + for q in queries: + actual = act(rows[q['native_role']], -(KBASE+q['query_index'])) + need(actual == expected_helpers[q['native_role']], 'Independent elementary feedback endpoint') + desired = [row.copy() for row in rows[:632]] + scalar_program(bank['entrance_scalar_program'], rows, owners) + entered = [row.copy() for row in rows[:632]] + by_event = {q['source_event']:q for q in queries} + cuts = 0 + for event_index, e in enumerate(source['programs']['forward']): + if event_index in by_event: + q = by_event[event_index] + owner, rawslot = q['native_role'], raw_start+q['query_index'] + need(charts[owner] == 0 and charts[rawslot] == q['first_chart'], 'Replacement charts') + need(rows[owner] == rows[rawslot], 'Replacement row on all original and owned inputs') + rows[owner], rows[rawslot] = rows[rawslot], rows[owner] + if not (mutation == 'chart_swap' and cuts == 0): + charts[owner], charts[rawslot] = charts[rawslot], charts[owner] + need(charts[owner] == q['first_chart'] and charts[rawslot] == 0, 'Replacement chart transport') + ordinary['physical_field_swap'] += 1 + clear(rawslot, 0) + cuts += 1 + continue + kind = e[0] + if kind == 'scalar': + gate, chart = e[1:] + dst = gate[1][1]+(632 if gate[1][0] == 'C' else 0) + if gate[0] == 'clear': + need(dst == 632, 'Native persistent erasure') + rows[dst], charts[dst] = {}, chart + continue + need(charts[dst] == chart, 'Native scalar destination chart') + if gate[0] in ('copy','add'): + src = gate[2][1]+(632 if gate[2][0] == 'C' else 0) + need(charts[src] == chart, 'Native scalar source chart') + if gate[0] == 'copy': + need(dst == 632, 'Native persistent overwrite') + rows[dst] = rows[src].copy() + else: + core.add(rows[dst], rows[src], F(gate[3],gate[4])) + else: + need(gate[0] == 'scale', 'Known native scalar') + rows[dst] = {key:F(gate[2],gate[3])*v for key,v in rows[dst].items()} + elif kind == 'warp': + _, ref, op, before, after = e + owner = ref[1]+(632 if ref[0] == 'C' else 0) + need(charts[owner] == before, 'Native warp chart') + rows[owner], charts[owner] = core.warp(rows[owner], op, False), after + elif kind in ('climb','center'): + if kind == 'climb': + _,_,owner,before,after,rank = e + need(rank == len(c['frames'][after])-len(c['frames'][before]), 'Native climb rank') + else: + _,index,before,after,rank = e + owner = 632+index + need(rank == abs(len(c['frames'][after])-len(c['frames'][before])), 'Native center rank') + need(charts[owner] == before, 'Native paid chart') + charts[owner] = after + paid[rank] += 1 + else: + need(kind in ('phase','adapter','residual_adapter'), 'Known native marker') + for owner in range(632): + expected = entered[owner].copy() + if 112 <= owner < 224: + core.add(expected, entered[owner-112], F(1)) + need(rows[owner] == expected, 'Complete original FULL endpoint on transformed helper inputs') + need(charts[:632] == c['final'], 'Original final charts') + need(paid == Counter(PROFILE), 'All original Gaussian children, including eight centers') + for index, completion in enumerate(bank['cold_completions']): + if mutation == 'missing_completion' and index == 0: + continue + charts[completion['native_role']] = 1 + paid[completion['charged_child_rank']] += 1 + need(all(charts[owner] == 1 for owner in owners), 'Common return chart before scalar decoding') + scalar_program(bank['exit_scalar_program'], rows, owners) + for q in queries: + owner, j = q['native_role'], q['query_index'] + rows[owner] = act(rows[owner], -(KBASE+j)) + desired[owner] = act(desired[owner], -(KBASE+j)) + for owner in owners: + need(rows[owner] == desired[owner] == expected_helpers[owner], 'Returned transformed helper after completion and decode') + for q in queries: + j = q['query_index'] + need(rows[obs_start+j] == act(desired[q['native_role']], QSYM), 'Retained normalized feedback observation') + clear(obs_start+j, 0) + need(all(not row for row in rows[632:]), 'Every arbitrary owned input removed and every owned output cleared') + n = len(feedbacks) + need(ordinary == Counter(owned_clear=448+3*n, owned_copy=224+2*n, + physical_field_swap=112, scalar_add=3*n, monomial_map=3*n), 'Complete added ordinary invoice') + return dict(status='PASS_UNCODED_FORWARD_EARLY_QUERY_FEEDBACK', + source_payload_sha256=PIN, + original_inputs=632, arbitrary_owned_inputs=owned, replacement_cuts=cuts, + feedbacks=feedbacks, completed_paid=dict(sorted(paid.items())), + helper_output_ranks_on_transformed_coordinates={4:2,7:7,8:41,9:358}, + ordinary=ordinary, all_owned_outputs_zero=True, + source_scope='Original forward FULL, all eight centers retained.', + target_scope='Helpers return on the transformed independent coordinates. A closed caller must prove its target.', + fixed_basis_adds=6420, fixed_basis_scales=408, + fixed_monomial_maps_at_most=400, additional_owned_fields=224 + bool(feedbacks), + limitation='Forward interface only. No caller closure, complete precision tariff, or kappa improvement is claimed.') + + +def produce(): + raw = gzip.decompress(SOURCE.read_bytes()) + need(sha256(raw).hexdigest() == PIN, 'Pinned native payload') + source = json.loads(raw) + bank = json.loads((ROOT / 'research/native-helper-query-bank/BANK.json').read_text()) + first = original_departures(source, bank) + physics = check_physics(source, bank) + feedbacks = [(0,1), (1,0), (1,2), (2,111), (111,0)] + result = run(source, bank, feedbacks) + result['first_departure_rows_checked'] = first + result['physical_checks'] = physics + result['empty_sequence_control'] = run(source, bank, [])['ordinary'] + controls = [] + for mutation, expected in [ + ('stale_raw', 'Held raw argument matches current helper coordinate'), + ('stale_observation', 'Observation matches current helper coordinate'), + ('one_Q', 'Observation matches current helper coordinate'), + ('chart_swap', 'Replacement chart transport'), + ('dirty_scratch', 'Owned COPY needs a cleared target'), + ('live_scratch', 'Every arbitrary owned input removed and every owned output cleared'), + ('missing_completion', 'Common return chart before scalar decoding'), + ]: + try: + run(source, bank, feedbacks, mutation) + except ValueError as exc: + need(str(exc) == expected, 'Wrong mutation rejection: ' + mutation + ': ' + str(exc)) + controls.append({'mutation': mutation, 'result': 'REJECT', 'reason': str(exc)}) + else: + raise ValueError('Mutation passed: ' + mutation) + result['rejected_controls'] = controls + comparator = module('feedback_invoice', ROOT / 'scripts/compare_recursive_invoices.py') + old = json.loads((HERE / 'SOURCE-INVOICE.json').read_text()) + new = json.loads((HERE / 'COMPLETION-INVOICE.json').read_text()) + old_helpers = Counter(len(source['canonical']['frames'][source['canonical']['final'][j]]) - + len(source['canonical']['frames'][source['canonical']['start'][j]]) + for j in range(224, 632)) + need({int(r): n for r, n in old['paid'].items()} == PROFILE, 'Source invoice paid profile') + need({int(r): n for r, n in old['targets'].items()} == old_helpers, 'Source invoice helper profile') + need({int(r): n for r, n in new['paid'].items()} == result['completed_paid'], 'Completion invoice paid profile') + need({int(r): n for r, n in new['targets'].items()} == result['helper_output_ranks_on_transformed_coordinates'], + 'Completion invoice helper profile before feedback') + comparison = comparator.compare_invoices(old, new) + need(comparison['classification'] == 'uniformly_worse', 'Completion is a strict concave-moment loss') + need(comparison['rank_mass']['delta']['paid'] == comparison['rank_mass']['delta']['targets'] == 136, + 'Completion paid and target rank-mass change') + result['completion_invoice_preflight'] = comparison + return result + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--emit', action='store_true', help='Write the result for package authors.') + args = parser.parse_args() + result = produce() + payload = json.dumps(result, sort_keys=True, indent=2) + '\n' + path = HERE / 'RESULT.json' + if args.emit: + path.write_text(payload) + else: + expected = json.dumps(json.loads(path.read_text()), sort_keys=True, indent=2) + '\n' + need(payload == expected, 'Saved typed mathematical receipt differs') + print(result['status'], json.dumps({'original_inputs': result['original_inputs'], + 'owned_inputs': result['arbitrary_owned_inputs'], 'replacement_cuts': result['replacement_cuts'], + 'feedback_shears': len(result['feedbacks']), 'rejected_controls': len(result['rejected_controls'])}, sort_keys=True)) + + +if __name__ == '__main__': + main()