altitude: attach in DSL.Condition pattern-matches IR leaf constructors — couples DSL layer to IR internals #27
Loading…
Add table
Add a link
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?
Problem
DSL.Condition.attachreaches through the IR domain constructors to attach anObserveStrategyto each leaf condition:Every new
IR.Domain.Process.ConditionorIR.Domain.System.Conditionconstructor forces a change toattachin the DSL layer — even if the strategy semantics are unchanged. The DSL layer should not need to know about domain-level constructor shapes.Better approach
Push the
attachStrategyresponsibility into the IR layer via a typeclass or a function exposed by each domain module:Adding a new
System.Conditionconstructor then requires only updatingSystem.attachStrategy— a single-file change in the IR package, with-Wallenforcing exhaustiveness there.Follow-up: make strategy conflicts an error instead of silent override
Discussed alongside this refactor: the current
attachsemantics silently replace any existing strategy on a leaf. Both "outer wins" (current) and "inner wins" (old <|> Just s) lose a strategy silently — e.g.:Decision: at this stage a conflict should be a
DomainError, not a silent override. The DSL already returnsEither DomainErroreverywhere, soviacan surface it naturally:Implications:
DomainErrorconstructor (StrategyConflictor similar) lives inIR.Domain.Error→ cross-repo change infrogos-ir, then repin incabal.project.viabehavior ("replaces any existing strategy", "overriding any strategies previously set on individual leaves") — docstring, override tests, and CHANGELOG must be updated.viaoverAnd/Notfails if any leaf already carries a strategy.Worth doing in the same pass as this refactor: the per-leaf conflict check is exactly the code this issue moves into the IR layer, so doing both at once avoids touching the same lines twice.