To report a bug or ask for a feature, open an
issue. Say what you did, what you expected,
what happened, and the jsonvet version (jsonvet --version). Report a vulnerability as
SECURITY.md says, not in an issue.
Clone with --recurse-submodules and install the tools in mise.toml (mise install), plus
Rust from rustup. Then run just setup once. It fetches the json5-tests submodule and installs
the git hooks with prek, including a commit-msg hook that checks
each commit's sign-off, so commit with git commit -s
(why). just --list shows every task.
Some checks need tools that mise.toml does not install:
| Tool | For |
|---|---|
| valgrind and gungraun-runner | just counts and just scaling (Linux only) |
| samply, perf | just profile and just counters (perf: Linux only) |
| wasm-bindgen-cli and wasm-opt | just playground |
| docker | just matrix |
pnpm (Node comes from mise.toml) |
just vsix, just playground and the vscode job |
| cargo-release | releasing |
Run just check before you open a pull request. It runs CI's lint and test jobs on your OS:
formatting, clippy, rustdoc, cargo deny, ruff, zizmor, the version check, the conformance page
check, and the tests with doctests. The page check fails while README.md,
docs/conformance.md or docs/conformance.json has unstaged edits, so stage them first.
zizmor runs its online audits only when GH_TOKEN is set, so without it just lint can pass
where CI fails.
just check leaves out these jobs in ci.yml:
teston the other two OSes, with clippy there too, since code behindcfg(unix)orcfg(windows)warns only on its own OS. On macOS it also runsscripts/test-action.sh, the Action script's tests, under bash 3.2. Runbash scripts/test-action.shyourself when you changescripts/action.sh.msrv,scaling,benchanddifferential:just msrv,just scaling,just countsandjust differential.vscode, the extension ineditors/vscode:cd editors/vscode && pnpm install --frozen-lockfile && pnpm run check && pnpm test && pnpm run build. The job also runs the docs pages' tests (pnpm --dir scripts/docs-site test), which build the site and check its links, anchors, old addresses and Content-Security-Policy.hook,actionandpackaging, which build the wheels and run the hook and the Action as users do.
Other workflows:
- On a pull request:
semver.yml(cargo semver-checks),fuzz.yml(30 seconds a target),coverage.yml(Codecov) andcodspeed.yml(benchmarks, only when the crates, Cargo files or SchemaStore fixtures change), andwheels-check.yml(the release wheels, built without an upload, only whenCargo.lock, aCargo.toml,.cargo/config.toml, the maturin config or the wheel matrix inwheels.ymlchanges). - Every week:
fuzz.ymlandmutants.ymlin full. Every Monday:advisories.yml, so a new RustSec advisory againstCargo.lockfails a run without waiting for a pull request. pages.ymlbuilds and tests the playground on a pull request that touches it ordocs/, and deploys it from main. It buildsdocs/*.mdinto the site'sdocs/pages with Starlight inscripts/docs-site(pnpm testthere checks every link, every anchor and every inline script's hash in the page's policy). On a pull request it also keeps screenshots of the page and three docs pages (playground/screenshots.sh: desktop and phone, light and dark) as theplayground-screenshotsartifact for 14 days, and a comment on the pull request links the newest one.just playground [PORT]does the same build and tests, and serves it at http://127.0.0.1:8000/jsonvet/, or at the PORT you pass.- A pull request that touches the playground, is open, not a draft and not from a bot or a fork,
also gets a preview at its own
jsonvet-playground-pr-<number>Worker on workers.dev (thepreviewjob inpages.yml).preview-retire.ymldeletes that Worker when the pull request closes or turns draft, and sweeps daily for strays. It needs theCLOUDFLARE_API_TOKENandCLOUDFLARE_ACCOUNT_IDsecrets in thepreviewenvironment, and skips quietly without them. scorecard.ymlrates the repository for the OpenSSF Scorecard badge.
Put each detail of the docs in one place and link to it: the README to get started,
docs/usage.md for the reference, docs/design.md for why, and
docs/decisions/ for the choices behind it.
main takes changes only through pull requests. Write commit subjects as
Conventional Commits, such as
fix(parser): reject a lone CR in a JWCC comment. A change in behaviour comes with a test that
fails without it, and a bug fix with a test that reproduces the bug. A change that reopens a
choice in docs/decisions/ brings the evidence its "Revisit if" asks for.
A pull request over 500 changed lines (generated files excluded) gets a CI warning: split a
refactor into its own pull request.
Prefer the standard library or a crate the workspace already uses. A new dependency in jsonvet
or jsonvet-cli needs a reason in the pull request: what it saves, that it is maintained, and for
a speed-up, the measurement 0004 asks
for. cargo deny checks that every crate in Cargo.lock comes from crates.io, has a permissive
licence and has no RustSec advisory or unmaintained notice. Renovate bumps the pins
(schedule); do not bump a pin by hand.
- Snapshots. CLI output is tested with insta. Review a
.snapdiff withcargo insta review, or accept everything withINSTA_UPDATE=always cargo test, then read the diff before you commit. - Corpus.
tests/corpus/<dialect>/has one file per case. Its bytes are part of the test, so.gitattributesand the hooks leave it alone. Do not let an editor reformat those files, or those with\uXXXXescapes in tests and snapshots. - SchemaStore.
tests/schemastore/holds real schemas with the files SchemaStore's own tests accept and reject, andcrates/jsonvet-cli/tests/schemastore.rschecks that jsonvet agrees. Refresh them withuv run scripts/schemastore-fixtures.py <a SchemaStore clone>, and add jsonvet's own cases under a schema'sextra/. - File lists. A new default extension or file name in the library (
Dialect::EXTENSIONS,Dialect::FILE_NAMES) goes into both hooks in.pre-commit-hooks.yaml,scripts/action.sh, and the README's file list and dialect table, orcrates/jsonvet-cli/tests/file_lists.rsfails. - New rules and dialects. A rule goes in
Rule::ALL(crates/jsonvet/src/rule.rs), with arule.<id>.explanationincrates/jsonvet-cli/src/messages.rsand the same words in a### <id>section ofdocs/usage.md, orevery_rule_has_help_that_its_docs_section_holdsfails. The--helptext must name it, orhelp_names_every_rule_and_dialectfails. A dialect goes inDialect::ALL(crates/jsonvet/src/dialect.rs) and the--helptext. Add either to the README's table. - Conformance matrix.
just matrixruns one set of inputs through 18 other parsers in docker containers, then rendersdocs/conformance.mdanddocs/conformance.json. Commitconformance/results/and the rendered files. CI fails when the report is stale, or whenconformance/results/versions.jsondisagrees with the pinned parsers. After a pin change, runjust matrix-lockfirst (details). - Fuzzing.
just fuzz check(ordiff_serde_json,diff_json5,parse,fix,config,config_file) runs a target for 20 minutes on a nightly toolchain. A new json5 version infuzz/can need new skips indiff_json5: read its skip list before you call a divergence a jsonvet bug. - Language server.
cargo nextest run -p jsonvet-cli lspruns the in-process tests. The stdio test islsp_checks_a_document_over_stdio_and_exits_0_after_shutdownincrates/jsonvet-cli/tests/cli.rs. - Mutation testing.
just mutantstakes over an hour on one CI runner, somutants.ymlruns it weekly in 64 shards, 15 at a time; itsshardsinput reruns only the ones you list. It fails when a mutant survives that.cargo/mutants.tomldoes not list. List one there only when it changes no behaviour, and say why. On a pull request,mutants-diff.ymlruns it on the changed lines only, in eight shards; locally,git diff origin/main... > pr.diff && cargo mutants --in-diff pr.diffdoes the same. - Differential.
just differentialcompares jsonvet with check-json5 1.4.1 on generated files. CI runs 5,000 cases with a new seed each run. - Speed claims. Measure with
just benchon a quiet machine, and report the median. For a release's speed table, thebenchworkflow runs it on a GitHub runner instead. To compare two builds, write the fixtures withjust profile-filesand runhyperfine -N -r 40on both. Time a change that touches every file on the 10,000-small-file walk too. - Instruction counts.
just countscounts the instructions of the parser (crates/jsonvet/benches/check.rs) and of whole--schemaruns (crates/jsonvet-cli/benches/schema.rs) under callgrind, and prints each case's change since the last run. A change under 0.3% is noise. CI fails a pull request when a case rises by more than 1% over the base branch. Compare two commits withjust counts --save-baseline=baseon one andjust counts --baseline=baseon the other. In a Docker container, setGUNGRAUN_ALLOW_ASLR=yes.gungraun-runnermust be the gungraun version inCargo.lock. - CodSpeed. CodSpeed comments each pull request's change in time, peak memory and
allocations on the divan benchmarks in each crate's
benches/codspeed.rs. Its check fails on a slowdown, but it is not a required check, because its path filter would leave docs-only pull requests waiting on it: thebenchjob is the gate. Neither sees wall time, so time a scanner change withhyperfine -Nas well (decision 0004). - Profiling.
just profile-fileswrites the bench files and 13 large cases totarget/profile-files: one per scanner path (pretty and minified objects, rows, strings, numbers, deep nesting, JSONC, JSON5, JSON Lines) and canada, citm_catalog and twitter from serde-rs/json-benchmark.just profile FILErecords call stacks with samply,just counters FILEreads the CPU's counters withperf stat(instructions per cycle, branch and cache misses) on one CPU, andjust threadstimes the small files on 1 to 8 CPUs.just core=2 compare mainbuildsmainin a temporary worktree and prints a table of instructions on the 13 cases,mainagainst your working tree; a change under 0.1% is noise. All four use theprofilingbuild: release code with line tables and frame pointers. The counters need perf access to the hardware, which CI runners and most containers lack, so they guide a change;just countsstill decides it. - Scaling.
just scalingrunscrates/jsonvet-cli/tests/scaling.rsunder valgrind, on Linux only. Each test counts the instructions on an input of size n and 10n. Most fail when the ratio reaches 15 (linear gives about 10): duplicate keys on many lines and on one long line,--schemaon keys with lone surrogates and on many$refs by$id, json5's hex numbers in thediff_json5target, and a walk with manyexcludeanddialectspatterns. Two fail unless the count stays within twice: schema errors past the first 100, and keys too costly for a pattern past the first 100.
Messages people read live in two tables of ids and English text: MESSAGES in
crates/jsonvet/src/messages.rs for problem messages, and ENGLISH in
crates/jsonvet-cli/src/messages.rs for everything else the command says, plus
rule.<id>.description for each rule. To add a language, write
crates/jsonvet-cli/locales/<locale>.toml, such as de.toml or pt_BR.toml, with a
"id" = "text" line for each id you translate, keeping every {name} in it. A count has two ids,
such as summary.files.one for 1 and summary.files.other for any other number; the .one text
may leave out {count}. build.rs bundles every file there, so nothing else changes.
- Format. Each text is a TOML string:
\nis a line break,\"a quote, and"""starts a text over several lines. Quote every id:rule.syntax.explanation = "..."without quotes is a TOML table, and the file is not used.#starts a comment.helpis the whole--helptext, layout included. - Check.
cargo nextest run -p jsonvet-cli messagesfails on a file that does not parse, an unknown id, or a text with other{name}s than its English one. At run time a broken file gives English, with no warning. - Try it.
LC_ALL=de cargo run -q -p jsonvet-cli -- file.jsonshows the text output in German. jsonvet readsLC_ALL, thenLC_MESSAGES, thenLANG, andpt_BR.UTF-8takespt_BR.toml, elsept.toml. It does not readLANGUAGEor the Windows language setting. - What stays English. The JSON and SARIF documents, rule ids, severities, JSONPaths and exit codes, and the text of other crates: jsonschema's validation messages, TOML syntax errors, argument errors and operating system errors (0013).
A new message gets an id in one of the tables, never a string in the code.
A release changes the version in these places, in one commit on a branch:
versionin the rootCargo.toml, andCargo.lockwith it- the
=x.y.zpin onjsonvetincrates/jsonvet-cli/Cargo.toml - the pin in
setup.py versionand thejsonvet==pin incompat/check-json5/pyproject.tomlversionineditors/vscode/package.jsonrev: vX.Y.Zin the hook examples inREADME.md,docs/usage.mdanddocs/format.md- in
CHANGELOG.md, the Unreleased entries moved under a new## [X.Y.Z] - dateheading, and the compare links at the bottom
cargo-release makes all of them. It only bumps and
commits, and refuses to run on main (0011). Write the
Unreleased entries first; the release commit only moves them. Every figure in a release's
CHANGELOG section compares with the last release.
git fetch && git switch -c release/X.Y.Z origin/main
cargo release X.Y.Z # dry run: shows every change
SKIP=dco-signoff,check-versions cargo release X.Y.Z --execute # commits "chore: release X.Y.Z"
git commit --amend -s --no-edit # cargo-release cannot sign off
git push -u origin release/X.Y.Z # a new minor only: the speed table, from bench.yml
gh workflow run bench.yml --ref release/X.Y.Z
gh run download <run-id> -n speed-table && git apply speed-table.patch
git commit -s -m "docs: speed figures for X.Y" -- docs/design.md README.md
just matrix # records the new version in the matrix
git commit -s -m "docs: re-run the conformance matrix for X.Y.Z" -- docs/conformance.md docs/conformance.json README.md conformance/results
uv run scripts/check-versions.py
git push -u origin release/X.Y.Z # then open the pull request
gh pr checks # the `wheels / wheels (...)` rows must be green
# then squash-merge it
git switch main && git pull --ff-only
git log -1 --oneline # must be "chore: release X.Y.Z (#NN)"
git tag -s vX.Y.Z -m vX.Y.Z # signed with your git signing key
git verify-tag vX.Y.Z && git push origin vX.Y.ZThe tag is signed, so GitHub shows it as verified and anyone can check it with git verify-tag.
cargo-release prints a "Publishing" line, but it publishes nothing.
Do not create the GitHub release by hand. The tag runs release.yml, which builds, attests and
publishes everything (design.md). Each publish job waits for an
approval: the pypi environment twice (the wheels, then check-json5) and crates-io once. If a
publish job fails, use "Re-run failed jobs", never "Re-run all jobs". A full re-run builds the
wheels again, so PyPI and the GitHub release could hold different builds.
"Re-run failed jobs" uses the workflow file at the tagged commit, so a fix to a workflow needs a new commit and a moved tag. Which way depends on how far the release got:
- Nothing is on PyPI yet (a wheels row,
smokeorgithub-releasefailed). Fix main through a pull request. Delete the remote tag withgit push origin :refs/tags/vX.Y.Z, then sign and push the tag again on the new release commit, as above.github-releasereplaces a leftover draft for the same tag and refuses a published release, so the old draft needs no cleanup. - PyPI already has a file. Never move the tag. Ship a patch version.
The release pull request changes Cargo.toml and Cargo.lock, so wheels-check.yml builds the
wheels on it. Look at its wheels / wheels (...) checks before you tag. They cannot be required
checks, because the workflow only runs for some paths.
A pre-release has a - in its tag (v3.1.0-rc.1). cargo-release bumps only the crates for one.
Edit the other places by hand, with the PEP 440 form (3.2.0rc1) in setup.py and the
compatibility package.
Once the release is published, run just major. It moves the major tag (v3), which
uses: simonvanlierde/jsonvet@v3 follows, to the newest vX.Y.Z, so a pre-release or a patch to
an older minor leaves it alone. The workflow's token cannot move a tag past changes to
.github/workflows/, and one that could would give CI write access to the workflows.
Every commit in a pull request carries a Signed-off-by: line, which says you wrote the change
or have the right to submit it under the MIT and Apache-2.0 licenses: the
Developer Certificate of Origin 1.1. git commit -s adds
it. git rebase --signoff upstream/main adds it to commits you already made. The DCO sign-off
check fails any pull request with a commit that lacks it, the maintainer's and Renovate's
included.
GOVERNANCE.md names the maintainer, who can publish each package, and what happens if the maintainer is unavailable. docs/roadmap.md says what is planned.