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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__pycache__/
5 changes: 5 additions & 0 deletions research/fraction-contribution-table-feasibility/NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Fraction arithmetic primitive profile and bounded contribution-table feasibility
============================================================================
Original Fraction/error arithmetic: Ali Romman, retaining Adam Gall/ywz65/PR2878, PR5826/5819, Mason Hale/PR5811 and all P104/native/compiler/precision notices. Full PR5848, PR5831 and nested source archives are unchanged. Apache-2.0.

New primitive profiling, exact local table, finite/key/capacity/failure checks and complete-cost screen: Chris R / Clear1nsight, substantial OpenAI Codex assistance; no subagents or independent human/kernel acceptance. Memoization is a standard technique. PR5848/5839 supply the qualifier/Linux baseline; PR5816/5818/5832/5761 retain tooling and test-repair credit with original authorship. The prior zero/unit negative artifact71f22c77b393e5cc14925c771894dc1a92c8443c supplies source-binding and finite-fixture lineage. No complete performance or kappa improvement is claimed.
15 changes: 15 additions & 0 deletions research/fraction-contribution-table-feasibility/PROOF.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Exact local contribution tabulation

For standard immutable Fraction values x,q,y,a,c, define

`v = x + q*y; d = abs(v)-abs(x); H(x,q,y,a,c) = (v,d*a,d*c,d)`.

This is exactly the original coefficient and score-increment arithmetic in the authenticated Fraction ADD/COPY loop. Each input Fraction has a unique reduced numerator/positive-denominator pair. The ten-integer key therefore determines every input value. A Python dictionary compares the complete tuple after hashing; hash collisions do not identify distinct tuples. On a miss, the table computes H with the original Fraction operators. On a hit, it returns the same immutable four-value tuple. FIFO eviction removes only an optional stored answer; a later miss recomputes H. Capacity zero bypasses storage. Exceptions are not stored. Nonstandard numeric types bypass the table; the proof does not extend to arbitrary user-defined numeric operator side effects.

Assuming equal rows/scores at the start of a coefficient iteration, replacing the local arithmetic with H preserves the new coefficient and all three increments. The caller still performs every score addition, zero removal/insertion and index-specific row update in the same order. Event operations, rounded-site injections, prefix/tie/peak decisions, full witness copies, Pareto sorting, final scores and signed hash updates are untouched. Induction over coefficients/events proves exact returned values on the declared domain. Tests additionally compare numeric types and unchanged inputs. Mutable output containers remain fresh; standard Fraction values are immutable through their public API.

The cache is newly constructed for every trace. Only a statistics dictionary survives for observation, cleared before a new call; no Fraction answer table is reused by another call or backend. Original integer arithmetic, literal execution and transpose oracles are unchanged. Full module/function hashes and unique setup/contribution/return seams bind the derivation. The live source callable must equal a fresh compilation's recursively compared executable structure, excluding only source locations. The installer restores it in `finally`.

Finite checks cover 241 programs/10,164 events at four capacities, including disabled and repeated-eviction cases, sign flips/cancellation and all operations. Thirty-four controls include each key operand, canonical equal-value keys, actual integer-hash collisions, capacity rejection, FIFO recomputation, uncached exceptions, failed-call statistics clearing, returned/statistics mutation, source/live/nested-code drift and restoration. Both full actual audits compare every returned trace/witness value/type and input on the frozen 25,984-event/799-coordinate word.

This correctness result does not imply profitable qualification. The complete-cost screen includes the new finite checks and remains below the requested 15% saving. No complete performance implementation or CPU/wall benchmark is admitted. Physical native/reset/owned-return/tape/compiler/outer obligations and the selected result are untouched; kappa work remains paused.
52 changes: 52 additions & 0 deletions research/fraction-contribution-table-feasibility/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Fraction primitive profile and contribution-table feasibility

