farseer-cli 1.18.0 → 1.20.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 (262) hide show
  1. package/README.md +33 -10
  2. package/dist/commands/app.js +42 -3
  3. package/dist/commands/app.js.map +1 -2
  4. package/dist/commands/apps.js.map +0 -1
  5. package/dist/commands/cells.js +120 -85
  6. package/dist/commands/cells.js.map +1 -2
  7. package/dist/commands/code.js.map +0 -1
  8. package/dist/commands/config.js.map +0 -1
  9. package/dist/commands/dashboards.js +246 -12
  10. package/dist/commands/dashboards.js.map +1 -2
  11. package/dist/commands/diff.js.map +0 -1
  12. package/dist/commands/dimensions.js +52 -27
  13. package/dist/commands/dimensions.js.map +1 -2
  14. package/dist/commands/docs.js +82 -0
  15. package/dist/commands/docs.js.map +6 -0
  16. package/dist/commands/files.js +49 -0
  17. package/dist/commands/files.js.map +2 -3
  18. package/dist/commands/folders.js +76 -0
  19. package/dist/commands/folders.js.map +6 -0
  20. package/dist/commands/formula.js +38 -30
  21. package/dist/commands/formula.js.map +1 -2
  22. package/dist/commands/install.js +32 -30
  23. package/dist/commands/install.js.map +2 -3
  24. package/dist/commands/list.js.map +0 -1
  25. package/dist/commands/login.js +3 -3
  26. package/dist/commands/login.js.map +1 -2
  27. package/dist/commands/logout.js.map +0 -1
  28. package/dist/commands/mcp-server.js.map +0 -1
  29. package/dist/commands/model.js +30 -5
  30. package/dist/commands/model.js.map +2 -3
  31. package/dist/commands/pipeline.js.map +0 -1
  32. package/dist/commands/pull.js +1 -1
  33. package/dist/commands/pull.js.map +1 -2
  34. package/dist/commands/push.js +6 -4
  35. package/dist/commands/push.js.map +1 -2
  36. package/dist/commands/refresh.js.map +0 -1
  37. package/dist/commands/run.js.map +0 -1
  38. package/dist/commands/sheets.js +289 -52
  39. package/dist/commands/sheets.js.map +1 -2
  40. package/dist/commands/skills.js +157 -0
  41. package/dist/commands/skills.js.map +6 -0
  42. package/dist/commands/status.js.map +0 -1
  43. package/dist/commands/tool.js.map +0 -1
  44. package/dist/commands/variables.js +246 -82
  45. package/dist/commands/variables.js.map +1 -2
  46. package/dist/commands/whoami.js.map +0 -1
  47. package/dist/index.js +117 -23
  48. package/dist/index.js.map +1 -2
  49. package/dist/mcp/index.js.map +0 -1
  50. package/dist/mcp/prompts/workflows.js.map +0 -1
  51. package/dist/mcp/resources/documentation.js +19 -12
  52. package/dist/mcp/resources/documentation.js.map +1 -2
  53. package/dist/mcp/server.js.map +0 -1
  54. package/dist/mcp/skills.js.map +0 -1
  55. package/dist/mcp/tools/appTools.js +1 -7
  56. package/dist/mcp/tools/appTools.js.map +1 -2
  57. package/dist/mcp/tools/authTools.js +1 -1
  58. package/dist/mcp/tools/authTools.js.map +1 -2
  59. package/dist/mcp/tools/cellTools.js +6 -19
  60. package/dist/mcp/tools/cellTools.js.map +1 -2
  61. package/dist/mcp/tools/dashboardTools.js +30 -412
  62. package/dist/mcp/tools/dashboardTools.js.map +2 -3
  63. package/dist/mcp/tools/dataTools.js +15 -146
  64. package/dist/mcp/tools/dataTools.js.map +1 -2
  65. package/dist/mcp/tools/folderTools.js +12 -78
  66. package/dist/mcp/tools/folderTools.js.map +1 -2
  67. package/dist/mcp/tools/modelTools.js +23 -372
  68. package/dist/mcp/tools/modelTools.js.map +1 -2
  69. package/dist/mcp/tools/pipelineContract.js +5 -1
  70. package/dist/mcp/tools/pipelineContract.js.map +1 -2
  71. package/dist/mcp/tools/pipelineTools.js.map +0 -1
  72. package/dist/mcp/tools/runTools.js +8 -69
  73. package/dist/mcp/tools/runTools.js.map +1 -2
  74. package/dist/mcp/tools/sheetTools.js +14 -264
  75. package/dist/mcp/tools/sheetTools.js.map +1 -2
  76. package/dist/mcp/tools/syncTools.js +7 -3
  77. package/dist/mcp/tools/syncTools.js.map +1 -2
  78. package/dist/mcp/utils/helpers.js.map +0 -1
  79. package/dist/mcp/utils/launchPin.js.map +0 -1
  80. package/dist/mcp/utils/operationResponse.js +41 -0
  81. package/dist/mcp/utils/operationResponse.js.map +6 -0
  82. package/dist/mcp/utils/registerTool.js.map +0 -1
  83. package/dist/mcp/utils/session.js.map +0 -1
  84. package/dist/mcp/utils/tenantPin.js.map +0 -1
  85. package/dist/operations/cells.js +444 -0
  86. package/dist/operations/cells.js.map +6 -0
  87. package/dist/operations/dashboards.js +357 -0
  88. package/dist/operations/dashboards.js.map +6 -0
  89. package/dist/operations/data.js +206 -0
  90. package/dist/operations/data.js.map +6 -0
  91. package/dist/operations/errors.js +64 -0
  92. package/dist/operations/errors.js.map +6 -0
  93. package/dist/operations/exportModel.js +59 -0
  94. package/dist/operations/exportModel.js.map +6 -0
  95. package/dist/operations/folderPath.js +128 -0
  96. package/dist/operations/folderPath.js.map +6 -0
  97. package/dist/operations/folders.js +80 -0
  98. package/dist/operations/folders.js.map +6 -0
  99. package/dist/operations/install.js +109 -0
  100. package/dist/operations/install.js.map +6 -0
  101. package/dist/operations/model.js +271 -0
  102. package/dist/operations/model.js.map +6 -0
  103. package/dist/operations/sheets.js +428 -0
  104. package/dist/operations/sheets.js.map +6 -0
  105. package/dist/pipeline/compatibility.js.map +0 -1
  106. package/dist/pipeline/connect.js.map +0 -1
  107. package/dist/pipeline/create.js.map +0 -1
  108. package/dist/pipeline/errors.js.map +0 -1
  109. package/dist/pipeline/failStep.js +43 -0
  110. package/dist/pipeline/failStep.js.map +6 -0
  111. package/dist/pipeline/generated-reference.json +25 -13
  112. package/dist/pipeline/guide.js.map +0 -1
  113. package/dist/pipeline/init.js.map +0 -1
  114. package/dist/pipeline/operations.js.map +0 -1
  115. package/dist/pipeline/query.js.map +0 -1
  116. package/dist/pipeline/queryDownloads.js.map +0 -1
  117. package/dist/pipeline/queryWorker.js +3 -1
  118. package/dist/pipeline/queryWorker.js.map +1 -2
  119. package/dist/pipeline/readiness.js.map +0 -1
  120. package/dist/pipeline/reference.js.map +0 -1
  121. package/dist/pipeline/requests.js +3 -32
  122. package/dist/pipeline/requests.js.map +1 -2
  123. package/dist/pipeline/runArguments.js.map +0 -1
  124. package/dist/pipeline/runtime.js.map +0 -1
  125. package/dist/pipeline/service.js +46 -2
  126. package/dist/pipeline/service.js.map +1 -2
  127. package/dist/services/appSyncService.js +59 -9
  128. package/dist/services/appSyncService.js.map +1 -2
  129. package/dist/services/apps.js +10 -0
  130. package/dist/services/apps.js.map +1 -2
  131. package/dist/services/authErrors.js.map +0 -1
  132. package/dist/services/codefirst/api.js +38 -5
  133. package/dist/services/codefirst/api.js.map +1 -2
  134. package/dist/services/codefirst/binaryDisk.js.map +0 -1
  135. package/dist/services/codefirst/byteHashes.js +5 -0
  136. package/dist/services/codefirst/byteHashes.js.map +1 -2
  137. package/dist/services/codefirst/documents.js +41 -15
  138. package/dist/services/codefirst/documents.js.map +1 -2
  139. package/dist/services/codefirst/layoutBinaryProjection.js +24 -13
  140. package/dist/services/codefirst/layoutBinaryProjection.js.map +1 -2
  141. package/dist/services/codefirst/layoutCompose.js +44 -38
  142. package/dist/services/codefirst/layoutCompose.js.map +1 -2
  143. package/dist/services/codefirst/layoutCore.js +14 -1
  144. package/dist/services/codefirst/layoutCore.js.map +1 -2
  145. package/dist/services/codefirst/layoutPaths.js +80 -4
  146. package/dist/services/codefirst/layoutPaths.js.map +1 -2
  147. package/dist/services/codefirst/layoutProjection.js +73 -39
  148. package/dist/services/codefirst/layoutProjection.js.map +1 -2
  149. package/dist/services/codefirst/layoutReadback.js +357 -130
  150. package/dist/services/codefirst/layoutReadback.js.map +2 -3
  151. package/dist/services/codefirst/layoutReadbackPlacement.js +94 -57
  152. package/dist/services/codefirst/layoutReadbackPlacement.js.map +2 -3
  153. package/dist/services/codefirst/layoutReceipt.js +283 -243
  154. package/dist/services/codefirst/layoutReceipt.js.map +2 -3
  155. package/dist/services/codefirst/layoutScan.js +208 -110
  156. package/dist/services/codefirst/layoutScan.js.map +1 -2
  157. package/dist/services/codefirst/output.js +76 -10
  158. package/dist/services/codefirst/output.js.map +1 -2
  159. package/dist/services/codefirst/types.js.map +0 -1
  160. package/dist/services/codefirst/workflow.js +65 -29
  161. package/dist/services/codefirst/workflow.js.map +2 -3
  162. package/dist/services/codefirst/workspace.js.map +0 -1
  163. package/dist/services/codefirst/workspaceLock.js.map +0 -1
  164. package/dist/services/codefirst/workspaceRoot.js +2 -1
  165. package/dist/services/codefirst/workspaceRoot.js.map +1 -2
  166. package/dist/services/configService.js.map +0 -1
  167. package/dist/services/credentials.js.map +0 -1
  168. package/dist/services/farseerService.js +31 -7
  169. package/dist/services/farseerService.js.map +1 -2
  170. package/dist/services/httpError.js.map +0 -1
  171. package/dist/services/modelExport.js.map +0 -1
  172. package/dist/services/organisation.js.map +0 -1
  173. package/dist/services/preflight.js.map +0 -1
  174. package/dist/services/realms.js.map +0 -1
  175. package/dist/services/syncService.js +3 -3
  176. package/dist/services/syncService.js.map +1 -2
  177. package/dist/skills/bundled.js +106 -0
  178. package/dist/skills/bundled.js.map +6 -0
  179. package/dist/skills/install.js +257 -0
  180. package/dist/skills/install.js.map +6 -0
  181. package/dist/skills/pipeline.js +10 -18
  182. package/dist/skills/pipeline.js.map +1 -2
  183. package/dist/utils/agentSandbox.js +1 -1
  184. package/dist/utils/agentSandbox.js.map +0 -1
  185. package/dist/utils/cliOptions.js.map +0 -1
  186. package/dist/utils/constants.js.map +0 -1
  187. package/dist/utils/entityResolver.js +72 -25
  188. package/dist/utils/entityResolver.js.map +1 -2
  189. package/dist/utils/errorFormatter.js +72 -11
  190. package/dist/utils/errorFormatter.js.map +1 -2
  191. package/dist/utils/fileLogger.js.map +0 -1
  192. package/dist/utils/fileValidation.js.map +0 -1
  193. package/dist/utils/folderMatch.js.map +0 -1
  194. package/dist/utils/formulaFilters.js +11 -2
  195. package/dist/utils/formulaFilters.js.map +1 -2
  196. package/dist/utils/helpers.js.map +0 -1
  197. package/dist/utils/logger.js.map +0 -1
  198. package/dist/utils/nameResolver.js.map +0 -1
  199. package/dist/utils/operationCli.js +102 -0
  200. package/dist/utils/operationCli.js.map +6 -0
  201. package/dist/utils/packageManager.js.map +0 -1
  202. package/dist/utils/syncReporting.js.map +0 -1
  203. package/dist/utils/syncScope.js.map +0 -1
  204. package/dist/utils/updateCheck.js.map +0 -1
  205. package/dist/utils/variableValues.js.map +0 -1
  206. package/dist/utils/workspace.js.map +0 -1
  207. package/docs/cli-guide.md +182 -2
  208. package/docs/import-workflows.md +14 -14
  209. package/docs/new-app-template.md +1 -1
  210. package/docs/pipeline-client-guide.md +1 -1
  211. package/docs/pipeline-reference.md +304 -9
  212. package/docs/troubleshooting.md +18 -0
  213. package/package.json +2 -2
  214. package/skills/farseer-analysis/SKILL.md +132 -0
  215. package/skills/farseer-app-dev/SKILL.md +131 -0
  216. package/skills/farseer-app-dev/assignments.md +185 -0
  217. package/skills/farseer-app-dev/farseer-client-api-guide.md +907 -0
  218. package/skills/farseer-app-dev/farseer-client-release-notes.md +212 -0
  219. package/skills/farseer-app-dev/working-patterns.md +876 -0
  220. package/skills/farseer-authenticate-to-tenant/SKILL.md +60 -0
  221. package/skills/farseer-authenticate-to-tenant/app-authentication.md +91 -0
  222. package/skills/farseer-author-import-job/SKILL.md +114 -0
  223. package/skills/farseer-author-import-job/cell-writes.md +530 -0
  224. package/skills/farseer-author-import-job/deploying-a-farseer-app.md +383 -0
  225. package/skills/farseer-author-import-job/import-job-pattern.md +232 -0
  226. package/skills/farseer-build-model/SKILL.md +122 -0
  227. package/skills/farseer-build-model/formula-grain-alignment.md +612 -0
  228. package/skills/farseer-build-model/naming-conventions.md +435 -0
  229. package/skills/farseer-build-model/sparse-formulas-pattern.md +330 -0
  230. package/skills/farseer-build-pipeline/SKILL.md +190 -0
  231. package/skills/farseer-build-pipeline/erp-sales/README.md +108 -0
  232. package/skills/farseer-build-pipeline/erp-sales/erp-sales-etl/Models/bronze/erp_sales_invoice_lines.yaml +23 -0
  233. package/skills/farseer-build-pipeline/erp-sales/erp-sales-etl/Models/bronze/erp_sales_invoice_lines_raw.yaml +23 -0
  234. package/skills/farseer-build-pipeline/erp-sales/erp-sales-etl/Models/bronze/erp_sales_item_product_map.yaml +17 -0
  235. package/skills/farseer-build-pipeline/erp-sales/erp-sales-etl/Models/bronze/erp_sales_item_product_map_raw.yaml +11 -0
  236. package/skills/farseer-build-pipeline/erp-sales/erp-sales-etl/Models/gold/erp_sales_cells.yaml +40 -0
  237. package/skills/farseer-build-pipeline/erp-sales/erp-sales-etl/Models/silver/erp_sales_lines.yaml +35 -0
  238. package/skills/farseer-build-pipeline/erp-sales/erp-sales-etl/Models/silver/erp_sales_recon.yaml +43 -0
  239. package/skills/farseer-build-pipeline/erp-sales/erp-sales-etl/Models/silver/erp_sales_unmapped_items.yaml +28 -0
  240. package/skills/farseer-build-pipeline/erp-sales/erp-sales-etl/main.py +49 -0
  241. package/skills/farseer-build-pipeline/erp-sales/erp-sales-load/Models/in/erp_sales_cells.yaml +17 -0
  242. package/skills/farseer-build-pipeline/erp-sales/erp-sales-load/Models/in/erp_sales_cells_raw.yaml +14 -0
  243. package/skills/farseer-build-pipeline/erp-sales/erp-sales-load/Models/load/erp_sales_to_model.yaml +47 -0
  244. package/skills/farseer-build-pipeline/erp-sales/erp-sales-load/main.py +44 -0
  245. package/skills/farseer-build-pipeline/erp-sales/item_to_product.csv +5 -0
  246. package/skills/farseer-build-pipeline/pipeline-app-failure-report-pattern.md +103 -0
  247. package/skills/farseer-build-pipeline/pipeline-source-encoding.md +68 -0
  248. package/skills/farseer-dashboards/SKILL.md +40 -0
  249. package/skills/farseer-formulas/SKILL.md +165 -0
  250. package/skills/farseer-help-center/SKILL.md +66 -0
  251. package/skills/farseer-model/SKILL.md +119 -0
  252. package/skills/farseer-modify-model/SKILL.md +158 -0
  253. package/skills/farseer-modify-model/model-validation-pattern.md +251 -0
  254. package/skills/farseer-optimize-model/SKILL.md +314 -0
  255. package/skills/farseer-optimize-model/stats-dump.ts +139 -0
  256. package/skills/farseer-pnl/SKILL.md +220 -0
  257. package/skills/farseer-review-model/SKILL.md +172 -0
  258. package/skills/farseer-run-apps/SKILL.md +102 -0
  259. package/skills/pipeline-authoring/SKILL.md +7 -5
  260. package/skills/pipeline-authoring/practices.md +21 -8
  261. package/dist/services/agentApprovalFetch.js +0 -86
  262. package/dist/services/agentApprovalFetch.js.map +0 -7
