Skip to content

Commit 62b675d

Browse files
explorer + ci: V2 strength GP web hookup + artifact / parity gates
Hooks the V2 strength GP up to the in-browser BOxCrete explorer and wires up the CI gates that enforce coherence between the deployed boxcrete model and the published model artifacts. JS-side V2 implementation (docs/explorer): * docs/gp_v2_fast.mjs — pure-JS implementation of the V2 gated-kernel posterior, optimised for the in-browser explorer. * docs/feature_registry.mjs — JS port of the F5_alllog feature builders to keep the JS path byte-identical to the Python path. * docs/gp.mjs / docs/ui.mjs / docs/units.mjs — explorer integration. * docs/generate_mix_analyses.py — produces per-mix analysis pages consumed by the explorer. * docs/model/README.md — documents the docs/model/ artifact layout. * docs/model/strength.json + compositions.json + test_vectors.json — refreshed model artifacts produced by the V2 fit. CI gates: * .github/workflows/strength-parity.yml — runs test_pretrained_loader_fidelity.py to guard that load_pretrained_strength_gp() faithfully reconstructs the deployed V2 strength GP from docs/model/strength_model.pt. * .github/workflows/model-artifacts-coherence.yml — guards that the published docs/model/ artifacts match the boxcrete fit output (catches stale artifacts after model code changes). Uses a cross-architecture-portable numerical drift check (experiments/check_artifacts_drift.py) instead of byte-level git diff. * .github/workflows/notebooks.yml + tests.yml — Python version bumps to match pyproject.toml's requires-python = ">=3.11" and BOXCRETE_SMOKE_TEST=1 env wiring for the notebook matrix. Regen pipeline (invoked by the artifacts-coherence gate): * experiments/regenerate_all_artifacts.sh — orchestrator. * experiments/regenerate_strength_json.py — Python regen of strength.json + test_vectors.json from a fresh V2 fit. * experiments/augment_test_vectors_with_gwp_cost.mjs — adds GWP / cost columns via the JS predictors. * experiments/regenerate_compositions_strength_predictions.mjs — regen of the static Pareto scatter dots. CI helpers: * experiments/check_artifacts_drift.py — numerical drift check. * experiments/run_notebook_with_progress.py — cell-by-cell timing helper used as a fast-fail step before nbconvert. * experiments/measure_fit_stability.py — empirical run-to-run fit determinism measurement (used during precision debugging). JS-side regression tests: * test/test_js_strength_v2.mjs — V2 posterior parity (Python vs JS). * test/test_js_physical_constraints.mjs — JS-side f(x, t=0) = 0 guard. * test/test_lengthscales_v2.mjs — JS-side lengthscale parity. * test/test_curve_monotonicity.mjs — strength-curve monotonicity. * test/test_data_freshness.mjs — guards that test_vectors.json is derived from the same data the deployed model was fit on. * test/test_js_ui_smoke.mjs — explorer UI smoke test.
1 parent ae767fc commit 62b675d

38 files changed

Lines changed: 5444 additions & 631 deletions

.github/workflows/e2e.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ name: E2E (Playwright)
66

77
on:
88
push:
9-
branches: [main]
9+
branches: [main, master]
1010
paths:
1111
- 'docs/**'
1212
- 'test/e2e/**'
1313
- 'playwright.config.ts'
1414
- 'package.json'
1515
- '.github/workflows/e2e.yml'
1616
pull_request:
17-
branches: [main]
17+
branches: [main, master]
1818
paths:
1919
- 'docs/**'
2020
- 'test/e2e/**'
@@ -46,7 +46,7 @@ jobs:
4646
project: [desktop, mobile]
4747

4848
steps:
49-
- uses: actions/checkout@v4
49+
- uses: actions/checkout@v5
5050

5151
- uses: actions/setup-node@v4
5252
with:
@@ -58,7 +58,7 @@ jobs:
5858

5959
- name: Cache Playwright browsers
6060
id: pw-cache
61-
uses: actions/cache@v4
61+
uses: actions/cache@v5
6262
with:
6363
path: ~/.cache/ms-playwright
6464
key: playwright-${{ runner.os }}-${{ hashFiles('package-lock.json') }}

.github/workflows/js-sync.yml

Lines changed: 69 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
# Verifies that the JavaScript GP implementation matches Python reference predictions.
2-
# Catches drift if model parameters or JS code are changed without re-syncing.
1+
# Runs the full JS-side test suite that pairs with the Python boxcrete
2+
# package: Python ↔ JS predictor parity, V2 posterior parity, JS-side
3+
# physical-constraint guards, lengthscale parity, curve monotonicity,
4+
# data-freshness check, units, and explorer UI smoke.
5+
#
6+
# Catches drift between the Python fit (boxcrete) and the in-browser
7+
# JavaScript GP (docs/gp*.mjs + docs/model/*.json artifacts) — if the
8+
# model, JS code, or model artifacts change without re-syncing the JS
9+
# port and the test_vectors.json baseline, this workflow fails.
310

