farseer-cli 1.14.2 → 1.16.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.
@@ -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: "2.9"
7
+ engine-profile: "3.0"
8
8
  ---
9
9
 
10
10
  # Pipeline authoring
11
11
 
12
- Pipeline authoring for simple-pipelines 2.9, the engine line in the runner image this CLI was released with. Patch releases keep the grammar, so any 2.9 engine runs what this skill describes.
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.
13
13
 
14
14
  ## What this is
15
15
 
@@ -22,7 +22,7 @@ If a required Simple Pipelines job, profile or source connection is missing, exp
22
22
  ## First pipeline in six steps
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
- 2. Write the YAML under `Models/`, one file per dataset, named after its `name:`. The guide topics `FarseerFilesExtractConfig`, `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.
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
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.
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.
@@ -36,7 +36,7 @@ Edit, `push`, `run`, `inspect`. `run` requires pushed files: it compares every l
36
36
 
37
37
  A refused `run` accepted no new run: read the reason, fix what it names or tell the user; never loop or switch to the ordinary CLI or API to retry.
38
38
 
39
- Iterate without runs where you can, because every run reads the sources again. Run the extracts once so they publish, then test each SQL transform with `query`, binding its inputs to those published extract versions, until it returns what you expect; only then push and run. Ask for shapes, not rows: `DESCRIBE <your SELECT>` shows the column types the run will produce, and `COUNT`, `SUM` and `GROUP BY` check totals and duplicates. Query results go to the model provider, so prefer these over reading raw rows. A Python transform cannot be tested this way, so keep its logic small and check its output with `query` after the run. Run `check` after every edit as well, knowing what it covers: the job, its image, the arguments the YAML names and whether this CLI is current. It does not validate the YAML against the grammar, look up model names or check export folders; the run's preflight does that within seconds, before any source is read.
39
+ Iterate without runs where you can, because every run reads the sources again. Run the extracts and their parse steps once so the parsed datasets publish, then test each SQL transform with `query`, binding its inputs to those published versions, until it returns what you expect; only then push and run. Ask for shapes, not rows: `DESCRIBE <your SELECT>` shows the column types the run will produce, and `COUNT`, `SUM` and `GROUP BY` check totals and duplicates. Query results go to the model provider, so prefer these over reading raw rows. A Python transform cannot be tested this way, so keep its logic small and check its output with `query` after the run. Run `check` after every edit as well, knowing what it covers: the job, its image, the arguments the YAML names and whether this CLI is current. It does not validate the YAML against the grammar, look up model names or check export folders; the run's preflight does that within seconds, before any source is read.
40
40
 
41
41
  Submit once after sync and save the UUID receipt. Inspect that UUID after reconnect; never select the latest run. Each API call, including authentication, sync and reading the response body, has a 30-second deadline. Tool cancellation, connection close or Ctrl-C aborts the network requests but does not undo server writes or cancel an accepted run. A lost response is unconfirmed: the receipt is saved before the request and survives a client restart even when the run finished quickly, and requests with an uncertain outcome are never repeated automatically. Recovery is a terminal step for the author, not an MCP operation: `farseer pipeline recover` clears the receipt when the job's history has no run since the submission (the backend records an admitted run before dispatching it, so none means none was accepted), and otherwise lists the runs in that window and clears nothing; `recover --uuid <uuid>` attaches the run that is this submission. A stale local operation lock needs the direct CLI `unlock` after its process has stopped. A queued acceptance with no runner observation needs operator investigation, not a timeout-based retry.
42
42
 
@@ -52,13 +52,15 @@ Submit once after sync and save the UUID receipt. Inspect that UUID after reconn
52
52
 
53
53
  ## Setup facts
54
54
 
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. Reading datasets, their versions and download links needs the right to run remote jobs (CLASS.REMOTE_JOB.RUN), which `init`, `check`, `query` and `versions` rely on; `restore` needs the right to update jobs (CLASS.REMOTE_JOB.UPDATE); creating or deleting datasets stays with super users and the runner. A permission refusal from `check` is a setup issue to report to the setup owner.
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 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; 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 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
- Extract: one dataset per source extraction, separate from the transformation that reshapes it. 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.
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
+
63
+ 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.
62
64
 
63
65
  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.
64
66
 
@@ -77,7 +79,7 @@ from farseer_simple_pipelines.authoring import PipelinePolicy
77
79
  run_pipeline(store_type=StoreType.DATASETS, pipeline_policy=PipelinePolicy(), experimental__emit_pipeline_visualization_markers=True)
78
80
  ```
