Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 124 additions & 0 deletions research/p104-integer-error-replay/BENCHMARK.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
{
"platform": "macOS-26.6.1-arm64-arm-64bit",
"python": "3.12.14 (main, Aug 25 2026, 13:50:33) [Clang 22.1.3 ]",
"code_sha256": {
"integer.py": "82a73e4bcf1835bfdd510c7ad5538625c1b380c559b671e6a67be490615a743a",
"contract.py": "ecf1f000e4aef11d5d5e1191a8e6fa44518ba8736e14505071f4ebc32d1409ce",
"verify.py": "aaa392ca9aa9aead0eee0ac6c64ff44ea66e1f251b0a79d18cd60baa946261a1",
"benchmark.py": "59c451bd1fcb1e8fcaebe5d6d7002bb85ccbd68c2f0f8d14e70de8fbcf949c69",
"inputs/source.tar": "f8252a90dc504ce8a77d781e558691fe8d21014b0f3f720d8dfd5274b5e8aadc"
},
"order": [
"baseline",
"candidate",
"candidate",
"baseline",
"baseline",
"candidate"
],
"runs": [
{
"mode": "baseline",
"wall_seconds": 31.14853112504352,
"internal_seconds": 31.07993,
"receipt": {
"coordinates": 799,
"events": 25984,
"guards": {
"owned": 22,
"prefix": 26,
"public": 23
},
"source_controls": 6,
"source_result_sha256": "cc7739703ed23532d187949c8507d09c13ac4c152e07a930f0087cde0d7a3d98"
}
},
{
"mode": "candidate",
"wall_seconds": 9.81022679200396,
"internal_seconds": 9.748412,
"receipt": {
"coordinates": 799,
"events": 25984,
"guards": {
"owned": 22,
"prefix": 26,
"public": 23
},
"source_controls": 6,
"source_result_sha256": "cc7739703ed23532d187949c8507d09c13ac4c152e07a930f0087cde0d7a3d98"
}
},
{
"mode": "candidate",
"wall_seconds": 3.2594693331047893,
"internal_seconds": 3.213043,
"receipt": {
"coordinates": 799,
"events": 25984,
"guards": {
"owned": 22,
"prefix": 26,
"public": 23
},
"source_controls": 6,
"source_result_sha256": "cc7739703ed23532d187949c8507d09c13ac4c152e07a930f0087cde0d7a3d98"
}
},
{
"mode": "baseline",
"wall_seconds": 24.090562083059922,
"internal_seconds": 24.048647,
"receipt": {
"coordinates": 799,
"events": 25984,
"guards": {
"owned": 22,
"prefix": 26,
"public": 23
},
"source_controls": 6,
"source_result_sha256": "cc7739703ed23532d187949c8507d09c13ac4c152e07a930f0087cde0d7a3d98"
}
},
{
"mode": "baseline",
"wall_seconds": 19.79097054200247,
"internal_seconds": 19.715903,
"receipt": {
"coordinates": 799,
"events": 25984,
"guards": {
"owned": 22,
"prefix": 26,
"public": 23
},
"source_controls": 6,
"source_result_sha256": "cc7739703ed23532d187949c8507d09c13ac4c152e07a930f0087cde0d7a3d98"
}
},
{
"mode": "candidate",
"wall_seconds": 4.3006944169756025,
"internal_seconds": 4.239551,
"receipt": {
"coordinates": 799,
"events": 25984,
"guards": {
"owned": 22,
"prefix": 26,
"public": 23
},
"source_controls": 6,
"source_result_sha256": "cc7739703ed23532d187949c8507d09c13ac4c152e07a930f0087cde0d7a3d98"
}
}
],
"baseline_median_seconds": 24.090562083059922,
"candidate_median_seconds": 4.3006944169756025,
"speedup": 5.601551690808398,
"wall_reduction_fraction": 0.8214780376585825,
"cold_processes": true,
"parallel_replays": false,
"scope": "Complete contract with source authentication, extraction, all original endpoint/error/guard/control checks. Local shared-host timings; no Linux or hosted speed claim. Qualification is a separate cost."
}
18 changes: 18 additions & 0 deletions research/p104-integer-error-replay/CONTRACT-EDITS.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[
[
"def authenticate():",
"def authenticate(P=P):"
],
[
"def calculate():",
"def calculate(P=P, backend=None):"
],
[
" authenticate()",
" authenticate(P)"
],
[
" a = module('noisy_precision', P / 'precision.py')",
" a = backend if backend is not None else module('noisy_precision', P / 'precision.py')"
]
]
66 changes: 66 additions & 0 deletions research/p104-integer-error-replay/PROOF.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Exact dyadic scale and complete replay equivalence