@@ -0,0 +1,102 @@
1
+ ---
2
+ name: farseer-run-apps
3
+ description: Find, inspect and run Farseer apps, the configured imports, recalculations, exports and integrations that run on the tenant's job runner. Covers matching the app the user means, reading its expected arguments, collecting every required input before a run, starting the run, and reporting it without claiming it finished. Use when the user asks to run, start or launch something by name, or asks what an app needs; an app is not a variable or a table. To write a Simple Pipeline, or to run one you are building or changing, use the `pipeline-authoring` skill instead.
4
+ metadata:
5
+ version: "1"
6
+ ---
7
+
8
+ # Running Farseer apps
9
+
10
+ An app is a runnable unit configured in a Farseer workspace: an import, a recalculation, an export or an integration. It has a name, an optional description, the arguments it expects and a status. Someone starts it with values for its arguments; it then runs in the background on the tenant's job runner and writes its results back to Farseer. Paths below are under `/api/v3`.
11
+
12
+ **An app is not a model variable or table.** When the user names something that is not in the model but treats it as runnable, look it up among the apps (steps 1 and 2) before you call it unknown.
13
+
14
+ A request about an app is one of two kinds:
15
+
16
+ - **Inspect**: the user wants the list of apps, or what inputs an app needs. Do steps 1 and 2, report what you found, and stop. Start nothing.
17
+ - **Run**: the user wants the app run, started or launched. Do all five steps.
18
+
19
+ ## The rule that matters most: never start an app with a required input missing
20
+
21
+ **Do not start an app until every required input has a value.** A required input is an expected argument that is not `fixed` and has no usable `defaultValue`. If one is still missing after you have checked the user's request and the conversation, ask the user for it and stop: do not start the app, do not substitute a placeholder, do not pass an empty value, and do not report "inputs used: none". An app run with a wrong or missing input does real work, possibly destructive. This holds even where your other instructions tell you not to ask the user questions.
22
+
23
+ When inputs are missing, your whole turn is asking for them. The app is started only on a later turn, once the user has given the values. Never ask and start in the same turn.
24
+
25
+ ## 1. Find the app
26
+
27
+ List the apps (`GET /remoteJobs`; from the CLI, `farseer app list --details` lists them with their description and status) and match the request to one:
28
+
29
+ - Match on the `name`, and on the `description` when there is one. A shortened or paraphrased name should match the closest app.
30
+ - If exactly one app plausibly matches, use it.
31
+ - If **several** plausibly match, ask the user which one they mean and list the candidates; do not guess.
32
+ - If **none** matches, say you could not find an app by that name and, if it helps, name a few apps that exist.
33
+ - If the app's `status` is `UNAVAILABLE`, say it cannot run right now and stop.
34
+ - If its `status` is `QUEUED` or `RUNNING`, a run of it is already waiting or in progress. Another run would wait in the job runner's queue and then do the same work again. Tell the user, and start another only if they want one.
35
+
36
+ ## 2. Read its arguments
37
+
38
+ Read the full app: `GET /remoteJobs/{id}`, or from the CLI `farseer tool call farseer_get_app --tenant TENANT --args '{"appName": "APP"}'` (`appId` instead when names collide), which lists the inputs under `arguments` with the same fields except `hasSavedValue`. Each expected argument is one input:
39
+
40
+ - `name`: the argument's name.
41
+ - `dataType`: `"string"` or `"boolean"`.
42
+ - `defaultValue`: the value used when the user gives none; it may be absent.
43
+ - `options`: when present, a closed list of allowed string values. Treat it as a choice.
44
+ - `fixed`: when true, the workspace sets the value and the user cannot change it. **Never ask about a fixed argument** and never show it.
45
+ - `secret`: when true, the value is sensitive: a password, a token, a key. Never show its `options` or any value of it.
46
+ - `hasSavedValue`: on a secret, true when the workspace already stores a value for it. The value itself is never returned.
47
+
48
+ The full app keeps secrets in plain text: a secret argument's `options` can be the secret itself, and a preset's `runArguments` can pin one. When you read an app, print only what you need: filter out the `options` of every `secret` argument and every secret value inside a preset before printing (with `jq` or a short script), so no secret reaches your output, the conversation or the user.
49
+
50
+ An empty list of arguments means the app takes no input. Do not conclude "no inputs" from a read you are unsure of: read the app again, because running an app with the wrong inputs costs a lot.
51
+
52
+ An app may also have `predefinedActions`: named presets, each with `runArguments` that pin values by argument name. These can hold secret values in plain text: never show, repeat or copy one. When the user names a preset, use its values for the arguments it pins, unless it pins a secret: then do not start it yourself, because an empty slot would run with the app's own saved secret rather than the preset's. Ask the user to start that preset in Farseer.
53
+
54
+ ## 3. Decide each value, and stop to ask if a required one is missing
55
+
56
+ First check step 4 for whether you can start the run at all. If you cannot, still work out which inputs are missing, but do not ask for secret values: the user enters those when they start the app in Farseer.
57
+
58
+ Go through every expected argument, in order, and classify it:
59
+
60
+ - `fixed` → do not ask and do not infer. The workspace uses its own value whatever you send; put an empty string `""` in its slot.
61
+ - Otherwise, a value the user clearly gave, in the request or earlier in the conversation → use it.
62
+ - Otherwise, a `defaultValue` → you may use it without asking.
63
+ - Otherwise → the argument is **required and missing**. Add it to the list to ask for.
64
+ - `secret` and not given explicitly by the user → **always** add it to the list, even if something in the context looks like the value. Never infer a secret. The one exception: a secret whose `hasSavedValue` is true runs with its saved value when its slot is `""`, so ask for it only if the user wants a different value.
65
+
66
+ **Then branch. This is the gate:**
67
+
68
+ - **The list is not empty:** stop, and start nothing this turn. Ask the user for exactly those inputs, then end your turn and wait for the answer. Name each input by its purpose; for an argument with `options`, give the allowed choices, except for a secret, which you ask for by purpose only; for a `boolean` argument, ask a plain yes-or-no question. Do not start the app, do not build the argument list ahead, and do not say the app started. On the user's next turn, with the values in hand, go on from step 4.
69
+ - **The list is empty:** every input has a value; go on to step 4.
70
+
71
+ The server does not refuse an empty free-text value: it runs the app with an empty string. This gate is the only thing that stops a run with a missing input.
72
+
73
+ Validate before you start the app:
74
+
75
+ - A `boolean` value is the **string** `"true"` or `"false"`, in lowercase. Turn a yes or no answer into one of them.
76
+ - A value for an argument with `options` is exactly one of those options.
77
+
78
+ ## 4. Start the run
79
+
80
+ A run takes its arguments as a **positional list of strings in the order of the expected arguments**, one entry per expected argument, with `""` for a fixed argument and for a secret that keeps its saved value. It is a list, not a map from name to value.
81
+
82
+ How you start it depends on what your environment gives you:
83
+
84
+ - **With access to the Farseer API**, through an SDK client or a helper your environment provides: `POST /remoteJobs/{id}/run` with the body `{"arguments": ["...", "..."]}`. It answers `202` with a `runUuid` once the run is queued.
85
+ - **With only the `farseer` CLI**, the one command that starts a run on the tenant is `farseer pipeline run`, for a Simple Pipeline you are building (see the `pipeline-authoring` skill). For any other app you cannot start the run. `farseer run` and the `farseer_run_app` tool run the app's code on this machine with your own credentials, which is a different run from the job runner's; never use them in place of one. Give the user the app's name and the values you decided on, leaving out every secret, and ask them to start it in Farseer. Say plainly that you did not start it.
86
+
87
+ ## 5. Report back
88
+
89
+ A started app runs in the background and returns no result. Once the run is accepted:
90
+
91
+ - Tell the user the app has started, and restate the values it runs with. Leave out every `secret` and every `fixed` argument.
92
+ - Point the user to the app's run history to follow its progress and see the outcome. If the start gave you a run id, the run is in `GET /remoteJobs/{id}/remoteJobRuns` under that `uuid`, with a `status` of `QUEUED`, `RUNNING`, `FINISHED` or `ERROR`.
93
+ - Do **not** claim the app finished, and do not report results you do not have: you only know it started.
94
+
95
+ ## When the start fails
96
+
97
+ Read the error's message, then tell the user what happened in terms of the app and its inputs. Pass on what concerns them, such as a refused value or a part of the app's setup that is missing; for anything about the job runner, say only that apps cannot run right now.
98
+
99
+ - **Forbidden (403):** usually the user may not run that app. The same status also means the job runner is not connected: then no app can run right now, and it is not about the user's access. An app deleted since you listed it also answers 403, so when the message is not about the job runner, list the apps again before you tell the user they lack access.
100
+ - **Not found (404):** the app no longer exists. List the apps again and reconcile.
101
+ - **Bad request (400):** the app cannot run as it is configured, or one of the values was refused. Say what is wrong and stop. Do not start the app again, not even with a value you corrected yourself: a value that must change is the user's to give (step 3).
102
+ - **Anything else:** say the app could not be started right now and ask the user to try again later.
@@ -4,12 +4,12 @@ description: Author all new repeatable Farseer data pipelines with Simple Pipeli
4
4
  metadata:
