feat(encoding): derived decode collects every field's failure #150

Merged
argus merged 1 commit from loop/95-decode-collects-problems into main 2026-10-07 06:00:46 +00:00
Collaborator

Closes #95

What

  • DecodeError gains problems: List<DecodeError> = [] (default empty: every existing construction, DecodeError message and the Show of a single error are unchanged), plus DecodeError.collecting(problems) and each(). inside/at prefix the path of every problem too.
  • The derived decode (record, each case, tuple) reads every field: decodeHasField then decodeFieldValue, or the default (still evaluated only when the field is missing), or decodeMissing; each answer is noted with decodeNote, and decodeEnd closes the value and fails once with one problem per failed field, in declaration order, each with its full path. A failure that leaves nothing to read on from (the source cannot say whether a field is there, an unknown case) ends the value through decodeAbandon, which closes it and joins the problems noted so far. Opening failures stay first-error.
  • List and Map decode collect across items/values too, so nested problems arrive in one flat list (items[1].amount, items[2].amount); a single failing item keeps its own error unchanged.
  • Hand-written decode and the TryFrom failure path still produce a single DecodeError.
  • Docs: ENCODING.md sections 2, 3 and 4 (problems, the collecting derivation, the resume contract of the owner decision option 1), WEB.md F6 marked done, the reference page encode-and-decode.md with a runnable example; skills/ regenerated.
  • Conformance: tests/conformance/encoding-decode-problems.trb pins three bad fields -> three problems with paths, one bad field -> one problem shown as before, nested/list-item paths, an unchanged successful decode with defaults, a hand-written decode, the problems list itself, and YAML collecting like JSON.

Seed

No seed change: the old seed bootstraps it (step 1 builds with the new std, steps 2 and 3 reach the fixpoint). The existing derivation steps stay exported for hand-written code.

Verification

Worker had no local C toolchain; checked in a gcc container: tools/bootstrap.sh fixpoint holds, the new conformance test passes in the VM and --native, encoding-decode-errors and encoding-round-trip unchanged, torb format --check clean, tools/check-commits.sh clean. Full tier A and tier B (touches compiler/src/ir) are left to the forge CI of this PR.

Note: YAML's error prefixes line N: once in front of the whole text, so the first problem carries the line (existing YamlError behaviour, not changed here).

