farseer-cli 1.19.0 → 1.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. package/README.md +32 -9
  2. package/dist/commands/app.js +42 -3
  3. package/dist/commands/app.js.map +1 -1
  4. package/dist/commands/cells.js +120 -85
  5. package/dist/commands/cells.js.map +1 -1
  6. package/dist/commands/dashboards.js +246 -12
  7. package/dist/commands/dashboards.js.map +1 -1
  8. package/dist/commands/dimensions.js +72 -31
  9. package/dist/commands/dimensions.js.map +1 -1
  10. package/dist/commands/docs.js +82 -0
  11. package/dist/commands/docs.js.map +6 -0
  12. package/dist/commands/files.js +49 -0
  13. package/dist/commands/files.js.map +2 -2
  14. package/dist/commands/folders.js +76 -0
  15. package/dist/commands/folders.js.map +6 -0
  16. package/dist/commands/formula.js +38 -30
  17. package/dist/commands/formula.js.map +1 -1
  18. package/dist/commands/install.js +32 -30
  19. package/dist/commands/install.js.map +2 -2
  20. package/dist/commands/model.js +30 -5
  21. package/dist/commands/model.js.map +2 -2
  22. package/dist/commands/push.js +5 -3
  23. package/dist/commands/push.js.map +1 -1
  24. package/dist/commands/sheets.js +474 -52
  25. package/dist/commands/sheets.js.map +1 -1
  26. package/dist/commands/skills.js +157 -0
  27. package/dist/commands/skills.js.map +6 -0
  28. package/dist/commands/variables.js +246 -82
  29. package/dist/commands/variables.js.map +1 -1
  30. package/dist/index.js +102 -13
  31. package/dist/index.js.map +1 -1
  32. package/dist/mcp/resources/documentation.js +19 -12
  33. package/dist/mcp/resources/documentation.js.map +1 -1
  34. package/dist/mcp/tools/appTools.js +1 -7
  35. package/dist/mcp/tools/appTools.js.map +1 -1
  36. package/dist/mcp/tools/cellTools.js +6 -19
  37. package/dist/mcp/tools/cellTools.js.map +1 -1
  38. package/dist/mcp/tools/dashboardTools.js +30 -412
  39. package/dist/mcp/tools/dashboardTools.js.map +2 -2
  40. package/dist/mcp/tools/dataTools.js +15 -146
  41. package/dist/mcp/tools/dataTools.js.map +1 -1
  42. package/dist/mcp/tools/folderTools.js +12 -78
  43. package/dist/mcp/tools/folderTools.js.map +1 -1
  44. package/dist/mcp/tools/modelTools.js +33 -371
  45. package/dist/mcp/tools/modelTools.js.map +1 -1
  46. package/dist/mcp/tools/pipelineContract.js +5 -1
  47. package/dist/mcp/tools/pipelineContract.js.map +1 -1
  48. package/dist/mcp/tools/runTools.js +8 -69
  49. package/dist/mcp/tools/runTools.js.map +1 -1
  50. package/dist/mcp/tools/sheetTools.js +14 -264
  51. package/dist/mcp/tools/sheetTools.js.map +1 -1
  52. package/dist/mcp/tools/syncTools.js +5 -1
  53. package/dist/mcp/tools/syncTools.js.map +1 -1
  54. package/dist/mcp/utils/operationResponse.js +41 -0
  55. package/dist/mcp/utils/operationResponse.js.map +6 -0
  56. package/dist/operations/cells.js +444 -0
  57. package/dist/operations/cells.js.map +6 -0
  58. package/dist/operations/dashboards.js +357 -0
  59. package/dist/operations/dashboards.js.map +6 -0
  60. package/dist/operations/data.js +206 -0
  61. package/dist/operations/data.js.map +6 -0
  62. package/dist/operations/errors.js +64 -0
  63. package/dist/operations/errors.js.map +6 -0
  64. package/dist/operations/exportModel.js +59 -0
  65. package/dist/operations/exportModel.js.map +6 -0
  66. package/dist/operations/folderPath.js +128 -0
  67. package/dist/operations/folderPath.js.map +6 -0
  68. package/dist/operations/folders.js +80 -0
  69. package/dist/operations/folders.js.map +6 -0
  70. package/dist/operations/install.js +109 -0
  71. package/dist/operations/install.js.map +6 -0
  72. package/dist/operations/model.js +275 -0
  73. package/dist/operations/model.js.map +6 -0
  74. package/dist/operations/sheets.js +766 -0
  75. package/dist/operations/sheets.js.map +6 -0
  76. package/dist/pipeline/failStep.js +43 -0
  77. package/dist/pipeline/failStep.js.map +6 -0
  78. package/dist/pipeline/generated-reference.json +11 -11
  79. package/dist/pipeline/queryWorker.js +3 -1
  80. package/dist/pipeline/queryWorker.js.map +1 -1
  81. package/dist/pipeline/requests.js +3 -32
  82. package/dist/pipeline/requests.js.map +1 -1
  83. package/dist/pipeline/service.js +46 -2
  84. package/dist/pipeline/service.js.map +1 -1
  85. package/dist/services/appSyncService.js +59 -9
  86. package/dist/services/appSyncService.js.map +1 -1
  87. package/dist/services/apps.js +10 -0
  88. package/dist/services/apps.js.map +1 -1
  89. package/dist/services/farseerService.js +28 -6
  90. package/dist/services/farseerService.js.map +1 -1
  91. package/dist/skills/bundled.js +106 -0
  92. package/dist/skills/bundled.js.map +6 -0
  93. package/dist/skills/install.js +257 -0
  94. package/dist/skills/install.js.map +6 -0
  95. package/dist/skills/pipeline.js +10 -18
  96. package/dist/skills/pipeline.js.map +1 -1
  97. package/dist/utils/agentSandbox.js +1 -1
  98. package/dist/utils/dimensionMembers.js +54 -0
  99. package/dist/utils/dimensionMembers.js.map +6 -0
  100. package/dist/utils/entityResolver.js +74 -25
  101. package/dist/utils/entityResolver.js.map +1 -1
  102. package/dist/utils/errorFormatter.js +13 -0
  103. package/dist/utils/errorFormatter.js.map +1 -1
  104. package/dist/utils/formulaFilters.js +11 -2
  105. package/dist/utils/formulaFilters.js.map +1 -1
  106. package/dist/utils/operationCli.js +102 -0
  107. package/dist/utils/operationCli.js.map +6 -0
  108. package/docs/cli-guide.md +195 -1
  109. package/docs/pipeline-reference.md +138 -24
  110. package/docs/troubleshooting.md +18 -0
  111. package/package.json +2 -2
  112. package/skills/farseer-app-dev/SKILL.md +131 -0
  113. package/skills/farseer-app-dev/assignments.md +185 -0
  114. package/skills/farseer-app-dev/farseer-client-api-guide.md +907 -0
  115. package/skills/farseer-app-dev/farseer-client-release-notes.md +212 -0
  116. package/skills/farseer-app-dev/working-patterns.md +876 -0
  117. package/skills/farseer-authenticate-to-tenant/SKILL.md +60 -0
  118. package/skills/farseer-authenticate-to-tenant/app-authentication.md +91 -0
  119. package/skills/farseer-author-import-job/SKILL.md +114 -0
  120. package/skills/farseer-author-import-job/cell-writes.md +530 -0
  121. package/skills/farseer-author-import-job/deploying-a-farseer-app.md +383 -0
  122. package/skills/farseer-author-import-job/import-job-pattern.md +232 -0
  123. package/skills/farseer-build-model/SKILL.md +122 -0
  124. package/skills/farseer-build-model/formula-grain-alignment.md +612 -0
  125. package/skills/farseer-build-model/naming-conventions.md +435 -0
  126. package/skills/farseer-build-model/sparse-formulas-pattern.md +330 -0
  127. package/skills/farseer-build-pipeline/SKILL.md +190 -0
  128. package/skills/farseer-build-pipeline/erp-sales/README.md +108 -0
  129. package/skills/farseer-build-pipeline/erp-sales/erp-sales-etl/Models/bronze/erp_sales_invoice_lines.yaml +23 -0
  130. package/skills/farseer-build-pipeline/erp-sales/erp-sales-etl/Models/bronze/erp_sales_invoice_lines_raw.yaml +23 -0
  131. package/skills/farseer-build-pipeline/erp-sales/erp-sales-etl/Models/bronze/erp_sales_item_product_map.yaml +17 -0
  132. package/skills/farseer-build-pipeline/erp-sales/erp-sales-etl/Models/bronze/erp_sales_item_product_map_raw.yaml +11 -0
  133. package/skills/farseer-build-pipeline/erp-sales/erp-sales-etl/Models/gold/erp_sales_cells.yaml +40 -0
  134. package/skills/farseer-build-pipeline/erp-sales/erp-sales-etl/Models/silver/erp_sales_lines.yaml +35 -0
  135. package/skills/farseer-build-pipeline/erp-sales/erp-sales-etl/Models/silver/erp_sales_recon.yaml +43 -0
  136. package/skills/farseer-build-pipeline/erp-sales/erp-sales-etl/Models/silver/erp_sales_unmapped_items.yaml +28 -0
  137. package/skills/farseer-build-pipeline/erp-sales/erp-sales-etl/main.py +49 -0
  138. package/skills/farseer-build-pipeline/erp-sales/erp-sales-load/Models/in/erp_sales_cells.yaml +17 -0
  139. package/skills/farseer-build-pipeline/erp-sales/erp-sales-load/Models/in/erp_sales_cells_raw.yaml +14 -0
  140. package/skills/farseer-build-pipeline/erp-sales/erp-sales-load/Models/load/erp_sales_to_model.yaml +47 -0
  141. package/skills/farseer-build-pipeline/erp-sales/erp-sales-load/main.py +44 -0
  142. package/skills/farseer-build-pipeline/erp-sales/item_to_product.csv +5 -0
  143. package/skills/farseer-build-pipeline/pipeline-app-failure-report-pattern.md +103 -0
  144. package/skills/farseer-build-pipeline/pipeline-source-encoding.md +68 -0
  145. package/skills/farseer-dashboards/SKILL.md +222 -20
  146. package/skills/farseer-dashboards/cards.md +59 -0
  147. package/skills/farseer-dashboards/charts.md +245 -0
  148. package/skills/farseer-dashboards/check.md +91 -0
  149. package/skills/farseer-dashboards/measures.md +88 -0
  150. package/skills/farseer-dashboards/page.md +99 -0
  151. package/skills/farseer-dashboards/reporting-period.md +82 -0
  152. package/skills/farseer-dashboards/standard-set.md +182 -0
  153. package/skills/farseer-dashboards/tables.md +174 -0
  154. package/skills/farseer-help-center/SKILL.md +66 -0
  155. package/skills/farseer-modify-model/SKILL.md +158 -0
  156. package/skills/farseer-modify-model/model-validation-pattern.md +251 -0
  157. package/skills/farseer-optimize-model/SKILL.md +314 -0
  158. package/skills/farseer-optimize-model/stats-dump.ts +139 -0
  159. package/skills/farseer-pnl/SKILL.md +220 -0
  160. package/skills/farseer-review-model/SKILL.md +172 -0
  161. package/skills/farseer-run-apps/SKILL.md +102 -0
  162. package/skills/pipeline-authoring/SKILL.md +4 -4
  163. package/skills/pipeline-authoring/practices.md +17 -4
  164. package/dist/services/agentApprovalFetch.js +0 -90
  165. package/dist/services/agentApprovalFetch.js.map +0 -6