**Scoped finding: correctness passes; stop before complete qualifier construction. No performance PR or kappa gain.** This follows [PR #5848](https://github.com/CrocSwap/integer-mult-bounds/pull/5848) and the [released zero/unit experiment](https://github.com/CrocSwap/integer-mult-bounds/pull/5848#issuecomment-6435104002).

A complete unchanged qualification passes with cProfile enabled only around its actual Fraction error trace. That trace makes **26,030,845 `_from_coprime_ints` calls, 10,396,952 `_add` calls, 7,892,384 `_mul` calls and 2,579,750 coefficient updates**. The profiled trace costs 65.737 seconds and whole qualification 86.794 seconds; instrumentation inflates these times. They are not benchmark observations and cannot be directly compared to the unprofiled 39.015-second complete median.

## Exact table and feasibility result

The prototype tabulates the pure local result `(new coefficient, weighted increment A, weighted increment C, unweighted increment)` as a function of exact Fraction values `(old coefficient, scalar, source coefficient, weight A, weight C)`. Canonical numerator/denominator pairs form the complete key. Misses use the original Fraction arithmetic. Every score/row update, rounded site, peak/witness, signed hash and original independent integer operation remains active. Each trace creates a fresh bounded FIFO table; it shares no answers across backends or calls. See `PROOF.md`.

All **241 finite programs / 10,164 events** compare complete values, witnesses, types and unchanged inputs at capacities **0,1,2,16384**: 964 complete differential comparisons. All **34** key/hash/capacity/eviction/source/exception/mutation/restoration controls pass normally and under optimization. The previous finite harness recompiled four unchanged functions per program; the final harness derives those same four functions once and explicitly checks fresh table lifetimes across repeated calls. No numerical case is removed.

Two separately labelled full actual audits preserve every trace/witness value/type and input on **25,984 events / 799 coordinates**:

| Table | Original trace | Derived trace | Hits | Misses | Evictions |
|---|---:|---:|---:|---:|---:|
| 2,048 entries, dictionary FIFO | 19.996 s | 16.578 s | 1,934,536 | 645,214 | 643,166 |
| 16,384 entries, OrderedDict FIFO | 20.251 s | 14.600 s | 2,252,966 | 326,784 | 310,400 |

The first result had insufficient whole-stage headroom. The plan was reassessed before any complete construction, allowing one final bounded size/constant-time FIFO test under the unchanged resource cap. Both prototypes and the reassessment remain in evidence. These are single ordered within-process comparisons, not fresh-process wall/CPU benchmarks, medians or a causal separation of capacity and container effects.

## Complete-cost decision

The larger table removes 5.652 seconds in its observed trace comparison. Against PR #5848's complete wall median of 39.015 seconds, that is only **14.49% before new checks**. The new full finite/control stage takes about 1.621 seconds. A simple screen gives:

`39.014916 - 5.651933 + 1.620956 = 34.983939 seconds`, about **10.33% modelled saving**.

The required 15% target is at most 33.162678 seconds, alongside an independently passing complete CPU gate. The screen does not justify a complete candidate. No complete qualifier, complete B/C pair, six-process expansion or performance PR is constructed. This is a scoped engineering decision, not a universal obstruction or measured complete-stage/CPU result.

## Reproduce and coverage boundary

Python 3.12, standard library only:

```sh
python3 -B scripts/research_package.py --package research/fraction-contribution-table-feasibility
```

This performs a **fresh full finite differential at all four capacities and all 34 controls**, about 1.6 seconds locally. It does not freshly replay the complete actual source, profile it, replace qualification, prove a mathematical theorem or certify performance. The manifest explicitly states finite-only coverage.

`actual_audit.py` is separately opt-in: it repeats the fresh original/16k derived full actual trace comparison, about 38 seconds here. Run only with a separately available serial budget, the original 180-second cap, 1 GiB sampled process-group RSS and no automatic retries. No automatic rerun is justified by this handoff.

The input is the complete official 97-file PR #5848 export at `66fb6c6b8683b37967e9d7f313b3df99a49d2406`, including unchanged PR #5831 and PR #5826 archives/notices. Exact module/function hashes, unique source edits and recursive executable-code binding are mandatory. Frozen files are never edited. The scoped installer restores the source callable on success and failure. `evidence/` retains all raw outputs/resource receipts, both table versions, cProfile statistics/data, runtime hashes and the screen.

## Open next questions

A separately assigned follow-up could examine whether source-bound type invariants allow moving the new table's repeated type validation out of the hot loop while preserving failure behaviour. The table currently checks five operand types per coefficient update, about 12.9 million checks. This overhead is visible in the implementation; its exact cost and any saving from relocation remain unmeasured. Such work needs an explicit well-formed-input contract, a proof of internal type preservation, malformed-input fallback and a new feasibility gate. No successor is dispatched here.

Other table policies or exact arithmetic algorithms require a fresh bounded reuse/primitive census and complete memory/time bill. No further capacity trial is authorized by this completed round. Kappa research, Work 1/2, feeds, agents and automations remain paused.

## Credit

Ali Romman supplied the original Fraction/error arithmetic and integer backend. Preserve [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 every retained P104/native/compiler/precision notice. [PR #5839](https://github.com/CrocSwap/integer-mult-bounds/pull/5839) supplies Linux observations; verification lineage includes [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 exact test-only [PR #5761](https://github.com/CrocSwap/integer-mult-bounds/pull/5761) authorship/cherry-pick credit. The previous negative artifact `71f22c77b393e5cc14925c771894dc1a92c8443c` supplies source-binding and fixture lineage. New profile/table/feasibility work: Chris R / Clear1nsight with substantial OpenAI Codex assistance; no subagents or independent human/kernel acceptance. Memoization is standard. Apache-2.0.
102 changes: 102 additions & 0 deletions research/fraction-contribution-table-feasibility/RESULT.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{
"actual_16384": {
"all_values_types_and_inputs_preserved": true,
"baseline_trace_seconds": 20.251469953014748,
"coordinates": 799,
"derived_trace_seconds": 14.599537244997919,
"events": 25984,
"full_output_sha256": "954c7448ff74d78753828e9623ad44c46da9e5ce459420b6e50a5d47294250b9",
"observed_seconds_removed": 5.65193270801683,
"profile_whole_qualifier_seconds": 38.31372155799181,
"status": "PASS_FULL_ACTUAL_FRACTION_TRACE_EQUIVALENCE",
"table_statistics": {
"bypasses": 0,
"calls": 2579750,
"capacity": 16384,
"evictions": 310400,
"hits": 2252966,
"misses": 326784,
"resident": 16384
},
"weights_sha256": "cf98bf5da5df28ec1ca3ca7e8723d740b98e142f31e94ff7ec36815cc387c373"
},
"actual_2048": {
"all_values_types_and_inputs_preserved": true,
"baseline_trace_seconds": 19.996063037018757,
"coordinates": 799,
"derived_trace_seconds": 16.578300290973857,
"events": 25984,
"full_output_sha256": "954c7448ff74d78753828e9623ad44c46da9e5ce459420b6e50a5d47294250b9",
"observed_seconds_removed": 3.4177627460449003,
"profile_whole_qualifier_seconds": 38.31372155799181,
"status": "PASS_FULL_ACTUAL_FRACTION_TRACE_EQUIVALENCE",
"table_statistics": {
"bypasses": 0,
"calls": 2579750,
"capacity": 2048,
"evictions": 643166,
"hits": 1934536,
"misses": 645214,
"resident": 2048
},
"weights_sha256": "cf98bf5da5df28ec1ca3ca7e8723d740b98e142f31e94ff7ec36815cc387c373"
},
"complete_qualifier_constructed": false,
"complete_wall_CPU_benchmark_run": false,
"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",
"omitted-witness",
"omitted-rounded-sites",
"wrong-coefficient",
"wrong-weighted-increment",
"bad-role",
"bad-scalar",
"missing-weight",
"restore-success",
"restore-exception",
"fresh-derivation",
"key-field-0",
"key-field-1",
"key-field-2",
"key-field-3",
"key-field-4",
"FIFO-eviction",
"canonical-key",
"hash-collision",
"disabled",
"invalid-capacity--1",
"invalid-capacity-16385",
"invalid-capacity-True",
"invalid-capacity-1.5",
"uncached-exception-0",
"uncached-exception-1",
"fresh-call-table",
"stats-mutation",
"failed-call-clears-stats"
],
"events": 10164,
"status": "PASS_FINITE_FRACTION_TABLE_FEASIBILITY"
},
"performance_claim": null,
"screen": {
"decision": "STOP_BEFORE_COMPLETE_CONSTRUCTION",
"extra_new_finite_wall_observation": 1.6209555940004066,
"further_capacity_trials": 0,
"modeled_complete_wall": 34.983938607008895,
"modeled_fraction_saved": 0.10331887278290623,
"modeled_not_a_complete_wall_CPU_benchmark": true,
"optimistic_fraction_ignoring_new_checks": 0.14486594687095472,
"prior_complete_wall_median": 39.01491572102532,
"required_fraction": 0.15,
"within_process_trace_seconds_removed": 5.65193270801683
},
"status": "SCOPED_NEGATIVE_COMPLETE_COST_SCREEN"
}
30 changes: 30 additions & 0 deletions research/fraction-contribution-table-feasibility/SOURCES.json
Original file line number Diff line number Diff line change
@@ -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-contribution-table-feasibility/inputs/PR5848.tar",
"usage": "input",
"git_blob": "307d09d2a968e1bbec8025d9fbd0a884df790d12",
"sha256": "f899600acb6966a6b028ffbf1e33a94061615626b510feaca8cb073f03a34de6",
"pin": "head:0b2de67914ff659b0e1fca4ff4f275228aa246d6:research/fraction-contribution-table-feasibility/inputs/PR5848.tar"
}
],
"external_origin": {
"pr": 5848,
"head": "66fb6c6b8683b37967e9d7f313b3df99a49d2406",
"export_files": 97
}
}
66 changes: 66 additions & 0 deletions research/fraction-contribution-table-feasibility/TASK.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"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 asked for primitive profile and feasibility before construction. Exact bounded table passes correctness and speeds the trace; complete-cost screen remains below15% after new checks, so no complete qualifier or performance PR.",
"actual_scope": "PR5848/frozen-66fb6c6/Fraction-primitives-and-bounded-contribution-table",
"bottleneck_link": "Faster trustworthy replays increase review throughput and let mechanism candidates be checked sooner.",
"stop_rule": "Stopped at complete-cost screen after the one declared final16k FIFO feasibility step. No further capacity/algorithm trial, complete qualifier, B/C benchmark or performance PR. Original180s source cap,600s initial/1500s shared cumulative,1GiB sampled group RSS, serialized, no automatic retries.",
"time_budget_minutes": 90,
"outcome": "negative-result",
"evidence": "PRIMITIVES profile, PROOF.md, RESULT.json and all raw evidence. 241 finite programs at4 capacities,34 controls, both2048/16384-entry actual audits, complete-cost screen and preserved bounds. All source bytes unchanged.",
"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": "Can source-bound invariant validation be moved out of the new hot loop without losing failure coverage?",
"why_it_matters": "The pure table introduces five type checks per coefficient update, about12.9 million checks; whether moving them changes the complete-cost decision is unmeasured.",
"first_step": "Separately bind a well-formed immutable Fraction input contract, prove internal type preservation, retain malformed-input fallback and profile the new hot path before a finite gate.",
"blocked_by": "A separately assigned source/independence/coverage scope; no automatic permission from this artifact."
},
{
"question": "Would a different bounded table or arithmetic algorithm clear the whole-stage gate?",
"why_it_matters": "The current16k table retains326784 misses; its measured trace benefit does not pay the complete15% target.",
"first_step": "Use a separately bounded reuse/primitive census and complete memory/time bill before construction.",
"blocked_by": "New overlap and feasibility gates; no extrapolated performance claim."
}
],
"base_commit": "de5ec2e7a6074068452f45b1a191b5c72832df4a"
}
Loading