79
81
 
80
- Incremental recipes are not the default. They need `StoreType.ICEBERG` in `main.py`, which applies to the whole pipeline, so give an incremental source its own pipeline folder and read it 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`, `write_mode` or `merge_keys`, because the store, the format and the merge keys of a dataset are fixed once it exists.
82
+ 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.
81
83
 
82
84
  ## Moving a pipeline to another tenant
83
85
 
@@ -4,24 +4,24 @@ Read this before designing a pipeline. The method gives the loop and the grammar
4
4
 
5
5
  ## 1. What goes where
6
6
 
7
- A pipeline is three things in a folder: `main.py`, `Models/` (one YAML per dataset) and `Code/` (scripts). Every responsibility has one home.
7
+ A pipeline is three things in a folder: `main.py`, `Models/` (one YAML per step) and `Code/` (scripts). Every responsibility has one home.
8
8
 
9
9
  | Part | Holds | Never holds |
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
- | `Models/<layer>/<name>.yaml` | One dataset: its step, `deps`, `schema`, `quality_rules`, and its load or export mapping. 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 | Reshaping; reading another pipeline's output through `deps`; credentials |
14
- | `parse` block | How to read the bytes: format, encoding, separator, decimal, header, start row, positional columns | What the values should be: no fixing, mapping or filtering |
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 |
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
- | `quality_rules` | What the values must mean, on extract and transform steps | Comparisons between datasets (write a reconciliation transform) |
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
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 |
21
21
  | `load` block | Column-to-model mapping, labels, import options | Any logic. To change a number, change a transform |
22
22
  | `export` block | File target, format, conflict behaviour | Shaping |
23
- | Files | Mapping tables, read with `source: files` and joined in SQL | |
24
- | The model | Member lists, read with `source: dimensions` to check codes before loading | Guesses: every name comes from the model tools |
23
+ | Files | Mapping tables, read with a `source: files` extract and its parse step, and joined in SQL | |
24
+ | The model | Member lists, read with a `source: dimensions` extract and its parse step to check codes before loading | Guesses: every name comes from the model tools |
25
25
  | Job arguments | The run's slice (period, company), fan-out lists, secrets as secret arguments | Credentials in YAML; truthiness tests (every value is a string) |
26
26
 
27
27
  ## 2. Layers and names
@@ -30,16 +30,16 @@ Start from the target. Before any YAML, write down each variable the pipeline fi
30
30
 
31
31
  | Folder | Holds | Rule |
32
32
  |---|---|---|
33
- | `Models/bronze/` | Extract-only datasets, one per source extraction | Lands the source with its own `schema` and structural rules and nothing else. No transform unless the data needs work |
33
+ | `Models/bronze/` | One extract per source extraction, `<name>_raw`, and the parse step `<name>` that reads it | The extract stores the source's file unread; the parse step reads it with the source's own `schema` and structural rules and nothing else. No transform unless the data needs work |
34
34
  | `Models/silver/` | Conformed rows | Codes cleaned, types settled, mappings joined, and an explicit flag on every row a mapping missed |
35
35
  | `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` |
36
36
  | `Models/load/` | Load steps | Thin: they map `gold` columns, nothing else |
37
37
 
38
- - **Why layer.** Extracting is the slow, metered part. Each extract runs once, and every transform after it can be tested with `query` against the published extract. Rules at each boundary localise a fault to one step. Because the load is thin, the dataset you reconcile is exactly what was imported.
38
+ - **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
39
  - **`name:` equals the file name, and the folder becomes the namespace:** `Models/bronze/erp_sales_lines.yaml` is `bronze.erp_sales_lines`.
40
40
  - **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
41
  - **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
- - **Read another pipeline's output** with `extract.type: farseer`, `source: datasets` and its `qualified_name`. It reads the last published version, and there is no ordering between pipelines.
42
+ - **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
43
  - **Keep `StoreType.DATASETS`** unless the pipeline accumulates data (section 8). `FARSEER_FILES`, the engine default, publishes on write and keeps no versions.
44
44
 
45
45
  ## 3. Transforms: SQL, then ibis, then pandas
@@ -83,12 +83,12 @@ Use a `LEFT JOIN` to a mapping and flag the rows that found no match. An `INNER
83
83
 
