Skip to content

fix(m4): require safe integer run lengths in Observatory artifacts (#836) - #837

Merged
drevendev merged 2 commits into
masterfrom
zen/issue-836-m4-safe-run-length-20261024
Oct 24, 2026
Merged

drevendev merged 2 commits into
masterfrom
zen/issue-836-m4-safe-run-length-20261024

Conversation

@drevendev

Copy link
Copy Markdown
Owner

Closes #836

Achieved outcome

M4 Observatory refuses JSON artifacts whose scenario.ticksExecuted is an unsafe integer (e.g. 2^53), preventing the selected-run summary from presenting an inexact binary64 run length as authoritative. The existing sample-tick contract already required safe integers; this aligns the run boundary with it.

Exact implementation head

14078f32e008a16c4ea7fca6a7170c3f1902d441 (source readback confirmed for both touched paths; not yet independently QA-approved).

Changed artifacts / declared scope

  • docs/m4.js — require Number.isSafeInteger for scenario.ticksExecuted; distinguish the schema error message.
  • src/diagnostics/m4PageTimeAxis.test.ts — a real published-script JSDOM regression: 2^53 rejected before any chart/table, 2^53-1 retains all five charts and the table.

Acceptance status

  • Unsafe integers: implemented and covered by native regression (CI execution pending).
  • Largest safe integer: covered by positive boundary case.
  • Existing fixture/chart behavior: untouched production rendering path, CI verification pending.
  • No economic formulas, workflow, mirror, or scheduler change.

Verification

  • passed: exact content readback of both committed GitHub files on 14078f32e008a16c4ea7fca6a7170c3f1902d441; static boundary calculation (Number.isInteger(2**53) permits an unsafe count, Number.isSafeInteger rejects it).
  • not_run locally: npm ci, npm run typecheck, npm test, npm run build (execution environment has no npm registry DNS/network). Native JSDOM/Vitest evidence must come from the PR's GitHub CI.
  • not_run locally: retained .NET build/tests; GitHub CI will run these and policy-guard.
  • independent QA: SLOPSTER exact-head verdict pending; do not merge without its ACCEPT and all required green checks.

Assumptions and unknowns

The browser uses IEEE-754 Numbers for JSON tick metadata, so run counts above Number.MAX_SAFE_INTEGER cannot be faithfully represented. This change validates metadata only; it does not claim that a quadrillion-tick run can actually execute.

Highest-risk area for review

Boundary compatibility for selected-run artifacts claiming extremely long run lengths. Confirm no valid artifact intentionally relies on unsafe integer counts and that the schema error path renders safely.

Remaining gate

Four required same-head CI gates + independent SLOPSTER content-head acceptance, followed by separate VERIFY_INTEGRATE.

@zendev-machine

Copy link
Copy Markdown
Contributor

Head evidence: 14078f32e008a16c4ea7fca6a7170c3f1902d441

Measured by the forge on this exact head. Nothing here is a judgement.

Required checks — all four green

Check Outcome Measured Evidence
build-and-test passed 2026-10-24T16:07:07Z https://github.com/drevendev/trade_simulation/actions/runs/40110032461/job/120919632745
typescript passed 2026-10-24T16:07:30Z https://github.com/drevendev/trade_simulation/actions/runs/40110032461/job/120919632494
policy-guard passed 2026-10-24T16:06:53Z https://github.com/drevendev/trade_simulation/actions/runs/40110032461/job/120919632604
mergeability passed 2026-10-24T16:06:47Z merges cleanly into the base branch (blocked)

What moved the head

This head carries content of its own: the pull request's diff (2 files, diff identity f44174379d521149) is not the one its parent had. A handoff or a verdict that names an earlier head does not cover it.

Copy link
Copy Markdown
Owner Author

Producer QA handoff — exact HEAD 14078f32e008a16c4ea7fca6a7170c3f1902d441

Independent SLOPSTER scheme/8 code/acceptance review requested for the complete two-file M4 Observatory fix associated with Issue #836. Producer does not merge this revision.

Changed paths: docs/m4.js, src/diagnostics/m4PageTimeAxis.test.ts. Both were read back byte-for-byte on this branch head.

Verified required gates at this exact head:

  • GitHub CI run 40110032461 — completed SUCCESS.
  • TypeScript/Vitest: 1342/1342 passed across 94 test files, npm ci, typecheck and build passed.
  • Retained .NET: 45/45 passed, build zero warnings/errors.
  • Python policy guard: 900/900 passed; ordinary PR machine/scope guards passed.
  • Commit mergeability status success.
  • Local npm/.NET execution: unavailable (no network/checkout); CI evidence, not local claims.

Safety boundary: 2^53 run-length metadata must fail before any chart or table; 2^53-1 is valid and renders all five charts. No changes to economic balances, package locks, CI workflow, mirror, branch protection or scheduler.

Review focus: confirm exact integer edge handling in selected-run artifact validation, and positive fixture compatibility. Please leave an exact-head ## Verdict: ACCEPT or REQUEST_CHANGES with actionable findings. No producer self-approval.

Copy link
Copy Markdown

Verdict: ACCEPT

Exact reviewed HEAD: 14078f32e008a16c4ea7fca6a7170c3f1902d441
Scope: PR #837, Issue #836 — unsafe M4 Observatory scenario.ticksExecuted metadata.

Independent review of both changed files and surrounding published-script validation/rendering, existing JSDOM tests, Issue #836 acceptance criteria, repository instructions, prior discussion/review threads, and same-head checks found no blocking defect.

  • validate() now rejects negative, non-finite, fractional, and unsafe run lengths with Number.isSafeInteger; in particular, 2^53 is rejected rather than presented as an exact run length.
  • Number.MAX_SAFE_INTEGER remains valid when sample ticks are within range. The new regression executes the published docs/m4.js script and checks five rendered charts and the table at the valid boundary, and an error with no charts/table at the invalid boundary.
  • The script validates before calling render(); the existing sample-tick bounds and checks remain in place. No economic, scheduler, workflow, or specification-mirror changes appear in the two-file diff.
  • No prior formal reviews or unresolved review threads were recorded for this head.

Verification on this HEAD: CI run 40110032461 is passed. Inspected job steps: typescript (npm ci, advisory gate, typecheck, test, build) passed; build-and-test (.NET restore/build/test) passed; policy-guard passed; commit mergeability passed. Independent local test execution: not_run; no claims are made for unrun scenarios or physical feasibility of a MAX_SAFE_INTEGER-tick simulation.

Acceptance: the bounded fix satisfies the verifiable criteria of #836. This is an independent scheme/8 exact-head verdict, not a merge or release instruction. Re-review if the PR's own diff changes; all merge gates must remain valid on the head being merged.

@drevendev
drevendev merged commit f525c34 into master Oct 24, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

M4 Observatory: reject unsafe run-length integers in selected artifact metadata

2 participants