@@ -0,0 +1,330 @@
1
+ # Sparse formulas — keep null cells null
2
+
3
+ Farseer stores data **sparse**: a cell that has no value is never materialized.
4
+ The moment a formula returns a concrete value — including `0` — for a cell that
5
+ *should* have been empty, that cell is materialized. Do this across a
6
+ high-dimensional grain and the model writes hundreds of thousands of cells that
7
+ carry no information, which inflates the cell count and slows every rollup,
8
+ export, and sheet render.
9
+
10
+ Treating sparsity as a feature — not an accident — is the **single biggest
11
+ performance lever** in Farseer modeling. The rule is simple:
12
+
13
+ > **Don't answer the false branch.** When a condition is not met, return *nothing*
14
+ > (null), not `0` and not a constant. Let null propagate.
15
+
16
+ Examples write a variable as `"Name" [Table, …] = formula`: its name, its tables in brackets, then its formula.
17
+
18
+ ---
19
+
20
+ ## Why `0` is not the same as null
21
+
22
+ | | Null cell | `0` cell |
23
+ |---|---|---|
24
+ | Stored? | No — sparse, costs nothing | Yes — materialized, costs a cell |
25
+ | In a SUM rollup | Treated as 0 (ignored) | Treated as 0 (counted as a populated cell) |
26
+ | In a `× multiply` | `value × null = null` (stays sparse) | `value × 0 = 0` (sows a 0) |
27
+ | Meaning | "no data here" | "the value here is exactly zero" |
28
+
29
+ The arithmetic result of a SUM is identical either way — which is exactly why the
30
+ bug is invisible until the model is slow. Reserve `0` for when zero is a **real,
31
+ meaningful measurement** that differs from "no data". Everywhere else, return null.
32
+
33
+ ---
34
+
35
+ ## The core mistake: answering both branches
36
+
37
+ A two-way `if(condition, trueValue, falseValue)` forces a value into *every* cell,
38
+ because the false branch always fires somewhere. If the false value is `0` (or a
39
+ constant equivalent to 0), every non-matching cell is materialized.
40
+
41
+ The fix is almost always to **drop the false branch** — Farseer's `if` is happy
42
+ with two arguments, and a missing third argument yields null.
43
+
44
+ | Anti-pattern (sows a value) | Sparse fix (returns null) | Why |
45
+ |---|---|---|
46
+ | `if(hasValue(B), 0, A)` | `if(not(hasValue(B)), A)` | true branch was a constant `0` — drop it; only emit when the real condition holds |
47
+ | `if(hasValue(B), B, 0)` | `B` | additive context: null already behaves as 0, the guard is pure overhead |
48
+ | `if(hasValue(B), A, C)` where `A ≡ 0` | `if(not(hasValue(B)), C)` | when one branch is a zero-constant, invert the test and emit only the meaningful branch |
49
+ | `gt(x, 0)` as a whole formula (binary flag) | `if(gt(x, 0), 1)` | a bare comparator emits `0` wherever its operands have data and the test is false (nothing where they are empty); the 2-arg `if` emits `1`-or-null |
50
+ | router `if(c1, a, … if(cN, z, 0))` | drop the terminal `, 0)` → `if(cN, z)` | every unmatched slice otherwise gets a `0` |
51
+ | `Measure × Flag` with `Flag = 0` on a slice | seed `Flag = NULL` on that slice | `value × 0` sows a 0; `value × null` stays sparse |
52
+
53
+ The recurring shape: **a constant `0` (or its equivalent) sitting in one branch of
54
+ an `if`.** Whenever you see that, ask "does this cell need to exist when the
55
+ condition is false?" — the answer is almost always no.
56
+
57
+ ---
58
+
59
+ ## Counting without sowing zeros
60
+
61
+ `RollupType` has no `COUNT`. To count populated rows, emit a **1-or-null presence
62
+ flag** and let `SUM` count it:
63
+
64
+ ```text
65
+ "Headcount flag" [Employee, Months] = if(gt("Contracted hours IN", 0), 1)
66
+ # SUM over Employee = headcount, and only populated employees cost a cell
67
+ ```
68
+
69
+ The 3-argument form `if(gt(...), 1, 0)` produces the same headcount but sows a `0`
70
+ on every empty employee/month — exactly the cells you wanted to stay sparse.
71
+
72
+ ---
73
+
74
+ ## When a constant genuinely must land in a cell — route it through an input, never a bare literal
75
+
76
+ The rule above is about **avoiding** a literal by dropping the false branch. But
77
+ sometimes a concrete `0` or `1` really does need to exist in a cell — a seed
78
+ value, a flag default, a "wake up this cell" anchor for a downstream
79
+ calculation that otherwise has nothing to attach to. For that case: **hold the
80
+ constant in a small input variable, and reference that variable inside the
81
+ `if()` — never write the literal in-line.**
82
+
83
+ ```text
84
+ # ❌ Still wrong even though a real value is needed here
85
+ "Seed_flag_CALC" = if(<condition>, 1, 0)
86
+
87
+ # ✅ Route the constant through an input
88
+ "Seed_flag_IN" = 1 # input variable, holds the constant
89
+ "Seed_flag_CALC" = if(<condition>, "Seed_flag_IN")
90
+ ```
91
+
92
+ This keeps the constant auditable and named (a real variable in the model,
93
+ not a magic number buried in a formula) — and, per the next point, it's also
94
+ the only reliable way to get the constant to materialize at all.
95
+
96
+ ## A bare literal with no dense operand to anchor a grain returns null, not the literal
97
+
98
+ Sharper and less obvious: a formula built entirely from literals **does not
99
+ reliably produce cells in the first place**, regardless of what you intended
100
+ it to output. Confirmed live: `if(lt(0 - 1649972, 0), 1649972, 0)` — every
101
+ operand a bare constant — evaluated to **null**, while the equivalent
102
+ comparison against a real stored variable, `lt(sum(<dense var>, ...), 0)`,
103
+ correctly returned `1`. A literal has no grain of its own to enumerate, so on
104
+ its own it cannot define which cells should exist.
105
+
106
+ **Practical consequence:** "I'll just hardcode the two branches for now and
107
+ fix it later" doesn't even give you a working placeholder — it gives you a
108
+ formula that evaluates to nothing at all, which is easy to misdiagnose as an
109
+ unrelated bug in the surrounding logic.
110
+
111
+ ```text
112
+ # ❌ WRONG — literal 0 false branch; also has no dense operand to anchor a grain
113
+ "Group_Magnitude_to_Loss_CALC" [<grain>, "Position" = "<loss technical account>"] =
114
+ if(lt("Group_Result_Signed_CALC", 0), 0 - "Company_Result_Signed_CALC", 0)
115
+
116
+ # ✅ RIGHT — omit the false branch; the dense "Company_Result_Signed_CALC"
117
+ # operand anchors the grain, so this both stays sparse AND reliably
118
+ # materializes where the condition holds
119
+ "Group_Magnitude_to_Loss_CALC" [<grain>, "Position" = "<loss technical account>"] =
120
+ if(lt("Group_Result_Signed_CALC", 0), 0 - "Company_Result_Signed_CALC")
121
+ ```
122
+
123
+ Note that `0 - "Company_Result_Signed_CALC"` is a *computed* expression
124
+ (negation of a real variable), not a bare literal output — that's fine and
125
+ unaffected by this rule. The rule targets a branch whose entire output is a
126
+ standalone constant.
127
+
128
+ ## Default value and anchor — `hasValue()` does not widen the cell grid
129
+
130
+ **RULE: a formula instantiates only on coordinates contributed by references in
131
+ VALUE position.** A reference inside `hasValue()` — condition position — does
132
+ **not** contribute. Even a dense anchor at the correct grain fails to widen the
133
+ grid from inside the condition.
134
+
135
+ Consequence: the routine "default when no input" shape silently doesn't work.
136
+ The fix is an anchor **returned as a value**:
137
+
138
+ ```text
139
+ # ✗ grid = only the cells of "Sparse Input"
140
+ "Weight OUT" = if(hasValue("Sparse Input"), "Sparse Input", 1)
141
+ # ✗ still wrong — anchor sits in the condition
142
+ "Weight OUT" = if(hasValue("Sparse Input"), "Sparse Input", if(hasValue("Dense Anchor"), 1))
143
+ # ✓ anchor in value position
144
+ "Dense Anchor" = ("Input A" + "Input B") * 0 + 1
145
+ "Weight OUT" = if(hasValue("Sparse Input"), "Sparse Input", "Dense Anchor")
146
+ ```
147
+
148
+ `A + B` yields the **union** of the two grids; `* 0 + 1` normalises it to a
149
+ constant `1` — right grid, right value. (This is the "route the constant
150
+ through an input" rule above, extended: the anchor variable also carries the
151
+ grid.)
152
+
153
+ **Reframing the rule.** "Never `if(hasValue(B), B, 0)` — `A + B` is
154
+ correct" reads as if the problem were the zero. It isn't — **the problem is
155
+ OPERAND POSITION**: a reference consulted only inside `hasValue()` contributes
156
+ no coordinates, whatever the default is. Restate the rule as: **never take a
157
+ default through `hasValue()`**. With a non-zero default the error is silent
158
+ and expensive — the missing cells null a downstream product, and where the
159
+ default is coarser than an operand carrying the whole grain, it never gets a
160
+ cell of its own: it contributes its value only on that operand's cells
161
+ ([`formula-grain-alignment.md` §4](formula-grain-alignment.md), measured
162
+ 2026-10-03).
163
+
164
+ **Measured:** a boundary-month weight moved to a sparse planner input, read
165
+ through `if(hasValue(fraction), fraction, 1)`, materialised the weight on about
166
+ one cell in five; `Cost = FTE × Weight` then returned null outside the boundary
167
+ months and total cost fell to **one eighth**, no error, no warning. A dense
168
+ anchor INSIDE the `hasValue` changed nothing; moving it to value position
169
+ restored the total to the cent.
170
+
171
+ **Diagnostic: count cells per chain step, not Σ.** Print each step's cell
172
+ count and assert `count(Weight) == count(Anchor)`. A Σ-only regression check
173
+ reports "regression" with no location; the cell-count chain points at the
174
+ exact step where the grid narrowed.
175
+
176
+ **Measured 2026-10-01 — this open question is closed.** A bare comparison
177
+ **inherits its operands' density**: it emits `0` wherever they carry data and
178
+ the test is false, and creates nothing where they are empty. Over a dense
179
+ 30-cell operand `gt(X, 100)` produced **30** cells (21 of them `0`); over an
180
+ already-sparse 9-cell flag a bare `eq()` produced **9**. The 3-arg
181
+ `if(cond, 1, 0)` also produced **30 with values** — it does NOT return null,
182
+ contrary to a long-standing claim.
183
+
184
+ ## Cross-grain lifts — `0 + X` sows phantom zeros where a projection needs to stay sparse
185
+
186
+ A close relative of the "answering both branches" mistake above, specific
187
+ to the common idiom of lifting a coarser variable to a finer grain (e.g.
188
+ across an FK hop — [`formula-grain-alignment.md` §7](formula-grain-alignment.md)
189
+ rule 2) with a bare `0 + X`. On the current engine this **materialises an
190
+ explicit `0`** on every finer-grain cell where `X` has no value, rather
191
+ than staying null. The cell isn't missing data anymore — it's a stored
192
+ zero — so it inflates the cell count and, more importantly, breaks any
193
+ control shaped like "reached by both paths": a control that checks
194
+ "populated on side A AND populated on side B" reads a phantom `0` as
195
+ "reached with nothing to report", not "not reached", and passes when it
196
+ shouldn't.
197
+
198
+ **Fix — lift through `hasValue`, not through addition:**
199
+
200
+ ```text
201
+ # ❌ lifts X, but sows a 0 wherever X has no cell at the finer grain
202
+ "X lifted" [<finer grain>] = 0 + "X"
203
+
204
+ # ✅ same lift, stays sparse
205
+ "X lifted" [<finer grain>] = if(hasValue("X"), "X")
206
+ ```
207
+
208
+ **Keep `0 + X` only where an explicit zero is genuinely the intended
209
+ value** — e.g. a factor that must read `1 − 0` rather than `1 − null`
210
+ downstream. That's a different use of the idiom (deliberately anchoring a
211
+ grid, per "Default value and anchor" above) from using it as a general-
212
+ purpose lift, which is where the phantom-zero cost shows up.
213
+
214
+ ## A time-series function takes a variable NAME, never an expression
215
+
216
+ `cumsum("A" + "B" - "C")` computes **correctly** and still leaves **no cells**
217
+ on part of its grain. The balance reads empty at addresses where the inputs
218
+ plainly exist; evaluating the identical expression ad hoc at the identical
219
+ address returns the right number. Nothing errors, nothing logs. To a reviewer it
220
+ looks like "the planner hasn't entered data yet"; to the client it looks like
221
+ the model is wrong.
222
+
223
+ ```text
224
+ # ❌ loses cells at addresses where only ONE operand is populated
225
+ "Receivable" [Pair, Versions, Years, Months] = cumsum("Opening IN" + "Invoiced IN" - "Collected IN")
226
+
227
+ # ✅ compute the expression into its own variable first
228
+ "Receivable movement" [Pair, Versions, Years, Months] = "Opening IN" + "Invoiced IN" - "Collected IN"
229
+ "Receivable" [Pair, Versions, Years, Months] = cumsum("Receivable movement")
230
+ ```
231
+
232
+ **Signature of the affected addresses: exactly one of the operands populated.**
233
+ Addresses with two or more survived every time, which is why this hides — seed
234
+ and demo data usually populate several inputs per address, and the rich pairs
235
+ are the first ones a consultant checks.
236
+
237
+ **The trigger is ordinary operations, not an edge case.** `importJob.undoPrevious()`
238
+ on one input followed by a re-import — what an auto-reconciliation app does on
239
+ every run. A full `model.load` (a whole-model write) restores the missing cells, which
240
+ is why the fault looks intermittent: it vanishes the moment anyone pushes the
241
+ model and returns after the next undo-and-reload. Four other provocations failed
242
+ to reproduce it; budget more than a couple of attempts before calling a
243
+ materialisation fault unreproducible.
244
+
245
+ So when a balance
246
+ reads empty where its inputs exist, **look at the recent import jobs on its inputs
247
+ first** — an undo, a re-run, a re-import — before suspecting the formula: an
248
+ import job can change these numbers without any model change.
249
+
250
+ Two consequences worth internalising:
251
+
252
+ - **Inline evaluation cannot confirm that a stored variable works.** Pinning the
253
+ address supplies the very enumeration the stored variable was missing, so the
254
+ ad-hoc evaluation returns the right number while the stored variable holds
255
+ nothing there. Every spot-check passes. This is the same trap as the section
256
+ above, reached from a different direction.
257
+ - **The same rule applies to `delay()`**, and on the available evidence to any
258
+ function that redistributes a value across periods. For the **shift**
259
+ argument it is measured (2026-10-15 on a sandbox tenant): `delay(Base,
260
+ "Shift")` places no cell where the shift variable has none — a shift never
261
+ entered, or a `0` that an import did not store — while `delay(Base, 0 +
262
+ "Shift")` places every cell the base enumerates.
263
+ For an **expression as the first argument**
264
+ (`delay("Gross" + "Opening IN", "Shift")`) the undo-and-reload loss above
265
+ has not been reproduced — pass a named variable as a convention.
266
+
267
+ Detection: a functional test with **hand-computed expected values read through
268
+ the stored variable** catches this in seconds. A visual review of a sheet does
269
+ not, because an empty row is indistinguishable from an unplanned one. Worth one
270
+ explicit assertion per regime, on an address where only a single input is
271
+ populated — that is the case that fails first.
272
+
273
+ ## Two operands dense in DISJOINT dimensions make a dense product — and a condition cannot narrow it
274
+
275
+ Neither operand is dense on the joint grain, so neither looks dangerous
276
+ on its own; the product is dense on the cross.
277
+
278
+ ```text
279
+ "Rate eff" [Item, Versions, Years, Months] # dense over item-months
280
+ "Rate Factor" [Customer, Versions, Years] # spans every customer
281
+ # product -> every item-month x every customer
282
+ ```
283
+
284
+ On a reference build that reached hundreds of millions of cells, the full recalc died with
285
+ `InternalError`, and the tenant had to be restored from backup.
286
+
287
+ **Gating it does not help.** `if(hasValue("Qty IN"), …)` leaves the grid just as
288
+ wide — a reference inside `if()` / `hasValue()` contributes no coordinates (see
289
+ "Default value and anchor" above), so the condition only nulls an
290
+ already-widened grid. Multiply a sparse carrier in instead:
291
+
292
+ ```text
293
+ "Qty Anchor" [Item, Customer, Versions, Years, Months] = "Qty IN" * 0 + 1
294
+ "Rate head" [Item, Customer, Versions, Years, Months] = "Rate eff" * "Rate Factor" * "Qty Anchor"
295
+ ```
296
+
297
+ Same build: a few hundred thousand cells, and the full recalc finished in tens of seconds.
298
+
299
+ **Verify by counting cells per chain step** (`count(head) == count(quantity)`),
300
+ and do it first on a **pinned probe** — one member, one version, one year, a few
301
+ thousand cells at worst — so a wrong hypothesis cannot take the tenant down.
302
+
303
+ ## Validation gotcha — you cannot eyeball this inline
304
+
305
+ An inline evaluation of `sum(gt(x, 0))` computes on the **aggregate** (it returns
306
+ 1, not the per-row count), so an inline check will *not* reveal whether a presence
307
+ formula is sparse. To verify, mutate a **stored** variable at the real grain and
308
+ inspect its SUM and cell count — the inline preview lies about sparsity.
309
+
310
+ ---
311
+
312
+ ## How to spot it (review checklist)
313
+
314
+ 1. Grep formulas for a literal `, 0)` closing an `if` — most are sowing zeros.
315
+ 2. Grep for bare comparators (`gt(`, `lt(`, `eq(`) used as a whole formula rather
316
+ than wrapped in a 2-arg `if`.
317
+ 3. Look for `if(hasValue(X), X, …)` in additive contexts — the guard is usually
318
+ removable entirely.
319
+ 4. Look for `× Flag` multiplications where the flag is seeded `0` on some slices.
320
+ 5. For any high-dimensionality variable, confirm the formula returns null on the
321
+ slices that carry no data — and confirm **Constrained Light Top Down** is on (`zConstraint`).
322
+ 6. Look for `0 + X` used as a cross-grain **lift** (not as a deliberate
323
+ grid-anchor, see "Default value and anchor" above) — it sows phantom
324
+ zeros; the sparse form is `if(hasValue(X), X)`.
325
+ 7. Grep for a time-series function wrapping an **expression** rather than a
326
+ variable name — `cumsum(`, `delay(` followed by anything but a single
327
+ quoted name. Each one loses cells wherever only one operand is populated.
328
+ 8. For every product, ask whether the two operands are dense in **different**
329
+ dimensions. If so the product is dense on the cross, and no `if()` around
330
+ it will narrow that — it needs a sparse carrier.
@@ -0,0 +1,190 @@
1
+ ---
2
+ name: farseer-build-pipeline
3
+ description: >-
4
+ Use when the user asks to build, design, extend, fix or review a recurring data pipeline into a Farseer model — an ETL / integration / data feed / scheduled import from an ERP, database, file drop, SharePoint, Drive, HubSpot or SAP, or anything described in bronze / silver / gold layers. All NEW recurring imports are Simple Pipelines (folders of dataset YAML run by `farseer pipeline`), even when TypeScript is asked for. Adds recommendations on top of the CLI's own pipeline-authoring guide — ETL and load as separate pipelines, period-keyed gold, reconciliation before load, locked `IMPORT_` targets, scope labels, sandbox first. Does NOT cover maintaining an existing TypeScript import app (use `farseer-app-dev` + `farseer-author-import-job`) or one-off test seeding. Triggers (match by MEANING, in ANY language): "build a pipeline", "set up the integration", "bronze silver gold", "import from the ERP every month", "the pipeline run failed".
5
+ metadata:
6
+ version: "1"
7
+ domain: modeling
8
+ minimum-cli: "1.14.2"
9
+ engine-profile: "3.3"
10
+ ---
11
+
12
+ # Build Pipeline
13
+
14
+ ## When this skill applies
15
+
16
+ Any new recurring flow of data into a Farseer model, and any change or review
17
+ of an existing Simple Pipelines job: designing the layers, writing the YAML,
18
+ running and verifying it, promoting it from a sandbox tenant to production, or
19
+ diagnosing a failed run.
20
+
21
+ Do **not** use for:
22
+ - **An existing TypeScript import app.** Inspect, run and fix it in place with
23
+ [`farseer-app-dev`](../farseer-app-dev/SKILL.md) and [`farseer-author-import-job`](../farseer-author-import-job/SKILL.md).
24
+ A request to fix or extend it does not authorise migrating it, replacing its
25
+ source folder, entrypoint, runner image or schedule, or building a duplicate
26
+ pipeline. Migration needs an explicit request.
27
+ - Seeding a few cells in a test, or a one-off load the user asked for as one-off.
28
+
29
+ ## Inputs to gather first
30
+
31
+ 1. **CLI version.** `farseer --version` must be ≥ 1.14.2 (this skill's
32
+ `minimum-cli`). Below that, ask the user for permission, then
33
+ `npm install -g farseer-cli@latest`. Restart the MCP connection after an upgrade.
34
+ 2. **The CLI's own guide — read it, this skill does not repeat it.**
35
+ `farseer pipeline guide` (the method), `--topic practices` (house style:
36
+ layers, transforms, schemas, quality rules, loading, storage, verification),
37
+ `--topic grammar` and the grammar topics you use (`--topic LoadCellsConfig`
38
+ and so on). In an MCP session: `farseer_pipeline` with `operation=guide`.
39
+ It is versioned with the engine; when it and this skill disagree on grammar
40
+ or engine behaviour, the guide wins.
41
+ 3. **What is already on the tenant.** `farseer app list <tenant> --details`.
42
+ For a Simple Pipelines job without a local profile:
43
+ `farseer pipeline init <org> <tenant> <jobId>` (local only, changes nothing
44
+ remotely). TypeScript apps on the same tenant stay as they are.
45
+ 4. **The target.** Every variable the pipeline fills: its dimensions (Versions
46
+ and time included), its grain, what one value means, and that it is a locked
47
+ `IMPORT_` variable ([`import-job-pattern.md`](../farseer-author-import-job/import-job-pattern.md) §1).
48
+ The gold layer's columns follow from this list.
49
+ 5. **The source.** System, access route, the credential and who holds it, the
50
+ slice one run reads (normally a month), and a control total the client
51
+ trusts for at least one period.
52
+ 6. **The tenant.** Sandbox or production.
53
+ Build on a sandbox copy whenever one exists.
54
+
55
+ ## Procedure
56
+
57
+ ### 1. Lay the subject out as two pipelines
58
+
59
+ | Pipeline | Layers | Reads | Writes |
60
+ |---|---|---|---|
61
+ | `<subject>-etl` | `bronze/` → `silver/` → `gold/` | the source system | datasets only, never the model |
62
+ | `<subject>-load` | `in/` → `load/` | the ETL's published gold (`source: datasets`), read by an `in/` extract and its parse step | the model |
63
+
64
+ The ETL is the only thing that touches the client's system; the load is the
65
+ only thing with model effects. A load can then rerun after a model or mapping
66
+ fix without reading the source again, and an ETL can run and be checked
67
+ without changing a cell. One pipeline is fine for a small source read from
68
+ Files, where a rerun costs nothing.
69
+
70
+ Name every dataset after its subject (`bronze.erp_sales_invoice_lines`, not
71
+ `bronze.lines`): qualified names are shared by every pipeline on the tenant.
72
+
73
+ ### 2. Key gold by period
74
+
75
+ The load reads the **last published** version of each dataset. One
76
+ `gold.<subject>_cells` overwritten by every run would let a March load read
77
+ the February extract a colleague ran after you. Give gold one dataset per
78
+ period with `expand`, and read the same names in `in/`:
79
+
80
+ ```yaml
81
+ expand:
82
+ values_expr: "{{ cartesian_product(m=months_in_range(pipeline_args.FROM_MONTH, pipeline_args.TO_MONTH)) }}"
83
+ template:
84
+ name: "erp_sales_cells_{{ each.m | strftime('%Y_%m') }}"
85
+ ```
86
+
87
+ `months_in_range` (inclusive, accepts `YYYY-MM`), `days_in_range`,
88
+ `years_in_range`, `cartesian_product` and the `strftime`, `add_months`,
89
+ `add_days` filters are engine template helpers; the CLI guide shows `expand`
90
+ but not these. `values_expr` must return `{key, value}` pairs, which is why
91
+ the month list is wrapped in `cartesian_product`.
92
+
93
+ ### 3. Write each layer to its rule
94
+
95
+ | Layer | Recommendation |
96
+ |---|---|
97
+ | **bronze** | An extract `<name>_raw` (only `extract:`) and the parse step `<name>` that reads it; the schema and the rules below go on the parse step, never on the extract. Cast in the source query (`CAST(x AS float)`, codes as text): for SQL sources the schema only checks. Full `schema`; `not_null` on mandatory columns; `custom__unique` on the line key; `custom__distinct_count {min: 1}` where an empty window is a fault. Legacy code pages: [`pipeline-source-encoding.md`](pipeline-source-encoding.md). |
98
+ | **silver** | Normalise codes (`upper(trim())`), `LEFT JOIN` mappings kept as data (a Files table, never a `CASE`), and flag every row a mapping missed. A separate dataset lists the misses with `isin: {allowed_values: []}` on the code column: it fails and names each code. |
99
+ | **reconciliation** | Per period, one row: source lines and amount against silver. `custom__compare` on the counts, `in_range ±0.01` on the difference. List it in gold's `deps` so a failed total stops gold. |
100
+ | **gold** | One row per target cell; columns are exactly what the load maps. `custom__unique_composite` over the coordinates (the import sums duplicates), `not_null` on coordinates and values, `isin` on the period column. Send a known zero as `0`. |
101
+ | **load** | Thin. One `cells` entry per variable. Labels `[<subject>, <version>, <period>, <measure>]` — two entries with the same labels undo each other. `overwrite_cells: true` + `undo_previous: true`. Versions pinned with `fixed_dimension_members`. `create_missing_members: false` unless the client decided otherwise for that dimension; a created member is permanent. Never load into a formula variable. |
102
+
103
+ ### 4. Arguments and secrets
104
+
105
+ - `main.py` checks every argument and writes back one canonical spelling
106
+ (`2026-1` → `2026-01`) before `run_pipeline`. Arguments are pasted into the
107
+ YAML verbatim, SQL included, so validate each against a pattern.
108
+ - Both period arguments empty means a scheduled run: default to the previous
109
+ month in `main.py`, never in Jinja (`default()` ignores empty strings).
110
+ - Credentials are **secret job arguments** read as `{{ pipeline_args.NAME }}`.
111
+ Never in YAML, code, logs, commits or this conversation: ask whoever holds
112
+ the credential to type it into the job in the web app.
113
+
114
+ ### 5. Build in the order the engine can check
115
+
116
+ 1. `farseer pipeline init <org> <tenant> --new <name>` creates the folder, the
117
+ job and the profile. **It creates a job on the tenant**: say so first, and
118
+ on a production tenant wait for the user's confirmation.
119
+ 2. Extracts and their parse steps first. `push`, `run`, `inspect` until the
120
+ parse steps publish.
121
+ 3. Each SQL transform: test it with `query` against the datasets the parse steps published,
122
+ asking for shapes (`DESCRIBE`, `COUNT`, `SUM`, `GROUP BY … HAVING count(*) > 1`),
123
+ not rows. Query results go to the model provider.
124
+ 4. `check` after every edit (job, image, arguments; it does **not** validate
125
+ the YAML — the run's preflight does, before any source is read).
126
+ 5. The load last, on a sandbox tenant, one period.
127
+
128
+ ### 6. Engine version is an explicit decision
129
+
130
+ `push` refuses a job on an older runner image (`RUNTIME_UPGRADE_REQUIRED`).
131
+ `farseer pipeline upgrade-runtime <org> <tenant>` moves the job to the CLI's
132
+ image; a job on `latest` or a digest is refused and must be pinned in the web
133
+ app. The next **scheduled** run uses the new engine too, so treat it as a
134
+ change to the client's integration: ask first, and run once right after.
135
+ Pipelines written for simple-pipelines 2.x need edits before the next run:
136
+ split every extract into `<name>_raw` and a parse step, and
137
+ `PipelinePolicy("Versions", "Actual")` → `PipelinePolicy()` (the guide's
138
+ "Setup facts" has the order, `store_type` included).
139
+
140
+ ### 7. Verify every run
141
+
142
+ - `inspect` by run UUID: every step OK, `skippedOutputs` empty, each import
143
+ `commit_confirmed`, no failed undo, `engine` not `mismatch`.
144
+ - Query gold: row count, zero duplicate coordinates, totals per period against
145
+ the client's control total.
146
+ - `inspect-import` on each import ID. Never verify with a variable export.
147
+ - Rerun the same period: nothing may change.
148
+ - Report the run UUIDs and dataset versions you checked, and what you did not.
149
+
150
+ ### 8. Promote and record
151
+
152
+ - Sandbox → production: copy `files/<name>/` only, `init` on the target,
153
+ re-create secrets, check names, run one period, `init <org> <tenant> <jobId> --force`
154
+ so the profile records its datasets, schedule last and `init … --force` again
155
+ (`farseer pipeline guide` → "Moving a pipeline to another tenant").
156
+ Production loads need the user's confirmation every time.
157
+ - The source lives in `farseer-apps/<tenant>/files/<name>/`. Commit that folder;
158
+ never commit `.pipeline-runs/` (local run state). The `.pipelines/` profile
159
+ can always be re-derived with `init <org> <tenant> <jobId> --force`.
160
+ - For runs a client tester watches, a readable failure report instead of a
161
+ traceback: [`pipeline-app-failure-report-pattern.md`](pipeline-app-failure-report-pattern.md).
162
+
163
+ ## Tools to invoke
164
+
165
+ - `farseer pipeline guide | init | check | pull | push | run | runs | inspect | inspect-import | query | versions | restore | upgrade-runtime`
166
+ (or the `farseer_pipeline` MCP tool with the same operations, tenant-bound)
167
+ - `farseer app list <tenant> --details`, `farseer variable details`, `farseer dimension details` for the model side
168
+ - [`erp-sales/`](erp-sales/) — the reference pair to copy from
169
+
170
+ ## Expected output
171
+
172
+ - Two pipeline folders (`<subject>-etl`, `<subject>-load`) that pass preflight,
173
+ reconcile to the source per period, and rerun without changing the model.
174
+ - A run report: run UUIDs, published dataset versions, import IDs with
175
+ `commit_confirmed`, control totals compared, and what was not verified.
176
+ - For a review: findings against the layer rules in step 3 and the CLI guide's
177
+ anti-patterns.
178
+
179
+ ## Constraints
180
+
181
+ - Do **not** build a new recurring import as a TypeScript app or a direct
182
+ import job, even when asked; explain and build the pipeline.
183
+ - Do **not** migrate, replace or duplicate an existing TypeScript app unless
184
+ the user explicitly asks for a migration.
185
+ - Do **not** create a job, run a load or `upgrade-runtime` on a production
186
+ tenant without the user's confirmation for that action.
187
+ - Do **not** put credentials in YAML, code, commits or the conversation.
188
+ - Do **not** let a load read an unkeyed, run-overwritten dataset (step 2).
189
+ - Do **not** set `create_missing_members: true` without the user's explicit confirmation.
190
+ - Do **not** declare a pipeline done before a rerun of the same period changed nothing.
@@ -0,0 +1,108 @@
1
+ # erp-sales — a bronze → silver → gold pipeline pair
2
+
3
+ Monthly sales from an ERP SQL database into two locked import variables, built
4
+ the way [`SKILL.md`](../SKILL.md) prescribes. Copy it into your project as a starting point; every
5
+ name, code and number in it is made up.
6
+
7
+ | | |
8
+ |---|---|
9
+ | **Engine** | simple-pipelines 3.3 |
10
+ | **Source** | SQL Server tables `dbo.sales_invoice_lines` + `dbo.sales_invoice_headers` |
11
+ | **Mapping** | `Mappings/erp-sales/item_to_product.csv` in tenant Files (sample: [`item_to_product.csv`](item_to_product.csv)) |
12
+ | **Targets** | `IMPORT_Revenue`, `IMPORT_Quantity`, both `{ Product, Customer, Versions, Years, Months } @readonly` |
13
+ | **Arguments** | `FROM_MONTH`, `TO_MONTH` (`YYYY-MM`, inclusive; both empty = previous month), `ERP_DB_URL` (secret, ETL only) |
14
+
15
+ ## Two pipelines, one subject
16
+
17
+ ```
18
+ erp-sales-etl/ the only pipeline that reads the ERP
19
+ main.py checks arguments, one canonical spelling
20
+ Models/bronze/
21
+ erp_sales_invoice_lines_raw.yaml extract: the source, cast at the source, stored unread
22
+ erp_sales_invoice_lines.yaml parse: its rows, structural rules
23
+ erp_sales_item_product_map_raw.yaml extract: the mapping file from Files
24
+ erp_sales_item_product_map.yaml parse: the mapping table
25
+ Models/silver/
26
+ erp_sales_lines.yaml conformed lines, LEFT JOIN + product_mapped flag
27
+ erp_sales_unmapped_items.yaml fails, naming each code, when any item is unmapped
28
+ erp_sales_recon.yaml per month: source vs silver, lines and amount
29
+ Models/gold/
30
+ erp_sales_cells.yaml per month: one row per target cell
31
+
32
+ erp-sales-load/ never reads the ERP
33
+ main.py
34
+ Models/in/erp_sales_cells_raw.yaml per month: stores the last published gold dataset
35
+ Models/in/erp_sales_cells.yaml per month: parse step reading it
36
+ Models/load/erp_sales_to_model.yaml per month: thin mapping, labels, undo_previous
37
+ ```
38
+
39
+ **Why split.** Extracting is the slow part that touches the client's system.
40
+ The load is the part with model effects. Splitting them lets the load rerun,
41
+ after a model fix or a mapping fix, without reading the ERP again, and lets the
42
+ ETL run and be checked without changing a single cell.
43
+
44
+ **Why one gold dataset per month.** The load reads the *last published*
45
+ version of a dataset. With one `gold.erp_sales_cells` overwritten by every ETL
46
+ run, a load for March could read the February a colleague extracted after you.
47
+ Period-keyed names (`gold.erp_sales_cells_2026_03`) make the slice explicit on
48
+ both sides.
49
+
50
+ ## What stops a bad month
51
+
52
+ This example comes from the playbook at a30bd65, where it was written for
53
+ engine 2.9. On engine 3.2.1 that layout fails before any step runs:
54
+ `invalid 'extract' step: schema: not valid on an 'extract' step, which stores
55
+ what its source handed over, unread; only on a 'parse' or 'transform' step`.
56
+ Each extract is therefore split into an extract (`<name>_raw`) and the parse
57
+ step that reads it, which passes. The split layout is verified offline against
58
+ engine 3.2.1 (discovery, authoring, graph checks); not run end to end.
59
+
60
+ The checks below are from engine 2.9.1, before the split: offline against its
61
+ source (discovery, preflight, the runner's schema and quality validators)
62
+ with synthetic data:
63
+
64
+ | Fault in the data | Caught by | Message |
65
+ |---|---|---|
66
+ | Item code missing from the mapping | `silver.erp_sales_unmapped_items` | `[isin · item_code] 1 row failed (values: 'Z-9999')` |
67
+ | Duplicate key in the mapping file | bronze map `custom__unique`, then the recon | `2 duplicate rows (values: 'A-1001')`; `net_amount_difference` out of range |
68
+ | Lines lost or multiplied between source and silver | `silver.erp_sales_recon_<month>` | `custom__compare silver_lines eq source_lines` |
69
+ | Two rows for one cell | gold `custom__unique_composite` | the import would have summed them |
70
+ | Empty source window | bronze `custom__distinct_count min 1` | |
71
+ | A malformed or injected month argument | `main.py` | `FROM_MONTH must look like 2026-03` |
72
+
73
+ A failing step publishes nothing, so the load keeps reading the last good
74
+ version. A customer or product the model lacks fails the import itself
75
+ (`missing_member_policy: DISALLOW`); this example never creates members.
76
+
77
+ **Run on a sandbox tenant (2026-10-17, engine 2.9.1, runner image 1.13.0)**,
78
+ with the bronze SQL extract swapped for a CSV in Files (the sandbox has no ERP)
79
+ and the load retargeted to that model's table and variable names. Everything
80
+ else ran as written here:
81
+
82
+ | Check | Result |
83
+ |---|---|
84
+ | ETL, two months | 8 datasets published; gold and reconciliation match the offline check exactly |
85
+ | Load, two months | 4 imports `commit_confirmed`; model values equal gold, a known zero included |
86
+ | Load rerun for one month | `undo_previous` undid that month's 2 earlier imports; values unchanged, the other month untouched |
87
+ | ETL with an unmapped item code | failed at `silver.erp_sales_unmapped_items` naming `'Z-9999'`; gold never ran, nothing published |
88
+
89
+ **Still unverified:** the SQL Server extract itself (`sql_database`, the
90
+ `nvarchar` casts). Run the
91
+ [verification loop](../SKILL.md#7-verify-every-run)
92
+ on the first real source.
93
+
94
+ ## Setting it up on a tenant
95
+
96
+ 1. Create `IMPORT_Revenue` and `IMPORT_Quantity` (locked) and check that
97
+ Product, Customer and the timeline have the members the data needs.
98
+ 2. Upload the mapping to `Files/Mappings/erp-sales/item_to_product.csv`.
99
+ 3. Copy both folders into `farseer-apps/<tenant>/files/`, then for each:
100
+ `farseer pipeline init <org> <tenant> --new erp-sales-etl` (it adopts the
101
+ folder and creates the job), and the same for `erp-sales-load`.
102
+ 4. Add `ERP_DB_URL` to the ETL job as a **secret** argument, typed in the web
103
+ app by whoever holds the credential; add `FROM_MONTH` and `TO_MONTH` (empty
104
+ defaults) to both jobs.
105
+ 5. Run the ETL for one month, `inspect` it, query gold; then run the load for
106
+ the same month and `inspect-import` each import. Schedule both only after
107
+ a rerun of the same month changes nothing, the load after the ETL's run:
108
+ each job runs on its own schedule, and nothing makes one wait for the other.
@@ -0,0 +1,23 @@
1
+ # Bronze: the ERP's invoice lines, read from the extract erp_sales_invoice_lines_raw.
2
+ # A SQL source hands back rows, so the format is parquet and the schema only
3
+ # checks types: the casts are in the extract's query.
4
+ name: erp_sales_invoice_lines
5
+ type: parse
6
+ deps: [bronze.erp_sales_invoice_lines_raw]
7
+ parse:
8
+ format: parquet
9
+ schema:
10
+ columns:
11
+ - name: line_id
12
+ type: str
13
+ not_null: true
14
+ quality_rules:
15
+ - type: custom__unique
16
+ # An empty window is a fault here, not a quiet month.
17
+ - type: custom__distinct_count
18
+ params: { min: 1 }
19
+ - { name: invoice_date, type: datetime, not_null: true }
20
+ - { name: item_code, type: str, not_null: true }
21
+ - { name: customer_code, type: str, not_null: true }
22
+ - { name: net_amount, type: float, not_null: true }
23
+ - { name: quantity, type: float }