Contributing¶
Ground rules¶
- Contract-only. Never import PhosKinTime code or read its result folders, workbooks or pickles. Data comes from a bundle that validates against a vendored schema in
contracts/. ESLint enforces the import rule. - No hard-coded meanings. Parameter labels, groups and units come from the manifest. Show the raw name when a label is missing.
- Nulls are gaps. Never render a missing value as 0. Never interpolate between sparse observations.
- Parity first. A panel that redraws a PhosKinTime plot computes the same numbers. Add the formula to
tests/reference/compute_reference.pyand a comparison totests/parity/parity.test.ts(rtol 1e-9; justify anything looser). - Synthetic data only in fixtures, screenshots and the demo.
Adding a panel¶
- Write
src/lib/panels/<workflow>/<Name>.sveltetaking{ bundle, report }. Put plotted rows inreport.rows(CSV export and raw-rows view) and caveats inreport.notes. - Register it in
src/lib/panels/registry.tswithrequires(tables and columns),minSchema,parity(file, function,defline, commit, ornullfor a viewer extra),coverageandpatterns. - Add it to
docs/panel-inventory.mdanddocs/plot-patterns.md. Add an entry todocs/substitutions.mdif it differs from PhosKinTime. - Marks with more than about 1,000 elements use canvas (
CANVAS_MIN).
Supporting a new upstream schema¶
npm run sync-contracts -- <phoskintime checkout> <ref>. It fails if a new major has no adapter.- Add
src/lib/contracts/adapters/v<major>.tsmapping the manifest toBundleMeta, and register it inadapters/index.ts. Panels do not change. - Generate fixtures with the upstream command, from the upstream checkout, with the output outside it:
pixi run phoskintime bundle create --synthetic-fixtures --out <dir>, thenpixi run phoskintime bundle verify <dir>/network.pkt.zip. Copy the zip totests/fixtures/upstream-<X.Y>/, record the commit in itsSOURCE.md, and run all tests.
Visual regression baselines¶
tests/visual/visual.spec.ts screenshots every section in light and dark themes
(npm run test:visual). After an intended visual change:
Review every changed PNG in tests/visual/visual.spec.ts-snapshots/ (they are synthetic-data
screenshots) and commit them with the change that caused them, stating why in the message.
Exports¶
- Figures export through
src/lib/export/(PNG, PDF, SVG, CSV) andsrc/lib/tikz/(PGFPlots). A panel needs nothing extra: marks imported fromsrc/lib/plotare recorded automatically. Never import marks fromsvelteplotdirectly in a panel. - A new mark type needs a wrapper in
src/lib/plot/, a case insrc/lib/tikz/emit.tsand a golden snapshot intests/unit/tikz.test.ts. tests/tikz/compile_all.shcompiles TikZ exports. Run it after emitter changes:node tests/tikz/export_all.mjs network tests/tikz/out tikz && bash tests/tikz/compile_all.sh tests/tikz/out/all-panels_*.zip. Comparison sections:node tests/tikz/export_compare.mjs tests/tikz/out/compare && bash tests/tikz/compile_all.sh tests/tikz/out/compare.- The PDF/PNG comparison in
tests/e2e/pdf-fidelity.spec.tsneeds Ghostscript (gs). - The TikZ gallery:
node tests/tikz/gallery.mjs <png-zips> -- <compile-workdirs>, thenpython tests/tikz/downscale_viewer_pngs.py(needs TeX Live and Ghostscript).
Hooks¶
pre-commit install (see .pre-commit-config.yaml) runs formatting checks, ruff and eslint on
commit, checks the commit message, and runs the type check and unit tests before a push.
Checks before a PR¶
npm run lint && npm run check && npm test && npm run test:parity && npm run build:single && npm run test:e2e
Use conventional commits. main is protected (linear history, no force-push).