@malloy-publisher/skills 0.1.67 → 0.2.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 (46) hide show
  1. package/CHANGELOG.md +385 -128
  2. package/package.json +62 -61
  3. package/skills/eval-answer/SKILL.md +1 -1
  4. package/skills/eval-diagnose/SKILL.md +1 -1
  5. package/skills/eval-import/SKILL.md +1 -1
  6. package/skills/eval-improve/SKILL.md +1 -1
  7. package/skills/eval-judge/SKILL.md +1 -1
  8. package/skills/eval-loop/SKILL.md +1 -1
  9. package/skills/eval-report/SKILL.md +1 -1
  10. package/skills/malloy-analysis/SKILL.md +1 -1
  11. package/skills/malloy-analysis-report/SKILL.md +1 -1
  12. package/skills/malloy-charts/SKILL.md +1 -1
  13. package/skills/malloy-classify/SKILL.md +1 -1
  14. package/skills/malloy-compliance-review/SKILL.md +1 -1
  15. package/skills/malloy-dashboards/SKILL.md +1 -1
  16. package/skills/malloy-define/SKILL.md +1 -1
  17. package/skills/malloy-define-workflow/SKILL.md +1 -1
  18. package/skills/malloy-discover/SKILL.md +1 -1
  19. package/skills/malloy-document/SKILL.md +1 -1
  20. package/skills/malloy-excel-review/SKILL.md +1 -1
  21. package/skills/malloy-getting-started/SKILL.md +1 -1
  22. package/skills/malloy-gotchas-modeling/SKILL.md +1 -1
  23. package/skills/malloy-html-data-apps/SKILL.md +2 -2
  24. package/skills/malloy-lookml-review/SKILL.md +1 -1
  25. package/skills/malloy-materialization/SKILL.md +17 -18
  26. package/skills/malloy-materialization/reference/access-filter.md +3 -3
  27. package/skills/malloy-materialization/reference/annotation.md +6 -7
  28. package/skills/malloy-materialization/reference/chaining.md +10 -30
  29. package/skills/malloy-materialization/reference/estimating.md +2 -2
  30. package/skills/malloy-materialization/reference/refresh.md +4 -4
  31. package/skills/malloy-materialization/reference/serving.md +61 -0
  32. package/skills/malloy-materialization/reference/tuning.md +5 -6
  33. package/skills/malloy-materialization/reference/why-live.md +8 -8
  34. package/skills/malloy-model/SKILL.md +2 -2
  35. package/skills/malloy-model-as-you-go/SKILL.md +1 -1
  36. package/skills/malloy-modeling/SKILL.md +1 -1
  37. package/skills/malloy-notebooks/SKILL.md +1 -1
  38. package/skills/malloy-phrase-detection/SKILL.md +1 -1
  39. package/skills/malloy-powerbi-review/SKILL.md +1 -1
  40. package/skills/malloy-publish/SKILL.md +1 -1
  41. package/skills/malloy-queries/SKILL.md +1 -1
  42. package/skills/malloy-reports/SKILL.md +1 -1
  43. package/skills/malloy-review/SKILL.md +1 -1
  44. package/skills/malloy-run-workflow/SKILL.md +1 -1
  45. package/skills/malloy-source-unreachable/SKILL.md +1 -1
  46. package/skills/malloy-materialization/reference/storage.md +0 -85
package/package.json CHANGED
@@ -1,63 +1,64 @@
1
1
  {
2
- "name": "@malloy-publisher/skills",
3
- "description": "Agent skills for Malloy and the Malloy Publisher",
4
- "version": "0.1.67",
5
- "license": "MIT",
6
- "type": "module",
7
- "main": "dist/index.js",
8
- "types": "dist/index.d.ts",
9
- "bin": {
10
- "malloy-skills": "dist/cli.js"
11
- },
12
- "exports": {
13
- ".": {
14
- "types": "./dist/index.d.ts",
15
- "default": "./dist/index.js"
16
- },
17
- "./package.json": "./package.json",
18
- "./skills/*": "./skills/*"
19
- },
20
- "files": [
21
- "skills",
22
- "dist",
23
- "CHANGELOG.md"
24
- ],
25
- "keywords": [
26
- "malloy",
27
- "publisher",
28
- "agent",
29
- "skills"
30
- ],
31
- "repository": {
32
- "type": "git",
33
- "url": "https://github.com/malloydata/publisher.git",
34
- "directory": "packages/skills"
35
- },
36
- "publishConfig": {
37
- "access": "public"
38
- },
39
- "scripts": {
40
- "copy-skills": "bun run scripts/copy-skills.ts",
41
- "build": "bun run copy-skills && bunx tsc -p tsconfig.build.json",
42
- "prepack": "bun run build",
43
- "prepublishOnly": "bun run scripts/check-pack.ts",
44
- "check-pack": "bun run build && bun run scripts/check-pack.ts",
45
- "typecheck": "bunx tsc --noEmit",
46
- "lint": "bunx eslint ./src ./scripts --fix",
47
- "format": "bunx prettier --write --parser typescript '{src,scripts}/**/*.ts'",
48
- "test": "bun run copy-skills && bun test ./src"
49
- },
50
- "dependencies": {
51
- "yaml": "^2.9.1"
52
- },
53
- "devDependencies": {
54
- "@eslint/js": "^8.57.0",
55
- "@types/bun": "^1.2.21",
56
- "@types/node": "^24.10.0",
57
- "@typescript-eslint/eslint-plugin": "^8.16.0",
58
- "@typescript-eslint/parser": "^8.16.0",
59
- "eslint": "^8.50.0",
60
- "ignore": "^7.0.16",
61
- "typescript": "^5.3.3"
62
- }
2
+ "name": "@malloy-publisher/skills",
3
+ "description": "Agent skills for Malloy and the Malloy Publisher",
4
+ "version": "0.2.0",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "bin": {
10
+ "malloy-skills": "dist/cli.js"
11
+ },
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "default": "./dist/index.js"
16
+ },
17
+ "./package.json": "./package.json",
18
+ "./skills/*": "./skills/*"
19
+ },
20
+ "files": [
21
+ "skills",
22
+ "dist",
23
+ "CHANGELOG.md"
24
+ ],
25
+ "keywords": [
26
+ "malloy",
27
+ "publisher",
28
+ "agent",
29
+ "skills"
30
+ ],
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "https://github.com/malloydata/publisher.git",
34
+ "directory": "packages/skills"
35
+ },
36
+ "publishConfig": {
37
+ "access": "public"
38
+ },
39
+ "scripts": {
40
+ "copy-skills": "bun run scripts/copy-skills.ts",
41
+ "build": "bun run copy-skills && bunx tsc -p tsconfig.build.json",
42
+ "prepack": "bun run build",
43
+ "prepublishOnly": "bun run scripts/check-pack.ts",
44
+ "check-pack": "bun run build && bun run scripts/check-pack.ts",
45
+ "typecheck": "bunx tsc --noEmit",
46
+ "lint": "bunx eslint ./src ./scripts --fix",
47
+ "format": "bunx prettier --write --parser typescript '{src,scripts}/**/*.ts'",
48
+ "test": "bun run copy-skills && bun test ./src"
49
+ },
50
+ "dependencies": {
51
+ "yaml": "^2.9.1"
52
+ },
53
+ "devDependencies": {
54
+ "@eslint/js": "^8.57.0",
55
+ "@types/bun": "^1.2.21",
56
+ "@types/node": "^24.10.0",
57
+ "@typescript-eslint/eslint-plugin": "^8.16.0",
58
+ "@typescript-eslint/parser": "^8.16.0",
59
+ "eslint": "^8.50.0",
60
+ "ignore": "^7.0.16",
61
+ "typescript": "^5.3.3"
62
+ },
63
+ "gitHead": "8c18f98c5a0de8f02ce3d227ebc2fed3fd212c68"
63
64
  }
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: eval-answer
3
3
  description: 'Score one analytical answer against a verified golden, and score which of the entities the golden depends on retrieval delivered to the answerer. Run the contamination checklist, re-execute the submitted query yourself, then spawn a judge subagent per skill:eval-judge. Append attempt, tool_call, score, and retrieval_score events to the file ledger (reference/ledger-schema.md). Never explain the failure (eval-diagnose) or edit the model (eval-improve). Use when asked whether an answer was correct, to score a run, or to baseline a model.'