84
84
  ## 4. Writing schemas
85
85
 
86
- Declare a `schema:` on every extract and transform, listing every column the dataset keeps, each with a `type`. The schema is the dataset's contract with whatever reads it. The one exception is a bronze extract that deliberately captures a source whole.
86
+ Declare a `schema:` on every parse step and transform, listing every column the dataset keeps, each with a `type`. The schema is the dataset's contract with whatever reads it. The one exception is a bronze parse step that deliberately captures a source whole.
87
87
 
88
88
  - **Types:** `str`, `int`, `float`, `datetime`, `bool`, `list[str]`. There is no date or decimal type. A `DECIMAL` column fails `float` and a `DATE` column fails `datetime`, so cast in SQL.
89
- - **Cast or check.** For file payloads (CSV, JSON, Excel) the declared type is a cast: `type: str` keeps `0042` as text. For SQL, Parquet, API and Farseer sources, and for every transform, the type is only a check, so cast in the query.
89
+ - **Cast or check.** The parse step's reader decides. With `format: csv`, `json` or `xlsx` the declared type is a cast, whatever the source, Farseer Files included: `type: str` keeps `0042` as text. With `format: parquet` (the rows a SQL, API or Farseer source hands back), with a parse `script:`, and in every transform, the type is only a check, so cast in the script or query.
90
90
  - **`not_null` is separate from `type`.** Built-in quality checks let nulls pass, so pair them with `not_null`. NaN is not NULL to these checks.
91
- - **Undeclared columns are not dropped.** They land with guessed types, except in JSON, where they are dropped with a warning. Select exactly the columns you want in the query or with the extract's column selection.
91
+ - **Undeclared columns are not dropped.** They land with guessed types, except in JSON, where they are dropped with a warning. Select exactly the columns you want in the query, with the extract's column selection, or with `columns` in the parse step's `csv:` or `xlsx:` block.
92
92
  - **Dates.** There is no format declaration; the reader guesses one format per column from its first value. Keep dates ISO at the source. For an ambiguous `dd/mm/yyyy` source, declare the column `str` and parse it in SQL with an explicit `strptime` pattern.
93
93
  - **Codes are `str`,** always. Declare them, even when the source looks numeric.
94
94
  A gold dataset written the intended way, with SQL, explicit casts, a full schema and its load contract:
@@ -118,7 +118,7 @@ quality_rules:
118
118
  params: { columns: [product_code, region, month] }
119
119
  ```
120
120
 
121
- - **CSV defaults that bite.** The separator is not detected (default `,`). `NA`, `null`, `None`, `n/a` and empty read as NULL, which turns the country code `NA` into a missing value. There is no option to change that, so check such columns on purpose. Set `csv_options.decimal: ","` for decimal commas.
121
+ - **CSV defaults that bite.** The separator is not detected (default `,`). `NA`, `null`, `None`, `n/a` and empty read as NULL, which turns the country code `NA` into a missing value. There is no option to change that, so check such columns on purpose. Set `csv: {decimal: ","}` in the parse step's `parse:` block for decimal commas.
122
122
 
123
123
  ## 5. Quality rules: which kind goes where
124
124
 
@@ -163,13 +163,13 @@ os.environ["FARSEER_ARGS"] = json.dumps(args)
163
163
  **One definition, many datasets.** Use `expand` rather than copied YAML. The grammar topics do not cover this shape, so follow it exactly:
164
164
 
165
165
  ```yaml
166
- # Models/bronze/tb_file.yaml: one extract per company
166
+ # Models/bronze/tb_file_raw.yaml: one extract per company
167
167
  expand:
168
168
  values:
169
169
  - [{key: company, value: C100}]
170
170
  - [{key: company, value: C200}]
171
171
  template:
172
- name: "tb_file_{{ each.company }}"
172
+ name: "tb_file_{{ each.company }}_raw"
173
173
  type: extract
174
174
  extract:
175
175
  type: sharepoint
@@ -179,6 +179,20 @@ expand:
179
179
  # site_url and the credential arguments as usual
