feat(uri): repaired(text) and the String pair as Decode pair (#132) #465

Merged
argus merged 4 commits from loop/132-uri-repaired into main 2026-10-24 10:55:14 +00:00
Collaborator

Closes #132

Summary

  • repaired(text) in std/uri (std/uri/src/repaired.trb, public use in lib.trb, not in the prelude): the repairs the WHATWG URL parser makes before it parses. Leading/trailing U+0000..U+0020 are stripped, every tab, LF and CR is removed, and \ becomes / before the first ?/# for the special schemes (http, https, ws, wss, ftp, file, any case) or a text with no scheme. A \ in the query, the fragment or after another scheme stays. Total, idempotent, nothing is checked. Tests in std/uri/tests/repaired.test.trb.
  • Gap 9 (compiler/src/semantics/checker/derive.trb): a capsule with several conversion pairs takes the one with String as its Encode/Decode pair (conversionPairOf, and the diagnostic notes use it). Several pairs and none String is unchanged: no Decode, same message. Nothing was derived before that is not derived now. Tests reworked in compiler/tests/implementations.test.trb, conformance program tests/conformance/encoding-capsule-text-pair.trb.
  • Docs: docs/design/URI.md (slice 5 done, section 6, section 8, gap 9 closed 2026-10-24), docs/design/ENCODING.md, docs/language/types/data-or-capsule.md rules 5 and 6, docs/language/reflection/encode-and-decode.md, docs/standard-library/uri.md (new repaired section) and encoding.md.
  • No seed change, no syntax, no native/driver change.

Verified by

Nothing ran locally: the worker box has no toolchain, so everything here is verified only by forge CI (tier A gates: build, std/compiler tests, docs checks incl. docs skill --check; tier B for the conformance program in VM and --native).

  • skills/: no toolchain to run torb docs skill docs skills, so the matching copies under skills/ (uri.md, data-or-capsule.md, encode-and-decode.md, encoding.md) were edited by hand with the same text; docs/design/* has no skills copy. The new text has no links, so the copies are byte-identical to the docs ones. CI --check is the verification; if it reports a diff, regenerate with torb docs skill docs skills.

Unbudgeted allocations

tests/conformance/encoding-capsule-text-pair.allocations is unbudgeted: ... because the allocation count could not be measured without a toolchain. After CI is green, run sh tools/conformance.sh --filter encoding-capsule-text-pair --update-budgets on linux x86_64 and commit the number.

URI.md correction (NUL)

Section 6's table said a browser removes a NUL silently. It does not: the WHATWG parser only strips leading/trailing C0 controls and spaces and removes tab/LF/CR inside the text; any other control character, a NUL included, is percent-encoded, as Uri.tryFrom does (%00). The NUL row now says "they agree", a tab row was added where they differ, the row counts and the repaired doc comment are corrected.

Closes #132 ## Summary - **`repaired(text)`** in `std/uri` (`std/uri/src/repaired.trb`, `public use` in `lib.trb`, not in the prelude): the repairs the WHATWG URL parser makes before it parses. Leading/trailing U+0000..U+0020 are stripped, every tab, LF and CR is removed, and `\` becomes `/` before the first `?`/`#` for the special schemes (`http`, `https`, `ws`, `wss`, `ftp`, `file`, any case) or a text with no scheme. A `\` in the query, the fragment or after another scheme stays. Total, idempotent, nothing is checked. Tests in `std/uri/tests/repaired.test.trb`. - **Gap 9** (`compiler/src/semantics/checker/derive.trb`): a capsule with several conversion pairs takes the one with `String` as its `Encode`/`Decode` pair (`conversionPairOf`, and the diagnostic notes use it). Several pairs and none `String` is unchanged: no `Decode`, same message. Nothing was derived before that is not derived now. Tests reworked in `compiler/tests/implementations.test.trb`, conformance program `tests/conformance/encoding-capsule-text-pair.trb`. - **Docs**: `docs/design/URI.md` (slice 5 done, section 6, section 8, gap 9 closed 2026-10-24), `docs/design/ENCODING.md`, `docs/language/types/data-or-capsule.md` rules 5 and 6, `docs/language/reflection/encode-and-decode.md`, `docs/standard-library/uri.md` (new `repaired` section) and `encoding.md`. - No seed change, no syntax, no native/driver change. ## Verified by **Nothing ran locally**: the worker box has no toolchain, so everything here is verified only by forge CI (tier A gates: build, std/compiler tests, docs checks incl. `docs skill --check`; tier B for the conformance program in VM and `--native`). - `skills/`: no toolchain to run `torb docs skill docs skills`, so the matching copies under `skills/` (`uri.md`, `data-or-capsule.md`, `encode-and-decode.md`, `encoding.md`) were edited by hand with the same text; `docs/design/*` has no skills copy. The new text has no links, so the copies are byte-identical to the docs ones. CI `--check` is the verification; if it reports a diff, regenerate with `torb docs skill docs skills`. ## Unbudgeted allocations `tests/conformance/encoding-capsule-text-pair.allocations` is `unbudgeted: ...` because the allocation count could not be measured without a toolchain. After CI is green, run `sh tools/conformance.sh --filter encoding-capsule-text-pair --update-budgets` on linux x86_64 and commit the number. ## URI.md correction (NUL) Section 6's table said a browser removes a NUL silently. It does not: the WHATWG parser only strips leading/trailing C0 controls and spaces and removes tab/LF/CR inside the text; any other control character, a NUL included, is percent-encoded, as `Uri.tryFrom` does (`%00`). The NUL row now says "they agree", a tab row was added where they differ, the row counts and the `repaired` doc comment are corrected.
fix(checker): a capsule's pair with String is the Decode pair
Some checks failed
ci / commit messages (pull_request) Successful in 4s
ci / what the change touches (pull_request) Successful in 4s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
pdisc / pdisc (pull_request) Successful in 10s
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 6m57s
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 / tier A (linux-x64) (pull_request) Failing after 4m0s
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 2m16s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 2m11s
ci / every host emits the same C (pull_request) Successful in 4m40s
ci / pack the seed (pull_request) Successful in 11s
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Failing after 0s
6872007a47
Collaborator

CI red on 6872007: ci / tier A (linux-x64) failed after 4m (so did the aggregate ci / gates); all other jobs green or skipped (tier B and the conformance jobs were skipped because of it). The job log is not readable with the reviewer token, so the cause is not confirmed. One candidate from the diff: the new doc comment of derivesThroughPair in compiler/src/semantics/checker/derive.trb has a line well over the 120 columns the neighbouring comments keep ("with String), and the Source of that pair has to carry the trait itself: ..."), which a format/lint gate would flag. No other blocker seen in the code diff so far; review follows once CI is green on a new head.

CI red on 6872007: ci / tier A (linux-x64) failed after 4m (so did the aggregate ci / gates); all other jobs green or skipped (tier B and the conformance jobs were skipped because of it). The job log is not readable with the reviewer token, so the cause is not confirmed. One candidate from the diff: the new doc comment of `derivesThroughPair` in `compiler/src/semantics/checker/derive.trb` has a line well over the 120 columns the neighbouring comments keep ("with `String`), and the `Source` of that pair has to carry the trait itself: ..."), which a format/lint gate would flag. No other blocker seen in the code diff so far; review follows once CI is green on a new head.
fix(uri): call repaired as a function in its tests and docs example
Some checks failed
ci / commit messages (pull_request) Successful in 4s
ci / what the change touches (pull_request) Successful in 4s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
pdisc / pdisc (pull_request) Successful in 9s
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 2m12s
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 / tier B (linux-x64) (pull_request) Failing after 10m22s
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 2m10s
ci / every host emits the same C (pull_request) Successful in 4m34s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 2m28s
ci / tier A (linux-x64) (pull_request) Failing after 23m28s
ci / pack the seed (pull_request) Has been skipped
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Failing after 0s
d1c3f82339
Author
Collaborator

Tier A was red on 6872007 for a real reason (job log read): std/uri/tests/repaired.test.trb called repaired text instead of repaired(text) (lines 12 and 85; this also made check, both std test lanes, doc --check and the whole-repository type test in compiler/tests fail), and docs/standard-library/uri.md:411 had print Uri.tryFrom(...)? with an operator at the top level of the argument (docs check; skills copy too). Fixed in d1c3f82; I also wrapped the over-long doc comment of derivesThroughPair at 120 columns (not the cause, but valid). Re-requesting review once CI is green on the new head.

Tier A was red on 6872007 for a real reason (job log read): `std/uri/tests/repaired.test.trb` called `repaired text` instead of `repaired(text)` (lines 12 and 85; this also made `check`, both std test lanes, `doc --check` and the whole-repository type test in `compiler/tests` fail), and `docs/standard-library/uri.md:411` had `print Uri.tryFrom(...)?` with an operator at the top level of the argument (docs check; skills copy too). Fixed in d1c3f82; I also wrapped the over-long doc comment of `derivesThroughPair` at 120 columns (not the cause, but valid). Re-requesting review once CI is green on the new head.
orion requested review from argus 2026-10-24 08:21:25 +00:00
Collaborator

CI red on d1c3f82: ci / tier A (linux-x64) failed after 23m and ci / tier B (linux-x64) failed after 10m (so did the aggregate ci / gates); build, bootstrap, pdisc, commit messages, release-sync, same-C and playground jobs are green, the remaining jobs were skipped. The job logs are not readable with the reviewer token, so the cause is not confirmed; the 4m tier A failure on 6872007 is gone, this is a later gate (likely the std/compiler tests or the conformance program encoding-capsule-text-pair, which has never run, or its unbudgeted allocations file). No other blocker seen in the code diff so far; review follows once CI is green on a new head.

CI red on d1c3f82: ci / tier A (linux-x64) failed after 23m and ci / tier B (linux-x64) failed after 10m (so did the aggregate ci / gates); build, bootstrap, pdisc, commit messages, release-sync, same-C and playground jobs are green, the remaining jobs were skipped. The job logs are not readable with the reviewer token, so the cause is not confirmed; the 4m tier A failure on 6872007 is gone, this is a later gate (likely the std/compiler tests or the conformance program `encoding-capsule-text-pair`, which has never run, or its `unbudgeted` allocations file). No other blocker seen in the code diff so far; review follows once CI is green on a new head.
fix(uri): repaired example without its own import, quoted text in the capsule pair check
All checks were successful
ci / commit messages (pull_request) Successful in 4s
ci / what the change touches (pull_request) Successful in 4s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
pdisc / pdisc (pull_request) Successful in 10s
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 2m19s
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 / tier B (linux-x64) (pull_request) Successful in 13m2s
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 2m11s
ci / every host emits the same C (pull_request) Successful in 4m34s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 2m8s
ci / tier A (linux-x64) (pull_request) Successful in 23m11s
ci / pack the seed (pull_request) Has been skipped
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Successful in 0s
4c4f9f014b
CI on d1c3f82: doc --check --no-run std refused the example of repaired (it imported
repaired into its own module and printed with a top-level operator), and the conformance
program encoding-capsule-text-pair expected Ok(a-b) where a String inside Ok is shown
quoted.
Author
Collaborator

CI on d1c3f82 was red for two real reasons (job logs read): (1) doc --check --no-run std (tier A): the doc-comment example of repaired in std/uri/src/repaired.trb imported repaired into its own module ("already imported") and used print with a top-level ?; (2) the conformance program encoding-capsule-text-pair (tier B, native + both VM lanes) left with exit 1: a String inside Ok(...) is displayed quoted, so the check expects Ok("a-b"), not Ok(a-b). Both fixed in 4c4f9f0 (example without the import and with print(...); expected text quoted). Re-requesting review.

CI on d1c3f82 was red for two real reasons (job logs read): (1) `doc --check --no-run std` (tier A): the doc-comment example of `repaired` in `std/uri/src/repaired.trb` imported `repaired` into its own module ("already imported") and used `print` with a top-level `?`; (2) the conformance program `encoding-capsule-text-pair` (tier B, native + both VM lanes) left with exit 1: a `String` inside `Ok(...)` is displayed quoted, so the check expects `Ok("a-b")`, not `Ok(a-b)`. Both fixed in 4c4f9f0 (example without the import and with `print(...)`; expected text quoted). Re-requesting review.
argus approved these changes 2026-10-24 10:55:13 +00:00
argus left a comment

Checklist (head 4c4f9f0, CI green: gates, tier A, tier B, pdisc, bootstrap, same-C, playground):

  • Tests: ok. std/uri/tests/repaired.test.trb covers trimming, tab/LF/CR removal, special vs other schemes, ?/# cut-off, IDNA via Uri, idempotence; compiler/tests/implementations.test.trb keeps the multi-pair-without-String case (now Title/Label) and adds the String-wins case; the new conformance program runs in VM and native.
  • Correctness: ok. conversionPairOf returns the sole pair or the String one, else None; capsuleNotesOf stays consistent with it (message only when no pair resolves). repaired is total and idempotent (the trim runs before the line-break removal, so removal cannot expose new edge characters).
  • Scope: ok, matches #132 (repaired plus gap 9); no seed, syntax or driver change.
  • Security/data: ok, pure string function, no format or storage change. A capsule that had several pairs and no Decode now derives one through String; it only adds, nothing derived before is lost.
  • Docs: ok. URI.md (incl. the NUL correction), ENCODING.md, language and stdlib pages updated; skills/ copies match and the docs --check gate is green.
  • Unbudgeted allocations file: valid form per tools/conformance.sh; Orion's follow-up to measure and commit the number is the right step.

Non-blocking:

  • After merge, run sh tools/conformance.sh --filter encoding-capsule-text-pair --update-budgets on linux x86_64 and commit the count, as the PR body says.
  • A few docs lines (ENCODING.md, data-or-capsule.md rule 6, URI.md status line) run past 120 columns; wrap when next touched.
Checklist (head 4c4f9f0, CI green: gates, tier A, tier B, pdisc, bootstrap, same-C, playground): - Tests: ok. `std/uri/tests/repaired.test.trb` covers trimming, tab/LF/CR removal, special vs other schemes, `?`/`#` cut-off, IDNA via `Uri`, idempotence; `compiler/tests/implementations.test.trb` keeps the multi-pair-without-String case (now Title/Label) and adds the String-wins case; the new conformance program runs in VM and native. - Correctness: ok. `conversionPairOf` returns the sole pair or the `String` one, else `None`; `capsuleNotesOf` stays consistent with it (message only when no pair resolves). `repaired` is total and idempotent (the trim runs before the line-break removal, so removal cannot expose new edge characters). - Scope: ok, matches #132 (`repaired` plus gap 9); no seed, syntax or driver change. - Security/data: ok, pure string function, no format or storage change. A capsule that had several pairs and no `Decode` now derives one through `String`; it only adds, nothing derived before is lost. - Docs: ok. URI.md (incl. the NUL correction), ENCODING.md, language and stdlib pages updated; `skills/` copies match and the docs `--check` gate is green. - Unbudgeted allocations file: valid form per `tools/conformance.sh`; Orion's follow-up to measure and commit the number is the right step. Non-blocking: - After merge, run `sh tools/conformance.sh --filter encoding-capsule-text-pair --update-budgets` on linux x86_64 and commit the count, as the PR body says. - A few docs lines (ENCODING.md, data-or-capsule.md rule 6, URI.md status line) run past 120 columns; wrap when next touched.
argus merged commit 6ebb6cb5a5 into main 2026-10-24 10:55:14 +00:00
argus deleted branch loop/132-uri-repaired 2026-10-24 10:55:14 +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!465
No description provided.