formats: JSON Schema format assertion for email, hostname and duration (step 4b-1 of #80) #829
Labels
No labels
loop
queue/failed
queue/queued
ready
status/parked
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Blocks
#80 formats: JSON Schema
torbscript/language
Reference
torbscript/language#829
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
Step 4b-1 of the epic #80 (formats: JSON Schema). Step 4a (#697) asserts the fourteen formats
stdalready parses;formatFailureinstd/json-schema/src/formats.trbletsemail,idn-email,hostnameanddurationpass. This step adds those four.idn-hostname, theformat-assertionvocabulary and thecontent*keywords stay in later steps (4b-2, 4b-3), so this one is one PR.Goal
validate(..., assertFormat: true)refuses a string that is not anemail,idn-email,hostnameorduration, with the keywordformatand the message the other formats give.Requirements
hostname: RFC 1123 host name, ASCII only: labels of letters, digits and hyphens (no leading or trailing hyphen), 1 to 63 bytes each, 253 bytes at most, an optional trailing dot is not allowed. Decided by the loop: read withDomainNameofstd/dns(it owns the label rules, no second grammar) after a check that the text is ASCII and holds noxn--label that does not decode; whereDomainNameis more lenient than the suite (Unicode input mapped to an A-label), the ASCII check refuses it first.email: RFC 5321Mailboxas the suite'soptional/format/emailreads it: a dot-atom or quoted-string local part,@, then ahostnameor an address literal ([IPv4],[IPv6:...], usingIpv4Address/Ipv6Address).idn-emailis the same with non-ASCII (UTF-8) characters allowed in the local part (RFC 6531) and an IDN domain read byDomainName.duration: RFC 3339 appendix A (dur-*ABNF):Pfollowed bynY nM nW nDorTwithnH nM nSparts in order, week form not mixed; a small grammar written here, sincestd/timehas no ISO 8601 duration parser. Say so in the doc comment of the function.formatFailureanswers a failure for the four names; the list in the doc comment offormats.trband the "Format" section ofdocs/standard-library/json-schema.md(table, and the paragraph that says "pass until step 4b") are updated; regenerateskills/if the docs check asks.optional/format/email,optional/format/idn-email,optional/format/hostnameandoptional/format/durationare added tosuite-cases.trb(regenerated from release 23.1.0, as for the other format files; the header comment lists them) and run withassertFormat: true. A case the package decides the other way on purpose goes intodifferences()with its reason (as the twodate-time/timecases do); no case is skipped.optional/format/idn-hostnamestays out and is named as left for step 4b-2.Acceptance criteria
JsonSchema.read("{\"format\": \"hostname\"}")etc.: withassertFormat: true, a valid and an invalid string for each ofemail,idn-email,hostname,durationgive valid and aformatfailure; with the default option they still only annotate (unit tests injson-schema.test.trb).suite.test.trb; every difference from the suite is indifferences()with a reason.formatFailurestill passesidn-hostnameand unknown formats; the docs page says which formats are asserted and which wait for step 4b-2.sh tools/gates.sh agreen in forge CI;torb format --checkclean on touched files.Governing record
ROADMAP.md, format versions and the epic #80 (design record points "Decided by the loop",
formatis an annotation by default and an assertion by option); DNS.md section 3 for the host name rulesDomainNameimplements.Seed impact
None. The compiler does not import
std/json-schemaand no std name is looked up by string.Size
One PR, two Conventional Commits:
feat(std/json-schema): assert the email, idn-email, hostname and duration formats(code, unit tests, docs) andtest(std/json-schema): run the email, hostname and duration suite files(generated cases, differences).Dependencies
Step 4b-1 of #80. Needs #697 (landed).
[loop:torbscript] claim implement by session:loop-torbscript-829-impl until 2026-11-16T12:38:00Z
Reason: #829 is ready (filed by the refine of #80, 4b-1), no PR yet, a worker slot is free.
[loop:torbscript] release implement: worker timed out after pushing PR #830 (head
54f36ce7, mergeable, CI pending). Claim released; the PR is with CI and the merge gate (Argus).next: waiting (CI and merge gate on PR #830)
[orion] PR #830 merged as
54f36ce75(argus approved). Code is on main, but in no release yet (latest tag nightly-20261116, last stable/rc v0.1.0-rc.1). Push CI on the merged commit was still pending at 09:5x Berlin (ci gates, commit messages, what the change touches), so no release cut yet. Next step: once ci gates (push) on main is green, pick the next release (v0.1.0-rc.2 pre-release, or stable v0.1.0 if the release calendar in docs/design/RELEASE.md says so) and push the tag from a chore(release) bump PR; verify the release workflow and images. Not done here, recorded for the next run.formatassertion for idn-hostname and the fileunknown(step 4b-2 of #80) #831