design: root sum FromJSON duplicates domain wire tags — new domain constructor silently breaks root parsing #1

Open
opened 2026-06-11 15:37:32 +02:00 by yorunikakeru · 0 comments
Owner

IR.Action, IR.Condition, IR.Policy root parsers hardcode every leaf wire tag:

  • IR/Condition.hs:38-41 lists "process_running", "cpu_load", "battery_below", "battery_above"
  • IR/Action.hs:47-49 lists "service_disable", "service_enable", "power_profile"
  • IR/Policy.hs:42-43 lists "allow_ports", "fallback"

Each domain module also parses its own "type" tag. So adding a constructor to e.g. `IR.Domain.System.Condition` compiles cleanly, ToJSON emits it, domain FromJSON accepts it — but the root parser rejects it as "unknown condition type". No compiler error links the two places; the failure shows up only at decode time (or never, if no roundtrip test covers the new tag).

Options:

  • each domain exports its tag set (`tags :: [Text]`) and the root dispatches `t `elem` Process.tags`, or
  • root tries domain parsers in order (`<|>`), keeping tag knowledge in one place per domain, or
  • TH/Generic-derived dispatch.

Either way, one source of truth per tag.

`IR.Action`, `IR.Condition`, `IR.Policy` root parsers hardcode every leaf wire tag: - IR/Condition.hs:38-41 lists "process_running", "cpu_load", "battery_below", "battery_above" - IR/Action.hs:47-49 lists "service_disable", "service_enable", "power_profile" - IR/Policy.hs:42-43 lists "allow_ports", "fallback" Each domain module *also* parses its own "type" tag. So adding a constructor to e.g. \`IR.Domain.System.Condition\` compiles cleanly, ToJSON emits it, domain FromJSON accepts it — but the **root** parser rejects it as "unknown condition type". No compiler error links the two places; the failure shows up only at decode time (or never, if no roundtrip test covers the new tag). Options: - each domain exports its tag set (\`tags :: [Text]\`) and the root dispatches \`t \`elem\` Process.tags\`, or - root tries domain parsers in order (\`<|>\`), keeping tag knowledge in one place per domain, or - TH/Generic-derived dispatch. Either way, one source of truth per tag.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
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
FrogOS/IR#1
No description provided.