farseer-cli 1.21.0 → 1.23.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 (48) hide show
  1. package/README.md +3 -1
  2. package/dist/commands/code.js +23 -0
  3. package/dist/commands/code.js.map +2 -2
  4. package/dist/commands/skills.js +110 -7
  5. package/dist/commands/skills.js.map +1 -1
  6. package/dist/index.js +5 -1
  7. package/dist/index.js.map +1 -1
  8. package/dist/mcp/tools/dashboardTools.js +1 -1
  9. package/dist/pipeline/create.js +1 -1
  10. package/dist/pipeline/generated-reference.json +6 -6
  11. package/dist/services/codefirst/workflow.js +3 -3
  12. package/dist/services/codefirst/workflow.js.map +1 -1
  13. package/dist/services/farseerService.js +10 -1
  14. package/dist/services/farseerService.js.map +1 -1
  15. package/dist/services/httpError.js +2 -1
  16. package/dist/services/httpError.js.map +1 -1
  17. package/dist/skills/install.js +221 -8
  18. package/dist/skills/install.js.map +2 -2
  19. package/dist/skills/userSkills.js +206 -0
  20. package/dist/skills/userSkills.js.map +6 -0
  21. package/dist/skills/workspaceSkills.js +213 -0
  22. package/dist/skills/workspaceSkills.js.map +6 -0
  23. package/docs/cli-guide.md +6 -1
  24. package/docs/pipeline-reference.md +1 -1
  25. package/package.json +1 -1
  26. package/skills/farseer-app-dev/SKILL.md +2 -2
  27. package/skills/farseer-app-dev/assignments.md +1 -1
  28. package/skills/farseer-app-dev/farseer-client-release-notes.md +13 -1
  29. package/skills/farseer-app-dev/working-patterns.md +30 -5
  30. package/skills/farseer-author-import-job/SKILL.md +20 -3
  31. package/skills/farseer-author-import-job/cell-writes.md +26 -6
  32. package/skills/farseer-author-import-job/deploying-a-farseer-app.md +117 -12
  33. package/skills/farseer-author-import-job/import-job-pattern.md +111 -13
  34. package/skills/farseer-build-model/SKILL.md +3 -2
  35. package/skills/farseer-build-model/formula-grain-alignment.md +186 -31
  36. package/skills/farseer-build-model/naming-conventions.md +5 -2
  37. package/skills/farseer-build-model/sparse-formulas-pattern.md +30 -11
  38. package/skills/farseer-build-pipeline/SKILL.md +36 -1
  39. package/skills/farseer-build-pipeline/erp-sales/README.md +8 -0
  40. package/skills/farseer-build-pipeline/erp-sales/erp-sales-etl/main.py +1 -1
  41. package/skills/farseer-build-pipeline/erp-sales/erp-sales-load/main.py +1 -1
  42. package/skills/farseer-build-pipeline/pipeline-app-failure-report-pattern.md +9 -6
  43. package/skills/farseer-data-permissions/SKILL.md +85 -0
  44. package/skills/farseer-modify-model/SKILL.md +3 -2
  45. package/skills/farseer-modify-model/model-validation-pattern.md +11 -3
  46. package/skills/farseer-review-model/SKILL.md +39 -8
  47. package/skills/pipeline-authoring/SKILL.md +3 -3
  48. package/skills/pipeline-authoring/practices.md +5 -3
@@ -135,9 +135,10 @@ declares a dim no operand carries. The mirror case is OPERAND-side:
135
135
  operands carry **different grains from each other**, and the formula
136
136
  combines them with `if(...)`, `+`, `*`, or `sum(A, B)`.
137
137
 
