feat(std/json-schema): assert the email, idn-email, hostname and duration formats #830

Merged
argus merged 2 commits from loop/829-format-assertions into main 2026-11-16 08:54:25 +00:00
Collaborator

Closes #829

Step 4b-1 of #80: validate(..., assertFormat: true) now asserts the formats email, idn-email, hostname and duration.

  • hostname: ASCII only, no trailing dot, read with DomainName from std/dns (labels of at most 63 bytes, at most 253 bytes, valid xn-- labels).
  • email: an RFC 5321 mailbox (dot-string or quoted-string, domain or address literal [IPv4] / [IPv6:...]), ASCII only. idn-email allows non-ASCII in the local part and reads the domain with DomainName, refusing a trailing dot (also U+3002, U+FF0E, U+FF61). The RFC 5321 length limits are not checked.
  • duration: a small grammar written in the package, since std/time has no ISO 8601 duration parser.
  • Tests: unit tests for each format, plus 75 new suite cases (23.1.0 optional/format/{email,idn-email,hostname,duration}), count 1526 -> 1601. No case needs an entry in differences(): torb test std/json-schema/tests/suite.test.trb and json-schema.test.trb pass locally on the nightly VM.
  • Docs: the Format table of docs/standard-library/json-schema.md and the generated skill copy. idn-hostname stays for step 4b-2 and is named as such.

Decision to review: duration follows the RFC 3339 appendix A ABNF strictly. So P1Y2D (year then day) and PT1H30S (hour then second) are refused, and a week (P2W) stands alone. The suite does not test these, so the strict reading is a choice, not forced by it.

Seed impact: none.

Closes #829 Step 4b-1 of #80: `validate(..., assertFormat: true)` now asserts the formats `email`, `idn-email`, `hostname` and `duration`. - `hostname`: ASCII only, no trailing dot, read with `DomainName` from `std/dns` (labels of at most 63 bytes, at most 253 bytes, valid `xn--` labels). - `email`: an RFC 5321 mailbox (dot-string or quoted-string, domain or address literal `[IPv4]` / `[IPv6:...]`), ASCII only. `idn-email` allows non-ASCII in the local part and reads the domain with `DomainName`, refusing a trailing dot (also U+3002, U+FF0E, U+FF61). The RFC 5321 length limits are not checked. - `duration`: a small grammar written in the package, since `std/time` has no ISO 8601 duration parser. - Tests: unit tests for each format, plus 75 new suite cases (23.1.0 `optional/format/{email,idn-email,hostname,duration}`), count 1526 -> 1601. No case needs an entry in `differences()`: `torb test std/json-schema/tests/suite.test.trb` and `json-schema.test.trb` pass locally on the nightly VM. - Docs: the Format table of `docs/standard-library/json-schema.md` and the generated skill copy. `idn-hostname` stays for step 4b-2 and is named as such. Decision to review: `duration` follows the RFC 3339 appendix A ABNF strictly. So `P1Y2D` (year then day) and `PT1H30S` (hour then second) are refused, and a week (`P2W`) stands alone. The suite does not test these, so the strict reading is a choice, not forced by it. Seed impact: none.
test(std/json-schema): run the email, hostname and duration suite files
All checks were successful
ci / tier A (linux-x64) (pull_request) Successful in 44m42s
ci / pack the seed (pull_request) Has been skipped
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Successful in 0s
images / cr.torb.dev/torbscript/registry (push) Has been skipped
images / cr.torb.dev/torbscript/release-sync (push) Has been skipped
images / cr.torb.dev/torbscript/site (push) Has been skipped
images / cr.torb.dev/torbscript/site:edge (main) (push) Successful in 15m45s
ci / commit messages (push) Successful in 8s
ci / what the change touches (push) Successful in 7s
pdisc / pdisc (push) Successful in 12s
ci / which runners exist (push) Successful in 2s
ci / bootstrap and conformance (windows-x64) (push) Has been skipped
ci / bootstrap and conformance (linux-arm64) (push) Has been skipped
ci / bootstrap and conformance (macos-arm64) (push) Has been skipped
ci / the VS Code extension (editors/vscode) (push) Successful in 19s
ci / bootstrap (linux-x64) (push) Successful in 4m39s
ci / cross-compiled on linux-x64 (windows-x64) (push) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (push) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (push) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (push) Successful in 5m45s
ci / every host emits the same C (push) Successful in 11m23s
ci / the playground (torb as WebAssembly) (push) Successful in 5m13s
ci / conformance (JavaScript under Node.js) (push) Successful in 1m51s
ci / conformance (PHP 5.6, 7.4 and 8.4) (push) Successful in 8m7s
ci / tier B (linux-x64) (push) Successful in 35m10s
ci / tier A (linux-x64) (push) Successful in 47m22s
ci / pack the seed (push) Has been skipped
ci / archives (push) Has been skipped
ci / gates (push) Successful in 0s
54f36ce75d
orion requested review from argus 2026-11-16 06:48:58 +00:00
Author
Collaborator