5
5
  version: "1"
6
6
  minimum-cli: "1.14.2"
7
- engine-profile: "3.0"
7
+ engine-profile: "3.3"
8
8
  ---
9
9
 
10
10
  # Pipeline authoring
11
11
 
12
- Pipeline authoring for simple-pipelines 3.0, the engine line in the runner image this CLI was released with. Patch releases keep the grammar, so any 3.0 engine runs what this skill describes.
12
+ Pipeline authoring for simple-pipelines 3.3, the engine line in the runner image this CLI was released with. Patch releases keep the grammar, so any 3.3 engine runs what this skill describes.
13
13
 
14
14
  ## What this is
15
15
 
@@ -23,7 +23,7 @@ If a required Simple Pipelines job, profile or source connection is missing, exp
23
23
 
24
24
  1. `init name=<folder>` (CLI: `farseer pipeline init <org> <tenant> --new <name>`) creates the local folder under files/<name>/ (`main.py`, an empty `Models/` and `Code/`), uploads `main.py` into a new source folder Files/<name>, creates a job named <name> with that folder, `main.py` as entrypoint and the runner-python-simple-pipelines image this CLI was released with, then writes the profile farseer-apps/<tenant>/.pipelines/<name>.json. If files/<name>/ already exists locally with a `main.py`, init adopts it instead: it uploads the folder's source files as they are and writes no starter.