The frozen source is PR5826 at58f93cf41751920f3d6766a39caccc2974ce18b0.
Its official source export is retained unchanged. The candidate changes the
arithmetic representation of sparse coefficients. It changes no native word,
error allowance, operation count, endpoint, guard inequality or scientific claim.

For each row, keep an upper bound d on the exponent of two in the denominator
of any coefficient. Start d=0. A reset sets d=0. MOVE leaves it unchanged.
SCALE by n/2^k sets d to d+k. ADD or additive COPY from s into r sets
`d_r=max(d_r,d_s+k)`. Injection of a new unit defect requires only exponent0.
The same rule on the transposed word uses `d_s=max(d_s,d_r+k)`. These bounds
ignore cancellations and powers of two in n; thus they can be conservative.
Take E to be the largest bound on either traversal and S=2^E.

Induction on each event proves that every exact forward and transposed
coefficient is an integer multiple of 1/S. Store its numerator at this common
scale as a Python arbitrary-size integer. Multiplication by n/2^k is exact:
first multiply by n, then divide by 2^k. The implementation checks divisibility
before every division. It does not truncate, use a modulus or accept a floating
comparison. A nondyadic coefficient is rejected. The same scale covers ideal
input coefficients; it is a representation bound, not a numerical precision
or magnitude promise for the physical caller.

Choose separate power-of-two scales A and C for the nonnegative local weights
a_j and c_j. If a coefficient is z/S, its three exact score contributions are

`abs(z)*a_j*A/(S*A)`, `abs(z)*c_j*C/(S*C)`, and `abs(z)/S`.

The numerator updates use the signed sum z_old+q*z_source before taking its
absolute value. Thus a cancellation changes the score by
`abs(z_new)-abs(z_old)`, including negative changes. The candidate does not
replace signed transfer by an absolute-value propagation bound. All score units
are fixed, so comparisons, tie choices and Pareto order agree with the rational
reference. Fraction conversion occurs only at the result and hash boundaries.
Canonical reduced numerator/denominator encodings preserve all source hashes.

The transposed pass uses a separate traversal with the same proved scale. It
checks every final signed coefficient and score. The original literal scalar
execution and reverse-cut oracles remain unchanged. The original contract's
complete ideal endpoint, native frame/ownership checks, guards, attaining
fixtures and six rejection controls remain active.

`contract.py` is an explicit adapted copy of the source runner. Its four declared
edits add source-directory and backend parameters. Its obsolete direct CLI is
removed; this package supplies its own CLI. The checker reconstructs these
exact edits before loading the runner. This is ordinary dependency injection;
no module, global function, source file or import hook is patched at runtime.

Qualification compares the complete baseline and candidate results, all actual
signed witness rows, and120 separate finite dyadic error words with cancellation,
scaling, reset, COPY and varied defect sites. It also compares each finite
transposed result and rejects nondyadic scalars, nondyadic weights and inexact
integer divisions. The frozen source and package code remain distinct.

The default command runs the fast complete source contract and compares the
entire result to the frozen expected record. `--qualify` additionally runs the
slow reference and the extra cross-checks; its cost is not hidden in the speedup.
`--baseline` runs the unmodified source contract for a matched timing. Timings
include source authentication, archive extraction and full original controls.
No cache is shared between processes. Local measurements are not a promise
about another machine or hosted CI.