4
- version: 0.1.67
4
+ version: 0.2.0
5
5
  ---
6
6
 
7
7
  # Evaluate One Answer
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: eval-diagnose
3
3
  description: 'Diagnose why a scored answer failed and who owns the fix, then cluster the failures by shared root cause. Walk dataset, agent-call, get_context/model, get_context/retrieval, construction, then model-definition. Append issue events to the file ledger, linked by traceId, one per cluster. Use after eval-answer, when triaging a run, or before changing a model. Does not edit the model (eval-improve).'
4
- version: 0.1.67
4
+ version: 0.2.0
5
5
  ---
6
6
 
7
7
  # Diagnose One Answer
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: eval-import
3
3
  description: 'Turn a list of questions into an eval set, whatever shape it arrived in: a JSONL a customer sent, a CSV, a spreadsheet export, a markdown doc, an email thread, or a pull from production logs. Classify each item by what came WITH the question (a query, a number, prose criteria, or nothing), write cases.jsonl and set.json per reference/case-format.md, keep the file as it arrived, and seal each question so a later edit is detectable. Never marks a value-bearing golden verified and never invents a question. Use when questions arrive from outside and need to become a set, or before the first run against a set nobody here authored.'
4
- version: 0.1.67
4
+ version: 0.2.0
5
5
  ---
6
6
 
7
7
  # Import questions into an eval set
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: eval-improve
3
3
  description: 'Make the smallest safe edit that closes a diagnosed gap the model repo owns: a Malloy model edit, or a package skill in the default skill set. Every factual claim carries a probe receipt. Use after eval-diagnose, or when asked to fix a model so an agent can discover the right answer. Never accepts its own edit; the acceptance check belongs to eval-loop. Does not decide whether an answer was wrong (eval-answer) or why (eval-diagnose).'
4
- version: 0.1.67
4
+ version: 0.2.0
5
5
  ---
6
6
 
7
7
  # Improve the Model
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: eval-judge
3
3
  description: 'Decide whether ONE answer matches its golden, and say whether you believe the golden. Read this before emitting any verdict. Covers containment, column pairing, near_match, refusals, and the gold_status judgement. Use when scoring an attempt in an evaluation run; never to conduct a run (eval-loop), diagnose a failure (eval-diagnose) or edit a model (eval-improve).'
4
- version: 0.1.67
4
+ version: 0.2.0
5
5
  ---
6
6
 
7
7
  # The judge
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: eval-loop
3
3
  description: 'Conduct a local Publisher evaluation loop in five steps: scrape/run, eval, diagnose, improve, checkpoint. You are the conductor: import cases into the file ledger, spawn a blind answerer, then run eval-answer, eval-diagnose, and eval-improve. Persistence is plain files: the set in the model package''s evals/ directory, runs in the set''s workdir; checkpoints are git commits of the model repo. `eval.py` runs each step from the set''s eval.toml. Use to score a model, diagnose failures, improve behind an acceptance check, or roll back a bad direction.'
4
- version: 0.1.67
4
+ version: 0.2.0
5
5
  ---
6
6
 
7
7
  # The Evaluation Loop
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: eval-report
3
3
  description: 'Write the summary a person reads after an evaluation run: what ran, what it scored, which failures were the MODEL and which were the EVAL itself (out of turns, contaminated, unestablished golden, unreadable judge), what was learned, and what to do next. Every claim links to the artifact behind it. Use at the end of any run, before quoting a number to anyone. Never scores an answer (eval-answer) or decides who owns a failure (eval-diagnose).'
4
- version: 0.1.67
4
+ version: 0.2.0
5
5
  ---
6
6
 
7
7
  # Report a Run
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: malloy-analysis
3
3
  description: "Read before your first get_context call on any business or data question. The required workflow, not background: which source, which rows, how to verify. Skipping it causes confident wrong answers."
4
- version: 0.1.67
4
+ version: 0.2.0
5
5
  ---
6
6
 
7
7
  <!-- Copyright (c) Credible Data Inc. SPDX-License-Identifier: MIT -->
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: malloy-analysis-report
3
3
  description: Combine validated Malloy queries into a report (a linear report, read top to bottom). Use when the user asks to "create a report", "combine these into a report", or wants a persistent multi-query artifact.
4
- version: 0.1.67
4
+ version: 0.2.0
5
5
  ---
6
6
 
7
7
  <!--
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: malloy-charts
3
3
  description: Read before choosing a chart or adding a chart annotation. Chart types, tag syntax and scale rules, KPI cards, dashboards, sparklines, and the renderer mistakes that fail silently.
4
- version: 0.1.67
4
+ version: 0.2.0
5
5
  ---
6
6
  <!--
7
7
  Copyright (c) Credible Data Inc.
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: malloy-classify
3
3
  description: 'Propose #(classification) annotations for a Malloy model from an access policy''s class scheme, backed by aggregate value evidence from the served data, and show them as a diff before writing anything. Use when the user asks to "classify the model", "tag PHI/PII", "label sensitive fields", or adds fields to a package that a policy governs, and before running malloy-compliance-review on a model nobody has classified.'
4
- version: 0.1.67
4
+ version: 0.2.0
5
5
  ---
6
6
 
7
7
  <!--
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: malloy-compliance-review
3
3
  description: 'Check a Malloy package and its controls against a written access policy: turn the policy''s prose into a control register, run compliance.py check against a served package (structure, access as each role, and the values themselves), judge what needs a person, and produce a report and a signable attestation. Use when the user asks whether a model "complies with", "satisfies" or "meets" a policy, HIPAA, SOC 2, PCI or the like, asks for a compliance review or attestation, or wants the review in CI.'
4
- version: 0.1.67
4
+ version: 0.2.0
5
5
  ---
6
6
 
7
7
  <!--
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: malloy-dashboards
3
3
  description: "Renamed to malloy-reports. A dashboard is now a report with layout=grid: a .malloy file with an ## artifact tag, written at the package root. Load malloy-reports instead when the user asks for a dashboard, a filterable view, or drill-through between views."
4
- version: 0.1.67
4
+ version: 0.2.0
5
5
  ---
6
6
 
7
7
  <!--
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: malloy-define
3
3
  description: Propose scope, a source plan and field definitions for a Malloy model. Which tables and questions, which sources at what grain, then renames, dimensions and measures, each backed by querying data.
4
- version: 0.1.67
4
+ version: 0.2.0
5
5
  ---
6
6
  <!--
7
7
  Copyright (c) Credible Data Inc.
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: malloy-define-workflow
3
3
  description: Define a package's skill sets (named folders of skills, including `default`, the package's own skills) and workflows (a named job with instructions that lists skill sets), declared in a package's publisher.json. Use when the user asks to create, add, change, fix or migrate a workflow or skill set in a package, to give a package its own skills, or to turn an old package agent into workflows. Not for running a workflow that already exists (that is malloy-run-workflow), and not for a one-off question, which you just answer.
