{
 "component": "baseline-toy: read-only reproduction and audit of toy-comparison/",
 "baseCommit": "aebd9183af6a4b1643ddd1e71277f0e8166f3eda",
 "objectiveStatus": "INCOMPLETE",
 "summary": "Build-and-test item. No repository file changed. All 18 unit tests pass, and all 14 fixture/method trials are solved with deterministic op counts. Every x in the inclusive [1000,5096] (4097 values) was checked for both methods: 0 failures and 0 runs over the limit. The toy group is the order-65393 subgroup of GF(130787)*, not secp256k1, so these numbers cannot calibrate Puzzle #140. Defects found: a width-0 off-by-one in fixture derivation, width-1 ZeroDivisionError, a>b ValueError, no guard against width>=N (two valid answers), asserts stripped by python -O, kangaroo op counts mixing fixed tame setup with solve work, the README's 'small memory' claim for kangaroo contradicted by measurement, and timings inflated by tracemalloc.",
 "files": {"changed": [], "created": ["artifacts/goal/batches/e2-runner-components/items/baseline-toy/result.json (this report, untracked)"], "scratch_not_submitted": ["test/scratch/audit.py"]},
 "environment": {"python": "CPython 3.12.3", "device": "unknown (task-supplied label absent); nproc=2", "network": "not used", "stdlib_only": true},
 "commands": [
  {"cwd": "toy-comparison", "cmd": "python3 -m unittest -v test_toy_dlog", "reported": "Ran 18 tests in 0.090s OK (TestGroup 5, TestFixtures 6, TestMethods 7)", "failures": []},
  {"cwd": "toy-comparison", "cmd": "python3 toy_dlog.py", "reported": "# summary: 14/14 trials solved (7 fixture(s) x 2 methods)", "failures": []},
  {"cwd": "toy-comparison", "cmd": "python3 toy_dlog.py --json (run twice, compared group_ops+recovered)", "reported": "identical across runs (deterministic)", "failures": []},
  {"cwd": "toy-comparison", "cmd": "python3 toy_dlog.py --fixture interior-charlie", "reported": "2/2 solved, bsgs 113 ops, kangaroo 260 ops (same as the full run)", "failures": []},
  {"cwd": "toy-comparison", "cmd": "python3 toy_dlog.py --fixture nope", "reported": "KeyError: \"unknown fixture: 'nope'\" traceback, raised from get_fixture in toy_dlog.py (no clean argparse error)", "failures": ["unhandled KeyError traceback for an unknown fixture name"]},
  {"cwd": "repo root", "cmd": "PYTHONDONTWRITEBYTECODE=1 python3 -I test/scratch/audit.py \"$PWD/toy-comparison\"", "reported": "exhaustive and extra-interval scans, out-of-range checks, invalid-input checks (see tests/measurements)", "failures": []},
  {"cwd": "toy-comparison", "cmd": "python3 -I -c: _derive_interior_x on widths 0,1,2; timing without tracemalloc (best of 50); python3 -O verify_group with N patched to 4", "reported": "see defects D1, D2, D6, D8"}
 ],
 "fixture_trials_14": [
  {"fixture": "endpoint-low", "x": 1000, "bsgs_ops": 66, "kangaroo_ops": 522},
  {"fixture": "endpoint-high", "x": 5096, "bsgs_ops": 129, "kangaroo_ops": 208},
  {"fixture": "interior-alpha", "x": 1417, "bsgs_ops": 72, "kangaroo_ops": 508},
  {"fixture": "interior-bravo", "x": 1881, "bsgs_ops": 79, "kangaroo_ops": 479},
  {"fixture": "interior-charlie", "x": 4102, "bsgs_ops": 113, "kangaroo_ops": 260},
  {"fixture": "interior-delta", "x": 1401, "bsgs_ops": 72, "kangaroo_ops": 490},
  {"fixture": "interior-echo", "x": 2001, "bsgs_ops": 81, "kangaroo_ops": 481},
  {"note": "all 14 ok=Y with recovered==expected. Limits: bsgs 130, kangaroo 624. Units: group ops = counted modular multiplications in gmul(). Peak memory (tracemalloc bytes): bsgs 4656-4688, kangaroo 25248-25296. These are synthetic toy fixtures with public known answers, not real keys."}
 ],
 "interval_definition": {
  "report_interval": "[1000,5096]",
  "b_minus_a": 4096, "inclusive_count": 4097,
  "implementation": "FIX_B = FIX_A + FIX_W, and Fixture.width = b - a = 4096 is an endpoint difference, not a count. Both solvers treat [a,b] as INCLUSIVE: BSGS searches y in [0,width] and accepts 0<=y<=width; kangaroo accepts a<=x<=b. All 4097 values were verified solvable (endpoint-high x=5096 included). The README's 'width 4096' and 'W = b - a' are consistent with the code, but README line 'One fixed interval [1000, 5096] (width 4096)' could be read as 4096 keys. sqrt sizing uses 4096, not 4097, which is harmless here because isqrt(4096)+1=65 still covers 4097 values (max covered y = 63*65+64 = 4159).",
  "interior_derivation": "off = 1 + (sha256 mod (W-1)) gives x in [a+1, b-1], exactly the 4095 strictly interior values. This is correct for W>=2. There is a slight modulo bias (2^256 mod 4095 != 0) of negligible size."
 },
 "op_count_split": {
  "bsgs": "setup uncounted: G^-1, G^-a, G^-m via builtin pow. Counted: 1 transform + m=65 baby steps + up to width//m+1 = 64 giant steps. Max = 130 = termination_limit exactly (observed 129 max in range, 130 for every out-of-range H). The test's +2 slack is unnecessary.",
  "kangaroo": "setup uncounted: jump factors G^(2^i) with k=8 (mean jump 31.875), start G^b, final verification pow. The counted ops include a FIXED tame phase of 3*isqrt(W)+16 = 208 ops on every solve, plus the wild phase. Over all 4097 x in [1000,5096]: total mean 413.1, max 522, wild-only mean 205.1, limit 624. endpoint-high's 208 is pure tame setup with 0 wild steps, because the wild starts on the tame start footprint. Reported 'g-ops' therefore mixes precomputation with solve work.",
  "units": "group operations = modular multiplications mod P"
 },
 "tests": {
  "implemented_and_passing": "18/18 repository unit tests",
  "audit_scratch_attempts": [
   {"case": "exhaustive [1000,5096], 4097 x", "bsgs_fail": 0, "kangaroo_fail": 0, "over_limit": 0},
   {"case": "[0,0] 1 x", "bsgs_fail": 0, "kang_fail": 0, "kang_ops": 19},
   {"case": "[0,1] 2 x", "bsgs_fail": 0, "kang_fail": 0},
   {"case": "[0,2] 3 x", "bsgs_fail": 0, "kang_fail": 0},
   {"case": "[7,22] 16 x", "bsgs_fail": 0, "kang_fail": 0, "kang_mean_ops": 33.7},
   {"case": "[100,355] 256 x", "bsgs_fail": 0, "kang_fail": 0, "kang_mean_ops": 89.1},
   {"case": "[5,1005] 1001 x", "bsgs_fail": 0, "kang_fail": 0, "bsgs_max": 64, "kang_mean_ops": 145.9},
   {"case": "[30000,34096] 4097 x", "bsgs_fail": 0, "kang_fail": 0, "kang_mean_ops": 323.2, "kang_max": 394},
   {"case": "[60000,65392] 400 sha256('audit|a|b|j')-derived x", "bsgs_fail": 0, "kang_fail": 0, "bsgs_max": 147, "kang_max": 416},
   {"case": "[0,16384] 400 sha256-derived x", "bsgs_fail": 0, "kang_fail": 0, "bsgs_max": 256, "kang_mean_ops": 599.3, "kang_max": 768},
   {"case": "out-of-range x in {999,5097,5596,500,0,65392} vs [1000,5096]", "result": "both methods returned None (kangaroo note limit-reached); no false claim. bsgs used 130 ops, kangaroo 521-537 ops"},
   {"case": "width>=N: [1000,66403], H=G^1005", "result": "bsgs returned 1005, kangaroo returned 66398 (both valid, since 66398 = 1005+N). Different answers with no warning: FAILURE of uniqueness guarding"},
   {"case": "a>b (10,5)", "result": "both raise ValueError: isqrt() argument must be nonnegative. FAILURE: no input validation"},
   {"case": "H=2 not in the order-N subgroup", "result": "both return None; no subgroup-membership check"},
   {"case": "negative a [-10,10], x=-3", "result": "both return -3 (works)"},
   {"case": "_derive_interior_x width 0, [0,0]", "result": "returns 1, OUTSIDE [0,0]. OFF-BY-ONE: span=-1, mod -1 = 0, off=1"},
   {"case": "_derive_interior_x width 1", "result": "ZeroDivisionError: integer modulo by zero"},
   {"case": "python3 -O with N patched to 4", "result": "verify_group() passes silently because asserts are stripped"}
  ],
  "kangaroo_failure_rate_observed": "0 of 9873 deterministic trials. Termination is guaranteed: wild_limit loop plus a break once a+dist_w > tame_max_exp. Failure is possible in principle but was not observed at these sizes.",
  "untested": ["widths > 16384 except width>=N case", "kangaroo multi-walk/distinguished points (not implemented)"],
  "unavailable": ["secp256k1 arithmetic, GPU, any real-target run (out of scope; never run)"]
 },
 "measurements": {
  "group": {"P": 130787, "N": 65393, "G": 4, "P_eq_2N_plus_1": true, "N_prime": true, "P_prime": true, "G_pow_N_mod_P": 1, "order_bits": 16, "is_secp256k1": false},
  "timing_s_interior_alpha": {"bsgs_traced": 0.000235, "kangaroo_traced": 0.002655, "bsgs_untraced_best_of_50": 0.000028, "kangaroo_untraced_best_of_50": 0.000211, "note": "tracemalloc inflates time about 8-12x. Seconds on CPython 3.12.3, unknown device. NOT transferable to #140."},
  "memory": {"bsgs_table_entries": 65, "kangaroo_footprint_entries_max": 209, "bsgs_peak_B": 4688, "kangaroo_peak_B": 25248, "finding": "README table says kangaroo memory is 'small (footprint table)', but in this single-table variant it stores 3*sqrt(W)+17 footprints, i.e. O(sqrt W) and about 5.4x BSGS peak bytes. The README's later sentence 'BSGS holds a full sqrt(W) table' implies kangaroo is lighter, which the measurement contradicts."},
  "calibration": "Group is a 16-bit finite-field subgroup. Its timings and op counts cannot calibrate a 2^139-wide secp256k1 search."
 },
 "defects_and_repair_guidance": [
  "D1 toy_dlog.py _derive_interior_x: for width<2 there is no interior. Raise ValueError when b-a<2 instead of returning a+1 (width 0) or dividing by zero (width 1).",
  "D2 verify_group and the _build_fixtures range check use assert, which python -O strips. Replace with explicit 'if not ...: raise RuntimeError'.",
  "D3 bsgs_interval/kangaroo: validate a<=b, 0<=b-a<N (reject width>=N because the answer is not unique), and that pow(h,N,P)==1 (subgroup membership). Raise ValueError otherwise.",
  "D4 kangaroo: report tame_ops (setup, currently always 3*isqrt(W)+16) and wild_ops separately in SolveResult, or document that g-ops includes precomputation. Remove the unused variable tame_reach.",
  "D5 README: change kangaroo memory to 'O(sqrt W) footprints in this single-table variant (measured ~5x BSGS)'. State 'b-a = 4096, 4097 inclusive candidates'. Rename width to span or add a count = b-a+1 field to JSON meta.",
  "D6 _measure: time with tracemalloc off (separate pass) so time(s) is not inflated by about 10x.",
  "D7 main --fixture: catch KeyError and call ap.error listing valid names.",
  "D8 tests: add exhaustive in-interval test for both methods (4097 x, ~1 s), width 0/1/a>b/width>=N/non-subgroup-H cases, and assert r.recovered is None for out-of-range H (current test_wrong_target_is_not_falsely_solved passes vacuously if recovered is None or anything in-range). Tighten the limit test to <= termination_limit (no +2)."
 ],
 "blockers": ["none for this audit; the real #140 objective is not addressed by this toy component"],
 "restartCommand": "cd toy-comparison && python3 -m unittest -v test_toy_dlog && python3 toy_dlog.py --json",
 "privacy": "Synthetic toy instances only. No real keys, wild-walk records or checkpoints included. Real target never run."
}
