Skip to content

Multi-language Jsontron: spec, conformance suite, .NET/JS/Python on JQLite - #26

Merged
kzu merged 9 commits into
mainfrom
feature/ports
Nov 30, 2026
Merged

kzu merged 9 commits into
mainfrom
feature/ports

Conversation

@kzu

@kzu kzu commented Nov 30, 2026

Copy link
Copy Markdown
Member

Summary

Extracts a language-neutral Jsontron 0.2 specification and shared JSON conformance suite, adds JavaScript/TypeScript and Python implementations alongside .NET, and standardizes all three implementations on devlooped/jqlite 1.0.0.

Highlights

  • Specification & conformance suite (spec/jsontron.md, tests/): normative spec for rules, assert, report, let, reference lowering, and portable jq profile aligned with jqlite, backed by a shared language-neutral JSON conformance suite run by every implementation.
  • Repository layout: moved .NET sources from src/ to dotnet/ alongside js/ and python/.
  • .NET (dotnet/, NuGet Jsontron):
    • Runs the full conformance suite with one error per failure and zero skipped tests.
    • Migrated from Devlooped.JQSharp to JQLite 1.0.0.
  • JavaScript / TypeScript (js/, npm @devlooped/jsontron):
    • Ajv keywords powered by @devlooped/jqlite 1.0.0 (ESM-only, zero native/WASM dependencies, synchronous addJsontron(ajv)).
    • Renamed from ajv-jsontron to @devlooped/jsontron (unscoped jsontron is taken on npm).
  • Python (python/, PyPI jsontron):
    • jsonschema keywords powered by devlooped-jqlite 1.0.0 (requires Python >=3.11).
  • CI & publishing (.github/workflows/js.yml, .github/workflows/python.yml):
    • Cross-platform test matrices (ubuntu, windows, macos) and OIDC trusted publishing on GitHub releases.

Verification

  • .NET: dotnet format clean; dnx --yes retest — 243 passed, 0 skipped (including JsonSchema.Net 9.7.0).
  • JavaScript / TypeScript: npm test — 275 passed; npm run typecheck, npm run build, npm pack --dry-run clean.
  • Python: pytest — 327 passed; ruff check and ruff format --check clean.

This pull request was created by CodeAlta.

kzu and others added 9 commits November 30, 2026 03:13
The repo will hold one folder per language implementation. dotnet-file
entries are re-keyed to the new local paths; the old src/ paths are
skipped so the repo-wide sync does not recreate them. includes.yml and
_config.yml carry local edits and are skipped from sync.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-authored-by: CodeAlta <noreply@codealta.io>
The spec states the semantics the .NET implementation and readme
carried implicitly, including the lowering of a rule set to one jq
program and the portable jq profile. tests/ holds the language-neutral
cases every implementation runs.