25
25
  2. Write the YAML under `Models/`, one file per step, named after its `name:`. The guide topics `FarseerFilesExtractConfig`, `ParseConfig`, `TransformConfig` and `LoadCellsConfig` each end with a complete example the engine accepts; start from those. Discover real source, dataset and model names with the existing tools first.
26
- 3. Give the job its secrets. A source that needs a key or password (Business Central, a private Drive folder, SharePoint) reads it from a secret-typed job argument and the YAML names it as `{{ pipeline_args.NAME }}`; never write the value into YAML, the engine refuses `farseer_credentials` blocks. init creates the job with no arguments, so add each one with `farseer_configure_app` (`arguments: [{name, dataType: "string", secret: true, defaultValue: "<the value>"}]`) or in the web app before the first real run. The value is the argument's `defaultValue`; reads and run logs show it masked. Setting it through the tool puts the value in this conversation, so when the client prefers, ask the admin to type it into the web app instead. `check` lists every `pipeline_args.NAME` the YAML uses that the job does not define.
26
+ 3. Give the job its secrets. A source that needs a key or password (Business Central, a private Drive folder, SharePoint, an HTTP API's `auth:`, a custom connector's `secrets:`) reads it from a secret-typed job argument and the YAML names it as `{{ pipeline_args.NAME }}`; never write the value into YAML, the engine refuses `farseer_credentials` blocks. init creates the job with no arguments, so add each one with `farseer_configure_app` (`arguments: [{name, dataType: "string", secret: true, defaultValue: "<the value>"}]`) or in the web app before the first real run. The value is the argument's `defaultValue`; reads and run logs show it masked. Setting it through the tool puts the value in this conversation, so when the client prefers, ask the admin to type it into the web app instead. `check` lists every `pipeline_args.NAME` the YAML uses that the job does not define.
27
27
  4. `push` uploads the edited files.
28
28
  5. `run` submits one run and returns a run UUID receipt. To change a job argument for one run, pass it by name: `args: ["MONTH=2026-08"]` (CLI: `--arg MONTH=2026-08`, repeatable). Arguments you do not name keep the job's default; a name the job does not declare, a bare value, an empty value or a fixed argument is refused before anything is sent, and the receipt lists the arguments it used, secrets masked.
29
29
  6. `inspect` reads that run's logs and markers. Then read the output with `query` on the output dataset, and what each load committed with `inspect-import` on the import ID that `loads` reports. Never check a load with a model or variable export: it pulls whole variables out of the tenant's in-memory model.
@@ -54,15 +54,17 @@ Submit once after sync and save the UUID receipt. Inspect that UUID after reconn
54
54
 
55
55
  The backend records each run before dispatch and answers with its run UUID. The tenant's jobrunner must be 3.6.0 or newer: an older one cannot keep the run id the backend assigns, so the backend refuses to send it the run and says so, and no run starts. A 3.0 pipeline keeps each extract's file for 30 days in the backend's payload area, which needs a backend that has it, storage that can sign download and upload links, and a runner key that is a super user's or holds CLASS.REMOTE_JOB.RUN_AS_SERVICE; without them the first extract fails. Reading datasets, their versions and download links needs the right to update jobs (CLASS.REMOTE_JOB.UPDATE) or the Data Hub permission (FEATURE.DATA_HUB); `init`, `check`, `query` and `versions` rely on it. `restore` needs the right to update jobs; creating or deleting datasets stays with super users and the runner. Download links, restores and other dataset changes made by a person are recorded in the audit log. A permission refusal from `check` is a setup issue to report to the setup owner.
56
56
 