The original precision theorem remains conditional. Native unitary gauges,
physical resets, exact owned return, compiler, precision-tape and analytic
admission retain their prior status. Faster verification is not a new kappa.
69 changes: 69 additions & 0 deletions research/p104-integer-error-replay/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Exact integer replay for the complete P104 precision contract

The complete PR5826 precision replay now has an exact integer backend for its
ideal input, signed error and transposed passes. A proved common dyadic scale
replaces Fraction operations in the inner loops. Every division is checked;
no floating or modular result decides acceptance. The word, full799-coordinate
endpoint, all25,984 events, signed coefficients, guards and six source rejection
controls remain unchanged. See [PROOF.md](PROOF.md).

The local complete-process median falls **24.091 to 4.301 seconds**
(**5.60x**, 82.1% less wall time). The host was not reserved:
baseline runs range from 19.791 to 31.149 seconds; candidate runs range
from 3.259 to 9.810 seconds. `BENCHMARK.json` records six serial fresh-process runs of the complete baseline
and candidate, with code hashes, all receipts and the local timing limits.
The candidate still authenticates and extracts the frozen source, executes the
literal attaining oracles, and compares the full source result. It has no
persistent cache. Qualification is a separate cost and is not hidden in the
claimed runtime.

Run the fast complete replay:

```sh
python3 -I -B research/p104-integer-error-replay/verify.py
```

Run the full independent arithmetic qualification:

```sh
python3 -B scripts/research_package.py --package research/p104-integer-error-replay
```

Qualification compares the entire original/candidate result, every actual
signed witness row, the ideal metadata and all local weights. It also checks120
separate dyadic words with4,240 events, varied defect sites, reset, COPY and
cancellation, plus three integer-contract rejection controls. The source's six
controls remain active in every normal replay. `RESULT.json` records this scope.

To repeat timings with Python3.12, run `benchmark.py --output /tmp/p104-error-times.json`
from this package directory. Six complete processes run in sequence. Local
macOS timings do not establish Linux or hosted CI performance. Python3.12 and
the standard library suffice. The source export and source NOTICE files are
retained unchanged. Registered, source-corruption and read-only Git-free
optimized checks are separate from timing.

`contract.py` adds four explicit parameter edits to the source runner and removes
its old CLI. `CONTRACT-EDITS.json` authenticates that adaptation. The backend is
passed as an ordinary argument. No runtime monkeypatch or import hook is used.
The candidate keeps the original literal scalar and reverse-cut oracles.

## Open next questions

- Reproduce the complete six-process measurement on an idle Linux runner. Keep
all endpoint, error and failure checks, and report qualification cost separately.
- If a later word needs new operations or nondyadic coefficients, prove a new
representation contract before using this backend. This package rejects them.
- Bind actual native/rounded child and reset implementations to the retained
precision theorem. A faster replay does not discharge those assumptions.

Source PR5826 at58f93cf41751920f3d6766a39caccc2974ce18b0. Credit PR5819,
Adam Gall, ywz65, PR2878, Mason Hale/PR5811 and all retained P104/native/compiler
sources. New backend and qualification by Ali Romman with substantial OpenAI
Codex assistance; no subagents. Apache-2.0. No new kappa, frontier change,
physical supplier admission or independent human acceptance is claimed.