An item without a message now has its test text as a literal message
instead of evaluating that text as a jq string, which broke on tests
containing quotes or interpolation.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-authored-by: CodeAlta <noreply@codealta.io>
- ConformanceSuite runs every tests/*.json case as its own xUnit case;
  a missing or empty suite fails.
- Each failed assert/report (or the evaluation error) is now its own
  validation error: the keyword returns one Details entry per failure,
  produced by a private subschema, instead of a "; "-joined string.
- An item without message uses its test text literally as the failure
  text instead of evaluating it as jq.
- tests/locations.json: the nested-location message used escaped quotes
  inside \(...), which jq 1.8 rejects after the spec's wrapping; use the
  explicit jq string form instead.
- Undefined $variables are skipped as known JQSharp gaps: its parser
  does not reject them, unlike jq.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-authored-by: CodeAlta <noreply@codealta.io>
Every behaviour the old xUnit classes checked is now a suite case; the
ones the suite lacked are added (report sugar shape and mixed array form,
report merged into an existing "." rule, let with report sugar alone,
labels on a rule report, blank id, flag+role on a rule item, let names
starting with a digit, rule-level let binding root). The behaviour classes
are deleted; ApiTests keeps what is .NET-specific: registration, the
dialect, JsonSchemaException at build, and the shape of reported errors.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-authored-by: CodeAlta <noreply@codealta.io>
A new npm package in js/ that adds rules, assert, report and let to Ajv 8
(draft 2020-12), running jq 1.8.2 through jq-wasm behind a JqEngine
interface.

- loadJsontron(options) loads the engine asynchronously and returns
  addJsontron(ajv); compile and validation are synchronous.
- The first present keyword (rules, assert, report, let) owns the schema
  object's rule set; all four are registered so strict mode stays on.
- Build time: keyword values validated against schemas/jsontron-0.2.json
  (bundled at build), flag/role and blank labels rejected, every jq
  expression checked in isolation with the variables in scope declared.
- Evaluation: the reference lowering of spec section 7, one jq call per
  schema object; the root is passed only when an expression reads $root.
- One Ajv error per failure text, one for a jq evaluation error.
- vitest: unit tests and a runner for every ../tests/*.json file.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-authored-by: CodeAlta <noreply@codealta.io>
JsontronValidator (Draft202012Validator with rules, assert, report and
let) and extend() for other validator classes, evaluated by jq 1.8 through
the jq package with the reference lowering of spec section 7.

- The root document is tied to the validator lineage: the outermost
  iter_errors registers a copy of the validator, and evolve() registers
  every derived one, so $root stays right when validations interleave or
  one starts inside another. Subschemas that declare the same $schema keep
  the extended class instead of jsonschema's plain one.
- check_schema checks keyword shapes against schemas/jsontron-0.2.json
  (packaged at build time by a hatch hook), flag with role, blank labels,
  and every jq expression in isolation with its variables declared; the
  same checks run on first use without check_schema.
- Lowered programs are cached per schema object (bounded, holding the
  object so its id cannot be reused) and receive $root only when an
  expression references it.
- pytest runs every ../tests/*.json; one locations.json group is a strict
  xfail: its plain-text message escapes " inside \(...), which jq 1.8.2
  rejects.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-authored-by: CodeAlta <noreply@codealta.io>
Real jq rejects an escaped quote inside an interpolation, so escaping
every quote made plain-text messages such as
  order \(.id // "?")
a build error in the JS and Python implementations. JQSharp accepts it,
which hid the problem in .NET. The spec now copies \(...) unchanged and
lets a backslash keep the character after it; all three implementations
follow, with suite cases.

Expressions are also followed by two newlines in the lowered program,
since jq continues a comment ending in a backslash onto the next line.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-authored-by: CodeAlta <noreply@codealta.io>
js.yml and python.yml run each implementation against the conformance
suite and publish to npm and PyPI by trusted publishing on release.
AGENTS.md records the layout and the decisions behind the ports; the
readme lists the implementations.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-authored-by: CodeAlta <noreply@codealta.io>
…ckage to @devlooped/jsontron

- Spec & suite: align with jqlite (portable jq 1.8 profile); move unbound $variable checks from build-errors to evaluation-errors and add an unknown-function build-error test.
- .NET: migrate from Devlooped.JQSharp to JQLite 1.0.0 and remove all conformance suite skips.
- JS/TS: migrate from jq-wasm to @devlooped/jqlite 1.0.0, rename package from ajv-jsontron to @devlooped/jsontron, switch to ESM-only and synchronous addJsontron(ajv).
- Python: migrate from jq (libjq) to devlooped-jqlite 1.0.0 (requires Python >=3.11).
- CI & docs: update workflows, root readme, package readmes, and AGENTS.md.

Co-authored-by: CodeAlta <noreply@codealta.io>
@kzu kzu added the enhancement New feature or request label Nov 30, 2026
@kzu
kzu enabled auto-merge (rebase) November 30, 2026 06:15
@kzu

kzu commented Nov 30, 2026

Copy link
Copy Markdown
Member Author

243 passed 243 passed

🧪 Details on Ubuntu 26.04.1 LTS

from retest v1.1.0 on .NET 11.0.0 with 💜 by @devlooped

@kzu
kzu merged commit 8fa407e into main Nov 30, 2026
41 checks passed
@kzu
kzu deleted the feature/ports branch November 30, 2026 06:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant