farseer-cli 1.22.0 → 1.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +3 -1
  2. package/dist/commands/code.js +23 -0
  3. package/dist/commands/code.js.map +2 -2
  4. package/dist/commands/skills.js +110 -7
  5. package/dist/commands/skills.js.map +1 -1
  6. package/dist/index.js +5 -1
  7. package/dist/index.js.map +1 -1
  8. package/dist/mcp/tools/dashboardTools.js +1 -1
  9. package/dist/pipeline/create.js +1 -1
  10. package/dist/pipeline/generated-reference.json +6 -6
  11. package/dist/services/codefirst/workflow.js +3 -3
  12. package/dist/services/codefirst/workflow.js.map +1 -1
  13. package/dist/services/farseerService.js +10 -1
  14. package/dist/services/farseerService.js.map +1 -1
  15. package/dist/services/httpError.js +2 -1
  16. package/dist/services/httpError.js.map +1 -1
  17. package/dist/skills/install.js +221 -8
  18. package/dist/skills/install.js.map +2 -2
  19. package/dist/skills/userSkills.js +206 -0
  20. package/dist/skills/userSkills.js.map +6 -0
  21. package/dist/skills/workspaceSkills.js +213 -0
  22. package/dist/skills/workspaceSkills.js.map +6 -0
  23. package/docs/cli-guide.md +6 -1
  24. package/docs/pipeline-reference.md +1 -1
  25. package/package.json +1 -1
  26. package/skills/farseer-app-dev/SKILL.md +2 -2
  27. package/skills/farseer-app-dev/assignments.md +1 -1
  28. package/skills/farseer-app-dev/farseer-client-release-notes.md +13 -1
  29. package/skills/farseer-app-dev/working-patterns.md +30 -5
  30. package/skills/farseer-author-import-job/SKILL.md +20 -3
  31. package/skills/farseer-author-import-job/cell-writes.md +26 -6
  32. package/skills/farseer-author-import-job/deploying-a-farseer-app.md +117 -12
  33. package/skills/farseer-author-import-job/import-job-pattern.md +111 -13
  34. package/skills/farseer-build-model/SKILL.md +3 -2
  35. package/skills/farseer-build-model/formula-grain-alignment.md +186 -31
  36. package/skills/farseer-build-model/naming-conventions.md +5 -2
  37. package/skills/farseer-build-model/sparse-formulas-pattern.md +30 -11
  38. package/skills/farseer-build-pipeline/SKILL.md +36 -1
  39. package/skills/farseer-build-pipeline/erp-sales/README.md +8 -0
  40. package/skills/farseer-build-pipeline/erp-sales/erp-sales-etl/main.py +1 -1
  41. package/skills/farseer-build-pipeline/erp-sales/erp-sales-load/main.py +1 -1
  42. package/skills/farseer-build-pipeline/pipeline-app-failure-report-pattern.md +9 -6
  43. package/skills/farseer-modify-model/SKILL.md +3 -2
  44. package/skills/farseer-modify-model/model-validation-pattern.md +11 -3
  45. package/skills/farseer-review-model/SKILL.md +39 -8
  46. package/skills/pipeline-authoring/SKILL.md +3 -3
  47. package/skills/pipeline-authoring/practices.md +5 -3
@@ -1,9 +1,9 @@
1
1
  ---
2
2
  name: farseer-review-model
3
3
  description: >-
4
- Audit an existing Farseer model's structure against modelling rules, read-only, and report each finding with severity, location and fix: naming and locking (IN/OUT/IMPORT, readonly), module boundaries, the table graph and its diamonds, formula grain, hardcoded members and non-Actual versions, sparse formulas and dense cells, and, in a full audit, where computed values can be overwritten: unlocked formula variables on sheets, apps writing unlocked variables, FK-rewriting imports, and Constrained Light Top Down against sheet exposure. Use when the user asks to review, audit, QA or health-check a model, its naming, locking or structure. It changes nothing: the farseer-modify-model skill plans a fix, and questions about the numbers belong to farseer-analysis.
4
+ Audit an existing Farseer model's structure against modelling rules, read-only, and report each finding with severity, location and fix: naming and locking (IN/OUT/IMPORT, readonly), module boundaries, the table graph and its diamonds, formula grain, hardcoded members and non-Actual versions, sparse formulas and dense cells, and, in a full audit, where computed values can be overwritten: unlocked formula variables on sheets, apps writing unlocked variables, FK-rewriting imports, Constrained Light Top Down against sheet exposure, and sheet and folder sharing (EDIT or everyone shares). Use when the user asks to review, audit, QA or health-check a model, its naming, locking or structure. It changes nothing: the farseer-modify-model skill plans a fix, and questions about the numbers belong to farseer-analysis.
5
5
  metadata:
