farseer-cli 1.22.0 → 1.24.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.
- package/README.md +3 -1
- package/dist/commands/code.js +23 -0
- package/dist/commands/code.js.map +2 -2
- package/dist/commands/skills.js +110 -7
- package/dist/commands/skills.js.map +1 -1
- package/dist/commands/views.js +116 -0
- package/dist/commands/views.js.map +6 -0
- package/dist/index.js +12 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp/tools/dashboardTools.js +1 -1
- package/dist/operations/views.js +79 -0
- package/dist/operations/views.js.map +6 -0
- package/dist/pipeline/create.js +1 -1
- package/dist/pipeline/generated-reference.json +6 -6
- package/dist/services/codefirst/workflow.js +3 -3
- package/dist/services/codefirst/workflow.js.map +1 -1
- package/dist/services/farseerService.js +10 -1
- package/dist/services/farseerService.js.map +1 -1
- package/dist/services/httpError.js +2 -1
- package/dist/services/httpError.js.map +1 -1
- package/dist/skills/install.js +221 -8
- package/dist/skills/install.js.map +2 -2
- package/dist/skills/userSkills.js +206 -0
- package/dist/skills/userSkills.js.map +6 -0
- package/dist/skills/workspaceSkills.js +213 -0
- package/dist/skills/workspaceSkills.js.map +6 -0
- package/docs/cli-guide.md +25 -1
- package/docs/pipeline-reference.md +1 -1
- package/package.json +1 -1
- package/skills/farseer-app-dev/SKILL.md +2 -2
- package/skills/farseer-app-dev/assignments.md +1 -1
- package/skills/farseer-app-dev/farseer-client-release-notes.md +13 -1
- package/skills/farseer-app-dev/working-patterns.md +30 -5
- package/skills/farseer-author-import-job/SKILL.md +20 -3
- package/skills/farseer-author-import-job/cell-writes.md +26 -6
- package/skills/farseer-author-import-job/deploying-a-farseer-app.md +117 -12
- package/skills/farseer-author-import-job/import-job-pattern.md +111 -13
- package/skills/farseer-build-model/SKILL.md +3 -2
- package/skills/farseer-build-model/formula-grain-alignment.md +186 -31
- package/skills/farseer-build-model/naming-conventions.md +5 -2
- package/skills/farseer-build-model/sparse-formulas-pattern.md +30 -11
- package/skills/farseer-build-pipeline/SKILL.md +36 -1
- package/skills/farseer-build-pipeline/erp-sales/README.md +8 -0
- package/skills/farseer-build-pipeline/erp-sales/erp-sales-etl/main.py +1 -1
- package/skills/farseer-build-pipeline/erp-sales/erp-sales-load/main.py +1 -1
- package/skills/farseer-build-pipeline/pipeline-app-failure-report-pattern.md +9 -6
- package/skills/farseer-modify-model/SKILL.md +3 -2
- package/skills/farseer-modify-model/model-validation-pattern.md +11 -3
- package/skills/farseer-page-context/SKILL.md +69 -0
- package/skills/farseer-review-model/SKILL.md +39 -8
- package/skills/pipeline-authoring/SKILL.md +3 -3
- package/skills/pipeline-authoring/practices.md +5 -3
|
@@ -248,7 +248,7 @@ const newFolderId = result.id ?? result.folderId;
|
|
|
248
248
|
|
|
249
249
|
`allowedTypes` is required and must respect the parent's constraints. A folder under Variables must allow `VARIABLE` (and typically `FOLDER` for nesting). A folder under Dimensions must allow `DIMENSION_TABLE` (and `FOLDER`). Mixing — e.g. trying to allow `DIMENSION_TABLE` under the Variables tree — fails with `"Invalid allowed types"`.
|
|
250
250
|
|
|
251
|
-
**Folder names
|
|
251
|
+
**Folder names are not globally unique.** Measured 2026-11-05 on a sandbox tenant: the same folder name was accepted in each of the four folder trees. A tree name must be unique within its parent folder, and a folder cannot take the name of a variable in the same parent — both answer `400 BadRequest "Name already taken"`. Whether one name may repeat under two parents of the same tree was not measured. If a folder of the desired name already exists under the parent you want, search and reuse it instead of creating a duplicate:
|
|
252
252
|
|
|
253
253
|
```typescript
|
|
254
254
|
const found = await client.entities.search({ name: "Import", types: ["FOLD"] });
|
|
@@ -304,7 +304,7 @@ When refactoring a model — e.g. unifying naming style on an existing tenant
|
|
|
304
304
|
|
|
305
305
|
**Wrong approaches that look right:**
|
|
306
306
|
|
|
307
|
-
- `client.folders.renameItem({ id, name })` — fails with `400 BadRequest "Requested item is not a folder"` for variables and dim tables. The endpoint
|
|
307
|
+
- `client.folders.renameItem({ id, name })` — fails with `400 BadRequest "Requested item is not a folder"` for variables and dim tables (for every item type but a folder). The endpoint renames folders themselves only, despite "item" in the name.
|
|
308
308
|
- `client.model.load(...)` with the new name and `clear: false` — creates a new variable / dim alongside the old one. Old entity remains, old cell data stays attached to it; new entity is empty. Net effect: orphans + duplicated work.
|
|
309
309
|
|
|
310
310
|
**Right approach — `entities.mutate` with `EntityUpdate.meta.name`:**
|
|
@@ -332,6 +332,11 @@ await client.entities.mutate({
|
|
|
332
332
|
|
|
333
333
|
The platform preserves the entity ID, all cell data, and updates internal references in formulas and dependencies. No orphan, no data loss.
|
|
334
334
|
|
|
335
|
+
**A file in Farseer Files** is an entity of type `FILE`, renamed the same way:
|
|
336
|
+
`entities.mutate` with `type: "FILE"` and `meta.name`. `PUT /farseerFiles/{uuid}`
|
|
337
|
+
with a new filename keeps the old name. The minimal payload is safe for `FILE`
|
|
338
|
+
only (the backend reads just `id` and `meta.name`).
|
|
339
|
+
|
|
335
340
|
### Why include `description` in the mutate
|
|
336
341
|
|
|
337
342
|
The `MetaComponent` shape has `name` and `description` as required fields when emitted. If you set `meta: { name: newName }` and omit the description, the platform may overwrite it with null. Always read the existing description first and pass it through (or pass the new description if you intend to change it). Same for any other meta-level fields (notes, etc.) the entity carries.
|
|
@@ -452,7 +457,7 @@ shape. **When to use import:**
|
|
|
452
457
|
`DIMENSION_TABLE` + per-`VARIABLE` columns map naturally onto
|
|
453
458
|
spreadsheet/CSV shapes.
|
|
454
459
|
- **Anything you want labelled** so QA / the customer can find and review it
|
|
455
|
-
later (e.g. `labels: ["
|
|
460
|
+
later (e.g. `labels: ["actuals_load", "2025_Q4"]` — `[A-Za-z0-9_-]` only).
|
|
456
461
|
|
|
457
462
|
### Quick decision table
|
|
458
463
|
|
|
@@ -487,7 +492,7 @@ const importJob = await client.createImportJob({
|
|
|
487
492
|
{ type: "VARIABLE", variableName: "Revenue" },
|
|
488
493
|
{ type: "VARIABLE", variableName: "Cost" },
|
|
489
494
|
],
|
|
490
|
-
labels: ["automated", "
|
|
495
|
+
labels: ["automated", "source_x"],
|
|
491
496
|
});
|
|
492
497
|
|
|
493
498
|
for (const row of sourceData) {
|
|
@@ -517,6 +522,13 @@ await importJob.commit();
|
|
|
517
522
|
> [`cell-writes.md`](../farseer-author-import-job/cell-writes.md) for the `metadata`-based escape hatch that flips
|
|
518
523
|
> both flags.
|
|
519
524
|
|
|
525
|
+
> **Financial year.** The overload sends no `ignoreFinancialYearOffset` either. On a tenant
|
|
526
|
+
> whose financial year starts in month S ≠ 1 the platform reads `Years`/`Months` as calendar
|
|
527
|
+
> periods and files every cell S − 1 months earlier; a month fixed in `dimensionsNames` (next
|
|
528
|
+
> section) shifts too. Rows that carry the tenant's own periods (copies of values read from a
|
|
529
|
+
> tenant) need the flag set through the `metadata` overload:
|
|
530
|
+
> [`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).
|
|
531
|
+
|
|
520
532
|
## Import data — dimension discrimination
|
|
521
533
|
|
|
522
534
|
When one variable is populated from multiple source columns that each represent a different dimension slice:
|
|
@@ -539,7 +551,7 @@ for (const row of sourceData) {
|
|
|
539
551
|
await importJob.commit();
|
|
540
552
|
```
|
|
541
553
|
|
|
542
|
-
|
|
554
|
+
A `VARIABLE` column is pinned with `dimensionsNames: [{ tableName, memberName }]`. There is no `tables` field: the SDK silently ignores it (checked 2026-11-09 against farseer-client on dev and on a sandbox tenant) and the column then writes without the pin. To check it before the job exists, build the metadata with `client.buildImportJobMetadata(columns)`: `columnMetas[i].applyTagsIds` must contain the member id next to the variable id. Then create the job from it with `createImportJob({ title, metadata, labels })`.
|
|
543
555
|
|
|
544
556
|
## Log progress on large imports
|
|
545
557
|
|
|
@@ -662,6 +674,17 @@ works fine.
|
|
|
662
674
|
same `id`-vs-`reference` split documented elsewhere for sheets/folder items
|
|
663
675
|
applies to uploaded files too.
|
|
664
676
|
|
|
677
|
+
## Reading a file back — by `reference`, not through `downloadUrl`
|
|
678
|
+
|
|
679
|
+
`GET /farseerFiles/{reference}/downloadUrl` signs a URL only for a file in
|
|
680
|
+
object storage; a file the tenant keeps in the database (an app script, for
|
|
681
|
+
example) answers 404 "No download URL available…" (read in source). Read
|
|
682
|
+
the content with `GET /farseerFiles/{reference}`: SDK
|
|
683
|
+
`client.farseerFiles.get(uuid)` returns a `Blob`. The id is the folder item's
|
|
684
|
+
`reference` (a uuid); a numeric id answers 400. This route buffers the whole
|
|
685
|
+
file, which is fine for a script; take the `downloadUrl` of a large file in
|
|
686
|
+
object storage. Don't `farseer pull` a whole tenant to read one script.
|
|
687
|
+
|
|
665
688
|
## Registering an uploaded script as a remote-job app — `remoteJobs.create`
|
|
666
689
|
|
|
667
690
|
```ts
|
|
@@ -730,6 +753,8 @@ first. The traps:
|
|
|
730
753
|
exist.
|
|
731
754
|
- `SheetsApi` has **no** delete / remove method (create / update /
|
|
732
755
|
duplicate / setData / getData / search / get / getByIds — no delete).
|
|
756
|
+
REST `DELETE /sheets/{id}` answers **405** `MethodNotAllowed`
|
|
757
|
+
(2026-11-06).
|
|
733
758
|
|
|
734
759
|
Sheets are **folder items** in the Sheets tree. The Folders API deletes
|
|
735
760
|
them by folder-item id:
|
|
@@ -3,7 +3,7 @@ name: farseer-author-import-job
|
|
|
3
3
|
description: >-
|
|
4
4
|
Use when the user asks to fix, extend, or review an EXISTING TypeScript import app — anything using `createImportJob` to push recurring data (GL actuals, source extracts, version copies) into a model, or double-counted / overwritten numbers after a re-import. NEW recurring imports are Simple Pipelines: use `farseer-build-pipeline` instead. Enforces locked `IMPORT_` targets, argument-driven design, and scope-encoding labels so re-runs are idempotent (revert-prior-then-apply). Does NOT cover one-off test seeding (use Insert) or app deployment mechanics (see deploying-a-farseer-app). Triggers (match by MEANING, in ANY language): "write an import job", "import GL actuals", "load data into the model".
|
|
5
5
|
metadata:
|
|
6
|
-
version: "
|
|
6
|
+
version: "2"
|
|
7
7
|
domain: modeling
|
|
8
8
|
---
|
|
9
9
|
|
|
@@ -56,7 +56,7 @@ INSERT, `model.updateCells` in [`cell-writes.md`](cell-writes.md): every grain d
|
|
|
56
56
|
### 3. Build labels that encode the run's scope
|
|
57
57
|
- Labels = exactly the slice this run owns. GL load for Jan 2025 → `["GL","2025","1"]`.
|
|
58
58
|
Version-specific / copy jobs add the version and source→target:
|
|
59
|
-
`["
|
|
59
|
+
`["fc_preparation","Plan","Y2025","<src>2<tgt>"]` — `[A-Za-z0-9_-]` only.
|
|
60
60
|
- These labels are the **idempotency key** — the re-run locates its own prior run
|
|
61
61
|
by label match. Get them wrong and re-imports duplicate.
|
|
62
62
|
|
|
@@ -64,7 +64,8 @@ INSERT, `model.updateCells` in [`cell-writes.md`](cell-writes.md): every grain d
|
|
|
64
64
|
Prefer the **reversible** primitive so the scope is never left empty:
|
|
65
65
|
```ts
|
|
66
66
|
const job = await c.createImportJob({ title, labels, columns /* or metadata */ });
|
|
67
|
-
|
|
67
|
+
for (let s = 0; s < rows.length; s += 10000) await job.addRows(rows.slice(s, s + 10000));
|
|
68
|
+
await job.flushRows(); // ≤10k rows per addRows call: ~100k+ in one call overflows
|
|
68
69
|
await job.detectDimensions(); await job.importDimensions();
|
|
69
70
|
// list() returns every job whose labels include these, newest first: keep the exact label set.
|
|
70
71
|
const same = (l: string[] = []) => l.length === labels.length && labels.every(x => l.includes(x));
|
|
@@ -82,6 +83,22 @@ Use `undoPrevious()` / `deleteById(id, {undoData:true})` only when the prior cel
|
|
|
82
83
|
genuinely should be destroyed — it cannot be rolled back.
|
|
83
84
|
- `addRow([...])` value order **must** match the `columns` array order — the #1 cause
|
|
84
85
|
of silently-wrong imports.
|
|
86
|
+
- There is no row limit per job, and the commit report counts only the backend's
|
|
87
|
+
last 10,000-row write batch: verify a large job by re-reading the tenant (total per slice)
|
|
88
|
+
([`import-job-pattern.md` §1a](import-job-pattern.md#1a-mechanics-that-bite-at-scale)).
|
|
89
|
+
|
|
90
|
+
### 4a. Financial year — set `ignoreFinancialYearOffset` by where the periods come from
|
|
91
|
+
- On a tenant whose financial year does not start in January (`GET /settings`
|
|
92
|
+
→ `financial_year_starting_month` ≠ 1), an import job reads the
|
|
93
|
+
`Years`/`Months` of its rows as calendar periods and maps them to fiscal
|
|
94
|
+
ones, unless its metadata sets `ignoreFinancialYearOffset: true`.
|
|
95
|
+
- Rows that carry the tenant's own periods (version copies, values read from
|
|
96
|
+
a tenant) → `true`; a calendar-dated GL / ERP feed → leave it `false`. The
|
|
97
|
+
SDK's `columns` overload sends no flag: build the metadata and set it.
|
|
98
|
+
- A Simple Pipeline always sends the flag as `true`, so a new import (or a
|
|
99
|
+
requested migration of this app) converts calendar dates to fiscal periods
|
|
100
|
+
in the pipeline itself ([`farseer-build-pipeline`](../farseer-build-pipeline/SKILL.md) step 3b).
|
|
101
|
+
- Details and a probe: [`import-job-pattern.md` §6](import-job-pattern.md#6-financial-year-an-import-job-maps-calendar-periods-to-fiscal-ones).
|
|
85
102
|
|
|
86
103
|
### 5. Deployment — arguments + secret credentials
|
|
87
104
|
- Instantiate the run's arguments (period/year/version) rather than baking them in.
|
|
@@ -38,6 +38,7 @@ The decision table:
|
|
|
38
38
|
| Recurring nightly ETL feed | **IMPORT** |
|
|
39
39
|
| Cross-version copy (Actual → Plan) | **IMPORT** (export-formula → row-import) |
|
|
40
40
|
| Mass clear of cells under a filter | **`/sheets/setData`** with `value: null` |
|
|
41
|
+
| Clear stored (typed-over) cells on a formula variable | **INSERT** with `value: null` — `farseer cells update --input clear.json -y` (CLI ≥ 1.20.0) or `model.updateCells` |
|
|
41
42
|
|
|
42
43
|
(Reminder: INSERT pins its cell in the **selector formula** — every grain
|
|
43
44
|
dimension at a leaf, `filters: []`. It is the `filters` field that misbehaves:
|
|
@@ -157,7 +158,7 @@ const importJob = await client.createImportJob({
|
|
|
157
158
|
{ type: "DIMENSION_TABLE", dimensionTableName: "Account", columnName: "Account" },
|
|
158
159
|
{ type: "VARIABLE", variableName: "IMPORT_GL_Period_activity_net" },
|
|
159
160
|
],
|
|
160
|
-
labels: ["
|
|
161
|
+
labels: ["actuals_load", "2025_Q4"], // [A-Za-z0-9_-] only
|
|
161
162
|
});
|
|
162
163
|
|
|
163
164
|
for (const row of sourceData) {
|
|
@@ -285,8 +286,20 @@ variables, and `value: null` in it clears a cell.
|
|
|
285
286
|
|
|
286
287
|
**`farseer cells query` reads through `/evaluate`, and `farseer cells update`
|
|
287
288
|
writes through `/model/updateCells`** (it previews the slice it writes unless
|
|
288
|
-
`-y` is given).
|
|
289
|
-
|
|
289
|
+
`-y` is given). `--input <file>` takes a JSON array of
|
|
290
|
+
`{variable, dimensions, value}` entries and sends them in one request;
|
|
291
|
+
`value: null` (or `--clear` on a single entry) clears a cell. A write
|
|
292
|
+
addresses a slice, not a cell: a dimension an entry leaves out would be
|
|
293
|
+
written on every member, Versions included, so name every grain dimension
|
|
294
|
+
(the CLI refuses an unnamed one unless `--across` names it). Measured on a
|
|
295
|
+
sandbox tenant (2026-W46): one `--input` request with `null` entries cleared
|
|
296
|
+
every stored cell of a formula variable, after
|
|
297
|
+
`farseer variables update --name "<Var>" --no-readonly`; make it `--readonly`
|
|
298
|
+
again afterwards.
|
|
299
|
+
|
|
300
|
+
Only the legacy `/cells/query` and `/cells/update` routes
|
|
301
|
+
answer **HTTP 501 Not Implemented**; CLI 1.19.0 and older called them, so
|
|
302
|
+
their `cells` commands never wrote anything. Always verify cell writes by reading
|
|
290
303
|
the written cells back ([Verifying writes](#verifying-writes--read-back-count-and-assert)).
|
|
291
304
|
|
|
292
305
|
These are not payload-shape problems — same payload, same headers, same
|
|
@@ -450,6 +463,8 @@ Q1F). Use **export-formula + import-job**, **not** `cells.copyAllCells`
|
|
|
450
463
|
(see the VERIFY note below).
|
|
451
464
|
|
|
452
465
|
```typescript
|
|
466
|
+
const slug = (s: string) => s.replace(/[^A-Za-z0-9]+/g, "_");
|
|
467
|
+
|
|
453
468
|
// 1) Read source via formula export
|
|
454
469
|
const blob = await client.export.exportFormula({
|
|
455
470
|
formula: `sum("${varName}", "Y${year}", "Versions">"${sourceVersion}")`,
|
|
@@ -469,14 +484,19 @@ const job = await client.createImportJob({
|
|
|
469
484
|
columnMetas: [
|
|
470
485
|
/* identifier dim columns + value column tagged with applyTagsIds */
|
|
471
486
|
],
|
|
472
|
-
handleMissingTags: "DISALLOW", // or "USE_DEFAULT" / "SKIP_ROW"
|
|
487
|
+
handleMissingTags: "DISALLOW", // or "USE_DEFAULT" / "SKIP_ROW" (HandleMissingTags enum)
|
|
473
488
|
importZeros: false,
|
|
474
489
|
overwriteCells: true,
|
|
490
|
+
// The rows carry this tenant's own periods (read from it): no calendar →
|
|
491
|
+
// fiscal mapping on a non-January financial year (import-job-pattern.md §6).
|
|
492
|
+
ignoreFinancialYearOffset: true,
|
|
475
493
|
},
|
|
476
|
-
|
|
494
|
+
// a label is [A-Za-z0-9_-] only: sanitise names, never pass them raw
|
|
495
|
+
labels: ["fc_preparation", slug(targetVersion), `Y${year}`, slug(varName)],
|
|
477
496
|
});
|
|
478
497
|
|
|
479
|
-
// addRows in chunks of ≤
|
|
498
|
+
// addRows in chunks of ≤ 10k (above ~100k one call overflows)
|
|
499
|
+
// → flushRows → undoPrevious → importDimensions → commit
|
|
480
500
|
// Wrap commit in retry-with-backoff (3 attempts).
|
|
481
501
|
```
|
|
482
502
|
|
|
@@ -172,8 +172,13 @@ farseer push <tenant> -y
|
|
|
172
172
|
local change under `farseer-apps/<tenant>/` (other apps, other scripts).
|
|
173
173
|
Since CLI 1.10.0, `farseer push <tenant> --only Scripts/<file>` (repeatable,
|
|
174
174
|
paths relative to the tenant's files folder) pushes just those files and
|
|
175
|
-
leaves other local edits
|
|
176
|
-
|
|
175
|
+
leaves other local edits and remote-only files alone (measured twice on
|
|
176
|
+
CLI 1.14.2, 2026-10-21). It **never pushes an app manifest**
|
|
177
|
+
(`apps/<Name>.json`; `farseer status` keeps listing the app as modified).
|
|
178
|
+
Ship a changed description without a full push with `farseer app configure
|
|
179
|
+
<tenant> "<App>" --description "<text>"`, which changes only the
|
|
180
|
+
description (measured: arguments, entrypoint, runner and image unchanged,
|
|
181
|
+
`farseer status` in sync). Run `farseer status <tenant>` first either way.
|
|
177
182
|
|
|
178
183
|
### 4. Verify — don't trust, confirm
|
|
179
184
|
|
|
@@ -191,6 +196,21 @@ farseer push <tenant> -y
|
|
|
191
196
|
arguments and a scheduled run with no arguments takes the defaults, so
|
|
192
197
|
neither exercises the read path (see below).
|
|
193
198
|
|
|
199
|
+
### 5. When a run fails — read its log
|
|
200
|
+
|
|
201
|
+
No CLI command shows an app's run log. The SDK does:
|
|
202
|
+
`client.remoteJobRuns.listByRemoteJobId(<appId>)` returns every run with its
|
|
203
|
+
`id`, `startedAt`, `status`, the `user` who started it and the full `logs[]`.
|
|
204
|
+
The app id is the manifest's `_remote.id`. Put such a read-only probe in
|
|
205
|
+
`farseer-apps/<tenant>/files/Scripts/` and run it with `farseer run-script <tenant>
|
|
206
|
+
<file>.ts`, which gives it the tenant's credentials; delete the file before the
|
|
207
|
+
next full `farseer push`.
|
|
208
|
+
|
|
209
|
+
A run started from the UI can sit in "Accepted by backend; awaiting runner
|
|
210
|
+
observation" for up to a minute before a runner picks it up (field report,
|
|
211
|
+
2026-10-20). An empty import-job list checked within that minute does not mean
|
|
212
|
+
nothing ran; read the run log first.
|
|
213
|
+
|
|
194
214
|
---
|
|
195
215
|
|
|
196
216
|
## Organising the Apps sidebar with folders
|
|
@@ -253,7 +273,7 @@ Declare arguments in `apps/<Name>.json` and push:
|
|
|
253
273
|
them in the manifest or in the UI (App → Edit argument → Options).
|
|
254
274
|
- **Do not create or update apps with `client.remoteJobs.create/update` on
|
|
255
275
|
SDK ≤ 1.8.12** (the version older CLIs wrote into the tenant folder's
|
|
256
|
-
`package.json
|
|
276
|
+
`package.json`; this CLI writes 1.18.1,
|
|
257
277
|
and `farseer pull` / `farseer install` move an older CLI-written pin forward). Its serializer drops
|
|
258
278
|
`dataType`, `options` and `fixed` and sends only the legacy
|
|
259
279
|
`type: variable|constant`. The platform reads `constant` as
|
|
@@ -277,7 +297,7 @@ Declare arguments in `apps/<Name>.json` and push:
|
|
|
277
297
|
| Runtime | Arguments arrive as | Notes |
|
|
278
298
|
|---|---|---|
|
|
279
299
|
| **Tenant runner** (UI, API, schedule) | `FARSEER_ARGS` = JSON object keyed by the **exact manifest names** | server validates first (below); positional argv also carries the values — never read it |
|
|
280
|
-
| **Local `farseer run <tenant> "<App>"`** | **positional argv only**, no `FARSEER_ARGS` | values passed through a shell: split on spaces (`"one two"` → 2 argv items), `""` dropped (later positions shift — §1b), shell syntax interpreted (`;` ends the command, `$VAR` expands). Override names are matched case-sensitively; an unknown name is ignored and the default used.
|
|
300
|
+
| **Local `farseer run <tenant> "<App>"`** | **positional argv only**, no `FARSEER_ARGS` | values passed through a shell: split on spaces (`"one two"` → 2 argv items), `""` dropped (later positions shift — §1b), shell syntax interpreted (`;` ends the command, `$VAR` expands). Override names are matched case-sensitively; an unknown name is ignored and the default used. |
|
|
281
301
|
| **Local `farseer run-script`** | **nothing** — no argv, no per-argument env vars | only env vars you exported in your shell reach the script |
|
|
282
302
|
| **Local, `FARSEER_ARGS` exported by you** — `FARSEER_ARGS='{"Year":"2026"}' farseer run <tenant> "<App>"` | `FARSEER_ARGS` exactly as you wrote it (measured: byte-identical, including a value with a space and an escaped quote) | **the supported local way to exercise the read path.** Nothing is merged locally: an argument missing from the blob is **absent** (the server would fill its default), and `""` stays `""` (the server would replace it by the default) — spell every argument out. A `--arg` override changes argv only, never the blob |
|
|
283
303
|
|
|
@@ -307,25 +327,72 @@ dropdown an explicit "all / not set" option (plain identifier, no spaces) as
|
|
|
307
327
|
its default, send that instead of `""`, send canonical forms (`"8"`, not
|
|
308
328
|
`"08"`), and log the response body of every run call.
|
|
309
329
|
|
|
330
|
+
**From Python, the SDK's names are not the TypeScript SDK's.** The Python
|
|
331
|
+
package's endpoints live in `farseer_client.generated.api` (singular), and
|
|
332
|
+
the run body is `RemoteJobsRunRequest`:
|
|
333
|
+
|
|
334
|
+
```python
|
|
335
|
+
from farseer_client import FarseerClient
|
|
336
|
+
from farseer_client.generated import RemoteJobsRunRequest
|
|
337
|
+
|
|
338
|
+
with FarseerClient() as client:
|
|
339
|
+
client.remote_jobs.run(app_id, RemoteJobsRunRequest(arguments=[...]))
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
Code ported from TypeScript (`generated.apis`, `RemoteJobRunBody`) fails with
|
|
343
|
+
`ModuleNotFoundError` on every run. This is not an old-version quirk: the SDK
|
|
344
|
+
in the Python Simple Pipelines image (1.8.6) and the Python SDK on Farseer's
|
|
345
|
+
`dev` (1.30.0) have the same names. When an import chains another app, wrap
|
|
346
|
+
the run call in `try/except`, so a failed chain never fails the import that
|
|
347
|
+
started it, and log the response body, so the failure is visible in the run
|
|
348
|
+
log instead of silent.
|
|
349
|
+
|
|
310
350
|
### Environment the script sees
|
|
311
351
|
|
|
312
|
-
| | Local `farseer run` / `run-script` (measured) | Tenant runner (job-runner source
|
|
352
|
+
| | Local `farseer run` / `run-script` (measured) | Tenant runner (measured on a Python Simple Pipelines runner; matches the job-runner source) |
|
|
313
353
|
|---|---|---|
|
|
314
|
-
| tenant | `TENANT_ID` = the tenant **slug** | `TENANT_ID` |
|
|
315
|
-
| URL | `FARSEER_URL` (`https://<org>.farseer.io/api/v3`) | `FARSEER_URL` |
|
|
316
|
-
| credential | `FARSEER_TOKEN` (browser login) **or** the API-key variable (api-key mode) — mutually exclusive | the API-key variable |
|
|
317
|
-
| job identity | — | `JOB_NAME` (the app's name), `JOB_UUID` (this run), `SOURCE_FOLDER_ID` |
|
|
354
|
+
| tenant | `TENANT_ID` = the tenant **slug** | `TENANT_ID` = the tenant **slug** |
|
|
355
|
+
| URL | `FARSEER_URL` (`https://<org>.farseer.io/api/v3`) | `FARSEER_URL` = `https://<org>.farseer.io`, **without `/api/v3`** |
|
|
356
|
+
| credential | `FARSEER_TOKEN` (browser login) **or** the API-key variable (api-key mode) — mutually exclusive | the API-key variable, the **tenant's** key, not the starting user's ([below](#an-app-runs-with-the-tenants-key)) |
|
|
357
|
+
| job identity | — | `JOB_NAME` (the app's name), `JOB_UUID` (this run), `SOURCE_FOLDER_ID`, `FARSEER_PIPELINE_RUN_UUID` (the pipeline run this job belongs to; empty when it belongs to none) |
|
|
318
358
|
| arguments | — | `FARSEER_ARGS` |
|
|
319
359
|
|
|
360
|
+
The runner column was measured with a probe app on the same image and
|
|
361
|
+
`compute` as a pipeline import, and it matches Farseer's job runner on `dev`:
|
|
362
|
+
`jobrunner/jobEnvironment.ts:28-36` sets `TENANT_ID: tenant.tenantId`,
|
|
363
|
+
`FARSEER_URL: farseerUrl` and `FARSEER_PIPELINE_RUN_UUID`, and both engines
|
|
364
|
+
pass the tenant's URL as it is stored (`batchRunEngine.ts:238`,
|
|
365
|
+
`localRunEngine.ts:148-150`). **So `FARSEER_URL` carries `/api/v3` locally
|
|
366
|
+
and not on the runner.** The Python SDK does not mind: `FarseerClient()`
|
|
367
|
+
appends `/api/v3` when it is missing
|
|
368
|
+
(the Python SDK's `farseer_client/client.py:97-100`). A hand-built REST call
|
|
369
|
+
must normalise the base the same way before it adds a path:
|
|
370
|
+
`base = FARSEER_URL.rstrip("/")`, then add `/api/v3` unless `base` already
|
|
371
|
+
ends with it. Code that concatenates `FARSEER_URL + "/remoteJobs"` works
|
|
372
|
+
under a local `farseer run` and breaks on the runner.
|
|
373
|
+
|
|
320
374
|
The API-key variable exported in your shell next to the token `farseer run`
|
|
321
375
|
injects crashes the SDK (`Cannot set both`).
|
|
322
376
|
No variable is documented to tell the two runtimes apart — `JOB_UUID` is
|
|
323
377
|
set only by the runner, an implementation detail; an explicit
|
|
324
|
-
`FARSEER_RUNTIME` is requested upstream
|
|
378
|
+
`FARSEER_RUNTIME` is requested upstream.
|
|
325
379
|
`JOB_NAME` lets one script serve N apps (entity in the app name), and
|
|
326
380
|
`JOB_UUID` finds the app's own run (`remoteJobRuns.listByRemoteJobId(id)`)
|
|
327
381
|
— e.g. to see who started it.
|
|
328
382
|
|
|
383
|
+
**`new FarseerClient()` reads `FARSEER_TOKEN` only from SDK 1.8.4 on.** An older
|
|
384
|
+
SDK — such as the 1.4.5 bucket tarball that CLI 1.6.2 and older wrote into
|
|
385
|
+
`farseer-apps/<tenant>/package.json` — reads only the API-key variable, so after a
|
|
386
|
+
browser login a local `farseer run` / `run-script` fails with `Tenant id, api
|
|
387
|
+
key and url not set up` (field reports 2026-10-20 and 2026-10-21). Upgrade the
|
|
388
|
+
SDK (`farseer install <tenant>` moves a pin an older CLI wrote to 1.18.1; [release notes](../farseer-app-dev/farseer-client-release-notes.md#an-existing-app-still-on-the-bucket-or-on---fixing-it)),
|
|
389
|
+
or for a one-off local probe build the client with explicit headers:
|
|
390
|
+
`new FarseerClient({ basePath: process.env.FARSEER_URL, headers: { 'X-TENANT-ID':
|
|
391
|
+
process.env.TENANT_ID, Authorization: 'Bearer ' + process.env.FARSEER_TOKEN } })`.
|
|
392
|
+
The tenant runner is not affected (API key). Extra words after the script name
|
|
393
|
+
in `run-script` are not arguments either: they become part of the path
|
|
394
|
+
(`Script not found: …/index.ts a b c`).
|
|
395
|
+
|
|
329
396
|
### Test — the one test that exercises the read path
|
|
330
397
|
|
|
331
398
|
The three production incidents behind this section (a scaffolder that
|
|
@@ -351,6 +418,33 @@ Write **every** argument into the blob — locally nothing fills a default —
|
|
|
351
418
|
and never `""`. This does not replace the UI run: it cannot exercise the
|
|
352
419
|
server's defaults, `options` validation or `fixed` arguments.
|
|
353
420
|
|
|
421
|
+
## The runner — what it has, whose key it uses
|
|
422
|
+
|
|
423
|
+
Read from Farseer's runner images and job runner at the CLI 1.19.0 release
|
|
424
|
+
(`runner-images/`, `jobrunner/jobEnvironment.ts`), and from a read-only probe
|
|
425
|
+
of the TypeScript image.
|
|
426
|
+
|
|
427
|
+
### What the runner image has
|
|
428
|
+
|
|
429
|
+
| Runner | Has | Has not |
|
|
430
|
+
|---|---|---|
|
|
431
|
+
| **TypeScript** (Node 22) | `pdfkit` (0.15 in the image; the `package.json` that `farseer pull` writes pins ^0.14), `pdfmake` 0.2, `xlsx` 0.20.3, `exceljs`, `draft-js` | Chromium or any browser, so no screenshot from an app; system fonts. pdfmake's bundled Roboto (`pdfmake/build/vfs_fonts.js`) works for č, ć, đ and Δ, and pdfkit can load it too |
|
|
432
|
+
| **Python** (plain and Simple Pipelines) | the Farseer client; Simple Pipelines adds pandas, polars, openpyxl, database drivers | any PDF library: write the PDF bytes yourself ([`pipeline-app-failure-report-pattern.md` §3](../farseer-build-pipeline/pipeline-app-failure-report-pattern.md#3-there-is-no-pdf-library-in-the-python-runner-image)) |
|
|
433
|
+
|
|
434
|
+
### An app runs with the tenant's key
|
|
435
|
+
|
|
436
|
+
On the runner, the API-key variable is the **tenant's** key
|
|
437
|
+
(`jobEnvironment.ts` sets it to `tenant.apiKey`), not a key of the user who started the
|
|
438
|
+
run, and nothing narrows it to that user's rights. Whatever the app reads or
|
|
439
|
+
writes, it does with the tenant's access. Two consequences:
|
|
440
|
+
|
|
441
|
+
- **Starting an app needs no write rights.** A user with run access to the
|
|
442
|
+
app gets its writes done; a tenant → tenant transfer relies on it.
|
|
443
|
+
- **An app's output can show data that the person who started it, or the
|
|
444
|
+
readers of its output folder, cannot see in the Farseer UI** (a PDF, an
|
|
445
|
+
export, a report file). Restrict who can run such an app, and share its
|
|
446
|
+
output folder only with people allowed to see all of it.
|
|
447
|
+
|
|
354
448
|
## Gotchas
|
|
355
449
|
|
|
356
450
|
- **No entrypoint after push** → the `entrypoint` names no file in the tenant's
|
|
@@ -366,6 +460,18 @@ server's defaults, `options` validation or `fixed` arguments.
|
|
|
366
460
|
*current* directory (or under `FARSEER_APPS_DIR`), and `install`, `push`,
|
|
367
461
|
`status`, `run` and `run-script` look for it there. Always `cd` into the
|
|
368
462
|
folder that holds `farseer-apps/` first.
|
|
463
|
+
- **`farseer run` and the MCP tool `farseer_run_app` run the app on your
|
|
464
|
+
laptop**, not on the runner. A runner run from a script is
|
|
465
|
+
`client.remoteJobs.run(<appId>, { arguments })`, and its log comes from
|
|
466
|
+
`remoteJobRuns.listByRemoteJobId` (§5). (The MCP tool's local run read in the CLI 1.19.0 source.)
|
|
467
|
+
- **`farseer app configure --add-arg "Name=Value"` on an argument that
|
|
468
|
+
exists changes its default value** (name matched ignoring case; type,
|
|
469
|
+
options and the secret flag kept), it does not add a second argument.
|
|
470
|
+
The value is cut at its first `=` (CLI 1.19.0 source).
|
|
471
|
+
- **Three SDK and REST answers that cost a run:** `folders.search` answers 400 above `limit: 20`;
|
|
472
|
+
`getItemByPath` fails when two items in the path share the name, so walk
|
|
473
|
+
by id; `PUT /farseerFiles/{ref}` answers plain `OK`, not JSON, so don't
|
|
474
|
+
parse the answer as JSON.
|
|
369
475
|
- **Entrypoint-name collision — the app runs ANOTHER app's code.** Measured
|
|
370
476
|
2026-10-15 on a sandbox tenant: a second app whose entrypoint is a bare
|
|
371
477
|
`main.ts`, pushed to a tenant where another app's folder already holds a
|
|
@@ -379,5 +485,4 @@ server's defaults, `options` validation or `fixed` arguments.
|
|
|
379
485
|
of a manifest that still says bare `main.ts` breaks it again — so give
|
|
380
486
|
every entrypoint a unique name (§1) and check `app show` after the first
|
|
381
487
|
deploy (§4). (Deleting and re-pushing
|
|
382
|
-
the app also repairs it, at the cost of its id and history.
|
|
383
|
-
`farseerdev/farseer#3131`.)
|
|
488
|
+
the app also repairs it, at the cost of its id and history.)
|
|
@@ -43,7 +43,8 @@ lock matters more than the prefix.
|
|
|
43
43
|
> a manual edit, an import, or an automation. If the import target is *unlocked*,
|
|
44
44
|
> a planner can silently overwrite an imported number in a sheet, and the next
|
|
45
45
|
> re-import will fight that edit. Locking the import target removes the conflict
|
|
46
|
-
> entirely.
|
|
46
|
+
> entirely. The `farseer-review-model` analysis flags an **import into an unlocked
|
|
47
|
+
> variable** as critical for exactly this reason.
|
|
47
48
|
|
|
48
49
|
---
|
|
49
50
|
|
|
@@ -77,7 +78,7 @@ reverses its own prior run:
|
|
|
77
78
|
So the labels must encode **exactly the scope the job owns**. A GL load for January
|
|
78
79
|
2025 carries `["GL", "2025", "1"]`. If the job is version-specific or copies
|
|
79
80
|
between versions, the version (and source→target) belong in the labels too:
|
|
80
|
-
`["
|
|
81
|
+
`["fc_preparation", "Plan", "Y2025", "<source>2<target>"]`.
|
|
81
82
|
|
|
82
83
|
The re-run protocol is then:
|
|
83
84
|
|
|
@@ -89,7 +90,7 @@ Two SDK primitives do step 2–3 — pick by reversibility:
|
|
|
89
90
|
|
|
90
91
|
| Primitive | Behavior | Use when |
|
|
91
92
|
|---|---|---|
|
|
92
|
-
| `importJobs.revert(id)` ↔ `commit(id)` | status flips `COMMITED ↔ REVERTED`; re-commit **re-applies** the cells | **preferred** — reversible; the month is never left empty if the new run fails |
|
|
93
|
+
| `importJobs.revert(id)` ↔ `commit(id)` | status flips `COMMITED ↔ REVERTED`; re-commit **re-applies** the cells. A revert deletes the cells the job wrote; it does not restore what they overwrote | **preferred** — reversible; the month is never left empty if the new run fails |
|
|
93
94
|
| `job.undoPrevious()` / `deleteById(id, {undoData:true})` | **destructive** — deletes prior cells, cannot be rolled back | only when you genuinely want the prior cells gone |
|
|
94
95
|
|
|
95
96
|
The reversible pattern (revert prior → commit new → on failure re-commit prior)
|
|
@@ -144,10 +145,10 @@ plans into them, and the undo trail there is worth keeping.
|
|
|
144
145
|
|
|
145
146
|
| Trap | Rule |
|
|
146
147
|
|---|---|
|
|
147
|
-
| `importJobs.list([label])` returns **HTTP 400** for a label containing
|
|
148
|
-
| **
|
|
149
|
-
| `job.addRows()` throws
|
|
150
|
-
| `commit().importedCells` systematically under-counts | It counts only the
|
|
148
|
+
| `importJobs.list([label])` returns a bare **HTTP 400** for a label containing parentheses — and `createImportJob` calls it before it creates the job, so the bare 400 comes from the create. Measured on a sandbox tenant 2026-11-09: `(` / `)` fail; hyphens, spaces, dots, slashes and square brackets passed | **A label must be `[A-Za-z0-9_-]` only** — stricter than the platform needs today, so no other character can trip it. Do not put a variable name — or anything else unsanitised — straight into a label; sanitise it (`s.replace(/[^A-Za-z0-9_-]+/g, "_")`). |
|
|
149
|
+
| A large job looks truncated | **No row limit per job was found.** One job of 150,000 rows (measured 2026-11-06, totals exact per version, a locked version included) and one of 240,000 cells (2026-10-08) landed complete. Two things look like truncation and are not: `addRows` overflows above ~100k rows in one call (send ≤10,000 rows per call), and the commit report counts only the backend's last 10,000-row write batch (it showed 10,000 for 150,000). Verify by re-reading the tenant (total per slice), never from the report. The one reason to split a large import is a slow connection, where a long send or commit can hit an HTTP timeout. |
|
|
150
|
+
| `job.addRows(rows)` throws `RangeError: Maximum call stack size exceeded` above ~100k rows in one call | Send **≤ 10,000 rows per `addRows` call** (`for (let s = 0; s < rows.length; s += 10000) await job.addRows(rows.slice(s, s + 10000))`), then one `commit()`. A failed call leaves an **empty job in `CREATED`** (any key upsert made before it stays): delete that job before the re-run. |
|
|
151
|
+
| `commit().importedCells` systematically under-counts | It counts only the backend's last 10,000-row write batch. **The only valid check is re-reading the tenant.** If an app claims "wrote N", that N must come from the tenant, not from the commit report. |
|
|
151
152
|
|
|
152
153
|
## 5. `importZeros` — a zero is not imported unless you ask for it
|
|
153
154
|
|
|
@@ -181,10 +182,24 @@ Three consequences worth stating, because each one has cost someone a day:
|
|
|
181
182
|
1. **Expected-row counts must be computed over NON-ZERO source rows** whenever
|
|
182
183
|
`importZeros: false` — which is what the `columns` overload gives you. A reconciliation that counts every source row will read short and
|
|
183
184
|
false-red forever.
|
|
184
|
-
2. **
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
`value: null`.
|
|
185
|
+
2. **Removing cells the source no longer has.** A re-import must leave no
|
|
186
|
+
stale leaves, but never by leaving a stored 0: a 0 is a value (`hasValue` is
|
|
187
|
+
true; [`sparse-formulas-pattern.md`](../farseer-build-model/sparse-formulas-pattern.md)). On a
|
|
188
|
+
writable target, use `updateCells` with `value: null`. On a `@readonly`
|
|
189
|
+
import variable or inside a globally locked region (where `updateCells` is
|
|
190
|
+
refused even with readonly off, measured 2026-11-06), use a **clearing
|
|
191
|
+
job**: an import job under its own label, `importZeros: true`, that writes 0
|
|
192
|
+
only for the vanished coordinates, then `importJobs.revert` it. A revert
|
|
193
|
+
deletes the cells that job wrote last, so those coordinates end empty
|
|
194
|
+
(measured 2026-11-06, locked Actual, `@readonly`).
|
|
195
|
+
Check: the file total equals the stored total per slice, and a re-run shows
|
|
196
|
+
nothing new. To clear the whole variable, `entities.deleteData` also clears
|
|
197
|
+
locked cells (measured). If a commit with `importZeros: true` hangs on an
|
|
198
|
+
instance
|
|
199
|
+
([`working-patterns.md`](../farseer-app-dev/working-patterns.md#importzeros-can-hang-on-commit-and-transient-commit-errors-are-safe-to-retry)),
|
|
200
|
+
fall back to `deleteData` and a full re-import — it clears every slice and
|
|
201
|
+
version of the variable, so only where you can re-import all of them. A row whose value is `null`
|
|
202
|
+
is skipped — it does not clear.
|
|
188
203
|
3. **A skipped zero is only harmless if the target's seed formula is fenced.**
|
|
189
204
|
If an ` IN` carries an unfenced seed (no `if(hasDMember(Versions>Actual), …)`),
|
|
190
205
|
the cell the import declined to create falls through to the formula, which
|
|
@@ -207,7 +222,84 @@ Both were right; neither recorded the flag it ran under.
|
|
|
207
222
|
|
|
208
223
|
---
|
|
209
224
|
|
|
210
|
-
##
|
|
225
|
+
## 6. Financial year: an import job maps calendar periods to fiscal ones
|
|
226
|
+
|
|
227
|
+
A tenant's financial year starts in the month its setting
|
|
228
|
+
`financial_year_starting_month` names (S, 1–12, `GET /settings`). With S ≠ 1
|
|
229
|
+
the model's `M1` is that month (M1 = March for S = 3) and `Y2026` is the
|
|
230
|
+
financial year that starts in 2026. An **import job reads the `Years`/`Months`
|
|
231
|
+
its rows name as calendar periods and maps them to fiscal ones**: every cell
|
|
232
|
+
lands S − 1 months earlier, into the previous year when it passes `M1`
|
|
233
|
+
(`importJobService.ts`). `ignoreFinancialYearOffset: true` in the job's
|
|
234
|
+
metadata turns the mapping off (the import
|
|
235
|
+
dialog has the same checkbox). On a January year (S = 1) nothing is mapped and
|
|
236
|
+
the flag changes nothing.
|
|
237
|
+
|
|
238
|
+
Measured on a sandbox tenant 2026-11-12 with S = 3 (a before/after snapshot of
|
|
239
|
+
149 variables / 154,293 cells was identical after the restore):
|
|
240
|
+
|
|
241
|
+
| Write | The row names | Stored at |
|
|
242
|
+
|---|---|---|
|
|
243
|
+
| import job, no flag (the SDK's `columns` overload) | `Y2026 M9` | **`Y2026 M7`** |
|
|
244
|
+
| import job, no flag | `Y2027 M1` | **`Y2026 M11`** |
|
|
245
|
+
| import job, `ignoreFinancialYearOffset: true` | `Y2026 M9` | `Y2026 M9`, as named |
|
|
246
|
+
| import job, no flag, the month fixed in the VARIABLE column's `dimensionsNames` | `M9` | **`M7`**: a fixed month shifts too |
|
|
247
|
+
| `model.updateCells` with `"Months">"M9"` | `M9` | `M9`: INSERT is never mapped |
|
|
248
|
+
|
|
249
|
+
**Set the flag by where the rows' periods come from:**
|
|
250
|
+
|
|
251
|
+
| The rows carry | Typical jobs | `ignoreFinancialYearOffset` |
|
|
252
|
+
|---|---|---|
|
|
253
|
+
| the tenant's own (fiscal) period names | model-to-model copies, version copies, a history freeze, any re-import of values read from a tenant (`export.exportFormula` → import) | **`true`**, or the copy lands S − 1 months early |
|
|
254
|
+
| calendar periods | a GL / ERP feed with calendar dates or calendar month numbers | leave it `false`: the platform does the mapping |
|
|
255
|
+
|
|
256
|
+
What else follows:
|
|
257
|
+
|
|
258
|
+
- **A fixed month shifts; `updateCells` does not.** A script that writes the
|
|
259
|
+
same period by an import job and by `updateCells` must name it differently
|
|
260
|
+
for each on a tenant with S ≠ 1, or set the flag.
|
|
261
|
+
- **Only the tables named `Years` and `Months` are mapped**, members
|
|
262
|
+
`Y<yyyy>` / `M<m>`. A date column is read as the year and month of the date
|
|
263
|
+
and mapped the same way, and a row whose mapped year is not on the tenant
|
|
264
|
+
fails the job with "Financial year offset mapping not found" (both from the
|
|
265
|
+
source, `importJobService.ts`; not measured).
|
|
266
|
+
- **Simple Pipelines always send `ignore_financial_year_offset=True`**
|
|
267
|
+
(`farseer_simple_pipelines/load/farseer.py`), so a pipeline writes every
|
|
268
|
+
period as named. A source with calendar dates must convert them to fiscal
|
|
269
|
+
periods in the pipeline itself: fiscal month = calendar month − (S − 1),
|
|
270
|
+
plus 12 and the year minus one when that is 0 or less.
|
|
271
|
+
- **The MCP import tool (CLI 1.19.0) and `farseer variables import` (from CLI
|
|
272
|
+
1.20) can set neither this flag nor `importZeros`**. On a tenant with S ≠ 1 use the SDK's
|
|
273
|
+
metadata overload or a pipeline. The SDK's `columns` overload sends no flag
|
|
274
|
+
either: build the metadata and add it.
|
|
275
|
+
|
|
276
|
+
```ts
|
|
277
|
+
const metadata = await c.buildImportJobMetadata(columns);
|
|
278
|
+
metadata.ignoreFinancialYearOffset = true; // the rows carry this tenant's own periods
|
|
279
|
+
const job = await c.createImportJob({ title, labels, metadata });
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
- **Changing S itself moves every entered cell.** Plan it as a migration.
|
|
283
|
+
|
|
284
|
+
**Detection — before trusting an import path on a tenant with S ≠ 1.** On a
|
|
285
|
+
development tenant, with a snapshot taken first:
|
|
286
|
+
|
|
287
|
+
1. Read S: `GET /settings` → `financial_year_starting_month`. S = 1: nothing to check.
|
|
288
|
+
2. Import one known **non-zero** value (a zero is skipped unless
|
|
289
|
+
`importZeros: true`) into a test variable at a named period, e.g.
|
|
290
|
+
`Y2026 M9`, through the exact path you will use: the app, the pipeline, the
|
|
291
|
+
CLI. Pick a coordinate that is empty at that period **and** S − 1 months
|
|
292
|
+
earlier: if the probe lands on a stored value, the revert in step 4 deletes
|
|
293
|
+
that value instead of restoring it.
|
|
294
|
+
3. Read it back at the named period and at the period S − 1 months earlier
|
|
295
|
+
(`sum("<Var>", "Years">"Y2026", "Months">"M9")` against `"M7"` for S = 3).
|
|
296
|
+
Where the value sits says whether the path maps.
|
|
297
|
+
4. Remove the probe: revert its job, which deletes the cell,
|
|
298
|
+
or write `null` with `updateCells`.
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
## How `farseer-review-model` reads import jobs
|
|
211
303
|
|
|
212
304
|
The model-analysis pass enumerates every app and classifies each variable an import
|
|
213
305
|
job writes:
|
|
@@ -220,7 +312,13 @@ job writes:
|
|
|
220
312
|
|
|
221
313
|
It also checks how jobs touch **dimension tables**: additive (append new members) is
|
|
222
314
|
the recommended posture; jobs that **overwrite FK keys** every run are flagged,
|
|
223
|
-
especially when a sheet also exposes that FK for editing.
|
|
315
|
+
especially when a sheet also exposes that FK for editing. See the `farseer-review-model`
|
|
316
|
+
skill for the full report shape.
|
|
317
|
+
|
|
318
|
+
Additive does not mean one member per source row: **open a new member only for a
|
|
319
|
+
row with a non-zero amount**, and keep filling the FKs of existing members. A job
|
|
320
|
+
that opened a key for every source row, zero-amount rows included, left several
|
|
321
|
+
hundred members without a single cell (field report, 2026-10-20).
|
|
224
322
|
|
|
225
323
|
---
|
|
226
324
|
|
|
@@ -3,7 +3,7 @@ name: farseer-build-model
|
|
|
3
3
|
description: >-
|
|
4
4
|
Design rules for a new Farseer model or module: the four variable layers (IMPORT, IN, calculations, OUT) and their names, grain alignment, members pinned in the grain instead of in formulas, sparse formulas, a checklist that keeps calculation fast, and how to validate the result. Use when the user asks to design or build a new model or module, or to check a model's naming, grain or sparse formulas against these rules. To audit an existing model, use the farseer-review-model skill. The farseer-model skill covers how to create the variables and tables.
|
|
5
5
|
metadata:
|
|
6
|
-
version: "
|
|
6
|
+
version: "2"
|
|
7
7
|
domain: modeling
|
|
8
8
|
---
|
|
9
9
|
|
|
@@ -58,7 +58,7 @@ Before designing anything (reads only):
|
|
|
58
58
|
|
|
59
59
|
- `farseer model --tables <tenant>` — what tables already exist; reuse, don't create duplicates (`--table "<Table>"` for one table's columns and members, incl. system tables like `Years`/`Versions`)
|
|
60
60
|
- `farseer model --variables <tenant>` — is there already an IMPORT layer? Master data wiring? Existing ` OUT` variables that downstream modules consume? (`--variable "<Var>"` for one variable's formula, tables, fixed members and properties)
|
|
61
|
-
- `farseer model --json <tenant> > model.json` — the whole structure in one file for cross-checks if the model is non-trivial: every variable's formula, tables, fixed members, rollup, `readonly`, `zConstraint`, notes and folder, and every table's columns with their FK targets. A read where every variable comes back without a formula is a failed read, not an empty model: read again. So is one that prints `/model/export failed …; falling back to initTagMap`, which has no fixed members, notes, folder or `
|
|
61
|
+
- `farseer model --json <tenant> > model.json` — the whole structure in one file for cross-checks if the model is non-trivial: every variable's formula, tables, fixed members, rollup, `readonly`, `zConstraint`, notes and folder, and every table's columns with their FK targets. A read where every variable comes back without a formula is a failed read, not an empty model: read again. So is one that prints `/model/export failed …; falling back to initTagMap`, which has no fixed members, notes, folder, `zConstraint` or `optimizeCalculation`.
|
|
62
62
|
|
|
63
63
|
If the CLI session is missing — say so, use the `farseer-authenticate-to-tenant` skill, or ask the user to paste the relevant lists. Do not invent symbol names that may collide with what's actually in the tenant.
|
|
64
64
|
|
|
@@ -83,6 +83,7 @@ If the graph has potential diamond paths (multiple dim routes between two dims),
|
|
|
83
83
|
|
|
84
84
|
**Performance checklist before push** — cheap to apply while the variable graph is still fresh, expensive to retrofit later:
|
|
85
85
|
|
|
86
|
+
- Every formula variable has Optimize calculation off (`optimizeCalculation: false`; [`formula-grain-alignment.md`, the v7 rule](formula-grain-alignment.md#optimize-calculation-v7), which says how to set it). With the flag off a coarser operand in a sum, or alone in an `if()` branch, places a cell on every member of the dimensions it lacks (measured: 720 cells instead of 4); a product with a coarse factor keeps its cells. Where filling the grain is not the intent, gate the coarse term on the detail operand, and count such a variable on a pinned probe before its first push.
|
|
86
87
|
- Broadcasting onto `Versions`? Use a condition (`if(eq(carrier, 1), X)`), never a product (`X * carrier`) — a cost difference of tens of times (the two are equal only when the carrier holds `1` or null, never a stored `0`), [`formula-grain-alignment.md` §7](formula-grain-alignment.md#7--avoid-it-at-the-start-design-time-performance-rules).
|
|
87
88
|
- Never combine a `Versions` broadcast and an FK hop in one product — split them.
|
|
88
89
|
- Lifting a coarse operand across an FK hop and the result must stay sparse? `if(hasValue(X), X)`, not `0 + X` (phantom zeros — [`sparse-formulas-pattern.md`](sparse-formulas-pattern.md)).
|