diff --git a/research/fraction-zero-unit-feasibility/.gitignore b/research/fraction-zero-unit-feasibility/.gitignore new file mode 100644 index 0000000000..c18dd8d83c --- /dev/null +++ b/research/fraction-zero-unit-feasibility/.gitignore @@ -0,0 +1 @@ +__pycache__/ diff --git a/research/fraction-zero-unit-feasibility/NOTICE b/research/fraction-zero-unit-feasibility/NOTICE new file mode 100644 index 0000000000..9a3e901261 --- /dev/null +++ b/research/fraction-zero-unit-feasibility/NOTICE @@ -0,0 +1,5 @@ +Fraction zero/unit feasibility study +==================================== +Original signed-error arithmetic: Ali Romman, with substantial OpenAI Codex assistance, retaining Adam Gall/ywz65/PR2878, PR5826/5819 and Mason Hale/PR5811/native/compiler/precision credit. The complete PR5848, PR5831 and nested source archives/notices remain unchanged. Apache-2.0. + +New profiling, exact Fraction shortcut derivation, finite and actual comparisons, guard diagnoses and negative gate: Chris R / Clear1nsight, substantial OpenAI Codex assistance; no subagents, independent human or formal-kernel acceptance. No performance, physical-supplier, kappa or selected-frontier improvement. PR5848 and PR5839 supplied the complete-qualification baseline; guard/custody lineage follows PR5816/5818/5832/5761 with original authorship preserved. diff --git a/research/fraction-zero-unit-feasibility/PROOF.md b/research/fraction-zero-unit-feasibility/PROOF.md new file mode 100644 index 0000000000..13ee321049 --- /dev/null +++ b/research/fraction-zero-unit-feasibility/PROOF.md @@ -0,0 +1,13 @@ +# Exact-value scope of the proposed shortcuts + +This argument concerns the authenticated Fraction `error_trace` function and its standard exact-rational inputs. It does not change a native operator, admitted cost, precision theorem or complete supplier. + +Assume both versions start an event with the same coefficient rows, scores, peaks, witness dictionaries, pairs and hash stream. Shared constants are ordinary immutable Fraction values 0,1,-1. Replacing repeated construction of those constants preserves exact values/types and does not share mutable row/score containers. + +For an ADD/COPY coefficient update, let x be the destination coefficient, y the source coefficient and q the parsed exact scalar. The original computes x+q*y. If q=1, the derived expression is x+y; if q=-1, it is x+(-y); otherwise it retains x+q*y. All are exactly equal standard Fraction values. With d=abs(x+q*y)-abs(x), the original updates each weighted score s by s+d*a, and the unweighted score by s+d. If d=1, addition of a is equal; if d=-1, subtraction of a is equal; if d=0, leaving the score unchanged is equal; otherwise the original expression is retained. There is no floating arithmetic, truncation, reassociation across distinct coefficient contributions or integer-backend reuse. + +The resulting coefficient is inserted or removed by the same zero predicate. The event order, rounded-site injections, prefix peak/tie rules, full witness copies, final scores/coefficients, Pareto rows and hash updates remain in their original order. Induction on the coefficient and event loops therefore preserves every returned value, including attaining witnesses and signed coefficient streams. Mutable output dictionaries/lists remain fresh. The scope excludes arbitrary user-defined numeric classes with observable operator side effects; standard Fraction arithmetic and the authenticated caller supply the declared domain. + +Exact module/function source hashes and uniquely bound edits prevent transfer to a changed source. The unmodified callable must match a fresh compilation's recursive executable structure; only file/line metadata is ignored. The original callable is restored by a context manager even on exceptions. Tests reject both outer and nested live-code drift, and compare numeric types as well as values. The three declared malformed-input probes preserve the original exception type/message; no universal malformed-object API claim is made. + +Finite evidence covers 241 programs/10,164 events, all six operations, zero/unit/general coefficients and weights, sign flips, cancellation and 16 failure/isolation controls. One full actual trace additionally checks every value/type and unchanged input on all 25,984 events/799 coordinates. This establishes source-bound exactness evidence. It does not fund a performance claim: the observed 0.237-second trace difference is insufficient headroom for the complete qualification target. The experiment stops before complete optimization construction. diff --git a/research/fraction-zero-unit-feasibility/README.md b/research/fraction-zero-unit-feasibility/README.md new file mode 100644 index 0000000000..0c701b9d67 --- /dev/null +++ b/research/fraction-zero-unit-feasibility/README.md @@ -0,0 +1,49 @@ +# Scoped negative Fraction zero/unit feasibility + +**Decision: stop before complete candidate construction. No speedup or kappa claim.** The full current [PR #5848](https://github.com/CrocSwap/integer-mult-bounds/pull/5848) qualifier profiles at 38.314 seconds. Its Fraction error propagation takes 20.053 seconds. A source-bound zero/unit shortcut routine passes correctness, but one fresh full-word comparison measures **20.180 seconds original versus 19.943 seconds derived**: only 0.237 seconds difference. That is about 0.62% of the profiled whole qualifier, far below the roughly 5.75 seconds needed for a 15% complete-stage saving. This is an insufficient-headroom decision, not a universal performance obstruction or verified kernel speedup. + +No complete optimized qualifier, first complete B/C pair, six-process benchmark or performance PR was built. The numerical/physical construction, source archives, precision guards, original independent integer backend and selected result remain unchanged. Kappa research, Work 1/2, feeds, agents and automations stay paused. + +## Sources and scope + +The input is the complete official 97-file PR #5848 export at `66fb6c6b8683b37967e9d7f313b3df99a49d2406`, containing unchanged PR #5831 and nested PR #5826 sources and notices. The exact original Fraction module SHA256 is `a4c743e79c55e9c2ac26deb6d87cb948b1b0fbe942e4f7912ccbfba55db4b32a`; its `error_trace` source SHA256 is `379c0e7c1c5ab7433ab5ad2669c1bda1234dbf0530fc61b21bfbe83528f37f53`. + +The prototype reuses immutable Fraction constants and applies exact identities for coefficients ±1 and magnitude changes 0/±1. It preserves generic Fraction arithmetic for every other case. Exact full-module/function hashes, unique replacement sites, ordinary function shape and recursive executable-code binding are required before deriving a function. The frozen files are never edited. The scoped installer restores the original callable on success and exception. `PROOF.md` explains the value/type invariants. + +The finite gate precedes the actual audit and any complete candidate. All **241 programs / 10,164 events**, complete traces, signed witnesses, numeric types and unmodified inputs agree. **16 controls** cover returned-output mutation, source/module/type/live/nested-code drift, wrong signs, missing witnesses/rounding/zero-delta arithmetic, original malformed-input exceptions, installation/restoration and a fresh derivation. Normal and optimized gates pass. + +The full actual audit compares all **25,984 events / 799 coordinates**, every trace/witness value and type, with unchanged inputs. The complete output digest is `954c7448ff74d78753828e9623ad44c46da9e5ce459420b6e50a5d47294250b9`, weights digest `cf98bf5da5df28ec1ca3ca7e8723d740b98e142f31e94ff7ec36815cc387c373`. + +## Reproduce + +Python 3.12, standard library only: + +```sh +python3 -B scripts/research_package.py --package research/fraction-zero-unit-feasibility +``` + +This runs a **fresh finite differential and all 16 controls**, about one second locally. It does not replay the full actual trace, substitute for PR #5848 qualification, establish performance or admit a mathematical theorem. The manifest states this limited coverage explicitly. + +The separately opt-in full actual audit is: + +```sh +python3 -B research/fraction-zero-unit-feasibility/actual_audit.py +``` + +It took 42.807 seconds locally and should run only under a fresh serial budget with the original 180-second cap, 1 GiB sampled group RSS and no automatic retries. Do not rerun it merely to validate these recorded results. Its within-process old/derived timers are not fresh-process wall/CPU qualification benchmarks. Ordering, retained output, unflushed caches and unreserved host load limit the timing inference. + +## Failures preserved + +Two attempts stopped before arithmetic comparison. The first wrapper retained an obsolete 14-member uniqueness count while checking the 98-member PR #5848 export. The official complete export check had already passed. The labelled correction requires both exact counts to be 98 and retains all 97 file/hash/mode bindings. + +The second code-binding check compared nested code objects with source-location metadata, rejecting a recompiled comprehension. The labelled correction compares executable structure recursively, including nested bytecode/constants, names, argument layout, flags, free/cell variables, stack/local counts and exception table, while excluding location metadata. Exact source hashes remain mandatory; a new nested-code corruption control verifies rejection. + +Original failed receipts, original hashes, reconstructed rejected sources and diagnoses are retained in `evidence/`. Public stderr replaces only the workspace prefix; its public hash and original stderr hash are both retained. Neither correction changes source arithmetic or expected scientific outputs. Every attempt is charged to the common cap. No failed arithmetic differential was repaired. + +## Open next questions + +The most useful next nomination would require a separately authorized primitive-level Fraction profile and an explicit bound on complete-stage headroom. The current data do not establish which branch, allocation or arithmetic primitive dominates the remaining cost. Repeating zero/unit tweaks or removing independent oracles is not justified by this result. A broader algorithm needs new source/coverage/purity review and finite feasibility before construction. + +## Credit + +Ali Romman supplied the original precision/error arithmetic and exact integer backend. Retain [PR #5831](https://github.com/CrocSwap/integer-mult-bounds/pull/5831), [PR #5826](https://github.com/CrocSwap/integer-mult-bounds/pull/5826), [PR #5819](https://github.com/CrocSwap/integer-mult-bounds/pull/5819), Adam Gall, ywz65, [PR #2878](https://github.com/CrocSwap/integer-mult-bounds/pull/2878), Mason Hale/[PR #5811](https://github.com/CrocSwap/integer-mult-bounds/pull/5811) and all retained P104/native/compiler/precision notices. PR #5848 and [PR #5839](https://github.com/CrocSwap/integer-mult-bounds/pull/5839) supply the qualifier and Linux baseline. Guard and custody lineage follows [PR #5816](https://github.com/CrocSwap/integer-mult-bounds/pull/5816), [PR #5818](https://github.com/CrocSwap/integer-mult-bounds/pull/5818), [PR #5832](https://github.com/CrocSwap/integer-mult-bounds/pull/5832) and the exact test-only [PR #5761](https://github.com/CrocSwap/integer-mult-bounds/pull/5761) dependency with original authorship/cherry-pick credit. New feasibility work by Chris R / Clear1nsight with substantial OpenAI Codex assistance; no subagents or independent human/kernel acceptance. Apache-2.0. diff --git a/research/fraction-zero-unit-feasibility/RESULT.json b/research/fraction-zero-unit-feasibility/RESULT.json new file mode 100644 index 0000000000..21d661f022 --- /dev/null +++ b/research/fraction-zero-unit-feasibility/RESULT.json @@ -0,0 +1,105 @@ +{ + "actual_audit": { + "all_values_types_and_inputs_preserved": true, + "baseline_trace_seconds": 20.17961209200439, + "coordinates": 799, + "derived_trace_seconds": 19.942737821984338, + "events": 25984, + "full_output_sha256": "954c7448ff74d78753828e9623ad44c46da9e5ce459420b6e50a5d47294250b9", + "observed_seconds_removed": 0.2368742700200528, + "profile_whole_qualifier_seconds": 38.31372155799181, + "status": "PASS_FULL_ACTUAL_FRACTION_TRACE_EQUIVALENCE", + "weights_sha256": "cf98bf5da5df28ec1ca3ca7e8723d740b98e142f31e94ff7ec36815cc387c373" + }, + "decision": "The observed trace difference of 0.237 seconds is insufficient to justify constructing a complete qualifier for a 15% whole-stage target. This is a scoped observation, not a universal obstruction.", + "finite": { + "all_complete_values_and_types_equal": true, + "cases": 241, + "controls": [ + "returned-mutation-isolated", + "source-drift", + "Fraction-type-drift", + "module-byte-drift", + "live-code-drift", + "nested-live-code-drift", + "wrong-signed-update", + "omitted-witness", + "omitted-rounded-sites", + "wrong-zero-delta", + "bad-role", + "bad-scalar", + "missing-weight", + "restore-success", + "restore-exception", + "fresh-derivation" + ], + "events": 10164, + "status": "PASS_FINITE_FRACTION_FEASIBILITY" + }, + "full_BC_benchmark_run": false, + "full_candidate_constructed": false, + "performance_claim": null, + "profile": { + "inclusive_profiles": { + "Fraction.calculate.inclusive": [ + 1, + 29.56573735800339 + ], + "Fraction.error_trace": [ + 1, + 20.052949415985495 + ], + "Fraction.execute": [ + 6, + 0.5582490059896372 + ], + "Fraction.ideal": [ + 4, + 4.049590509006521 + ], + "Fraction.reverse_all": [ + 1, + 2.8532538060098886 + ], + "Fraction.reverse_cut": [ + 4, + 0.07846067700302228 + ], + "integer.calculate.inclusive": [ + 1, + 7.428388572006952 + ], + "integer.error_trace": [ + 121, + 3.0883288670156617 + ], + "integer.ideal": [ + 4, + 0.8438016349391546 + ], + "integer.reverse_all": [ + 121, + 1.0509023397462443 + ], + "observation.calls.inclusive": [ + 35, + 30.843270772049436 + ], + "observation.deepcopy": [ + 16, + 0.11094509204849601 + ], + "observation.take": [ + 18, + 0.30852267597219907 + ], + "reference.digest": [ + 44, + 3.5292127177817747 + ] + }, + "seconds": 38.02564648500993, + "status": "PASS_FULL_QUALIFIER_PROFILE" + }, + "status": "NEGATIVE_COMPLETE_COST_FEASIBILITY" +} diff --git a/research/fraction-zero-unit-feasibility/SOURCES.json b/research/fraction-zero-unit-feasibility/SOURCES.json new file mode 100644 index 0000000000..8955c4c368 --- /dev/null +++ b/research/fraction-zero-unit-feasibility/SOURCES.json @@ -0,0 +1,30 @@ +{ + "schema_version": 1, + "base_commit": "de5ec2e7a6074068452f45b1a191b5c72832df4a", + "files": [ + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec", + "sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81" + }, + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "581f8d87008354eb5b869f7ed9de1317ad837ce8", + "sha256": "2a0220e866417774606e0f991e41b9c1d26b1f43b97857238cf478dbc7d330b5" + }, + { + "path": "research/fraction-zero-unit-feasibility/inputs/PR5848.tar", + "usage": "input", + "git_blob": "307d09d2a968e1bbec8025d9fbd0a884df790d12", + "sha256": "f899600acb6966a6b028ffbf1e33a94061615626b510feaca8cb073f03a34de6", + "pin": "head:e5614e94d93945963268e76fbd37f7dec58fde78:research/fraction-zero-unit-feasibility/inputs/PR5848.tar" + } + ], + "external_origin": { + "pr": 5848, + "head": "66fb6c6b8683b37967e9d7f313b3df99a49d2406", + "complete_export_files": 97 + } +} diff --git a/research/fraction-zero-unit-feasibility/TASK.json b/research/fraction-zero-unit-feasibility/TASK.json new file mode 100644 index 0000000000..e7d8688b51 --- /dev/null +++ b/research/fraction-zero-unit-feasibility/TASK.json @@ -0,0 +1,60 @@ +{ + "schema_version": 1, + "task_id": "replay-runtime", + "original_card": { + "id": "replay-runtime", + "question": "Can one measured replay bottleneck be sped up without dropping coverage?", + "starting_points": [ + "scripts/run_isolated_tests.py", + "scripts/verify_replay_coverage.py", + "certificates/selected-result.json" + ], + "methods": [ + "Profile one isolated replay and optimize the measured bottleneck.", + "Design source-bound reuse with explicit dependency invalidation and negative controls." + ], + "acceptance_gate": "Report before/after wall time on the same fixture, retained checks and invalidation behavior.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_selected_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Resolve the current selected review, separate complex/ordinary BIT/admitted BIT/outer budgets, and compare the card against live handoffs before starting. Historical ceilings require exact source/model equivalence.", + "scope": "Source-binding orientation only; not a scientific replay or all-size proof. Materialize selected inputs if this checkout is sparse." + }, + "first_experiment": "Measure one unchanged fixture, preserve check coverage, and test one optimization with invalidation controls.", + "bottleneck_link": "Faster trustworthy replays increase review throughput and let mechanism candidates be checked sooner.", + "allowed_variations": [ + "Profile one stage or design one source-bound cache boundary." + ], + "scope_change_triggers": [ + "Skipping coverage or comparing different fixtures to claim speedup." + ], + "overlap_terms": [ + "replay runtime", + "cache invalidation", + "isolated tests" + ] + }, + "scope_status": "refined", + "scope_change_reason": "Explicit donor requested profile and finite feasibility before construction. Full actual kernel comparison found insufficient saving; stop before a complete optimization candidate or performance PR.", + "actual_scope": "PR5848/frozen-66fb6c6/Fraction-zero-unit-small-feasibility", + "bottleneck_link": "Faster trustworthy replays increase review throughput and let mechanism candidates be checked sooner.", + "stop_rule": "Gate stopped after one full actual trace comparison:20.180\u219219.943s does not justify15% complete38-second qualification saving. No full candidate or six-run benchmark. Original180s science cap,600s finite/profile stage,1GiB sampled group RSS and zero automatic retries; pre-arithmetic diagnosed corrections labelled and charged.", + "time_budget_minutes": 90, + "outcome": "negative-result", + "evidence": "RESULT.json, PROOF.md, README.md and evidence/: exact241-case/10164-event equality,16 controls, full actual25984-event/799-coordinate trace and typed witness equality, measured insufficient headroom, two preserved pre-arithmetic wrapper binding failures and diagnoses.", + "author": "Chris R / Clear1nsight", + "ai_assistance": "Substantial OpenAI Codex assistance for source review, execution, tooling and report; no subagents, independent human or proof-kernel acceptance.", + "open_questions": [ + { + "question": "Which Fraction primitive dominates the remaining20-second trace?", + "why_it_matters": "This zero/unit micro-optimization did not change the complete-cost decision.", + "first_step": "Under a separately authorized budget, profile arithmetic primitives with complete source-bound output checks before nominating another algorithm.", + "blocked_by": "New bounded nomination and overlap check; no authorization inferred from this checkpoint." + } + ], + "base_commit": "de5ec2e7a6074068452f45b1a191b5c72832df4a" +} diff --git a/research/fraction-zero-unit-feasibility/VALIDATION.json b/research/fraction-zero-unit-feasibility/VALIDATION.json new file mode 100644 index 0000000000..46577b3d72 --- /dev/null +++ b/research/fraction-zero-unit-feasibility/VALIDATION.json @@ -0,0 +1,17 @@ +{ + "attempts": 9, + "automatic_retries": 0, + "complete_BC_benchmark_run": false, + "complete_qualifier_constructed": false, + "finite_replay": "pass normal and optimized", + "full_actual_trace": "values/types/inputs equal; timing insufficient for15% complete qualification", + "guarded_wall_seconds": 87.11620681601926, + "initial_stage_limit_seconds": 600, + "kappa_research": "PAUSED", + "nomination": "STOP: insufficient observed complete-stage headroom", + "passes": 7, + "per_command_limit_seconds": 180, + "pre_arithmetic_guard_rejections": 2, + "shared_limit_seconds": 1500, + "source": "66fb6c6b8683b37967e9d7f313b3df99a49d2406" +} diff --git a/research/fraction-zero-unit-feasibility/VERIFY.json b/research/fraction-zero-unit-feasibility/VERIFY.json new file mode 100644 index 0000000000..8812827112 --- /dev/null +++ b/research/fraction-zero-unit-feasibility/VERIFY.json @@ -0,0 +1,20 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/fraction-zero-unit-feasibility/inputs/PR5848.tar" + ], + "commands": [ + { + "argv": [ + "{python}", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 30, + "checks": "Fresh complete241-case/10164-event finite exact Fraction differential and16 source/code/type/mutation/exception/restoration controls. Finite negative feasibility only; this command does not rerun the full actual trace or qualify a multiplication theorem/performance claim." + } + ] +} diff --git a/research/fraction-zero-unit-feasibility/actual_audit.py b/research/fraction-zero-unit-feasibility/actual_audit.py new file mode 100644 index 0000000000..d3fab385a6 --- /dev/null +++ b/research/fraction-zero-unit-feasibility/actual_audit.py @@ -0,0 +1,29 @@ +"""One fresh full actual original/derived trace comparison; not a speed benchmark.""" +from copy import deepcopy +import gzip +import importlib.util +import json +from pathlib import Path +import sys +import time +from frozen import baseline,require +from fraction_fast import derive +from finite import types_of + +with baseline() as package: + sys.path.insert(0,str(package)) + import source + with source.baseline() as p: + spec=importlib.util.spec_from_file_location('actual_audit_source',p/'verify.py') + v=importlib.util.module_from_spec(spec);spec.loader.exec_module(v) + with v.source() as (original_path,original,reference): + word=json.loads(gzip.decompress((original_path/'inputs/WORD.json.gz').read_bytes())) + ideal,weights=reference.ideal(word);rounded=set(ideal['counts']) + fingerprint=reference.digest((word,weights,sorted(rounded))) + started=time.perf_counter();a=reference.error_trace(word,weights,rounded);baseline_seconds=time.perf_counter()-started + fast=derive(reference) + started=time.perf_counter();b=fast(word,weights,rounded);candidate_seconds=time.perf_counter()-started + require(a==b and types_of(a)==types_of(b),'all actual trace/witness values and types') + require(reference.digest((word,weights,sorted(rounded)))==fingerprint,'all actual inputs unchanged') + result=dict(status='PASS_FULL_ACTUAL_FRACTION_TRACE_EQUIVALENCE',events=len(word['program']),coordinates=ideal['n'],full_output_sha256=reference.digest(a),weights_sha256=reference.digest(weights),baseline_trace_seconds=baseline_seconds,derived_trace_seconds=candidate_seconds,observed_seconds_removed=baseline_seconds-candidate_seconds,profile_whole_qualifier_seconds=38.31372155799181,all_values_types_and_inputs_preserved=True) + print(json.dumps(result,sort_keys=True)) diff --git a/research/fraction-zero-unit-feasibility/evidence/CLAIM.md b/research/fraction-zero-unit-feasibility/evidence/CLAIM.md new file mode 100644 index 0000000000..9de8c438e4 --- /dev/null +++ b/research/fraction-zero-unit-feasibility/evidence/CLAIM.md @@ -0,0 +1 @@ +CLAIM — bounded verification-engineering follow-up to [PR #5848](https://github.com/CrocSwap/integer-mult-bounds/pull/5848), frozen head `66fb6c6b8683b37967e9d7f313b3df99a49d2406`. Fresh full qualification profile passes at 38.314 s; its Fraction signed-error pass takes 20.053 s. Scope: finite feasibility, then at most one source-bound exact Fraction zero/unit fast-path candidate in that routine. This includes immutable constants, coefficients ±1 and magnitude changes 0/±1; all nontrivial arithmetic stays exact Fraction, with the independent integer backend unchanged. Preserve every 25,984 event/799 coordinate result/witness/hash, original 120-program/4,240-event differential, six semantic/three integer rejections, four custody and 27 observation controls. Full actual original/derived trace equality, normal/optimized/sealed checks and >=15% complete qualification wall AND CPU savings are mandatory before a performance PR. Serial fresh processes, first pair before remaining B,C,C,B,B,C, original 180 s command cap, 1 GiB sampled group RSS, 600 s initial stage / 1,500 s shared local cap, no automatic retries. Stop on source/coverage/receipt failure, insufficient complete-stage gain or active overlap. One wrapper-census attempt stopped before target entry; its receipt and explicit 98-member correction are retained and charged. Canonical main remains `de5ec2e7a6074068452f45b1a191b5c72832df4a`, priority 8. Targeted PR/source checks found no matching successor or external PR5848 feedback; this is bounded coverage, not exhaustive/unpublished assurance. Expiry 27 October 2026 at 18:30 AEDT. Preserve Ali Romman and retained PR5831/5826/5819/native/compiler/precision and verification-tooling credit. Chris R / Clear1nsight with substantial OpenAI Codex assistance, no subagents. Kappa research, Work 1/2, feeds and automations remain paused. diff --git a/research/fraction-zero-unit-feasibility/evidence/CODE-BINDING-DIAGNOSIS.json b/research/fraction-zero-unit-feasibility/evidence/CODE-BINDING-DIAGNOSIS.json new file mode 100644 index 0000000000..c8f75915ca --- /dev/null +++ b/research/fraction-zero-unit-feasibility/evidence/CODE-BINDING-DIAGNOSIS.json @@ -0,0 +1,12 @@ +{ + "failed_label": "finite", + "stage": "derive(): code authentication before any arithmetic differential", + "cause": "Direct equality of nested code objects in co_consts compares source locations as well as executable structure. Standalone compilation relocates comprehensions.", + "correction": "Recursively compare bytecode, normalized constants, names, args, flags, free/cell vars, stack/locals and exception table; exclude only source location metadata. Exact module and function source hashes still mandatory.", + "old_sha256": "dc3510e7e24b9505a9f96e7d854da6c516cafbfa192c5480b0a8ba8b558a489c", + "corrected_sha256": "a178989906b401f5f922f35a48484b6cae65e191336e17ebf7f61de2601238d2", + "arithmetic_logic_changed": false, + "failed_receipt_preserved": true, + "cost_charged": true, + "new_label": "finite-code-binding-fixed" +} diff --git a/research/fraction-zero-unit-feasibility/evidence/PLAN.json b/research/fraction-zero-unit-feasibility/evidence/PLAN.json new file mode 100644 index 0000000000..6b02549ba3 --- /dev/null +++ b/research/fraction-zero-unit-feasibility/evidence/PLAN.json @@ -0,0 +1,39 @@ +{ + "scope": "One bounded verification-only Fraction-reference follow-up to exact PR5848; profile, finite feasibility, then at most one complete candidate.", + "main": "de5ec2e7a6074068452f45b1a191b5c72832df4a", + "base_with_exact_PR5761_test_dependency": "01014cbe772ea5a59ccbc55266222433944c7368", + "source_PR5848": "66fb6c6b8683b37967e9d7f313b3df99a49d2406", + "source_archive_sha256": "f899600acb6966a6b028ffbf1e33a94061615626b510feaca8cb073f03a34de6", + "gates": [ + "One full current qualifier profile plus static purity/operation census before nomination.", + "Exact source-bound Fraction simplification only after real-backend finite differential, all-operation/negative/zero/cancellation/exception/input-and-output-mutation/installation-and-restoration/source-drift controls, normal and -O.", + "First fresh complete B/C pair >=15% less wall AND CPU before remaining B,C,C,B,B,C samples. All results/witnesses/events/controls retained.", + "Full actual fresh reference/derived error-trace equivalence outside benchmark, complete expected scientific receipts, original 27 observation/four custody/six semantic/three integer controls and 120-program differential.", + "Normal/O/read-only Git-free complete qualification, committed byte/mode/input/export checks and exact-head hosted CI before final required handoffs." + ], + "limits": { + "profile_stage_seconds": 600, + "all_local_guarded_seconds": 1500, + "per_precision_command_seconds": 180, + "sampled_process_group_rss_bytes": 1073741824, + "serial_runs": true, + "automatic_retries": 0 + }, + "stop": [ + "Incomplete source/fixture closure, byte/mode/head drift, arithmetic/witness/receipt/control mismatch, unexpected stderr or resource failure.", + "Insufficient whole-qualification headroom or first-pair/median wall-or-CPU saving below15%, or materially overlapping active upstream implementation. Retain evidence; do not expand." + ], + "candidate_domain": "Exact Fraction arithmetic; initial nomination constants and zero/unit fast paths in signed error transfer. No integer engine, word, weights, guards, tests, skip, oracle-count or source-archive edits. Broader changes need explicit reassessment before construction.", + "kappa_research": "PAUSED", + "agents": 0, + "profile_gate": { + "status": "PASS_AFTER_PRESERVED_PRETARGET_CENSUS_ERROR", + "full_wall_seconds": 38.31372155799181, + "Fraction_error_trace_seconds": 20.052949415985495, + "deepcopy_seconds": 0.11094509204849601, + "digest_inclusive_seconds": 3.5292127177817747, + "nomination": "Source-bound exact Fraction zero/unit simplification in error_trace, including unit magnitude deltas; no approximation, arithmetic representation change or integer-engine edits.", + "reject": "Copy-only elimination has insufficient measured complete-stage headroom." + }, + "feasibility_gate": "Pending: finite proof-oriented differential before complete candidate." +} diff --git a/research/fraction-zero-unit-feasibility/evidence/PRETARGET-DIAGNOSIS.json b/research/fraction-zero-unit-feasibility/evidence/PRETARGET-DIAGNOSIS.json new file mode 100644 index 0000000000..9f015cbb3e --- /dev/null +++ b/research/fraction-zero-unit-feasibility/evidence/PRETARGET-DIAGNOSIS.json @@ -0,0 +1,12 @@ +{ + "stage": "pre-target payload authentication; zero scientific stdout, no target entry", + "cause": "Stale 14-member uniqueness constant when adapting old13-file wrapper to checked97-file PR5848 export. Both total/unique counts must be98 including receipt.", + "failed_label": "profile", + "old_wrapper_sha256": "5d50f3cc070065c05b343a936d4f9f40daf5a2d50e61df5f36380b824c56f525", + "corrected_wrapper_sha256": "a5848c4290e96fc639bd15beb3d533e49fa026e9e0333381543acdb0bf1a9547", + "actual_source_changes": false, + "original_failed_receipt_preserved": true, + "cost_charged_to_shared_cap": true, + "manual_corrected_attempt": "profile-census-fixed", + "all_source_hashes_and_complete_file_rows_still_required": true +} diff --git a/research/fraction-zero-unit-feasibility/evidence/REJECTED-binding-source.txt b/research/fraction-zero-unit-feasibility/evidence/REJECTED-binding-source.txt new file mode 100644 index 0000000000..3db6d4b26a --- /dev/null +++ b/research/fraction-zero-unit-feasibility/evidence/REJECTED-binding-source.txt @@ -0,0 +1,89 @@ +"""Derive exact Fraction zero/unit shortcuts from one authenticated function. + +Original arithmetic: Ali Romman and retained completed-error lineage. +Derivation and checks: Chris R / Clear1nsight, substantial OpenAI Codex assistance. +Apache-2.0. No approximate arithmetic or integer-backend sharing. +""" +from contextlib import contextmanager +from fractions import Fraction +from hashlib import sha256 +import inspect +from pathlib import Path + +MODULE_SHA256 = 'a4c743e79c55e9c2ac26deb6d87cb948b1b0fbe942e4f7912ccbfba55db4b32a' +FUNCTION_SHA256 = '379c0e7c1c5ab7433ab5ad2669c1bda1234dbf0530fc61b21bfbe83528f37f53' +BEFORE = ''' for i, v in rows[event[2]].items(): + old = rows[r].get(i, F(0)) + value = old + q*v + change = abs(value)-abs(old) + scores[r][0] += change*weights[i][0] + scores[r][1] += change*weights[i][1] + scores[r][2] += change +''' +AFTER = ''' unit, negative_unit = q == ONE, q == NEGATIVE_ONE + for i, v in rows[event[2]].items(): + old = rows[r].get(i, ZERO) + value = old + (v if unit else -v if negative_unit else q*v) + change = abs(value)-abs(old) + if change == ONE: + scores[r][0] += weights[i][0] + scores[r][1] += weights[i][1] + scores[r][2] += ONE + elif change == NEGATIVE_ONE: + scores[r][0] -= weights[i][0] + scores[r][1] -= weights[i][1] + scores[r][2] -= ONE + elif change: + scores[r][0] += change*weights[i][0] + scores[r][1] += change*weights[i][1] + scores[r][2] += change +''' + + +def need(ok, message): + if not ok: + raise ValueError(message) + + +def transformed(raw): + need(sha256(raw.encode()).hexdigest() == FUNCTION_SHA256, 'exact Fraction function source') + need(raw.count(BEFORE) == 1, 'one exact Fraction coefficient loop') + value = raw.replace(BEFORE, AFTER) + # Shared Fraction objects are immutable; output dictionaries stay fresh. + for token, replacement, count in [('F(0)', 'ZERO', 3), ('F(1)', 'ONE', 1), ('F(-1)', 'NEGATIVE_ONE', 1)]: + need(value.count(token) == count, 'exact Fraction constant sites: '+token) + value = value.replace(token, replacement) + seam = " n = word['public'] + word['owned_fields']\n" + need(value.count(seam) == 1, 'one exact Fraction setup seam') + return value.replace(seam, seam+' ZERO, ONE, NEGATIVE_ONE = F(0), F(1), F(-1)\n') + + +def code_shape(code): + return (code.co_code, code.co_consts, code.co_names, code.co_varnames, + code.co_argcount, code.co_posonlyargcount, code.co_kwonlyargcount, code.co_flags) + + +def derive(reference): + need(reference.F is Fraction, 'exact standard Fraction type') + path = Path(reference.__file__) + need(sha256(path.read_bytes()).hexdigest() == MODULE_SHA256, 'exact Fraction module bytes') + original = reference.error_trace + raw = inspect.getsource(original) + text = transformed(raw) + namespace = dict(reference.__dict__) + exec(compile(raw, '', 'exec'), namespace) + need(code_shape(original.__code__) == code_shape(namespace['error_trace'].__code__), 'live Fraction code agrees with source') + need(original.__defaults__ is None and original.__kwdefaults__ is None and original.__closure__ is None, 'ordinary Fraction function') + exec(compile(text, '', 'exec'), namespace) + return namespace['error_trace'] + + +@contextmanager +def installed(reference): + original = reference.error_trace + derived = derive(reference) + reference.error_trace = derived + try: + yield derived + finally: + reference.error_trace = original diff --git a/research/fraction-zero-unit-feasibility/evidence/REJECTED-wrapper-source.txt b/research/fraction-zero-unit-feasibility/evidence/REJECTED-wrapper-source.txt new file mode 100644 index 0000000000..9690be07f0 --- /dev/null +++ b/research/fraction-zero-unit-feasibility/evidence/REJECTED-wrapper-source.txt @@ -0,0 +1,67 @@ +"""Authenticate the unchanged complete PR5848 export before importing it.""" +from contextlib import contextmanager +from hashlib import sha256 +import json +from pathlib import Path +import tarfile +import tempfile + +HERE = Path(__file__).resolve().parent +BUNDLE_SHA256 = 'f899600acb6966a6b028ffbf1e33a94061615626b510feaca8cb073f03a34de6' +SOURCE_HEAD = '66fb6c6b8683b37967e9d7f313b3df99a49d2406' + + +def require(ok, why): + if not ok: + raise ValueError(why) + + +def payload(archive=None): + archive = HERE / 'inputs/PR5848.tar' if archive is None else archive + require(sha256(archive.read_bytes()).hexdigest() == BUNDLE_SHA256, 'Exact PR5848 bundle') + with tarfile.open(archive, 'r:') as stream: + members = stream.getmembers() + require(len(members) == 98 and len({m.name for m in members}) == 14, 'Complete unique baseline bundle') + require(all(m.isfile() and 0 <= m.size <= 8 * 1024**2 for m in members), 'Regular bounded baseline members') + receipt = json.loads(stream.extractfile('.research-export.json').read()) + require(receipt['commit'] == SOURCE_HEAD, 'Exact baseline export head') + rows = {r['path']: r for r in receipt['files']} + require(len(rows) == len(receipt['files']) == 97, 'Complete baseline file census') + require({m.name for m in members} == set(rows) | {'.research-export.json'}, 'Exact baseline member set') + contents = {} + for member in members: + path = Path(member.name) + require(not path.is_absolute() and '..' not in path.parts and path.parts, 'Safe baseline path') + raw = stream.extractfile(member).read() + if member.name in rows: + row = rows[member.name] + require(len(raw) == row['size'] and sha256(raw).hexdigest() == row['sha256'], 'Exact baseline file bytes') + require(row['mode'] in (0o644, 0o755), 'Regular baseline file mode') + contents[member.name] = raw + return contents + + +@contextmanager +def baseline(): + contents = payload() + with tempfile.TemporaryDirectory(prefix='precision-linux-source-') as temporary: + root = Path(temporary) + try: + for name, raw in contents.items(): + path = root / name + path.parent.mkdir(parents=True, exist_ok=True) + path.write_bytes(raw) + path.chmod(0o444) + for path in root.rglob('*'): + if path.is_dir(): + path.chmod(0o555) + before = {str(p.relative_to(root)): [sha256(p.read_bytes()).hexdigest(), p.stat().st_mode & 0o777] + for p in root.rglob('*') if p.is_file()} + yield root / 'research/p104-single-pass-qualification' + after = {str(p.relative_to(root)): [sha256(p.read_bytes()).hexdigest(), p.stat().st_mode & 0o777] + for p in root.rglob('*') if p.is_file() and not p.is_symlink()} + require(after == before and not any(p.is_symlink() for p in root.rglob('*')), 'Baseline export unchanged') + finally: + for path in [root, *root.rglob('*')]: + if path.is_dir(): + path.chmod(0o755) diff --git a/research/fraction-zero-unit-feasibility/evidence/SOURCE-BINDINGS.json b/research/fraction-zero-unit-feasibility/evidence/SOURCE-BINDINGS.json new file mode 100644 index 0000000000..705d869cb1 --- /dev/null +++ b/research/fraction-zero-unit-feasibility/evidence/SOURCE-BINDINGS.json @@ -0,0 +1,5 @@ +{ + "PR5848": "66fb6c6b8683b37967e9d7f313b3df99a49d2406", + "module_sha256": "a4c743e79c55e9c2ac26deb6d87cb948b1b0fbe942e4f7912ccbfba55db4b32a", + "function_sha256": "379c0e7c1c5ab7433ab5ad2669c1bda1234dbf0530fc61b21bfbe83528f37f53" +} diff --git a/research/fraction-zero-unit-feasibility/evidence/actual-audit/receipt.json b/research/fraction-zero-unit-feasibility/evidence/actual-audit/receipt.json new file mode 100644 index 0000000000..69a54b9084 --- /dev/null +++ b/research/fraction-zero-unit-feasibility/evidence/actual-audit/receipt.json @@ -0,0 +1,26 @@ +{ + "exit": 0, + "label": "actual-audit", + "optimized": false, + "original_local_receipt_sha256": "5db579174f58f76bc4bcd19cb1ae1ab9ad046219abf778428340e5d7d62d5388", + "platform": "Linux-7.0.0-38-generic-x86_64-with-glibc2.39", + "python": "3.12.3 (main, Aug 31 2026, 10:18:26) [GCC 13.3.0]", + "runner_sha256": "1aee21813dda66eedf2cd28db2c70bb3a8545465e918cc62536fef43281af974", + "runtime_policy_sha256": "d9a4aa849bc96917106ce76ca97898226675569877d1b257612463faf2e42d30", + "sampled_process_group_rss_bytes": 107667456, + "source_bytes_and_modes_unchanged": true, + "source_inventory_sha256": "fd22d51f0eceefe67ab2d868eac484220d8e11abdd7ce198be0578d077a51655", + "status": "PASS", + "stderr_bytes": 0, + "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "stdout_bytes": 510, + "stdout_sha256": "f49c0de98255a96517ac588634cf1f42a0d99dbf6bf6041b27c73b8c64624669", + "termination": null, + "usage": { + "exit": 0, + "kernel_max_rss_kib": 103692, + "system_seconds": 0.07, + "user_seconds": 42.67 + }, + "wall_seconds": 42.80668038499425 +} diff --git a/research/fraction-zero-unit-feasibility/evidence/actual-audit/stderr.txt b/research/fraction-zero-unit-feasibility/evidence/actual-audit/stderr.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/research/fraction-zero-unit-feasibility/evidence/actual-audit/stdout.txt b/research/fraction-zero-unit-feasibility/evidence/actual-audit/stdout.txt new file mode 100644 index 0000000000..87a50cfd95 --- /dev/null +++ b/research/fraction-zero-unit-feasibility/evidence/actual-audit/stdout.txt @@ -0,0 +1 @@ +{"all_values_types_and_inputs_preserved": true, "baseline_trace_seconds": 20.17961209200439, "coordinates": 799, "derived_trace_seconds": 19.942737821984338, "events": 25984, "full_output_sha256": "954c7448ff74d78753828e9623ad44c46da9e5ce459420b6e50a5d47294250b9", "observed_seconds_removed": 0.2368742700200528, "profile_whole_qualifier_seconds": 38.31372155799181, "status": "PASS_FULL_ACTUAL_FRACTION_TRACE_EQUIVALENCE", "weights_sha256": "cf98bf5da5df28ec1ca3ca7e8723d740b98e142f31e94ff7ec36815cc387c373"} diff --git a/research/fraction-zero-unit-feasibility/evidence/actual-audit/usage.json b/research/fraction-zero-unit-feasibility/evidence/actual-audit/usage.json new file mode 100644 index 0000000000..d8eaf81a6e --- /dev/null +++ b/research/fraction-zero-unit-feasibility/evidence/actual-audit/usage.json @@ -0,0 +1 @@ +{"user_seconds":42.67,"system_seconds":0.07,"kernel_max_rss_kib":103692,"exit":0} diff --git a/research/fraction-zero-unit-feasibility/evidence/finite-code-binding-fixed/receipt.json b/research/fraction-zero-unit-feasibility/evidence/finite-code-binding-fixed/receipt.json new file mode 100644 index 0000000000..ac777a316a --- /dev/null +++ b/research/fraction-zero-unit-feasibility/evidence/finite-code-binding-fixed/receipt.json @@ -0,0 +1,26 @@ +{ + "exit": 0, + "label": "finite-code-binding-fixed", + "optimized": false, + "original_local_receipt_sha256": "76f301fa30b7519efa256d58eddc48bc21cd523ad486fcfe70872b3c51ab0d74", + "platform": "Linux-7.0.0-38-generic-x86_64-with-glibc2.39", + "python": "3.12.3 (main, Aug 31 2026, 10:18:26) [GCC 13.3.0]", + "runner_sha256": "230ecf45dc93ca64a3c615a5146e5fe456a1d12a62d1d7d1d8cfb61e5d1a9cfb", + "runtime_policy_sha256": "ae4783bf73619e3b1e423dd8edf5cf007a66083ba602b9507f88797bff18b5c8", + "sampled_process_group_rss_bytes": 29732864, + "source_bytes_and_modes_unchanged": true, + "source_inventory_sha256": "25de9a9eb88c55d831014cc174262b38b3f1f6ce0d1cf8d81fa5f3004341270d", + "status": "PASS", + "stderr_bytes": 0, + "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "stdout_bytes": 437, + "stdout_sha256": "a80c1c2d58ceb1d080a308d0d5b7710ad4fe55fb85b2998d0d08a14c258b57bf", + "termination": null, + "usage": { + "exit": 0, + "kernel_max_rss_kib": 27748, + "system_seconds": 0.02, + "user_seconds": 0.81 + }, + "wall_seconds": 0.8617779269989114 +} diff --git a/research/fraction-zero-unit-feasibility/evidence/finite-code-binding-fixed/stderr.txt b/research/fraction-zero-unit-feasibility/evidence/finite-code-binding-fixed/stderr.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/research/fraction-zero-unit-feasibility/evidence/finite-code-binding-fixed/stdout.txt b/research/fraction-zero-unit-feasibility/evidence/finite-code-binding-fixed/stdout.txt new file mode 100644 index 0000000000..80379fe8ac --- /dev/null +++ b/research/fraction-zero-unit-feasibility/evidence/finite-code-binding-fixed/stdout.txt @@ -0,0 +1 @@ +{"all_complete_values_and_types_equal": true, "cases": 241, "controls": ["returned-mutation-isolated", "source-drift", "Fraction-type-drift", "module-byte-drift", "live-code-drift", "wrong-signed-update", "omitted-witness", "omitted-rounded-sites", "wrong-zero-delta", "bad-role", "bad-scalar", "missing-weight", "restore-success", "restore-exception", "fresh-derivation"], "events": 10164, "status": "PASS_FINITE_FRACTION_FEASIBILITY"} diff --git a/research/fraction-zero-unit-feasibility/evidence/finite-code-binding-fixed/usage.json b/research/fraction-zero-unit-feasibility/evidence/finite-code-binding-fixed/usage.json new file mode 100644 index 0000000000..0ae3387303 --- /dev/null +++ b/research/fraction-zero-unit-feasibility/evidence/finite-code-binding-fixed/usage.json @@ -0,0 +1 @@ +{"user_seconds":0.81,"system_seconds":0.02,"kernel_max_rss_kib":27748,"exit":0} diff --git a/research/fraction-zero-unit-feasibility/evidence/finite-nested-guard-O/receipt.json b/research/fraction-zero-unit-feasibility/evidence/finite-nested-guard-O/receipt.json new file mode 100644 index 0000000000..713bdef62d --- /dev/null +++ b/research/fraction-zero-unit-feasibility/evidence/finite-nested-guard-O/receipt.json @@ -0,0 +1,26 @@ +{ + "exit": 0, + "label": "finite-nested-guard-O", + "optimized": true, + "original_local_receipt_sha256": "dfc851f2a88468236720cbee2c5a0f485c230027a40e979711f604bbf7c0a214", + "platform": "Linux-7.0.0-38-generic-x86_64-with-glibc2.39", + "python": "3.12.3 (main, Aug 31 2026, 10:18:26) [GCC 13.3.0]", + "runner_sha256": "230ecf45dc93ca64a3c615a5146e5fe456a1d12a62d1d7d1d8cfb61e5d1a9cfb", + "runtime_policy_sha256": "ae4783bf73619e3b1e423dd8edf5cf007a66083ba602b9507f88797bff18b5c8", + "sampled_process_group_rss_bytes": 29827072, + "source_bytes_and_modes_unchanged": true, + "source_inventory_sha256": "7a8ec6a1b79c325d5f9fdcf935448c9899db9cdfc4ccc26bfdaaf34ff009d174", + "status": "PASS", + "stderr_bytes": 0, + "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "stdout_bytes": 463, + "stdout_sha256": "a870a06ab4910cb027a73dc63df43aef0dcf55a2b938f0dd4efaffe503e5f3ac", + "termination": null, + "usage": { + "exit": 0, + "kernel_max_rss_kib": 27840, + "system_seconds": 0.02, + "user_seconds": 0.8 + }, + "wall_seconds": 0.8613314000249375 +} diff --git a/research/fraction-zero-unit-feasibility/evidence/finite-nested-guard-O/stderr.txt b/research/fraction-zero-unit-feasibility/evidence/finite-nested-guard-O/stderr.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/research/fraction-zero-unit-feasibility/evidence/finite-nested-guard-O/stdout.txt b/research/fraction-zero-unit-feasibility/evidence/finite-nested-guard-O/stdout.txt new file mode 100644 index 0000000000..284cacaf0f --- /dev/null +++ b/research/fraction-zero-unit-feasibility/evidence/finite-nested-guard-O/stdout.txt @@ -0,0 +1 @@ +{"all_complete_values_and_types_equal": true, "cases": 241, "controls": ["returned-mutation-isolated", "source-drift", "Fraction-type-drift", "module-byte-drift", "live-code-drift", "nested-live-code-drift", "wrong-signed-update", "omitted-witness", "omitted-rounded-sites", "wrong-zero-delta", "bad-role", "bad-scalar", "missing-weight", "restore-success", "restore-exception", "fresh-derivation"], "events": 10164, "status": "PASS_FINITE_FRACTION_FEASIBILITY"} diff --git a/research/fraction-zero-unit-feasibility/evidence/finite-nested-guard-O/usage.json b/research/fraction-zero-unit-feasibility/evidence/finite-nested-guard-O/usage.json new file mode 100644 index 0000000000..0efe5b41fc --- /dev/null +++ b/research/fraction-zero-unit-feasibility/evidence/finite-nested-guard-O/usage.json @@ -0,0 +1 @@ +{"user_seconds":0.80,"system_seconds":0.02,"kernel_max_rss_kib":27840,"exit":0} diff --git a/research/fraction-zero-unit-feasibility/evidence/finite-nested-guard/receipt.json b/research/fraction-zero-unit-feasibility/evidence/finite-nested-guard/receipt.json new file mode 100644 index 0000000000..715ca0b45b --- /dev/null +++ b/research/fraction-zero-unit-feasibility/evidence/finite-nested-guard/receipt.json @@ -0,0 +1,26 @@ +{ + "exit": 0, + "label": "finite-nested-guard", + "optimized": false, + "original_local_receipt_sha256": "1ed6618cdd48c743aa715cc6c198b5410d2e775f891500783b122dd1561c6889", + "platform": "Linux-7.0.0-38-generic-x86_64-with-glibc2.39", + "python": "3.12.3 (main, Aug 31 2026, 10:18:26) [GCC 13.3.0]", + "runner_sha256": "230ecf45dc93ca64a3c615a5146e5fe456a1d12a62d1d7d1d8cfb61e5d1a9cfb", + "runtime_policy_sha256": "ae4783bf73619e3b1e423dd8edf5cf007a66083ba602b9507f88797bff18b5c8", + "sampled_process_group_rss_bytes": 29671424, + "source_bytes_and_modes_unchanged": true, + "source_inventory_sha256": "7a8ec6a1b79c325d5f9fdcf935448c9899db9cdfc4ccc26bfdaaf34ff009d174", + "status": "PASS", + "stderr_bytes": 0, + "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "stdout_bytes": 463, + "stdout_sha256": "a870a06ab4910cb027a73dc63df43aef0dcf55a2b938f0dd4efaffe503e5f3ac", + "termination": null, + "usage": { + "exit": 0, + "kernel_max_rss_kib": 27688, + "system_seconds": 0.02, + "user_seconds": 0.84 + }, + "wall_seconds": 0.9129154940019362 +} diff --git a/research/fraction-zero-unit-feasibility/evidence/finite-nested-guard/stderr.txt b/research/fraction-zero-unit-feasibility/evidence/finite-nested-guard/stderr.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/research/fraction-zero-unit-feasibility/evidence/finite-nested-guard/stdout.txt b/research/fraction-zero-unit-feasibility/evidence/finite-nested-guard/stdout.txt new file mode 100644 index 0000000000..284cacaf0f --- /dev/null +++ b/research/fraction-zero-unit-feasibility/evidence/finite-nested-guard/stdout.txt @@ -0,0 +1 @@ +{"all_complete_values_and_types_equal": true, "cases": 241, "controls": ["returned-mutation-isolated", "source-drift", "Fraction-type-drift", "module-byte-drift", "live-code-drift", "nested-live-code-drift", "wrong-signed-update", "omitted-witness", "omitted-rounded-sites", "wrong-zero-delta", "bad-role", "bad-scalar", "missing-weight", "restore-success", "restore-exception", "fresh-derivation"], "events": 10164, "status": "PASS_FINITE_FRACTION_FEASIBILITY"} diff --git a/research/fraction-zero-unit-feasibility/evidence/finite-nested-guard/usage.json b/research/fraction-zero-unit-feasibility/evidence/finite-nested-guard/usage.json new file mode 100644 index 0000000000..62669a4968 --- /dev/null +++ b/research/fraction-zero-unit-feasibility/evidence/finite-nested-guard/usage.json @@ -0,0 +1 @@ +{"user_seconds":0.84,"system_seconds":0.02,"kernel_max_rss_kib":27688,"exit":0} diff --git a/research/fraction-zero-unit-feasibility/evidence/finite/receipt.json b/research/fraction-zero-unit-feasibility/evidence/finite/receipt.json new file mode 100644 index 0000000000..22304f1a81 --- /dev/null +++ b/research/fraction-zero-unit-feasibility/evidence/finite/receipt.json @@ -0,0 +1,25 @@ +{ + "exit": 1, + "label": "finite", + "optimized": false, + "original_local_receipt_sha256": "bd2d84ed4b85bfdaa524a5760948e5e70df786b9af5fa0195ba06f7a794845eb", + "platform": "Linux-7.0.0-38-generic-x86_64-with-glibc2.39", + "public_stderr_sha256": "f3a6302369515c2c315ecab16ef73eff47df58625115585489191a431dd1f0a3", + "python": "3.12.3 (main, Aug 31 2026, 10:18:26) [GCC 13.3.0]", + "runner_sha256": "230ecf45dc93ca64a3c615a5146e5fe456a1d12a62d1d7d1d8cfb61e5d1a9cfb", + "runtime_policy_sha256": "ae4783bf73619e3b1e423dd8edf5cf007a66083ba602b9507f88797bff18b5c8", + "sampled_process_group_rss_bytes": 40542208, + "source_bytes_and_modes_unchanged": true, + "source_inventory_sha256": "1414b1fa9bd02a1f8fca1d62c8bfd97ac1ecca9aa915ae42dca7e6680ab32c33", + "status": "STOP", + "stderr_bytes": 1096, + "stderr_redaction": "Only workspace prefix replaced by ; original stderr hash retained.", + "stderr_sha256": "ed3fa16b94df8da0beb106fd45369805621e4b03a31f1a4366c3d160d405abef", + "stdout_bytes": 0, + "stdout_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "termination": null, + "usage": { + "raw": "Command exited with non-zero status 1\n{\"user_seconds\":0.81,\"system_seconds\":0.04,\"kernel_max_rss_kib\":38140,\"exit\":1}\n" + }, + "wall_seconds": 0.9278320000157692 +} diff --git a/research/fraction-zero-unit-feasibility/evidence/finite/stderr.txt b/research/fraction-zero-unit-feasibility/evidence/finite/stderr.txt new file mode 100644 index 0000000000..fa5a0f04f0 --- /dev/null +++ b/research/fraction-zero-unit-feasibility/evidence/finite/stderr.txt @@ -0,0 +1,12 @@ +Traceback (most recent call last): + File "/outputs/fraction-reference-feasibility-20261027/runtime/../feasibility/finite.py", line 118, in + if __name__=='__main__':main() + ^^^^^^ + File "/outputs/fraction-reference-feasibility-20261027/runtime/../feasibility/finite.py", line 62, in main + fast=derive(ref) + ^^^^^^^^^^^ + File "/outputs/fraction-reference-feasibility-20261027/feasibility/fraction_fast.py", line 75, in derive + need(code_shape(original.__code__) == code_shape(namespace['error_trace'].__code__), 'live Fraction code agrees with source') + File "/outputs/fraction-reference-feasibility-20261027/feasibility/fraction_fast.py", line 45, in need + raise ValueError(message) +ValueError: live Fraction code agrees with source diff --git a/research/fraction-zero-unit-feasibility/evidence/finite/stdout.txt b/research/fraction-zero-unit-feasibility/evidence/finite/stdout.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/research/fraction-zero-unit-feasibility/evidence/finite/usage.json b/research/fraction-zero-unit-feasibility/evidence/finite/usage.json new file mode 100644 index 0000000000..527cefbab6 --- /dev/null +++ b/research/fraction-zero-unit-feasibility/evidence/finite/usage.json @@ -0,0 +1,2 @@ +Command exited with non-zero status 1 +{"user_seconds":0.81,"system_seconds":0.04,"kernel_max_rss_kib":38140,"exit":1} diff --git a/research/fraction-zero-unit-feasibility/evidence/packaged-O/receipt.json b/research/fraction-zero-unit-feasibility/evidence/packaged-O/receipt.json new file mode 100644 index 0000000000..d6700d3a24 --- /dev/null +++ b/research/fraction-zero-unit-feasibility/evidence/packaged-O/receipt.json @@ -0,0 +1,26 @@ +{ + "exit": 0, + "label": "packaged-O", + "optimized": true, + "original_local_receipt_sha256": "a08f080c1b76abe84e7cc110c96f9af6c3875c11990a275c00e4db85e59d9bc9", + "platform": "Linux-7.0.0-38-generic-x86_64-with-glibc2.39", + "python": "3.12.3 (main, Aug 31 2026, 10:18:26) [GCC 13.3.0]", + "runner_sha256": "1aee21813dda66eedf2cd28db2c70bb3a8545465e918cc62536fef43281af974", + "runtime_policy_sha256": "911a625b0ac71c69d37d79f3cb69b740f702b292a5fdfaff8a2f62436d8322cb", + "sampled_process_group_rss_bytes": 28942336, + "source_bytes_and_modes_unchanged": true, + "source_inventory_sha256": "d4be1508094086f483fd061becc9e519b830247f28148c5b297124727b1c7ba0", + "status": "PASS", + "stderr_bytes": 0, + "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "stdout_bytes": 515, + "stdout_sha256": "2babc2d0840abbd90bfaedadcf9be8d2269a8edd4de98d51ecce0197d5aa50a1", + "termination": null, + "usage": { + "exit": 0, + "kernel_max_rss_kib": 26980, + "system_seconds": 0.02, + "user_seconds": 0.85 + }, + "wall_seconds": 0.9117185460054316 +} diff --git a/research/fraction-zero-unit-feasibility/evidence/packaged-O/stderr.txt b/research/fraction-zero-unit-feasibility/evidence/packaged-O/stderr.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/research/fraction-zero-unit-feasibility/evidence/packaged-O/stdout.txt b/research/fraction-zero-unit-feasibility/evidence/packaged-O/stdout.txt new file mode 100644 index 0000000000..e80b80784d --- /dev/null +++ b/research/fraction-zero-unit-feasibility/evidence/packaged-O/stdout.txt @@ -0,0 +1,2 @@ +{"all_complete_values_and_types_equal": true, "cases": 241, "controls": ["returned-mutation-isolated", "source-drift", "Fraction-type-drift", "module-byte-drift", "live-code-drift", "nested-live-code-drift", "wrong-signed-update", "omitted-witness", "omitted-rounded-sites", "wrong-zero-delta", "bad-role", "bad-scalar", "missing-weight", "restore-success", "restore-exception", "fresh-derivation"], "events": 10164, "status": "PASS_FINITE_FRACTION_FEASIBILITY"} +PASS_SCOPED_NEGATIVE_FEASIBILITY_FINITE_REPLAY_ONLY diff --git a/research/fraction-zero-unit-feasibility/evidence/packaged-O/usage.json b/research/fraction-zero-unit-feasibility/evidence/packaged-O/usage.json new file mode 100644 index 0000000000..f8330e25a2 --- /dev/null +++ b/research/fraction-zero-unit-feasibility/evidence/packaged-O/usage.json @@ -0,0 +1 @@ +{"user_seconds":0.85,"system_seconds":0.02,"kernel_max_rss_kib":26980,"exit":0} diff --git a/research/fraction-zero-unit-feasibility/evidence/packaged-normal/receipt.json b/research/fraction-zero-unit-feasibility/evidence/packaged-normal/receipt.json new file mode 100644 index 0000000000..cf632fdd61 --- /dev/null +++ b/research/fraction-zero-unit-feasibility/evidence/packaged-normal/receipt.json @@ -0,0 +1,26 @@ +{ + "exit": 0, + "label": "packaged-normal", + "optimized": false, + "original_local_receipt_sha256": "255ae84aa47484864e112fa1f7e9978cb6e6dc7919deb785b6b2d83b61aad897", + "platform": "Linux-7.0.0-38-generic-x86_64-with-glibc2.39", + "python": "3.12.3 (main, Aug 31 2026, 10:18:26) [GCC 13.3.0]", + "runner_sha256": "1aee21813dda66eedf2cd28db2c70bb3a8545465e918cc62536fef43281af974", + "runtime_policy_sha256": "911a625b0ac71c69d37d79f3cb69b740f702b292a5fdfaff8a2f62436d8322cb", + "sampled_process_group_rss_bytes": 28774400, + "source_bytes_and_modes_unchanged": true, + "source_inventory_sha256": "d4be1508094086f483fd061becc9e519b830247f28148c5b297124727b1c7ba0", + "status": "PASS", + "stderr_bytes": 0, + "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "stdout_bytes": 515, + "stdout_sha256": "2babc2d0840abbd90bfaedadcf9be8d2269a8edd4de98d51ecce0197d5aa50a1", + "termination": null, + "usage": { + "exit": 0, + "kernel_max_rss_kib": 26788, + "system_seconds": 0.02, + "user_seconds": 0.8 + }, + "wall_seconds": 0.8610072860028595 +} diff --git a/research/fraction-zero-unit-feasibility/evidence/packaged-normal/stderr.txt b/research/fraction-zero-unit-feasibility/evidence/packaged-normal/stderr.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/research/fraction-zero-unit-feasibility/evidence/packaged-normal/stdout.txt b/research/fraction-zero-unit-feasibility/evidence/packaged-normal/stdout.txt new file mode 100644 index 0000000000..e80b80784d --- /dev/null +++ b/research/fraction-zero-unit-feasibility/evidence/packaged-normal/stdout.txt @@ -0,0 +1,2 @@ +{"all_complete_values_and_types_equal": true, "cases": 241, "controls": ["returned-mutation-isolated", "source-drift", "Fraction-type-drift", "module-byte-drift", "live-code-drift", "nested-live-code-drift", "wrong-signed-update", "omitted-witness", "omitted-rounded-sites", "wrong-zero-delta", "bad-role", "bad-scalar", "missing-weight", "restore-success", "restore-exception", "fresh-derivation"], "events": 10164, "status": "PASS_FINITE_FRACTION_FEASIBILITY"} +PASS_SCOPED_NEGATIVE_FEASIBILITY_FINITE_REPLAY_ONLY diff --git a/research/fraction-zero-unit-feasibility/evidence/packaged-normal/usage.json b/research/fraction-zero-unit-feasibility/evidence/packaged-normal/usage.json new file mode 100644 index 0000000000..d479369f2a --- /dev/null +++ b/research/fraction-zero-unit-feasibility/evidence/packaged-normal/usage.json @@ -0,0 +1 @@ +{"user_seconds":0.80,"system_seconds":0.02,"kernel_max_rss_kib":26788,"exit":0} diff --git a/research/fraction-zero-unit-feasibility/evidence/profile-census-fixed/receipt.json b/research/fraction-zero-unit-feasibility/evidence/profile-census-fixed/receipt.json new file mode 100644 index 0000000000..c9c8dcb977 --- /dev/null +++ b/research/fraction-zero-unit-feasibility/evidence/profile-census-fixed/receipt.json @@ -0,0 +1,26 @@ +{ + "exit": 0, + "label": "profile-census-fixed", + "optimized": false, + "original_local_receipt_sha256": "be8a007eae2f511ccd4016b320073ade645a9809d196ca0a6c71cc96ae7d658f", + "platform": "Linux-7.0.0-38-generic-x86_64-with-glibc2.39", + "python": "3.12.3 (main, Aug 31 2026, 10:18:26) [GCC 13.3.0]", + "runner_sha256": "186e1467239d3d60c0606b062e36e505aae2c14c422447e3490f088775ed6784", + "runtime_policy_sha256": "a618b9cb0985a4da96c76810ef84a38a0f3a92b5932d335b1d34bafda525c184", + "sampled_process_group_rss_bytes": 123142144, + "source_bytes_and_modes_unchanged": true, + "source_inventory_sha256": "f9a98d46ea8d720ecdb944eba3ab0e7ed3b49f6479bc357432c1389ec81622ed", + "status": "PASS", + "stderr_bytes": 0, + "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "stdout_bytes": 2067, + "stdout_sha256": "4947828e4dcac41063c097fa0544da909ac1287123a40e3bfd37533936f01d65", + "termination": null, + "usage": { + "exit": 0, + "kernel_max_rss_kib": 118804, + "system_seconds": 0.08, + "user_seconds": 38.15 + }, + "wall_seconds": 38.31372155799181 +} diff --git a/research/fraction-zero-unit-feasibility/evidence/profile-census-fixed/stderr.txt b/research/fraction-zero-unit-feasibility/evidence/profile-census-fixed/stderr.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/research/fraction-zero-unit-feasibility/evidence/profile-census-fixed/stdout.txt b/research/fraction-zero-unit-feasibility/evidence/profile-census-fixed/stdout.txt new file mode 100644 index 0000000000..68473b7a0f --- /dev/null +++ b/research/fraction-zero-unit-feasibility/evidence/profile-census-fixed/stdout.txt @@ -0,0 +1,5 @@ +PASS_PRECISION_LINUX_SOURCE_CONTROLS {"contract": "declared contract edits", "declared_edit": "unique backend seam", "inner_archive": "source hash", "official_export_byte": "Exact PR5831 bundle"} +{"backends": 2, "controls": ["one-use", "closed-call", "missing", "duplicate", "changed-weights", "changed-rounding", "changed-word", "original-malformed-rejection", "propagated-exception", "failed-finish", "failed-take", "fresh-context-not-previous-pass", "aborted-take", "one-use", "closed-call", "missing", "duplicate", "changed-weights", "changed-rounding", "changed-word", "original-malformed-rejection", "propagated-exception", "failed-finish", "failed-take", "fresh-context-not-previous-pass", "aborted-take", "input-mutation"], "events": 5, "status": "PASS_FINITE_FEASIBILITY_ONLY"} +PASS_P104_SINGLE_PASS_QUALIFICATION +{"mode": "qualify", "receipt": {"all_actual_witness_rows_equal": true, "coefficient_scale_bits": 55, "coordinates": 799, "events": 25984, "finite_fixtures": {"cases": 120, "controls": ["nondyadic scalar", "inexact scale division", "nondyadic weight"], "events": 4240}, "guards": {"owned": 22, "prefix": 26, "public": 23}, "source_controls": 6, "source_result_sha256": "cc7739703ed23532d187949c8507d09c13ac4c152e07a930f0087cde0d7a3d98"}, "seconds": 37.915092} +{"inclusive_profiles": {"Fraction.calculate.inclusive": [1, 29.56573735800339], "Fraction.error_trace": [1, 20.052949415985495], "Fraction.execute": [6, 0.5582490059896372], "Fraction.ideal": [4, 4.049590509006521], "Fraction.reverse_all": [1, 2.8532538060098886], "Fraction.reverse_cut": [4, 0.07846067700302228], "integer.calculate.inclusive": [1, 7.428388572006952], "integer.error_trace": [121, 3.0883288670156617], "integer.ideal": [4, 0.8438016349391546], "integer.reverse_all": [121, 1.0509023397462443], "observation.calls.inclusive": [35, 30.843270772049436], "observation.deepcopy": [16, 0.11094509204849601], "observation.take": [18, 0.30852267597219907], "reference.digest": [44, 3.5292127177817747]}, "seconds": 38.02564648500993, "status": "PASS_FULL_QUALIFIER_PROFILE"} diff --git a/research/fraction-zero-unit-feasibility/evidence/profile-census-fixed/usage.json b/research/fraction-zero-unit-feasibility/evidence/profile-census-fixed/usage.json new file mode 100644 index 0000000000..f0ceabb55f --- /dev/null +++ b/research/fraction-zero-unit-feasibility/evidence/profile-census-fixed/usage.json @@ -0,0 +1 @@ +{"user_seconds":38.15,"system_seconds":0.08,"kernel_max_rss_kib":118804,"exit":0} diff --git a/research/fraction-zero-unit-feasibility/evidence/profile/receipt.json b/research/fraction-zero-unit-feasibility/evidence/profile/receipt.json new file mode 100644 index 0000000000..3b5c1f2ccc --- /dev/null +++ b/research/fraction-zero-unit-feasibility/evidence/profile/receipt.json @@ -0,0 +1,25 @@ +{ + "exit": 1, + "label": "profile", + "optimized": false, + "original_local_receipt_sha256": "3e684a4ae46d06ef074b41e6132a3d34640305a0e971e61873b8caf21e4961e7", + "platform": "Linux-7.0.0-38-generic-x86_64-with-glibc2.39", + "public_stderr_sha256": "cac73c837c55ef4d317bab7bbd80a347ed162bf1e84d7fbc2011a2ab5f8722c4", + "python": "3.12.3 (main, Aug 31 2026, 10:18:26) [GCC 13.3.0]", + "runner_sha256": "186e1467239d3d60c0606b062e36e505aae2c14c422447e3490f088775ed6784", + "runtime_policy_sha256": "a618b9cb0985a4da96c76810ef84a38a0f3a92b5932d335b1d34bafda525c184", + "sampled_process_group_rss_bytes": 40267776, + "source_bytes_and_modes_unchanged": true, + "source_inventory_sha256": "07bc9b9fd072f912c28e76ad791330264b5ee1568ba16b3c098780a78540191e", + "status": "STOP", + "stderr_bytes": 1109, + "stderr_redaction": "Only workspace prefix replaced by ; original stderr hash retained.", + "stderr_sha256": "a6a880082bf127e6ef1959c9aaf0d3c256bf49da4be1f349f3ed73959e41d261", + "stdout_bytes": 0, + "stdout_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "termination": null, + "usage": { + "raw": "Command exited with non-zero status 1\n{\"user_seconds\":0.60,\"system_seconds\":0.01,\"kernel_max_rss_kib\":37872,\"exit\":1}\n" + }, + "wall_seconds": 0.6592222199833486 +} diff --git a/research/fraction-zero-unit-feasibility/evidence/profile/stderr.txt b/research/fraction-zero-unit-feasibility/evidence/profile/stderr.txt new file mode 100644 index 0000000000..7b0aab988c --- /dev/null +++ b/research/fraction-zero-unit-feasibility/evidence/profile/stderr.txt @@ -0,0 +1,14 @@ +Traceback (most recent call last): + File "/outputs/fraction-reference-feasibility-20261027/runtime/profile.py", line 22, in + with baseline() as package: + File "/usr/lib/python3.12/contextlib.py", line 137, in __enter__ + return next(self.gen) + ^^^^^^^^^^^^^^ + File "/outputs/fraction-reference-feasibility-20261027/runtime/frozen.py", line 46, in baseline + contents = payload() + ^^^^^^^^^ + File "/outputs/fraction-reference-feasibility-20261027/runtime/frozen.py", line 24, in payload + require(len(members) == 98 and len({m.name for m in members}) == 14, 'Complete unique baseline bundle') + File "/outputs/fraction-reference-feasibility-20261027/runtime/frozen.py", line 16, in require + raise ValueError(why) +ValueError: Complete unique baseline bundle diff --git a/research/fraction-zero-unit-feasibility/evidence/profile/stdout.txt b/research/fraction-zero-unit-feasibility/evidence/profile/stdout.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/research/fraction-zero-unit-feasibility/evidence/profile/usage.json b/research/fraction-zero-unit-feasibility/evidence/profile/usage.json new file mode 100644 index 0000000000..296b0e1037 --- /dev/null +++ b/research/fraction-zero-unit-feasibility/evidence/profile/usage.json @@ -0,0 +1,2 @@ +Command exited with non-zero status 1 +{"user_seconds":0.60,"system_seconds":0.01,"kernel_max_rss_kib":37872,"exit":1} diff --git a/research/fraction-zero-unit-feasibility/evidence/recorded-dispatch.py.txt b/research/fraction-zero-unit-feasibility/evidence/recorded-dispatch.py.txt new file mode 100644 index 0000000000..f28b5251b7 --- /dev/null +++ b/research/fraction-zero-unit-feasibility/evidence/recorded-dispatch.py.txt @@ -0,0 +1,6 @@ +import guard,sys +label=sys.argv[1] +script='../feasibility/finite.py' if label.startswith('finite') else '../feasibility/actual_audit.py' if label=='actual-audit' else 'profile.py' +with (guard.HERE/'execution.lock').open('a') as lock: + guard.fcntl.flock(lock,guard.fcntl.LOCK_EX|guard.fcntl.LOCK_NB) + guard.run(label,script,optimized=label.endswith('-O')) diff --git a/research/fraction-zero-unit-feasibility/evidence/recorded-guard.py.txt b/research/fraction-zero-unit-feasibility/evidence/recorded-guard.py.txt new file mode 100644 index 0000000000..c4fea8aa9b --- /dev/null +++ b/research/fraction-zero-unit-feasibility/evidence/recorded-guard.py.txt @@ -0,0 +1,120 @@ +"""Serial bounded Linux measurements; preserve the complete frozen precision contract.""" +import argparse +import fcntl +import hashlib +import json +import os +from pathlib import Path +import platform +import signal +import statistics +import subprocess +import sys +import tempfile +import time + +HERE = Path(__file__).resolve().parent +SOURCE = HERE +CLOSURE = ('frozen.py','profile.py','guard.py','dispatch.py','inputs/PR5848.tar','../feasibility/fraction_fast.py','../feasibility/finite.py','../feasibility/actual_audit.py') +TIMEOUT = 180 +RSS_CAP = 1024**3 +OUTPUT_CAP = 2*1024**2 +AGGREGATE = 600 +PREVIOUS_WALL_SECONDS = 0 + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + +def inventory(): + result = {} + for name in CLOSURE: + path = SOURCE / name + if path.is_symlink() or not path.is_file(): + raise ValueError('Regular complete runtime file: ' + name) + result[name] = [sha(path.read_bytes()), path.stat().st_mode & 0o777] + return result + +def group_rss(group): + total = 0 + count = 0 + for p in Path('/proc').iterdir(): + if not p.name.isdigit(): + continue + try: + raw = (p/'stat').read_text() + fields = raw[raw.rfind(')')+2:].split() + if int(fields[2]) == group: + total += int(fields[21])*os.sysconf('SC_PAGE_SIZE') + count += 1 + except (FileNotFoundError, ProcessLookupError, PermissionError): + pass + return total, count + +def run(label, script, optimized=False): + records = HERE/'runs' + records.mkdir(exist_ok=True) + prior = list(records.glob('*/receipt.json')) + spent = PREVIOUS_WALL_SECONDS + sum(json.loads(p.read_bytes())['wall_seconds'] for p in prior) + if spent >= AGGREGATE: + raise ValueError('Aggregate budget consumed') + folder = records/label + folder.mkdir() + before = inventory() + env = os.environ.copy() + for key in ('PYTHONPATH','PYTHONOPTIMIZE','PYTHONINSPECT','PYTHONSTARTUP','PYTHONPYCACHEPREFIX'): + env.pop(key,None) + env.update(PYTHONHASHSEED='0', LC_ALL='C.UTF-8', TZ='UTC') + usage = folder/'usage.json' + with tempfile.TemporaryDirectory(prefix='linux5757-bytecode-') as cache: + command = ['/usr/bin/python3.12', '-B', '-X', 'pycache_prefix='+cache] + if optimized: + command.append('-O') + command.append(str(SOURCE/script)) + timed = ['/usr/bin/time','-f','{"user_seconds":%U,"system_seconds":%S,"kernel_max_rss_kib":%M,"exit":%x}', '-o', str(usage),'--',*command] + start = time.monotonic() + peak = 0 + stop = None + with (folder/'stdout.txt').open('wb') as out, (folder/'stderr.txt').open('wb') as err: + p = subprocess.Popen(timed, cwd=SOURCE, env=env, stdout=out, stderr=err, start_new_session=True) + try: + while p.poll() is None: + rss, _ = group_rss(p.pid) + peak = max(peak,rss) + elapsed = time.monotonic()-start + if rss > RSS_CAP: + stop='sampled_group_rss_cap' + elif elapsed > min(TIMEOUT,AGGREGATE-spent): + stop='wall_or_aggregate_cap' + elif max((folder/'stdout.txt').stat().st_size,(folder/'stderr.txt').stat().st_size)>OUTPUT_CAP: + stop='output_cap' + if stop: + os.killpg(p.pid,signal.SIGKILL) + break + time.sleep(0.05) + code=p.wait() + finally: + try: os.killpg(p.pid,signal.SIGKILL) + except ProcessLookupError: pass + p.wait() + elapsed = time.monotonic()-start + stdout=(folder/'stdout.txt').read_bytes() + stderr=(folder/'stderr.txt').read_bytes() + after=inventory() + measurement=None + if usage.exists(): + try: measurement=json.loads(usage.read_bytes()) + except json.JSONDecodeError: measurement={'raw':usage.read_text()} + receipt={'label':label,'script':script,'optimized':optimized,'wall_seconds':elapsed, + 'exit':code,'termination':stop,'sampled_process_group_rss_bytes':peak, + 'usage':measurement,'stdout_sha256':sha(stdout),'stdout_bytes':len(stdout), + 'stderr_sha256':sha(stderr),'stderr_bytes':len(stderr), + 'source_inventory_sha256':sha(json.dumps(before,sort_keys=True,separators=(',',':')).encode()), + 'source_bytes_and_modes_unchanged':before==after, + 'python':sys.version,'platform':platform.platform(), + 'runner_sha256':sha(Path(__file__).read_bytes()),'runtime_policy_sha256':sha(json.dumps(CLOSURE).encode())} + receipt['status']='PASS' if code==0 and stop is None and not stderr and before==after else 'STOP' + (folder/'receipt.json').write_text(json.dumps(receipt,indent=2,sort_keys=True)+'\n') + print(json.dumps(receipt,sort_keys=True),flush=True) + if receipt['status']!='PASS': + raise SystemExit(1) + return receipt diff --git a/research/fraction-zero-unit-feasibility/evidence/recorded-profile.py.txt b/research/fraction-zero-unit-feasibility/evidence/recorded-profile.py.txt new file mode 100644 index 0000000000..c20c680de9 --- /dev/null +++ b/research/fraction-zero-unit-feasibility/evidence/recorded-profile.py.txt @@ -0,0 +1,67 @@ +"""Observe complete frozen PR5848 qualification, excluding timing from benchmarks.""" +from collections import defaultdict +import importlib.util +import json +import runpy +import sys +import time +from frozen import baseline, require + +rows = defaultdict(lambda: [0, 0.0]) +def observe(obj, name, label): + original = getattr(obj, name) + def wrapped(*args, **kwargs): + started = time.perf_counter() + try: + return original(*args, **kwargs) + finally: + rows[label][0] += 1 + rows[label][1] += time.perf_counter()-started + setattr(obj, name, wrapped) + +with baseline() as package: + sys.path.insert(0, str(package)) + import candidate, observe as observation + observe(observation, 'deepcopy', 'observation.deepcopy') + observe(observation.Observation, 'take', 'observation.take') + observe(observation.Observation, '_call', 'observation.calls.inclusive') + native_spec = importlib.util.spec_from_file_location + def spec(name, path, *args, **kwargs): + value = native_spec(name, path, *args, **kwargs) + if name == 'single_pass_source': + execute = value.loader.exec_module + def observed_execute(module): + execute(module) + load = module.load + def observed_load(n, p): + m = load(n, p) + if n == 'frozen_contract': + factory = m.module + def observed_factory(n2, p2): + a = factory(n2, p2) + if n2 == 'noisy_precision': + for f in ('ideal','error_trace','reverse_all','reverse_cut','execute'): + observe(a, f, 'Fraction.'+f) + return a + m.module = observed_factory + observe(m, 'calculate', 'Fraction.calculate.inclusive') + elif n == 'frozen_precision': + observe(m,'digest','reference.digest') + elif n == 'integer_backend': + for f in ('ideal','error_trace','reverse_all'): + observe(m.Engine,f,'integer.'+f) + elif n == 'explicit_contract': + observe(m,'calculate','integer.calculate.inclusive') + return m + module.load = observed_load + value.loader.exec_module = observed_execute + return value + importlib.util.spec_from_file_location = spec + started = time.perf_counter() + try: + sys.argv = [str(package/'verify.py')] + runpy.run_path(sys.argv[0], run_name='__main__') + finally: + importlib.util.spec_from_file_location = native_spec + seconds = time.perf_counter()-started + print(json.dumps({'status':'PASS_FULL_QUALIFIER_PROFILE','seconds':seconds,'inclusive_profiles':dict(rows)},sort_keys=True)) diff --git a/research/fraction-zero-unit-feasibility/finite.py b/research/fraction-zero-unit-feasibility/finite.py new file mode 100644 index 0000000000..86a1e142b5 --- /dev/null +++ b/research/fraction-zero-unit-feasibility/finite.py @@ -0,0 +1,125 @@ +"""Finite gate before construction, using the actual frozen Fraction source.""" +from copy import deepcopy +from fractions import Fraction as F +import importlib.util +import inspect +import json +from pathlib import Path +import random +import sys +import tempfile +import types +from frozen import baseline, require +from fraction_fast import derive, installed, transformed + + +def types_of(value): + if isinstance(value, dict): + return ('dict', {k:types_of(v) for k,v in value.items()}) + if isinstance(value, (list, tuple)): + return (type(value).__name__, [types_of(v) for v in value]) + return type(value).__name__ + + +def fixtures(): + rng = random.Random(5848) + special = [['ADD',0,1,1,0],['ADD',1,0,1,0],['ADD',1,0,-2,0], + ['ADD',1,0,1,0],['COPY',2,1,-1,0],['SCALE',1,'1/2',0], + ['MOVE',2,0,0,False],['INIT',2,0],['CLEAR',2,0]] + yield dict(public=2,owned_fields=1,program=special), [(F(1),F(1))]*len(special), {'ADD','COPY','SCALE','INIT','CLEAR','MOVE'} + scalars = ['1','-1','1/2','-3/8','2','-4','5/16'] + for case in range(240): + n = 3+case%6 + program = [] + for i in range(case%95): + op = rng.choice(['INIT','CLEAR','MOVE','ADD','COPY','SCALE']) + r = rng.randrange(n) + if op in ('INIT','CLEAR'):event=[op,r,0] + elif op=='MOVE':event=[op,r,0,0,False] + elif op=='SCALE':event=[op,r,rng.choice(scalars),0] + else:event=[op,r,rng.choice([s for s in range(n) if s!=r]),rng.choice(scalars),0] + program.append(event) + weights=[(F(rng.randrange(6),2**rng.randrange(7)),F(rng.randrange(5),2**rng.randrange(6))) for e in program] + rounded={op for op in ('INIT','CLEAR','MOVE','ADD','COPY','SCALE') if rng.randrange(2)} + yield dict(public=n-1,owned_fields=1,program=program),weights,rounded + + +def main(): + results=[] + def rejects(label, action, exception=ValueError): + try:action() + except exception:results.append(label) + else:raise ValueError('accepted '+label) + with baseline() as package: + sys.path.insert(0,str(package)) + import source + with source.baseline() as p: + spec=importlib.util.spec_from_file_location('finite_precision_entry',p/'verify.py') + v=importlib.util.module_from_spec(spec);spec.loader.exec_module(v) + with v.source() as (_,original,ref): + old=ref.error_trace + fast=derive(ref) + cases=list(fixtures());events=0 + for word,weights,rounded in cases: + before=deepcopy((word,weights,rounded)) + a=old(word,weights,rounded);b=fast(word,weights,rounded) + require(a==b and types_of(a)==types_of(b),'complete finite output and numeric types') + require((word,weights,rounded)==before,'inputs remain unchanged') + events+=len(word['program']) + word,weights,rounded=cases[0] + value=fast(word,weights,rounded);value[0]['final_scores'][0][0]=F(999) + require(fast(word,weights,rounded)==old(word,weights,rounded),'fresh mutable output') + results.append('returned-mutation-isolated') + raw=inspect.getsource(old) + rejects('source-drift',lambda:transformed(raw+'\n# drift\n')) + saved_F=ref.F;ref.F=int + try:rejects('Fraction-type-drift',lambda:derive(ref)) + finally:ref.F=saved_F + with tempfile.TemporaryDirectory() as td: + file=Path(td)/'precision.py';file.write_bytes(Path(ref.__file__).read_bytes()+b'\n# drift\n') + saved_file=ref.__file__;ref.__file__=str(file) + try:rejects('module-byte-drift',lambda:derive(ref)) + finally:ref.__file__=saved_file + code=old.__code__.replace(co_consts=('live-code-drift',)+old.__code__.co_consts[1:]) + ref.error_trace=types.FunctionType(code,old.__globals__) + try:rejects('live-code-drift',lambda:derive(ref)) + finally:ref.error_trace=old + constants=list(old.__code__.co_consts) + index=next(i for i,c in enumerate(constants) if isinstance(c,types.CodeType)) + constants[index]=constants[index].replace(co_consts=constants[index].co_consts+('nested-code-drift',)) + ref.error_trace=types.FunctionType(old.__code__.replace(co_consts=tuple(constants)),old.__globals__) + try:rejects('nested-live-code-drift',lambda:derive(ref)) + finally:ref.error_trace=old + for label,change in [ + ('wrong-signed-update',('value = old + (','value = old - (')), + ('omitted-witness',('witness[k] = dict(rows[r])','witness[k] = {}')), + ('omitted-rounded-sites',('if op in rounded:','if False:')), + ('wrong-zero-delta',('elif change:\n','else:\n'))]: + text=transformed(raw) + if label=='wrong-zero-delta': + text=text.replace('elif change:\n','else:\n').replace('scores[r][2] += change','scores[r][2] += ONE') + else: + require(change[0] in text,'mutant site');text=text.replace(*change) + ns=dict(ref.__dict__);exec(compile(text,'','exec'),ns) + require(any(ns['error_trace'](*c)!=old(*c) for c in cases),'mutant rejected '+label) + results.append(label) + for label,bad_word,bad_weights in [('bad-role',dict(public=2,owned_fields=0,program=[['ADD',99,0,1,0]]),[(F(1),F(1))]),('bad-scalar',dict(public=2,owned_fields=0,program=[['ADD',0,1,'bad',0]]),[(F(1),F(1))]),('missing-weight',word,[])]: + errors=[] + for fn in (old,fast): + try:fn(bad_word,bad_weights,rounded) + except (IndexError,ValueError) as e:errors.append((type(e).__name__,str(e))) + else:raise ValueError('missing original exception '+label) + require(errors[0]==errors[1],'same original exception '+label);results.append(label) + with installed(ref) as f: + require(ref.error_trace is f and f(*cases[0])==old(*cases[0]),'scoped install') + require(ref.error_trace is old,'restore on success');results.append('restore-success') + try: + with installed(ref):raise RuntimeError('caller-failure') + except RuntimeError:pass + require(ref.error_trace is old,'restore on exception');results.append('restore-exception') + require(derive(ref)(*cases[0])==old(*cases[0]),'fresh derivation');results.append('fresh-derivation') + require(len(results)==16,'finite control census') + result={'status':'PASS_FINITE_FRACTION_FEASIBILITY','cases':len(cases),'events':events,'controls':results,'all_complete_values_and_types_equal':True} + print(json.dumps(result,sort_keys=True)) + return result +if __name__=='__main__':main() diff --git a/research/fraction-zero-unit-feasibility/fraction_fast.py b/research/fraction-zero-unit-feasibility/fraction_fast.py new file mode 100644 index 0000000000..175d1bd3ac --- /dev/null +++ b/research/fraction-zero-unit-feasibility/fraction_fast.py @@ -0,0 +1,95 @@ +"""Derive exact Fraction zero/unit shortcuts from one authenticated function. + +Original arithmetic: Ali Romman and retained completed-error lineage. +Derivation and checks: Chris R / Clear1nsight, substantial OpenAI Codex assistance. +Apache-2.0. No approximate arithmetic or integer-backend sharing. +""" +from contextlib import contextmanager +from fractions import Fraction +from hashlib import sha256 +import inspect +from pathlib import Path +from types import CodeType + +MODULE_SHA256 = 'a4c743e79c55e9c2ac26deb6d87cb948b1b0fbe942e4f7912ccbfba55db4b32a' +FUNCTION_SHA256 = '379c0e7c1c5ab7433ab5ad2669c1bda1234dbf0530fc61b21bfbe83528f37f53' +BEFORE = ''' for i, v in rows[event[2]].items(): + old = rows[r].get(i, F(0)) + value = old + q*v + change = abs(value)-abs(old) + scores[r][0] += change*weights[i][0] + scores[r][1] += change*weights[i][1] + scores[r][2] += change +''' +AFTER = ''' unit, negative_unit = q == ONE, q == NEGATIVE_ONE + for i, v in rows[event[2]].items(): + old = rows[r].get(i, ZERO) + value = old + (v if unit else -v if negative_unit else q*v) + change = abs(value)-abs(old) + if change == ONE: + scores[r][0] += weights[i][0] + scores[r][1] += weights[i][1] + scores[r][2] += ONE + elif change == NEGATIVE_ONE: + scores[r][0] -= weights[i][0] + scores[r][1] -= weights[i][1] + scores[r][2] -= ONE + elif change: + scores[r][0] += change*weights[i][0] + scores[r][1] += change*weights[i][1] + scores[r][2] += change +''' + + +def need(ok, message): + if not ok: + raise ValueError(message) + + +def transformed(raw): + need(sha256(raw.encode()).hexdigest() == FUNCTION_SHA256, 'exact Fraction function source') + need(raw.count(BEFORE) == 1, 'one exact Fraction coefficient loop') + value = raw.replace(BEFORE, AFTER) + # Shared Fraction objects are immutable; output dictionaries stay fresh. + for token, replacement, count in [('F(0)', 'ZERO', 3), ('F(1)', 'ONE', 1), ('F(-1)', 'NEGATIVE_ONE', 1)]: + need(value.count(token) == count, 'exact Fraction constant sites: '+token) + value = value.replace(token, replacement) + seam = " n = word['public'] + word['owned_fields']\n" + need(value.count(seam) == 1, 'one exact Fraction setup seam') + return value.replace(seam, seam+' ZERO, ONE, NEGATIVE_ONE = F(0), F(1), F(-1)\n') + + +def code_shape(code): + # File/line tables differ when a bound function is compiled alone. Compare + # executable structure recursively, including nested comprehensions. + constants = tuple(code_shape(c) if isinstance(c, CodeType) else c for c in code.co_consts) + return (code.co_code, constants, code.co_names, code.co_varnames, + code.co_argcount, code.co_posonlyargcount, code.co_kwonlyargcount, + code.co_flags, code.co_freevars, code.co_cellvars, code.co_name, + code.co_stacksize, code.co_nlocals, code.co_exceptiontable) + + +def derive(reference): + need(reference.F is Fraction, 'exact standard Fraction type') + path = Path(reference.__file__) + need(sha256(path.read_bytes()).hexdigest() == MODULE_SHA256, 'exact Fraction module bytes') + original = reference.error_trace + raw = inspect.getsource(original) + text = transformed(raw) + namespace = dict(reference.__dict__) + exec(compile(raw, '', 'exec'), namespace) + need(code_shape(original.__code__) == code_shape(namespace['error_trace'].__code__), 'live Fraction code agrees with source') + need(original.__defaults__ is None and original.__kwdefaults__ is None and original.__closure__ is None, 'ordinary Fraction function') + exec(compile(text, '', 'exec'), namespace) + return namespace['error_trace'] + + +@contextmanager +def installed(reference): + original = reference.error_trace + derived = derive(reference) + reference.error_trace = derived + try: + yield derived + finally: + reference.error_trace = original diff --git a/research/fraction-zero-unit-feasibility/frozen.py b/research/fraction-zero-unit-feasibility/frozen.py new file mode 100644 index 0000000000..eb26be4a0f --- /dev/null +++ b/research/fraction-zero-unit-feasibility/frozen.py @@ -0,0 +1,67 @@ +"""Authenticate the unchanged complete PR5848 export before importing it.""" +from contextlib import contextmanager +from hashlib import sha256 +import json +from pathlib import Path +import tarfile +import tempfile + +HERE = Path(__file__).resolve().parent +BUNDLE_SHA256 = 'f899600acb6966a6b028ffbf1e33a94061615626b510feaca8cb073f03a34de6' +SOURCE_HEAD = '66fb6c6b8683b37967e9d7f313b3df99a49d2406' + + +def require(ok, why): + if not ok: + raise ValueError(why) + + +def payload(archive=None): + archive = HERE / 'inputs/PR5848.tar' if archive is None else archive + require(sha256(archive.read_bytes()).hexdigest() == BUNDLE_SHA256, 'Exact PR5848 bundle') + with tarfile.open(archive, 'r:') as stream: + members = stream.getmembers() + require(len(members) == 98 and len({m.name for m in members}) == 98, 'Complete unique baseline bundle') + require(all(m.isfile() and 0 <= m.size <= 8 * 1024**2 for m in members), 'Regular bounded baseline members') + receipt = json.loads(stream.extractfile('.research-export.json').read()) + require(receipt['commit'] == SOURCE_HEAD, 'Exact baseline export head') + rows = {r['path']: r for r in receipt['files']} + require(len(rows) == len(receipt['files']) == 97, 'Complete baseline file census') + require({m.name for m in members} == set(rows) | {'.research-export.json'}, 'Exact baseline member set') + contents = {} + for member in members: + path = Path(member.name) + require(not path.is_absolute() and '..' not in path.parts and path.parts, 'Safe baseline path') + raw = stream.extractfile(member).read() + if member.name in rows: + row = rows[member.name] + require(len(raw) == row['size'] and sha256(raw).hexdigest() == row['sha256'], 'Exact baseline file bytes') + require(row['mode'] in (0o644, 0o755), 'Regular baseline file mode') + contents[member.name] = raw + return contents + + +@contextmanager +def baseline(): + contents = payload() + with tempfile.TemporaryDirectory(prefix='precision-linux-source-') as temporary: + root = Path(temporary) + try: + for name, raw in contents.items(): + path = root / name + path.parent.mkdir(parents=True, exist_ok=True) + path.write_bytes(raw) + path.chmod(0o444) + for path in root.rglob('*'): + if path.is_dir(): + path.chmod(0o555) + before = {str(p.relative_to(root)): [sha256(p.read_bytes()).hexdigest(), p.stat().st_mode & 0o777] + for p in root.rglob('*') if p.is_file()} + yield root / 'research/p104-single-pass-qualification' + after = {str(p.relative_to(root)): [sha256(p.read_bytes()).hexdigest(), p.stat().st_mode & 0o777] + for p in root.rglob('*') if p.is_file() and not p.is_symlink()} + require(after == before and not any(p.is_symlink() for p in root.rglob('*')), 'Baseline export unchanged') + finally: + for path in [root, *root.rglob('*')]: + if path.is_dir(): + path.chmod(0o755) diff --git a/research/fraction-zero-unit-feasibility/inputs/PR5848.tar b/research/fraction-zero-unit-feasibility/inputs/PR5848.tar new file mode 100644 index 0000000000..307d09d2a9 Binary files /dev/null and b/research/fraction-zero-unit-feasibility/inputs/PR5848.tar differ diff --git a/research/fraction-zero-unit-feasibility/verify.py b/research/fraction-zero-unit-feasibility/verify.py new file mode 100644 index 0000000000..d96f4bd8a5 --- /dev/null +++ b/research/fraction-zero-unit-feasibility/verify.py @@ -0,0 +1,9 @@ +"""Fresh finite replay only; full actual audit remains separately opt-in.""" +import json +from pathlib import Path +from frozen import require +from finite import main +if __name__=='__main__': + result=main() + require(result==json.loads(Path(__file__).with_name('RESULT.json').read_bytes())['finite'],'complete finite feasibility receipt') + print('PASS_SCOPED_NEGATIVE_FEASIBILITY_FINITE_REPLAY_ONLY') diff --git a/tests/fixtures/README.md b/tests/fixtures/README.md new file mode 100644 index 0000000000..472a6a502f --- /dev/null +++ b/tests/fixtures/README.md @@ -0,0 +1,41 @@ +# Frozen research routing fixture + +`research-routing-v7.json` retains two exact task cards from priority revision 7: +`portable-replay` and `centre-path-sharing`. They exercise the generic-baseline +and historical-ceiling routes in `choose_current_research_task.py`. The fixture +records the source commit, path and SHA256. The card objects are unchanged. + +The source is commit `553d26d796fde9871ff2661a49ac7732e945410f`, file +`docs/research/agent-task-catalog.json`. The test places these cards in a small +catalogue with one track of weight 100. This carrier is test data, not a change +to research priorities. Current cards are checked separately from the live +catalogue. Every live card must preserve its other fields; each distinct direct +command also passes through both real CLIs. + +The CLI fixture copies the two real scripts. It creates inert reference files +for path validation and copies the current selected record for receipt fields. +It does not execute those references or verify a mathematical claim. Missing +references, sparse omissions, deleted files and staged replacements have separate +negative tests. No Git history, network request or change to the live catalogue +is needed to run the fixture. + +```sh +python3 -B -m unittest discover -s tests -p test_research_current_assignment.py -v +python3 -B -m unittest discover -s tests -p test_research_assignment.py -v +``` + +This fixture repairs the CI handoff in +[Discussion 5722](https://github.com/CrocSwap/integer-mult-bounds/discussions/5722). +The [investigation](https://github.com/CrocSwap/integer-mult-bounds/discussions/5758) +records the failure, checks and publication status. The original scripts, task +catalogue and selected frontier are unchanged. + +On base `de5ec2e7a6074068452f45b1a191b5c72832df4a`, the old suite has eight +failures and two errors. After the repair, all 12 current-assignment tests pass +under Python 3.14.7 and Python 3.12.14, including an isolated optimized run. +All 16 related assignment tests pass under Python 3.12.14. This is test coverage, +not a mathematical replay. See the investigation for hosted-plan status. + +Retain the original catalogue, routing and test authors, including Douglas +Colkitt, Ali Romman and Mihir Srivastava. New fixture and test repair: Ali Romman +with substantial OpenAI Codex assistance. No subagents. Apache-2.0. diff --git a/tests/fixtures/research-routing-v7.json b/tests/fixtures/research-routing-v7.json new file mode 100644 index 0000000000..f5d52ac21d --- /dev/null +++ b/tests/fixtures/research-routing-v7.json @@ -0,0 +1,87 @@ +{ + "source_commit": "553d26d796fde9871ff2661a49ac7732e945410f", + "source_path": "docs/research/agent-task-catalog.json", + "source_sha256": "f7a48bfa2659b88378282a8eee7d9fe52cdf505594124c4d1686b58510fffd72", + "scope": "Two exact revision-7 cards. The test carrier is not a research allocation.", + "cards": [ + { + "id": "centre-path-sharing", + "question": "Can the 64-per-call centre path (eight rank-8 COPY/ERASE totals through the private temporary) be shared across calls or shrunk?", + "starting_points": [ + "docs/research/research-family-status.md", + "research/complex-local-word-ceiling/README.md", + "research/split-centres-global/proofs/PR386-BIT-GEOMETRY.txt", + "certificates/selected-result.json" + ], + "methods": [ + "Derive a fully charged favorable relaxation for sharing one centre path across k calls, including restoration, hosting and precision.", + "Prove a lower bound on copied information per call for the selected decoder contract." + ], + "acceptance_gate": "Show the changed centre charge and copy profile per call with every added restoration or hosting cost charged, and its ceiling via ceiling.ceiling(centre=...). A scoped local result may be retained without a complete supplier. Expanding it into further construction rounds requires the family-level budget and obligation gate in research-family-status.md; an optimistic passing relaxation alone is not acceptance.", + "first_step": { + "command": [ + "python3", + "-B", + "research/complex-local-word-ceiling/verify.py" + ], + "expected": "PASS_COMPLEX_LOCAL_WORD_CEILING", + "inspect": "Read the selected word's per-call local profile, its packing ceiling and the lever table; run levers.py for the ideal budget of the lever you target.", + "scope": "Positive control and planning budget only; this is not a new construction or full cold replay." + }, + "first_experiment": "Write the per-call centre charge and copy children for sharing across k = 2 calls, charge the sharing overhead, and screen it; stop this route if even the ideal sharing gains under 10%. Ideal budgets: free 2.80x, shared by two 1.90x (levers.py).", + "bottleneck_link": "The centre path consumes 64 of about 99.6 unpaid coordinates per call, i.e. about 64% of the raw deficit.", + "allowed_variations": [ + "One sharing pattern across a fixed number of calls.", + "One reduced copied-total contract for the existing decoder.", + "If the coverage law, template or guard changes, derive an applicable fully charged replacement bound instead of applying the incumbent ceiling outside its scope." + ], + "scope_change_triggers": [ + "Removing copies without a replacement contract for the decoder's copied totals.", + "Continuing a partial cost improvement while leaving the same unpriced consumer, restoration or central-readout obligation unresolved; refresh the family expansion decision first. Local product-retiming evidence has a narrow scope and is not a ban on changed graphs or contracts." + ], + "overlap_terms": [ + "centre path", + "copied totals", + "private temporary", + "shared centre", + "batching" + ] + }, + { + "id": "portable-replay", + "question": "Can one reproducible environment or artifact-comparison failure be repaired?", + "starting_points": [ + "research/gzip-container-reproducibility/README.md", + "docs/ci-verification.md" + ], + "methods": [ + "Reproduce one portability failure and add a minimal cross-environment fix.", + "Audit one canonical-payload comparison for omitted proof-relevant fields." + ], + "acceptance_gate": "Preserve immutable source hashes and proof-relevant content; a different compressed byte stream alone is not a mathematical mismatch.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read the gzip-container reproducibility examples and distinguish frozen source bytes from regenerated payloads.", + "scope": "Positive control / source-bound orientation only; this is not a new construction or full cold replay." + }, + "first_experiment": "Reproduce one specific mismatch or audit one canonical comparison for omitted proof-relevant fields.", + "bottleneck_link": "Portable exact checks prevent environment failures from blocking valid contributions.", + "allowed_variations": [ + "One interpreter/version mismatch or one payload field comparison." + ], + "scope_change_triggers": [ + "Removing immutable-source pins because generated compressed bytes differ." + ], + "overlap_terms": [ + "gzip container", + "reproducibility", + "canonical payload" + ] + } + ] +} diff --git a/tests/test_research_current_assignment.py b/tests/test_research_current_assignment.py index 860f6b9b9e..c524c0037f 100644 --- a/tests/test_research_current_assignment.py +++ b/tests/test_research_current_assignment.py @@ -1,9 +1,15 @@ -"""Current orientation must preserve frozen task-selection evidence.""" +"""Current orientation must preserve frozen task-selection evidence. + +Frozen fixtures and live-catalog coverage: Ali Romman with OpenAI Codex +assistance. Retain the original routing and test authors. Apache-2.0. +""" import copy +from contextlib import contextmanager import importlib.util import json from pathlib import Path import subprocess +import shutil import sys import tempfile import unittest @@ -15,16 +21,49 @@ LEGACY = current.LEGACY legacy = current.runpy.run_path(str(LEGACY)) CATALOG = json.loads((ROOT / legacy["CATALOG"]).read_text(encoding="utf-8")) +FROZEN = json.loads((ROOT / "tests/fixtures/research-routing-v7.json").read_text()) +FROZEN_CATALOG = { + "schema_version": 1, "priority_revision": 7, + "priority_log": "docs/research/routing-fixture.md", + "tracks": [{"id": "routing-fixtures", "weight": 100, "tasks": FROZEN["cards"]}], +} + + +@contextmanager +def frozen_cli_tree(): + """Run the real scripts with exact old cards and inert reference files.""" + with tempfile.TemporaryDirectory() as directory: + root = Path(directory) + required = {FROZEN_CATALOG["priority_log"], + "scripts/research_selected_baseline.py", "scripts/research_package.py", + "research/historical-complex-ceiling-replay/VERIFY.json", + "research/historical-complex-ceiling-replay/verify.py"} + for card in FROZEN["cards"]: + required.update(card["starting_points"]) + required.add(card["first_step"]["command"][-1]) + for name in required: + path = root / name + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text("Inert reference for CLI validation only.\n") + for name in ("choose_research_task.py", "choose_current_research_task.py"): + shutil.copyfile(ROOT / "scripts" / name, root / "scripts" / name) + path = root / legacy["CATALOG"] + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text(json.dumps(FROZEN_CATALOG)) + path = root / "certificates/selected-result.json" + path.parent.mkdir(parents=True, exist_ok=True) + shutil.copyfile(ROOT / "certificates/selected-result.json", path) + yield root class CurrentResearchAssignmentTests(unittest.TestCase): - def test_every_frozen_card_and_other_fields_stay_exact(self): - before = copy.deepcopy(CATALOG) + def check_card_round_trips(self, catalog): + before = copy.deepcopy(catalog) resolved = 0 historical = 0 - for track in CATALOG["tracks"]: + for track in catalog["tracks"]: for task in track["tasks"]: - result = legacy["select"](CATALOG, "a1" * 16, task_id=task["id"]) + result = legacy["select"](catalog, "a1" * 16, task_id=task["id"]) original = copy.deepcopy(result) current.resolve_current_first_steps(result, ROOT) card = result["suggestions"][0] @@ -55,19 +94,25 @@ def test_every_frozen_card_and_other_fields_stay_exact(self): self.assertTrue(card.pop("first_step_resolution")) card["first_step"] = card.pop("catalog_first_step") self.assertEqual(result, original) - self.assertEqual(resolved, 16) - self.assertEqual(historical, 4) - self.assertEqual(CATALOG, before) + self.assertEqual(catalog, before) + return resolved, historical + + def test_frozen_routes_and_other_fields_stay_exact(self): + self.assertEqual(self.check_card_round_trips(FROZEN_CATALOG), (1, 1)) + + def test_every_live_card_and_other_fields_stay_exact(self): + self.assertTrue(CATALOG["tracks"]) + self.check_card_round_trips(CATALOG) def test_only_exact_generic_command_is_resolved(self): - result = copy.deepcopy(legacy["select"](CATALOG, "0" * 32, task_id="portable-replay")) + result = copy.deepcopy(legacy["select"](FROZEN_CATALOG, "0" * 32, task_id="portable-replay")) result["suggestions"][0]["first_step"]["command"].append("--historical-fixture") original = copy.deepcopy(result) self.assertEqual(current.resolve_current_first_steps(result, ROOT), []) self.assertEqual(result, original) def test_missing_current_helper_does_not_change_receipt(self): - result = legacy["select"](CATALOG, "0" * 32, task_id="portable-replay") + result = legacy["select"](FROZEN_CATALOG, "0" * 32, task_id="portable-replay") original = copy.deepcopy(result) with tempfile.TemporaryDirectory() as directory: with self.assertRaisesRegex(ValueError, "missing current first-step script"): @@ -82,7 +127,7 @@ def test_nonexact_scientific_commands_are_not_reinterpreted(self): ): with self.subTest(command=command): result = copy.deepcopy(legacy["select"]( - CATALOG, "0" * 32, task_id="centre-path-sharing")) + FROZEN_CATALOG, "0" * 32, task_id="centre-path-sharing")) result["suggestions"][0]["first_step"]["command"] = command original = copy.deepcopy(result) self.assertEqual(current.resolve_current_first_steps(result, ROOT), []) @@ -102,34 +147,52 @@ def test_missing_historical_reference_leaves_all_cards_unchanged(self): path = root / name path.parent.mkdir(parents=True, exist_ok=True) path.write_text("fixture\n") - result = legacy["select"](CATALOG, "0" * 32, task_id="portable-replay") + result = legacy["select"](FROZEN_CATALOG, "0" * 32, task_id="portable-replay") result["suggestions"] += legacy["select"]( - CATALOG, "0" * 32, task_id="centre-path-sharing")["suggestions"] + FROZEN_CATALOG, "0" * 32, task_id="centre-path-sharing")["suggestions"] original = copy.deepcopy(result) with self.assertRaises(ValueError) as raised: current.resolve_current_first_steps(result, root) self.assertIn(absent, str(raised.exception)) self.assertEqual(result, original) - def cli(self, script, args): - return subprocess.run([sys.executable, "-B", str(script), *args], cwd=ROOT, + def cli(self, script, args, root=ROOT): + return subprocess.run([sys.executable, "-B", str(root / "scripts" / Path(script).name), *args], cwd=root, capture_output=True, text=True, encoding="utf-8") def test_cli_preserves_legacy_output_and_emits_both_commands(self): - args = ["--seed", "0" * 32, "--task", "portable-replay"] - original = self.cli(LEGACY, args) - output = self.cli(ROOT / "scripts/choose_current_research_task.py", args) - self.assertEqual(original.returncode, 0) - self.assertEqual(output.returncode, 0) - old, new = json.loads(original.stdout), json.loads(output.stdout) - card = new["suggestions"][0] - self.assertEqual(card["first_step"]["command"], - ["python3", "-B", "scripts/research_selected_baseline.py"]) - self.assertEqual(card.pop("catalog_first_step"), old["suggestions"][0]["first_step"]) - self.assertTrue(card.pop("first_step_resolution")) - card["first_step"] = old["suggestions"][0]["first_step"] - self.assertEqual(new, old) - self.assertEqual(self.cli(LEGACY, args).stdout, original.stdout) + with frozen_cli_tree() as root: + args = ["--seed", "0" * 32, "--task", "portable-replay"] + original = self.cli(LEGACY, args, root) + output = self.cli(ROOT / "scripts/choose_current_research_task.py", args, root) + self.assertEqual(original.returncode, 0) + self.assertEqual(output.returncode, 0) + old, new = json.loads(original.stdout), json.loads(output.stdout) + card = new["suggestions"][0] + self.assertEqual(card["first_step"]["command"], + ["python3", "-B", "scripts/research_selected_baseline.py"]) + self.assertEqual(card.pop("catalog_first_step"), old["suggestions"][0]["first_step"]) + self.assertTrue(card.pop("first_step_resolution")) + card["first_step"] = old["suggestions"][0]["first_step"] + self.assertEqual(new, old) + self.assertEqual(self.cli(LEGACY, args, root).stdout, original.stdout) + + def test_live_cli_preserves_each_unmapped_command(self): + checked = {tuple(card["first_step"]["command"]) for card in FROZEN["cards"]} + for track in CATALOG["tracks"]: + for task in track["tasks"]: + command = tuple(task["first_step"]["command"]) + if command in checked: + continue + checked.add(command) + with self.subTest(task=task["id"]): + args = ["--seed", "0" * 32, "--task", task["id"]] + original = self.cli(LEGACY, args) + output = self.cli(ROOT / "scripts/choose_current_research_task.py", args) + self.assertEqual(original.returncode, 0, original.stderr) + self.assertEqual(output.returncode, 0, output.stderr) + self.assertEqual(json.loads(output.stdout), json.loads(original.stdout)) + self.assertEqual(self.cli(LEGACY, args).stdout, original.stdout) def test_help_and_error_preserve_child_status_and_output(self): for args, code in ((["--help"], 0), (["--unknown-option"], 2), (["--seed", "bad"], 2)): @@ -139,23 +202,24 @@ def test_help_and_error_preserve_child_status_and_output(self): self.assertEqual((output.stdout, output.stderr), (original.stdout, original.stderr)) def test_cli_distinguishes_current_orientation_from_historical_control(self): - args = ["--seed", "0" * 32, "--task", "complex-new-helper-inventory"] - original = self.cli(LEGACY, args) - output = self.cli(ROOT / "scripts/choose_current_research_task.py", args) - self.assertEqual(original.returncode, 0, original.stderr) - self.assertEqual(output.returncode, 0, output.stderr) - old, new = json.loads(original.stdout), json.loads(output.stdout) - card = new["suggestions"][0] - self.assertEqual(card["first_step"]["command"][2], "scripts/research_selected_baseline.py") - self.assertEqual(card["first_step"]["expected"], "PASS_RESEARCH_BASELINE_BINDINGS_ONLY") - follow_up, = card.pop("follow_up_steps") - self.assertEqual(follow_up["command"][-1], "research/historical-complex-ceiling-replay") - self.assertIn("historical", follow_up["scope"].lower()) - self.assertIn("cost law", follow_up["inspect"]) - self.assertTrue(card.pop("first_step_resolution")) - card["first_step"] = card.pop("catalog_first_step") - self.assertEqual(new, old) - self.assertEqual(self.cli(LEGACY, args).stdout, original.stdout) + with frozen_cli_tree() as root: + args = ["--seed", "0" * 32, "--task", "centre-path-sharing"] + original = self.cli(LEGACY, args, root) + output = self.cli(ROOT / "scripts/choose_current_research_task.py", args, root) + self.assertEqual(original.returncode, 0, original.stderr) + self.assertEqual(output.returncode, 0, output.stderr) + old, new = json.loads(original.stdout), json.loads(output.stdout) + card = new["suggestions"][0] + self.assertEqual(card["first_step"]["command"][2], "scripts/research_selected_baseline.py") + self.assertEqual(card["first_step"]["expected"], "PASS_RESEARCH_BASELINE_BINDINGS_ONLY") + follow_up, = card.pop("follow_up_steps") + self.assertEqual(follow_up["command"][-1], "research/historical-complex-ceiling-replay") + self.assertIn("historical", follow_up["scope"].lower()) + self.assertIn("cost law", follow_up["inspect"]) + self.assertTrue(card.pop("first_step_resolution")) + card["first_step"] = card.pop("catalog_first_step") + self.assertEqual(new, old) + self.assertEqual(self.cli(LEGACY, args, root).stdout, original.stdout) def test_sparse_historical_references_require_unchanged_head_entries(self): with tempfile.TemporaryDirectory() as directory: @@ -178,12 +242,12 @@ def git(*args): git("update-index", "--skip-worktree", *omitted) for name in omitted: (root / name).unlink() - result = legacy["select"](CATALOG, "0" * 32, task_id="coverage-law-change") + result = legacy["select"](FROZEN_CATALOG, "0" * 32, task_id="centre-path-sharing") self.assertEqual(current.resolve_current_first_steps(result, root), sorted(omitted)) # Ordinary deletion must not acquire the deliberate-sparse exemption. changed = omitted[-1] git("update-index", "--no-skip-worktree", changed) - result = legacy["select"](CATALOG, "0" * 32, task_id="coverage-law-change") + result = legacy["select"](FROZEN_CATALOG, "0" * 32, task_id="centre-path-sharing") original = copy.deepcopy(result) with self.assertRaises(ValueError): current.resolve_current_first_steps(result, root) @@ -208,9 +272,9 @@ def git(*args): git("-c", "user.name=Fixture", "-c", "user.email=fixture@example.invalid", "-c", "core.hooksPath=/dev/null", "commit", "-qm", "helper") git("update-index", "--skip-worktree", name); path.unlink() - result = legacy["select"](CATALOG, "0" * 32, task_id="portable-replay") + result = legacy["select"](FROZEN_CATALOG, "0" * 32, task_id="portable-replay") self.assertEqual(current.resolve_current_first_steps(result, root), [name]) git("update-index", "--no-skip-worktree", name) - result = legacy["select"](CATALOG, "0" * 32, task_id="portable-replay") + result = legacy["select"](FROZEN_CATALOG, "0" * 32, task_id="portable-replay") with self.assertRaisesRegex(ValueError, "missing current first-step script"): current.resolve_current_first_steps(result, root)