6
- version: "1"
6
+ version: "2"
7
7
  domain: modeling
8
8
  ---
9
9
 
@@ -13,7 +13,7 @@ metadata:
13
13
 
14
14
  Before a model goes to its users, after a change, or as a periodic model health check. Do not use for writing or modifying the model — this skill is read-only.
15
15
 
16
- A plain review runs Tier 1 (sections A–G). **A full audit** (the user asks for a full or deep audit, or where the model can be broken by use) runs Tier 1 **and** the Tier 2 risk-surface pass (section H), and produces the full report laid out under Expected output.
16
+ A plain review runs Tier 1 (sections A–G). **A full audit** (the user asks for a full or deep audit, or where the model can be broken by use) runs Tier 1 **and** the Tier 2 risk-surface pass (section H) and the sharing posture (section J), and produces the full report laid out under Expected output.
17
17
 
18
18
  - Fixing what the review finds → the `farseer-modify-model` skill (risk tier, snapshot, impact, rollback). This skill writes nothing.
19
19
  - Formula syntax → the `farseer-formulas` skill.
@@ -22,8 +22,8 @@ A plain review runs Tier 1 (sections A–G). **A full audit** (the user asks for
22
22
  ## Inputs to gather first
23
23
 
24
24
  1. **Tenant and session** — name the tenant on every call. Check that reads work: `farseer model --tables <tenant>`. If they don't, the `farseer-authenticate-to-tenant` skill reconnects. A saved `farseer model --json` file (for example a snapshot taken before a change) also works: run A–E, G and G2 on it, and mark F and H "not verified" unless live reads work too. #16 and the member counts of #35 need member rows, which a file holds only when it was taken with `--include-members`; otherwise mark them "not verified" too.
25
- 2. **The model** — `farseer model --json <tenant> > model.json`, then search the file rather than printing it. Each variable carries `formula`, `tables` (its grain), `members` (its fixed members), `readonly`, `zConstraint`, `notes`, `description`, `folderPath`, `rollupType`, `dataType` and `numberFormat`; each table carries its columns, and an FK column names its target table in `foreignKeyTableName`. `folderPath` starts at the tenant's top-level folder.
26
- - If the CLI prints `/model/export failed …; falling back to initTagMap`, that read has no fixed members, notes, folders or `zConstraint`: mark the checks that need them "not verified".
25
+ 2. **The model** — `farseer model --json <tenant> > model.json`, then search the file rather than printing it. Each variable carries `formula`, `tables` (its grain), `members` (its fixed members), `readonly`, `zConstraint`, `optimizeCalculation`, `notes`, `description`, `folderPath`, `rollupType`, `dataType` and `numberFormat`; each table carries its columns, and an FK column names its target table in `foreignKeyTableName`. `folderPath` starts at the tenant's top-level folder.
26
+ - If the CLI prints `/model/export failed …; falling back to initTagMap`, that read has no fixed members, notes, folders, `zConstraint` or `optimizeCalculation`: mark the checks that need them "not verified", 24a included.
27
27
  - If the read shows no formulas at all, read it again: the first export from a cold tenant can return every formula empty.
28
28
  3. **For a full audit, the sheets and the apps** — the sheet and app commands under Tools.
29
29
  4. **Reference material** — `naming-conventions.md`, `sparse-formulas-pattern.md` and `formula-grain-alignment.md` in the `farseer-build-model` skill hold these rules with their reasons.
@@ -71,6 +71,7 @@ These naming and structure rules are recommended conventions, not platform rules
71
71
  ### G. Property hygiene
72
72
  23. Data type, rollup, number format consistent with what the formula produces
73
73
  24. Folder hierarchy reflects business structure, not technical
74
+ 24a. **Optimize calculation off on every formula variable** ([`formula-grain-alignment.md`, the v7 rule](../farseer-build-model/formula-grain-alignment.md#optimize-calculation-v7)) — `"optimizeCalculation": true` in the export marks a formula variable that still has it on. New model: Error. Delivered model: Info — list the variables for the change that next touches each; Warning where the formula has a shape that loses cells with the flag on: next to an operand that carries the variable's full grain, an operand with a member filter on a grain dimension (`sum("X", "Versions" > "Actual")`), a coarser operand, or an `if()` branch at a coarser grain.
74
75
 
75
76
  ### G2. Formula discipline (Tier 1)
76
77
  25. **No version other than `Actual` in formulas** — a formula referencing a specific non-Actual version (Plan, Budget, a named scenario) hardcodes version routing into a calculation. Flag it; version routing belongs in a version carrier read through a condition (`if(eq(carrier, 1), X)`, see #28), not in a formula that names the version.
@@ -88,6 +89,35 @@ Triggered when the model has a meaningful number of **unlocked, formula-bearing
88
89
 
89
90
  See Expected output for the full report layout and table templates.
90
91
 
92
+ ### J. Sharing posture (Tier 2 — for a full audit, and before go-live)
93
+ A sheet filter is a view convenience, not a security boundary. *Inferred, not measured:* a group holding `EDIT` ("full edit") on a sheet can change the sheet's definition, remove the filter, and see or write everything the filter hid. The usual accident is a filtered sheet meant to restrict a group, shared with that group as `EDIT` instead of `DATA_ENTRY` or `VIEW`; nothing fails and nothing warns. The model export carries no shares (they live in `SharesApi` only), and every new item copies its parent folder's shares, so one wide folder share reaches every sheet created in that folder later; the copies are separate records, so changing or removing the folder share later leaves them on the items already created.
94
+
95
+ **Where the data comes from.** `farseer code checkout <org> <tenant>` (read-only; CLI ≥ 1.18, experimental) writes the whole tenant as JSON, `Files/` included:
96
+ - `access/shares/<kind>-<id>.json`: one file per shared item; `shares[].type` = `VIEW` | `DATA_ENTRY` | `EDIT`, principals in `users[]` (ids), `groups[]` (names) and `labels[]`, plus `publicLink`;
97
+ - `access/groups/<Name>.json`: the group's `members[]`;
98
+ - `tree/**.json`: each item (sheet, folder, …) with `shares.file` pointing to its share file, its `rows.filters[]`, and `refSheet` + `refConfig`.
99
+
100
+ **`access/` may contain personal data. Check out into a scratch folder outside any git repository (or a gitignored one) and never commit any of it.**
101
+
102
+ **The admin allowlist comes from the user.** Ask which groups count as admins, or take it from the project's own notes. Without it, a group whose name matches `/admin/i` is shown as a *suggested* admin only; it never silences a finding.
103
+
104
+ Read on one tenant (2026-11-09): "everyone" has no principal of its own; it is the group every user lands in (`Default` there), any group whose members cover all users, or `publicLink: true`. "Has a filter" means a `rows.filters[]` entry with `selectAll: false`; a sheet with `refSheet` and `refConfig.useFilters: true` has the referenced sheet's filters. A share's `comment` is not its level (two `EDIT` shares there said "Simple view"): read `type`.
105
+
106
+ 37. `EDIT` share to a **user group not on the admin allowlist**, on a sheet that **has a filter** → 🔴 DANGER.
107
+ 38. Same as 37 on a sheet without a filter → ⚠️ WARNING.
108
+ 39. Shared with **everyone**, any level → ⚠️ WARNING; with `EDIT` → 🔴 DANGER.
109
+ 40. `EDIT` share to an **individual user** who is in no allowlisted admin group, rather than to a group (it bypasses group-based governance) → ⚠️ WARNING. Every new item gives its creator such a share, so a non-admin creator shows up here.
110
+ 41. `EDIT` or everyone share on a **folder**: every item created in it later copies the share. This is the root cause, 37–39 are its symptoms → 🔴 DANGER.
111
+ 42. Dangling `DATA_ENTRY` share left by a failed assignment create (`restrictions.active: false`; [`assignments.md`](../farseer-app-dev/assignments.md) TL;DR #4) → ℹ️ INFO.
112
+ 43. Per group: `VIEW` or `DATA_ENTRY` on a filtered sheet **and** access to another sheet showing the same variables unfiltered, so the filter restricts nothing for that group → ℹ️ INFO (a judgement call; report it, don't fail on it).
113
+ 44. A **time-limited share is a principal's only active share on an item** (`expirationTimeActive: true`, no `status`, i.e. not an assignment) → ⚠️ WARNING: at the deadline the share switches off and the item disappears for that group, viewing included. Fix: a permanent `VIEW` share plus a separate time-limited `DATA_ENTRY` share for the input window. Read in source, not measured. Read the expiration and status from the live share records (`shares.search`); whether the checkout's share files carry them is not checked.
114
+
115
+ Output one row per (sheet or folder × principal × level): the item's id and folder path, the filter summary if any, the verdict, and the suggested fix (downgrade to `DATA_ENTRY` or `VIEW`, move the share to a group, remove the folder share and the copies it left on the items under it). Shares to `labels[]` have not been seen yet: list them without a verdict.
116
+
117
+ - **Confirm every 🔴 on the tenant before reporting it.** The checkout is a snapshot; read the item's shares live (`shares.search`: SDK `client.shares.search`, or `POST /shares/search` with `{"sortBy": ["ID"], "pagination": {"pageIndex": 0, "pageSize": 100}, "filter": {"itemNodeIds": {"selectAll": false, "blanks": false, "values": [<node ids>]}}}`) or open the item's sharing in the UI.
118
+
119
+ The checks ran on one tenant (2026-W46), where 37–42 came back clean. A 37 or 41 finding has not been seen live yet.
120
+
91
121
  ## Tools to invoke
92
122
 
93
123
  - Model (A–G2): `farseer model --json <tenant> > model.json` (Inputs). Search it for naming patterns (` IN"`, ` OUT"`, or the project's own markers, and `"readonly": false`) — **not** `S_`: the prefix is retired, so its absence is correct and its presence on an old model is legacy, not a defect. Search the formulas for a variable's name both quoted and bare: the export writes an identifier-shaped name without quotes
@@ -98,13 +128,14 @@ See Expected output for the full report layout and table templates.
98
128
  - `farseer sheets rows <id> --json <tenant>` — each row's variable, members, table and `readonly` flag (#32, #35)
99
129
  - `farseer sheets show <id> --json <tenant>` — the custom columns (`accountTagId` is the variable's id, `tableColumnIds` the table columns a column shows, such as an FK open for editing) and `rows.filters` (each filter's `tableId` and selected `dimensionIds`) (#34, #35)
100
130
  - A column names its variable only by id: `farseer variables list --json <tenant>` gives every variable's id as `gid`. If it warns `Variable ids unavailable`, report such a column by sheet, column name and variable id
131
+ - Sharing (§J): `farseer code checkout <org> <tenant>` (experimental) in a scratch folder outside any git repository — `access/` and `tree/`
101
132
  - Apps (#33–34): `farseer app list --details <tenant>` — every app with its scripts and arguments; `farseer pull <org> <tenant>` downloads the scripts into `farseer-apps/<tenant>/` under the current folder, so run it in a scratch folder, then search the scripts for the variables and tables they write
102
133
 
103
134
  ## Expected output
104
135
 
105
136
  **Tier 1 (review):** ordered list of issues — Errors → Warnings → Info, each with severity, location, description, fix; summary counts.
106
137
 
107
- **Tier 2 (full audit):** additionally, the full report below — the sheet vulnerability table (WARNING/DANGER with sheet ids), per-app import-job classification (OK/CRITICAL/Confusion), dimension-table FK posture, the Constrained Top Down table (Check 35: per input variable × sheet exposure), and a recommendations section (rename/lock offers, sparse fixes).
138
+ **Tier 2 (full audit):** additionally, the full report below — the sheet vulnerability table (WARNING/DANGER with sheet ids), per-app import-job classification (OK/CRITICAL/Confusion), dimension-table FK posture, the Constrained Top Down table (Check 35: per input variable × sheet exposure), the sharing posture table (section J: per item × principal × level), and a recommendations section (rename/lock offers, sparse fixes).
108
139
 
109
140
  ### Report layout
110
141
  1. **Header** — tenant, read time, model size (variable / sheet / app counts).
@@ -165,8 +196,8 @@ For each import job that touches dimension tables, determine whether it is:
165
196
 
166
197
  ## Constraints
167
198
 
168
- - Do **not** modify the tenant or the user's files; write only scratch files (the export, the pulled scripts). Output only.
199
+ - Do **not** modify the tenant or the user's files; write only scratch files (the export, the pulled scripts, section J's checkout, which never changes a share). Output only.
169
200
  - Run only reads: no command that creates, updates, deletes, pushes or runs anything on the tenant. A fix goes to the `farseer-modify-model` skill.
170
201
  - Do **not** invent symbols. If you don't see a variable in the model, say so — don't assume it exists.
171
- - If live-tenant reads are unavailable (no CLI session), mark live-only checks (F.18–22, H) as "not verified" rather than skipping them silently.
202
+ - If live-tenant reads are unavailable (no CLI session), mark live-only checks (F.18–22, H, J) as "not verified" rather than skipping them silently.
172
203
  - Recommendations (Constrained Light Top Down, missing notes, renames) are advisory — present them as such; do not present them as defects that fail a review.
@@ -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.5"
7
+ engine-profile: "3.6"
8
8
  ---
9
9
 
10
10
  # Pipeline authoring
11
11
 
12
- Pipeline authoring for simple-pipelines 3.5, the engine line in the runner image this CLI was released with. Patch releases keep the grammar, so any 3.5 engine runs what this skill describes.
12
+ Pipeline authoring for simple-pipelines 3.6, the engine line in the runner image this CLI was released with. Patch releases keep the grammar, so any 3.6 engine runs what this skill describes.
13
13
 
14
14
  ## What this is
15
15
 
@@ -78,7 +78,7 @@ Starter `main.py`, exactly what init writes:
78
78
  from farseer_simple_pipelines.runner import run_pipeline
79
79
  from farseer_simple_pipelines.storage import StoreType
80
80
  from farseer_simple_pipelines.authoring import PipelinePolicy
81
- run_pipeline(store_type=StoreType.DATASETS, pipeline_policy=PipelinePolicy(), experimental__emit_pipeline_visualization_markers=True)
81
+ run_pipeline(store_type=StoreType.DATASETS, pipeline_policy=PipelinePolicy())
82
82
  ```
83
83
 
84
84
  Incremental recipes are not the default. They need `StoreType.ICEBERG` in `main.py`, which applies to the whole pipeline, so give an incremental source's extract, and the one parse step that reads it, a pipeline folder of their own, and read the parse step's dataset downstream with `source: datasets`. Section 8 of `topic=practices` covers choosing the store, `overwrite`, `append` or `upsert`, qualifying a cursor, and rebuilding safely; read it before declaring `cursor_column` (on the extract) or `write_mode` and `merge_keys` (on its parse step), because the store, the format and the merge keys of a dataset are fixed once it exists.
@@ -11,7 +11,7 @@ A pipeline is three things in a folder: `main.py`, `Models/` (one YAML per step)
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
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
- | `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 |
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, or one per table when the file holds several, such as one per sheet, 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 |
@@ -36,7 +36,7 @@ Start from the target. Before any YAML, write down each variable the pipeline fi
36
36
  | `Models/gold/` | One row per target cell | Columns are exactly what the load maps: dimension columns, date or time columns, value columns, and any `custom_fields` |
37
37
  | `Models/load/` | Load steps | Thin: they map `gold` columns, nothing else |
38
38
 
39
- - **Why layer.** Extracting is the slow, metered part. Each extract runs once, and every transform after it can be tested with `query` against the dataset its parse step published. Rules at each boundary localise a fault to one step. Because the load is thin, the dataset you reconcile is exactly what was imported.
39
+ - **Why layer.** Extracting is the slow, metered part. Extract each source once, with every column later steps need, and every transform after it can be tested with `query` against the dataset its parse step published. Rules at each boundary localise a fault to one step. Because the load is thin, the dataset you reconcile is exactly what was imported.
40
40
  - **`name:` equals the file name, and the folder becomes the namespace:** `Models/bronze/erp_sales_lines.yaml` is `bronze.erp_sales_lines`.
41
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.
42
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.
@@ -236,6 +236,8 @@ expand:
236
236
 
237
237
  **Never load into a formula variable.** The loaded values shadow the formula; load its inputs instead.
238
238
 
239
+ **Load all dimension tables in one load step,** even when they link to each other. Use another load step only where a setting for the whole step must differ, such as `delete_missing`, or for one load per `expand:` item. Order such steps through `deps:`: one dataset the later step loads lists every dataset the earlier step loads, with a comment that those entries only set the order.
240
+
239
241
  **Dimension loads are permanent.** Members match by name, ignoring case. A renamed value becomes a new member. `delete_missing: true` deletes members absent from the load, together with their cells, so a partial run keeps it `false`.
240
242
 
241
243
  **A load step is not atomic.** Dimensions sync first, then each cells entry is its own import. If a step fails, no dataset is published, but loads that already ran keep their cells.
@@ -342,7 +344,7 @@ A client reads two things a pipeline's author writes: each step's description, a
342
344
 
343
345
  - A transform without `engine:`, or pandas doing set-based work.
344
346
  - Logic in the load step or in `main.py`; reading data or calling APIs from `main.py`.
345
- - The same YAML or function copied per company or month.
347
+ - The same YAML or function copied per company or month, or two steps that compute the same data.
346
348
  - A dataset named generically enough to collide with another pipeline's.
347
349
  - Columns kept without being declared, or codes left as numbers.
348
350
  - An `INNER JOIN` to a mapping, or a mapping `CASE` repeated across queries.