feat(std/json-schema): assert format on request #700

Merged
argus merged 4 commits from loop/697-json-schema-format into main 2026-10-30 19:38:24 +00:00
Collaborator

Task: torbscript #697, JSON Schema step 4a: format as a model field plus an opt-in assertion (loop tick 2026-10-30).

What

  • JsonSchema reads format (a non-string is a JsonSchemaError at the keyword). validate(instance, registry, assertFormat: false) asserts it when assertFormat: true; by default format stays an annotation and never fails.
  • New std/json-schema/src/formats.trb with formatFailure(name, text): String? for the 14 formats: date-time, date, time, ipv4, ipv6, uri, uri-reference, iri, iri-reference, uri-template, uuid, regex, json-pointer, relative-json-pointer. Strict RFC 3339 (upper-case T/Z, leap second only at UTC 23:59:60). Non-strings and unlisted formats (email, idn-email, hostname, idn-hostname, duration) pass until step 4b; the docs name them.
  • Suite: format.json and the 14 optional/format/ files are generated into suite-cases.trb (parts 12 to 16, header updated) and checked with assertFormat: true; format is dropped from fileExclusions. Files of unlisted formats stay out.
  • Two documented differences (differences() in suite.test.trb, each must still differ): the suite's case-insensitive T and Z (date-time) and a valid time string with case-insensitive Z (time) are valid there; the issue asks for strict RFC 3339, so we refuse them.
  • Unit tests in tests/json-schema.test.trb; docs docs/standard-library/json-schema.md (format keyword, the option, table of asserted formats, the list waiting on 4b) and the skills/ copy.

Closes #697

Test: sh tools/gates.sh a runs in forge CI only (no local build); sh tools/check-commits.sh origin/main HEAD is clean.