57
- `check` reads the prepared job, its runner image, whether a newer CLI was released with the tenant's runner image (`cli-version`, pending means update before authoring), and the output manifests, then probes the first Parquet file using signed HTTPS access, or through the API when the CLI runs with an agent turn key, because an agent sandbox can reach only the API. This CLI authors for exactly one engine: the one inside the runner image it was released with. Only jobs already using a Simple Pipelines runner are eligible for image pinning. TypeScript, other runner families and an unknown or inherited image are refused by init, source sync and run; use the existing app tools and preserve the app. The CLI never changes a job's image on its own. A Simple Pipelines job on an older released image is reported as failed: `run`, `pull` and reads still work on its own image, but `push` is refused (`RUNTIME_UPGRADE_REQUIRED`) until the job is upgraded with `upgrade-runtime` (CLI: `farseer pipeline upgrade-runtime`), which moves it to this CLI's image and reports where it moved from. Upgrading changes the engine for everyone on that tenant and, on a scheduled job, for the next scheduled run, so ask the user before upgrading, then `run` once and fix whatever the newer engine's preflight rejects. A pipeline written for simple-pipelines 2.x never passes it: split every extract into `<name>_raw` and a parse step (Authoring rules below) and push the split right after the upgrade, before the job runs again, because every run from the upgrade on, scheduled ones included, uses this engine and fails until the split is pushed. A job on a moving tag such as `latest`, or on a digest, is reported as pending and left as it is: `upgrade-runtime` refuses it, and each run reports the engine it started on (`engine` in `inspect`). A job on a newer released image is reported as pending: it runs and accepts pushes, but update the CLI to author what the newer engine added. No job is ever moved down. A dataset declared under `Models/` is created by the engine on the first run, so init and check report a dataset that does not exist yet as pending, not as an error; an extract (`<name>_raw`) stores a payload and a load writes no dataset, so those two stay pending after the first run as well, which is expected; after the first run, rerun `init jobId=<id> force=true` to record the new dataset IDs (a rerun for the same job and folder keeps the setup record, declared config files and author), and the profile's `datasetIds` lists the outputs recorded so far. No published version means read verification stays pending until the first prepared run. The setup record (owner, evidence, checkedAt, retentionDays, otherWritersExcluded=true, runtimeVerified=true) is the owner's statement, not an API-verified fact: do not invent it, and reconfirm it after setup changes. `readyForAcceptance` does not establish source replay, reconciliation or real-client acceptance.
57
+ `check` reads the prepared job, its runner image, whether a newer CLI was released with the tenant's runner image (`cli-version`, pending means update before authoring), the step descriptions (`step-descriptions` warns, and never blocks, when a step has no `description:` or one over 300 characters), and the output manifests, then probes the first Parquet file using signed HTTPS access, or through the API when the CLI runs with an agent turn key, because an agent sandbox can reach only the API. This CLI authors for exactly one engine: the one inside the runner image it was released with. Only jobs already using a Simple Pipelines runner are eligible for image pinning. TypeScript, other runner families and an unknown or inherited image are refused by init, source sync and run; use the existing app tools and preserve the app. The CLI never changes a job's image on its own. A Simple Pipelines job on an older released image is reported as failed: `run`, `pull` and reads still work on its own image, but `push` is refused (`RUNTIME_UPGRADE_REQUIRED`) until the job is upgraded with `upgrade-runtime` (CLI: `farseer pipeline upgrade-runtime`), which moves it to this CLI's image and reports where it moved from. Upgrading changes the engine for everyone on that tenant and, on a scheduled job, for the next scheduled run, so ask the user before upgrading, then `run` once and fix whatever the newer engine's preflight rejects. A pipeline written for simple-pipelines 2.x never passes it: split every extract into `<name>_raw` and a parse step (Authoring rules below) and push the split right after the upgrade, before the job runs again, because every run from the upgrade on, scheduled ones included, uses this engine and fails until the split is pushed. A `main.py` that names no `store_type` writes to Farseer Files on older engines and to datasets on newer ones, so before upgrading such a job, add `store_type=StoreType.FARSEER_FILES` to the local `main.py` unless the user has confirmed it is ready for datasets, and push it right after the upgrade, before the job runs again; an explicit store works on every engine. A job on a moving tag such as `latest`, or on a digest, is reported as pending and left as it is: `upgrade-runtime` refuses it, and each run reports the engine it started on (`engine` in `inspect`). A job on a newer released image is reported as pending: it runs and accepts pushes, but update the CLI to author what the newer engine added. No job is ever moved down. A dataset declared under `Models/` is created by the engine on the first run, so init and check report a dataset that does not exist yet as pending, not as an error; an extract (`<name>_raw`) stores a payload and a load writes no dataset, so those two stay pending after the first run as well, which is expected; after the first run, rerun `init jobId=<id> force=true` to record the new dataset IDs (a rerun for the same job and folder keeps the setup record, declared config files and author), and the profile's `datasetIds` lists the outputs recorded so far. No published version means read verification stays pending until the first prepared run. The setup record (owner, evidence, checkedAt, retentionDays, otherWritersExcluded=true, runtimeVerified=true) is the owner's statement, not an API-verified fact: do not invent it, and reconfirm it after setup changes. `readyForAcceptance` does not establish source replay, reconciliation or real-client acceptance.
58
58
 
59
59
  ## Authoring rules
60
60
 
61
61
  Extract: one step per source extraction, named `<name>_raw`, separate from the parse step that reads it and the transformation that reshapes it. It stores what the source hands over, unread, as a payload (a file source's file as it came, a typed source's rows as parquet), so it carries no `parse:`, `schema:`, quality rules, `write_mode` or `merge_keys`. Read another pipeline's or this pipeline's published dataset with `extract.type: farseer`, `source: datasets` and the dataset's `qualified_name` (optionally pinned to a `version_id`). Never add a `farseer_credentials` block; the pipeline always uses the tenant it runs in.
62
62
 
63
+ A source with no built-in type: a plain HTTP(S) API is `extract.type: http` (`HttpExtractConfig`): a URL and `params`, credentials only under `auth:`, and `records:` plus `pagination:` for an API that pages JSON. It needs no code, so use it whenever it can express the source. Anything it cannot express is `extract.type: custom` (`CustomExtractConfig`): an `@extractor` function in `Code/`, one script per connector, configured through `args:` and handed credentials through `secrets:`; it returns a file it wrote, records or a table, and the parse step reads that as for any extract. Fetch through the `http` client it is handed, not a library of its own, which skips the network guard and token masking, and for a large or paged source `yield` records or stream a file with `http.download`: a returned list or table holds the whole source in memory. Never call an API from a `@transform`: it skips the payload, `optional:` and the extract-then-parse checks. A 404 and an empty answer fail the step unless the YAML says they mean missing data (`not_found: missing`, `empty: missing`, or `ExtractionSourceMissing` from an `@extractor`); only then does `optional: true` skip it.
64
+
63
65
  Parse: a `type: parse` step named `<name>` with `deps: [<the extract>]` reads the payload into the dataset. It names exactly one of `parse.format` (`csv`, `xlsx`, `json` or `parquet`; `parquet` for a source that hands back rows rather than a file, such as `sql_database`, `business_central` or `source: datasets`) or `parse.script` (an `@parse` function in `Code/`), with read options in the block named for the format, such as `csv: {decimal: ","}`. The parse step carries the dataset's `schema:`, quality rules and `write_mode`/`merge_keys`. Every extract must be read by a parse step, and only a parse step may read an extract: a transform, load or export with an extract in its `deps` fails the run before any step executes.
64
66
 
65
- 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.
67
+ Transform: choose SQL first (`engine: duckdb` with inline `transform.query`, never a SQL file), then `engine: ibis` with an `@ibis_transform` script when the logic needs Python to compose, and `engine: python` (`@transform`, pandas) only for work with no lazy form, because it is the one surface that holds whole frames in memory. Always write `engine:`; the default is `python`. Section 3 of `topic=practices` has the rules. When a SQL step should stop because the data isn't what it needs, call `fail_step('…')` with a message the client can act on, saying what is wrong and what to do, never `error()`: the client reads `fail_step`'s message as the step's failure, and `error()` only as "the app's own code failed". 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.
66
68
 
