farseer-cli 1.17.0 → 1.19.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 (161) hide show
  1. package/README.md +3 -3
  2. package/dist/commands/app.js.map +0 -1
  3. package/dist/commands/apps.js.map +0 -1
  4. package/dist/commands/cells.js.map +0 -1
  5. package/dist/commands/code.js.map +0 -1
  6. package/dist/commands/config.js.map +0 -1
  7. package/dist/commands/dashboards.js.map +0 -1
  8. package/dist/commands/diff.js.map +0 -1
  9. package/dist/commands/dimensions.js.map +0 -1
  10. package/dist/commands/files.js.map +0 -1
  11. package/dist/commands/formula.js +16 -7
  12. package/dist/commands/formula.js.map +1 -2
  13. package/dist/commands/install.js.map +0 -1
  14. package/dist/commands/list.js.map +0 -1
  15. package/dist/commands/login.js +3 -3
  16. package/dist/commands/login.js.map +1 -2
  17. package/dist/commands/logout.js.map +0 -1
  18. package/dist/commands/mcp-server.js.map +0 -1
  19. package/dist/commands/model.js.map +0 -1
  20. package/dist/commands/pipeline.js.map +0 -1
  21. package/dist/commands/pull.js +1 -1
  22. package/dist/commands/pull.js.map +1 -2
  23. package/dist/commands/push.js +2 -2
  24. package/dist/commands/push.js.map +1 -2
  25. package/dist/commands/refresh.js.map +0 -1
  26. package/dist/commands/run.js.map +0 -1
  27. package/dist/commands/sheets.js.map +0 -1
  28. package/dist/commands/status.js.map +0 -1
  29. package/dist/commands/tool.js +120 -0
  30. package/dist/commands/tool.js.map +6 -0
  31. package/dist/commands/variables.js.map +0 -1
  32. package/dist/commands/whoami.js.map +0 -1
  33. package/dist/index.js +29 -12
  34. package/dist/index.js.map +1 -2
  35. package/dist/mcp/index.js.map +0 -1
  36. package/dist/mcp/prompts/workflows.js.map +0 -1
  37. package/dist/mcp/resources/documentation.js.map +0 -1
  38. package/dist/mcp/server.js.map +0 -1
  39. package/dist/mcp/skills.js.map +0 -1
  40. package/dist/mcp/tools/appTools.js.map +0 -1
  41. package/dist/mcp/tools/authTools.js +1 -1
  42. package/dist/mcp/tools/authTools.js.map +1 -2
  43. package/dist/mcp/tools/cellTools.js.map +0 -1
  44. package/dist/mcp/tools/dashboardTools.js.map +0 -1
  45. package/dist/mcp/tools/dataTools.js.map +0 -1
  46. package/dist/mcp/tools/folderTools.js.map +0 -1
  47. package/dist/mcp/tools/modelTools.js +65 -23
  48. package/dist/mcp/tools/modelTools.js.map +2 -3
  49. package/dist/mcp/tools/pipelineContract.js.map +0 -1
  50. package/dist/mcp/tools/pipelineTools.js.map +0 -1
  51. package/dist/mcp/tools/runTools.js +6 -2
  52. package/dist/mcp/tools/runTools.js.map +1 -2
  53. package/dist/mcp/tools/sheetTools.js.map +0 -1
  54. package/dist/mcp/tools/syncTools.js +2 -2
  55. package/dist/mcp/tools/syncTools.js.map +1 -2
  56. package/dist/mcp/utils/helpers.js.map +0 -1
  57. package/dist/mcp/utils/launchPin.js +1 -1
  58. package/dist/mcp/utils/launchPin.js.map +1 -2
  59. package/dist/mcp/utils/registerTool.js.map +0 -1
  60. package/dist/mcp/utils/session.js.map +0 -1
  61. package/dist/mcp/utils/tenantPin.js.map +0 -1
  62. package/dist/pipeline/compatibility.js.map +0 -1
  63. package/dist/pipeline/connect.js.map +0 -1
  64. package/dist/pipeline/create.js.map +0 -1
  65. package/dist/pipeline/errors.js.map +0 -1
  66. package/dist/pipeline/generated-reference.json +22 -10
  67. package/dist/pipeline/guide.js.map +0 -1
  68. package/dist/pipeline/init.js.map +0 -1
  69. package/dist/pipeline/operations.js.map +0 -1
  70. package/dist/pipeline/query.js.map +0 -1
  71. package/dist/pipeline/queryDownloads.js.map +0 -1
  72. package/dist/pipeline/queryWorker.js.map +0 -1
  73. package/dist/pipeline/readiness.js.map +0 -1
  74. package/dist/pipeline/reference.js.map +0 -1
  75. package/dist/pipeline/requests.js.map +0 -1
  76. package/dist/pipeline/runArguments.js.map +0 -1
  77. package/dist/pipeline/runtime.js.map +0 -1
  78. package/dist/pipeline/service.js.map +0 -1
  79. package/dist/services/agentApprovalFetch.js +7 -3
  80. package/dist/services/agentApprovalFetch.js.map +1 -2
  81. package/dist/services/appSyncService.js.map +0 -1
  82. package/dist/services/apps.js.map +0 -1
  83. package/dist/services/authErrors.js.map +0 -1
  84. package/dist/services/codefirst/api.js +38 -5
  85. package/dist/services/codefirst/api.js.map +1 -2
  86. package/dist/services/codefirst/binaryDisk.js.map +0 -1
  87. package/dist/services/codefirst/byteHashes.js +5 -0
  88. package/dist/services/codefirst/byteHashes.js.map +1 -2
  89. package/dist/services/codefirst/documents.js +41 -15
  90. package/dist/services/codefirst/documents.js.map +1 -2
  91. package/dist/services/codefirst/layoutBinaryProjection.js +24 -13
  92. package/dist/services/codefirst/layoutBinaryProjection.js.map +1 -2
  93. package/dist/services/codefirst/layoutCompose.js +44 -38
  94. package/dist/services/codefirst/layoutCompose.js.map +1 -2
  95. package/dist/services/codefirst/layoutCore.js +14 -1
  96. package/dist/services/codefirst/layoutCore.js.map +1 -2
  97. package/dist/services/codefirst/layoutPaths.js +80 -4
  98. package/dist/services/codefirst/layoutPaths.js.map +1 -2
  99. package/dist/services/codefirst/layoutProjection.js +73 -39
  100. package/dist/services/codefirst/layoutProjection.js.map +1 -2
  101. package/dist/services/codefirst/layoutReadback.js +357 -130
  102. package/dist/services/codefirst/layoutReadback.js.map +2 -3
  103. package/dist/services/codefirst/layoutReadbackPlacement.js +94 -57
  104. package/dist/services/codefirst/layoutReadbackPlacement.js.map +2 -3
  105. package/dist/services/codefirst/layoutReceipt.js +283 -243
  106. package/dist/services/codefirst/layoutReceipt.js.map +2 -3
  107. package/dist/services/codefirst/layoutScan.js +208 -110
  108. package/dist/services/codefirst/layoutScan.js.map +1 -2
  109. package/dist/services/codefirst/output.js +76 -10
  110. package/dist/services/codefirst/output.js.map +1 -2
  111. package/dist/services/codefirst/types.js.map +0 -1
  112. package/dist/services/codefirst/workflow.js +65 -29
  113. package/dist/services/codefirst/workflow.js.map +2 -3
  114. package/dist/services/codefirst/workspace.js.map +0 -1
  115. package/dist/services/codefirst/workspaceLock.js.map +0 -1
  116. package/dist/services/codefirst/workspaceRoot.js +2 -1
  117. package/dist/services/codefirst/workspaceRoot.js.map +1 -2
  118. package/dist/services/configService.js.map +0 -1
  119. package/dist/services/credentials.js.map +0 -1
  120. package/dist/services/farseerService.js +3 -1
  121. package/dist/services/farseerService.js.map +1 -2
  122. package/dist/services/httpError.js.map +0 -1
  123. package/dist/services/modelExport.js.map +0 -1
  124. package/dist/services/organisation.js.map +0 -1
  125. package/dist/services/preflight.js.map +0 -1
  126. package/dist/services/realms.js.map +0 -1
  127. package/dist/services/syncService.js +3 -3
  128. package/dist/services/syncService.js.map +1 -2
  129. package/dist/skills/pipeline.js.map +0 -1
  130. package/dist/utils/agentSandbox.js.map +0 -1
  131. package/dist/utils/cliOptions.js.map +0 -1
  132. package/dist/utils/constants.js.map +0 -1
  133. package/dist/utils/entityResolver.js.map +0 -1
  134. package/dist/utils/errorFormatter.js +59 -11
  135. package/dist/utils/errorFormatter.js.map +1 -2
  136. package/dist/utils/fileLogger.js.map +0 -1
  137. package/dist/utils/fileValidation.js.map +0 -1
  138. package/dist/utils/folderMatch.js.map +0 -1
  139. package/dist/utils/formulaFilters.js +48 -0
  140. package/dist/utils/formulaFilters.js.map +6 -0
  141. package/dist/utils/helpers.js.map +0 -1
  142. package/dist/utils/logger.js.map +0 -1
  143. package/dist/utils/nameResolver.js.map +0 -1
  144. package/dist/utils/packageManager.js.map +0 -1
  145. package/dist/utils/syncReporting.js.map +0 -1
  146. package/dist/utils/syncScope.js.map +0 -1
  147. package/dist/utils/updateCheck.js.map +0 -1
  148. package/dist/utils/variableValues.js.map +0 -1
  149. package/dist/utils/workspace.js.map +0 -1
  150. package/docs/cli-guide.md +14 -1
  151. package/docs/import-workflows.md +14 -14
  152. package/docs/new-app-template.md +1 -1
  153. package/docs/pipeline-client-guide.md +1 -1
  154. package/docs/pipeline-reference.md +292 -3
  155. package/package.json +2 -2
  156. package/skills/farseer-analysis/SKILL.md +132 -0
  157. package/skills/farseer-dashboards/SKILL.md +40 -0
  158. package/skills/farseer-formulas/SKILL.md +165 -0
  159. package/skills/farseer-model/SKILL.md +119 -0
  160. package/skills/pipeline-authoring/SKILL.md +6 -4
  161. package/skills/pipeline-authoring/practices.md +6 -5
