Skip to content

feat(spec+snapshot): MS_PER_MINUTE + Zod-strict snapshot schemas (cherry-pick E)#739

Merged
Flotapponnier merged 1 commit into
mainfrom
chore/cherry-spec-snapshot-refactors
Jun 26, 2026
Merged

feat(spec+snapshot): MS_PER_MINUTE + Zod-strict snapshot schemas (cherry-pick E)#739
Flotapponnier merged 1 commit into
mainfrom
chore/cherry-spec-snapshot-refactors

Conversation

@Flotapponnier

Copy link
Copy Markdown
Collaborator

PR E — the riskiest of the dev → main reconciliation series. Reviewer-validated SAFE TO MERGE.

Strategy: minimal-change

Main was already AHEAD of dev on spec.ts (chain-aliases #708/#711/#724, expectedN #732, quorum guard #631 all already cherry-picked). Dev's only real additions are:

spec.ts (cosmetic)

  • MS_PER_MINUTE refactor: 2 magic numbers replaced (3-line diff)
  • Cache keys bumped bench-unfiltered v14→v15, all-benchmarks v18→v19 (regenerate for snapshot v5 below)
  • Preserves: chain-aliases reconciliation, bestForChain re-export, AllBenchmarksDraftError, quorum guard, expectedN overlay

snapshot.ts (real upgrade)

  • Full file replaced 323L → 441L (dev version)
  • Strict Zod schemas replace z.any() for ProviderResult / ResultExtras / MetricPanel / CellRankEntry / StalenessMeta / RegionPoint
  • AssertEqual compile-time guards (4 const checks) — build fails if types drift from Zod schemas
  • SnapshotPayload adopts expectedN + dataConfidence → completes PR feat(sample-health): per-provider data confidence + aggregate (cherry-pick A) #732 sample-health on persistence side
  • SCHEMA_VERSION bumped 3→5. v3 blobs safeParse→null→live Prom rewrites under v5 (graceful, verified)
  • Removes as ProviderResult[] casts

Reviewer agent verdict

All claimed-preserved elements present at expected lines... Graceful degradation on SCHEMA_VERSION mismatch is intact... No external callers of @/lib/snapshot outside spec.ts. SAFE TO MERGE.

Risk

  • Zero callers of snapshot.ts outside spec.ts
  • Old v3 KV blobs → safeParse null → live Prom path absorbs (one-time cold render per slug)
  • 5 pre-existing main TS errors unchanged (out of scope)

…emas (PR E)

PR E in dev → main reconciliation. Minimal-change strategy: main was
already ahead on spec.ts (chain-aliases reconciliation, expectedN
overlay, quorum guard all already cherry-picked). Dev only brings
2 real additions:

spec.ts changes (cosmetic):
- Import MS_PER_MINUTE from @/lib/time-constants
- Replace 30 * 60_000 → 30 * MS_PER_MINUTE (line 50)
- Replace / 60000 → / MS_PER_MINUTE in log fmt (line 61)
- Cache keys bumped bench-unfiltered v14 → v15,
  all-benchmarks v18 → v19 (regenerate stored snapshots through
  the new shape v5 below)
- Everything else preserved: chain-aliases import, bestForChain
  re-export, overlayEditorial canonical-slug reconciliation,
  expectedN passthrough, AllBenchmarksDraftError, quorum guard.

snapshot.ts changes (real upgrade):
- Replace full file with dev's 441-line version
- Was: 323 lines with z.any() loose validation
- Now: strict Zod schemas for ProviderResult / ResultExtras /
  MetricPanel / CellRankEntry / StalenessMeta / RegionPoint
- Adds AssertEqual compile-time guards (4 const checks) that fail
  the build if @/types/benchmark drifts from the Zod schemas
- SnapshotPayload adopts expectedN + dataConfidence (completes
  PR #732 sample-health on the persistence side — sample-health
  fields now survive KV roundtrip)
- snapshotFromBenchmark writes the new fields too
- SCHEMA_VERSION bumped 3 → 5 (covers both branches' versions)
  Old v3 blobs in Upstash KV will safeParse → null → live Prom
  path takes over and rewrites under v5. Graceful degradation
  intact (verified in readSnapshot at line 373).
- Removes 'as ProviderResult[]' casts (Zod now guarantees shape)

Risk: LOW (per second-pass review by reviewer agent).
- No external callers of snapshot.ts (only spec.ts imports it).
- No external constructors of SnapshotPayload (only
  snapshotFromBenchmark builds it).
- One-time cold render per (slug, variant) on first reader after
  deploy. With READ_FROM_STORE=1 the worker snapshots absorb it;
  without, it's a single Prom fan-out per bench.
- No caller signature changes.
@Flotapponnier
Flotapponnier merged commit 26e07ee into main Jun 26, 2026
1 check failed
Flotapponnier added a commit that referenced this pull request Jun 26, 2026
Dev was force-pushed after PR #730 and the venue support in BenchmarkFilters (materialize/filters.ts) was lost in the spec/snapshot refactor PR #739. The worker still references f.venue and dims.venue, so typecheck failed. Re-add venue across:
- BenchmarkFilters union (load.ts)
- parseFilterSig allowlist
- Spec.dimensions schema (spec-schema.ts) so YAML venue dim parses
@Flotapponnier
Flotapponnier deleted the chore/cherry-spec-snapshot-refactors branch July 17, 2026 14:41
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.

1 participant