67
69
  Load: the engine's full surface is available, with `load.target: farseer` and `load.farseer.cells[].source_dataset` naming a dependency. Each `mapping.variables[]` entry has `source_column`, `target_variable` and `fixed_dimension_members`; `mapping.dimension_tables` maps a column onto a dimension. `options.overwrite_cells: true` repairs the same coordinates on a rerun; it does not erase omitted rows or old mappings. `undo_previous: true` (which requires at least one `labels` entry) undoes, after the new import commits, every earlier import job that carries all the same labels, so rows that left the source leave the model; a failed undo is logged as a warning, not raised. `create_missing_members: true` lets the import job create members that mapped columns name but the model lacks; it does not create `fixed_dimension_members`, which must already exist or be written by a dimension load earlier in the run. On a production model a created member is a permanent change, so say so before running. Dimension-table loads and exports are allowed. Statically, the only hard refusals are credentials in YAML and SQL files.
68
70
 
@@ -10,14 +10,15 @@ A pipeline is three things in a folder: `main.py`, `Models/` (one YAML per step)
10
10
  |---|---|---|
11
11
  | `main.py` | Argument checks and canonical spellings, then one `run_pipeline()` call with `store_type=StoreType.DATASETS` and `pipeline_policy=PipelinePolicy()` | Data reads, business logic, API calls, starting other jobs |
12
12
  | `Models/<layer>/<name>.yaml` | One step: its `type`, `deps` and its block, with `schema` and `quality_rules` on a parse step or transform, and a load or export mapping on a load or export. Or one `expand:` fan-out over one axis | Copies per company or period; two run cadences in one folder (use two pipeline folders) |
13
- | `extract` block | How to reach the source: connector, the source-side filter and columns, `optional` for a source that may genuinely be missing. The step, named `<name>_raw`, stores what the source hands over unread: a file source's file as it came, a typed source's rows as parquet | Anything that reads or checks the data: `parse`, `schema`, `quality_rules`, `write_mode`, `merge_keys`. Reshaping; reading another pipeline's output through `deps`; credentials |
13
+ | `extract` block | How to reach the source: connector (a plain HTTP(S) API is `type: http`, no code), the source-side filter and columns, `optional` for a source that may genuinely be missing. The step, named `<name>_raw`, stores what the source hands over unread: a file source's file as it came, a typed source's rows as parquet | Anything that reads or checks the data: `parse`, `schema`, `quality_rules`, `write_mode`, `merge_keys`. Reshaping; reading another pipeline's output through `deps`; credentials |
14
14
  | `parse` step (`type: parse`, `deps: [<the extract>]`) | How to read the extract's file into the dataset `<name>`: `format` (or a `script`) and, in the block named for the format (`csv:`, `xlsx:`, `json:`), encoding, separator, decimal, header, start row, positional columns. Every extract has one, and only a parse step reads an extract | What the values should be: no fixing, mapping or filtering |
15
15
  | `schema` | The dataset's column contract: every column it keeps, with `type` and `not_null` | Reshaping |
16
16
  | `quality_rules` | What the values must mean, on parse and transform steps | Comparisons between datasets (write a reconciliation transform) |
17
17
  | SQL transform (`engine: duckdb`, `query`) | All set-based work: filter, join, map, aggregate, reshape, final casts | Procedural row-by-row logic |
18
18
  | `@ibis_transform` (`engine: ibis`, `script`) | Logic that needs Python to compose, still streaming | DataFrames, `.to_pandas()`, `.execute()` |
19
19
  | `@transform` (`engine: python`, `script`) | Only work with no lazy form | Set-based work; I/O, environment reads, the clock |
20
- | `Code/` | One script per transform function; a function shared by many datasets through `transform.function` and `transform.args` | Helper modules imported across scripts: each script runs on its own |
20
+ | `@extractor` (`extract.type: custom`, `script`) | Reaching a source no built-in type can: the requests, their auth and paging, returning a file it wrote, records or a table. Configuration from `args`, credentials from `secrets` | Reading or fixing the data (that is the parse step and transforms); credentials in `args` or in the script |
21
+ | `Code/` | One script per transform function; a function shared by many datasets through `transform.function` and `transform.args`; one script per custom connector | Helper modules imported across scripts: each script runs on its own |
21
22
  | `load` block | Column-to-model mapping, labels, import options | Any logic. To change a number, change a transform |
22
23
  | `export` block | File target, format, conflict behaviour | Shaping |
23
24
  | Files | Mapping tables, read with a `source: files` extract and its parse step, and joined in SQL | |
@@ -40,7 +41,7 @@ Start from the target. Before any YAML, write down each variable the pipeline fi
40
41
  - **Qualified names are shared by every pipeline on the tenant.** Name datasets after their subject (`bronze.erp_sales_lines`, not `bronze.lines`), so two pipelines never write the same dataset.
41
42
  - **Leaf names must be unique within one step's `deps`.** SQL sees each dependency as a view named by its leaf, and Python sees it as a parameter named by its leaf.
42
43
  - **Read another pipeline's output** with `extract.type: farseer`, `source: datasets` and its `qualified_name`, and a parse step with `format: parquet` that reads the extract. It reads the last published version, and there is no ordering between pipelines.
43
- - **Keep `StoreType.DATASETS`** unless the pipeline accumulates data (section 8). `FARSEER_FILES`, the engine default, publishes on write and keeps no versions.
44
+ - **Keep `StoreType.DATASETS`** unless the pipeline accumulates data (section 8). `FARSEER_FILES` publishes on write and keeps no versions.
44
45
 
45
46
  ## 3. Transforms: SQL, then ibis, then pandas
46
47
 
@@ -81,6 +82,8 @@ def sales_lines_clean(erp_sales_lines, *, args):
81
82
 
82
83
  Use a `LEFT JOIN` to a mapping and flag the rows that found no match. An `INNER JOIN` drops them silently. Keep mappings as data, a Files table or a model attribute, rather than a `CASE` copied into several queries.
83
84
 
85
+ **Stop a SQL step with `fail_step('…')`, never `error()`.** When the data isn't what the step needs, call `fail_step` saying what is wrong and what the client does next: `fail_step('No rate for APAC. Add it to the rates sheet and run again.')`. The client reads it as the step's failure; `error()` reads only "the app's own code failed". Put the call where the query reads it (section 5).
86
+
84
87
  ## 4. Writing schemas
85
88
 
86
89
  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.
@@ -130,7 +133,7 @@ quality_rules:
130
133
  - `isin` on the period columns set to the run's period.
131
134
  - **Reconcile in a transform.** A rule cannot compare two datasets, and `custom__sum_equals` and `custom__compare` work per row. Write a small transform that totals both sides per period into one row, assert it with `custom__compare`, and list it in the gold dataset's `deps`. A failed total then stops gold, and the load with it.
132
135
  - **Severity.** `error`, the default, is for structural garbage where loading is pointless; `warn` is for findings to report; the review gate (section 7) is for anything a person should decide.
133
- - **A SQL `error()` guard must be read.** DuckDB drops a column or CTE that the final `SELECT` never uses, and the `error()` inside it with it, so `... CROSS JOIN guard` alone never fails. Use the guard in the `WHERE` (`WHERE guard.g IS NULL`) or in a selected column. Prefer a quality rule when one can say it.
136
+ - **A SQL guard must be read.** DuckDB drops a column or CTE that the final `SELECT` never uses, and the `fail_step()` inside it with it, so `... CROSS JOIN guard` alone never fails. Use the guard in the `WHERE` (`WHERE guard.g IS NULL`) or in a selected column. Prefer a quality rule when one can say it.
134
137
  - **Regexes run on RE2:** no lookahead or backreferences.
135
138
  - **Any rule loads the whole dataset** to validate it.
136
139
 
@@ -246,9 +249,9 @@ Storage choices are the hardest to undo. A dataset's store and file format are f
246
249
 
247
250
  | Store | What it does | Use for | Never |
248
251
  |---|---|---|---|
249
- | `DATASETS` | Versioned datasets in the registry. A run writes candidates, which become visible only when published | Almost everything: any dataset rebuilt whole each run and read downstream | Incremental extraction: a cursor is refused |
252
+ | `DATASETS` (the engine default after 3.1.0) | Versioned datasets in the registry. A run writes candidates, which become visible only when published | Almost everything: any dataset rebuilt whole each run and read downstream | Incremental extraction: a cursor is refused |
250
253
  | `ICEBERG` (experimental) | One Iceberg table per dataset. Each run writes on its own branch, frozen as a tag when complete | Datasets that accumulate: `append`, `upsert`, incremental SQL extracts | Data that a full rebuild each run would serve as well |
251
- | `FARSEER_FILES` (the engine default) | One file per dataset under the pipeline's `Data/` folder. Saving is publishing; there are no versions | Ad hoc output nobody else reads | Anything read downstream: a failing run has already replaced the file |
254
+ | `FARSEER_FILES` | One file per dataset under the pipeline's `Data/` folder. Saving is publishing; there are no versions | Ad hoc output nobody else reads | Anything read downstream: a failing run has already replaced the file |
252
255
 
253
256
  - **An incremental source gets its own pipeline folder on `ICEBERG`,** holding its extract and the one parse step that reads it. Everything that consumes it lives in a `DATASETS` pipeline and reads the parse step's dataset with `source: datasets`. That keeps the experimental store to the datasets that need it.
254
257
  - **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.
@@ -315,7 +318,16 @@ Only a `sql_database` extract with `cursor_column`, on `ICEBERG`, reads incremen
315
318
  | Large immutable event log | `ICEBERG`, `append`, its own pipeline | Cursor on a sequence assigned at commit | A text or transaction-start timestamp cursor; `append` on a source that edits rows |
316
319
  | Large records that change, with `updated_at` | `ICEBERG`, `upsert` on a stable business id, its own pipeline | Cursor on a commit-time `updated_at`, plus a periodic rebuild to drop rows deleted at the source | `append`; wide composite keys; reading by position |
317
320
 
318
- ## 9. Verify
321
+ ## 9. What the client reads: descriptions and log lines
322
+
323
+ A client reads two things a pipeline's author writes: each step's description, and the run log. Both are written for them, not for the next engineer.
324
+
325
+ - **Every step has a `description:`.** The client reads it in the step's panel on the Pipeline tab. Say what the step does and any rule needed to judge its result, in plain words and at most about 300 characters: "Sums the monthly sales per cost centre; a centre with no sales that month is left out." Leave build details out: engines, joins, why the query is shaped as it is. Those go in comments. `check` warns on a step with no description or a longer one.
326
+ - **Log through the logger the package hands you:** `logger` in a transform or parse script, and `app_logger()` in `main.py`. What it logs at INFO, WARNING or ERROR is shown, as written, in the run log's plain view, which is the view the client reads, so write it for them: what happened and, for a warning, what to do. DEBUG is for engineers and shows only in the technical view, as do `print` and `logging.getLogger`.
327
+ - **A step that stops on purpose tells the client why:** `fail_step('…')` in SQL (section 3), `PipelineError(…, informative='…')` in a script.
328
+ - **Log a moment the client should know about, not progress.** The engine already says when each step starts and finishes and how many rows it read or prepared. A line of your own says what only your code knows: a rate it applied, rows it set aside and why.
329
+
330
+ ## 10. Verify
319
331
 
320
332
  - **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.
321
333
  - **After every run:**
@@ -325,7 +337,7 @@ Only a `sql_database` extract with `cursor_column`, on `ICEBERG`, reads incremen
325
337
  - Rerun the same slice and confirm nothing changed.
326
338
  - Report what you verified, with run and version identifiers, and what you did not.
327
339
 
328
- ## 10. Anti-patterns
340
+ ## 11. Anti-patterns
329
341
 
330
342
  - A transform without `engine:`, or pandas doing set-based work.
331
343
  - Logic in the load step or in `main.py`; reading data or calling APIs from `main.py`.
@@ -337,3 +349,4 @@ Only a `sql_database` extract with `cursor_column`, on `ICEBERG`, reads incremen
337
349
  - Labels from unnormalised arguments, or two loads sharing labels.
338
350
  - Transforms that read the environment or the clock.
339
351
  - Comments carrying dates, people's names, ticket numbers or runner versions. Say what the code relies on.