138
- Symptom is the same — wrong values, sometimes-null cells, slow execution
139
- — because the calculator's optimisation cannot reliably align operands
140
- across different grains.
138
+ Symptom is the same — wrong values, sometimes-null cells, slow execution.
139
+ The null cells come from Optimize calculation: with it on, only operands at
140
+ the consumer's full grain place cells. On v7 it is off on every formula
141
+ variable ([the v7 rule](#optimize-calculation-v7)).
141
142
 
142
143
  Common shapes:
143
144
 
@@ -145,7 +146,7 @@ Common shapes:
145
146
  # WRONG — three different grains in one if expression
146
147
  "PL_Plan_OUT" [PL_Analytics, CostCenter, Versions, Years, Months] =
147
148
  if(eq("FC_ONE_PASS_BY_INPUT", 1), # grain: [Versions, Years, Months]
148
- "PL_Actual_upstream", # grain: [PL_Analytics, CC, Versions, Y, M]
149
+ "PL_Actual_upstream", # grain: [PL_Analytics, CC, Y, M] — version-less
149
150
  sum("PL_Plan_IN")) # grain: [Account, CC, Versions, Y, M]
150
151
  ```
151
152
 
@@ -161,7 +162,7 @@ dimensionality.
161
162
 
162
163
  "PL_Plan_OUT" [PL_Analytics, CostCenter, Versions, Years, Months] =
163
164
  if(eq("FC_ONE_PASS_BY_INPUT", 1),
164
- "PL_Actual_upstream", # broadcasts Versions; matches OUT grain ✓
165
+ "PL_Actual_upstream", # version-less: broadcasts into every version ✓
165
166
  "PL_Plan_IN_at_PL_Analytics") # same grain as OUT ✓
166
167
  ```
167
168
 
@@ -172,12 +173,10 @@ chain is self-documenting at the call site.
172
173
 
173
174
  **Properties on projections (the rule, stated once).** A projection
174
175
  intermediate always carries `readonly` — it is derived, never
175
- planner-editable. Turn Optimize calculation off (`optimizeCalculation: false`) **only when the
176
- projection's source is import-fed** and the derived value must refresh
177
- after a data load (the cross-grain-addition case below); a projection over
178
- purely calculated sources does not need it. This is different from
179
- disabling Optimize calculation on the **consumer**, which remains the
180
- discouraged anti-fix below.
176
+ planner-editable — and, like every formula variable,
177
+ Optimize calculation off (`optimizeCalculation: false`; [the v7 rule](#optimize-calculation-v7)). That
178
+ flag decides which cells exist, not whether they refresh: an import
179
+ recalculates its dependants with the flag on or off.
181
180
 
182
181
  **Constraint on projection.** It only works when the source and target
183
182
  dimensions are linked by FK relationships — the engine traverses the FK
@@ -196,23 +195,102 @@ new FK column on the dim before attempting the projection.
196
195
  fine when there's a single operand (engine auto-rolls), risky when
197
196
  combined with other operands of yet-different grain.
198
197
 
199
- **Anti-fix that's discouraged:** disabling "Optimize calculation" on the
200
- consumer — UI "Optimize calculation",
201
- API `variable.optimizeCalculation` (default `true`). This forces fresh
202
- per-cell calculation, sidestepping the optimiser's grain assumptions. It
203
- hides the real issue and makes the model harder to read; only use when an
204
- intermediate-var refactor is genuinely impossible.
198
+ **Optimize calculation.** On v7 every formula variable has
199
+ Optimize calculation off ([the v7 rule](#optimize-calculation-v7)). With
200
+ the flag off a mixed-grain formula places cells from every operand, so the
201
+ projections above are no longer needed for the cells to exist; keep them
202
+ where they make the formula easier to read or the heavy part cheaper (the
203
+ named application below). On a delivered variable that still has the flag
204
+ on, they remain the fix.
205
205
 
206
206
  Calculate on demand (`calculateOnDemand`) is a **different** switch and is
207
- **not** a fallback here: it stops the variable from being computed at all until
207
+ **not** a substitute for either: it stops the variable from being computed at all until
208
208
  a dedicated API call demands it, so it and every stored formula reading it go
209
209
  null. Turn it on only when the user explicitly asks for it, variable by
210
210
  variable.
211
211
 
212
- The "match dimensionality" rule is HARD: same-grain operands or no
213
- combination at all. If a formula CAN be wrong on grain alignment, it
214
- WILL be wrong eventually — don't rely on the calculator picking the
215
- right axis.
212
+ With Optimize calculation on, the "match dimensionality" rule is HARD:
213
+ same-grain operands or no combination at all. If a formula CAN be wrong on
214
+ grain alignment, it WILL be wrong eventually — don't rely on the calculator
215
+ picking the right axis.
216
+
217
+ <a id="optimize-calculation-v7"></a>
218
+
219
+ ### The v7 rule — Optimize calculation off on every formula variable
220
+
221
+ **Every variable with a formula has Optimize calculation off** (UI:
222
+ *Optimize calculation* unticked; API `variable.optimizeCalculation: false`) —
223
+ calculated OUTs and internal variables, and an IN with a seed formula. All
224
+ Farseer tenants run v7 since 2026-11, and on v7 Optimize calculation is not
225
+ used: which cells it keeps cannot be predicted from the formula. On an input
226
+ without a formula the flag has no effect. Confirmed by Farseer's system
227
+ engineering on 2026-11-16: Optimize calculation is always false. New
228
+ models carry it from the first write. `farseer variables create` creates a
229
+ variable with it on, the platform default, and neither `create` nor `update`
230
+ has an option for it: switch it off in the UI, or through the API (read the
231
+ variable with `GET /entities/{id}/VAR`, set `variable.optimizeCalculation` to
232
+ `false`, remove `variable.referencedBy`, which is read-only and answered with
233
+ 400 `is read-only` when sent (the SDK's `entities.mutate` leaves it out), and
234
+ send the rest back through `POST /entities/mutate` as
235
+ `{"updated": [...]}`), and check
236
+ it in `farseer model --json` (`"optimizeCalculation": false`). Switch in
237
+ batches, never the whole model in one update, and check the tenant still
238
+ answers after each batch: one bulk toggle stopped a development tenant until
239
+ support undid it. A delivered model switches a variable when a change
240
+ touches it (`farseer-modify-model`).
241
+
242
+ **Why** (measured 2026-11-10 on a sandbox tenant, the same formula with the
243
+ flag on, then off):
244
+
245
+ | Formula | Flag on | Flag off |
246
+ |---|---|---|
247
+ | `if(<cond>, sum("Src", "Versions" > "Actual"), "Drv" * 2)` | 4 of 17 cells, only where `Drv` has data — actuals lost even in the Actual version | all 17, same values |
248
+ | `if(hasValue(<override>), <override>, "FC ONE ALWAYS")` | the Actual version has no cell outside the override months | Actual reads 1 in every month (60 of 60), plus the override cells |
249
+ | `if(hasDMember("Versions" > "Actual"), "Src", "Coarse")`, `Coarse [Item, Years]` | every non-Actual version empty | the coarse branch fills the months of every non-Actual version |
250
+
251
+ **What the flag does** (Farseer engine source; it is the flag's only use).
252
+ Either way an operand inside an `if()` condition places no cells unless it
253
+ is the formula's only operand. Off: every other operand places cells (a
254
+ union), and one that lacks a grain dimension places them on every member of
255
+ it. On: only operands that carry the variable's whole grain directly — as
256
+ their own dimension or a grain pin — place cells, and a member filter inside
257
+ `sum()` on a grain dimension disqualifies an operand; only when no operand
258
+ qualifies do they all place cells, as with the flag off. A cell still needs an
259
+ operand with data, and the value decides the rest (`x * null` stays empty, `null + x` is `x`).
260
+ Refresh is the same either way.
261
+
262
+ **A coarse summand fills the grain; a coarse factor does not.** Measured
263
+ 2026-11-10 on a sandbox tenant (v7). A product with a coarser operand is safe
264
+ with the flag off: `"Qty" * "Rate"`, `Rate [Years]`, at
265
+ `[Customer, Item, Versions, Years, Months]` with 400 customers, 400 items
266
+ and 5 versions (9.6 million combinations a year) stored the same 100 cells
267
+ with the flag off as on (`x * null` stays empty); a one-cell write to `Rate`
268
+ returned in 103–211 ms with the flag off against 89–227 ms on, and creating
269
+ the variable took 264 against 268 ms. The engine-source prediction that the
270
+ coarse operand is evaluated on every member of the dimensions it lacks did
271
+ not show on v7. What the flag off does change is a coarser operand in a
272
+ **sum**, or alone in an `if()` branch: it places a cell on every member of
273
+ the dimensions it lacks, because `null + x` is `x`. `"Src" + "Rate"`
274
+ (`Rate [Years]`) stored 720 cells with the flag off against 4 with it on —
275
+ the rate on every item × version × month. The arithmetic is right, but it
276
+ creates cells (the class of
277
+ [§7 "Dense cell production"](#7--avoid-it-at-the-start-design-time-performance-rules))
278
+ and, on a delivered model, changes numbers: `Sales + Adjustment [Years]`
279
+ puts the adjustment on every item. Where filling the grain is not the
280
+ intent, gate the coarse term on the detail operand —
281
+ `if(hasValue("Src"), "Src" + "Rate")`: the condition places no cells, and
282
+ where `Src` has no value the `if` has no else-branch and stays empty.
283
+ Measured the same day with the flag off: 4 cells, `Src + Rate` each, the same
284
+ cells as the ungated sum with the flag on. On a
285
+ delivered model, comparing its cells per version before and after the switch
286
+ is what catches it: count a variable with a coarse summand before switching
287
+ it.
288
+
289
+ **Workarounds written for the flag on** — projecting each source to the full
290
+ grain, the ACT/PLAN split, lifting a coarse fallback to the consumer grain, a
291
+ helper that holds a cross-version reference — are required only while a
292
+ variable still has the flag on. With it off they are optional: keep them
293
+ where they make a formula clearer or cheaper.
216
294
 
217
295
  ### Named anti-pattern — `sum(A * Flag)` across grains aggregates-then-multiplies, not element-wise
218
296
 
@@ -312,11 +390,19 @@ Two findings from the same probe:
312
390
  [`sparse-formulas-pattern.md`](sparse-formulas-pattern.md), "A bare literal
313
391
  with no dense operand to anchor a grain returns null").
314
392
 
315
- ### Cross-grain addition — which operands place the cells (× inflates; + places cells only from full-grain operands)
393
+ ### Cross-grain addition — which operands place the cells (× inflates; with the flag on, + places cells only from full-grain operands)
316
394
 
317
395
  The multiplication case above produces a **silently inflated** number. Addition across grains
318
396
  fails differently, and the failure is about **which cells exist**, not about the arithmetic.
319
- What decides is which operands place cells:
397
+ What decides is which operands place cells.
398
+
399
+ **Rules 1–3, the measured shapes, the diagnostic and the coarse-branch allocation below hold for
400
+ a variable with Optimize calculation on** — the platform default these measurements ran with,
401
+ and what a delivered model not yet switched still has. With the flag off
402
+ ([the v7 rule](#optimize-calculation-v7)) every operand outside an `if()` condition places cells,
403
+ an operand that lacks a dimension on every member of it (rule 3 for all operands), so a
404
+ lower-grain term fills its own coordinates and the projections below are optional. Rule 4 holds
405
+ either way.
320
406
 
321
407
  1. Cells come only from operands that carry the consumer's **whole grain directly** — every
322
408
  grain dimension as their own dimension or a pin. An operand that reaches a dimension by
@@ -341,14 +427,15 @@ named intermediate, so that it places its own cells:
341
427
  ```text
342
428
  "<Source>_at_<consumer grain>" [<consumer grain>] = "<Source>"
343
429
  readonly
344
- optimizeCalculation: false # source is import-fed — see the properties rule above
345
430
  ```
346
431
 
347
432
  The properties follow the "Properties on projections" rule stated with the naming
348
- convention above: `readonly` always; `optimizeCalculation: false` because this
349
- case's source is **import-fed** and the projection must refresh after a data load. It
350
- sits on the **projection**, not the consumer — the discouraged anti-fix of disabling
351
- Optimize calculation on the consumer stands.
433
+ convention above: `readonly` and Optimize calculation off. An import-fed source
434
+ changes nothing about either — the projection is current after a data load with the flag on
435
+ or off.
436
+ On a consumer that already has the flag off the projection is optional; switching the consumer
437
+ off is the other fix, on a delivered model through a change of its own
438
+ (`farseer-modify-model`).
352
439
 
353
440
  **Scoping the sparse rule.** The rule "bare `A + B` treats null as 0 — never wrap in
354
441
  `if(hasValue(B), B, 0)`" holds for the
@@ -368,6 +455,41 @@ cells, the suspect operand carries the full grain and has no cells at the missin
368
455
  (rule 2). That tells you whose source to check — including whether the import job that feeds it
369
456
  has run for those coordinates, since an import can change which cells exist.
370
457
 
458
+ <a id="coarse-branch-allocation"></a>
459
+
460
+ **With the flag on, a coarse branch next to a full-grain operand places no cells of its own.** In
461
+ `if(<cond>, "Shape" / "Shape total", "Key")` the then-branch computes only where `Key` has
462
+ cells (rule 2), for an IN and a calculated variable alike, and an inline `Base / Base` changes
463
+ nothing. With the flag off the coarse branch places its own cells (measured 2026-11-10 for a
464
+ coarse `if()` branch, [the v7 rule](#optimize-calculation-v7)) and the split below is optional.
465
+ On a variable that still has the flag on, split each allocation into its own variable and give
466
+ the coarse one an operand that carries the line grain:
467
+
468
+ ```text
469
+ "Base by month" [<full grain>] = if(<cond>, "Base") # no full-grain operand: rule 3 spreads Base over the months
470
+ "Alloc B" [<full grain>] = "Shape" / "Shape total" * "Base by month"
471
+ "Alloc A" [<full grain>] = "Base" * "Key"
472
+ "Allocated" [<full grain>] = "Alloc A" + "Alloc B"
473
+ ```
474
+
475
+ Avoid `"Base" * "Shape" / "Shape total"` with no full-grain operand: `null / x` writes `0` on
476
+ every line without a base, while `x * null` stays empty, so operand order changes the cell
477
+ count (measured 2026-11-09 on a sandbox tenant). `*` and `/` group from the left, so the operand
478
+ that can be null goes last, as in "Alloc B". Control: `"<Alloc>" - "Base"` at Base's grain
479
+ must be 0 for every line with a base.
480
+
481
+ **Never filter a composite by a member of a dimension only some of its parts carry.** A
482
+ composite — a sum of parts on different grains — does not pass such a filter to the part
483
+ without the dimension; sum the part that has it. Measured 2026-11-09 on a sandbox tenant with
484
+ stored variables, parts `A [E, K]` = 10 (k1), 20 (k2) and `B [E]` = 100:
485
+
486
+ | Read | Result |
487
+ |---|---|
488
+ | composite at `[E]`, filtered to `K > k1` | **130** — the filter is ignored |
489
+ | composite at `[E, K]`, filtered to `K > k1` | **110** — B leaks in whole |
490
+ | composite at `[E, K]`, unfiltered total | **230** — B counted once per member of K |
491
+ | `sum(A, K > k1)` | 10 — the part that has the dimension |
492
+
371
493
  ---
372
494
 
373
495
  ## §5 — Grain pins — operand broadcast and the "pin doesn't scope an inner `sum()`" trap
@@ -489,6 +611,18 @@ adding a null term changes nothing. The one tell in `formula eval`:
489
611
  pins versions (`sum(V, Versions > FC) / sum(V, Versions > Plan)`) also
490
612
  reads null when read with a version pin.
491
613
 
614
+ <a id="rollup-formula-no-time-functions"></a>
615
+
616
+ **A variable with rollup FORMULA (and a measure) cannot use date or timeline
617
+ functions (`cumsum`, `delay`, …).** The platform refuses such a formula on a
618
+ real load (a dry run passes it; measured 2026-11-09); an existing variable
619
+ switched to rollup FORMULA reads blank everywhere. Put the time function in a
620
+ helper with rollup LAST, never SUM (a SUM month counter reads 78 for a year,
621
+ not 12), and reference the helper; the helper's year value on LAST is null
622
+ while `M12` is empty. A rollup FORMULA ratio also needs every operand to carry, or
623
+ reach by FK, each dimension the sheet rows pin; otherwise its denominator is
624
+ the whole total.
625
+
492
626
  ---
493
627
 
494
628
  ## §6 — When the orphan is intentional
@@ -508,6 +642,18 @@ The distinguishing question: **"is the same value supposed to land in
508
642
  every member of the orphan dim?"** If yes — broadcast is intentional,
509
643
  leave it. If no — it's the antipattern, fix the grain.
510
644
 
645
+ **A date or attribute that is a one-off fact of an entity carries no time
646
+ dimension; a recurring event does (2026-11-09).** Contract start/end, asset
647
+ activation, loan maturity, lease start/end, acquisition date: the entity's
648
+ grain only, broadcast to the time grain by the formulas that read it. A copy
649
+ per year can disagree (field case: dozens of positions with two different start
650
+ dates) and a missing year silently zeroes that year's plan (hundreds of positions
651
+ without a next-year date, so no cost and no error). A recurring event (a
652
+ second leave episode in a year, a raise month, a yearly window) keeps
653
+ `Years`. Ask the same of any attribute: does its value really change
654
+ by year? Before re-graining, check that the stored values do not differ by
655
+ year; if they do, the owner decides.
656
+
511
657
  **The reverse direction never works: an output that omits a dimension
512
658
  cannot SELECT one member of it.** Broadcast (writing the same value into
513
659
  every member of an absent dimension) is legitimate; selection (reading one
@@ -576,7 +722,12 @@ cross product spread over a detail grain × `Versions` × periods, or a `0 + x`
576
722
  problem at tens of millions of cells as at hundreds of millions — calculation
577
723
  time, storage and memory grow with every cell, and a large enough one can
578
724
  make the instance unusable for everyone on it. Do not rely on the platform to
579
- stop it: today it does not warn loudly — symptoms range from a very slow
725
+ stop it. It refuses only the extremes: a variable that would add more than 100 million
726
+ rows fails with `Variable exceeded maximum size of 100000000 added rows`, and one
727
+ whose formula would generate more than 500 million rows with `Variable exceeded maximum size of
728
+ 500000000 generated rows` (field report 2026-10-26: a coarse flag multiplied
729
+ into a full-grain expression; gate with `if(hasValue(flag), …)` instead).
730
+ Symptoms range from a very slow
580
731
  recalculation to a variable that silently reads null downstream. (A large
581
732
  grain on its own is not the problem: a variable whose member-count product
582
733
  was in the hundreds of millions but which held one cell computed normally —
@@ -588,7 +739,11 @@ need; let operands roll coarser dimensions away before a product; return
588
739
  null, not `0`, on slices without data; place cells with sparse carriers, not
589
740
  with broadcasts over a full grain; split a broadcast and an FK hop into
590
741
  stored steps; and estimate the cells a new formula will produce (operand
591
- cells × the members it broadcasts over) before pushing it.
742
+ cells × the members it broadcasts over) before pushing it. With Optimize
743
+ calculation off ([the v7 rule](#optimize-calculation-v7)) that estimate covers
744
+ **every** operand of a sum, not only the full-grain ones: a coarse summand
745
+ fills the grain, while a sparse carrier still narrows a product (`x * null`
746
+ stays empty).
592
747
 
593
748
  ---
594
749
 
@@ -325,13 +325,16 @@ Helpers and aggregators that *consume* an `IMPORT_` variable to feed downstream
325
325
  ```text
326
326
  # Same calculation, name doesn't pretend it's an ETL target.
327
327
  "GL_Actual_total_upstream" [GL_Analytics, ...] = sum("IMPORT_GL_Balances")
328
- folder: Import/upstream
328
+ folder: Scaffold/Import/Upstream/BS
329
+ optimizeCalculation: false
329
330
  ```
330
331
 
331
332
  ### `_upstream` vs `_collector` — direction of data flow decides folder
332
333
 
333
334
  Two related but distinct suffixes for "shaping data before/after the main calculation". The distinction is **direction of flow** — am I sending data downstream, or receiving it from upstream? Pick the right one and the folder choice follows automatically.
334
335
 
336
+ **The point of view of `_upstream` is the consumer's.** The feeder sits upstream of the OUT that reads it — in its own words, "I send data downstream to consumers". The suffix names that role in the flow, not the version axis: a feeder without `Versions` in its grain is called **version-less** in prose (every Actual-side feeder of a forecast-gated OUT must be version-less). Keep `_upstream`: a name such as "… all versions" says something else, because in dashboards "all versions" is a sum across versions.
337
+
335
338
  | Suffix | Semantic | Folder |
336
339
  | --- | --- | --- |
337
340
  | `_upstream` | "I send data downstream to consumers." A passthrough or simple aggregator that **feeds** an OUT or another consumer. | `Scaffold/Import/Upstream/[<Statement>/]` — under the Import tree because upstream feeders are part of the import-side data flow, not business logic. Statement-specific feeders sit under a `<Statement>/` subfolder (e.g. `Import/Upstream/PL/`, `Import/Upstream/BS/`). |
@@ -367,7 +370,7 @@ one breaks a planner's sheet.
367
370
 
368
371
  ## Word-separator style — pick one per project, never mix
369
372
 
370
- There are **two valid ways** to write multi-word identifiers in Farseer. Both are valid names, but they form two different conventions. The core convention: **a project commits to one style for the whole model and never mixes them.**
373
+ There are **two valid ways** to write multi-word identifiers in Farseer. They are two valid, **different** names — `BS_Analytics` and `"BS Analytics"` are two different dims on the platform (nothing turns `_` into a space; the CLI's name lookup ignores only case and surrounding spaces) — and they form two different conventions. The core convention: **a project commits to one style for the whole model and never mixes them.**
371
374
 
372
375
  ### Style A — spaces, quoted
373
376
 
@@ -24,6 +24,7 @@ Examples write a variable as `"Name" [Table, …] = formula`: its name, its tabl
24
24
  | Stored? | No — sparse, costs nothing | Yes — materialized, costs a cell |
25
25
  | In a SUM rollup | Treated as 0 (ignored) | Treated as 0 (counted as a populated cell) |
26
26
  | In a `× multiply` | `value × null = null` (stays sparse) | `value × 0 = 0` (sows a 0) |
27
+ | As the numerator of a `÷` | `null / x = 0` — **a materialised cell**, unlike `x × null = null`; operand order changes the cell count (measured 2026-11-09, [`formula-grain-alignment.md` §4](formula-grain-alignment.md#coarse-branch-allocation)) | `0 / x = 0` |
27
28
  | Meaning | "no data here" | "the value here is exactly zero" |
28
29
 
29
30
  The arithmetic result of a SUM is identical either way — which is exactly why the
@@ -155,11 +156,14 @@ correct" reads as if the problem were the zero. It isn't — **the problem is
155
156
  OPERAND POSITION**: a reference consulted only inside `hasValue()` contributes
156
157
  no coordinates, whatever the default is. Restate the rule as: **never take a
157
158
  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
159
+ and expensive — the missing cells null a downstream product, and, with
160
+ Optimize calculation on, where the default is coarser than an operand carrying
161
+ the whole grain, it never gets a cell of its own: it contributes its value
162
+ only on that operand's cells
161
163
  ([`formula-grain-alignment.md` §4](formula-grain-alignment.md), measured
162
- 2026-10-03).
164
+ 2026-10-03). The condition-position rule holds with the flag on or off; the
165
+ coarse-default part does not apply with it off
166
+ ([the v7 rule](formula-grain-alignment.md#optimize-calculation-v7)).
163
167
 
164
168
  **Measured:** a boundary-month weight moved to a sparse planner input, read
165
169
  through `if(hasValue(fraction), fraction, 1)`, materialised the weight on about
@@ -215,8 +219,10 @@ purpose lift, which is where the phantom-zero cost shows up.
215
219
 
216
220
  `cumsum("A" + "B" - "C")` computes **correctly** and still leaves **no cells**
217
221
  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
222
+ plainly exist. You can't cross-check it ad hoc either: the evaluator refuses
223
+ `cumsum(…)` and `delay(…)` (HTTP 400 with code `Unknown` and the function's name as the message, measured 2026-11-09),
224
+ so compare against a stored scratch variable that takes the name form. Nothing
225
+ errors, nothing logs. To a reviewer it
220
226
  looks like "the planner hasn't entered data yet"; to the client it looks like
221
227
  the model is wrong.
222
228
 
@@ -249,11 +255,10 @@ import job can change these numbers without any model change.
249
255
 
250
256
  Two consequences worth internalising:
251
257
 
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.
258
+ - **Inline evaluation cannot confirm that a stored variable works.** For a
259
+ time-series function it can't run at all: the evaluator refuses `cumsum` and
260
+ `delay` (see above). Check the stored variable's own cells, with a
261
+ scoped `farseer variable export` or a scratch variable on a dev or test copy.
257
262
  - **The same rule applies to `delay()`**, and on the available evidence to any
258
263
  function that redistributes a value across periods. For the **shift**
259
264
  argument it is measured (2026-10-15 on a sandbox tenant): `delay(Base,
@@ -300,6 +305,20 @@ Same build: a few hundred thousand cells, and the full recalc finished in tens o
300
305
  and do it first on a **pinned probe** — one member, one version, one year, a few
301
306
  thousand cells at worst — so a wrong hypothesis cannot take the tenant down.
302
307
 
308
+ ⚠ **With Optimize calculation off the carrier still narrows the product — a
309
+ summand without it does not.** Measured 2026-11-10 on a sandbox tenant (v7): a
310
+ product with a coarse factor stored the full-grain factor's cells with the flag
311
+ off as with it on (`x * null` stays empty), in the same time — the engine-source
312
+ prediction that `Rate eff` and `Rate Factor` would land on the whole cross did
313
+ not show. What the flag off widens is a coarse **summand**: a term added
314
+ without the carrier, `… * "Qty Anchor" + "Surcharge"` with
315
+ `Surcharge [Customer, Years]`, puts the surcharge on every item-month
316
+ (`null + x` is `x`). Keep every term of a head on the carrier, and count a head
317
+ with a coarse summand on the pinned probe before it is pushed with the flag off
318
+ — the v7 rule,
319
+ [`formula-grain-alignment.md`](formula-grain-alignment.md#optimize-calculation-v7),
320
+ "A coarse summand fills the grain".
321
+
303
322
  ## Validation gotcha — you cannot eyeball this inline
304
323
 
305
324
  An inline evaluation of `sum(gt(x, 0))` computes on the **aggregate** (it returns
@@ -3,7 +3,7 @@ name: farseer-build-pipeline
3
3
  description: >-
4
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
5
  metadata:
6
- version: "1"
6
+ version: "2"
7
7
  domain: modeling
8
8
  minimum-cli: "1.14.2"
9
9
  engine-profile: "3.3"
@@ -100,6 +100,41 @@ the month list is wrapped in `cartesian_product`.
100
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
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
102
 
103
+ ### 3a. Rule tables the users maintain — on dimension tables
104
+
105
+ A rule table (a flag per member, a sign, a number of days, an exception with
106
+ validity dates) can live on dimension tables: TEXT / NUMBER / DATE attribute
107
+ columns plus FK connections to small value tables (a dropdown in the sheet). A
108
+ Simple Pipelines dimension load creates the columns and fills them (so does
109
+ `POST /entities/mutate`, as the `farseer-model` skill shows), and the
110
+ pipeline reads them back with a `source: dimensions` extract.
111
+ Take the grammar from the CLI guide (`farseer pipeline guide --topic DimensionTablesConfig`,
112
+ `--topic FarseerDimensionsExtractConfig`), not from a YAML written for engine
113
+ 3.0: the current CLI splits every extract into `<name>_raw` and a `type: parse`
114
+ step.
115
+
116
+ - **An FK cannot be empty on load** (`Connection column '…' contains N empty
117
+ value(s)`): map "no value" to one sentinel member per value table, named the
118
+ same way in every table (such as `NULL (<Table>)`), never an ad-hoc
119
+ "(empty)" member.
120
+ - **Add only new members, keep user edits:** anti-join the source list against
121
+ the extract and load the difference with `delete_missing: false`.
122
+ - **`delete_missing` applies to every table in that load step:** a table
123
+ replaced on every run (a warnings list) gets a step of its own.
124
+
125
+ ### 3b. Periods on a financial year that does not start in January
126
+
127
+ Simple Pipelines always send `ignore_financial_year_offset=True` (the
128
+ loader, `farseer_simple_pipelines/load/farseer.py`), so a pipeline writes
129
+ every period **as named**. Read the tenant's starting month S (`GET
130
+ /settings` → `financial_year_starting_month`). With S ≠ 1, a source with
131
+ calendar dates is converted to fiscal periods in the pipeline, in silver,
132
+ before gold: fiscal month = calendar month − (S − 1), plus 12 and the year
133
+ minus one when that is 0 or less — for a month date, the date moved back
134
+ S − 1 months. Rows that already carry the tenant's own periods need nothing.
135
+ Platform fact and a probe:
136
+ [`import-job-pattern.md` §6](../farseer-author-import-job/import-job-pattern.md#6-financial-year-an-import-job-maps-calendar-periods-to-fiscal-ones).
137
+
103
138
  ### 4. Arguments and secrets
104
139
 
105
140
  - `main.py` checks every argument and writes back one canonical spelling
@@ -12,6 +12,14 @@ name, code and number in it is made up.
12
12
  | **Targets** | `IMPORT_Revenue`, `IMPORT_Quantity`, both `{ Product, Customer, Versions, Years, Months } @readonly` |
13
13
  | **Arguments** | `FROM_MONTH`, `TO_MONTH` (`YYYY-MM`, inclusive; both empty = previous month), `ERP_DB_URL` (secret, ETL only) |
14
14
 
15
+ **Financial year.** The ETL maps calendar invoice dates to a month
16
+ (`date_trunc('month', invoice_date)` in silver), and Simple Pipelines write
17
+ every period as named (`ignore_financial_year_offset=True`). That is right on
18
+ a tenant whose financial year starts in January. On any other tenant,
19
+ convert first: move the month back by S − 1 months in silver, before gold,
20
+ where S is the tenant's starting month
21
+ ([`import-job-pattern.md` §6](../../farseer-author-import-job/import-job-pattern.md#6-financial-year-an-import-job-maps-calendar-periods-to-fiscal-ones)).
22
+
15
23
  ## Two pipelines, one subject
16
24
 
17
25
  ```
@@ -46,4 +46,4 @@ if not (args.get("ERP_DB_URL") or "").strip():
46
46
  sys.exit("ERP_DB_URL is not set: add it to the job as a secret argument")
47
47
  os.environ["FARSEER_ARGS"] = json.dumps(args)
48
48
 
49
- run_pipeline(store_type=StoreType.DATASETS, pipeline_policy=PipelinePolicy(), experimental__emit_pipeline_visualization_markers=True)
49
+ run_pipeline(store_type=StoreType.DATASETS, pipeline_policy=PipelinePolicy())
@@ -41,4 +41,4 @@ if args["TO_MONTH"] < args["FROM_MONTH"]:
41
41
  sys.exit(f"TO_MONTH {args['TO_MONTH']} is before FROM_MONTH {args['FROM_MONTH']}")
42
42
  os.environ["FARSEER_ARGS"] = json.dumps(args)
43
43
 
44
- run_pipeline(store_type=StoreType.DATASETS, pipeline_policy=PipelinePolicy(), experimental__emit_pipeline_visualization_markers=True)
44
+ run_pipeline(store_type=StoreType.DATASETS, pipeline_policy=PipelinePolicy())
@@ -41,12 +41,15 @@ single printed line. **Test this rather than assuming it:** break the report
41
41
  module at import time on purpose and confirm the job still ends `ERROR` with
42
42
  its *original* message plus one `Error report unavailable (…)` line.
43
43
 
44
- ### 3. There is no PDF library in the runner image
45
-
46
- No `reportlab`, `fpdf`, `weasyprint`, `PIL`. Write PDF 1.4 bytes directly over
47
- the base-14 fonts (objects + xref, Helvetica / Helvetica-Bold / Courier,
48
- `/WinAnsi` encoding). It is less work than it sounds and it removes a
49
- dependency the image will not give you.
44
+ ### 3. There is no PDF library in the Python runner image
45
+
46
+ No `reportlab`, `fpdf`, `weasyprint`, `PIL`: the Python image carries the
47
+ Farseer client and little else. Write PDF 1.4 bytes directly over the base-14
48
+ fonts (objects + xref, Helvetica / Helvetica-Bold / Courier, `/WinAnsi`
49
+ encoding). It is less work than it sounds and it removes a dependency the
50
+ image will not give you. The **TypeScript** runner is different: it ships
51
+ `pdfkit` and `pdfmake`, so a TypeScript app uses those
52
+ ([`deploying-a-farseer-app.md`](../farseer-author-import-job/deploying-a-farseer-app.md#what-the-runner-image-has)).
50
53
 
51
54
  ### 4. 🔐 `FARSEER_ARGS` is UNMASKED inside the app process
52
55
 
@@ -0,0 +1,85 @@
1
+ ---
2
+ name: farseer-data-permissions
3
+ description: How data access decides which numbers each user of a Farseer workspace sees, and how to explain, plan, check or change it. Covers the workspace switch, each user group's Data access switch, restricting a group to some members of a dimension, hidden variables and per-group overrides, how a user's groups add up, what admins and the Default group see, and View as. Use when the user asks who can see what, why someone sees too much or too little, wants a team limited to some regions, entities or other members, wants a variable such as salaries hidden, or is about to turn data access on. Sharing decides which sheets and dashboards a user can open; this skill is about what they see inside them.
4
+ metadata:
5
+ version: "1"
6
+ ---
7
+
8
+ # Data access
9
+
10
+ Data access decides **what a user sees inside** the sheets and dashboards they can open: which members of each dimension, and which variables. Sharing still decides **which** items they can open at all. The usual setup is one sheet shared with everyone, with data access giving each group its own view of it: the same sheet, seen through different glasses, instead of one copy per team. Paths below are under `/api/v3`.
11
+
12
+ ## The rules
13
+
14
+ 1. **Admins see everything.** Super users and members of the **Super Admins** and **Admins** groups always see all data, hidden variables included. Only they change data access, and while it is on, only they read it.
15
+ 2. **The workspace switch**, "Data access" above the Groups table in Users & groups (`GET /dataAccess`, `PUT /dataAccess`). Off, everyone sees everything, hidden variables included, as before data access existed. On, the group rules below apply. Switching it off or on keeps every group's settings.
16
+ 3. **Each group's switch**, the Data access column of the Groups table. A group starts with it off, and while it is off the group gives its members nothing. **Default**, the group everyone is in, is always off, so a user who is only in Default sees nothing. Super Admins and Admins are always on.
17
+ 4. **A group with its switch on sees all data except hidden variables**, and is then narrowed:
18
+ - **Restrictions** limit one dimension to some of its members: **Only** the listed members, where members added later stay hidden, or **All except** the listed ones, where members added later are shown. **Restrict further** adds a restriction on another dimension.
19
+ - **Variable overrides** (Variables → Edit) set a variable to **Show** or **Hide** for this group, or leave it at its **Default**.
20
+ - A switched-on group with no restriction is marked "Members see all data". It is a warning to check, not an error.
21
+ 5. **Hidden variables.** A variable is visible by default. Marked **Hidden by default** in Edit variable, it is seen only by the groups that Show it, and by admins.
22
+ 6. **Groups add up.** A user sees everything that any of their switched-on groups gives. Membership only ever widens the view: one group cannot take away what another gives, and a Hide in one group does not hide a variable that another of the user's groups shows. To narrow someone's view, take them out of a group or change that group's rules; never add a group to restrict them.
23
+ 7. **No switched-on group, no data.** A user, an API key's service user or a public share link that is in no switched-on group sees no data at all.
24
+
25
+ ## What a restricted user sees
26
+
27
+ - Members they may not see are gone: no row or column for them, and totals add up only the members they see. A Revenue total of 270 over North, South and East reads 210 for a user limited to North and South.
28
+ - A hidden variable's row keeps its name and shows no values.
29
+ - In Users & groups, a user who sees no data at all is marked with a red sign next to their View as button.
30
+ - A user restricted by data access, anyone but an admin while it is on, still enters values in the cells they see. They cannot change the model's structure (members, variables, tables), run imports or use goal seeking top down, whatever their other permissions: those stay with admins.
31
+
32
+ ## Explaining why someone sees what they see
33
+
34
+ While data access is on, reading it needs an admin's sign-in; anyone else gets 403.
35
+
36
+ 1. `GET /dataAccess` answers `{"enabled": true}` or `false`. Off, everyone sees everything: stop here.
37
+ 2. `GET /users` lists every user with `id`, `email` and `dataAdmin`. A data admin sees everything.
38
+ 3. `GET /userGroups` lists every group as `{"id", "name", "userIds"}`. The groups whose `userIds` hold the user's `id` are theirs.
39
+ 4. `GET /dataAccess/groups` lists one entry per group: `{"userGroupId", "enabled", "fullAccess", "variables": {"show": [GID], "hide": [GID]} or null, "dimensions": [{"tableGid", "rule", "members": [GID]}]}`. A `rule` of `include` is Only, `exclude` is All except. `farseer variables list --json` and `farseer dimensions members TABLE --json` list the gids to read these by; a member's `parentId` is its table's gid.
40
+ 5. Take the user's groups with `enabled` true and add up what they give (rule 6).
41
+
42
+ The usual answers:
43
+
44
+ - **Sees nothing:** none of their groups is switched on, or they are only in Default.
45
+ - **Sees too much:** one of their groups has no restriction, or Shows the variable. Every group counts, so look at all of them, not only the one the user mentions.
46
+ - **Cannot open the sheet at all:** that is sharing, not data access. Share the sheet with them, or with a group they are in.
47
+
48
+ ## Changing data access
49
+
50
+ Only admins change data access, and only super users change who is in a group. A group's change applies at once to all its members, and the workspace switch to everyone: before you write, tell the user exactly what will change and for whom, and go on only when they confirm.
51
+
52
+ - **The workspace switch:** `PUT /dataAccess` with `{"enabled": true}` or `{"enabled": false}`.
53
+ - **A group:** `PUT /dataAccess/groups/{userGroupId}` with the group's whole definition. It replaces what the group had: a restriction or an override left out is removed. Read the group's entry from `GET /dataAccess/groups`, change only what you need, and send all of it back. To limit Sales to North and South and show it the hidden Salary:
54
+
55
+ ```json
56
+ {"enabled": true, "variables": {"show": [SALARY_GID], "hide": []},
57
+ "dimensions": [{"tableGid": REGION_TABLE_GID, "rule": "include", "members": [NORTH_GID, SOUTH_GID]}]}
58
+ ```
59
+
60
+ Super Admins and Admins always have full access, and Default always stays off; theirs cannot be changed.
61
+ - **A variable's default:** read it with `GET /entities/{gid}/VAR`, set `variable.visibility` to `"hidden"` or `"visible"`, remove `variable.referencedBy`, and send the object back with `POST /entities/mutate` as `{"updated": [OBJECT]}`. `referencedBy` is read-only: an update that keeps it is refused with 400.
62
+ - **Membership:** `POST /userGroups/{id}/users` adds and `DELETE /userGroups/{id}/users` removes, both with `{"userIds": [USER_ID]}`.
63
+
64
+ Every change is in the audit log, under the `DATA_ACCESS.` types for rules, switches and visibility.
65
+
66
+ ## Before turning data access on
67
+
68
+ Once the workspace switch is on, nobody outside Super Admins and Admins sees anything until a group gives it to them. Set up and switch on the groups first, then turn on the workspace switch, then check a member of each group with View as.
69
+
70
+ - **Integrations and scheduled imports** run as an API key's service user, and a service user is restricted like anyone else. One that runs imports or changes structure must be in Admins: an import is refused to a restricted caller, even one in a switched-on group. One that only reads or writes cell values can be in a switched-on group instead. In no switched-on group, its reads return nothing and its cell writes change nothing, without an error.
71
+ - **Public share links** are in no group, so they show no data.
72
+ - **Jobs already queued** keep the access their caller had when they were queued.
73
+
74
+ ## Checking a user's view: View as
75
+
76
+ View as is in the app, for admins. Start it from Users & groups → Users → **View as** on the user's row, or from any sheet with **Share → ⋯ → View as**. The app reloads showing exactly what that user sees, read-only, under a "Viewing as" banner; **Exit** in the banner returns to your own view. An admin who is not a super user cannot view as a super user or another admin.
77
+
78
+ After a change, ask an admin to check it with View as. From the API, answer from the rules above instead.
79
+
80
+ ## When a call fails
81
+
82
+ - **403 on `/dataAccess`:** the caller is not an admin. Ask someone in Super Admins or Admins to make the change, or to give the access.
83
+ - **A membership change is refused:** only super users change who is in a group.
84
+ - **400 on `/entities/mutate`:** the object still holds `variable.referencedBy`, or it is not the whole object read back.
85
+ - **A group's change is refused:** Super Admins, Admins and Default cannot be changed. Otherwise check each gid against the variable and member lists.