datanotes 2.0.1 → 3.1.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 (185) hide show
  1. package/NOTICE +9 -0
  2. package/README.md +203 -28
  3. package/SECURITY.md +92 -45
  4. package/dist/THIRD-PARTY-NOTICES.txt +682 -0
  5. package/dist/api/catalog.d.cts +69 -0
  6. package/dist/api/catalog.d.ts +50 -2
  7. package/dist/api/cli-options.d.cts +39 -0
  8. package/dist/api/cli-options.d.ts +39 -0
  9. package/dist/api/client.d.cts +122 -0
  10. package/dist/api/client.d.ts +56 -34
  11. package/dist/api/docs.d.cts +211 -0
  12. package/dist/api/docs.d.ts +211 -0
  13. package/dist/api/guidance.d.cts +81 -0
  14. package/dist/api/guidance.d.ts +81 -0
  15. package/dist/api/index.cjs +7470 -2771
  16. package/dist/api/index.d.cts +14 -0
  17. package/dist/api/index.d.ts +11 -7
  18. package/dist/api/index.js +7470 -2771
  19. package/dist/api/local.cjs +118 -6
  20. package/dist/api/local.d.cts +95 -0
  21. package/dist/api/local.d.ts +70 -6
  22. package/dist/api/local.js +104 -6
  23. package/dist/api/mcp.cjs +17387 -0
  24. package/dist/api/mcp.d.cts +108 -0
  25. package/dist/api/mcp.d.ts +108 -0
  26. package/dist/api/mcp.js +17337 -0
  27. package/dist/api/otlp.d.cts +113 -0
  28. package/dist/api/otlp.d.ts +63 -15
  29. package/dist/api/redact.d.cts +42 -0
  30. package/dist/api/redact.d.ts +42 -0
  31. package/dist/api/requests.d.cts +26 -0
  32. package/dist/api/requests.d.ts +14 -16
  33. package/dist/api/results.d.cts +16 -0
  34. package/dist/api/results.d.ts +2 -1
  35. package/dist/api/tokens.d.cts +12 -0
  36. package/dist/api/tokens.d.ts +5 -0
  37. package/dist/api/tracing.d.cts +107 -0
  38. package/dist/api/tracing.d.ts +107 -0
  39. package/dist/datanotes.cjs +69597 -28329
  40. package/dist/docs/administration/configuration.md +59 -0
  41. package/dist/docs/administration/docker.md +80 -0
  42. package/dist/docs/administration/git-sync.md +71 -0
  43. package/dist/docs/administration/limits.md +153 -0
  44. package/dist/docs/administration/run-the-service.md +237 -0
  45. package/dist/docs/administration/status.md +61 -0
  46. package/dist/docs/administration/use-with-obsidian.md +75 -0
  47. package/dist/docs/api/operations/add_column.md +49 -0
  48. package/dist/docs/api/operations/add_constraint.md +55 -0
  49. package/dist/docs/api/operations/adopt_rows.md +50 -0
  50. package/dist/docs/api/operations/align_relations.md +41 -0
  51. package/dist/docs/api/operations/alter_column.md +46 -0
  52. package/dist/docs/api/operations/alter_table.md +67 -0
  53. package/dist/docs/api/operations/batch.md +48 -0
  54. package/dist/docs/api/operations/changes_stream.md +28 -0
  55. package/dist/docs/api/operations/check_table.md +29 -0
  56. package/dist/docs/api/operations/clone_table.md +48 -0
  57. package/dist/docs/api/operations/comment_on.md +42 -0
  58. package/dist/docs/api/operations/configure_database.md +52 -0
  59. package/dist/docs/api/operations/create_table.md +78 -0
  60. package/dist/docs/api/operations/create_view.md +54 -0
  61. package/dist/docs/api/operations/create_webhook.md +37 -0
  62. package/dist/docs/api/operations/define_base.md +52 -0
  63. package/dist/docs/api/operations/delete_rows.md +43 -0
  64. package/dist/docs/api/operations/delete_webhook.md +31 -0
  65. package/dist/docs/api/operations/describe_database.md +30 -0
  66. package/dist/docs/api/operations/describe_history.md +40 -0
  67. package/dist/docs/api/operations/describe_semantic_index.md +24 -0
  68. package/dist/docs/api/operations/describe_table.md +38 -0
  69. package/dist/docs/api/operations/docs.md +13 -0
  70. package/dist/docs/api/operations/drop_column.md +41 -0
  71. package/dist/docs/api/operations/drop_constraint.md +39 -0
  72. package/dist/docs/api/operations/drop_table.md +43 -0
  73. package/dist/docs/api/operations/drop_view.md +38 -0
  74. package/dist/docs/api/operations/engine_status.md +23 -0
  75. package/dist/docs/api/operations/graph_neighbors.md +34 -0
  76. package/dist/docs/api/operations/graph_path.md +32 -0
  77. package/dist/docs/api/operations/graph_traverse.md +43 -0
  78. package/dist/docs/api/operations/identify_session.md +24 -0
  79. package/dist/docs/api/operations/infer_table.md +43 -0
  80. package/dist/docs/api/operations/insert_row.md +48 -0
  81. package/dist/docs/api/operations/list_changes.md +35 -0
  82. package/dist/docs/api/operations/list_folder.md +28 -0
  83. package/dist/docs/api/operations/list_link_targets.md +44 -0
  84. package/dist/docs/api/operations/list_migrations.md +35 -0
  85. package/dist/docs/api/operations/list_tables.md +32 -0
  86. package/dist/docs/api/operations/list_webhooks.md +23 -0
  87. package/dist/docs/api/operations/manual_index.md +14 -0
  88. package/dist/docs/api/operations/manual_page.md +22 -0
  89. package/dist/docs/api/operations/merge_rows.md +44 -0
  90. package/dist/docs/api/operations/move_rows.md +52 -0
  91. package/dist/docs/api/operations/openapi.md +13 -0
  92. package/dist/docs/api/operations/openapi_post.md +20 -0
  93. package/dist/docs/api/operations/read_note.md +29 -0
  94. package/dist/docs/api/operations/recompute_columns.md +44 -0
  95. package/dist/docs/api/operations/record_tool_call.md +37 -0
  96. package/dist/docs/api/operations/rename_column.md +44 -0
  97. package/dist/docs/api/operations/rename_value.md +45 -0
  98. package/dist/docs/api/operations/restore_database.md +51 -0
  99. package/dist/docs/api/operations/restore_table.md +46 -0
  100. package/dist/docs/api/operations/search_notes.md +28 -0
  101. package/dist/docs/api/operations/select_rows.md +61 -0
  102. package/dist/docs/api/operations/semantic_search.md +34 -0
  103. package/dist/docs/api/operations/semantic_search_docs.md +26 -0
  104. package/dist/docs/api/operations/set_table_bases.md +44 -0
  105. package/dist/docs/api/operations/status.md +13 -0
  106. package/dist/docs/api/operations/stop_engine.md +23 -0
  107. package/dist/docs/api/operations/sync_semantic_index.md +33 -0
  108. package/dist/docs/api/operations/table_changes.md +31 -0
  109. package/dist/docs/api/operations/tags/auxiliary.md +14 -0
  110. package/dist/docs/api/operations/tags/change-feed.md +8 -0
  111. package/dist/docs/api/operations/tags/history.md +17 -0
  112. package/dist/docs/api/operations/tags/queries.md +15 -0
  113. package/dist/docs/api/operations/tags/rows-dml.md +16 -0
  114. package/dist/docs/api/operations/tags/schema-ddl.md +22 -0
  115. package/dist/docs/api/operations/tags/service.md +15 -0
  116. package/dist/docs/api/operations/tags/tokens.md +13 -0
  117. package/dist/docs/api/operations/tokens_create.md +34 -0
  118. package/dist/docs/api/operations/tokens_delete.md +29 -0
  119. package/dist/docs/api/operations/tokens_list.md +21 -0
  120. package/dist/docs/api/operations/tokens_me.md +20 -0
  121. package/dist/docs/api/operations/tokens_rotate.md +29 -0
  122. package/dist/docs/api/operations/tokens_update.md +34 -0
  123. package/dist/docs/api/operations/undo_migration.md +46 -0
  124. package/dist/docs/api/operations/update_row.md +60 -0
  125. package/dist/docs/api/operations/update_rows.md +46 -0
  126. package/dist/docs/api/operations/vacuum_table.md +37 -0
  127. package/dist/docs/api.md +135 -0
  128. package/dist/docs/develop/build-an-app.md +320 -0
  129. package/dist/docs/develop/build-on-datanotes.md +138 -0
  130. package/dist/docs/develop/change-feed-and-webhooks.md +70 -0
  131. package/dist/docs/develop/client.md +116 -0
  132. package/dist/docs/develop/concurrency.md +188 -0
  133. package/dist/docs/develop/http-api.md +89 -0
  134. package/dist/docs/develop/telemetry.md +285 -0
  135. package/dist/docs/guides/agents/docs-offline.md +99 -0
  136. package/dist/docs/guides/agents/how-agents-use-datanotes.md +124 -0
  137. package/dist/docs/guides/agents/prompts.md +495 -0
  138. package/dist/docs/guides/agents/reading-errors.md +112 -0
  139. package/dist/docs/guides/data-quality/check-constraints.md +379 -0
  140. package/dist/docs/guides/data-quality/check-table.md +63 -0
  141. package/dist/docs/guides/data-quality/hand-edits.md +507 -0
  142. package/dist/docs/guides/data-quality/sync-between-devices.md +51 -0
  143. package/dist/docs/guides/data-quality/validation.md +90 -0
  144. package/dist/docs/guides/database-objects/bases.md +480 -0
  145. package/dist/docs/guides/database-objects/catalogs-and-schemas.md +897 -0
  146. package/dist/docs/guides/database-objects/columns.md +1332 -0
  147. package/dist/docs/guides/database-objects/relations.md +1454 -0
  148. package/dist/docs/guides/database-objects/tables.md +1340 -0
  149. package/dist/docs/guides/database-objects/views.md +1003 -0
  150. package/dist/docs/guides/history/back-up.md +203 -0
  151. package/dist/docs/guides/history/change-data-feed.md +247 -0
  152. package/dist/docs/guides/history/journal-and-undo.md +262 -0
  153. package/dist/docs/guides/history/restore.md +341 -0
  154. package/dist/docs/guides/history/table-history.md +657 -0
  155. package/dist/docs/guides/history/vacuum.md +26 -0
  156. package/dist/docs/guides/read-and-write/automatic-links.md +768 -0
  157. package/dist/docs/guides/read-and-write/batch.md +139 -0
  158. package/dist/docs/guides/read-and-write/import-notes.md +896 -0
  159. package/dist/docs/guides/read-and-write/joins-and-aggregates.md +251 -0
  160. package/dist/docs/guides/read-and-write/read-and-filter.md +536 -0
  161. package/dist/docs/guides/read-and-write/write-rows.md +573 -0
  162. package/dist/docs/guides/search/link-graph.md +241 -0
  163. package/dist/docs/guides/search/semantic.md +133 -0
  164. package/dist/docs/guides/search/text.md +142 -0
  165. package/dist/docs/guides/security/security-model.md +110 -0
  166. package/dist/docs/guides/security/tokens.md +60 -0
  167. package/dist/docs/guides/security/who-did-what.md +44 -0
  168. package/dist/docs/index.md +113 -0
  169. package/dist/docs/llms.txt +33 -0
  170. package/dist/docs/reference/cli.md +143 -0
  171. package/dist/docs/reference/compatibility.md +83 -0
  172. package/dist/docs/reference/errors.md +72 -0
  173. package/dist/docs/reference/glossary.md +161 -0
  174. package/dist/docs/reference/operations/auxiliary.md +116 -0
  175. package/dist/docs/reference/operations/history.md +168 -0
  176. package/dist/docs/reference/operations/queries.md +169 -0
  177. package/dist/docs/reference/operations/rows.md +185 -0
  178. package/dist/docs/reference/operations/schema.md +316 -0
  179. package/dist/docs/reference/operations.md +96 -0
  180. package/dist/docs/reference/settings.md +43 -0
  181. package/dist/docs/release-notes.md +188 -0
  182. package/dist/docs/start/connect-agents.md +204 -0
  183. package/dist/docs/start/how-it-works.md +349 -0
  184. package/dist/docs/start/quick-start.md +128 -0
  185. package/package.json +60 -15