The source manifest pins replay inputs to copies in this publication history.
Its `retained_predecessors` records keep each original head, path, blob and
SHA256, plus its exact retained file or archive member. Each source was checked
byte-for-byte before this rebind. This removes an unavailable side-commit
dependency from clean CI; no source bytes or scientific checks are changed.
22 changes: 22 additions & 0 deletions research/p104-integer-error-replay/RESULT.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"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"
}
80 changes: 80 additions & 0 deletions research/p104-integer-error-replay/SOURCES.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"schema_version": 1,
"base_commit": "de5ec2e7a6074068452f45b1a191b5c72832df4a",
"files": [
{
"path": "certificates/selected-result.json",
"usage": "provenance",
"git_blob": "581f8d87008354eb5b869f7ed9de1317ad837ce8",
"sha256": "2a0220e866417774606e0f991e41b9c1d26b1f43b97857238cf478dbc7d330b5"
},
{
"path": "docs/research/agent-task-catalog.json",
"usage": "provenance",
"git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec",
"sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81"
},
{
"path": "research/p104-integer-error-replay/inputs/source.tar",
"usage": "input",
"origin": {
"commit": "58f93cf41751920f3d6766a39caccc2974ce18b0",
"package": "research/p104-noisy-copy-reset",
"format": "official research-package export"
},
"git_blob": "8f17461fcdbef4bc896bd45f2481ac3bad758d0d",
"sha256": "f8252a90dc504ce8a77d781e558691fe8d21014b0f3f720d8dfd5274b5e8aadc",
"pin": "head:55394bd623bc9db68ac5d49999481185ba9b82dd:research/p104-integer-error-replay/inputs/source.tar"
}
],
"retained_predecessors": [
{
"path": "research/p104-noisy-copy-reset/SOURCES.json",
"usage": "provenance",
"pin": "head:58f93cf41751920f3d6766a39caccc2974ce18b0:research/p104-noisy-copy-reset/SOURCES.json",
"git_blob": "081ab1db527ad481b475585ed73d8d7c042f1cf9",
"sha256": "da233c5ea2b28a58d6026cebbd266ea373716afd11b2013f655265d536b8b787",
"retained_source": {
"path": "research/p104-integer-error-replay/inputs/source.tar",
"pin": "head:55394bd623bc9db68ac5d49999481185ba9b82dd:research/p104-integer-error-replay/inputs/source.tar",
"member": "research/p104-noisy-copy-reset/SOURCES.json"
}
},
{
"path": "research/p104-noisy-copy-reset/VERIFY.json",
"usage": "provenance",
"pin": "head:58f93cf41751920f3d6766a39caccc2974ce18b0:research/p104-noisy-copy-reset/VERIFY.json",
"git_blob": "b5a196e0e71cfafbb88f457ff7c94b63a9a7087a",
"sha256": "b84a00c78d77b82e87050516ef19199fc30a5bae50846f588e09dd5f2a5ed52d",
"retained_source": {
"path": "research/p104-integer-error-replay/inputs/source.tar",
"pin": "head:55394bd623bc9db68ac5d49999481185ba9b82dd:research/p104-integer-error-replay/inputs/source.tar",
"member": "research/p104-noisy-copy-reset/VERIFY.json"
}
},
{
"path": "research/p104-noisy-copy-reset/RESULT.json",
"usage": "provenance",
"pin": "head:58f93cf41751920f3d6766a39caccc2974ce18b0:research/p104-noisy-copy-reset/RESULT.json",
"git_blob": "66a891b4fa7d5860b5a08b67f50e988f15e4a520",
"sha256": "ac7f1922f777667f51bf666538eb36bdca97f55cb0313210c60ffe29fef77cd2",
"retained_source": {
"path": "research/p104-integer-error-replay/inputs/source.tar",
"pin": "head:55394bd623bc9db68ac5d49999481185ba9b82dd:research/p104-integer-error-replay/inputs/source.tar",
"member": "research/p104-noisy-copy-reset/RESULT.json"
}
},
{
"path": "research/p104-noisy-copy-reset/verify.py",
"usage": "provenance",
"pin": "head:58f93cf41751920f3d6766a39caccc2974ce18b0:research/p104-noisy-copy-reset/verify.py",
"git_blob": "55beda7b0518b9e458b610ee4e16ee2a7ad43f74",
"sha256": "4896c85513f0e15e96fdcb9df9245055bf252dc6be99be5e2a037420a795bb34",
"retained_source": {
"path": "research/p104-integer-error-replay/inputs/source.tar",
"pin": "head:55394bd623bc9db68ac5d49999481185ba9b82dd:research/p104-integer-error-replay/inputs/source.tar",
"member": "research/p104-noisy-copy-reset/verify.py"
}
}
]
}
Loading