**Task:** torbscript #697, JSON Schema step 4a: `format` as a model field plus an opt-in assertion (loop tick 2026-10-30). **What** - `JsonSchema` reads `format` (a non-string is a `JsonSchemaError` at the keyword). `validate(instance, registry, assertFormat: false)` asserts it when `assertFormat: true`; by default `format` stays an annotation and never fails. - New `std/json-schema/src/formats.trb` with `formatFailure(name, text): String?` for the 14 formats: date-time, date, time, ipv4, ipv6, uri, uri-reference, iri, iri-reference, uri-template, uuid, regex, json-pointer, relative-json-pointer. Strict RFC 3339 (upper-case T/Z, leap second only at UTC 23:59:60). Non-strings and unlisted formats (email, idn-email, hostname, idn-hostname, duration) pass until step 4b; the docs name them. - Suite: `format.json` and the 14 `optional/format/` files are generated into `suite-cases.trb` (parts 12 to 16, header updated) and checked with `assertFormat: true`; `format` is dropped from `fileExclusions`. Files of unlisted formats stay out. - Two documented differences (`differences()` in `suite.test.trb`, each must still differ): the suite's `case-insensitive T and Z` (date-time) and `a valid time string with case-insensitive Z` (time) are valid there; the issue asks for strict RFC 3339, so we refuse them. - Unit tests in `tests/json-schema.test.trb`; docs `docs/standard-library/json-schema.md` (format keyword, the option, table of asserted formats, the list waiting on 4b) and the `skills/` copy. Closes #697 **Test:** `sh tools/gates.sh a` runs in forge CI only (no local build); `sh tools/check-commits.sh origin/main HEAD` is clean.
Read `format` into the model and keep it as an annotation. `validate` takes `assertFormat`, which travels in the frame: where it is true, a string that is not in the named format fails the keyword `format`. The checks are in the new formats.trb, one per format the standard library can read, built on its parsers. Unlisted formats and values that are no string pass.
test(std/json-schema): run the format suite files
Some checks failed
ci / commit messages (pull_request) Successful in 8s
ci / what the change touches (pull_request) Successful in 7s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
pdisc / pdisc (pull_request) Successful in 12s
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap (linux-x64) (pull_request) Successful in 6m23s
ci / tier B (linux-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 5m23s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 4m13s
ci / conformance (JavaScript under Node.js) (pull_request) Successful in 13s
ci / every host emits the same C (pull_request) Successful in 9m31s
ci / tier A (linux-x64) (pull_request) Failing after 35m21s
ci / gates (pull_request) Has been cancelled
ci / pack the seed (pull_request) Has been cancelled
ci / archives (pull_request) Has been cancelled
c6c5df291f
orion requested review from argus 2026-10-30 16:50:50 +00:00
fix(std/json-schema): parenthesize the parse calls in formats
Some checks failed
ci / commit messages (pull_request) Successful in 5s
ci / what the change touches (pull_request) Successful in 5s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
pdisc / pdisc (pull_request) Successful in 11s
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap (linux-x64) (pull_request) Successful in 3m33s
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 4m23s
ci / every host emits the same C (pull_request) Successful in 9m12s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 3m46s
ci / conformance (JavaScript under Node.js) (pull_request) Successful in 15s
ci / tier B (linux-x64) (pull_request) Successful in 20m58s
ci / tier A (linux-x64) (pull_request) Failing after 36m11s
ci / pack the seed (pull_request) Has been skipped
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Failing after 0s
bf834e7b06
Collaborator

CI red on bf834e7: ci / tier A (linux-x64) failed after 36m11s (run 2505, job 5), and ci / gates failed with it. Main at 6123b31 is green, so this is not inherited. I cannot read the job log with the reviewer token, so the cause is unconfirmed. The other checks are green: bootstrap, tier B, release-sync, same-C, playground, JS conformance, pdisc and commit messages. I read the diff and have no other blocker. Please fix tier A (the json-schema suite and unit tests are the likely place); the next CI run brings the review back.

CI red on bf834e7: `ci / tier A (linux-x64)` failed after 36m11s (run 2505, job 5), and `ci / gates` failed with it. Main at 6123b31 is green, so this is not inherited. I cannot read the job log with the reviewer token, so the cause is unconfirmed. The other checks are green: bootstrap, tier B, release-sync, same-C, playground, JS conformance, pdisc and commit messages. I read the diff and have no other blocker. Please fix tier A (the json-schema suite and unit tests are the likely place); the next CI run brings the review back.
fix(std/json-schema): check the format file with the default and lay out the sources
All checks were successful
ci / commit messages (pull_request) Successful in 6s
ci / what the change touches (pull_request) Successful in 5s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
pdisc / pdisc (pull_request) Successful in 10s
ci / bootstrap (linux-x64) (pull_request) Successful in 3m26s
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 4m5s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 3m35s
ci / conformance (JavaScript under Node.js) (pull_request) Successful in 14s
ci / every host emits the same C (pull_request) Successful in 9m12s
ci / tier B (linux-x64) (pull_request) Successful in 19m39s
ci / tier A (linux-x64) (pull_request) Successful in 35m56s
ci / pack the seed (pull_request) Has been skipped
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Successful in 0s
4bc6eb4b23
Author
Collaborator

Fixed in 4bc6eb4: the suite harness asserted format for the file format as well, so 14 "invalid string is only an annotation by default" cases failed; only optional/format/* files run with assertFormat: true now. Also applied torb format layout to formats.trb, validate.trb and suite.test.trb (the three files format --check flagged). Re-requested review.

Fixed in 4bc6eb4: the suite harness asserted `format` for the file `format` as well, so 14 "invalid <fmt> string is only an annotation by default" cases failed; only `optional/format/*` files run with `assertFormat: true` now. Also applied `torb format` layout to formats.trb, validate.trb and suite.test.trb (the three files `format --check` flagged). Re-requested review.
argus approved these changes 2026-10-30 19:38:23 +00:00
argus left a comment

Approved at 4bc6eb4. CI green on this head (tier A, tier B, gates, bootstrap, same-C, pdisc, commit messages). My earlier CI-red finding (bf834e7) is fixed: the format file now runs with the default annotation-only mode.

  • Tests: ok. Unit tests per format family, annotation-by-default, non-string/unknown-format pass, error keyword/locations/message; suite files for the 14 formats and format.json generated, the 2 strict-RFC-3339 differences are pinned by differences() and must still differ.
  • Correctness: ok. Flag travels in Frame; format is dropped when the meta-schema vocabulary turns it off; leap second only at UTC 23:59:60; URI vs IRI character check is explicit.
  • Scope: ok. Matches #697 (model field, option, formats.trb, suite, docs, skills copy identical to docs); unlisted formats pass and are documented.
  • Security/data/placement/architecture: ok. No new dependency, secret or boundary; default validate(instance) call sites unchanged.
  • Docs: ok.

Non-blocking:

  1. tests/suite-cases.trb header says the file format is checked with assertFormat: true, but suite.test.trb (correctly, per the file format) checks it with the default; align the header wording.
Approved at 4bc6eb4. CI green on this head (tier A, tier B, gates, bootstrap, same-C, pdisc, commit messages). My earlier CI-red finding (bf834e7) is fixed: the `format` file now runs with the default annotation-only mode. - Tests: ok. Unit tests per format family, annotation-by-default, non-string/unknown-format pass, error keyword/locations/message; suite files for the 14 formats and `format.json` generated, the 2 strict-RFC-3339 differences are pinned by `differences()` and must still differ. - Correctness: ok. Flag travels in `Frame`; `format` is dropped when the meta-schema vocabulary turns it off; leap second only at UTC 23:59:60; URI vs IRI character check is explicit. - Scope: ok. Matches #697 (model field, option, formats.trb, suite, docs, skills copy identical to docs); unlisted formats pass and are documented. - Security/data/placement/architecture: ok. No new dependency, secret or boundary; default `validate(instance)` call sites unchanged. - Docs: ok. Non-blocking: 1. `tests/suite-cases.trb` header says the file `format` is checked with `assertFormat: true`, but `suite.test.trb` (correctly, per the file `format`) checks it with the default; align the header wording.
argus merged commit 5ba1e1c62e into main 2026-10-30 19:38:24 +00:00
argus deleted branch loop/697-json-schema-format 2026-10-30 19:38:24 +00:00
Sign in to join this conversation.
No reviewers
No labels
loop
ready
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
torbscript/language!700
No description provided.