4
- version: 0.1.67
4
+ version: 0.2.0
5
5
  ---
6
6
  <!--
7
7
  Copyright (c) Credible Data Inc.
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: malloy-discover
3
3
  description: Silent data discovery for Malloy modeling. Used at Step 1 of the modeling workflow. Scans tables, columns, distributions, and relationships without user interaction. The agent builds an internal picture before presenting anything.
4
- version: 0.1.67
4
+ version: 0.2.0
5
5
  ---
6
6
  <!--
7
7
  Copyright (c) Credible Data Inc.
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: malloy-document
3
3
  description: 'Add documentation with #(doc) tags to Malloy models so fields and sources are described in plain language. Use when user asks to "add documentation", "add doc tags", "document the model", or wants fields and sources described for natural-language search and discovery. For runtime filters, declare given: parameters (see the malloy-model skill); #(filter) is deprecated. Filters are a runtime/modeling construct (governance, latency, correctness), not a documentation tag.'
4
- version: 0.1.67
4
+ version: 0.2.0
5
5
  ---
6
6
 
7
7
  <!--
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: malloy-excel-review
3
3
  description: Move an Excel workbook (.xlsx or .xlsm) onto Malloy - recover the model hiding in its cells, translate its formulas and pivots, and prove the numbers match against the values the file already stores. Use when a workbook is present, when a user wants to migrate or switch off a spreadsheet, and whenever a specific formula has to become Malloy - SUMIFS, COUNTIF, SUMPRODUCT, VLOOKUP, XLOOKUP, INDEX/MATCH, pivot tables, assumption cells, roll-forwards, circular references, Monte Carlo, or a Power Pivot model. Carries worked recipes, each labelled executed or semantics-cited in place, and states what each port costs. Works with or without a database connection.
4
- version: 0.1.67
4
+ version: 0.2.0
5
5
  ---
6
6
  <!--
7
7
  Copyright (c) Credible Data Inc.
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: malloy-getting-started
3
3
  description: First steps for using a Malloy Publisher deployment through its MCP tools. Use when connecting to Publisher for the first time, when you do not yet know the available environments, packages, or models, or when a user asks what data they can explore. Also use for "malloy help" or which Malloy skill to read. Covers verifying the server, discovering data with get_context, and running a first grounded query.
4
- version: 0.1.67
4
+ version: 0.2.0
5
5
  ---
6
6
  <!--
7
7
  Copyright (c) Credible Data Inc.
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: malloy-gotchas-modeling
3
3
  description: Malloy modeling mistakes and compile-error fixes. Read before writing sources, dimensions, measures or joins, and when a .malloy file will not compile. Reserved words, NULLs, dates, field access.
4
- version: 0.1.67
4
+ version: 0.2.0
5
5
  ---
6
6
  <!--
7
7
  Copyright (c) Credible Data Inc.
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: malloy-html-data-apps
3
3
  description: "Build or modify an in-package HTML data app for a Malloy Publisher package (a public/ directory the package serves): design it, write its Publisher.query code, embed it. Hand-authored, no build step."
4
- version: 0.1.67
4
+ version: 0.2.0
5
5
  ---
6
6
  <!--
7
7
  Copyright (c) Credible Data Inc.
@@ -88,7 +88,7 @@ You are building for someone who cannot tell a correct dashboard from a broken o
88
88
  - **Validate every query against the model before wiring it in** (step 4): confirm it compiles and that the column names match what your render code reads.