180
180
  ```
181
181
 
182
+ ```yaml
183
+ # Models/bronze/tb_file.yaml: one parse step per company, reading that company's extract
184
+ expand:
185
+ values:
186
+ - [{key: company, value: C100}]
187
+ - [{key: company, value: C200}]
188
+ template:
189
+ name: "tb_file_{{ each.company }}"
190
+ type: parse
191
+ deps: ["bronze.tb_file_{{ each.company }}_raw"]
192
+ parse:
193
+ format: csv
194
+ ```
195
+
182
196
  - **`expand:` is the only top-level key.** Everything else, `name` and `type` included, goes under `template:`.
183
197
  - **Each `values:` entry is a list of `{key, value}` pairs,** read as `each.<key>`. `values_expr:` computes the same list from arguments. Every rendered name must be unique.
184
198
  - **A downstream fan-out repeats the same `values:`** and names its dependency with the same key, for example `deps: ["bronze.tb_file_{{ each.company }}"]`. Its SQL then reads the view `tb_file_{{ each.company }}`.
@@ -236,7 +250,7 @@ Storage choices are the hardest to undo. A dataset's store and file format are f
236
250
  | `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 |
237
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 |
238
252
 
239
- - **An incremental source gets its own pipeline folder on `ICEBERG`.** Everything that consumes it lives in a `DATASETS` pipeline and reads it with `source: datasets`. That keeps the experimental store to the datasets that need it.
253
+ - **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.
240
254
  - **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.
241
255
 
242
256
  ### Versions, publication and restore
@@ -244,11 +258,11 @@ Storage choices are the hardest to undo. A dataset's store and file format are f
244
258
  - **Publication waits for the whole run.** By default every dataset publishes only after every step has succeeded, each dataset separately. One failing step therefore publishes nothing, and it holds back every reading position in the pipeline.
245
259
  - **Readers see the last published version.** Other pipelines, `source: datasets` and `query` keep seeing it while a run is in progress. A dataset that was never published reads as missing.
246
260
  - **`restore` makes an earlier published version current again,** and rewinds the reading position to where that version stopped. It cancels any candidate in flight. It does not undo model loads or exports.
247
- - **Nothing is deleted.** Published versions, cancelled candidates, Iceberg snapshots and files superseded by upserts all stay indefinitely, with no expiry and no compaction. A dataset may hold at most 10 unpublished candidates, and abandoned ones are marked cancelled after 24 hours.
261
+ - **Nothing is deleted.** Published versions, cancelled candidates, Iceberg snapshots and files superseded by upserts all stay indefinitely, with no expiry and no compaction. The one exception is an extract's payload, the file it stored, which is removed 30 days after it was stored. A dataset may hold at most 10 unpublished candidates, and abandoned ones are marked cancelled after 24 hours.
248
262
 
249
263
  ### Write modes: decide per dataset
250
264
 
251
- `write_mode` is set per extract or transform and defaults to `overwrite`. `append` and `upsert` work only on `ICEBERG`.
265
+ `write_mode` is set per parse step or transform and defaults to `overwrite`. `append` and `upsert` work only on `ICEBERG`.
252
266
 
253
267
  | | `overwrite` | `append` | `upsert` (with `merge_keys`) |
254
268
  |---|---|---|---|
@@ -264,12 +278,12 @@ Storage choices are the hardest to undo. A dataset's store and file format are f
264
278
  - **`merge_keys` are fixed for the dataset's life.** They must be unique within each run's output, non-null, and finite. Keys cannot be added to a dataset that already has unkeyed history; changing them means a new dataset and a rebuild. A composite key with very many distinct combinations is refused, so lead it with a low-cardinality column, such as the period.
265
279
  - **A mode can change between runs, and nothing stops a harmful change.** Switching a populated dataset from `overwrite` to `append` silently starts accumulating. Change a mode deliberately, with a rebuild if the history no longer fits.
266
280
  - **Rules and `schema:` check the whole accumulated dataset on every run,** including quiet ones, and quality rules load all of it to do so. A rule tightened so that old rows fail it blocks every future publication of that dataset. Budget the validation cost as the history grows.
267
- - **An empty full extract under `overwrite` publishes an empty dataset.** No built-in rule checks a minimum row count. Where an empty source is a fault, put `custom__distinct_count` with `min: 1` on a column that is never null, such as a key.
281
+ - **An empty full extract publishes an empty dataset** through its parse step under `overwrite`. No built-in rule checks a minimum row count. Where an empty source is a fault, put `custom__distinct_count` with `min: 1` on a column that is never null, such as a key.
268
282
  - **Under `upsert`, select columns by name and sort explicitly.** Never read by position.
