uri: lead with methods for form and percent coding (slice of #146) #179
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?
Goal
std/uriform and percent coding are used as methods:text.formDecoded(),pairs.formEncoded(),text.percentDecoded().Part of #146 (methods are the preferred API style; owner direction 2026-10-06, first applied in #96 as
Digest.equalsConstantTimewithconstantTimeEqualkept as a thin wrapper). This slice follows exactly that pattern.Functions in scope
formDecoded(String),formEncoded(List<(String, String)>),percentDecoded(String) instd/uri. Keep as free functions:route(combines a template and a case, no single receiver) and the undocumented byte/character helpers incharacters.trb(internal; see the open question on #146). Not markedreadyyet: the ready buffer is full (4); label it when a slot frees.Source (pinned record)
usethe method like any member. If anextendwithout a trait on a type of another package turns out not to work instd/, stop and re-plan instead of working around it.Acceptance criteria
std/uriprovidesString.formDecoded(),List<(String, String)>.formEncoded()andString.percentDecoded()with the current result typesstd/uriform and bridges test files): method result equals free function result on the existing vectors, including malformed escapesdeprecatedhere (the deprecation path is an open owner decision on #146).docs/standard-library/leads with the method in every example; the wrapper is listed as the older spelling. Examples are checked withtrb check;skills/is regenerated.compiler/srcandtools/keep calling the wrapper).Seed
No. Ordinary TorbScript in
std/only: no syntax change, no new native, no driver flag, no std name the compiler looks up by string. If that turns out wrong, stop and re-plan (two commits, seed refresh).Size
One PR, one Conventional Commit (
refactor(<module>): ...orfeat(<module>): ...), tests and docs in the same commit.Dependencies
Tracking epic: #146. No other dependency; independent of the other module slices.
[loop:torbscript] scope update from the owner decision on #146 (torben, 2026-10-08): the free functions covered by this slice are removed in the same PR that adds the methods, not kept as wrappers and not marked
deprecated. Migrate every caller in the repo (std, tests, examples, docs) to the method in the same PR. No lint migration rule needed.[loop:torbscript] claim refine by session:loop-torbscript-20261008 until 2026-10-08T11:36:00Z
[loop:torbscript] refine: ready. Checked at main
4a675e7against ROADMAP, docs/design/URI.md, CONCEPT "Extension Methods" and the Open Questions (nothing blocks; deprecation path decided on #146).Acceptance criteria (supersede the wrapper bullets in the body, per the scope-update comment)
String.formDecoded(): List<(String, String)>,List<(String, String)>.formEncoded(): StringandString.percentDecoded(): Result<String, UriError>exist instd/uriwith the current result types and behaviour.formDecoded,formEncoded,percentDecodedare removed; no wrapper, nodeprecated, no lint rule. Keep free:route,percentDecodedBytesand the other helpers ofcharacters.trb.std/uri/tests/bridges.test.trbare rewritten to the method spelling on the existing vectors (malformed escapes, invalid UTF-8, empty input, round trip) and still pass.trb checkpasses on the examples:docs/standard-library/uri.md(frontmatter members list lines 24-25, import line 54, signatures at 312-314, prose at 120), the doc comments inform.trb/characters.trb, thedocs/design/URI.mdsignature block and prose (lines ~330, 749-755, 796-799, 814, includingsegments().map(percentDecoded));skills/torbscript-networking/references/standard-library/uri.mdregenerated.Free functions to remove:
formDecoded(std/uri/src/form.trb:18),formEncoded(form.trb:71),percentDecoded(std/uri/src/characters.trb:249).Callers to migrate (all inside
std/uri; no caller in compiler/src, tools, examples, benchmarks or tests/conformance):uri.trb(lines ~14-15 imports, 742, 750, 769formEncoded pairs, 928),template.trb(imports at 9-10, calls at 386-387, 865, 910),tests/bridges.test.trb, docs above. Not a caller: the localpercentDecodedinstd/yaml/src/scanner.trb:760is a private function of its own with a different signature; leave it.Where the methods are declared (lesson of #182, and #178): a method is found in the module a
usenames. Re-exported members only work throughpublic use List.x from "./file"imported by thestd/uripackage path (asList.plainTextfrom "std/markdown" does today); importing a re-export through a relative../src/libpath fails (#182, open). Plan: declareextend String { formDecoded, percentDecoded }andextend List<(String, String)> { formEncoded }next to their bodies inform.trbandcharacters.trb, re-export instd/uri/src/lib.trbwithpublic use String.formDecoded, List.formEncoded from "./form"andpublic use String.percentDecoded from "./characters"(replacing lines 27-28); internal callers and tests import from the declaring file (./form,./characters, tests../src/form,../src/characters), docs and anything external from "std/uri". If anextendwith a generic/tuple receiver inform.trbfails the seed's native back end (asList<MarkdownInline>did in lib.trb), move that one declaration as #178 did and say so in the PR; if thestd/urire-export import does not check, declare inlib.trbas compression and encoding do. Do not work around #182 in the compiler in this PR.Pinned records: docs/standard-library/uri.md, docs/design/URI.md, CONCEPT.md "Extension Methods" at
129f1574e8. No design record fixes the API shape.Seed: no (std only; no syntax change, no native, no driver flag; the names
formDecoded/formEncoded/percentDecodedare not looked up by the compiler, wellknown.trb only names the types). Stop and re-plan if that proves wrong.Size: one PR, one commit
refactor(uri): make formDecoded, formEncoded and percentDecoded methods and remove the functions. Note: the ready buffer already holds #170-#172 and #177, so this is the fifth; implementation order stays oldest first.Implementer model: sonnet/medium (std and docs only). Worker usage for this refine: about 60k tokens (sonnet).
next: implement
[loop:torbscript] claim implement by session:loop-torbscript-20261008 until 2026-10-08T15:40:00Z
[loop:torbscript] implement: PR open at #187 (branch
loop/179-uri-methods, one commitrefactor(uri): make formDecoded, formEncoded and percentDecoded methods and remove the functions).String.formDecoded(),List<(String, String)>.formEncoded()andString.percentDecoded()are declared next to their bodies inform.trb/characters.trband re-exported fromstd/uriviapublic use String.x, List.y; the three free functions are removed, callers inuri.trb,template.trbandbridges.test.trbmigrated;docs/standard-library/uri.md,docs/design/URI.mdand the skill reference lead with the methods. CI on649f1f5a: bootstrap, tier A (docs check, doc --check, skill --check, format --check, std tests), commit messages and pdisc green; tier B skipped (not required); the aggregategatesjob and seed/archive packaging were still finishing when I stopped waiting. One CI round was needed: a doc example (print [..].formEncoded()) parsed as indexing and faileddoc --check; fixed and squashed. Worker usage: about 200k tokens (sonnet), estimated. next: reviewReleasing the claim by session:loop-torbscript-20261008.