89
89
  - **Load the finished page and confirm every tile shows real numbers**: not stuck on "Loading…", not an error, not an empty state you didn't intend. In a headless browser, wait on `load` plus a content selector, not network idle (`publisher.js` holds an SSE stream open; see `reference/runtime.md`). Don't hand-roll this each time - `reference/verification-harness.md` is a copy-adaptable recipe: a mock `sdk/publisher.js` returning canned rows keyed by `(model, query)`, a `python3 -m http.server` webroot, and Playwright assertions (KPIs non-null, no `.is-error`, no stuck `.kit-skeleton`, a chart/table present). It also documents the false-"stuck skeleton" trap (assert after the mock's async delay, never on `networkidle`).
90
90
  - **Check it embedded, for stability, and through its drawers.** Load each page inside the Publisher console (`/<env>/<package>/data-apps/<path>`) as well as on its own, measure layout shift on a first and a repeat visit, confirm the app never scrolls inside its frame, and open a drawer from well down the page after scrolling the host with real wheel events: the page behind must not move, the drawer must span exactly the visible area, and its scroll must stay in it. `reference/verification-harness.md` section 4 has the checks. A tile check alone passed on a build where every one of these was broken.
91
- - **When the package materializes anything, replay the app's own queries before publishing.** List every query the app sends: each `Publisher.query(model, query)` call and each query text in its tile definitions, with the filter values a reader picks most and the givens a real reader's request carries (a gated source answers differently without them). Run each with `execute_query` on the local Publisher in simulation (`skill:malloy-materialization`, "Validate before publish") and write down its path report, one line per query: the table that would answer it (`path.servedBy`, with its `mode`), or for a live answer why its table was skipped (`path.firstSkip`, with its `reason`). A query the author expects a table to answer that comes back live is a finding to fix before publishing, unless its reason is one that is live by design: `row_level_gate`, `inherited_gate` or `unreachable`. Never weaken an `#(access_filter)`, an `#(authorize)` or a given to make a query serve from a table; report it instead. Simulation answers every query from live rows, so it tells you which table would answer, never how fast: a table's read time can only be measured after a real build. Each replayed query is a live query against the very sources the package materializes because they are expensive, so run each once, at the filter values that matter, not in a loop. Over `cred dev`'s proxy connections a local server does not yet plan a `storage=` source as the host would (it is refused, `storage_source_unsupported`), so those queries show no simulated path; judge them after a real build on the host.
91
+ - **When the package materializes anything, replay the app's own queries before publishing.** List every query the app sends: each `Publisher.query(model, query)` call and each query text in its tile definitions, with the filter values a reader picks most and the givens a real reader's request carries (a gated source answers differently without them). Run each with `execute_query` on the local Publisher in simulation (`skill:malloy-materialization`, "Validate before publish") and write down its path report, one line per query: the table that would answer it (`path.servedBy`, with its `mode`), or for a live answer why its table was skipped (`path.firstSkip`, with its `reason`). A query the author expects a table to answer that comes back live is a finding to fix before publishing, unless its reason is one that is live by design: `row_level_gate`, `inherited_gate` or `unreachable`. Never weaken an `#(access_filter)`, an `#(authorize)` or a given to make a query serve from a table; report it instead. Simulation answers every query from live rows, so it tells you which table would answer, never how fast: a table's read time can only be measured after a real build. Each replayed query is a live query against the very sources the package materializes because they are expensive, so run each once, at the filter values that matter, not in a loop.
92
92
  - **Unit-test any non-trivial pure logic** (a month-join, a de-cumulation, a unit conversion). Keep that logic in DOM-free helpers so `node --test` can cover it, and run it.
93
93
 
94
94
  ## Minimal scaffold
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: malloy-lookml-review
3
3
  description: Analyze LookML files as prior art for Malloy modeling. Used during Step 1 (DISCOVER) when .lkml files are present. Coordinates reference files that extract business logic, relationships, and curation decisions. Works with or without a database connection.
4
- version: 0.1.67
4
+ version: 0.2.0
5
5
  ---
6
6
  <!--
7
7
  Copyright (c) Credible Data Inc.
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: malloy-materialization
3
3
  description: Use to materialize a Malloy source, roll up a measure or persist a view (`#(materialize)`, `#(rollup)`, `#@ persist`), to check one before publishing, or when a stored table is not built or not read.
4
- version: 0.1.67
4
+ version: 0.2.0
5
5
  ---
6
6
  <!--
7
7
  Copyright (c) Credible Data Inc.
@@ -21,8 +21,8 @@ This file is the core. The details live beside it, one topic per file, and each
21
21
  - `reference/estimating.md` - before annotating: whether a materialization is worth it and which one, measured with aggregates and metadata only, shown as a tradeoff table, and approved before anything is applied.
22
22
  - `reference/annotation.md` - the `#(materialize)` tag: the name rules, identity and reuse, readers of a materialized source, persisted views and named queries, and every key with where it is explained.
23
23
  - `reference/policy.md` - the `publisher.json` block: `scope`, `queryMetadata`, and where the rules are enforced.
24
- - `reference/storage.md` - building into a **storage destination** (`storage=`), where a given may sit, which sources that tier refuses, how a stored table is served, and rollups.
25
- - `reference/chaining.md` - one stored source built **over another stored source**: what makes it build over the parent's table, why one that cannot is refused rather than recomputed from the warehouse, and how to read what happened.
24
+ - `reference/serving.md` - where a table is built (its own connection; a copy in a lake is an `#(extract)`), where a given may sit, shaping a rollup, and how a stored table is served.
25
+ - `reference/chaining.md` - one stored source built **over another stored source**: what makes it build over the parent's table, why one that cannot is refused rather than recomputed from raw, and how to read what happened.
26
26
  - `reference/refresh.md` - keeping a table current: `freshness`, `schedule`, and `refresh="incremental"`.
27
27
  - `reference/access-filter.md` - materializing a `#(access_filter)`-gated source, and the bound on a stale access decision.
28
28
  - `reference/tuning.md` - after building: reading the materialization history to decide what to materialize, stop materializing, or reschedule (recommendations only).
@@ -32,7 +32,7 @@ This file is the core. The details live beside it, one topic per file, and each
32
32
  | To store | Write |
33
33
  |---|---|
34
34
  | a source, in its own warehouse | `#(materialize)`, or `#(materialize) name="schema.table"` to name and place the table |
35
- | a source, in a storage destination | `#(materialize) storage="lake"` |
35
+ | a copy of a query's rows in a managed DuckLake database, never answered live | `#(extract) into="lake.orders"` on a query-shaped target, not a materialization (`reference/serving.md`) |
36
36
  | a measure rolled up to a coarse grain | `#(rollup) grain=["a", "b"]` on the measure, one line per grain |
37
37
  | a view's result | `#@ persist` on the `view:` |
38
38
  | a named query's result | `#@ persist` on the top-level `query:` |
@@ -40,7 +40,7 @@ This file is the core. The details live beside it, one topic per file, and each
40
40
 
41
41
  ```malloy
42
42
  // Annotations on sources the model already declares: no new source, no reshaping.
43
- #(materialize) name="orders_store" storage="lake"
43
+ #(materialize) name="analytics.orders_store"
44
44
  source: orders is orders_base extend {
45
45
  measure: order_count is count()
46
46
  }
@@ -52,21 +52,21 @@ source: sales is orders_base extend {
52
52
  }
53
53
  ```
54
54
 
55
- `#@ persist` belongs on views and named queries only; never put it on a source. `#(materialize)`, `#(rollup)` and the storage tier are always read: there is no server switch to turn on. Write `#(rollup)`, never `#@ preaggregate`: the legacy line is read as exactly the `#(rollup)` line it means and warns (`deprecated-preaggregate-annotation`). So is `#(preaggregate)`, `#(rollup)`'s former name, for one release; a measure that carries both fails the load (`rollup-invalid`).
55
+ `#@ persist` belongs on views and named queries only; never put it on a source. `#(materialize)` and `#(rollup)` are always read: there is no server switch to turn on. Never write `storage=`: it is rewritten at load into an extract, answered only from its copy (a rollup's is dropped with a warning; `reference/serving.md`). Write `#(rollup)`, never `#@ preaggregate`: the legacy line is read as exactly the `#(rollup)` line it means and warns (`deprecated-preaggregate-annotation`). So is `#(preaggregate)`, `#(rollup)`'s former name, for one release; a measure that carries both fails the load (`rollup-invalid`).
56
56
 
57
57
 
58
58
  What to know about `#(materialize)`:
59
59
 
60
- - **It stores the source as written** - every dimension (computed, private and internal ones too) with its `where:` applied, not a query's output - so a plain `extend` over a table is fine and needs no `-> { select: * }`, and no `##!` flag is needed in its file. Keys are closed: `name`, `storage`, `refresh`, `watermark`, `merge_key`, `lookback`, `freshness.*`, `queryMetadata.*`, `inline`. Any other key fails the publish and the load (`materialize-unknown-key`; the retired `partition=` is `materialize-retired-key`).
60
+ - **It stores the source as written** - every dimension (computed, private and internal ones too) with its `where:` applied, not a query's output - so a plain `extend` over a table is fine and needs no `-> { select: * }`, and no `##!` flag is needed in its file. Keys are closed: `name`, `refresh`, `watermark`, `merge_key`, `lookback`, `freshness.*`, `queryMetadata.*`, `inline`. Any other key fails the publish and the load (`materialize-unknown-key`; the retired `partition=` is `materialize-retired-key`).
61
61
  - **A base's measures, views and joins are carried** when the base is named by its own name, in the source's file or a file it imports: the served copy writes the base's `extend` block again over the table, and every file that imports the source reads the table. A source the base's block reads that the source's file cannot see (a join to a source the base's file imports) is imported into the served copy for it. It cannot when the base comes in under another name (`import { o is orders } from ...`), or the source's file declares or imports a different source under a name the block reads: then the source is built but answered live, `served-copy-not-served` ("This source inherits fields ..."), serve verdict `live` / `served_copy`. First try what changes no shape: import the base under its own name, or leave the source unmaterialized. Renaming the clashing source, building over a different base, or rewriting the source as a query shape (`orders -> { select: * } extend { ... }`, with the measures declared after it) changes the model's shape: each is a tier-2 change (`reference/estimating.md`), shown as its own diff and approved on its own.
62
62
  - **An extension that declares its own `#(materialize)` gets its own table**, built over its parent's table rather than recomputing the chain; one that declares none reads its parent's table (`reference/chaining.md`).
63
- - **Joins are references by default.** `inline=["j"]` stores a join_one as `j__<field>` columns, or a join_many as a pair table; an incremental pair table names a watermark on each side, `watermark=["updated_at", "j.updated_at"]`. An inlined join_one is keyed by one equality, or by several joined by `and` (`on: dt = spend.dt and campaign = spend.campaign`), each between a field of the joined source and a field of this source of exactly its type; its build fails if the joined source repeats the key (a combination, for several columns, NULLs aside). An `or`, a `!=`, a filter term in `on:`, or a computed side is refused and the source answers live; so is a string key whose collation the build cannot prove one on both sides (any dialect but DuckDB, Postgres and BigQuery), and a Snowflake `timestamptz` key. `docs/materialization.md` has the full rule.
64
- - **A given-reading `where:` must sit on the materialized source itself.** Its own term is left out of the build and applied per caller at read; one inherited from a base refuses the source (`materialize-not-built`) and it answers live (`reference/storage.md`).
65
- - **A source with a row-level gate of its own** (`#(authorize)`, `#(access_filter)`) is built and served past that gate on either tier, database or `storage=`: the table holds every caller's rows and the gate is re-applied on every read. A `storage=` table puts those rows, ungated, in the destination, where anyone with direct access to it can read them; say so when you materialize a gated source there. A row filter it inherits, a gate reached through a join, or a gate over a source whose build reads a given is refused on both tiers (`reference/access-filter.md`).
63
+ - **Joins are references by default.** `inline=["j"]` stores a join_one as `j__<field>` columns, or a join_many as a pair table, which an incremental refresh rebuilds in full (a pair table has no delta). An inlined join_one is keyed by one equality, or by several joined by `and` (`on: dt = spend.dt and campaign = spend.campaign`), each between a field of the joined source and a field of this source of exactly its type; its build fails if the joined source repeats the key (a combination, for several columns, NULLs aside). An `or`, a `!=`, a filter term in `on:`, or a computed side is refused and the source answers live; so is a string key whose collation the build cannot prove one on both sides (any dialect but DuckDB, Postgres and BigQuery), and a Snowflake `timestamptz` key. `docs/materialization.md` has the full rule.
64
+ - **A given-reading `where:` must sit on the materialized source itself.** Its own term is left out of the build and applied per caller at read; one inherited from a base refuses the source (`materialize-not-built`) and it answers live (`reference/serving.md`).
65
+ - **A source with a row-level gate of its own** (`#(authorize)`, `#(access_filter)`) is built and served past that gate: the table holds every caller's rows, ungated in the warehouse, and the gate is re-applied on every read through Publisher. A row filter it inherits, a gate reached through a join, or a gate over a source whose build reads a given is refused (`reference/access-filter.md`).
66
66
  - **On BigQuery a database table needs a dataset**: a database `#(materialize)` with no dataset-qualified `name=`, or a rollup whose `name=` (or its base's) gives none, is refused at plan (`needs_qualified_name`) and serves live.
67
67
  - **The table's name.** Without `name=`, a table takes a readable name, `<package>__<file>__<source>__p<8 hex>`. An unversioned or `scope: "package"` package writes `name=` exactly as given; under `scope: "version"` a `name=` sets the start of the table's name, schema or dataset included, and the version and a hash follow it (`analytics.summary_t__v1_2_0__p<hash>`). No view is ever made at `name=`.
68
68
 
69
- **Legacy v1 chains.** Code written with v1 `#@ persist` on a source still loads and serves. An extension that only inherits the tag has no table of its own and reads its base's; `#(materialize)` on it gives it one, built over the base's stored table with its own refinements applied, on either tier, whether the base is in the same file or another. When asked to move v1 code to v2, follow `docs/materialization-migration.md` in the Publisher repository: a dry-run publish (`POST .../packages?dryRun=true`) to read the warnings and serve verdicts, a build (every migrated source rebuilds once, because its content address moves), then the path report and a served-versus-live comparison. Keep the v1 source's `name=` when you move it, so an unversioned or `scope: "package"` package's table stays at that name. The legacy `#@ preaggregate` on a measure becomes `#(rollup)`, with its comma-separated `grain="a, b"` written as a list.
69
+ **Legacy v1 chains.** Code written with v1 `#@ persist` on a source still loads and serves. An extension that only inherits the tag has no table of its own and reads its base's; `#(materialize)` on it gives it one, built over the base's stored table with its own refinements applied, whether the base is in the same file or another. When asked to move v1 code to v2, follow `docs/materialization-migration.md` in the Publisher repository: a dry-run publish (`POST .../packages?dryRun=true`) to read the warnings and serve verdicts, a build (every migrated source rebuilds once, because its content address moves), then the path report and a served-versus-live comparison. Keep the v1 source's `name=` when you move it, so an unversioned or `scope: "package"` package's table stays at that name. The legacy `#@ preaggregate` on a measure becomes `#(rollup)`, with its comma-separated `grain="a, b"` written as a list.
70
70
 
71
71
  ## The recipe (get this right and it just works)
72
72
 
@@ -80,7 +80,7 @@ What to know about `#(materialize)`:
80
80
  - **The name is not the identity.** A materialized source is identified by a content address of its connection and its build, so a rebuild with unchanged logic reuses the table. An `extend` that declares no `#(materialize)` of its own reads the same table and is not a second build target.
81
81
  - **A `name=` is one table on its schema, whichever package asks.** A `name=` is used as written and marked as its package's; if another package already holds it, that source's build is refused (`table-owned-elsewhere` in the run's failures) and it answers live. Give it a different `name=`. Two sources of one package on one `name=` fail the load (`materialization-table-collision`).
82
82
 
83
- The name rules, `#@ -persist`, persisted views and queries, and every key (`storage=`, `refresh=`, `freshness.*`, `queryMetadata.*`, `inline=`) are in `reference/annotation.md`.
83
+ The name rules, `#@ -persist`, persisted views and queries, and every key (`refresh=`, `freshness.*`, `queryMetadata.*`, `inline=`) are in `reference/annotation.md`.
84
84
 
85
85
  2. **Package materialization policy in `publisher.json`** (all optional):
86
86
  ```jsonc
@@ -119,11 +119,11 @@ The steps, in order:
119
119
  5. **Get approval.** The annotations on the existing shape are approved **as a set**. Each shape change (a new or split source, an extracted base, restructured joins, a moved field) is approved **on its own, with its diff**, and only after the annotations are shown not to suffice.
120
120
  6. **Annotate.** Apply exactly what was approved, save, and read the summary and the path reports again.
121
121
 
122
- **What simulation cannot settle.** The build SQL is compiled and planned, never run, so it is `unvalidated` until a real build: a warehouse permission, a dialect gap or a statement limit first shows there. How fast a table answers is not measured either: every simulated query reads live rows, so a table's read time is known only after a real build. Freshness on the host and build limits are `not_knowable_locally`. Key uniqueness (behind an inlined `join_many` and key-dependent rollups) is `predicted`, from one aggregate per key check (only a count comes back; a `storage=` table's own key compares `count()` with `count(distinct key)`); a real build confirms it. Stored types are predicted (a Postgres `numeric` with no modifier is predicted `DECIMAL(38,0)`). Simulation answers live under live's ceiling, so it can deny a query a served copy would answer. A `storage=` destination no build has ever created cannot be attached, so its tables bind but are reported answered live, with a `destination` fact `not_knowable_locally`. Each metadata read is bounded (15 s, 2 minutes per package); one that fails or runs out of time makes its fact `not_knowable_locally`. Metadata is cached per table, so only `reload_package` sees a warehouse schema or permission change.
122
+ **What simulation cannot settle.** The build SQL is compiled and planned, never run, so it is `unvalidated` until a real build: a warehouse permission, a dialect gap or a statement limit first shows there. How fast a table answers is not measured either: every simulated query reads live rows, so a table's read time is known only after a real build. Freshness on the host and build limits are `not_knowable_locally`. Key uniqueness (behind an inlined `join_many` and key-dependent rollups) is `predicted`, from one aggregate per key check (only a count comes back); a real build confirms it. Stored types are predicted (a Postgres `numeric` with no modifier is predicted `DECIMAL(38,0)`). Simulation answers live under live's ceiling, so it can deny a query a served copy would answer. Each metadata read is bounded (15 s, 2 minutes per package); one that fails or runs out of time makes its fact `not_knowable_locally`. Metadata is cached per table, so only `reload_package` sees a warehouse schema or permission change.
123
123
 
124
124
  **A real local build** means restarting the server with `--no-materialize-simulate` (or `PUBLISHER_MATERIALIZE_SIMULATE=false`): its builds then run for real and report `mode: "local"`. Under simulation, a build request (`malloy-pub materialize`, `POST …/materializations`), a run delete, a table drop and a manifest binding all answer **409 `SIMULATION_ACTIVE`**, and the scheduler does not start. A server cannot start with simulation on under a frozen config or with no watched environment, and a watched package whose `publisher.json` declares a `manifestLocation` still loads but serves live, with a `simulation-manifest-bound` warning.
125
125
 
126
- **Over a proxy connection** (`type: "publisher"`, forwarding to another Publisher), an unpublished package plans a `storage=` source as the type of the host connection the proxy stands for: a Postgres, BigQuery or Snowflake source is admitted, a DuckLake source is refused for author SQL, any other type is refused because the host would refuse it too, and its stats are the host's. What depends on the host's configuration (its build times, limits, same-catalog and managed verdicts, its DuckLake lake) is still `not_knowable_locally`. The one planning setting, `persist.addressIncludesDestination`, is read locally; hosted cells pin it `false`, so a local server with it on predicts addresses, names and reuse that differ from the host's.
126
+ **Over a proxy connection** (`type: "publisher"`, forwarding to another Publisher), an unpublished package plans a stored source as the type of the host connection the proxy stands for, and its stats are the host's. What depends on the host's configuration (its build times, limits, managed verdicts) is still `not_knowable_locally`.
127
127
 
128
128
  ## Building and refreshing (standalone vs. hosted)
129
129
 
@@ -145,7 +145,7 @@ A green run is not proof, and neither is a fast query (on small data a live reco
145
145
  3. **The query names the table.** Every query result carries a path report, `path`. An answer from a `#(materialize)` table reads `servedBy.kind: "materialized"` with `via: "served_copy"`; a rollup reads `kind: "rollup"`; a persisted view `kind: "view"`; a persisted named query `kind: "query"`. A table that was tried and not used is in `considered` with its `reason`. The full result (the REST query response without `compactJson`) also carries the SQL it ran, whose `FROM` names the physical table.
146
146
  4. **Compare served with live.** Declare an opted-out reader in a scratch model file (`#@ -persist source: x_live is x extend {}`, in a file, not in the query text, where it is not opted out), run the same query on both, and compare the rows; delete the file afterwards.
147
147
 
148
- A query response's `servedFrom` field names the tier that answered: `database` for a table built in the source's own connection, `storage` for a `storage=` table, `live_fallback` when a `storage=` read failed and live answered, and empty when no table answered. The path report's `servedBy.tier` names the same tier. MCP `execute_query` returns both: `servedFrom`, and a compact `path` whose `servedBy` names the table that answered, and whose `firstSkip`, on a live answer, gives why the source's own table was skipped, else a rollup skipped for `MISSING_FIELD` (its grain covers the query, and a field the query asks for is missing), else another rollup skip, with `GRAIN_TOO_COARSE` last (`NOT_BUILT` means build it).
148
+ A query response's `servedFrom` field names the tier that answered: `database` for a table built in the source's own connection, `live_fallback` when a stored table's read failed and live answered, `extract` when an extract's copy answered the query or part of it (the path report says which parts; each extract's data age is `path.servedBy.extracts[].dataAsOf`), and empty when no table answered. The path report's `servedBy.tier` names the same tier. MCP `execute_query` returns both: `servedFrom`, and a compact `path` whose `servedBy` names the table that answered, and whose `firstSkip`, on a live answer, gives why the source's own table was skipped, else a rollup skipped for `MISSING_FIELD` (its grain covers the query, and a field the query asks for is missing), else another rollup skip, with `GRAIN_TOO_COARSE` last (`NOT_BUILT` means build it).
149
149
 
150
150
  ## Why does this answer live?
151
151
 
@@ -161,7 +161,6 @@ The ladder for a source that still recomputes on every query is in `reference/wh
161
161
  - **A ready run can still have lost a source** - read `manifest.failures` and `metadata.refusedSources`.
162
162
  - **Reuse is by content address, not by name** - `--force-refresh` and every scheduler fire defeat it.
163
163
  - **Removing a materialized source does not drop its table** - and neither does `delete materialization`, which is record-only. Drop the table once no remaining ready run, of any version (list runs per version with `versionId`), names a table with that name in any place: `DELETE …/connections/{connectionName}/materializedTables/{physicalTableName}` checks that itself and answers 409 `TABLE_IN_USE` otherwise; serving reverts to live in place.
164
- - **A given in the source's own `where:` is applied per caller; inherited from a base it refuses the source** - `reference/storage.md`.
165
- - **A join to a source not stored with it, or a nested column, serves live for the queries that touch it** - the source's own fields still serve from the table.
166
- - **A `#(access_filter)`-gated source freezes its gating column when materialized** - a `storage=` table holds every caller's rows, ungated, in the destination; `reference/access-filter.md`.
164
+ - **A given in the source's own `where:` is applied per caller; inherited from a base it refuses the source** - `reference/serving.md`.
165
+ - **A `#(access_filter)`-gated source freezes its gating column when materialized** - the table holds every caller's rows, ungated; `reference/access-filter.md`.
167
166
  - **An extension of a v1 `#@ persist` source can take `#(materialize)`** - it then gets its own table, built over the base's stored table.
@@ -7,9 +7,9 @@ SPDX-License-Identifier: MIT
7
7
 
8
8
  A gated source **can** be materialized, on either tier but only in one shape, and the thing to be careful about is not refused by anything - you have to decide it.
9
9
 
10
- - **A `#(rollup)` over a gated source is built only where its gate holds on the rollup's rows**: on either tier, every gate the base's own (declared on the base's own statement, not inherited from a source it extends, not through a join), and every field it reads a grain dimension; a `storage=` rollup is read past the gate only when its gate columns are stored exactly and compared as live compares them. It is also admitted, on either tier, when every gate on its base is an `#(authorize)` lock that reads no row field, own or inherited at any depth (still with each gate proven on the rollup). The gate is then re-applied on every read, as on a stored source. Any other gated rollup is refused, naming it. The build skips a refused source, records it on the run (`metadata.refusedSources`), and builds the rest of the package. A run fails on a refusal only when every authored source it targeted was refused, or when `sourceNames` named this one; a refused rollup never fails it. (`#(rollup)` stores a rollup Publisher derives from a measure you annotated with a grain, rather than a source you wrote.) A rollup also groups *across* the gated column, so it could not be row-filtered afterwards even in principle.
11
- - **A `#(materialize)`, database or `storage=`, is admitted** when its row filter is the entry point's **own** (declared on the materialized source itself, and classified as a row filter) and any `#(authorize)` lock is on its own `extend`/`->` chain (declared on it, or inherited from a source it extends or derives from). Both tiers follow the same rule: the table holds every caller's rows and the gate is re-applied on every read through Publisher. (`#(materialize) storage="<name>"` materializes into a separate registered storage destination and serves from there, rather than building in the source's own connection.) **A `storage=` table puts those rows, ungated, at rest in the destination**, where anyone with direct access to the destination reads every row; tell the author before choosing that tier for a gated source, and make sure no connection a model can name reaches the destination (its catalog, schema or data path): stored tables are named predictably, so any package could read the gated rows through it. It is refused in three cases: the gate is reached only through a join, it does not classify as a row filter (or a lock) at all, or the materialized source inherits an `#(access_filter)` row filter from a source it derives from or extends (`source: mine is gated -> { ... }`, `gated extend { ... }`, across imports or two hops away). An inherited lock is not refused: it reads no row, so it admits or denies the caller on the table as on live. A table under an inherited row filter would hold every caller's rows, and the served copy, which reads the table in place of the source that declares the filter, cannot apply the filter to it, so no query would be answered from that table: it is not built. Its queries are answered as they were without it (live, or, for a refinement of a stored source that declares the gate, through that source's table, with the gate applied). Declare the gate on the materialized source itself to serve it from a table.
12
- - **A gate reached only through a join is never frozen, by rule.** No mechanism (`#@ persist`, `#(materialize)`, a persisted view or named query, a `#(rollup)`, on either tier) builds a table over a gate it can reach other than the ones it keeps on every read (the bullets above: the entry point's own proven row filter, or an `#(authorize)` lock on its own `extend`/`->` chain, and, for a rollup, its base's own gates over grain dimensions and locks that read no row field). A gate reached only through a join is never one of those: a source that joins a gated source is refused and answered live. That holds even though a live query on the joining source does not apply the joined source's gate (gates follow the entry point's `extend`/`->` chain, never a join), so do not tell the author it is a gap a later release will trace. The table would hold the joined source's rows at rest, where other readers reach them (a storage destination's files, another package, a data app); a later change to the joined gate would not purge it until its next build; and `#(carries)` and classification would have to count it as exposing the joined fields. To materialize anyway, store a source that does not join the gated one and add the join in an unmaterialized `extend` over it (which raises the same `join-bypass` warning the original joining source does, since it opens the same door), or materialize the gated source on its own under its own gate. See `docs/materialization.md`, "A gate reached through a join is never frozen".
10
+ - **A `#(rollup)` over a gated source is built only where its gate holds on the rollup's rows**: every gate the base's own (declared on the base's own statement, not inherited from a source it extends, not through a join), and every field it reads a grain dimension. It is also admitted when every gate on its base is an `#(authorize)` lock that reads no row field, own or inherited at any depth (still with each gate proven on the rollup). The gate is then re-applied on every read, as on a stored source. Any other gated rollup is refused, naming it. The build skips a refused source, records it on the run (`metadata.refusedSources`), and builds the rest of the package. A run fails on a refusal only when every authored source it targeted was refused, or when `sourceNames` named this one; a refused rollup never fails it. (`#(rollup)` stores a rollup Publisher derives from a measure you annotated with a grain, rather than a source you wrote.) A rollup also groups *across* the gated column, so it could not be row-filtered afterwards even in principle.
11
+ - **A `#(materialize)` is admitted** when its row filter is the entry point's **own** (declared on the materialized source itself, and classified as a row filter) and any `#(authorize)` lock is on its own `extend`/`->` chain (declared on it, or inherited from a source it extends or derives from). The table holds every caller's rows and the gate is re-applied on every read through Publisher; the rows sit ungated in the warehouse, where anyone with direct access to the table reads every row. It is refused in three cases: the gate is reached only through a join, it does not classify as a row filter (or a lock) at all, or the materialized source inherits an `#(access_filter)` row filter from a source it derives from or extends (`source: mine is gated -> { ... }`, `gated extend { ... }`, across imports or two hops away). An inherited lock is not refused: it reads no row, so it admits or denies the caller on the table as on live. A table under an inherited row filter would hold every caller's rows, and the served copy, which reads the table in place of the source that declares the filter, cannot apply the filter to it, so no query would be answered from that table: it is not built. Its queries are answered as they were without it (live, or, for a refinement of a stored source that declares the gate, through that source's table, with the gate applied). Declare the gate on the materialized source itself to serve it from a table.
12
+ - **A gate reached only through a join is never frozen, by rule.** No mechanism (`#@ persist`, `#(materialize)`, a persisted view or named query, a `#(rollup)`) builds a table over a gate it can reach other than the ones it keeps on every read (the bullets above: the entry point's own proven row filter, or an `#(authorize)` lock on its own `extend`/`->` chain, and, for a rollup, its base's own gates over grain dimensions and locks that read no row field). A gate reached only through a join is never one of those: a source that joins a gated source is refused and answered live. That holds even though a live query on the joining source does not apply the joined source's gate (gates follow the entry point's `extend`/`->` chain, never a join), so do not tell the author it is a gap a later release will trace. The table would hold the joined source's rows at rest, where other readers reach them (another package, a data app); a later change to the joined gate would not purge it until its next build; and `#(carries)` and classification would have to count it as exposing the joined fields. To materialize anyway, store a source that does not join the gated one and add the join in an unmaterialized `extend` over it (which raises the same `join-bypass` warning the original joining source does, since it opens the same door), or materialize the gated source on its own under its own gate. See `docs/materialization.md`, "A gate reached through a join is never frozen".
13
13
 
14
14
  **What to be wary of.** Materializing does not weaken the gate: it changes only where rows are read FROM, and the gate still runs live on every query as that query's own `WHERE`, so filtered rows come back filtered. What freezes is the **column the gate filters on**. A row whose access decision changes - it changes owner, say - keeps being served under its OLD decision until the next rebuild. That is a stale *access decision*, not merely stale data, and nothing raises an error.
15
15
 
@@ -20,7 +20,7 @@ source: my_rollup is some_source -> { group_by: ...; aggregate: ... }
20
20
 
21
21
  **A parameterized source must have its argument bound.** `#(materialize)` on `high_value(min_amount is 500) -> { ... }` builds one fixed relation; on the free template `high_value -> { ... }` it is refused (`free_parameter`). A source with any unbound parameter is never stored, on any mechanism or tier (`#(materialize)`, a `#(rollup)` of it, legacy `#@ persist`), whether or not its rows read the parameter; its queries are answered live. Bind it (`s(x is 1)`), or store a query source over a bound invocation (`source: s1 is s(x is 1) -> { select: * }`). An `extend` straight over a bound invocation of a source that reads the parameter (`source: e is s(x is 50) extend { … }`) cannot be keyed, so `#(materialize)`, `#(rollup)`, a persisted view and a persisted named query refuse it, and anything stored over a source extending it (`bound_invocation_unkeyable`, a `*-not-built` warning), and it is answered live: write it as `s(x is 50) -> { select: * } extend { … }` instead. Any other source a run cannot key is refused alone (`address_unresolved`), and the rest of the package builds. Each of these remedies adds a source or rewrites a definition, so it is a shape change (`reference/estimating.md`): show the diff and get it approved on its own.
22
22
 
23
- **A mistake on the line fails the load.** A `#(materialize)` line that does not parse (`materialize-unparseable`), a key outside the closed set (`materialize-unknown-key`), a retired key (`partition=`; `materialize-retired-key`), and a value that is wrong as written (an empty or non-text `storage=`, an `@env.` reference, an `inline=` that is not a list of joins of the source, an unsafe or reserved `name=`, an invalid incremental declaration; `materialize-invalid`) each fail the publish and the load, on every path: publish, reload, restart, watch mode. A misspelled route (`#(materialise)`) fails the same way, code `materialization-near-miss`, naming the spelling it meant. The error has one line per mistake, each ending with its code in brackets, and shows in the publish response and `/status` `loadErrors`; a failed reload keeps serving the previous model (`stale: true`). Fix what it names and reload. A _valid_ annotation Publisher cannot build (an unconfigured destination, an inherited given, a dialect that cannot refresh incrementally, a BigQuery database table with no dataset) is different: that declaration alone is refused with a `warn` under its mechanism's not-built code (`materialize-not-built`, `rollup-not-built`, `persist-view-not-built`, `persist-query-not-built`), answered live, and the package loads. The build plan's `refusedSources` holds one record for it, with the reason.
23
+ **A mistake on the line fails the load.** A `#(materialize)` line that does not parse (`materialize-unparseable`), a key outside the closed set (`materialize-unknown-key`), a retired key (`partition=`; `materialize-retired-key`), and a value that is wrong as written (an `@env.` reference, an `inline=` that is not a list of joins of the source, an unsafe or reserved `name=`, an invalid incremental declaration; `materialize-invalid`) each fail the publish and the load, on every path: publish, reload, restart, watch mode. A misspelled route (`#(materialise)`) fails the same way, code `materialization-near-miss`, naming the spelling it meant. The error has one line per mistake, each ending with its code in brackets, and shows in the publish response and `/status` `loadErrors`; a failed reload keeps serving the previous model (`stale: true`). Fix what it names and reload. A _valid_ annotation Publisher cannot build (an inherited given, a dialect that cannot refresh incrementally, a BigQuery database table with no dataset) is different: that declaration alone is refused with a `warn` under its mechanism's not-built code (`materialize-not-built`, `rollup-not-built`, `persist-view-not-built`, `persist-query-not-built`), answered live, and the package loads. The build plan's `refusedSources` holds one record for it, with the reason.
24
24
 
25
25
  ## The name
26
26
 
@@ -28,8 +28,8 @@ source: my_rollup is some_source -> { group_by: ...; aggregate: ... }
28
28
  - **Quote it.** `name="my_table"`, or a path `name="dataset.table"` / `name="project.dataset.table"`.
29
29
  - **Plain identifier segments only**: dot-separated segments of letters, digits, underscores and hyphens, because the name is inlined into DDL. Publisher quotes each segment for the target warehouse, so case is preserved (`name="OrdersDaily"`) and reserved words work (`name="order"`); never add quotes inside the value (`name="\"Quoted Tbl\""` fails the load, `materialize-invalid`).
30
30
  - **How `name=` is read depends on `scope`.** An unversioned or `scope: "package"` package writes the table at exactly that name, checked and marked as this package's; under `scope: "version"` it is the start of the table's name, lowercased, and the version and a hash follow it (`summary_t__v1_2_0__p<8 hex>`). No view is made at `name=`.
31
- - **One name per table.** Two sources that resolve to the same `name=` in the same destination fail the publish and the load (`materialization-table-collision`); there is no opt-out. A `name=` another package holds refuses that source's build (`table-owned-elsewhere` in the run's failures).
32
- - **The target's container must exist.** `name="analytics.daily"` puts the table in `analytics`, which the connection must be able to write and which Publisher does not create. A `storage=` destination takes `name="daily"` (built in the destination's schema: its `ducklakeConnection.destinationSchema`, else `main`) or `name="analytics.daily"` (a second dot fails the build with a DuckDB parser error); that schema must already exist in the destination, since the build does not create it.
31
+ - **One name per table.** Two sources that resolve to the same `name=` on the same connection fail the publish and the load (`materialization-table-collision`); there is no opt-out. A `name=` another package holds refuses that source's build (`table-owned-elsewhere` in the run's failures).
32
+ - **The target's container must exist.** `name="analytics.daily"` puts the table in `analytics`, which the connection must be able to write and which Publisher does not create. On a managed DuckLake connection the schema must be `main` or one the connection's `readableSchemas` lists.
33
33
 
34
34
  ## Identity and reuse
35
35
 
@@ -43,22 +43,21 @@ A materialized source's identity is its **`sourceEntityId`**: a content address
43
43
  - **An `extend` that declares no `#(materialize)` reads the stored table** through the served copy: its own `extend` block is your text over the table, and is not a build target of its own. An extension that declares its own `#(materialize)` gets its own table, built over its parent's (`reference/chaining.md`).
44
44
  - **A query, a view, a join or a source in a file that imports it** reads the table too, with the materialized source's own `where:` re-applied per caller.
45
45
  - **`#@ -persist`** on an extension opts it out: it recomputes from raw on every query and never reads the table. Reach for it when a reader must not see stale rows, and remember it forgoes exactly the work materialization was there to save. It is Malloy core's own opt-out, and it is not deprecated. Declare it in a model file: written in the query text itself it is not opted out.
46
- - Which queries over a reader route to the table is decided per query - a join to a source not stored with it or a nested column serves live for the queries that touch it (`reference/storage.md`).
46
+ - Which queries over a reader route to the table is decided per query - a join to a source not stored with it or a nested column serves live for the queries that touch it (`reference/serving.md`).
47
47
 
48
48
  ## Every key
49
49
 
50
50
  | On the tag | What it does | Where it is explained |
51
51
  |---|---|---|
52
52
  | `name="..."` | the target table (optional) | above |
53
- | `storage="<destination>"` | build into a storage destination and serve from it | `reference/storage.md` |
54
53
  | `refresh="incremental" watermark="col" [merge_key="a,b"] [lookback="2 days"]` | refresh by bounded delta instead of a full rebuild; `lookback=` re-reads late rows (needs `merge_key=` and a date or timestamp watermark) | `reference/refresh.md` |
55
54
  | `freshness.window="24h" freshness.fallback="live"` | per-source freshness objective | `reference/refresh.md` |
56
55
  | `queryMetadata.<key>="v"` | per-source cost-attribution properties | `reference/policy.md` |
57
56
  | `inline=["j"]` | store a join_one as `j__<field>` columns (keyed by one equality, or several joined by `and`), or a join_many as a pair table | the main skill |
58
57
  | `#@ -persist` (on a reader) | opt a reader out of the table | above |
59
- | `#(rollup) grain=["a", "b"]` (on a measure) | store a derived rollup | `reference/storage.md` |
58
+ | `#(rollup) grain=["a", "b"]` (on a measure) | store a derived rollup | `reference/serving.md` |
60
59
 
61
- `storage=` and `name=` may be written beside the route's key or inside it: `#(materialize) storage="lake"` and `#(materialize) { storage="lake" }` place the table the same way, on every route (`#(materialize)`, `#(rollup)`, a persisted view or query). When both are written, the one inside the key wins, even when it names nothing. A `storage=` that is empty or only whitespace, or that is a list or a block rather than text, fails the publish and the load (the route's own `*-invalid` code): name the destination, or drop the key to build in the source's own warehouse.
60
+ `name=` may be written beside the route's key or inside it: `#(materialize) name="analytics.daily"` and `#(materialize) { name="analytics.daily" }` place the table the same way, on every route (`#(materialize)`, `#(rollup)`, a persisted view or query). When both are written, the one inside the key wins. Do not write `storage=`: a copy in a lake is an extract (`#(extract)`), and a `storage=` declaration is rewritten into one at load (`reference/serving.md`).
62
61
 
63
62
  A rollup takes `name=` too, as a prefix: `name="analytics.orders_rollup"` creates `analytics.orders_rollup__p<hash>`, the container placing it and the leaf starting its name, as `name=` does under `scope: "version"`; the hash, and so the identity, stays Publisher's. Without `name=` the table takes the readable name `<pkg>__<file>__<base>_by_<grain>__p<hash>`, in its base's database `name=` container if it has one. The leaf is lowercased in the name; one the name would otherwise rewrite (a space, punctuation, a leading digit, `__`), an empty one, or one ending in `__p<8 hex>`, fails the load (`rollup-invalid`). Changing the leaf renames the table (rebuilt once; the old one is dropped).
64
63