Skip to content

G2 S3: spec/seed number consistency — audit minors m4/m5/m6/m7/n2#157

Merged
brownjuly2003-code merged 1 commit into
mainfrom
docs/g2-s3-spec-numbers-minors
Jul 6, 2026
Merged

G2 S3: spec/seed number consistency — audit minors m4/m5/m6/m7/n2#157
brownjuly2003-code merged 1 commit into
mainfrom
docs/g2-s3-spec-numbers-minors

Conversation

@brownjuly2003-code

Copy link
Copy Markdown
Owner

Closes the five minor G2-audit findings against docs/generator-spec.md (S3 of new_plen_05_07_26.md). Each finding got an explicit fix-vs-relax decision:

m5 — seed daily rate vs §1 (fixed the data)

satellite_seed.sql + satellite_seed_all_branches.sql spread 10,000 orders over 21 days (~476/day) while §1 pins ~1,965/day. Nothing else in the repo referenced the 21-day window (git grep '24 \* 21' — only the 5 seed lines), so compressing was the low-risk path: window is now (number * 7) % 122 — a ~122-hour (≈5.1-day) flat window, ≈1,965 orders/day, matching §11's "10,000 ≈ 5.1 baseline days" exactly. §11 gained a paragraph stating why §4's monthly seasonality is deliberately not encoded (baseline days are multiplier-1.0 by definition; a 5-day snapshot can't express a 12-month curve).

m6 — 12-digit GTINs failing is_valid_gtin13 (fixed the data)

synthetic_seed.sql's gs1_gtin stems now append the genuine GS1 mod-10 check digit. Implementation: a pinned 160-char check-digit string (one char per SKU slot) rather than inline SQL arithmetic — deliberately, so correctness is machine-verified locally: new test test_invariant_7_seed_sql_gtin_check_digit_string_is_genuine recomputes the string from the stem formula via gs1.gtin13_check_digit and asserts the SQL carries exactly it (plus structural guards on the stem formula). §12#7 now states the vault-seed literals are covered alongside the reference catalog.

m7 — equal-range amounts skewing averages high (fixed the data)

Old bands' midpoints ran above §1's average checks (mp 2,250 vs 2,150; B2B RU 55k vs 52k; dxb realized 101.3k vs 90k — the small dxb/ala slices didn't even wrap their modulus, so realized means drifted further than the midpoint). New bands are centered on §1 means and multipliers re-chosen (empirically, over the exact number ranges) to equidistribute: realized means mp 2,149 / d2c 3,301 / B2B msk 52,062 / spb 52,034 / ekb 51,920 / dxb 89,827 / ala 44,941. postgres_oltp/seed.sql mirrors. No new distribution scheme — same lo + (n * mult) % mod technique.

m4 — §12#4 vs §1 contradiction + weak/unpinned tests (fixed spec text + tightened tests)

§12#4's flat "Avg B2B check ∈ [30k, 80k]" excluded dxb's §1-mandated 90k. The data is right, the sentence was wrong: §12#4 now claims the order-weighted aggregate (§1 ⇒ ≈54.9k) and explicitly names dxb's 90k as the by-design outlier. Tests: test_invariant_4 now asserts the order-weighted B2B and marketplace aggregates (not just per-branch proxies); test_invariant_5_per_sku/test_invariant_7 pin len(products) == 160 / len(suppliers) == 30 so their loops can't pass vacuously; new test_build_reference_default_counts_match_spec pins the default catalog shape incl. the §6 country split 22 CN + 5 RU + 2 AE + 1 KZ (also catches silent tax-id-collision drops in _make_suppliers).

n2 — §10 FX constants declared but never applied (relaxed the spec)

Wiring AED/KZT into the seeds would be a currency-model rebuild, far beyond this finding's scope. §1/§10 now say what is actually true: every branch is seeded in ₽, no generator or seed converts FX at runtime, and the pinned AED/KZT/CNY constants live in reference/legend.py solely as the fixed basis for doc/evidence-level conversions (and for any future revision that does store branch-local currencies).

Verification

  • ruff check / ruff format --check on src/ tests/ scripts/ — clean
  • mypy src/ --ignore-missing-imports — clean (124 files)
  • pytest tests/unit/ tests/property/ — 1385 passed; 1 env-only failure (test_sdk_wheel_contains_py_typed_marker: local machine lacks the hatchling build backend for --no-isolation; unrelated to this diff, green in CI)
  • Amount-mean and window math verified numerically over the exact seed number ranges (values quoted above)

Reviewer sanity-checks: the 160-char check-digit string (test recomputes it — trust the test, not eyeballs); substring(..., number + 1, 1) 1-based indexing in ClickHouse; note docs/dv2-multi-branch/demo_evidence.md remains a dated capture of the old seeds — evidence regeneration is its own later plan step on the Mac stand.

🤖 Generated with Claude Code

…istency

- m5 (fix data): satellite seeds' order_date window 21d -> ~122h (about 5.1
  baseline days), 10,000 orders ~ 1,965/day per spec §1; §11 documents why §4
  seasonality is deliberately not encoded in a 5-baseline-day seed
- m6 (fix data): synthetic_seed.sql gs1_gtin now carries the genuine GS1
  mod-10 check digit (pinned 160-digit string, asserted against
  gs1.gtin13_check_digit by a new invariant test); §12#7 extended to state
  the vault-seed literals are covered
- m7 (fix data): amount bands re-centered on §1 avg checks (mp 1.5-2.8k mean
  2,150; d2c 2-4.6k mean 3,300; B2B RU 30-74k mean 52k; dxb 60-120k mean 90k;
  ala 25-65k mean 45k) with multipliers re-chosen so small branch slices
  equidistribute; postgres_oltp/seed.sql mirrors the same formulas
- m4 (fix spec text + tighten tests): §12#4 restated as the order-weighted
  aggregate B2B avg check (~54.9k in [30k,80k]) with dxb's 90k as the
  by-design outlier it always was per §1; invariant tests now assert the
  aggregates and pin spec-fixed defaults (160 SKUs, 30 suppliers 22/5/2/1,
  sourcing coverage per SKU)
- n2 (relax spec): §1/§10 now state every branch is seeded in RUB and no
  generator/seed converts FX at runtime; AED/KZT/CNY constants documented as
  doc-level-only conversion basis

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

DORA Metrics

  • Window: last 30 days
  • Branch: main
  • Deployment frequency: 84 total / 19.6 per week
  • Lead time for changes: avg 0.58h / median 0.0h
  • Change failure rate: 55.95% (47/84)
  • MTTR: n/a across 0 incident(s)

MTTR note: No failed mainline CI runs in the selected window.

@brownjuly2003-code brownjuly2003-code merged commit a577705 into main Jul 6, 2026
19 checks passed
@brownjuly2003-code brownjuly2003-code deleted the docs/g2-s3-spec-numbers-minors branch July 6, 2026 00:51
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.

2 participants