Skip to content

spikes: W-4940 subtotal-regrouping verifier for exact future regrouping - #4945

Open
dankezo wants to merge 1 commit into
limitlessprojects:mainfrom
dankezo:spike/w4940-subtotal-regrouping
Open

dankezo wants to merge 1 commit into
limitlessprojects:mainfrom
dankezo:spike/w4940-subtotal-regrouping

Conversation

@dankezo

@dankezo dankezo commented Nov 29, 2026 •

Copy link
Copy Markdown

Spike for #4940 (Wildcard Track): an executable verification of the proposal "Compile the extra subtotals that keep a future regrouping exact after a task discards its input", plus the four artifacts the proposal did not produce.

What this spike does

Standalone directory spikes/w4940-subtotal-regrouping/ (no Hybrid language or compiler change):

  • plan.py - the generator. Grouping-driven, not calendar-driven: it walks each producer cell (Monday-Sunday weeks clipped to the year) in day order, splits it into maximal runs of equal consumer label (calendar months), and saves the prefix subtotal ending at every run boundary but the last.
  • checker.py - a plan checker independent of the generator (no shared code; the groupings are the shared input, the algorithms are not). It decides determinacy per producer cell by exact rational linear algebra, replays recovery against direct totals, proves every saved subtotal necessary with a concrete ablation witness pair, and derives its own lower bound - rank([P;C]) - rank(P) - the minimum over ALL scalar linear measurements, not just prefixes.
  • emit_go.py + emitted/ - plain Go for the weekly reducer and the recovery function for the 2026 fixture, generated from the verified plan, with the int64 overflow contract stated up front.
  • fiscal.py - the second-consumer experiment the issue asks for: can the summary compiled for calendar months answer fiscal periods starting on the 15th?
  • baseline.py - the both-totals comparison (state, operations, auditability).

Reproduced numbers (the proposer's pre-registered claims)

  • Basis inputs 366 + 365 + 365 for 2024 / 2025 / 2026: all recovered exactly; 200 seeded random inputs per year also exact.
  • Extra subtotal counts 9 / 9 / 10, matching the proposal exactly.
  • Minimality, strengthened: the checker's independently derived lower bound equals the counts in every year, so the prefix construction is minimal among all scalar linear measurements, not only among prefix schemes.
  • Ablation: every saved subtotal has a witness pair - two concrete inputs with identical stored summaries (under the reduced plan) and different true monthly totals.
  • The issue's diagnostic pair (one unit, Saturday 2026-01-31 vs Sunday 2026-02-01): identical weekly totals, separated by the saved subtotal, and the recovered January and February totals differ by one each, as they must.

The four additions beyond the proposal

  1. Emitted plain Go reducer + recovery (the proposal ran a Python model only).
  2. A generator-independent plan checker (the proposal had no checker).
  3. The fiscal-schedule second consumer: the calendar-compiled summary answers 0 of 13 fiscal periods exactly in 2026 (1 of 13 in 2024 and 2025). Witness: one unit on 2026-01-15 vs one unit on 2026-01-12 - same week, same calendar month, identical stored summary, different fiscal totals. Named in advance, the fiscal schedule would have cost 11 extra subtotals; both questions together cost 21, each provably minimal.
  4. The both-totals baseline: weekly+monthly and weekly+extras span the same space (equal ranks 62 / 62 / 63), so for this consumer the two stored forms carry identical information. Specialization buys state (63 vs 65 counters in 2026) and operations (about 1.10 vs 2.000 increments per record); it does not buy flexibility - both forms lose the fiscal schedule identically. RESULTS.md states this plainly, per the issue's own decision rule.

Verification level, honestly

Python side fully executed: python3 report.py ends with ALL CHECKS PASSED; python3 -m unittest discover -s tests runs 15 tests, all passing. The emitted Go has also been compiled and run for real: the three emitted files were combined into a single main package and executed in the Go Playground (Go 1.27) on 2026-11-29. It compiled with no errors and printed exactly the expected demonstration output (weekly totals identical: true; extra subtotals identical: false; Jan 31 input -> monthly [1 0 0 0 0 0 0 0 0 0 0 0]; Feb 1 input -> monthly [0 1 0 0 0 0 0 0 0 0 0 0]). The machine that produced this spike has no Go toolchain, so the in-repo module build still rests on repository CI; the construction is additionally verified by a test that parses the emitted tables back and replays the Go code's exact operations on basis and random inputs.

Full write-up: spikes/w4940-subtotal-regrouping/RESULTS.md.

@github-actions github-actions Bot added the bot:land-candidate Shepherd: fresh, gate-clean, verifiable (set from classify()) label Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:land-candidate Shepherd: fresh, gate-clean, verifiable (set from classify())

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant