formats: Xml.decode reads a document into a typed value (step 3a of #78) #570
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 3a of the epic #78 (
std/xml). Steps 1 (#429, tree, reader, writer) and 2 (#552, internal subset) have landed. S3 listings and errors (#20) and the WebDAV multistatus replies (#67) need typed reading first; writing follows as step 3b once this has landed.Goal
Xml().decode<T>(text)reads an XML document into aDecodetype with the default mapping, so an S3ListBucketResultdecodes into a type.Source
ValueDecoder(section 4 vocabulary), and decision 15 in section 16.std/toml/src/decoder.trbandToml.decodeare the layout model (tree toEncodedValue, thenValueDecoder).Design record point
ENCODING.md slice 8, section 9. Touches the seed? No: the compiler does not import
std/xml, and no std name is looked up by string.Decisions (decided by the loop)
parse, then converted to anEncodedValueand read byValueDecoder.of(..., lenient: true, naming:, strict:); XML has only text, soint()andfloat()parse it.xmlns="http://s3.amazonaws.com/doc/2006-03-01/") needs. The root element's own name is not checked.Toml.decode.ValueDecoderhas no such option yet, so commit 1 adds one (singleAsList, default off, documented instd/encoding); commit 2 is the decoder.Xml:naming(asToml.naming) andstrict(an unread child element or attribute is an error).decodeanswersResult<Value, XmlError>;XmlErrorgets adecodeFailedconstructor likeTomlError.decodeFailed.Format<XmlError>andXml.encodeare step 3b, not here.Acceptance criteria
Xml().decode<T>(text)exists with the documented behaviour; a missing field takes its default orNone, a text that is not well-formed is theXmlErrorofparse, a type mismatch is anXmlErrorwith the field chain.std/xml/tests: a record from child elements, from attributes, and from a mix; aList<T>from repeated elements and from a single one;Int,Float,BoolandOptionfields from text;naming;stricton and off; a default-namespace document; an entity and a CDATA value; a failure with its field chain.ListBucketResult(Name,Prefix,IsTruncated,ContentswithKey,Size,LastModified,ETag) and an S3Errordocument (Code,Message,RequestId) into types.singleAsListinstd/encoding(on and off).docs/standard-library/xml.mdanddocs/standard-library/encoding.mddocument the new surface,skills/is regenerated, and ENCODING.md section 14 and 16 record the step (new decision point).sh tools/gates.sh agreen in forge CI;tools/check-commits.shclean.Size
One PR, two Conventional Commits:
feat(encoding): ValueDecoder reads a single value as a one-item list on requestandfeat(std/xml): Xml.decode reads a document into a typed value.Dependencies
Part of #78 (step 3a). Unblocks step 3b (encode,
Format<XmlError>), then #20 and #67 (typed replies).std/xml#78std/xml#78std/xml#78[loop:torbscript] claim implement by session:loop-torbscript-20261029 until 2026-10-29T12:46Z
[loop:torbscript] checkpoint: done: commit 1 (singleAsList option, test, docs, skills) on branch loop/570-xml-decode; in flight: commit 2 (Xml.decode); next: tests, docs, ENCODING.md, push, PR. Finding: ValueDecoder already reads a single value as a one-item list under lenient, so the new option makes it independent of lenient (lenient implies it).
[loop:torbscript] checkpoint: PR #573 open (branch loop/570-xml-decode, two commits, review requested from argus); CI pending (gates, commit messages, touches, pdisc); next: read CI result, fix red on the same branch, then write-back.
[loop:torbscript] implement: #573, CI pending (commit messages, touches, pdisc and bootstrap green; tier A / gates still running after ~50 min), worker usage ~400k tokens, next: waiting (CI result, then merge gate: argus review). Notes: ValueDecoder already read a lone value as a list under lenient, so singleAsList is the independent option with lenient implying it; the S3 tests needed Naming.PascalCase and a lenient String refusing records, both in commit 2 and listed in the PR body.
[loop:torbscript] claim fix by session:loop-torbscript-20261029 until 2026-10-29T14:45Z
[loop:torbscript] review: the red
tier A (linux-x64)lane was caused by this change, not flaky:docs checkanddocs index --checkfailed because thestd/xmlsummary had grown to 278 characters (limit 240) and the generated indexes were stale; every other tier A gate was green. Fixed on the same branch by shortening the summary to 238 characters and refreshing the six copies of it (docs and generated skills), folded into the Xml.decode commit (rebased onto the same base, force-with-lease; head now5cced74d,tools/check-commits.shclean). Forge CI for the new head is queued behind other runs on the runner pool (run 2257 waiting), next: waiting (forge CI and merge gate). Worker usage: ~0.4M tokens.s3:driver as a package of its own #20Xml.encodewrites a typed value as an XML document (step 3b of #78) #605std/xml#78