@@ -0,0 +1,316 @@
1
+ # Schema operations (DDL)
2
+
3
+ > Operations that define the database: tables, columns, constraints, bases and views.
4
+
5
+ Operations that define the database: tables, columns, constraints, bases and views. The [overview](https://datanotes.dev/reference/operations/) lists every operation by kind. The MCP server, `datanotes mcp`, offers each operation as an MCP tool of the same name, and `engineTools()` of `datanotes/mcp` gives the same definitions to [your own MCP server](https://datanotes.dev/develop/build-on-datanotes/#build-your-own-mcp-server). `DatanotesClient.call(name, args)` runs one from code. Over HTTP each one is `POST /datanotes/operations/<name>/`, with its arguments as the JSON body: the [HTTP API reference](https://datanotes.dev/api/) lists them.
6
+
7
+ Every write is validated. Writes to rows and to the schema are journaled and undone with `undo_migration`; `configure_database`, the webhook operations, `vacuum_table` and `sync_semantic_index` are not journaled.
8
+
9
+ ## `create_table`
10
+
11
+ **Create Table** · write
12
+
13
+ Create a table: `name`, in `catalog` and `schema` (default: the database’s defaults); the definition goes in metastore.yaml, the rows in `<root>/<catalog>/<schema>/<name>/`. Names: lowercase letters, digits, `_` (no dots: pass the catalog and the schema as their own arguments).
14
+
15
+ * `description` (required): what a row of the table records. Every column needs its own `description` too, what it holds: the table is refused otherwise, with every missing one listed. Descriptions are how agents and people understand the schema, so write them for a reader who never saw the notes. The engine writes those of `id` and of `identity` “uuid” / “created” columns.
16
+ * `columns`: specs like `{"name": "kind", "type": "enum", "values": ["a","b"], "required": true, "description": "What kind of entry the row is"}`. Types: string, integer, number, boolean, date, datetime, enum, link, list (+ `items`), json. Attributes: required, default (`"{now}"`/`"{today}"`), min, max, step, values, `ordered` (enum in order: filters/avg use the position), ref (link target, full `catalog.schema.table` or “self”), unique, label, description, aliases, `generated` (e.g. `"date(occurred_at)"`, `"{name} {surname}"`), `identity` (“filename” | “created”), `vocabulary` (allowed values = names of another table’s rows), `hierarchy: true` (one parent link to its own table), `dense` (written on every row), `inverse` on a link column: the column of the `ref` table that links back (`friends` ↔ `friends`, `children` ↔ `parents`, `partner` ↔ `partner`); writes keep both sides in step.
17
+ * `time_column`: rows named by that date/datetime; otherwise `filename` (e.g. `"{name}"`).
18
+ * The table’s options, as alter_table names them: `aliases` (how agents find it, with the description), `partition`, `exclude`, `archive`, `history` (keep its versions; default: the database’s setting), `autolink_target` (true / false: may automatic links link its rows? default: yes, unless its rows are named by a date or a time, as with `time_column`).
19
+ * `row_template`: markdown body of new rows. Shared columns come from bases: `set_table_bases`.
20
+ * `tags`: key/value labels of the table, strings (`{"domain": "health"}`); list_tables and describe_table return them, alter_table changes them. Enum columns: `values` and, for each, its meaning in `value_descriptions` (`{"stated": "the user said it", …}`): describe_table shows them and a refused value lists them. Generated link columns: `generated: "link({occurred_at:YYYY-MM-DD})"` with `ref` = the days table links each row to the row of `ref` named by the template (its folder read from the schema; the target may not exist yet). Filtered link targets (link columns): `ref_where` (a `where` every target must match) and `ref_by` (a column of the row picks the target level: `{"column": "kind", "levels": ["area", "project", "workstream"]}` or `{"column": "kind", "map": {"area": null, "project": ["area"]}}`; null = top level, no link; `target_column` when the target names it differently: an enum target column must have every value the map allows, a string one takes any value). A link to no row of the table, or to the row itself, is refused too. Existing rows that break them refuse the change; `list_link_targets` lists the valid targets of a row.
21
+
22
+ The schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).
23
+
24
+ Examples: [Catalogs, schemas and the database](https://datanotes.dev/guides/database-objects/catalogs-and-schemas/), [Tables](https://datanotes.dev/guides/database-objects/tables/), [Columns and types](https://datanotes.dev/guides/database-objects/columns/), [Bases](https://datanotes.dev/guides/database-objects/bases/), [Relations and hierarchies](https://datanotes.dev/guides/database-objects/relations/), [Write and move rows](https://datanotes.dev/guides/read-and-write/write-rows/), [Automatic links](https://datanotes.dev/guides/read-and-write/automatic-links/), [Import existing notes](https://datanotes.dev/guides/read-and-write/import-notes/), [Table history and time travel](https://datanotes.dev/guides/history/table-history/).
25
+
26
+ | Parameter | Type | Required | Default | Description |
27
+ | ----------------- | ------------ | -------- | ------- | ----------- |
28
+ | `name` | string | yes | | |
29
+ | `description` | string \\ | null | | `null` |
30
+ | `columns` | object\[] | yes | | |
31
+ | `catalog` | string \\ | null | | `null` |
32
+ | `schema` | string \\ | null | | `null` |
33
+ | `time_column` | string \\ | null | | `null` |
34
+ | `filename` | string \\ | null | | `null` |
35
+ | `partition` | string \\ | null | | `null` |
36
+ | `exclude` | string\[] \\ | null | | `null` |
37
+ | `archive` | string \\ | null | | `null` |
38
+ | `aliases` | string\[] \\ | null | | `null` |
39
+ | `history` | boolean \\ | null | | `null` |
40
+ | `autolink_target` | boolean \\ | null | | `null` |
41
+ | `row_template` | string \\ | null | | `null` |
42
+ | `fields` | object \\ | null | | `null` |
43
+ | `tags` | object \\ | null | | `null` |
44
+ | `dry_run` | boolean | | `false` | |
45
+
46
+ ## `drop_table`
47
+
48
+ **Drop Table** · destructive write
49
+
50
+ Drop a table. Refused while it has rows unless `mode: "archive"`, which removes the definition from `metastore.yaml` and moves all rows to the table’s archive folder (nothing is hard-deleted; undo restores). The transaction log is kept: `restore_table` can bring it back. Refused while a CHECK that follows links, or a `ref_where` / `ref_by`, of another table reads this table through a link (link targets are not rewritten): the conflicts name them; drop or change them first.
51
+
52
+ The schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).
53
+
54
+ Examples: [Tables](https://datanotes.dev/guides/database-objects/tables/).
55
+
56
+ | Parameter | Type | Required | Default | Description |
57
+ | --------- | -------------- | -------- | ------- | ----------- |
58
+ | `table` | string | yes | | |
59
+ | `mode` | `"archive"` \\ | null | | `null` |
60
+ | `dry_run` | boolean | | `false` | |
61
+
62
+ ## `alter_table`
63
+
64
+ **Alter Table** · destructive write
65
+
66
+ Alter a table: move it (`catalog`, `schema`), rename it (`name`), change `partition` / `filename` patterns, `description` (changes, never goes: “” is refused), `aliases`, `exclude` folders, `row_template` (“” removes it), `history` (true | false | “default”), `autolink_target` (true | false | “default”: may automatic links link its rows? default: yes, unless its rows are named by a date or a time) or `tags` (key/value labels merged into the table’s, e.g. `{"domain": "health"}`; a `null` value removes that tag; `clear_tags: true` removes every tag first, so with `tags` the table keeps exactly those), `archive` (folder name inside the table folder) or `fields` (untyped fields, name → default; a `null` value removes one). Rows, archive and transaction log follow; links are updated; renamed rows keep their old name in `aliases`. A change of metadata only (tags, description, aliases, history, autolink_target, row_template, fields) rewrites the table entry alone: no row is moved or rewritten. Refused when a row cannot fill a pattern. Renaming or moving the table is refused while a CHECK that follows links, or a `ref_where` / `ref_by`, of another table reads it through a link (link targets are not rewritten): the conflicts name them. Use `dry_run` to see `planned_moves`; undo with undo_migration.
67
+
68
+ The schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).
69
+
70
+ Examples: [Catalogs, schemas and the database](https://datanotes.dev/guides/database-objects/catalogs-and-schemas/), [Tables](https://datanotes.dev/guides/database-objects/tables/), [Automatic links](https://datanotes.dev/guides/read-and-write/automatic-links/), [Import existing notes](https://datanotes.dev/guides/read-and-write/import-notes/), [Table history and time travel](https://datanotes.dev/guides/history/table-history/).
71
+
72
+ | Parameter | Type | Required | Default | Description |
73
+ | ----------------- | ------------ | -------------- | ------- | -------------------------------------------------------------------- |
74
+ | `table` | string | yes | | |
75
+ | `catalog` | string \\ | null | | `null` |
76
+ | `schema` | string \\ | null | | `null` |
77
+ | `name` | string \\ | null | | `null` |
78
+ | `partition` | string \\ | null | | `null` |
79
+ | `filename` | string \\ | null | | `null` |
80
+ | `description` | string \\ | null | | `null` |
81
+ | `aliases` | string\[] \\ | null | | `null` |
82
+ | `history` | boolean \\ | `"default"` \\ | null | |
83
+ | `autolink_target` | boolean \\ | `"default"` \\ | null | |
84
+ | `exclude` | string\[] \\ | null | | `null` |
85
+ | `row_template` | string \\ | null | | `null` |
86
+ | `tags` | object \\ | null | | `null` |
87
+ | `clear_tags` | boolean | | `false` | Remove every tag first (with `tags`: the table keeps exactly those). |
88
+ | `archive` | string \\ | null | | `null` |
89
+ | `fields` | object \\ | null | | `null` |
90
+ | `dry_run` | boolean | | `false` | |
91
+
92
+ ## `clone_table`
93
+
94
+ **Clone Table** · write
95
+
96
+ CREATE TABLE `target` CLONE `source`: same definition plus independent copies of its rows (deep clone), optionally as of a `version` / `timestamp`. `copy_rows: false` copies the definition only (CREATE TABLE LIKE). `target`: `catalog.schema.table`, `schema.table` (in the source’s catalog) or a name (source’s catalog and schema). Useful for experiments, e.g. a sandbox copy in the `agent` catalog. The clone is a new table, so it needs the descriptions create_table does: a source without them is refused, naming what to describe first (alter_table, alter_column). A past version lacking one gets the one the source has now.
97
+
98
+ The schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).
99
+
100
+ Examples: [Tables](https://datanotes.dev/guides/database-objects/tables/), [Bases](https://datanotes.dev/guides/database-objects/bases/), [Table history and time travel](https://datanotes.dev/guides/history/table-history/).
101
+
102
+ | Parameter | Type | Required | Default | Description |
103
+ | ----------- | ---------- | -------- | ------- | ------------------------------------------------------------------------------ |
104
+ | `source` | string | yes | | |
105
+ | `target` | string | yes | | |
106
+ | `version` | integer \\ | null | | `null` |
107
+ | `timestamp` | string \\ | null | | `null` |
108
+ | `copy_rows` | boolean | | `true` | Copy the rows (default); false copies the definition only (CREATE TABLE LIKE). |
109
+ | `dry_run` | boolean | | `false` | |
110
+
111
+ ## `add_column`
112
+
113
+ **Add Column** · write
114
+
115
+ Add a typed column. Sparse by default (written only on rows that have a value — use for metrics, e.g. `{"name": "metric_mood", "type": "integer", "min": 1, "max": 5, "label": "Mood", "aliases": ["mood"], "description": "Mood of the day, 1 = bad, 5 = great"}`). `description` is required: what the column holds, for the agents and people who read the schema (the engine writes it for `identity` “uuid” / “created” columns). `dense: true` in the spec adds it to every row with its `default`. Call `describe_table` first: never add a column whose meaning an existing column (name/label/aliases/description) already covers. Column names are permanent identifiers; only `rename_column` changes them. Enum columns: `values` and, for each, its meaning in `value_descriptions` (`{"stated": "the user said it", …}`): describe_table shows them and a refused value lists them. Generated link columns: `generated: "link({occurred_at:YYYY-MM-DD})"` with `ref` = the days table links each row to the row of `ref` named by the template (its folder read from the schema; the target may not exist yet). Filtered link targets (link columns): `ref_where` (a `where` every target must match) and `ref_by` (a column of the row picks the target level: `{"column": "kind", "levels": ["area", "project", "workstream"]}` or `{"column": "kind", "map": {"area": null, "project": ["area"]}}`; null = top level, no link; `target_column` when the target names it differently: an enum target column must have every value the map allows, a string one takes any value). A link to no row of the table, or to the row itself, is refused too. Existing rows that break them refuse the change; `list_link_targets` lists the valid targets of a row.
116
+
117
+ The schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).
118
+
119
+ Examples: [Columns and types](https://datanotes.dev/guides/database-objects/columns/), [Relations and hierarchies](https://datanotes.dev/guides/database-objects/relations/), [Import existing notes](https://datanotes.dev/guides/read-and-write/import-notes/).
120
+
121
+ | Parameter | Type | Required | Default | Description |
122
+ | --------- | ------- | -------- | ------- | ---------------------------------------------------------------------------------------------------------- |
123
+ | `table` | string | yes | | |
124
+ | `column` | object | yes | | The column’s spec: name, type, description and its other attributes; `dense: true` writes it on every row. |
125
+ | `dry_run` | boolean | | `false` | |
126
+
127
+ ## `rename_column`
128
+
129
+ **Rename Column** · destructive write
130
+
131
+ Rename a column in metastore.yaml and on every row. Refused if `to_column` is already a column of the table; a row that has a stray `to_column` key with a different value is a conflict, and nothing is written. CHECKs, `ref_where` and `ref_by` that read the column (in this table, or through a link from another table: `parent.kind`) follow the new name. Views and note text that mention the old name are not rewritten.
132
+
133
+ The schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).
134
+
135
+ Examples: [Columns and types](https://datanotes.dev/guides/database-objects/columns/).
136
+
137
+ | Parameter | Type | Required | Default | Description |
138
+ | ------------- | ------- | -------- | ------- | ----------- |
139
+ | `table` | string | yes | | |
140
+ | `from_column` | string | yes | | |
141
+ | `to_column` | string | yes | | |
142
+ | `dry_run` | boolean | | `false` | |
143
+
144
+ ## `drop_column`
145
+
146
+ **Drop Column** · destructive write
147
+
148
+ Remove a column from the schema and every row. Previous values are journaled; revert with `undo_migration`. Refused while a CHECK, `ref_where` or `ref_by` of any table reads the column (directly or through a link): the conflicts name them; drop or change them first.
149
+
150
+ The schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).
151
+
152
+ Examples: [Columns and types](https://datanotes.dev/guides/database-objects/columns/).
153
+
154
+ | Parameter | Type | Required | Default | Description |
155
+ | --------- | ------- | -------- | ------- | ------------------ |
156
+ | `table` | string | yes | | |
157
+ | `column` | string | yes | | The column’s name. |
158
+ | `dry_run` | boolean | | `false` | |
159
+
160
+ ## `alter_column`
161
+
162
+ **Alter Column** · destructive write
163
+
164
+ Change a column’s attributes (type, min/max/step, values, required, default, label, aliases, description, note, `ref_where`, `ref_by` (see list_link_targets); `null` removes an attribute, except `description`, which changes but never goes (null or “” is refused); `dense` true/false). Refused with the list of violating rows when existing values do not satisfy the new definition. A different scale means a different column: add a new one instead of rescaling. To rename one enum value use `rename_value`. Dropping an enum value that a `ref_by` (of any table) allows as a target level is refused, naming it.
165
+
166
+ The schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).
167
+
168
+ Examples: [Tables](https://datanotes.dev/guides/database-objects/tables/), [Columns and types](https://datanotes.dev/guides/database-objects/columns/), [Relations and hierarchies](https://datanotes.dev/guides/database-objects/relations/).
169
+
170
+ | Parameter | Type | Required | Default | Description |
171
+ | --------- | ------- | -------- | ------- | ------------------ |
172
+ | `table` | string | yes | | |
173
+ | `column` | string | yes | | The column’s name. |
174
+ | `changes` | object | yes | | |
175
+ | `dry_run` | boolean | | `false` | |
176
+
177
+ ## `rename_value`
178
+
179
+ **Rename Value** · destructive write
180
+
181
+ Rename one value of an enum column (e.g. `high` → `very high`) in metastore.yaml and every row, keeping its position, so an ordered scale is unchanged. CHECKs and `ref_where` conditions on the column (also through a link from another table) and `ref_by` levels / maps that name the value use the new one. Note text (queries, prose) is not rewritten. Refused if `to_value` already exists. Undo with `undo_migration`. Adding or removing classes changes the scale: create a new table instead.
182
+
183
+ The schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).
184
+
185
+ Examples: [Columns and types](https://datanotes.dev/guides/database-objects/columns/).
186
+
187
+ | Parameter | Type | Required | Default | Description |
188
+ | ------------ | ------- | -------- | ------- | ----------- |
189
+ | `table` | string | yes | | |
190
+ | `column` | string | yes | | |
191
+ | `from_value` | string | yes | | |
192
+ | `to_value` | string | yes | | |
193
+ | `dry_run` | boolean | | `false` | |
194
+
195
+ ## `comment_on`
196
+
197
+ **Comment On** · destructive write
198
+
199
+ COMMENT ON CATALOG / SCHEMA: set the `description` of a catalog (`catalog` alone) or of one of its schemas (`catalog` and `schema`) in metastore.yaml: what it holds, so agents pick the right place. `description` “” removes it. An unknown catalog or schema is refused with the existing ones. describe_database and `system.information_schema.catalogs` / `schemata` show it. Undo with `undo_migration`. A table’s description: alter_table.
200
+
201
+ The schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).
202
+
203
+ Examples: [Catalogs, schemas and the database](https://datanotes.dev/guides/database-objects/catalogs-and-schemas/).
204
+
205
+ | Parameter | Type | Required | Default | Description |
206
+ | ------------- | --------- | -------- | ------- | ----------------------------------- |
207
+ | `catalog` | string | yes | | |
208
+ | `schema` | string \\ | null | | `null` |
209
+ | `description` | string | yes | | The new description; “” removes it. |
210
+ | `dry_run` | boolean | | `false` | |
211
+
212
+ ## `define_base`
213
+
214
+ **Define Base** · destructive write
215
+
216
+ Create or replace a base: a named set of columns (same spec as `create_table`) that tables inherit, like a parent class (`bases` in `metastore.yaml`). Tables using it get the columns with the same name and meaning; `ref: "self"` means the inheriting table (e.g. a `parent` column with `hierarchy: true`). `bases` builds on other bases. Descriptions are required, as in create_table: `description` says what the tables of the base share, and each column has its `description` (a column given without one keeps the one the base had for it). Replacing a base changes every inheriting table: `rename_columns` (`{"old": "new"}`) renames the column on their rows, `drop_columns` removes it from their rows; dropping a column without listing it is refused. A renamed column is followed into the CHECKs and `ref_where` / `ref_by` that read it (the base’s own included); dropping one they read is refused, naming them. All affected rows are validated before any write, inherited `ref_where` / `ref_by` and CHECKs that follow links included. Enum columns: `values` and, for each, its meaning in `value_descriptions` (`{"stated": "the user said it", …}`): describe_table shows them and a refused value lists them.
217
+
218
+ The schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).
219
+
220
+ Examples: [Bases](https://datanotes.dev/guides/database-objects/bases/).
221
+
222
+ | Parameter | Type | Required | Default | Description |
223
+ | ---------------- | ------------ | -------- | ------- | ----------- |
224
+ | `name` | string | yes | | |
225
+ | `columns` | object\[] | yes | | |
226
+ | `bases` | string\[] \\ | null | | `null` |
227
+ | `description` | string \\ | null | | `null` |
228
+ | `rename_columns` | object \\ | null | | `null` |
229
+ | `drop_columns` | string\[] \\ | null | | `null` |
230
+ | `dry_run` | boolean | | `false` | |
231
+
232
+ ## `set_table_bases`
233
+
234
+ **Set Table Bases** · destructive write
235
+
236
+ Set the bases a table inherits from (`bases`, in order; `[]` removes them). Inherited columns come after `id` and before the table’s own columns. An own column with the name of an inherited one is replaced by the inherited definition (rows must fit it, its `ref_where` / `ref_by` included); a table may only restyle an inherited column (label, description, aliases, note, dense) with `alter_column`. Dense and generated/identity columns are filled on existing rows.
237
+
238
+ The schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).
239
+
240
+ Examples: [Bases](https://datanotes.dev/guides/database-objects/bases/).
241
+
242
+ | Parameter | Type | Required | Default | Description |
243
+ | --------- | --------- | -------- | ------- | ----------- |
244
+ | `table` | string | yes | | |
245
+ | `bases` | string\[] | yes | | |
246
+ | `dry_run` | boolean | | `false` | |
247
+
248
+ ## `add_constraint`
249
+
250
+ **Add Constraint** · write
251
+
252
+ ALTER TABLE ADD CONSTRAINT `name` CHECK: `check` is a where filter every row must match, e.g. `{"value": {"gte": 1, "lte": 5}}`. A condition on a column the row leaves empty passes, like SQL; inside `or` / `and` / `not` an empty value is tested as it is (`{"exists": true}` there fails). A key may follow a link column to the row it names, as in queries: `{"parent.kind": "project"}` (further dots follow further links). An empty link passes at the top level and fails inside `or` / `and` / `not`; only the first link of a longer path is skipped when empty (`parent.parent.kind` fails for a row whose parent has no parent). A link to a row that does not exist fails; on a list of links every linked row must match. `not` turns that into a pass: `{"not": {"parent.kind": "area"}}` passes a link to a missing row, so add `"parent.kind": {"exists": true}` to require a real one. Links resolve as in the vault (by path, from the row’s note: same-named rows in two folders stay apart); renaming or moving a linked row keeps them (they follow it). Refused while existing rows violate it (they are listed); then enforced on every write, by the same rule. A write that changes a linked row re-checks the rows that link to it and is refused, listing them, when it breaks them, naming the changed row (in a batch, re-link them first: each step is checked on the vault the earlier ones left); the inverse links a write adds, undo_migration and restore_table are checked too. rename_column / rename_value follow into CHECKs; drop_column of a column a CHECK reads is refused.
253
+
254
+ The schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).
255
+
256
+ Examples: [CHECK constraints](https://datanotes.dev/guides/data-quality/check-constraints/).
257
+
258
+ | Parameter | Type | Required | Default | Description |
259
+ | --------- | ------- | -------- | ------- | ----------- |
260
+ | `table` | string | yes | | |
261
+ | `name` | string | yes | | |
262
+ | `check` | object | yes | | |
263
+ | `dry_run` | boolean | | `false` | |
264
+
265
+ ## `drop_constraint`
266
+
267
+ **Drop Constraint** · destructive write
268
+
269
+ Remove the CHECK constraint `name` from `table`.
270
+
271
+ The schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).
272
+
273
+ Examples: [CHECK constraints](https://datanotes.dev/guides/data-quality/check-constraints/).
274
+
275
+ | Parameter | Type | Required | Default | Description |
276
+ | --------- | ------- | -------- | ------- | ----------- |
277
+ | `table` | string | yes | | |
278
+ | `name` | string | yes | | |
279
+ | `dry_run` | boolean | | `false` | |
280
+
281
+ ## `create_view`
282
+
283
+ **Create View** · destructive write
284
+
285
+ Create (or `replace`) a view: a named select stored in metastore.yaml. Name it with the prefix `vw_` (e.g. `vw_open_tasks`): views share names and folders with tables. `query` takes the select_rows parameters (table, columns, where, order_by, limit, join, group_by, aggregates, expand; relative dates keep it current) and must run now. Or `query: {union: [{table, columns, where}, …], columns, where, order_by, limit, expand}` stacks the rows of several tables (UNION ALL, each row tagged `_source`). Its filters may read the note the view is shown for: `{this.<property>}` (`{this.date+1d}`, `{this.date-1w}` shift a date), `{this.link}`, `{this.name}`, `{this.path}`, filled in from select_rows `this_note` (one view serves every daily note, every project note). `description` and `aliases` let agents find it; `labels` are column headings. Views are selected with `select_rows(table=<view>)`, which may narrow them further (where, columns, order_by, limit; a `where` operator the view already has on a column replaces it). A view writes no note: it lives only in metastore.yaml.
286
+
287
+ The schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).
288
+
289
+ Examples: [Views](https://datanotes.dev/guides/database-objects/views/).
290
+
291
+ | Parameter | Type | Required | Default | Description |
292
+ | ------------- | ------------ | -------- | ------- | ----------- |
293
+ | `name` | string | yes | | |
294
+ | `query` | object | yes | | |
295
+ | `catalog` | string \\ | null | | `null` |
296
+ | `schema` | string \\ | null | | `null` |
297
+ | `description` | string \\ | null | | `null` |
298
+ | `aliases` | string\[] \\ | null | | `null` |
299
+ | `labels` | object \\ | null | | `null` |
300
+ | `replace` | boolean | | `false` | |
301
+ | `dry_run` | boolean | | `false` | |
302
+
303
+ ## `drop_view`
304
+
305
+ **Drop View** · destructive write
306
+
307
+ Remove a view from `metastore.yaml` (undo with `undo_migration`).
308
+
309
+ The schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).
310
+
311
+ Examples: [Views](https://datanotes.dev/guides/database-objects/views/).
312
+
313
+ | Parameter | Type | Required | Default | Description |
314
+ | --------- | ------- | -------- | ------- | ----------- |
315
+ | `view` | string | yes | | |
316
+ | `dry_run` | boolean | | `false` | |
@@ -0,0 +1,96 @@
1
+ # Operations
2
+
3
+ > Every operation of the HTTP API, offered to agents as an MCP tool of the same name, grouped by kind.
4
+
5
+ The engine has 54 operations of five kinds, like the statements of a SQL reference. The MCP server, `datanotes mcp`, offers each operation as an MCP tool of the same name, and `engineTools()` of `datanotes/mcp` gives the same definitions to [your own MCP server](https://datanotes.dev/develop/build-on-datanotes/#build-your-own-mcp-server). `DatanotesClient.call(name, args)` runs one from code. Over HTTP each one is `POST /datanotes/operations/<name>/`, with its arguments as the JSON body: the [HTTP API reference](https://datanotes.dev/api/) lists them.
6
+
7
+ Next to them, `datanotes mcp` offers three tools that read these docs offline, `list_docs`, `read_docs` and `search_docs`; they aren’t operations of the engine ([Read the docs offline](https://datanotes.dev/guides/agents/docs-offline/)). `search_docs` takes required and excluded words, and becomes a hybrid search when the engine has semantic search on ([Search by words and by meaning](https://datanotes.dev/guides/agents/docs-offline/#search-by-words-and-by-meaning)).
8
+
9
+ ## Schema (DDL)
10
+
11
+ Operations that define the database: tables, columns, constraints, bases and views. [Schema operations (DDL)](https://datanotes.dev/reference/operations/schema/) lists their parameters.
12
+
13
+ | Operation | What it does | Examples |
14
+ | ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
15
+ | [`create_table`](https://datanotes.dev/reference/operations/schema/#create_table) | Create a table: `name`, in `catalog` and `schema` (default: the database’s defaults); the definition goes in metastore.yaml, the rows in `<root>/<catalog>/<schema>/<name>/`. | [Catalogs, schemas and the database](https://datanotes.dev/guides/database-objects/catalogs-and-schemas/), [Tables](https://datanotes.dev/guides/database-objects/tables/), [Columns and types](https://datanotes.dev/guides/database-objects/columns/), [Bases](https://datanotes.dev/guides/database-objects/bases/), [Relations and hierarchies](https://datanotes.dev/guides/database-objects/relations/), [Write and move rows](https://datanotes.dev/guides/read-and-write/write-rows/), [Automatic links](https://datanotes.dev/guides/read-and-write/automatic-links/), [Import existing notes](https://datanotes.dev/guides/read-and-write/import-notes/), [Table history and time travel](https://datanotes.dev/guides/history/table-history/) |
16
+ | [`drop_table`](https://datanotes.dev/reference/operations/schema/#drop_table) | Drop a table. | [Tables](https://datanotes.dev/guides/database-objects/tables/) |
17
+ | [`alter_table`](https://datanotes.dev/reference/operations/schema/#alter_table) | Alter a table: move it (`catalog`, `schema`), rename it (`name`), change `partition` / `filename` patterns, `description` (changes, never goes: “” is refused), `aliases`, `exclude` folders, `row_template` (“” removes it), `history` (true \| false \| “default”), `autolink_target` (true \| false \| “default”: may automatic links link its rows? default: yes, unless its rows are named by a date or a time) or `tags` (key/value labels merged into the table’s, e.g. | [Catalogs, schemas and the database](https://datanotes.dev/guides/database-objects/catalogs-and-schemas/), [Tables](https://datanotes.dev/guides/database-objects/tables/), [Automatic links](https://datanotes.dev/guides/read-and-write/automatic-links/), [Import existing notes](https://datanotes.dev/guides/read-and-write/import-notes/), [Table history and time travel](https://datanotes.dev/guides/history/table-history/) |
18
+ | [`clone_table`](https://datanotes.dev/reference/operations/schema/#clone_table) | CREATE TABLE `target` CLONE `source`: same definition plus independent copies of its rows (deep clone), optionally as of a `version` / `timestamp`. | [Tables](https://datanotes.dev/guides/database-objects/tables/), [Bases](https://datanotes.dev/guides/database-objects/bases/), [Table history and time travel](https://datanotes.dev/guides/history/table-history/) |
19
+ | [`add_column`](https://datanotes.dev/reference/operations/schema/#add_column) | Add a typed column. | [Columns and types](https://datanotes.dev/guides/database-objects/columns/), [Relations and hierarchies](https://datanotes.dev/guides/database-objects/relations/), [Import existing notes](https://datanotes.dev/guides/read-and-write/import-notes/) |
20
+ | [`rename_column`](https://datanotes.dev/reference/operations/schema/#rename_column) | Rename a column in metastore.yaml and on every row. | [Columns and types](https://datanotes.dev/guides/database-objects/columns/) |
21
+ | [`drop_column`](https://datanotes.dev/reference/operations/schema/#drop_column) | Remove a column from the schema and every row. | [Columns and types](https://datanotes.dev/guides/database-objects/columns/) |
22
+ | [`alter_column`](https://datanotes.dev/reference/operations/schema/#alter_column) | Change a column’s attributes (type, min/max/step, values, required, default, label, aliases, description, note, `ref_where`, `ref_by` (see list_link_targets); `null` removes an attribute, except `description`, which changes but never goes (null or “” is refused); `dense` true/false). | [Tables](https://datanotes.dev/guides/database-objects/tables/), [Columns and types](https://datanotes.dev/guides/database-objects/columns/), [Relations and hierarchies](https://datanotes.dev/guides/database-objects/relations/) |
23
+ | [`rename_value`](https://datanotes.dev/reference/operations/schema/#rename_value) | Rename one value of an enum column (e.g. | [Columns and types](https://datanotes.dev/guides/database-objects/columns/) |
24
+ | [`comment_on`](https://datanotes.dev/reference/operations/schema/#comment_on) | COMMENT ON CATALOG / SCHEMA: set the `description` of a catalog (`catalog` alone) or of one of its schemas (`catalog` and `schema`) in metastore.yaml: what it holds, so agents pick the right place. | [Catalogs, schemas and the database](https://datanotes.dev/guides/database-objects/catalogs-and-schemas/) |
25
+ | [`define_base`](https://datanotes.dev/reference/operations/schema/#define_base) | Create or replace a base: a named set of columns (same spec as `create_table`) that tables inherit, like a parent class (`bases` in `metastore.yaml`). | [Bases](https://datanotes.dev/guides/database-objects/bases/) |
26
+ | [`set_table_bases`](https://datanotes.dev/reference/operations/schema/#set_table_bases) | Set the bases a table inherits from (`bases`, in order; `[]` removes them). | [Bases](https://datanotes.dev/guides/database-objects/bases/) |
27
+ | [`add_constraint`](https://datanotes.dev/reference/operations/schema/#add_constraint) | ALTER TABLE ADD CONSTRAINT `name` CHECK: `check` is a where filter every row must match, e.g. | [CHECK constraints](https://datanotes.dev/guides/data-quality/check-constraints/) |
28
+ | [`drop_constraint`](https://datanotes.dev/reference/operations/schema/#drop_constraint) | Remove the CHECK constraint `name` from `table`. | [CHECK constraints](https://datanotes.dev/guides/data-quality/check-constraints/) |
29
+ | [`create_view`](https://datanotes.dev/reference/operations/schema/#create_view) | Create (or `replace`) a view: a named select stored in metastore.yaml. | [Views](https://datanotes.dev/guides/database-objects/views/) |
30
+ | [`drop_view`](https://datanotes.dev/reference/operations/schema/#drop_view) | Remove a view from `metastore.yaml` (undo with `undo_migration`). | [Views](https://datanotes.dev/guides/database-objects/views/) |
31
+
32
+ ## Rows (DML)
33
+
34
+ Operations that write rows: insert, update, merge, delete, move, adopt and batch. [Row operations (DML)](https://datanotes.dev/reference/operations/rows/) lists their parameters.
35
+
36
+ | Operation | What it does | Examples |
37
+ | -------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
38
+ | [`insert_row`](https://datanotes.dev/reference/operations/rows/#insert_row) | Insert a row (new note). | [Catalogs, schemas and the database](https://datanotes.dev/guides/database-objects/catalogs-and-schemas/), [Tables](https://datanotes.dev/guides/database-objects/tables/), [Columns and types](https://datanotes.dev/guides/database-objects/columns/), [Bases](https://datanotes.dev/guides/database-objects/bases/), [Relations and hierarchies](https://datanotes.dev/guides/database-objects/relations/), [Validation](https://datanotes.dev/guides/data-quality/validation/), [CHECK constraints](https://datanotes.dev/guides/data-quality/check-constraints/), [Write and move rows](https://datanotes.dev/guides/read-and-write/write-rows/), [Automatic links](https://datanotes.dev/guides/read-and-write/automatic-links/), [Batch writes](https://datanotes.dev/guides/read-and-write/batch/), [Import existing notes](https://datanotes.dev/guides/read-and-write/import-notes/), [Journal and undo](https://datanotes.dev/guides/history/journal-and-undo/), [Table history and time travel](https://datanotes.dev/guides/history/table-history/), [Change data feed](https://datanotes.dev/guides/history/change-data-feed/), [Restore a table or the database](https://datanotes.dev/guides/history/restore/) |
39
+ | [`update_row`](https://datanotes.dev/reference/operations/rows/#update_row) | Update exactly ONE row, addressed by its `id` (the system UUID) or its `path`; refused when the row does not exist (or id and path disagree). | [Columns and types](https://datanotes.dev/guides/database-objects/columns/), [Bases](https://datanotes.dev/guides/database-objects/bases/), [Relations and hierarchies](https://datanotes.dev/guides/database-objects/relations/), [CHECK constraints](https://datanotes.dev/guides/data-quality/check-constraints/), [Hand edits](https://datanotes.dev/guides/data-quality/hand-edits/), [Write and move rows](https://datanotes.dev/guides/read-and-write/write-rows/), [Automatic links](https://datanotes.dev/guides/read-and-write/automatic-links/), [Batch writes](https://datanotes.dev/guides/read-and-write/batch/), [Journal and undo](https://datanotes.dev/guides/history/journal-and-undo/), [Table history and time travel](https://datanotes.dev/guides/history/table-history/), [Change data feed](https://datanotes.dev/guides/history/change-data-feed/), [Restore a table or the database](https://datanotes.dev/guides/history/restore/) |
40
+ | [`update_rows`](https://datanotes.dev/reference/operations/rows/#update_rows) | Update every row matching `where` (required: `{}` is every row). | [Write and move rows](https://datanotes.dev/guides/read-and-write/write-rows/) |
41
+ | [`merge_rows`](https://datanotes.dev/reference/operations/rows/#merge_rows) | MERGE (upsert) `rows` into `table` by the key columns `on` (e.g. | [Write and move rows](https://datanotes.dev/guides/read-and-write/write-rows/) |
42
+ | [`delete_rows`](https://datanotes.dev/reference/operations/rows/#delete_rows) | Delete rows matching `where`. | [Relations and hierarchies](https://datanotes.dev/guides/database-objects/relations/), [Write and move rows](https://datanotes.dev/guides/read-and-write/write-rows/), [Table history and time travel](https://datanotes.dev/guides/history/table-history/) |
43
+ | [`move_rows`](https://datanotes.dev/reference/operations/rows/#move_rows) | Move rows matching `where` (required: `{}` is every row) to another table (e.g. | [Write and move rows](https://datanotes.dev/guides/read-and-write/write-rows/) |
44
+ | [`adopt_rows`](https://datanotes.dev/reference/operations/rows/#adopt_rows) | Turn existing notes (not rows of any table yet) into rows of `table`, keeping their body and links: `rename` keys (`{"data": "occurred_at"}`), `set` for all, `per_row` values by note path (`{"Home/x.md": {"zone": "[[Kitchen]]"}}`), `drop` keys the table does not have. | [Import existing notes](https://datanotes.dev/guides/read-and-write/import-notes/) |
45
+ | [`batch`](https://datanotes.dev/reference/operations/rows/#batch) | Several writes that succeed or fail together. | [Views](https://datanotes.dev/guides/database-objects/views/), [Relations and hierarchies](https://datanotes.dev/guides/database-objects/relations/), [CHECK constraints](https://datanotes.dev/guides/data-quality/check-constraints/), [Batch writes](https://datanotes.dev/guides/read-and-write/batch/), [Restore a table or the database](https://datanotes.dev/guides/history/restore/) |
46
+ | [`align_relations`](https://datanotes.dev/reference/operations/rows/#align_relations) | Add the reciprocal links missing on a table’s `inverse` link columns (e.g. | [Relations and hierarchies](https://datanotes.dev/guides/database-objects/relations/) |
47
+ | [`recompute_columns`](https://datanotes.dev/reference/operations/rows/#recompute_columns) | Bring generated and identity columns up to date (all rows, or only `paths`), e.g. | [Hand edits](https://datanotes.dev/guides/data-quality/hand-edits/) |
48
+
49
+ ## Queries
50
+
51
+ Operations that read rows and notes: select_rows, link targets, text and semantic search, the link graph. [Query operations](https://datanotes.dev/reference/operations/queries/) lists their parameters.
52
+
53
+ | Operation | What it does | Examples |
54
+ | ----------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
55
+ | [`select_rows`](https://datanotes.dev/reference/operations/queries/#select_rows) | Query rows: `{table, total, rows: [{path, ...}]}`. | [Catalogs, schemas and the database](https://datanotes.dev/guides/database-objects/catalogs-and-schemas/), [Tables](https://datanotes.dev/guides/database-objects/tables/), [Columns and types](https://datanotes.dev/guides/database-objects/columns/), [Views](https://datanotes.dev/guides/database-objects/views/), [Bases](https://datanotes.dev/guides/database-objects/bases/), [Relations and hierarchies](https://datanotes.dev/guides/database-objects/relations/), [Validation](https://datanotes.dev/guides/data-quality/validation/), [CHECK constraints](https://datanotes.dev/guides/data-quality/check-constraints/), [Hand edits](https://datanotes.dev/guides/data-quality/hand-edits/), [Read and filter rows](https://datanotes.dev/guides/read-and-write/read-and-filter/), [Joins and aggregates](https://datanotes.dev/guides/read-and-write/joins-and-aggregates/), [Write and move rows](https://datanotes.dev/guides/read-and-write/write-rows/), [Batch writes](https://datanotes.dev/guides/read-and-write/batch/), [Import existing notes](https://datanotes.dev/guides/read-and-write/import-notes/), [Journal and undo](https://datanotes.dev/guides/history/journal-and-undo/), [Table history and time travel](https://datanotes.dev/guides/history/table-history/), [Restore a table or the database](https://datanotes.dev/guides/history/restore/) |
56
+ | [`list_link_targets`](https://datanotes.dev/reference/operations/queries/#list_link_targets) | The rows a link column may point to, for one row: what an agent or a picker offers before writing the link. | [Relations and hierarchies](https://datanotes.dev/guides/database-objects/relations/) |
57
+ | [`read_note`](https://datanotes.dev/reference/operations/queries/#read_note) | Read a note or another file of the vault: `{path, content, front_matter, tags, modified_at, created_at, size}`. | [Relations and hierarchies](https://datanotes.dev/guides/database-objects/relations/), [Hand edits](https://datanotes.dev/guides/data-quality/hand-edits/), [Import existing notes](https://datanotes.dev/guides/read-and-write/import-notes/), [Read and search notes](https://datanotes.dev/guides/search/text/) |
58
+ | [`list_folder`](https://datanotes.dev/reference/operations/queries/#list_folder) | The direct children of a vault folder: `{folder, folders, files}`, each a vault path, sorted; dot-files and dot-folders are left out. | [Catalogs, schemas and the database](https://datanotes.dev/guides/database-objects/catalogs-and-schemas/), [Tables](https://datanotes.dev/guides/database-objects/tables/), [Columns and types](https://datanotes.dev/guides/database-objects/columns/), [Write and move rows](https://datanotes.dev/guides/read-and-write/write-rows/), [Read and search notes](https://datanotes.dev/guides/search/text/) |
59
+ | [`search_notes`](https://datanotes.dev/reference/operations/queries/#search_notes) | Plain-text search: every word of `query` must occur, case- and accent-insensitive, in the note’s path or text; there are no operators. | [Read and search notes](https://datanotes.dev/guides/search/text/) |
60
+ | [`semantic_search`](https://datanotes.dev/reference/operations/queries/#semantic_search) | Find notes by meaning, not exact words: `{query, results: [{path, score, heading, snippet, table?}]}`, one result per note (its best passage), best first. | [Find notes by meaning](https://datanotes.dev/guides/search/semantic/) |
61
+ | [`graph_neighbors`](https://datanotes.dev/reference/operations/queries/#graph_neighbors) | Direct neighbours of notes: what they link to (`out`) and what links to them (`in`, backlinks), with counts per edge label. | [Walk the link graph](https://datanotes.dev/guides/search/link-graph/) |
62
+ | [`graph_traverse`](https://datanotes.dev/reference/operations/queries/#graph_traverse) | Breadth-first walk over links from `from_nodes` (`{"paths": [...]}`, `{"table", "where"}` and/or `{"tables": [...]}`). | [Walk the link graph](https://datanotes.dev/guides/search/link-graph/) |
63
+ | [`graph_path`](https://datanotes.dev/reference/operations/queries/#graph_path) | Shortest chain of links between two sets of notes (each `{"paths": [...]}`, `{"table", "where"}` and/or `{"tables": [...]}`): `found`, `length` and `path`: the steps (`from`, `label`, `direction`, `to`). | [Walk the link graph](https://datanotes.dev/guides/search/link-graph/) |
64
+
65
+ ## History
66
+
67
+ Operations on the journal, a table’s versions, the change feed and webhooks: undo, time travel, restore and vacuum. [History operations](https://datanotes.dev/reference/operations/history/) lists their parameters.
68
+
69
+ | Operation | What it does | Examples |
70
+ | --------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
71
+ | [`list_migrations`](https://datanotes.dev/reference/operations/history/#list_migrations) | The operation journal, newest first: `total` (the matching operations) and `migrations`, each with `migration_id` (for undo_migration), `op`, `summary`, `table` (when it was about one), `executed_at`, `notes_changed`, `files_changed`, `undone`, `undoes`, `files_failed`, `by` (the agent), and `members` (a batch’s operations) or `batch` (the batch of an operation). | [Hand edits](https://datanotes.dev/guides/data-quality/hand-edits/), [Journal and undo](https://datanotes.dev/guides/history/journal-and-undo/) |
72
+ | [`undo_migration`](https://datanotes.dev/reference/operations/history/#undo_migration) | Revert a journaled table operation by its `migration_id`. | [Columns and types](https://datanotes.dev/guides/database-objects/columns/), [Views](https://datanotes.dev/guides/database-objects/views/), [Journal and undo](https://datanotes.dev/guides/history/journal-and-undo/), [Restore a table or the database](https://datanotes.dev/guides/history/restore/) |
73
+ | [`describe_history`](https://datanotes.dev/reference/operations/history/#describe_history) | DESCRIBE HISTORY: the table’s versions, newest first — `version`, `timestamp`, `operation` (CREATE TABLE, WRITE, UPDATE, DELETE, MERGE, ALTER TABLE, ADD COLUMNS, RESTORE, UNDO, …; `EXTERNAL_EDIT` = changed outside the engine: an editor, git, sync), `operation_metrics` and `migration_id` (undo). | [Table history and time travel](https://datanotes.dev/guides/history/table-history/), [Restore a table or the database](https://datanotes.dev/guides/history/restore/) |
74
+ | [`table_changes`](https://datanotes.dev/reference/operations/history/#table_changes) | Change data feed between two versions (both included, end defaults to latest): one entry per row change with its values plus `_change_type` (insert, delete, update_preimage, update_postimage, metadata), `_commit_version`, `_commit_timestamp`, `_operation`, `path`. | [Table history and time travel](https://datanotes.dev/guides/history/table-history/) |
75
+ | [`restore_table`](https://datanotes.dev/reference/operations/history/#restore_table) | RESTORE TABLE to a `version` or `timestamp`: rows and definition return to that state — rows added since are deleted, changed rows get their old content, removed rows come back (a dropped table is re-created). | [Restore a table or the database](https://datanotes.dev/guides/history/restore/) |
76
+ | [`restore_database`](https://datanotes.dev/reference/operations/history/#restore_database) | RESTORE DATABASE to a `timestamp` (each table as of its last version committed at or before it) or to `before_migration` (a `migration_id` or a `batch`: every table as it was just before that operation ran — to rewind an agent’s run). | [Restore a table or the database](https://datanotes.dev/guides/history/restore/) |
77
+ | [`vacuum_table`](https://datanotes.dev/reference/operations/history/#vacuum_table) | Delete transaction-log history older than `retain_from_version` (default: keep only the latest version); time travel before it becomes impossible. | [Vacuum old history](https://datanotes.dev/guides/history/vacuum/) |
78
+ | [`list_changes`](https://datanotes.dev/reference/operations/history/#list_changes) | Change feed across all tables: numbered row changes (`seq`), oldest first, from engine writes and from hand edits (`source: external`). | [Hand edits](https://datanotes.dev/guides/data-quality/hand-edits/), [Change data feed](https://datanotes.dev/guides/history/change-data-feed/) |
79
+ | [`list_webhooks`](https://datanotes.dev/reference/operations/history/#list_webhooks) | Webhooks of the change feed: id, url, filter (tables, ops, columns, exclude_actor), `cursor` (last change delivered), `status` (ok, failing, disabled), `last_delivery`, `last_error`. | [Change data feed](https://datanotes.dev/guides/history/change-data-feed/) |
80
+ | [`create_webhook`](https://datanotes.dev/reference/operations/history/#create_webhook) | Push row changes to a URL (a service that would rather be called than poll `list_changes`): batches of up to 100 events POSTed as `{webhook, events, last}`, signed with `X-Datanotes-Signature: sha256=<HMAC of the body>`, retried with backoff until a 2xx. | [Change data feed](https://datanotes.dev/guides/history/change-data-feed/) |
81
+ | [`delete_webhook`](https://datanotes.dev/reference/operations/history/#delete_webhook) | Stop and remove a webhook (by `id` from list_webhooks). | [Change data feed](https://datanotes.dev/guides/history/change-data-feed/) |
82
+
83
+ ## Auxiliary
84
+
85
+ Operations that describe and check the database, configure it and maintain its indexes. [Auxiliary operations](https://datanotes.dev/reference/operations/auxiliary/) lists their parameters.
86
+
87
+ | Operation | What it does | Examples |
88
+ | ------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
89
+ | [`list_tables`](https://datanotes.dev/reference/operations/auxiliary/#list_tables) | List every table: `name`, `catalog`, `schema`, `qualified` (`personal.metrics.mood` — use it wherever a table is expected; `metrics.mood` or `mood` also work when unambiguous), `path` and, when declared, `description`, `aliases` (other words for what it records) and `tags`. | [Tables](https://datanotes.dev/guides/database-objects/tables/), [Views](https://datanotes.dev/guides/database-objects/views/) |
90
+ | [`describe_table`](https://datanotes.dev/reference/operations/auxiliary/#describe_table) | Describe a table (`catalog.schema.table` or a shorter unambiguous name): `qualified`, `name`, `catalog`, `schema`, `description`, `aliases`, `layout` (`folder`, `row_folder`: the folder pattern of new rows, `archive`), `options` (`partition`, `filename`, `archive`, `exclude`), typed `columns` with label/aliases/description and the dense flag, `untyped_fields`, `row_count`, and when set: `tags`, `bases` (the bases it inherits from, in order), `constraints` (its CHECKs, name → where), `row_template`, `history`, `autolink_target`, `fields` (their values). | [Catalogs, schemas and the database](https://datanotes.dev/guides/database-objects/catalogs-and-schemas/), [Tables](https://datanotes.dev/guides/database-objects/tables/), [Bases](https://datanotes.dev/guides/database-objects/bases/), [Relations and hierarchies](https://datanotes.dev/guides/database-objects/relations/) |
91
+ | [`describe_database`](https://datanotes.dev/reference/operations/auxiliary/#describe_database) | Describe the database: its folder (`root`), `metastore` (`metastore.yaml`: read it freely, but it is read-only for agents and changes only through the schema operations), configuration (default catalog and schema, row partition and file-name formats, archive folder, time zone, history, automatic links), journal folder, `bases` (shared column sets and the tables using them), `catalogs` → `schemas` → `tables` (with `row_count`, `tags`, and `unreadable_count` when some rows’ front matter cannot be read) and `views`; catalogs and schemas show their `comment` (set with `comment_on`). | [Catalogs, schemas and the database](https://datanotes.dev/guides/database-objects/catalogs-and-schemas/), [Hand edits](https://datanotes.dev/guides/data-quality/hand-edits/) |
92
+ | [`configure_database`](https://datanotes.dev/reference/operations/auxiliary/#configure_database) | Configure the database (persisted in metastore.yaml `config:`): `root` (rename the database folder; links follow; revert by renaming back), `default_catalog`, `default_schema`, `default_partition` (“” = flat) and `default_filename` (date formats for new time-based tables), `archive_folder`, `timezone` (IANA; completes date-times written without offset), `history` (transaction log for every table: true in a database the engine creates, false when `config` lacks it, as in a metastore from before 3.0.0; change it only on the user’s request), `autolink` (the text a write puts in a body links the notes it mentions; on by default). | [Catalogs, schemas and the database](https://datanotes.dev/guides/database-objects/catalogs-and-schemas/), [Tables](https://datanotes.dev/guides/database-objects/tables/), [Automatic links](https://datanotes.dev/guides/read-and-write/automatic-links/), [Table history and time travel](https://datanotes.dev/guides/history/table-history/) |
93
+ | [`check_table`](https://datanotes.dev/reference/operations/auxiliary/#check_table) | Validate every row against the table (required, types, ranges, enums, links, unknown columns, CHECK constraints, those that follow links included, filtered link targets (ref_where / ref_by), stale generated/identity values, missing inverse links, front matter that cannot be read: code `unreadable`, with no column, for a note whose `table` line names the table but whose YAML is broken, which every other read leaves out). | [Relations and hierarchies](https://datanotes.dev/guides/database-objects/relations/), [Hand edits](https://datanotes.dev/guides/data-quality/hand-edits/), [Find rows that break the schema](https://datanotes.dev/guides/data-quality/check-table/) |
94
+ | [`infer_table`](https://datanotes.dev/reference/operations/auxiliary/#infer_table) | Read-only schema inference from notes’ front matter. | [Hand edits](https://datanotes.dev/guides/data-quality/hand-edits/), [Import existing notes](https://datanotes.dev/guides/read-and-write/import-notes/) |
95
+ | [`describe_semantic_index`](https://datanotes.dev/reference/operations/auxiliary/#describe_semantic_index) | The semantic search index: `enabled`, `provider`, `model`, `files`, `passages`, `pending`, `running`, `last_sync`, `last_error`. | [Find notes by meaning](https://datanotes.dev/guides/search/semantic/) |
96
+ | [`sync_semantic_index`](https://datanotes.dev/reference/operations/auxiliary/#sync_semantic_index) | Bring the semantic search index up to date: embed the notes changed since the last run (the engine also does it on its own about ten seconds after edits). | [Find notes by meaning](https://datanotes.dev/guides/search/semantic/) |