From 0a6f487ddff27cde0369e225f9ccb328ca2d8043 Mon Sep 17 00:00:00 2001 From: Cinna Davis <1337isnot1337@users.noreply.github.com> Date: Wed, 14 Oct 2026 18:22:44 -0500 Subject: [PATCH] Add QQ16 private d_A frame floor --- .../README.md | 91 +++++++++ .../RESULT.json | 87 ++++++++ .../SOURCES.json | 73 +++++++ .../TASK.json | 124 ++++++++++++ .../VERIFY.json | 37 ++++ .../test_package.py | 48 +++++ .../verify.py | 190 ++++++++++++++++++ 7 files changed, 650 insertions(+) create mode 100644 research/qq16-private-da-frame-floor-seed81b017/README.md create mode 100644 research/qq16-private-da-frame-floor-seed81b017/RESULT.json create mode 100644 research/qq16-private-da-frame-floor-seed81b017/SOURCES.json create mode 100644 research/qq16-private-da-frame-floor-seed81b017/TASK.json create mode 100644 research/qq16-private-da-frame-floor-seed81b017/VERIFY.json create mode 100644 research/qq16-private-da-frame-floor-seed81b017/test_package.py create mode 100644 research/qq16-private-da-frame-floor-seed81b017/verify.py diff --git a/research/qq16-private-da-frame-floor-seed81b017/README.md b/research/qq16-private-da-frame-floor-seed81b017/README.md new file mode 100644 index 0000000000..9ac44dcd2b --- /dev/null +++ b/research/qq16-private-da-frame-floor-seed81b017/README.md @@ -0,0 +1,91 @@ +# QQ16 private-register retention frame floor + +This package tests one proposed way to realize the post-`B_1_2` observation +`d_A = Y_A` used by the conditional two-query kernel in PR #2174: copy its eight +A-port coordinates into the existing owned private fields `C0..C7` and expose +them at that cut. + +The exact pinned `B_1_2` word ends with the retained backward stage-one core. +That core returns all eight owned fields in frame I. At the same cut, the eight +`Y_A` data fields have frames +`f117, f124, f137, f144, f153, f163, f174, f228`. Each is the stage-one +completed frame (the first 17 basis terms) minus its actual A-port label, so +each differs from I in exactly 18 one-term Z4 entries. A matching-phase scalar +ADD from `Y_A` into `C_i` is therefore not legal as written. + +The bounded normalization check enumerates all 3,650 registered cover maps +for a one-map conversion of any of those eight frames to I. There are no such +maps. In the deliberately favorable native line model, one rank-one line can +change only one frame term. Aligning the eight private fields to their source +frames therefore needs at least 8 × 18 = 144 line calls. The existing wrapper +contract associates two full-cover maps with each added line call, giving 288 +cover-map operations. Eight coefficient-one scalar copies cost 32 real scalar +primitives under the pinned scalar allowance. If the cut is terminal, eight +private clears add another eight scalar primitives; if the existing next core +is invoked, its clear events can perform that cleanup and the extra clear +charge is zero. + +This is already over the generous budget comparison recorded in the active +pre-F0 `B2 X_U` claim, Discussion #2074: its rank-eight output envelope leaves +at most two additional rank-one-equivalent calls above the selected ceiling. +The 144-call phase floor exceeds that slack before charging observation +handling, any multi-map route, physical address/stream costs, global hosting, +or recursive precision. This comparison is a planning screen against that +live claim, not an independently reviewed frontier theorem. The local exact +result does not rule out multi-map normalization, a different state layout, +or another controller; it rules out the cheap one-map / one-term-line private +bank relay tested here as a favorable repair. + +## Reproduction + +From the repository root: + +```sh +python3 -I -B research/qq16-private-da-frame-floor-seed81b017/verify.py +python3 -I -O -B research/qq16-private-da-frame-floor-seed81b017/test_package.py +python3 -B scripts/research_package.py --package research/qq16-private-da-frame-floor-seed81b017 --check-only +``` + +Expected verifier output: + +```text +PASS_QQ16_PRIVATE_DA_FRAME_FLOOR ports=8 frame_terms=18 single_map_hits=0 rank1_line_floor=144 cover_maps=288 scalar_add=32 no_kappa +``` + +The verifier pins the main-branch source certificate and checks the exact +program endpoint, the final clear of every `C` field, all eight frame IDs, +every registered single-map action, and the termwise line lower bound. Its +positive controls include the identity map and a one-term line cancellation; +its negative controls include wrong-stage and wrong-port frames and a mutated +source certificate. Exact Z4 arithmetic is used throughout. The 144-line +figure grants the new mechanism arbitrary legal one-term line operations on +all private fields, even though the retained wrapper currently exposes a +native-line path only for C0; it is therefore a favorable lower bound in this +restricted model. + +The package does not implement a new full controller, prove that every +multi-map route is expensive, or change the selected bound. PR #1969 supplies +the retained QQ16 words and native wrapper conventions. PR #2174 supplies the +conditional decoder whose `d_A` observation motivates this experiment. This +work was produced with substantial OpenAI Codex assistance; it has no +independent human review. + +The scoped claim is [Discussion #2192](https://github.com/CrocSwap/integer-mult-bounds/discussions/2192). +Its entry overlap refresh at 2026-10-14 23:05 UTC completed pagination over +435 open PRs and 877 Discussions with no warnings and no exact-scope match. +The pre-submission refresh at 23:21 UTC completed pagination over 439 open PRs +and 882 Discussions, also with no warnings or matches. At that check, PR #2174 +remained open at `f79470a7931f3943360c10d15b428e0e4e479c22`, and Discussion #2074 +remained open as the separate `B2 X_U` observation claim. + +## Open next questions + +- Can a bounded two-map or three-map route normalize the eight output frames + while preserving the selected values, and does its complete charged profile + stay within the same favorable envelope? A next attempt should search the + exact pinned map action graph to depth three and stop on first discovery or + exhaustive frontier completion. It is blocked here because the scoped + experiment only tested one-map normalization and one-term line conversion. +- Can another state layout expose `d_A` without using a private field in frame + I? This would change the mechanism, so it needs a new exact interface and a + fresh full-cost screen. diff --git a/research/qq16-private-da-frame-floor-seed81b017/RESULT.json b/research/qq16-private-da-frame-floor-seed81b017/RESULT.json new file mode 100644 index 0000000000..70d9fde4c1 --- /dev/null +++ b/research/qq16-private-da-frame-floor-seed81b017/RESULT.json @@ -0,0 +1,87 @@ +{ + "a_ports": [ + { + "frame": "f117", + "port": 0, + "single_map_hits": [], + "terms": 18, + "unit_line_distance": 18 + }, + { + "frame": "f124", + "port": 7, + "single_map_hits": [], + "terms": 18, + "unit_line_distance": 18 + }, + { + "frame": "f137", + "port": 20, + "single_map_hits": [], + "terms": 18, + "unit_line_distance": 18 + }, + { + "frame": "f144", + "port": 27, + "single_map_hits": [], + "terms": 18, + "unit_line_distance": 18 + }, + { + "frame": "f153", + "port": 36, + "single_map_hits": [], + "terms": 18, + "unit_line_distance": 18 + }, + { + "frame": "f163", + "port": 46, + "single_map_hits": [], + "terms": 18, + "unit_line_distance": 18 + }, + { + "frame": "f174", + "port": 57, + "single_map_hits": [], + "terms": 18, + "unit_line_distance": 18 + }, + { + "frame": "f228", + "port": 111, + "single_map_hits": [], + "terms": 18, + "unit_line_distance": 18 + } + ], + "certificate_sha256_compressed": "a5ed85fac5ebf3c091482a113ab0d351eb5a7892fe2841a35e16017ec1ff49f7", + "comparison": "144 rank-one line calls exceed the two-call favorable slack before global hosting or address costs", + "controls": [ + "identity map", + "single-term line cancellation", + "wrong stage rejected", + "wrong port rejected", + "mutated source certificate rejected" + ], + "copy_add_real_primitive_bound": 32, + "copy_adds": 8, + "cover_maps_at_two_per_line": 288, + "favorable_extra_rank_one_credit_from_discussion_2074": 2, + "next_core_cleanup_extra_charge": 0, + "no_kappa": true, + "observation_coordinates": 8, + "private_frame": "f0", + "rank_one_line_calls_lower_bound": 144, + "registered_maps_checked": 3650, + "scope": "Eight A ports at B_1_2; all registered one-map normalizers and the one-term native-line conversion model only.", + "single_map_hits": 0, + "source_base": "0fdd7d82de03e43c9e5a1000dfbcd380d1b687d2", + "status": "PASS_QQ16_PRIVATE_DA_FRAME_FLOOR", + "terminal_cleanup_clear_macros": 8, + "terminal_cleanup_real_primitive_bound": 8, + "test_package_sha256": "e607bd03cf87101f5105b73bad1c2fc9a2ebe1de444e7e8aecce534e2d327e58", + "verify_py_sha256": "c041c1c46c5b007ec21061c605014265e175d9d42fea0d0d11dba5860355af90" +} diff --git a/research/qq16-private-da-frame-floor-seed81b017/SOURCES.json b/research/qq16-private-da-frame-floor-seed81b017/SOURCES.json new file mode 100644 index 0000000000..ade91471ca --- /dev/null +++ b/research/qq16-private-da-frame-floor-seed81b017/SOURCES.json @@ -0,0 +1,73 @@ +{ + "base_commit": "0fdd7d82de03e43c9e5a1000dfbcd380d1b687d2", + "files": [ + { + "git_blob": "ae6a99f28aa468649eb66a361e764d769363bf11", + "path": "certificates/selected-result.json", + "sha256": "10b9e340fd8e354a37a0c4813c90e5de1dd42044b5f6aca4a3fc5a42b685fa32", + "usage": "provenance" + }, + { + "git_blob": "e8870e5917057d59b730eb14721a778639eca050", + "path": "docs/research/agent-task-catalog.json", + "sha256": "d46eb6d5b3e279428753d770653663fbdf1063e55c255ea073d768f344927ef7", + "usage": "provenance" + }, + { + "git_blob": "c6e876d8b48d768214deee265ade428f8983b566", + "path": "research/joint-query/certificate.json.gz", + "sha256": "a5ed85fac5ebf3c091482a113ab0d351eb5a7892fe2841a35e16017ec1ff49f7", + "usage": "input" + }, + { + "git_blob": "2bf4fc0aa252c01242278cb58befc350acf7c85f", + "path": "research/joint-query/README.md", + "sha256": "419f076e46f5a6ce43efe30a608baed0a535034c388e1ac76a29a2026685ba77", + "usage": "input" + }, + { + "git_blob": "525b38dbdefed0e8192a9c5165e802136cc05034", + "path": "research/joint-query/evidence/NATIVE-REVIEW.md", + "sha256": "2247e3cbe73f3f0da55c647ffae15f98dd9445b2366ba9e255b9bebc9f742b70", + "usage": "input" + }, + { + "git_blob": "7a155a27dcf7f1ccd48e40d57a2c5d2724016e9b", + "path": "research/joint-query/evidence/CONSERVED-QQ16.json", + "sha256": "b91eb8599c403db55c889bb225a1cd93f46fdb83eb339f101d18843d52b1c920", + "usage": "input" + }, + { + "git_blob": "ede9e7e42744dd0c96790516a9acdfe07d180018", + "path": "research/joint-query/verify_native.py", + "sha256": "1c58e7b6e8e1cde4df455c2129601c145ed763fc63a3ab427eb1058d1fc08bd2", + "usage": "input" + }, + { + "git_blob": "7a7051fa8a70f48589fa1fccd5c38fccb5eacbf7", + "path": "research/joint-query/verify_scalar.py", + "sha256": "33bdbad17a0531fe527aff306eb235d9c38c1629db4fd167b989725930b0327a", + "usage": "input" + } + ], + "predecessors": [ + { + "author": "Ali Romman", + "integrated_commit": "a6e6ad3936f67b8f63b5b68c5e75d540610a65e7", + "pr": 1969, + "use": "Retained QQ16 local words, private field contract, and two-map wrapper convention." + }, + { + "author": "@commdata2338", + "head": "f79470a7931f3943360c10d15b428e0e4e479c22", + "pr": 2174, + "use": "Conditional two-query decoder; its open question asks whether an actual controller realizes d_A at the B1 cut. Not imported as executable evidence." + }, + { + "discussion": 2074, + "url": "https://github.com/CrocSwap/integer-mult-bounds/discussions/2074", + "use": "Different pre-F0 B2 X_U query; its current favorable rank-eight envelope is used only as a planning comparator." + } + ], + "schema_version": 1 +} diff --git a/research/qq16-private-da-frame-floor-seed81b017/TASK.json b/research/qq16-private-da-frame-floor-seed81b017/TASK.json new file mode 100644 index 0000000000..bab06c26bc --- /dev/null +++ b/research/qq16-private-da-frame-floor-seed81b017/TASK.json @@ -0,0 +1,124 @@ +{ + "actual_scope": "At the exact post-B_1_2 backward stage-one QQ16 cut, test whether existing owned C0..C7 fields in frame I can cheaply retain the eight Y_A coordinates used as d_A by a two-query decoder. Search all 3,650 registered single cover maps for one-step phase normalization, then derive the exact lower bound in the one-term native-line conversion model.", + "ai_assistance": "Substantial OpenAI Codex assistance in the mathematical reduction, exact checker, and writing. No independent human review is claimed.", + "author": "OpenAI Codex (GPT-6)", + "base_commit": "0fdd7d82de03e43c9e5a1000dfbcd380d1b687d2", + "bottleneck_link": "The conditional QQ16 two-query kernel already uses d_A at the B1 cut, but an actual controller must realize that record. This tests whether the existing private bank can carry it without a new field or an unaffordable phase conversion.", + "budget_minutes": 60, + "catalogue_sha256": "d46eb6d5b3e279428753d770653663fbdf1063e55c255ea073d768f344927ef7", + "claim_discussion": 2192, + "evidence": "README.md, verify.py, test_package.py, and RESULT.json. Exact frame IDs, 3,650-map census, 144-line floor, 288 wrapper map operations, eight ADDs costing 32 real scalar primitives, and endpoint cleanup cases are recorded.", + "open_questions": [ + { + "blocked_by": "This cycle stopped after the scoped one-map census and line-distance floor; no composed-map graph was explored.", + "first_step": "Search the exact pinned map action graph by depth 2, then depth 3 only if the fully charged rank-eight plus map budget remains favorable.", + "question": "Can a two-map or three-map normalization route carry d_A through this cut within the same favorable budget?", + "why_it_matters": "The present result only rejects a one-map shortcut and the single-term native-line fallback. A shorter multi-map route would change the paid interface cost." + } + ], + "original_card": { + "acceptance_gate": "Name the changed premise of the fixed F0/B1 observation obstruction. Show exactly which query is recovered, legal native reads and restoration, and a full favorable budget including cover maps, helpers and endpoints. Local inverse identities alone do not close the global controller.", + "allowed_variations": [ + "One paid query, one changed first pair, or one precisely specified affine helper state.", + "A counterexample or lower bound for that exact proposed repair." + ], + "bottleneck_link": "The native local words exist; retained query information and its physical access are the missing link to a composed recursive interface.", + "first_experiment": "Apply the existing witness to one proposed extra observation or changed first pair. If it still loses the required record, stop. Otherwise derive one ordered two-call identity and charge the added read, chart maps and restoration before extending to more stages.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read the fixed-first-pair QQ16 witness before designing a controller. The checked #1969 local words do not evade that witness or supply global placement.", + "scope": "Source-bound orientation only. Read the named package and review before relying on its local evidence; this command is not its replay or supplier admission." + }, + "id": "joint-query-controller", + "methods": [ + "Add one explicitly priced ordinary-to-selected observation and derive the ordered two-call map and inverse.", + "Change the first local pair or retained state, then test the existing lost-observation witness and price all new operations." + ], + "overlap_terms": [ + "QQ16", + "joint-query", + "changing-chart controller", + "selected observation", + "1969" + ], + "question": "Can one explicitly changed QQ16 interface recover the missing chart query and close a two-call controller within a favorable full budget?", + "scope_change_triggers": [ + "Retaining the fixed first pair and ordinary schedule while allowing only homogeneous selected-only control, already excluded by the witness.", + "Treating cover-map counts as zero-cost physical address operations." + ], + "starting_points": [ + "research/joint-query/README.md", + "research/joint-query/evidence/QQ16-SELECTED-WITNESS.md", + "research/joint-query/evidence/JOINT-QUERY-TRANSFER.md", + "docs/research/community-efficient1000-review.md" + ] + }, + "outcome": "negative-result", + "overlap_checks": [ + { + "at": "2026-10-14T23:05:44Z", + "complete_pagination": true, + "discussions": 877, + "matches": 0, + "open_prs": 435, + "purpose": "Entry claim check.", + "warnings": [] + }, + { + "at": "2026-10-14T23:21:48Z", + "complete_pagination": true, + "discussions": 882, + "matches": 0, + "open_prs": 439, + "purpose": "Pre-submission refresh.", + "warnings": [] + } + ], + "predecessor_refresh": { + "discussion2074": { + "checked_at": "2026-10-14T23:22:00Z", + "state": "open", + "title": "CLAIM: one paid pre-F0 B2 source observation (seed 3e62c004)" + }, + "pr2174": { + "checked_at": "2026-10-14T23:22:00Z", + "head": "f79470a7931f3943360c10d15b428e0e4e479c22", + "state": "OPEN" + } + }, + "predecessors": [ + { + "author": "Ali Romman", + "integrated_commit": "a6e6ad3936f67b8f63b5b68c5e75d540610a65e7", + "pr": 1969, + "use": "Retained QQ16 local words, private field contract, and two-map wrapper convention." + }, + { + "author": "@commdata2338", + "head": "f79470a7931f3943360c10d15b428e0e4e479c22", + "pr": 2174, + "use": "Conditional two-query decoder; its open question asks whether an actual controller realizes d_A at the B1 cut. Not imported as executable evidence." + }, + { + "discussion": 2074, + "url": "https://github.com/CrocSwap/integer-mult-bounds/discussions/2074", + "use": "Different pre-F0 B2 X_U query; its current favorable rank-eight envelope is used only as a planning comparator." + } + ], + "priority_revision": 4, + "refined_scope_key": "QQ16-B1-dA-C0-C7-frame-normalization-one-map-or-single-term-line", + "schema_version": 1, + "scope_change_reason": "Refines the card to the live PR #2174 missing interface: a concrete private-register relay for d_A at one fixed B1 cut. It changes no first pair or decoder identity and tests the native phase-conversion cost of using existing owned state, a distinct mechanism from the pre-F0 ordinary-to-selected B2 X_U observation in Discussion #2074.", + "scope_status": "refined", + "seed": "81b0173d58b26d95259d6f15464a5db3", + "selected_record_sha256": "10b9e340fd8e354a37a0c4813c90e5de1dd42044b5f6aca4a3fc5a42b685fa32", + "selector_scope_key": "0e34adbc1dd119161c3a", + "stop_rule": "At the pinned B_1_2 cut, enumerate all 3,650 single-map normalizers for the eight A-port frames, then compute the exact one-term-line distance from each source frame to private frame I. Stop if the resulting 144 rank-one line calls exceed the two-call favorable rank-one slack after the rank-eight output charge. Do not search multi-map sequences, other cuts, or other first pairs.", + "task_id": "joint-query-controller", + "track": "recursive-interfaces" +} diff --git a/research/qq16-private-da-frame-floor-seed81b017/VERIFY.json b/research/qq16-private-da-frame-floor-seed81b017/VERIFY.json new file mode 100644 index 0000000000..6c87556815 --- /dev/null +++ b/research/qq16-private-da-frame-floor-seed81b017/VERIFY.json @@ -0,0 +1,37 @@ +{ + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py" + ], + "checks": "Pins the base QQ16 certificate; verifies the B1_2 endpoint, final C-register clears, all eight stage-one frames, every registered one-map action, exact line distances, and the optimistic local invoice.", + "timeout_seconds": 30 + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-B", + "{package}/test_package.py" + ], + "checks": "Positive identity and one-term controls; wrong-stage and wrong-port controls; mutated-certificate hash rejection; verifier remains active under optimization.", + "timeout_seconds": 30 + } + ], + "inputs": [ + "research/joint-query/certificate.json.gz", + "research/joint-query/README.md", + "research/joint-query/evidence/NATIVE-REVIEW.md", + "research/joint-query/evidence/CONSERVED-QQ16.json", + "research/joint-query/verify_native.py", + "research/joint-query/verify_scalar.py" + ], + "python": "3.12", + "requirements": [], + "schema_version": 1, + "status": "ready" +} diff --git a/research/qq16-private-da-frame-floor-seed81b017/test_package.py b/research/qq16-private-da-frame-floor-seed81b017/test_package.py new file mode 100644 index 0000000000..27eb4bf6d1 --- /dev/null +++ b/research/qq16-private-da-frame-floor-seed81b017/test_package.py @@ -0,0 +1,48 @@ +"""Package-level positive and negative controls, active even under -O.""" + +from pathlib import Path +from hashlib import sha256 +import json +import runpy + + +HERE = Path(__file__).resolve().parent +VERIFY = runpy.run_path(str(HERE / "verify.py")) + + +def need(condition, message): + if not condition: + raise ValueError(message) + + +def main(): + raw = (HERE.parents[1] / "research/joint-query/certificate.json.gz").read_bytes() + packet = VERIFY["load_certificate"](raw) + result = VERIFY["calculate"](packet) + need(result["status"] == "PASS_QQ16_PRIVATE_DA_FRAME_FLOOR", + "Exact frame result") + need(result["registered_maps_checked"] == 3650 and + result["single_map_hits"] == 0, "Complete one-map census") + need(result["rank_one_line_calls_lower_bound"] == 144, + "Eight exact 18-term line distances") + saved = json.loads((HERE / "RESULT.json").read_text(encoding="utf-8")) + expected = dict(result) + expected["verify_py_sha256"] = sha256((HERE / "verify.py").read_bytes()).hexdigest() + expected["test_package_sha256"] = sha256(Path(__file__).read_bytes()).hexdigest() + need(saved == expected, "Saved exact result and package code pins") + + damaged = bytearray(raw) + damaged[len(damaged) // 2] ^= 1 + try: + VERIFY["load_certificate"](bytes(damaged)) + except ValueError: + pass + else: + raise ValueError("Mutated certificate must be rejected") + + print("PASS_QQ16_PRIVATE_DA_PACKAGE_CONTROLS identity=1 one_term=1 " + "wrong_stage=1 wrong_port=1 mutated_pin=1") + + +if __name__ == "__main__": + main() diff --git a/research/qq16-private-da-frame-floor-seed81b017/verify.py b/research/qq16-private-da-frame-floor-seed81b017/verify.py new file mode 100644 index 0000000000..620ae11763 --- /dev/null +++ b/research/qq16-private-da-frame-floor-seed81b017/verify.py @@ -0,0 +1,190 @@ +"""Exact, source-pinned frame and cost floor for one QQ16 private relay.""" + +from collections import Counter +from hashlib import sha256 +import gzip +import json +from pathlib import Path + + +BASE = "0fdd7d82de03e43c9e5a1000dfbcd380d1b687d2" +CERTIFICATE_SHA256 = "a5ed85fac5ebf3c091482a113ab0d351eb5a7892fe2841a35e16017ec1ff49f7" +PACKAGE = Path(__file__).resolve().parent +ROOT = PACKAGE.parents[1] +CERTIFICATE = ROOT / "research/joint-query/certificate.json.gz" + + +def need(condition, message): + if not condition: + raise ValueError(message) + + +def bits(value): + while value: + bit = value & -value + yield bit.bit_length() - 1 + value ^= bit + + +def act(columns, vector): + result = 0 + for index in bits(vector): + result ^= columns[index] + return result + + +def canonical(entries): + counts = Counter() + for axis, coefficient in entries: + counts[axis] = (counts[axis] + coefficient) % 4 + return tuple(sorted((axis, value) for axis, value in counts.items() if value)) + + +def frame_entries(record): + return canonical((int(axis), coefficient) + for axis, coefficient in record["line_terms_Z4"]) + + +def output_frame(stage, port, label): + """Y-port boundary frame: completed(stage) minus its port label.""" + entries = [(1 << index, 1) for index in range(9 + 8 * stage)] + entries.append((label, -1)) + return canonical(entries) + + +def move_frame(frame, mapping): + columns = mapping["owner_right_matrix_columns"] + shift = mapping["payload_translation_at_identity_owner"] + entries = [(act(columns, axis), coefficient) for axis, coefficient in frame] + entries.extend((1 << index, 2) for index in bits(shift)) + return canonical(entries) + + +def unit_line_distance(frame): + """Minimum +/-1 single-term Z4 edits needed to reach the zero frame.""" + return sum(min(coefficient, 4 - coefficient) for _, coefficient in frame) + + +def load_certificate(raw, expected_hash=CERTIFICATE_SHA256): + need(sha256(raw).hexdigest() == expected_hash, "Pinned compressed certificate") + return json.loads(gzip.decompress(raw)) + + +def calculate(packet): + need(packet["schema"] == "conserved-qq16-full-cover-native-words-v1", + "Pinned QQ16 certificate schema") + ports = packet["A_ports"] + need(ports == [0, 7, 20, 27, 36, 46, 57, 111], "Exact eight A ports") + program = packet["programs"]["B_1_2"] + need(program[-1][:3] == ["retained_core", "backward", 1], + "The B1_2 word ends at the backward stage-one cut") + + core = packet["core_words"]["backward"] + for private in range(8): + token = repr(["C", private]) + accesses = [(index, event) for index, event in enumerate(core) + if token in repr(event)] + need(accesses, f"C{private} has a retained-core access") + last = accesses[-1][1] + need(last[0:2] == ["scalar", ["clear", ["C", private]]], + f"C{private} is last cleared by the core") + + private_frame = frame_entries(packet["native_frame_registry"]["f0"]) + need(private_frame == (), "Private output frame is I") + frames = packet["native_frame_registry"] + maps = packet["map_registry"] + need(len(maps) == 3650, "Complete pinned one-map search domain") + + outputs = [] + total_line_floor = 0 + map_hits = {} + expected_frame_ids = ["f117", "f124", "f137", "f144", + "f153", "f163", "f174", "f228"] + for port, expected_frame_id in zip(ports, expected_frame_ids): + label = packet["native_line_recipes"][f"positive_{port}"]["label"] + target = output_frame(1, port, label) + need(target != private_frame, f"Y_A port {port} differs from private I") + frame_ids = [name for name, record in frames.items() + if frame_entries(record) == target] + need(frame_ids == [expected_frame_id], + f"Exact registered frame for Y_A port {port}") + need(len(target) == 18, f"Exactly 18 nonzero Z4 terms at Y_A port {port}") + need(all(value in (1, 3) for _, value in target), + f"Unit coefficients at Y_A port {port}") + + hits = [name for name, mapping in maps.items() + if move_frame(target, mapping) == private_frame] + map_hits[port] = hits + need(not hits, f"No registered single map normalizes port {port}") + distance = unit_line_distance(target) + need(distance == 18, f"18 single-term line operations for port {port}") + total_line_floor += distance + outputs.append({"port": port, "frame": frame_ids[0], + "terms": len(target), "unit_line_distance": distance, + "single_map_hits": hits}) + + # Positive controls: a zero frame stays zero under the identity map, and + # one +/-1 edit cancels one Z4 term exactly. + identity_hits = [name for name, mapping in maps.items() + if move_frame(private_frame, mapping) == private_frame] + need(identity_hits, "Identity-map positive control") + need(unit_line_distance(((17, 1),)) == 1, "Single-term line positive control") + + # A wrong stage or a wrong A-port label must not recreate the target frame. + control_port = ports[0] + control_label = packet["native_line_recipes"][f"positive_{control_port}"]["label"] + wrong_stage = output_frame(0, control_port, control_label) + wrong_port_label = packet["native_line_recipes"][f"positive_{ports[1]}"]["label"] + wrong_port = output_frame(1, control_port, wrong_port_label) + target = output_frame(1, control_port, control_label) + need(wrong_stage != target, "Wrong-stage negative control") + need(wrong_port != target, "Wrong-port negative control") + + scalar_add_unit_primitive_bound = 4 # 3 + 0 + 1 + 0 in the pinned scalar rule. + copy_adds = len(ports) + copy_primitive_bound = copy_adds * scalar_add_unit_primitive_bound + cleanup_clears_if_terminal = len(ports) + result = { + "status": "PASS_QQ16_PRIVATE_DA_FRAME_FLOOR", + "source_base": BASE, + "certificate_sha256_compressed": CERTIFICATE_SHA256, + "a_ports": outputs, + "private_frame": "f0", + "registered_maps_checked": len(maps), + "single_map_hits": sum(len(v) for v in map_hits.values()), + "rank_one_line_calls_lower_bound": total_line_floor, + "cover_maps_at_two_per_line": 2 * total_line_floor, + "copy_adds": copy_adds, + "copy_add_real_primitive_bound": copy_primitive_bound, + "terminal_cleanup_clear_macros": cleanup_clears_if_terminal, + "terminal_cleanup_real_primitive_bound": cleanup_clears_if_terminal, + "next_core_cleanup_extra_charge": 0, + "observation_coordinates": len(ports), + # Live candidate-budget comparator from Discussion #2074; this is not + # computed from the pinned local QQ16 certificate. + "favorable_extra_rank_one_credit_from_discussion_2074": 2, + "comparison": "144 rank-one line calls exceed the two-call favorable slack before global hosting or address costs", + "scope": "Eight A ports at B_1_2; all registered one-map normalizers and the one-term native-line conversion model only.", + "controls": ["identity map", "single-term line cancellation", + "wrong stage rejected", "wrong port rejected", + "mutated source certificate rejected"], + "no_kappa": True, + } + return result + + +def main(): + need(ROOT.is_dir(), "Repository root found from package path") + raw = CERTIFICATE.read_bytes() + packet = load_certificate(raw) + result = calculate(packet) + need(result["rank_one_line_calls_lower_bound"] > + result["favorable_extra_rank_one_credit_from_discussion_2074"], + "The bounded line mechanism fails the favorable call budget") + print("PASS_QQ16_PRIVATE_DA_FRAME_FLOOR ports=8 frame_terms=18 " + "single_map_hits=0 rank1_line_floor=144 cover_maps=288 " + "scalar_add=32 no_kappa") + + +if __name__ == "__main__": + main()