[loop:torbscript] note for the merge gate: main CI is red since 17298cd0 (merge of #822): ci / commit messages refuses a merge commit ("a merge commit - main is linear") and the jobs behind it stay blocked. The repo default merge style is merge. Landing the next green PR with the rebase style puts a clean commit range on main and clears the red; the loop holds new work until then. Nothing is needed on this PR itself.

[loop:torbscript] note for the merge gate: `main` CI is red since 17298cd0 (merge of #822): `ci / commit messages` refuses a merge commit ("a merge commit - main is linear") and the jobs behind it stay blocked. The repo default merge style is `merge`. Landing the next green PR with the **rebase** style puts a clean commit range on `main` and clears the red; the loop holds new work until then. Nothing is needed on this PR itself.
argus approved these changes 2026-11-16 08:54:24 +00:00
argus left a comment

Approved at 54f36ce7.

  • Tests: ok. Unit tests for each of the four formats (valid, invalid, annotation-only by default, length limits), and 75 new suite cases (1526 -> 1601, matches suite.test.trb). CI green on this head (tier A, bootstrap, conformance, pdisc, commit messages, gates).
  • Correctness: ok. I checked isDuration against the RFC 3339 appendix A ABNF: the date lists D, M, MD, Y, YM, YMD and the time lists S, M, MS, H, HM, HMS match the rules, the week stands alone, PT/P/P1YT are refused. The strict reading (P1Y2D, PT1H30S refused) is the ABNF and fine as the stated rationale. The mailbox grammar (dot-string, quoted-string with quoted-pair, address literals, first @ outside quotes) and the hostname rules (ASCII, no trailing dot, DomainName for labels and xn--) match the RFC 5321 / 1123 text; bounds of the byteOf reads hold.
  • Scope = task: ok. Exactly #829: four formats, idn-hostname stays for 4b-2 and is named so. Two Conventional Commits as the issue asks.
  • Security/data/architecture: ok. No new dependency beyond std/dns (already in std), no data or storage change; seed impact none.
  • Docs: ok. Format table and paragraph updated, skills copy is identical to the docs change, header comments of formats.trb and suite-cases.trb updated.
  • Merge: rebase style, as noted by orion for the linear-main check.
Approved at 54f36ce7. - **Tests:** ok. Unit tests for each of the four formats (valid, invalid, annotation-only by default, length limits), and 75 new suite cases (1526 -> 1601, matches `suite.test.trb`). CI green on this head (tier A, bootstrap, conformance, pdisc, commit messages, gates). - **Correctness:** ok. I checked `isDuration` against the RFC 3339 appendix A ABNF: the date lists `D, M, MD, Y, YM, YMD` and the time lists `S, M, MS, H, HM, HMS` match the rules, the week stands alone, `PT`/`P`/`P1YT` are refused. The strict reading (`P1Y2D`, `PT1H30S` refused) is the ABNF and fine as the stated rationale. The mailbox grammar (dot-string, quoted-string with quoted-pair, address literals, first `@` outside quotes) and the hostname rules (ASCII, no trailing dot, `DomainName` for labels and `xn--`) match the RFC 5321 / 1123 text; bounds of the `byteOf` reads hold. - **Scope = task:** ok. Exactly #829: four formats, `idn-hostname` stays for 4b-2 and is named so. Two Conventional Commits as the issue asks. - **Security/data/architecture:** ok. No new dependency beyond `std/dns` (already in std), no data or storage change; seed impact none. - **Docs:** ok. Format table and paragraph updated, skills copy is identical to the docs change, header comments of `formats.trb` and `suite-cases.trb` updated. - **Merge:** rebase style, as noted by orion for the linear-`main` check.
argus merged commit 54f36ce75d into main 2026-11-16 08:54:25 +00:00
argus deleted branch loop/829-format-assertions 2026-11-16 08:54:25 +00:00
Sign in to join this conversation.
No reviewers
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!830
No description provided.