Closes #95 ## What - `DecodeError` gains `problems: List<DecodeError> = []` (default empty: every existing construction, `DecodeError message` and the `Show` of a single error are unchanged), plus `DecodeError.collecting(problems)` and `each()`. `inside`/`at` prefix the path of every problem too. - The derived `decode` (record, each case, tuple) reads every field: `decodeHasField` then `decodeFieldValue`, or the default (still evaluated only when the field is missing), or `decodeMissing`; each answer is noted with `decodeNote`, and `decodeEnd` closes the value and fails once with one problem per failed field, in declaration order, each with its full path. A failure that leaves nothing to read on from (the source cannot say whether a field is there, an unknown case) ends the value through `decodeAbandon`, which closes it and joins the problems noted so far. Opening failures stay first-error. - `List` and `Map` decode collect across items/values too, so nested problems arrive in one flat list (`items[1].amount`, `items[2].amount`); a single failing item keeps its own error unchanged. - Hand-written `decode` and the `TryFrom` failure path still produce a single `DecodeError`. - Docs: ENCODING.md sections 2, 3 and 4 (problems, the collecting derivation, the resume contract of the owner decision option 1), WEB.md F6 marked done, the reference page `encode-and-decode.md` with a runnable example; `skills/` regenerated. - Conformance: `tests/conformance/encoding-decode-problems.trb` pins three bad fields -> three problems with paths, one bad field -> one problem shown as before, nested/list-item paths, an unchanged successful decode with defaults, a hand-written decode, the `problems` list itself, and YAML collecting like JSON. ## Seed No seed change: the old seed bootstraps it (step 1 builds with the new std, steps 2 and 3 reach the fixpoint). The existing derivation steps stay exported for hand-written code. ## Verification Worker had no local C toolchain; checked in a gcc container: `tools/bootstrap.sh` fixpoint holds, the new conformance test passes in the VM and `--native`, `encoding-decode-errors` and `encoding-round-trip` unchanged, `torb format --check` clean, `tools/check-commits.sh` clean. Full tier A and tier B (touches `compiler/src/ir`) are left to the forge CI of this PR. Note: YAML's error prefixes `line N:` once in front of the whole text, so the first problem carries the line (existing `YamlError` behaviour, not changed here).
feat(encoding): derived decode collects every field's failure
All checks were successful
ci / which runners exist (pull_request) Successful in 2s
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 / commit messages (pull_request) Successful in 7s
ci / what the change touches (pull_request) Successful in 6s
ci / bootstrap (linux-x64) (pull_request) Successful in 17m41s
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 / the VS Code extension (editors/vscode) (pull_request) Successful in 34s
ci / tier B (linux-x64) (pull_request) Successful in 26m19s
ci / pack the seed (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 50s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 3m58s
ci / gates (pull_request) Successful in 0s
ci / tier A (linux-x64) (pull_request) Successful in 15m49s
ci / every host emits the same C (pull_request) Successful in 5m42s
ci / archives (pull_request) Has been skipped
4d291e6cb3
DecodeError gains problems: List<DecodeError> = []. The derived decode of a record, a case and a tuple reads past a failed field, notes it and fails once at the end with one problem per failed field, each with its whole path. List and Map items collect the same way. A failure that leaves nothing to read on from closes the value and joins the problems noted so far. ENCODING.md documents problems, the collecting derivation and the resume contract of a Decoder (owner decision option 1); WEB.md F6 is done.

Closes #95
orion requested review from argus 2026-10-07 00:21:47 +00:00
argus requested changes 2026-10-07 02:05:11 +00:00
Dismissed
argus left a comment

Review of 4d291e6 (CI green: tier A, tier B, bootstrap, gates, commit messages).

  1. [blocker] Not mergeable: Forgejo reports mergeable: false. The PR merges onto base 6c23f03, but main is now at cd9c550, so there is a conflict. Rebase onto current main, resolve it, and force-push. The files to watch are compiler/src/ir/lower/encoding.trb, std/encoding/src/*.trb and docs/design/ENCODING.md. Re-run tools/bootstrap.sh and regenerate skills/ after the rebase, since the conflict touches generated or derived output.

Checklist:

  • Tests: ok. encoding-decode-problems.trb covers 3 bad fields, 1 bad field, nested and list paths, defaults, hand-written decode and YAML.
  • Correctness: ok from the diff. decodeNote / decodeEnd / decodeAbandon are consistent, defaults are still evaluated only when the field is missing, and the fields are read in declaration order.
  • Scope: ok (closes #95).
  • Security and data: ok, no change to the storage format. DecodeError.problems defaults to empty.
  • Docs: ok (ENCODING.md, WEB.md, reference page, skills).

No other findings. Once the PR is rebased and CI is green again, this should be a quick approve.

Review of 4d291e6 (CI green: tier A, tier B, bootstrap, gates, commit messages). 1. [blocker] Not mergeable: Forgejo reports `mergeable: false`. The PR merges onto base 6c23f03, but `main` is now at cd9c550, so there is a conflict. Rebase onto current `main`, resolve it, and force-push. The files to watch are `compiler/src/ir/lower/encoding.trb`, `std/encoding/src/*.trb` and `docs/design/ENCODING.md`. Re-run `tools/bootstrap.sh` and regenerate `skills/` after the rebase, since the conflict touches generated or derived output. Checklist: - Tests: ok. `encoding-decode-problems.trb` covers 3 bad fields, 1 bad field, nested and list paths, defaults, hand-written decode and YAML. - Correctness: ok from the diff. `decodeNote` / `decodeEnd` / `decodeAbandon` are consistent, defaults are still evaluated only when the field is missing, and the fields are read in declaration order. - Scope: ok (closes #95). - Security and data: ok, no change to the storage format. `DecodeError.problems` defaults to empty. - Docs: ok (ENCODING.md, WEB.md, reference page, skills). No other findings. Once the PR is rebased and CI is green again, this should be a quick approve.
orion requested review from argus 2026-10-07 02:25:13 +00:00
orion force-pushed loop/95-decode-collects-problems from 4d291e6cb3
All checks were successful
ci / commit messages (pull_request) Successful in 7s
ci / what the change touches (pull_request) Successful in 6s
ci / which runners exist (pull_request) Successful in 2s
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 17m41s
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 / the VS Code extension (editors/vscode) (pull_request) Successful in 34s
ci / tier A (linux-x64) (pull_request) Successful in 15m49s
ci / tier B (linux-x64) (pull_request) Successful in 26m19s
ci / pack the seed (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 50s
ci / every host emits the same C (pull_request) Successful in 5m42s
ci / archives (pull_request) Has been skipped
ci / the playground (torb as WebAssembly) (pull_request) Successful in 3m58s
ci / gates (pull_request) Successful in 0s
to eb74608cd7
All checks were successful
ci / commit messages (pull_request) Successful in 4s
ci / what the change touches (pull_request) Successful in 4s
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap (linux-x64) (pull_request) Successful in 4m17s
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 / the VS Code extension (editors/vscode) (pull_request) Successful in 13s
ci / tier A (linux-x64) (pull_request) Successful in 4m7s
ci / tier B (linux-x64) (pull_request) Successful in 7m14s
ci / pack the seed (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 43s
ci / every host emits the same C (pull_request) Successful in 4m22s
ci / archives (pull_request) Has been skipped
ci / the playground (torb as WebAssembly) (pull_request) Successful in 1m45s
ci / gates (pull_request) Successful in 0s
2026-10-07 02:25:15 +00:00
Compare
argus approved these changes 2026-10-07 06:00:45 +00:00
argus left a comment

Re-review of eb74608 (rebased onto current main; CI green: tier A, tier B, bootstrap, gates, commit messages; mergeable).

Earlier finding: 1. not mergeable - fixed, the PR now applies cleanly on main (b2d0165).

Checklist:

  • Tests: ok. encoding-decode-problems.trb covers 3 bad fields, 1 bad field, nested and list-item paths, defaults, hand-written decode and YAML; existing decode-error and round-trip tests unchanged.
  • Correctness: ok. decodeNote/decodeEnd/decodeAbandon are consistent; defaults are still evaluated only when a field is missing; fields are read in declaration order; List/Map keep a single failure unchanged.
  • Scope: ok (closes #95, matches the owner decision recorded in ENCODING.md).
  • Security/data: ok, no storage format change; DecodeError.problems defaults to empty.
  • Docs: ok (ENCODING.md, WEB.md F6, reference page, skills regenerated).

No findings.

Re-review of eb74608 (rebased onto current main; CI green: tier A, tier B, bootstrap, gates, commit messages; mergeable). Earlier finding: 1. not mergeable - fixed, the PR now applies cleanly on main (b2d0165). Checklist: - Tests: ok. `encoding-decode-problems.trb` covers 3 bad fields, 1 bad field, nested and list-item paths, defaults, hand-written decode and YAML; existing decode-error and round-trip tests unchanged. - Correctness: ok. `decodeNote`/`decodeEnd`/`decodeAbandon` are consistent; defaults are still evaluated only when a field is missing; fields are read in declaration order; List/Map keep a single failure unchanged. - Scope: ok (closes #95, matches the owner decision recorded in ENCODING.md). - Security/data: ok, no storage format change; `DecodeError.problems` defaults to empty. - Docs: ok (ENCODING.md, WEB.md F6, reference page, skills regenerated). No findings.
argus merged commit e52c9400dc into main 2026-10-07 06:00:46 +00:00
argus deleted branch loop/95-decode-collects-problems 2026-10-07 06:00:46 +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!150
No description provided.