411
name: JS Model Sync
512

@@ -14,14 +21,42 @@ on:
1421
branches: [main, master]
1522
paths:
1623
- 'docs/gp.mjs'
24+
- 'docs/gp_v2_fast.mjs'
25+
- 'docs/feature_registry.mjs'
26+
- 'docs/units.mjs'
1727
- 'docs/model/**'
1828
- 'test/test_js_gp.mjs'
29+
- 'test/test_js_strength_v2.mjs'
30+
- 'test/test_js_predictor_parity.mjs'
31+
- 'test/test_js_physical_constraints.mjs'
32+
- 'test/test_js_ui_smoke.mjs'
33+
- 'test/test_js_units.mjs'
34+
- 'test/test_lengthscales_v2.mjs'
35+
- 'test/test_js_feature_parity.mjs'
36+
- 'test/fixtures/feature_parity_fixture.json'
37+
- 'test/test_curve_monotonicity.mjs'
38+
- 'test/test_data_freshness.mjs'
39+
- '.github/workflows/js-sync.yml'
1940
pull_request:
2041
branches: [main, master]
2142
paths:
2243
- 'docs/gp.mjs'
44+
- 'docs/gp_v2_fast.mjs'
45+
- 'docs/feature_registry.mjs'
46+
- 'docs/units.mjs'
2347
- 'docs/model/**'
2448
- 'test/test_js_gp.mjs'
49+
- 'test/test_js_strength_v2.mjs'
50+
- 'test/test_js_predictor_parity.mjs'
51+
- 'test/test_js_physical_constraints.mjs'
52+
- 'test/test_js_ui_smoke.mjs'
53+
- 'test/test_js_units.mjs'
54+
- 'test/test_lengthscales_v2.mjs'
55+
- 'test/test_js_feature_parity.mjs'
56+
- 'test/fixtures/feature_parity_fixture.json'
57+
- 'test/test_curve_monotonicity.mjs'
58+
- 'test/test_data_freshness.mjs'
59+
- '.github/workflows/js-sync.yml'
2560

2661
env:
2762
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
@@ -30,11 +65,41 @@ jobs:
3065
js-model-sync:
3166
runs-on: ubuntu-latest
3267
steps:
33-
- uses: actions/checkout@v4
68+
- uses: actions/checkout@v5
3469

3570
- uses: actions/setup-node@v4
3671
with:
3772
node-version: '20'
3873

39-
- name: Run JS GP sync test
74+
# Run each JS test individually rather than via a globbing wrapper
75+
# so a single test failure surfaces with its own step in the CI UI
76+
# (easy to skim "which test broke" without scrolling logs).
77+
- name: Python ↔ JS GP equivalence (test_vectors.json)
4078
run: node test/test_js_gp.mjs
79+
80+
- name: JS ↔ Python feature builder parity
81+
run: node test/test_js_feature_parity.mjs
82+
83+
- name: V2 posterior parity (Python vs JS)
84+
run: node test/test_js_strength_v2.mjs
85+
86+
- name: Single-vs-batch JS predictor contract
87+
run: node test/test_js_predictor_parity.mjs
88+
89+
- name: JS-side f(x, t=0) = 0 physical-constraint guard
90+
run: node test/test_js_physical_constraints.mjs
91+
92+
- name: Explorer UI smoke
93+
run: node test/test_js_ui_smoke.mjs
94+
95+
- name: JS unit conversions
96+
run: node test/test_js_units.mjs
97+
98+
- name: JS-side lengthscale parity / identifiability
99+
run: node test/test_lengthscales_v2.mjs
100+
101+
- name: JS-side strength-curve monotonicity
102+
run: node test/test_curve_monotonicity.mjs
103+
104+
- name: Data-freshness (compositions.json vs live JS GP)
105+
run: node test/test_data_freshness.mjs

.github/workflows/lighthouse.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ name: Lighthouse CI
66

77
on:
88
push:
9-
branches: [main]
9+
branches: [main, master]
1010
paths:
1111
- 'docs/**'
1212
- 'lighthouserc.json'
1313
- '.github/workflows/lighthouse.yml'
1414
pull_request:
15-
branches: [main]
15+
branches: [main, master]
1616
paths:
1717
- 'docs/**'
1818
- 'lighthouserc.json'
@@ -31,7 +31,7 @@ jobs:
3131
timeout-minutes: 15
3232

3333
steps:
34-
- uses: actions/checkout@v4
34+
- uses: actions/checkout@v5
3535

