DecodeResult coercions are lossy and zero-fill, and become live when t2db.31 calls it #1700

Closed
opened 2026-10-27 13:41:26 +00:00 by sam · 0 comments
Owner

Surfaced by nx30 (the schema-aware ModuleRegistry.DecodeResult that turns a module's flat map result into the kind's typed Result).

THE DEBT

  • A lossy int to string coercion.
  • Absent keys zero-fill rather than failing, so a result missing a field reads as the zero value instead of being rejected.

WHY IT IS NOT URGENT YET, AND WHY IT STILL MATTERS
Both are currently unreachable because nothing calls DecodeResult in production: action playbooks load but are not routed (nx30). t2db.31 wires the first side-effecting position and will call it, which is the moment a silently zero-filled field becomes a silently wrong value in an expression that a later action then branches on. That is the field-level rejection this design exists to provide, inverted.

WHAT TO DO
Decide per coercion: a representation change (int to string) should either be rejected or be explicit and total; an absent required key should fail, not zero-fill, since the kind's Result schema is known at that point. Add the table-driven cases first, then the fix.

Close reason

Fixed in 9790b805. DecodeResult now rejects both debts: setResultField accepts a value only when its type is the field type (the ConvertibleTo/Convert path is gone, so a number for a string field no longer becomes the rune string - 42 was decoding as "*"), and decodeResultStruct requires every declared Result field to be present (an absent field used to read as the zero value). Unknown-key detection is now sorted, so the error is deterministic. Decision recorded as D5 in docs/prds/multi-action-playbooks.md with a verification bullet. Red-first evidence: TestDecodeResultRejectsSchemaViolations failed on the absent-field and number-for-string cases before the fix and passes after; TestDecodeResultUnknownFieldIsError was passing an incomplete map, so its fixture now supplies every field plus the bogus key. task check clean on the committed tree.


Imported from beads archie-core-zmr4 · GitHub #1104 · type bug · priority P2 · created 2026-09-21 · closed 2026-09-29

Surfaced by nx30 (the schema-aware ModuleRegistry.DecodeResult that turns a module's flat map result into the kind's typed Result). THE DEBT - A lossy int to string coercion. - Absent keys zero-fill rather than failing, so a result missing a field reads as the zero value instead of being rejected. WHY IT IS NOT URGENT YET, AND WHY IT STILL MATTERS Both are currently unreachable because nothing calls DecodeResult in production: action playbooks load but are not routed (nx30). t2db.31 wires the first side-effecting position and will call it, which is the moment a silently zero-filled field becomes a silently wrong value in an expression that a later action then branches on. That is the field-level rejection this design exists to provide, inverted. WHAT TO DO Decide per coercion: a representation change (int to string) should either be rejected or be explicit and total; an absent required key should fail, not zero-fill, since the kind's Result schema is known at that point. Add the table-driven cases first, then the fix. ### Close reason Fixed in 9790b805. DecodeResult now rejects both debts: setResultField accepts a value only when its type is the field type (the ConvertibleTo/Convert path is gone, so a number for a string field no longer becomes the rune string - 42 was decoding as "*"), and decodeResultStruct requires every declared Result field to be present (an absent field used to read as the zero value). Unknown-key detection is now sorted, so the error is deterministic. Decision recorded as D5 in docs/prds/multi-action-playbooks.md with a verification bullet. Red-first evidence: TestDecodeResultRejectsSchemaViolations failed on the absent-field and number-for-string cases before the fix and passes after; TestDecodeResultUnknownFieldIsError was passing an incomplete map, so its fixture now supplies every field plus the bogus key. task check clean on the committed tree. --- _Imported from beads `archie-core-zmr4` · GitHub #1104 · type bug · priority P2 · created 2026-09-21 · closed 2026-09-29_
sam added the bugmedium labels 2026-10-27 13:41:26 +00:00
sam self-assigned this 2026-10-27 13:41:26 +00:00
sam closed this issue 2026-10-27 13:41:26 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sam/archie#1700