@@ -0,0 +1,165 @@
1
+ ---
2
+ name: farseer-formulas
3
+ description: Farseer's formula syntax, with its references, filters and functions, and how a formula is evaluated over versions, years and linked tables. Use before writing a formula not yet written in this conversation, such as a read of values for a comparison, a new variable's formula or the address of a cell write.
4
+ metadata:
5
+ version: "1"
6
+ ---
7
+
8
+ # Formula syntax
9
+
10
+ Evaluate one formula with `farseer formula eval 'EXPRESSION' --json`, or many in one request with `POST /api/v3/evaluate`. A cell write addresses its cells with the same `SUM(...)` filters (see the `farseer-model` skill).
11
+
12
+ Put filters inside the formula, as in `SUM("Revenue", "Years">"Y2025", "Versions">"Actual")`. The evaluate request's own `filters` field holds named filters a formula must reference, so filters passed there leave a plain formula unfiltered.
13
+
14
+ ## Syntax Rules
15
+
16
+ * Wrap variable, table, and member names in double quotes: `"Revenue"`, `"Years">"2024"`
17
+ * `>` is the table→member accessor, **not** a comparison operator. For comparisons use `gt()`, `lt()`, etc.
18
+ * Operators: `+ - * /` (standard math precedence)
19
+ * Parentheses must be balanced.
20
+ * Functions: `FUNCTION(arg1, arg2, ...)`, which can be nested. Names are case-insensitive.
21
+ * Always generate a complete expression, never a list or comma-separated values.
22
+
23
+ ## CRITICAL: Member Names in Formulas
24
+
25
+ * Every member has a **name** and an optional **description**.
26
+ * **Always use the `name` field in formulas. NEVER use the description.**
27
+ * Member names have no consistent format: they can be codes ("001"), abbreviations ("M1", "Y2025"), or readable text ("North America").
28
+ * **Never guess member names.** Always look up the actual names in the model using the available tools.
29
+
30
+ ## Valid / Invalid Examples
31
+
32
+ Valid:
33
+ ```
34
+ SUM("Revenue", "Years">"2024")
35
+ "Gross profit" + "Operating expenses"
36
+ IF(gt("Revenue", 1000), "High revenue", "Low revenue")
37
+ SUM("Revenue" - "Costs", "Years">"2025")
38
+ ```
39
+
40
+ Invalid (will crash the engine):
41
+ * Comma-separated values outside a function: `"Revenue", "Years">"2024"`
42
+ * Lists or numbered expressions: `1. "Revenue"; 2. "Costs"`
43
+ * Variable treated as function: `"Profit"("Years">"2025")`
44
+ * Standalone dimension access without expression: `"Table">"Member"`
45
+
46
+ ## Built-in Functions
47
+
48
+ ### Aggregation / Time
49
+
50
+ | Function | Meaning |
51
+ |-----------------------------------|-----------------------------------------------|
52
+ | `sum(var, filters)` | The variable at a slice, by its rollup; use `"Table">"Member"` for filters |
53
+ | `avg(var, months, skip_nulls)` | Moving average |
54
+ | `delay(var, months)` | Shift forward/back by N months |
55
+ | `spread(var, months, delay)` | Spread value across months (depreciation) |
56
+ | `spread_days(var, days, delay)` | Spread value across days |
57
+ | `cumsum(var, factor, resetVar)` | Cumulative sum (YTD, interest, growth), see below |
58
+ | `predictAverage()` | Fill with average of previous values |
59
+
60
+ **Running totals with `cumsum(var, factor, resetVar)`.** Each month is `var + previous * (1 + factor)`, carried across years, except where `resetVar` has a value: there the month returns that value and the total restarts from it. The total runs separately in every cell, such as each client and product, so a reset that is blank in one cell carries that cell's total over. A year-to-date variable is split like its source and restarts each January with the source's January value, or 0 where January has none. Save the reset as its own variable, split like the source, and pass it by name: a reset written inline, such as an `if(...)`, takes the engine's fallback path, which can get a month wrong.
61
+
62
+ - `Net sales YTD reset`: `if(hasDMember("Months">"M1"), if(hasValue("Net sales"), "Net sales", 0))`
63
+ - `Net sales YTD`: `cumsum("Net sales", 0, "Net sales YTD reset")`
64
+
65
+ Give `Net sales YTD` the CLOSING STATE rollup, so a quarter or a year shows its last month, and check it by month: January equals January's source value and each later month adds that month's.
66
+
67
+ ### Math
68
+
69
+ | Function | Meaning |
70
+ |-----------------------------|--------------------|
71
+ | `round(var, decimals)` | Round (Excel-style)|
72
+ | `floor(var)` | Round down |
73
+ | `ceil(var)` | Round up |
74
+ | `abs(var)` | Absolute value |
75
+ | `power(x, z)` | Exponentiation |
76
+ | `max(a, b)` / `min(a, b)` | Bigger / smaller |
77
+
78
+ ### Comparison (return logical value)
79
+
80
+ | Function | Meaning |
81
+ |-------------|------------------|
82
+ | `eq(a, b)` | Equals |
83
+ | `gt(a, b)` | Greater than |
84
+ | `gte(a, b)` | Greater or equal |
85
+ | `lt(a, b)` | Less than |
86
+ | `lte(a, b)` | Less or equal |
87
+
88
+ ### Logical / Branching
89
+
90
+ | Function | Meaning |
91
+ |-------------------------------------|-------------------------------------------|
92
+ | `if(test, trueResult, falseResult)` | Conditional (like Excel IF). `falseResult` is optional (defaults to null). |
93
+ | `or(dim1, dim2)` | Logical OR / combine dimension filters |
94
+ | `and(dim1, dim2)` | Logical AND |
95
+ | `not(dim)` | Logical NOT |
96
+
97
+ ### Dimension / Data Checks
98
+
99
+ | Function | Meaning |
100
+ |------------------------|--------------------------------------|
101
+ | `hasDMember(dimension)`| TRUE if dimension member is present (e.g., `hasDMember("Years">"Y2025")`) |
102
+ | `hasTags(dimension)` | Alias for `hasDMember` |
103
+ | `hasValue(variable)` | TRUE if variable has a value |
104
+
105
+ ### Date / Time
106
+
107
+ Requires system dimensions **Years** and **Months**.
108
+
109
+ | Function |
110
+ |---------------------------------------------|
111
+ | `currentMonth()` |
112
+ | `currentDate()` |
113
+ | `daysInCurrentMonth()` |
114
+ | `date(year, month, day)` |
115
+ | `edate(date, months)` |
116
+ | `day(date)` / `month(date)` / `year(date)` |
117
+
118
+ ### Growth
119
+
120
+ | Function | Meaning |
121
+ |-------------------|--------------------------------|
122
+ | `mom(percentage)` | Month-over-month growth |
123
+ | `qoq(percentage)` | Quarter-over-quarter growth |
124
+ | `yoy(percentage)` | Year-over-year growth |
125
+
126
+ ## SUM and Dimension Filters
127
+
128
+ * Format: `SUM("Variable", "Table">"Member", ...)`; filters combine with AND.
129
+ * Use one member per dimension. To include several members of one dimension, prefer their common parent (e.g. a quarter over its months); use `OR(...)` only when there is no such parent.
130
+ * Omitting a connected dimension = include all its members, totalled by the variable's rollup (a sum only for a SUM rollup).
131
+
132
+ **OR helper:** Union multiple members of the **same** dimension: `OR("Months">"M1", "Months">"M2")`. Takes 2+ arguments.
133
+
134
+ * **Every argument must filter the same dimension.** Mixing dimensions in one `OR(...)`, for example `OR("Months">"M1", "Clients">"Acme")`, is not rejected but silently produces a wrong result.
135
+ * **Combining filters on different dimensions:**
136
+ * Both at once (M1 *and* Acme): put both filters in one `SUM`: `SUM("Revenue", "Months">"M1", "Clients">"Acme")`.
137
+ * Either one (M1 *or* Acme): adding `SUM("Revenue", "Months">"M1") + SUM("Revenue", "Clients">"Acme")` counts the overlap twice (Acme's M1 revenue is in both). Subtract it once: `SUM("Revenue", "Months">"M1") + SUM("Revenue", "Clients">"Acme") - SUM("Revenue", "Months">"M1", "Clients">"Acme")`. This holds only for a variable with a SUM rollup; for any other rollup, read the slices separately.
138
+ * Add separate sums only when the slices cannot overlap and the variable's rollup is SUM.
139
+ * **Prefer a parent dimension over OR-ing its children.** When the members you want roll up to a single parent member, filter by the parent: use `"Quarters">"Q1"` rather than `OR("Months">"M1", "Months">"M2", "Months">"M3")`. Both give the same total, but the parent form is shorter and avoids mis-listing a member.
140
+
141
+ **Dimensionality rules:**
142
+ * Use members only from tables connected (directly or indirectly) to the variable.
143
+ * If a dimension is fixed in the variable, you may only use that same fixed member.
144
+ * Skipping a connected table returns the variable over all its members by its rollup (a sum only for SUM).
145
+
146
+ **System dimensions:** Years, Half Years, Quarters, Months, Year To Date, Versions.
147
+ If connected to Months, you may filter by Quarters or Half Years instead (they expand to matching months).
148
+
149
+ ## Inferring Versions
150
+
151
+ * If the variable is connected to "Versions", you **must** include exactly one version filter.
152
+ * Omitting the version sums across all versions, which is always wrong (critical error).
153
+ * Choose by intent: expected/projected → plan or forecast; realized/recorded → actual.
154
+ * When the user does not say, past periods use actuals and future periods the plan or forecast. State the version you used. When several versions fit, such as Budget and Forecast, evaluate each.
155
+
156
+ ## Inferring Years
157
+
158
+ * If the variable is connected to "Years", include a specific year unless intentionally aggregating across years.
159
+ * Defaults when unspecified: a period named without a year is in the current year; "last year" is the previous year and "next year" the next.
160
+ * Use explicit years from the question when provided.
161
+
162
+ ## Constraints
163
+
164
+ * Use **only** variables, tables, and members that exist in the model.
165
+ * Never invent names. If unsure, look them up with tools.
@@ -0,0 +1,119 @@
1
+ ---
2
+ name: farseer-model
3
+ description: How a Farseer model works, with its tables, members and links, variables, versions and the rollup types that total a variable over periods and members, and how to change it through tables, members and links, cell values and Farseer-as-code. Use when an answer depends on how a variable rolls up, and before creating or changing variables, tables, members, links or cell values.
4
+ metadata:
5
+ version: "1"
6
+ ---
7
+
8
+ # Farseer model
9
+
10
+ How a model is built, how its numbers total, and how to change it. Paths below are under `/api/v3`.
11
+
12
+ ## Tables (Dimensions)
13
+
14
+ A table is a collection of dimension members (rows).
15
+
16
+ * Each member has a unique **name** and an optional **description**.
17
+ - **name** is the identifier used in formulas. **description** is for display only.
18
+ - Names have no consistent format: they can be codes ("001"), abbreviations ("M1", "Y2025"), or readable text ("North America"). Always look up actual names in the model.
19
+ * Column types:
20
+ - **NAME**: the member's unique name (primary key)
21
+ - **FOREIGN_KEY**: references another table, creating a connection (see below)
22
+ - **DESCRIPTION**: display label for the member
23
+ - **DATE / NUMBER / TEXT / FILE**: custom data columns
24
+
25
+ ## Table Connections
26
+
27
+ Tables are connected through FOREIGN_KEY columns. A FK column in table A pointing to table B means each member of A is linked to one or more members of B.
28
+
29
+ * Example chain: **Months** FK→ **Quarters** FK→ **Half Years** FK→ **Years**. Each month belongs to a quarter, each quarter to a half year, etc.
30
+ * A **hierarchy table** has a FOREIGN_KEY referencing itself (tree structure within one table).
31
+ * FOREIGN_KEY defines relationships, **not aggregation**: aggregation depends on the variable's formula and rollup settings.
32
+ * A member's links are the values of its FOREIGN_KEY columns: `farseer model --table TABLE --json` lists every column of a table's members.
33
+ * For "other X in the same Y" questions, start from the member the user named, follow its link column to Y, and list the members linked to that Y, rather than matching names.
34
+
35
+ ## Variables
36
+
37
+ A variable is a multi-dimensional dataset. Its dimensions are the tables it is connected to (`tableGids`).
38
+
39
+ **Types:**
40
+ * **Input variable**: no formula; values are entered or imported.
41
+ * **Calculated variable**: has a formula referencing other variables and functions.
42
+ * **Measure** (`measure: true`): no dimensions; holds a single scalar value.
43
+ * **On-demand variable** (`calculateOnDemand: true`): calculated only when explicitly requested, not on every model recalculation.
44
+
45
+ **Fixed dimensions:** When a variable has `members` entries, those dimensions are locked to specific member values. You cannot filter by other members of that table in formulas for this variable.
46
+
47
+ ## How connections affect formulas
48
+
49
+ A variable can be filtered by members of any table that is **directly or indirectly connected** to it:
50
+
51
+ * **Direct**: tables listed in the variable's `tableGids`.
52
+ * **Indirect**: tables reachable via FOREIGN_KEY chains from directly connected tables.
53
+
54
+ Example: Suppose "Revenue" is directly connected to **Clients** and **Months**. The **Clients** table has a FK to **Client Groups**. Even though "Revenue" is not directly connected to Client Groups, you can filter by it because it's reachable via Clients → Client Groups:
55
+
56
+ ```
57
+ SUM("Revenue", "Client Groups">"B2B", "Versions">"Actual")
58
+ ```
59
+
60
+ This sums revenue across all clients that belong to the "B2B" client group.
61
+
62
+ Similarly, because Months FK→ Quarters FK→ Years, you can filter "Revenue" by any of those time dimensions:
63
+
64
+ ```
65
+ SUM("Revenue", "Years">"Y2025", "Versions">"Actual")
66
+ SUM("Revenue", "Quarters">"Q1 2025", "Versions">"Actual")
67
+ ```
68
+
69
+ ## Key Variable Fields
70
+
71
+ | Field | Meaning |
72
+ |---------------|----------------------------------------------------------------|
73
+ | formula | Expression using other variables, functions, literals |
74
+ | rollupType | SUM, AVERAGE, CLOSING STATE, BEGINNING STATE, FORMULA, MAX, MIN, NONE |
75
+ | dataType | DECIMAL or INTEGER |
76
+ | numberFormat | Display formatting (currency, decimals, unit). Unit (ONES/THOUSANDS/MILLIONS) is display-only: values are always stored as raw numbers. |
77
+ | readonly | If true, values cannot be edited manually |
78
+ | useHierarchy | If true, hierarchy tables are considered in calculation |
79
+ | calculateOnDemand | If true, variable is calculated on-demand |
80
+
81
+ **Rollup types explained:**
82
+ * **SUM**: additive aggregation. Safe to use with the `SUM()` formula function.
83
+ * **AVERAGE**: not additive. `SUM("Var", filters)` returns the variable at that slice by its own rollup: over months it stays an average, but across members it is an unweighted average, so for a price or rate across members fetch the components and divide.
84
+ * **CLOSING STATE / BEGINNING STATE**: point-in-time values. `SUM("Var", filters)` over a period returns its last (or first) month, not a sum.
85
+ * **FORMULA**: rollup is computed by the variable's own formula: `SUM("Var", filters)` recomputes it from its components at that slice.
86
+ * **MAX / MIN**: takes the maximum/minimum across aggregated values.
87
+ * **NONE**: no aggregation.
88
+
89
+ **Rules:**
90
+ * Always check the variable's `rollupType` before choosing an aggregation method.
91
+ * If dataType = INTEGER and rollup yields a decimal → round half up.
92
+ * readonly + formula → formula output always wins.
93
+ * A variable can connect to at most one hierarchy table.
94
+ * Empty/null fields mean "not set."
95
+
96
+ ## Changing tables, members and links
97
+
98
+ The CLI creates and deletes members, but tables and links between tables go through `POST /entities/mutate`.
99
+
100
+ - `farseer dimensions create-member` adds a member. Without `-y`, `farseer dimensions delete-member` only prints a preview and exits successfully, changing nothing: pass `-y` when you intend the delete. `create-member` takes no `-y`.
101
+ - `farseer dimensions members TABLE --json` lists `id`, `name` and `parentId`; `--limit` shortens only the text output, not `--json`.
102
+ - `farseer push` syncs files and apps, not the model, and waits at a prompt unless you pass `-y`; with `--force` it always prompts, so never use `--force`. There is no `farseer model push` or validation command.
103
+
104
+ - **A table:** `{"created": [{"type": "DTAB", "meta": {"name": "Sales regions"}, "dimensionTable": {}}]}`.
105
+ - **Its members,** several in one write: `{"created": [{"type": "DMEM", "meta": {"name": "Nordics"}, "relations": {"parent": {"key": {"id": TABLE_GID, "type": "DTAB"}, "order": 0}}, "dimensionMember": {"data": {}}}]}`.
106
+ - **To change an existing table or member,** read it with `GET /entities/{id}/{type}` (type `DTAB` or `DMEM`), change only what you need, and send the whole object back in `{"updated": [OBJECT]}`. A partial object can be accepted and change nothing. A table's `dimensionTable.columns` goes back with only the columns whose id is above 7: ids 0 to 7 are the built-in columns, such as Name, Formula and Description, which the read includes, and an update that lists one is refused with 400 `Cannot update internal columns`. Every column above 7 stays in the list, since one left out is deleted, its links included.
107
+ - **To link a table to another,** such as each country to its region: update the table as above, with the new column `{"id": -1, "name": "Sales regions", "type": "FOREIGN_KEY", "metadata": null, "refTableGid": REGION_TABLE_GID, "primaryKey": false, "foreignKey": true, "unique": false}` added to its `dimensionTable.columns` and `{"key": {"id": REGION_TABLE_GID, "type": "DTAB"}, "order": N}` to `links.tableForeignKeys`, then read the table again for the id the new column got. Then on each member, append `{"key": {"id": REGION_GID, "type": "DMEM"}, "order": N}` to `links.connections` and set `dimensionMember.data["COLUMN_ID"]` to `[REGION_GID]` with that id, keeping its existing links. Check the result with `evaluate`: a region's total equals the sum of its countries.
108
+
109
+ ## Writing cell values
110
+
111
+ The legacy `/cells/query` and `/cells/update` routes, used by `farseer cells`, are not implemented: read values with `/evaluate` and write them with `/model/updateCells`.
112
+
113
+ - `/model/updateCells` takes `{"filters": [], "cellUpdates": [{"formula": "SUM(\"Quantity\", \"Versions\">\"Plan\", \"Years\">\"Y2026\", \"Quarters\">\"Q3\")", "value": 300000}]}`; the empty `filters` is required. It addresses cells with `SUM(...)` filters, like a read, and writes across every member of a dimension it leaves out, Versions included, so name one version.
114
+ - A value written to an aggregate, such as a year or a parent member, is spread over the cells beneath it: by the variable's top-down mapping if it has one, otherwise in proportion to the current values, changing only cells that hold one. Into an empty slice, a SUM variable is split evenly and other rollups repeat the value.
115
+ - To set a price or rate for every month, write each month as its own `cellUpdates` entry. Before writing a total, say how it will spread, and afterwards read back the cells it reached.
116
+
117
+ ## Farseer-as-code
118
+
119
+ `/labs/fsl/generate`, `/labs/fsl/lint` and `/labs/fsl/compile` generate, lint and compile Farseer-as-code (FSL); compiling does not change the live model. Read the `/model/load` schema before applying a compiled model, preserve unrelated definitions, and verify the result.
@@ -4,12 +4,12 @@ description: Author all new repeatable Farseer data pipelines with Simple Pipeli
4
4
  metadata:
5
5
  version: "1"
6
6
  minimum-cli: "1.14.2"
7
- engine-profile: "3.0"
7
+ engine-profile: "3.2"
8
8
  ---
9
9
 
10
10
  # Pipeline authoring
11
11
 
12
- Pipeline authoring for simple-pipelines 3.0, the engine line in the runner image this CLI was released with. Patch releases keep the grammar, so any 3.0 engine runs what this skill describes.
12
+ Pipeline authoring for simple-pipelines 3.2, the engine line in the runner image this CLI was released with. Patch releases keep the grammar, so any 3.2 engine runs what this skill describes.
13
13
 
14
14
  ## What this is
15
15
 
@@ -23,7 +23,7 @@ If a required Simple Pipelines job, profile or source connection is missing, exp
23
23
 
24
24
  1. `init name=<folder>` (CLI: `farseer pipeline init <org> <tenant> --new <name>`) creates the local folder under files/<name>/ (`main.py`, an empty `Models/` and `Code/`), uploads `main.py` into a new source folder Files/<name>, creates a job named <name> with that folder, `main.py` as entrypoint and the runner-python-simple-pipelines image this CLI was released with, then writes the profile farseer-apps/<tenant>/.pipelines/<name>.json. If files/<name>/ already exists locally with a `main.py`, init adopts it instead: it uploads the folder's source files as they are and writes no starter.
25
25
  2. Write the YAML under `Models/`, one file per step, named after its `name:`. The guide topics `FarseerFilesExtractConfig`, `ParseConfig`, `TransformConfig` and `LoadCellsConfig` each end with a complete example the engine accepts; start from those. Discover real source, dataset and model names with the existing tools first.
26
- 3. Give the job its secrets. A source that needs a key or password (Business Central, a private Drive folder, SharePoint) reads it from a secret-typed job argument and the YAML names it as `{{ pipeline_args.NAME }}`; never write the value into YAML, the engine refuses `farseer_credentials` blocks. init creates the job with no arguments, so add each one with `farseer_configure_app` (`arguments: [{name, dataType: "string", secret: true, defaultValue: "<the value>"}]`) or in the web app before the first real run. The value is the argument's `defaultValue`; reads and run logs show it masked. Setting it through the tool puts the value in this conversation, so when the client prefers, ask the admin to type it into the web app instead. `check` lists every `pipeline_args.NAME` the YAML uses that the job does not define.
26
+ 3. Give the job its secrets. A source that needs a key or password (Business Central, a private Drive folder, SharePoint, an HTTP API's `auth:`, a custom connector's `secrets:`) reads it from a secret-typed job argument and the YAML names it as `{{ pipeline_args.NAME }}`; never write the value into YAML, the engine refuses `farseer_credentials` blocks. init creates the job with no arguments, so add each one with `farseer_configure_app` (`arguments: [{name, dataType: "string", secret: true, defaultValue: "<the value>"}]`) or in the web app before the first real run. The value is the argument's `defaultValue`; reads and run logs show it masked. Setting it through the tool puts the value in this conversation, so when the client prefers, ask the admin to type it into the web app instead. `check` lists every `pipeline_args.NAME` the YAML uses that the job does not define.
27
27
  4. `push` uploads the edited files.
28
28
  5. `run` submits one run and returns a run UUID receipt. To change a job argument for one run, pass it by name: `args: ["MONTH=2026-08"]` (CLI: `--arg MONTH=2026-08`, repeatable). Arguments you do not name keep the job's default; a name the job does not declare, a bare value, an empty value or a fixed argument is refused before anything is sent, and the receipt lists the arguments it used, secrets masked.
29
29
  6. `inspect` reads that run's logs and markers. Then read the output with `query` on the output dataset, and what each load committed with `inspect-import` on the import ID that `loads` reports. Never check a load with a model or variable export: it pulls whole variables out of the tenant's in-memory model.
@@ -54,12 +54,14 @@ Submit once after sync and save the UUID receipt. Inspect that UUID after reconn
54
54
 
55
55
  The backend records each run before dispatch and answers with its run UUID. The tenant's jobrunner must be 3.6.0 or newer: an older one cannot keep the run id the backend assigns, so the backend refuses to send it the run and says so, and no run starts. A 3.0 pipeline keeps each extract's file for 30 days in the backend's payload area, which needs a backend that has it, storage that can sign download and upload links, and a runner key that is a super user's or holds CLASS.REMOTE_JOB.RUN_AS_SERVICE; without them the first extract fails. Reading datasets, their versions and download links needs the right to update jobs (CLASS.REMOTE_JOB.UPDATE) or the Data Hub permission (FEATURE.DATA_HUB); `init`, `check`, `query` and `versions` rely on it. `restore` needs the right to update jobs; creating or deleting datasets stays with super users and the runner. Download links, restores and other dataset changes made by a person are recorded in the audit log. A permission refusal from `check` is a setup issue to report to the setup owner.
56
56
 
57
- `check` reads the prepared job, its runner image, whether a newer CLI was released with the tenant's runner image (`cli-version`, pending means update before authoring), and the output manifests, then probes the first Parquet file using signed HTTPS access, or through the API when the CLI runs with an agent turn key, because an agent sandbox can reach only the API. This CLI authors for exactly one engine: the one inside the runner image it was released with. Only jobs already using a Simple Pipelines runner are eligible for image pinning. TypeScript, other runner families and an unknown or inherited image are refused by init, source sync and run; use the existing app tools and preserve the app. The CLI never changes a job's image on its own. A Simple Pipelines job on an older released image is reported as failed: `run`, `pull` and reads still work on its own image, but `push` is refused (`RUNTIME_UPGRADE_REQUIRED`) until the job is upgraded with `upgrade-runtime` (CLI: `farseer pipeline upgrade-runtime`), which moves it to this CLI's image and reports where it moved from. Upgrading changes the engine for everyone on that tenant and, on a scheduled job, for the next scheduled run, so ask the user before upgrading, then `run` once and fix whatever the newer engine's preflight rejects. A pipeline written for simple-pipelines 2.x never passes it: split every extract into `<name>_raw` and a parse step (Authoring rules below) and push the split right after the upgrade, before the job runs again, because every run from the upgrade on, scheduled ones included, uses this engine and fails until the split is pushed. A job on a moving tag such as `latest`, or on a digest, is reported as pending and left as it is: `upgrade-runtime` refuses it, and each run reports the engine it started on (`engine` in `inspect`). A job on a newer released image is reported as pending: it runs and accepts pushes, but update the CLI to author what the newer engine added. No job is ever moved down. A dataset declared under `Models/` is created by the engine on the first run, so init and check report a dataset that does not exist yet as pending, not as an error; an extract (`<name>_raw`) stores a payload and a load writes no dataset, so those two stay pending after the first run as well, which is expected; after the first run, rerun `init jobId=<id> force=true` to record the new dataset IDs (a rerun for the same job and folder keeps the setup record, declared config files and author), and the profile's `datasetIds` lists the outputs recorded so far. No published version means read verification stays pending until the first prepared run. The setup record (owner, evidence, checkedAt, retentionDays, otherWritersExcluded=true, runtimeVerified=true) is the owner's statement, not an API-verified fact: do not invent it, and reconfirm it after setup changes. `readyForAcceptance` does not establish source replay, reconciliation or real-client acceptance.
57
+ `check` reads the prepared job, its runner image, whether a newer CLI was released with the tenant's runner image (`cli-version`, pending means update before authoring), and the output manifests, then probes the first Parquet file using signed HTTPS access, or through the API when the CLI runs with an agent turn key, because an agent sandbox can reach only the API. This CLI authors for exactly one engine: the one inside the runner image it was released with. Only jobs already using a Simple Pipelines runner are eligible for image pinning. TypeScript, other runner families and an unknown or inherited image are refused by init, source sync and run; use the existing app tools and preserve the app. The CLI never changes a job's image on its own. A Simple Pipelines job on an older released image is reported as failed: `run`, `pull` and reads still work on its own image, but `push` is refused (`RUNTIME_UPGRADE_REQUIRED`) until the job is upgraded with `upgrade-runtime` (CLI: `farseer pipeline upgrade-runtime`), which moves it to this CLI's image and reports where it moved from. Upgrading changes the engine for everyone on that tenant and, on a scheduled job, for the next scheduled run, so ask the user before upgrading, then `run` once and fix whatever the newer engine's preflight rejects. A pipeline written for simple-pipelines 2.x never passes it: split every extract into `<name>_raw` and a parse step (Authoring rules below) and push the split right after the upgrade, before the job runs again, because every run from the upgrade on, scheduled ones included, uses this engine and fails until the split is pushed. A `main.py` that names no `store_type` writes to Farseer Files on older engines and to datasets on newer ones, so before upgrading such a job, add `store_type=StoreType.FARSEER_FILES` to the local `main.py` unless the user has confirmed it is ready for datasets, and push it right after the upgrade, before the job runs again; an explicit store works on every engine. A job on a moving tag such as `latest`, or on a digest, is reported as pending and left as it is: `upgrade-runtime` refuses it, and each run reports the engine it started on (`engine` in `inspect`). A job on a newer released image is reported as pending: it runs and accepts pushes, but update the CLI to author what the newer engine added. No job is ever moved down. A dataset declared under `Models/` is created by the engine on the first run, so init and check report a dataset that does not exist yet as pending, not as an error; an extract (`<name>_raw`) stores a payload and a load writes no dataset, so those two stay pending after the first run as well, which is expected; after the first run, rerun `init jobId=<id> force=true` to record the new dataset IDs (a rerun for the same job and folder keeps the setup record, declared config files and author), and the profile's `datasetIds` lists the outputs recorded so far. No published version means read verification stays pending until the first prepared run. The setup record (owner, evidence, checkedAt, retentionDays, otherWritersExcluded=true, runtimeVerified=true) is the owner's statement, not an API-verified fact: do not invent it, and reconfirm it after setup changes. `readyForAcceptance` does not establish source replay, reconciliation or real-client acceptance.
58
58
 
59
59
  ## Authoring rules
60
60
 
61
61
  Extract: one step per source extraction, named `<name>_raw`, separate from the parse step that reads it and the transformation that reshapes it. It stores what the source hands over, unread, as a payload (a file source's file as it came, a typed source's rows as parquet), so it carries no `parse:`, `schema:`, quality rules, `write_mode` or `merge_keys`. Read another pipeline's or this pipeline's published dataset with `extract.type: farseer`, `source: datasets` and the dataset's `qualified_name` (optionally pinned to a `version_id`). Never add a `farseer_credentials` block; the pipeline always uses the tenant it runs in.
62
62
 
63
+ A source with no built-in type: a plain HTTP(S) API is `extract.type: http` (`HttpExtractConfig`): a URL and `params`, credentials only under `auth:`, and `records:` plus `pagination:` for an API that pages JSON. It needs no code, so use it whenever it can express the source. Anything it cannot express is `extract.type: custom` (`CustomExtractConfig`): an `@extractor` function in `Code/`, one script per connector, configured through `args:` and handed credentials through `secrets:`; it returns a file it wrote, records or a table, and the parse step reads that as for any extract. Fetch through the `http` client it is handed, not a library of its own, which skips the network guard and token masking, and for a large or paged source `yield` records or stream a file with `http.download`: a returned list or table holds the whole source in memory. Never call an API from a `@transform`: it skips the payload, `optional:` and the extract-then-parse checks. A 404 and an empty answer fail the step unless the YAML says they mean missing data (`not_found: missing`, `empty: missing`, or `ExtractionSourceMissing` from an `@extractor`); only then does `optional: true` skip it.
64
+
63
65
  Parse: a `type: parse` step named `<name>` with `deps: [<the extract>]` reads the payload into the dataset. It names exactly one of `parse.format` (`csv`, `xlsx`, `json` or `parquet`; `parquet` for a source that hands back rows rather than a file, such as `sql_database`, `business_central` or `source: datasets`) or `parse.script` (an `@parse` function in `Code/`), with read options in the block named for the format, such as `csv: {decimal: ","}`. The parse step carries the dataset's `schema:`, quality rules and `write_mode`/`merge_keys`. Every extract must be read by a parse step, and only a parse step may read an extract: a transform, load or export with an extract in its `deps` fails the run before any step executes.
64
66
 
65
67
  Transform: choose SQL first (`engine: duckdb` with inline `transform.query`, never a SQL file), then `engine: ibis` with an `@ibis_transform` script when the logic needs Python to compose, and `engine: python` (`@transform`, pandas) only for work with no lazy form, because it is the one surface that holds whole frames in memory. Always write `engine:`; the default is `python`. Section 3 of `topic=practices` has the rules. A script transform names its `Code/` script in `transform.script`; missing code, compile errors and invalid definitions fail before extraction when the pipeline policy is enabled. Declare `deps`, add quality checks, and reconcile the agreed business scope. Folder names under `Models/` become dataset namespaces. Output versions are candidates until published, failed quality checks do not publish the failed candidate, and publication is per dataset, so a later failure can leave earlier effects in place.
@@ -10,14 +10,15 @@ A pipeline is three things in a folder: `main.py`, `Models/` (one YAML per step)
10
10
  |---|---|---|
11
11
  | `main.py` | Argument checks and canonical spellings, then one `run_pipeline()` call with `store_type=StoreType.DATASETS` and `pipeline_policy=PipelinePolicy()` | Data reads, business logic, API calls, starting other jobs |
12
12
  | `Models/<layer>/<name>.yaml` | One step: its `type`, `deps` and its block, with `schema` and `quality_rules` on a parse step or transform, and a load or export mapping on a load or export. Or one `expand:` fan-out over one axis | Copies per company or period; two run cadences in one folder (use two pipeline folders) |
13
- | `extract` block | How to reach the source: connector, the source-side filter and columns, `optional` for a source that may genuinely be missing. The step, named `<name>_raw`, stores what the source hands over unread: a file source's file as it came, a typed source's rows as parquet | Anything that reads or checks the data: `parse`, `schema`, `quality_rules`, `write_mode`, `merge_keys`. Reshaping; reading another pipeline's output through `deps`; credentials |
13
+ | `extract` block | How to reach the source: connector (a plain HTTP(S) API is `type: http`, no code), the source-side filter and columns, `optional` for a source that may genuinely be missing. The step, named `<name>_raw`, stores what the source hands over unread: a file source's file as it came, a typed source's rows as parquet | Anything that reads or checks the data: `parse`, `schema`, `quality_rules`, `write_mode`, `merge_keys`. Reshaping; reading another pipeline's output through `deps`; credentials |
14
14
  | `parse` step (`type: parse`, `deps: [<the extract>]`) | How to read the extract's file into the dataset `<name>`: `format` (or a `script`) and, in the block named for the format (`csv:`, `xlsx:`, `json:`), encoding, separator, decimal, header, start row, positional columns. Every extract has one, and only a parse step reads an extract | What the values should be: no fixing, mapping or filtering |
15
15
  | `schema` | The dataset's column contract: every column it keeps, with `type` and `not_null` | Reshaping |
16
16
  | `quality_rules` | What the values must mean, on parse and transform steps | Comparisons between datasets (write a reconciliation transform) |
17
17
  | SQL transform (`engine: duckdb`, `query`) | All set-based work: filter, join, map, aggregate, reshape, final casts | Procedural row-by-row logic |
18
18
  | `@ibis_transform` (`engine: ibis`, `script`) | Logic that needs Python to compose, still streaming | DataFrames, `.to_pandas()`, `.execute()` |
19
19
  | `@transform` (`engine: python`, `script`) | Only work with no lazy form | Set-based work; I/O, environment reads, the clock |
20
- | `Code/` | One script per transform function; a function shared by many datasets through `transform.function` and `transform.args` | Helper modules imported across scripts: each script runs on its own |
20
+ | `@extractor` (`extract.type: custom`, `script`) | Reaching a source no built-in type can: the requests, their auth and paging, returning a file it wrote, records or a table. Configuration from `args`, credentials from `secrets` | Reading or fixing the data (that is the parse step and transforms); credentials in `args` or in the script |
21
+ | `Code/` | One script per transform function; a function shared by many datasets through `transform.function` and `transform.args`; one script per custom connector | Helper modules imported across scripts: each script runs on its own |
21
22
  | `load` block | Column-to-model mapping, labels, import options | Any logic. To change a number, change a transform |
22
23
  | `export` block | File target, format, conflict behaviour | Shaping |
23
24
  | Files | Mapping tables, read with a `source: files` extract and its parse step, and joined in SQL | |
@@ -40,7 +41,7 @@ Start from the target. Before any YAML, write down each variable the pipeline fi
40
41
  - **Qualified names are shared by every pipeline on the tenant.** Name datasets after their subject (`bronze.erp_sales_lines`, not `bronze.lines`), so two pipelines never write the same dataset.
41
42
  - **Leaf names must be unique within one step's `deps`.** SQL sees each dependency as a view named by its leaf, and Python sees it as a parameter named by its leaf.
42
43
  - **Read another pipeline's output** with `extract.type: farseer`, `source: datasets` and its `qualified_name`, and a parse step with `format: parquet` that reads the extract. It reads the last published version, and there is no ordering between pipelines.
43
- - **Keep `StoreType.DATASETS`** unless the pipeline accumulates data (section 8). `FARSEER_FILES`, the engine default, publishes on write and keeps no versions.
44
+ - **Keep `StoreType.DATASETS`** unless the pipeline accumulates data (section 8). `FARSEER_FILES` publishes on write and keeps no versions.
44
45
 
45
46
  ## 3. Transforms: SQL, then ibis, then pandas
46
47
 
@@ -246,9 +247,9 @@ Storage choices are the hardest to undo. A dataset's store and file format are f
246
247
 
247
248
  | Store | What it does | Use for | Never |
248
249
  |---|---|---|---|
249
- | `DATASETS` | Versioned datasets in the registry. A run writes candidates, which become visible only when published | Almost everything: any dataset rebuilt whole each run and read downstream | Incremental extraction: a cursor is refused |
250
+ | `DATASETS` (the engine default after 3.1.0) | Versioned datasets in the registry. A run writes candidates, which become visible only when published | Almost everything: any dataset rebuilt whole each run and read downstream | Incremental extraction: a cursor is refused |
250
251
  | `ICEBERG` (experimental) | One Iceberg table per dataset. Each run writes on its own branch, frozen as a tag when complete | Datasets that accumulate: `append`, `upsert`, incremental SQL extracts | Data that a full rebuild each run would serve as well |
251
- | `FARSEER_FILES` (the engine default) | One file per dataset under the pipeline's `Data/` folder. Saving is publishing; there are no versions | Ad hoc output nobody else reads | Anything read downstream: a failing run has already replaced the file |
252
+ | `FARSEER_FILES` | One file per dataset under the pipeline's `Data/` folder. Saving is publishing; there are no versions | Ad hoc output nobody else reads | Anything read downstream: a failing run has already replaced the file |
252
253
 
253
254
  - **An incremental source gets its own pipeline folder on `ICEBERG`,** holding its extract and the one parse step that reads it. Everything that consumes it lives in a `DATASETS` pipeline and reads the parse step's dataset with `source: datasets`. That keeps the experimental store to the datasets that need it.
254
255
  - **A dataset never changes store.** A run that names a dataset on the wrong store creates it there. For example, a cursor on `DATASETS` is refused only after the dataset exists. Moving it to `ICEBERG` afterwards is refused too, so give the dataset a new name.