269
283
 
270
284
  ### Incremental extraction
271
285
 
272
- Only a `sql_database` extract with `cursor_column`, on `ICEBERG`, reads incrementally. Default to extracting the run's slice in full with `overwrite`: it reruns cleanly, and deletions simply disappear. Go incremental only when re-reading the slice is too slow, and only after the source's cursor passes every check below.
286
+ Only a `sql_database` extract with `cursor_column`, on `ICEBERG`, reads incrementally. The `cursor_column` stays on the extract; exactly one parse step reads it and carries the `write_mode` and `merge_keys`. Default to extracting the run's slice in full with `overwrite`: it reruns cleanly, and deletions simply disappear. Go incremental only when re-reading the slice is too slow, and only after the source's cursor passes every check below.
273
287
 
274
288
  - **The window is everything strictly after the last committed position, up to a maximum measured at the start, with no lookback.** Three things are never read:
275
289
  - rows that become visible later with a cursor at or below the committed position;
@@ -279,14 +293,14 @@ Only a `sql_database` extract with `cursor_column`, on `ICEBERG`, reads incremen
279
293
  - It is a column the source types as a number, a timestamp or a sequence. A text column holding numbers sorts `10.00` below `9.50`: the dataset silently stops growing while the runs stay green.
280
294
  - It is assigned when the row commits. Rows that share the measured maximum and commit after the measurement are lost.
281
295
  - It is never null. The first read refuses null cursors, and later reads skip historical nulls for good.
282
- - **The position advances only when the version publishes,** in the same step that makes it current. A failed run publishes nothing, and the retry may read a wider window.
283
- - **The position is tied to the exact query text,** along with the host, database, table and cursor column. Any edit, a comment or reformatting included, makes later runs refuse until an operator moves the position to the new query through the dataset's watermark endpoint. Treat an incremental query as frozen.
296
+ - **The position advances only when the parse step's version publishes,** in the same action that makes it current. A failed run publishes nothing, and the retry may read a wider window.
297
+ - **The position is tied to the exact query text,** along with the host, database, table and cursor column. Any edit, a comment or reformatting included, makes later runs refuse until an operator moves the position to the new query through the watermark endpoint of the parse step's dataset. Treat an incremental query as frozen.
284
298
  - **A quiet run,** with no new rows, cancels its candidate and keeps the data and the position. It still runs validation.
285
299
  - **There is no lease.** Two runs of one incremental dataset at once cancel each other's work. Give each such dataset one schedule and no overlapping manual runs.
286
300
  - **Rebuilding safely:**
287
301
  1. Stop the schedule.
288
302
  2. Have the operator delete the watermark.
289
- 3. Run once with `write_mode: overwrite`. That reads from the beginning, replaces the table and records a fresh position, and merge keys survive.
303
+ 3. Run once with `write_mode: overwrite` on the parse step. That reads from the beginning, replaces the table and records a fresh position, and merge keys survive.
290
304
  4. Switch back to `append` or `upsert`.
291
305
 
292
306
  Never delete the watermark and rerun under `append`: that stores everything twice. To undo one bad publication, `restore` the previous version instead.
@@ -303,7 +317,7 @@ Only a `sql_database` extract with `cursor_column`, on `ICEBERG`, reads incremen
303
317
 
304
318
  ## 9. Verify
305
319
 
306
- - **Before the first run:** run `check`, confirm every model name with the model tools, and run the extracts once. Then test each SQL transform with `query` against the published extracts, asking for shapes (`DESCRIBE`, `COUNT`, `SUM`, `GROUP BY ... HAVING count(*) > 1`) rather than rows.
320
+ - **Before the first run:** run `check`, confirm every model name with the model tools, and run the extracts and their parse steps once. Then test each SQL transform with `query` against the datasets the parse steps published, asking for shapes (`DESCRIBE`, `COUNT`, `SUM`, `GROUP BY ... HAVING count(*) > 1`) rather than rows.
307
321
  - **After every run:**
308
322
  - `inspect` the run by its UUID: every step OK, `skippedOutputs` empty, each import `commit_confirmed`, and no failed undo.
309
323
  - Query gold for its row count, zero duplicate coordinates, and totals per period against the control totals.