352
+ - A step without a `description:`, or log lines through `print` that the client never sees.
@@ -1,86 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var agentApprovalFetch_exports = {};
20
- __export(agentApprovalFetch_exports, {
21
- installAgentApprovalFetch: () => installAgentApprovalFetch,
22
- withAgentApprovals: () => withAgentApprovals
23
- });
24
- module.exports = __toCommonJS(agentApprovalFetch_exports);
25
- var import_promises = require("node:timers/promises");
26
- var import_requests = require("../pipeline/requests");
27
- var import_configService = require("./configService");
28
- function withAgentApprovals(transport, backendUrl, secret, notify = (message) => process.stderr.write(message + "\n"), pollMs = 1e3) {
29
- const base = new URL(backendUrl.replace(/\/api\/v3\/?$/, "").replace(/\/$/, "") + "/");
30
- return async (input, init) => {
31
- const request = new Request(input, init);
32
- const url = new URL(request.url);
33
- if (url.origin !== base.origin || !url.pathname.startsWith(base.pathname + "api/v3/") || request.headers.get("X-API-KEY") !== secret)
34
- return transport(request);
35
- const response = await transport(request.clone());
36
- if (response.status !== 428) return response;
37
- const receipt = await response.clone().json().catch(() => null);
38
- if (receipt?.code !== "FARSEER_WRITE_APPROVAL_REQUIRED" || !/^write-[0-9a-f-]{36}$/.test(receipt.approval_id))
39
- return response;
40
- const statusUrl = new URL("api/v3/agent/write-approvals/" + receipt.approval_id, base);
41
- const signal = AbortSignal.any([request.signal, AbortSignal.timeout(36e5)]);
42
- const waiting = () => notify("Waiting for approval in Farseer chat before changing Farseer data.");
43
- waiting();
44
- const heartbeat = setInterval(waiting, 5e3);
45
- const resumeDeadline = (0, import_requests.pausePipelineDeadlines)();
46
- try {
47
- for (; ; ) {
48
- await (0, import_promises.setTimeout)(pollMs, void 0, { signal });
49
- const statusResponse = await transport(statusUrl, {
50
- headers: { "X-API-KEY": secret, "X-TENANT-ID": request.headers.get("X-TENANT-ID") ?? "" },
51
- signal
52
- }).catch((error) => {
53
- if (signal.aborted) throw error;
54
- return null;
55
- });
56
- if (!statusResponse || statusResponse.status >= 500) continue;
57
- if (!statusResponse.ok)
58
- throw new Error("Farseer write approval expired or the turn was cancelled. No write was retried.");
59
- const { status } = await statusResponse.json();
60
- if (status === "pending") continue;
61
- if (status !== "approved")
62
- throw new Error(
63
- "Farseer write was rejected or already attempted. Inspect its result before proposing another write."
64
- );
65
- const headers = new Headers(request.headers);
66
- headers.set("X-Farseer-Approval", receipt.approval_id);
67
- resumeDeadline();
68
- return await transport(new Request(request, { headers, signal }));
69
- }
70
- } finally {
71
- clearInterval(heartbeat);
72
- resumeDeadline();
73
- }
74
- };
75
- }
76
- function installAgentApprovalFetch() {
77
- const { FARSEER_API_KEY: secret, FARSEER_URL: backendUrl } = process.env;
78
- if (!secret?.startsWith(import_configService.AGENT_API_KEY_PREFIX) || !backendUrl) return;
79
- globalThis.fetch = withAgentApprovals(globalThis.fetch, backendUrl, secret);
80
- }
81
- // Annotate the CommonJS export names for ESM import in node:
82
- 0 && (module.exports = {
83
- installAgentApprovalFetch,
84
- withAgentApprovals
85
- });
86
- //# sourceMappingURL=agentApprovalFetch.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/services/agentApprovalFetch.ts"],
4
- "sourcesContent": ["import { setTimeout as delay } from 'node:timers/promises';\nimport { pausePipelineDeadlines } from '../pipeline/requests';\nimport { AGENT_API_KEY_PREFIX } from './configService';\n\n/** CLI commands and the MCP server both use the SDK/global fetch transport.\n * Only ephemeral agent turn keys enable this; normal CLI logins are unchanged. */\nexport function withAgentApprovals(\n transport: typeof fetch,\n backendUrl: string,\n secret: string,\n notify: (message: string) => void = (message) => process.stderr.write(message + '\\n'),\n pollMs = 1000,\n): typeof fetch {\n const base = new URL(backendUrl.replace(/\\/api\\/v3\\/?$/, '').replace(/\\/$/, '') + '/');\n return async (input, init) => {\n const request = new Request(input, init);\n const url = new URL(request.url);\n if (\n url.origin !== base.origin ||\n !url.pathname.startsWith(base.pathname + 'api/v3/') ||\n request.headers.get('X-API-KEY') !== secret\n )\n return transport(request);\n // Keep an immutable copy, including multipart boundary and file bytes, for the\n // single retry the backend explicitly says has NOT executed yet.\n const response = await transport(request.clone());\n if (response.status !== 428) return response;\n const receipt = await response\n .clone()\n .json()\n .catch(() => null);\n if (receipt?.code !== 'FARSEER_WRITE_APPROVAL_REQUIRED' || !/^write-[0-9a-f-]{36}$/.test(receipt.approval_id))\n return response;\n const statusUrl = new URL('api/v3/agent/write-approvals/' + receipt.approval_id, base);\n const signal = AbortSignal.any([request.signal, AbortSignal.timeout(3600_000)]);\n const waiting = () => notify('Waiting for approval in Farseer chat before changing Farseer data.');\n waiting();\n // OpenHands' terminal yields after a period without output. stderr also keeps\n // MCP stdout clean: it contains protocol messages only.\n const heartbeat = setInterval(waiting, 5000);\n const resumeDeadline = pausePipelineDeadlines();\n try {\n for (;;) {\n await delay(pollMs, undefined, { signal });\n // The poll is a read, so an outage or a starting API pod only delays the decision.\n const statusResponse = await transport(statusUrl, {\n headers: { 'X-API-KEY': secret, 'X-TENANT-ID': request.headers.get('X-TENANT-ID') ?? '' },\n signal,\n }).catch((error: unknown) => {\n if (signal.aborted) throw error;\n return null;\n });\n if (!statusResponse || statusResponse.status >= 500) continue;\n if (!statusResponse.ok)\n throw new Error('Farseer write approval expired or the turn was cancelled. No write was retried.');\n const { status } = await statusResponse.json();\n if (status === 'pending') continue;\n if (status !== 'approved')\n throw new Error(\n 'Farseer write was rejected or already attempted. Inspect its result before proposing another write.',\n );\n const headers = new Headers(request.headers);\n headers.set('X-Farseer-Approval', receipt.approval_id);\n resumeDeadline(); // The approved write is network work again.\n // Never retry a network error or a handler error: the outcome could be uncertain.\n return await transport(new Request(request, { headers, signal }));\n }\n } finally {\n clearInterval(heartbeat);\n resumeDeadline();\n }\n };\n}\n\nexport function installAgentApprovalFetch(): void {\n const { FARSEER_API_KEY: secret, FARSEER_URL: backendUrl } = process.env;\n if (!secret?.startsWith(AGENT_API_KEY_PREFIX) || !backendUrl) return;\n globalThis.fetch = withAgentApprovals(globalThis.fetch, backendUrl, secret);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAoC;AACpC,sBAAuC;AACvC,2BAAqC;AAI9B,SAAS,mBACZ,WACA,YACA,QACA,SAAoC,CAAC,YAAY,QAAQ,OAAO,MAAM,UAAU,IAAI,GACpF,SAAS,KACG;AACZ,QAAM,OAAO,IAAI,IAAI,WAAW,QAAQ,iBAAiB,EAAE,EAAE,QAAQ,OAAO,EAAE,IAAI,GAAG;AACrF,SAAO,OAAO,OAAO,SAAS;AAC1B,UAAM,UAAU,IAAI,QAAQ,OAAO,IAAI;AACvC,UAAM,MAAM,IAAI,IAAI,QAAQ,GAAG;AAC/B,QACI,IAAI,WAAW,KAAK,UACpB,CAAC,IAAI,SAAS,WAAW,KAAK,WAAW,SAAS,KAClD,QAAQ,QAAQ,IAAI,WAAW,MAAM;AAErC,aAAO,UAAU,OAAO;AAG5B,UAAM,WAAW,MAAM,UAAU,QAAQ,MAAM,CAAC;AAChD,QAAI,SAAS,WAAW,IAAK,QAAO;AACpC,UAAM,UAAU,MAAM,SACjB,MAAM,EACN,KAAK,EACL,MAAM,MAAM,IAAI;AACrB,QAAI,SAAS,SAAS,qCAAqC,CAAC,wBAAwB,KAAK,QAAQ,WAAW;AACxG,aAAO;AACX,UAAM,YAAY,IAAI,IAAI,kCAAkC,QAAQ,aAAa,IAAI;AACrF,UAAM,SAAS,YAAY,IAAI,CAAC,QAAQ,QAAQ,YAAY,QAAQ,IAAQ,CAAC,CAAC;AAC9E,UAAM,UAAU,MAAM,OAAO,oEAAoE;AACjG,YAAQ;AAGR,UAAM,YAAY,YAAY,SAAS,GAAI;AAC3C,UAAM,qBAAiB,wCAAuB;AAC9C,QAAI;AACA,iBAAS;AACL,kBAAM,gBAAAA,YAAM,QAAQ,QAAW,EAAE,OAAO,CAAC;AAEzC,cAAM,iBAAiB,MAAM,UAAU,WAAW;AAAA,UAC9C,SAAS,EAAE,aAAa,QAAQ,eAAe,QAAQ,QAAQ,IAAI,aAAa,KAAK,GAAG;AAAA,UACxF;AAAA,QACJ,CAAC,EAAE,MAAM,CAAC,UAAmB;AACzB,cAAI,OAAO,QAAS,OAAM;AAC1B,iBAAO;AAAA,QACX,CAAC;AACD,YAAI,CAAC,kBAAkB,eAAe,UAAU,IAAK;AACrD,YAAI,CAAC,eAAe;AAChB,gBAAM,IAAI,MAAM,iFAAiF;AACrG,cAAM,EAAE,OAAO,IAAI,MAAM,eAAe,KAAK;AAC7C,YAAI,WAAW,UAAW;AAC1B,YAAI,WAAW;AACX,gBAAM,IAAI;AAAA,YACN;AAAA,UACJ;AACJ,cAAM,UAAU,IAAI,QAAQ,QAAQ,OAAO;AAC3C,gBAAQ,IAAI,sBAAsB,QAAQ,WAAW;AACrD,uBAAe;AAEf,eAAO,MAAM,UAAU,IAAI,QAAQ,SAAS,EAAE,SAAS,OAAO,CAAC,CAAC;AAAA,MACpE;AAAA,IACJ,UAAE;AACE,oBAAc,SAAS;AACvB,qBAAe;AAAA,IACnB;AAAA,EACJ;AACJ;AAEO,SAAS,4BAAkC;AAC9C,QAAM,EAAE,iBAAiB,QAAQ,aAAa,WAAW,IAAI,QAAQ;AACrE,MAAI,CAAC,QAAQ,WAAW,yCAAoB,KAAK,CAAC,WAAY;AAC9D,aAAW,QAAQ,mBAAmB,WAAW,OAAO,YAAY,MAAM;AAC9E;",
6
- "names": ["delay"]
7
- }