You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/reference/rule-engine-semantics.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,18 +24,18 @@ Rule semantics must preserve:
24
24
25
25
## Rule execution order
26
26
27
-
Rules execute in the order specified by `workspace.formula_rule_order`. This list of rule IDs is the semantic contract. Do not rely on dictionary insertion order as a semantic execution contract — always use `formula_rule_order`.
27
+
Rules execute in the order specified by `workspace.rule_order`. This list of rule IDs is the semantic contract. Do not rely on dictionary insertion order as a semantic execution contract — always use `rule_order`.
28
28
29
29
## Value precedence
30
30
31
31
When a cell is evaluated, the engine resolves value precedence from highest to lowest:
32
32
33
-
1. Hardcoded user override (`user_override_addrs`)
33
+
1. Hardcoded user override (`cube.user_override_addrs`)
34
34
2. Cell rule (single-cell rule)
35
35
3. Slice rule (rule targeted at a pattern)
36
36
4. Empty cell (`None`)
37
37
38
-
A more specific rule always wins over a less specific rule. When two rules have the same specificity and match the same cell, the later rule in `workspace.formula_rule_order` wins.
38
+
A more specific rule always wins over a less specific rule. When two rules have the same specificity and match the same cell, the later rule in `workspace.rule_order` wins.
39
39
40
40
## Rule invalidation
41
41
@@ -49,15 +49,15 @@ The system must not expose a durable state where deleted graph or item reference
49
49
50
50
## Rule deletion
51
51
52
-
Deleting a rule must remove its rule ID from `workspace.formula_rule_order` in the same semantic mutation. The system must not persist dangling rule-order entries.
52
+
Deleting a rule must remove its rule ID from `workspace.rule_order` in the same semantic mutation. The system must not persist dangling rule-order entries.
53
53
54
54
## Anti-patterns
55
55
56
56
| Anti-pattern | Why we avoid | Correct approach |
57
57
| --- | --- | --- |
58
58
| Skipping dependency cleanup during recompute | Leaves stale state | Ensure recompute cleanup and indegree updates always run |
59
59
| Rule references stored by label | Renames break rules | Resolve to stable IDs |
60
-
| Relying on dict order for rule execution | Serialization drift | Use `workspace.formula_rule_order`|
60
+
| Relying on dict order for rule execution | Serialization drift | Use `workspace.rule_order`|
61
61
| Bidirectional recurrence | Ambiguous dependency direction | Use only `PREV` or only `NEXT`|
62
62
| Writing to `PREV` / `NEXT` on LHS | Ambiguous mutation target | LHS may target only current cell or explicit slice |
63
63
| Persisting error values | Reload corrupts state | Recalculate errors on load |
Copy file name to clipboardExpand all lines: docs/reference/rule-syntax.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -96,15 +96,15 @@ This is **not** the same as `Year[2026]`. Bracket shorthand applies to a full cu
96
96
97
97
### Cube-relative shorthand on the RHS
98
98
99
-
RHS references may use cube-relative shorthand. If a referenced cube shares a dimension with the current target cell, OM Core binds that dimension from the current evaluation context, provided the binding is unambiguous. Dimensions that do not exist in the referenced cube are ignored. A fully explicit address is always safer and required when the shorthand would be ambiguous.
99
+
RHS references may use cube-relative shorthand. If a referenced cube shares a dimension with the current target cell, OM Core binds that dimension from the current evaluation context, provided the binding is unambiguous. Dimensions that do not exist in the referenced cube are not carried over; they default to the first item of that dimension in the target cube. A fully explicit address is always safer and required when the shorthand would be ambiguous.
100
100
101
101
For example, if the target cell is `AnnualDep::Asset.Vehicle:Year.2026`, then this shorthand:
102
102
103
103
```text
104
104
Inputs::[Metric.Cost]
105
105
```
106
106
107
-
carries over the shared `Asset.Vehicle` context to resolve `Inputs::Asset.Vehicle:Metric.Cost`. The `Year` dimension is not carried over because `Inputs` does not have a `Year` dimension.
107
+
carries over the shared `Asset.Vehicle` context to resolve `Inputs::Asset.Vehicle:Metric.Cost`. The `Year` dimension is not carried over because `Inputs` does not have a `Year` dimension; it would default to the first `Year` item of `Inputs` if that dimension existed there.
108
108
109
109
Use the full semantic address whenever you need to read from a different context than the current target cell.
110
110
@@ -198,11 +198,11 @@ This behavior lets you define a general rule first and then add targeted overrid
198
198
An **anchored rule** targets exactly one cell. The user opts in by prefixing the rule target with `$`.
199
199
200
200
```text
201
-
rule $[Year.2024, Region.North] = 1100 # anchored: one cell
The `$[...]`form is a **contextual shorthand**used when the active cube, channel, and view context are already known, such as in the grid or rule panel. In standalone scripts, prefer the full form:
205
+
The `$` prefix is the only anchored shorthand available in standalone scripts. The bracket form `$[...]` is **not**accepted as a rule target; it is only valid in contextual input such as the grid or rule panel, where the active cube, channel, and view are already known. In scripts, prefer the full form:
206
206
207
207
```text
208
208
rule Cube::@.value:Dim.Item:Dim.Item = expression
@@ -222,10 +222,10 @@ Example with a 3D cube `(Year, Region, Scenario)`:
|`$[Year.2024, Region.North, Scenario.Actual]`| Yes |`Actual`| One cell: `(2024, North, Actual)`|
226
-
|`[Year.2024, Region.North]`| No | wildcard | Slice: `(2024, North, *)`|
225
+
|`$Sales::@.value:Year.2024:Region.North:Scenario.Actual`| Yes |`Actual`| One cell: `(2024, North, Actual)`|
226
+
|`Sales::@.value:Year.2024:Region.North`| No | wildcard | Slice: `(2024, North, *)`|
227
227
228
-
Use `$`when entering a rule via the grid or rule panel to bind it to one specific cell. In scripts, use the full `Cube::@.channel:...` form and omit `$` when defining rules that should apply across dimensions.
228
+
In scripts, use `$`only as a prefix on a full canonical address. In the grid or rule panel, the contextual `$[...]` form may be used to bind a rule to one specific cell.
Copy file name to clipboardExpand all lines: docs/reference/scripting.md
+19-6Lines changed: 19 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -126,8 +126,8 @@ rule {{selected}} = 100000
126
126
Use `exec {{cmd}}` to execute a command and capture its output.
127
127
128
128
```openm
129
-
# Legacy $(selection) is deprecated. Use exec selection instead.
130
-
cells=exec selection
129
+
# Legacy $(timestamp) is deprecated. Use exec timestamp instead.
130
+
ts=exec timestamp %Y%m%d_%H%M%S
131
131
```
132
132
133
133
### Legacy syntax
@@ -170,6 +170,15 @@ view PnL
170
170
171
171
The first form defines a view. The second form activates it.
172
172
173
+
#### `use` — set the active cube context
174
+
175
+
```openm
176
+
use Sales
177
+
rule Revenue = Cost * 1.15
178
+
```
179
+
180
+
`use` sets the default cube for subsequent `rule` commands that omit a `Cube::` prefix. It is optional; explicit `Cube::@.value:...` addresses are preferred in scripts.
181
+
173
182
### Rule definition
174
183
175
184
#### `rule` — define a calculation rule
@@ -211,7 +220,7 @@ References can also use bracket shorthand:
When a referenced cube shares a dimension with the current target cell, the shorthand binds that dimension from the context. Dimensions that do not exist in the referenced cube are ignored. For example, `AnnualDep` has dimensions `Asset` and `Year`, while `Inputs` has `Asset` and `Metric`. The shorthand `Inputs::[Metric.Cost]` binds the current `Asset` from the target cell but ignores the `Year` dimension because `Inputs` does not have one.
223
+
When a referenced cube shares a dimension with the current target cell, the shorthand binds that dimension from the context. Dimensions that do not exist in the referenced cube are not carried over; they default to the first item of that dimension in the target cube. For example, `AnnualDep` has dimensions `Asset` and `Year`, while `Inputs` has `Asset` and `Metric`. The shorthand `Inputs::[Metric.Cost]` binds the current `Asset` from the target cell. The `Year` dimension is not carried over because `Inputs` does not have a `Year` dimension.
0 commit comments