3636
- uses: actions/setup-node@v4
3737
with:
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# Verifies that docs/model/*.json artifacts are coherent with the
2+
# Python V2 strength GP fit. Runs the regen pipeline and asserts no
3+
# diff — any uncommitted drift in strength.json / test_vectors.json /
4+
# compositions.json (e.g., from a manual edit, a partial regen, or
5+
# upstream model code that wasn't followed by a regen run) fails CI.
6+
#
7+
# See docs/model/README.md for the artifact schema + regen workflow.
8+
9+
name: Model Artifacts Coherence
10+
11+
permissions:
12+
contents: read
13+
14+
on:
15+
push:
16+
branches: [main, master]
17+
paths:
18+
- 'boxcrete/strength_model.py'
19+
- 'boxcrete/kernels.py'
20+
- 'boxcrete/likelihoods.py'
21+
- 'boxcrete/priors.py'
22+
- 'boxcrete/features.py'
23+
- 'boxcrete/utils.py'
24+
- 'boxcrete/__init__.py'
25+
- 'data/**'
26+
- 'experiments/regenerate_strength_json.py'
27+
- 'experiments/regenerate_compositions_strength_predictions.mjs'
28+
- 'experiments/augment_test_vectors_with_gwp_cost.mjs'
29+
- 'experiments/regenerate_all_artifacts.sh'
30+
- 'docs/model/**'
31+
- 'docs/feature_registry.mjs'
32+
- 'docs/gp.mjs'
33+
- 'docs/gp_v2_fast.mjs'
34+
- '.github/workflows/model-artifacts-coherence.yml'
35+
pull_request:
36+
branches: [main, master]
37+
paths:
38+
- 'boxcrete/strength_model.py'
39+
- 'boxcrete/kernels.py'
40+
- 'boxcrete/likelihoods.py'
41+
- 'boxcrete/priors.py'
42+
- 'boxcrete/features.py'
43+
- 'boxcrete/utils.py'
44+
- 'boxcrete/__init__.py'
45+
- 'data/**'
46+
- 'experiments/regenerate_strength_json.py'
47+
- 'experiments/regenerate_compositions_strength_predictions.mjs'
48+
- 'experiments/augment_test_vectors_with_gwp_cost.mjs'
49+
- 'experiments/regenerate_all_artifacts.sh'
50+
- 'docs/model/**'
51+
- 'docs/feature_registry.mjs'
52+
- 'docs/gp.mjs'
53+
- 'docs/gp_v2_fast.mjs'
54+
- '.github/workflows/model-artifacts-coherence.yml'
55+
workflow_dispatch: {}
56+
57+
jobs:
58+
regen-idempotency:
59+
runs-on: ubuntu-latest
60+
steps:
61+
- uses: actions/checkout@v5
62+
63+
- uses: actions/setup-python@v6
64+
with:
65+
python-version: '3.12'
66+
cache: 'pip'
67+
68+
- uses: actions/setup-node@v4
69+
with:
70+
node-version: '20'
71+
72+
- name: Install Python deps
73+
run: |
74+
python -m pip install --upgrade pip
75+
pip install -e .
76+
77+
- name: Save committed docs/model/ for later comparison
78+
# Snapshot the JSON artifacts BEFORE regen overwrites them, so
79+
# the post-regen comparison can diff against the committed copy.
80+
# We snapshot only the JSONs (not the .pt) because cross-arch
81+
# determinism on binary state_dicts requires bit-equality which
82+
# we can't expect from a multi-modal MLL fit; the JSON-level
83+
# checks cover the same coverage surface (lengthscales +
84+
# prediction surface) via experiments/check_artifacts_drift.py.
85+
run: |
86+
mkdir -p /tmp/committed_docs_model
87+
cp docs/model/strength.json /tmp/committed_docs_model/
88+
cp docs/model/test_vectors.json /tmp/committed_docs_model/
89+
cp docs/model/compositions.json /tmp/committed_docs_model/
90+
91+
- name: Run regen pipeline
92+
run: bash experiments/regenerate_all_artifacts.sh
93+
94+
- name: Assert artifacts agree with committed copy within tolerance
95+
# Replaces the legacy ``git diff --exit-code docs/model/`` check,
96+
# which was over-strict: it required bit-equality of JSON output
97+
# across architectures, but the V2 strength GP fit goes through
98+
# scipy's L-BFGS-B against a multi-modal MLL surface, and
99+
# different CPU architectures land in different local optima
100+
# (Apple Silicon via qemu-emulated amd64 vs GitHub-runner native
101+
# x86_64 produce ~2x different lengthscales while predicting
102+
# nearly the same surface). The new check tolerates this
103+
# cross-architecture basin divergence (10x ratio band on
104+
# internal hyperparameters) while still catching the original
105+
# failure mode (a stale export typically shifts predictions
106+
# by 100s of psi at OOT compositions). See the docstring of
107+
# ``experiments/check_artifacts_drift.py`` for the full rationale.
108+
run: |
109+
python experiments/check_artifacts_drift.py \
110+
--committed-dir /tmp/committed_docs_model \
111+
--fresh-dir docs/model

0 commit comments

Comments
 (0)