datanotes 2.0.0 → 3.0.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 (181) hide show
  1. package/NOTICE +9 -0
  2. package/README.md +207 -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 +89 -0
  10. package/dist/api/client.d.ts +19 -30
  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 +6610 -2247
  16. package/dist/api/index.d.cts +13 -0
  17. package/dist/api/index.d.ts +10 -7
  18. package/dist/api/index.js +6610 -2247
  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 +17384 -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 +17334 -0
  27. package/dist/api/otlp.d.cts +65 -0
  28. package/dist/api/redact.d.cts +17 -0
  29. package/dist/api/redact.d.ts +17 -0
  30. package/dist/api/requests.d.cts +26 -0
  31. package/dist/api/requests.d.ts +14 -16
  32. package/dist/api/results.d.cts +16 -0
  33. package/dist/api/results.d.ts +2 -1
  34. package/dist/api/tokens.d.cts +7 -0
  35. package/dist/datanotes.cjs +62911 -28409
  36. package/dist/docs/administration/configuration.md +59 -0
  37. package/dist/docs/administration/docker.md +80 -0
  38. package/dist/docs/administration/git-sync.md +71 -0
  39. package/dist/docs/administration/limits.md +69 -0
  40. package/dist/docs/administration/run-the-service.md +219 -0
  41. package/dist/docs/administration/status.md +61 -0
  42. package/dist/docs/administration/use-with-obsidian.md +75 -0
  43. package/dist/docs/api/operations/add_column.md +49 -0
  44. package/dist/docs/api/operations/add_constraint.md +55 -0
  45. package/dist/docs/api/operations/adopt_rows.md +50 -0
  46. package/dist/docs/api/operations/align_relations.md +41 -0
  47. package/dist/docs/api/operations/alter_column.md +46 -0
  48. package/dist/docs/api/operations/alter_table.md +67 -0
  49. package/dist/docs/api/operations/batch.md +48 -0
  50. package/dist/docs/api/operations/changes_stream.md +28 -0
  51. package/dist/docs/api/operations/check_table.md +29 -0
  52. package/dist/docs/api/operations/clone_table.md +48 -0
  53. package/dist/docs/api/operations/comment_on.md +42 -0
  54. package/dist/docs/api/operations/configure_database.md +52 -0
  55. package/dist/docs/api/operations/create_table.md +78 -0
  56. package/dist/docs/api/operations/create_view.md +54 -0
  57. package/dist/docs/api/operations/create_webhook.md +37 -0
  58. package/dist/docs/api/operations/define_base.md +52 -0
  59. package/dist/docs/api/operations/delete_rows.md +43 -0
  60. package/dist/docs/api/operations/delete_webhook.md +31 -0
  61. package/dist/docs/api/operations/describe_database.md +30 -0
  62. package/dist/docs/api/operations/describe_history.md +40 -0
  63. package/dist/docs/api/operations/describe_semantic_index.md +24 -0
  64. package/dist/docs/api/operations/describe_table.md +38 -0
  65. package/dist/docs/api/operations/docs.md +13 -0
  66. package/dist/docs/api/operations/drop_column.md +41 -0
  67. package/dist/docs/api/operations/drop_constraint.md +39 -0
  68. package/dist/docs/api/operations/drop_table.md +43 -0
  69. package/dist/docs/api/operations/drop_view.md +38 -0
  70. package/dist/docs/api/operations/engine_status.md +23 -0
  71. package/dist/docs/api/operations/graph_neighbors.md +32 -0
  72. package/dist/docs/api/operations/graph_path.md +32 -0
  73. package/dist/docs/api/operations/graph_traverse.md +43 -0
  74. package/dist/docs/api/operations/identify_session.md +24 -0
  75. package/dist/docs/api/operations/infer_table.md +43 -0
  76. package/dist/docs/api/operations/insert_row.md +48 -0
  77. package/dist/docs/api/operations/list_changes.md +35 -0
  78. package/dist/docs/api/operations/list_folder.md +28 -0
  79. package/dist/docs/api/operations/list_link_targets.md +44 -0
  80. package/dist/docs/api/operations/list_migrations.md +35 -0
  81. package/dist/docs/api/operations/list_tables.md +32 -0
  82. package/dist/docs/api/operations/list_webhooks.md +23 -0
  83. package/dist/docs/api/operations/manual_index.md +14 -0
  84. package/dist/docs/api/operations/manual_page.md +22 -0
  85. package/dist/docs/api/operations/merge_rows.md +44 -0
  86. package/dist/docs/api/operations/move_rows.md +52 -0
  87. package/dist/docs/api/operations/openapi.md +13 -0
  88. package/dist/docs/api/operations/openapi_post.md +20 -0
  89. package/dist/docs/api/operations/read_note.md +29 -0
  90. package/dist/docs/api/operations/recompute_columns.md +44 -0
  91. package/dist/docs/api/operations/record_tool_call.md +36 -0
  92. package/dist/docs/api/operations/rename_column.md +44 -0
  93. package/dist/docs/api/operations/rename_value.md +45 -0
  94. package/dist/docs/api/operations/restore_database.md +51 -0
  95. package/dist/docs/api/operations/restore_table.md +46 -0
  96. package/dist/docs/api/operations/search_notes.md +28 -0
  97. package/dist/docs/api/operations/select_rows.md +61 -0
  98. package/dist/docs/api/operations/semantic_search.md +34 -0
  99. package/dist/docs/api/operations/semantic_search_docs.md +26 -0
  100. package/dist/docs/api/operations/set_table_bases.md +44 -0
  101. package/dist/docs/api/operations/status.md +13 -0
  102. package/dist/docs/api/operations/stop_engine.md +23 -0
  103. package/dist/docs/api/operations/sync_semantic_index.md +33 -0
  104. package/dist/docs/api/operations/table_changes.md +31 -0
  105. package/dist/docs/api/operations/tags/auxiliary.md +14 -0
  106. package/dist/docs/api/operations/tags/change-feed.md +8 -0
  107. package/dist/docs/api/operations/tags/history.md +17 -0
  108. package/dist/docs/api/operations/tags/queries.md +15 -0
  109. package/dist/docs/api/operations/tags/rows-dml.md +16 -0
  110. package/dist/docs/api/operations/tags/schema-ddl.md +22 -0
  111. package/dist/docs/api/operations/tags/service.md +15 -0
  112. package/dist/docs/api/operations/tags/tokens.md +13 -0
  113. package/dist/docs/api/operations/tokens_create.md +34 -0
  114. package/dist/docs/api/operations/tokens_delete.md +29 -0
  115. package/dist/docs/api/operations/tokens_list.md +21 -0
  116. package/dist/docs/api/operations/tokens_me.md +20 -0
  117. package/dist/docs/api/operations/tokens_rotate.md +29 -0
  118. package/dist/docs/api/operations/tokens_update.md +34 -0
  119. package/dist/docs/api/operations/undo_migration.md +46 -0
  120. package/dist/docs/api/operations/update_row.md +60 -0
  121. package/dist/docs/api/operations/update_rows.md +46 -0
  122. package/dist/docs/api/operations/vacuum_table.md +37 -0
  123. package/dist/docs/api.md +135 -0
  124. package/dist/docs/develop/build-an-app.md +320 -0
  125. package/dist/docs/develop/build-on-datanotes.md +138 -0
  126. package/dist/docs/develop/change-feed-and-webhooks.md +70 -0
  127. package/dist/docs/develop/client.md +116 -0
  128. package/dist/docs/develop/concurrency.md +153 -0
  129. package/dist/docs/develop/http-api.md +79 -0
  130. package/dist/docs/develop/telemetry.md +86 -0
  131. package/dist/docs/guides/agents/docs-offline.md +99 -0
  132. package/dist/docs/guides/agents/how-agents-use-datanotes.md +124 -0
  133. package/dist/docs/guides/agents/prompts.md +495 -0
  134. package/dist/docs/guides/agents/reading-errors.md +112 -0
  135. package/dist/docs/guides/data-quality/check-constraints.md +379 -0
  136. package/dist/docs/guides/data-quality/check-table.md +63 -0
  137. package/dist/docs/guides/data-quality/hand-edits.md +507 -0
  138. package/dist/docs/guides/data-quality/sync-between-devices.md +51 -0
  139. package/dist/docs/guides/data-quality/validation.md +90 -0
  140. package/dist/docs/guides/database-objects/bases.md +480 -0
  141. package/dist/docs/guides/database-objects/catalogs-and-schemas.md +897 -0
  142. package/dist/docs/guides/database-objects/columns.md +1332 -0
  143. package/dist/docs/guides/database-objects/relations.md +1454 -0
  144. package/dist/docs/guides/database-objects/tables.md +1404 -0
  145. package/dist/docs/guides/database-objects/views.md +1003 -0
  146. package/dist/docs/guides/history/back-up.md +195 -0
  147. package/dist/docs/guides/history/change-data-feed.md +247 -0
  148. package/dist/docs/guides/history/journal-and-undo.md +262 -0
  149. package/dist/docs/guides/history/restore.md +341 -0
  150. package/dist/docs/guides/history/table-history.md +657 -0
  151. package/dist/docs/guides/history/vacuum.md +35 -0
  152. package/dist/docs/guides/read-and-write/automatic-links.md +768 -0
  153. package/dist/docs/guides/read-and-write/batch.md +139 -0
  154. package/dist/docs/guides/read-and-write/import-notes.md +896 -0
  155. package/dist/docs/guides/read-and-write/joins-and-aggregates.md +251 -0
  156. package/dist/docs/guides/read-and-write/read-and-filter.md +536 -0
  157. package/dist/docs/guides/read-and-write/write-rows.md +573 -0
  158. package/dist/docs/guides/search/link-graph.md +146 -0
  159. package/dist/docs/guides/search/semantic.md +133 -0
  160. package/dist/docs/guides/search/text.md +142 -0
  161. package/dist/docs/guides/security/security-model.md +110 -0
  162. package/dist/docs/guides/security/tokens.md +60 -0
  163. package/dist/docs/guides/security/who-did-what.md +42 -0
  164. package/dist/docs/index.md +113 -0
  165. package/dist/docs/llms.txt +33 -0
  166. package/dist/docs/reference/cli.md +136 -0
  167. package/dist/docs/reference/compatibility.md +63 -0
  168. package/dist/docs/reference/errors.md +72 -0
  169. package/dist/docs/reference/glossary.md +161 -0
  170. package/dist/docs/reference/operations/auxiliary.md +116 -0
  171. package/dist/docs/reference/operations/history.md +168 -0
  172. package/dist/docs/reference/operations/queries.md +169 -0
  173. package/dist/docs/reference/operations/rows.md +185 -0
  174. package/dist/docs/reference/operations/schema.md +316 -0
  175. package/dist/docs/reference/operations.md +96 -0
  176. package/dist/docs/reference/settings.md +31 -0
  177. package/dist/docs/release-notes.md +67 -0
  178. package/dist/docs/start/connect-agents.md +204 -0
  179. package/dist/docs/start/how-it-works.md +317 -0
  180. package/dist/docs/start/quick-start.md +126 -0
  181. package/package.json +59 -14
@@ -0,0 +1,161 @@
1
+ # Glossary
2
+
3
+ > The words of Datanotes, from row and table to journal, transaction log, token and change feed, each with the page that explains it.
4
+
5
+ The words these docs use, in alphabetical order. Each one links to the page that explains it.
6
+
7
+ ## Actor
8
+
9
+ Who made a write: the credential as `auth` (`owner` or a token’s name), and, when the caller sends them, the harness, model, session and tool. The journal, the history and the change feed record it. See [Who did what](https://datanotes.dev/guides/security/who-did-what/).
10
+
11
+ ## Agent
12
+
13
+ A program driven by a language model, such as Claude, Cursor or Codex, that calls the engine’s operations as tools through the MCP server. See [How agents work with your vault](https://datanotes.dev/guides/agents/how-agents-use-datanotes/).
14
+
15
+ ## App
16
+
17
+ A program that calls the HTTP API with its own named token, such as a script, a service or an MCP server of your own. Each app has its own [named token](https://datanotes.dev/guides/security/tokens/). See [Build on Datanotes](https://datanotes.dev/develop/build-on-datanotes/).
18
+
19
+ ## Automatic link
20
+
21
+ A link the engine adds where the text of a write mentions another note by name. A doubtful mention stays as text, and the write returns it in `ambiguous_mentions` with the notes it may name. The `autolink` setting turns it off. See [Automatic links](https://datanotes.dev/guides/read-and-write/automatic-links/).
22
+
23
+ ## Base
24
+
25
+ A named set of columns that tables inherit, like a parent class. One query reads every table that extends a base. See [Bases](https://datanotes.dev/guides/database-objects/bases/).
26
+
27
+ ## Backlinks
28
+
29
+ The notes that link to a given note. `file_backlink_count` counts them, and the graph operations follow them with the direction `in`. See [Read and filter rows](https://datanotes.dev/guides/read-and-write/read-and-filter/).
30
+
31
+ ## Batch
32
+
33
+ A list of writes that succeed or fail together, as one journal entry that one undo reverts. See [Batch writes](https://datanotes.dev/guides/read-and-write/batch/).
34
+
35
+ ## Catalog
36
+
37
+ The top level of the database’s hierarchy: a catalog holds schemas, and a schema holds tables. A table’s full name is `catalog.schema.table`. See [Catalogs, schemas and the database](https://datanotes.dev/guides/database-objects/catalogs-and-schemas/).
38
+
39
+ ## Change feed
40
+
41
+ The numbered list of every change in the vault, writes and hand edits alike, that programs poll, stream or receive by webhook. Also called the change data feed. See [Change data feed](https://datanotes.dev/guides/history/change-data-feed/).
42
+
43
+ ## CHECK constraint
44
+
45
+ A rule, written as a filter, that every row of a table must pass. It can follow links into other tables. See [CHECK constraints](https://datanotes.dev/guides/data-quality/check-constraints/).
46
+
47
+ ## Column
48
+
49
+ A typed front matter key of a table’s rows. Its type can be a string, a number, a date, an enum or a link, and it has attributes such as `required`, `unique` and `default`. See [Columns and types](https://datanotes.dev/guides/database-objects/columns/).
50
+
51
+ ## Data home
52
+
53
+ The folder that holds the engine’s stores, one per database: `%LOCALAPPDATA%\Datanotes` on Windows, `~/Library/Application Support/Datanotes` on macOS and `~/.local/share/datanotes` on Linux. `DATANOTES_DATA_HOME` moves it. See [Run the engine as a service](https://datanotes.dev/administration/run-the-service/#where-the-engine-keeps-its-store).
54
+
55
+ ## Database folder
56
+
57
+ The folder that holds `metastore.yaml`. With `--database`, it’s the folder you pass, and `metastore.yaml` sits at its root. With `--vault`, it’s a folder inside the vault, `datanotes/` by default: the engine finds it at each start, and `configure_database` with `root` moves it. See [One database per vault](https://datanotes.dev/administration/run-the-service/#one-database-per-vault).
58
+
59
+ ## Database id
60
+
61
+ A UUID at the top of `metastore.yaml`, as `id`, that names the database. The engine writes it when it creates the database, and finds the database’s store by it. A copy of a vault gets its own with `datanotes store new-id`. See [Run a copy of a vault](https://datanotes.dev/administration/run-the-service/#run-a-copy-of-a-vault).
62
+
63
+ ## Engine
64
+
65
+ The process that runs a vault as a database, `datanotes serve`. It checks and journals every write and serves the HTTP API. See [Run the engine as a service](https://datanotes.dev/administration/run-the-service/).
66
+
67
+ ## Front matter
68
+
69
+ The YAML block at the top of a note, between two `---` lines. Each key of a row’s front matter holds the value of one column. See [How it works](https://datanotes.dev/start/how-it-works/).
70
+
71
+ ## Hand edit
72
+
73
+ A change to a note made outside the engine: in an editor, with git or through a sync tool. The engine checks it against the tables’ rules but never refuses it. See [Hand edits](https://datanotes.dev/guides/data-quality/hand-edits/).
74
+
75
+ ## History
76
+
77
+ A table’s transaction log, when it’s turned on: every version of the table, for time travel and restores. See [Table history and time travel](https://datanotes.dev/guides/history/table-history/).
78
+
79
+ ## Hybrid search
80
+
81
+ A search that ranks by words and by meaning, then merges the two rankings with Reciprocal Rank Fusion. `search_docs` works this way when the engine has semantic search on. See [Search by words and by meaning](https://datanotes.dev/guides/agents/docs-offline/#search-by-words-and-by-meaning).
82
+
83
+ ## Journal
84
+
85
+ The record of every write to rows and to the schema, with the data to undo it and its actor, in `journal/` in the engine’s store. See [Journal and undo](https://datanotes.dev/guides/history/journal-and-undo/).
86
+
87
+ ## MCP
88
+
89
+ The Model Context Protocol, the way agents call tools. `datanotes mcp`, the MCP server of Datanotes, offers the operations of the engine as tools, the webhook tools only on request. See [Connect your agents](https://datanotes.dev/start/connect-agents/).
90
+
91
+ ## Metastore
92
+
93
+ The file that defines every catalog, schema, table, column, base and view: `metastore.yaml`, at the root of the database folder. It changes only through operations. See [How it works](https://datanotes.dev/start/how-it-works/#the-metastore-defines-every-table).
94
+
95
+ ## Migration
96
+
97
+ One journal entry: a write, with its `migration_id`. `list_migrations` lists them, and `undo_migration` reverts one. See [Journal and undo](https://datanotes.dev/guides/history/journal-and-undo/).
98
+
99
+ ## Module
100
+
101
+ A JavaScript entry point of the `datanotes` package: `datanotes/client` calls the HTTP API, `datanotes/local` finds the local engine, and `datanotes/mcp` gives the engine’s tools to an MCP server of your own. See [Call the engine from JavaScript](https://datanotes.dev/develop/client/).
102
+
103
+ ## Note
104
+
105
+ A Markdown file in the vault. A note with a front matter key `table` that names a table is a row; any other note is an ordinary note. See [How it works](https://datanotes.dev/start/how-it-works/).
106
+
107
+ ## Operation
108
+
109
+ A call the engine runs, such as `create_table`, `insert_row` or `select_rows`. Each one is an HTTP route and an MCP tool of the same name. See [Operations](https://datanotes.dev/reference/operations/).
110
+
111
+ ## Owner token
112
+
113
+ The token that can do everything, generated at the engine’s first start and kept in its settings file. See [Tokens and permissions](https://datanotes.dev/guides/security/tokens/).
114
+
115
+ ## Row
116
+
117
+ A note whose front matter key `table` names a table, wherever it lives in the vault. Its front matter keys are the row’s columns. Each row has an `id` that never changes. See [Tables](https://datanotes.dev/guides/database-objects/tables/).
118
+
119
+ ## Schema
120
+
121
+ The level between catalogs and tables: a schema holds tables and views. See [Catalogs, schemas and the database](https://datanotes.dev/guides/database-objects/catalogs-and-schemas/).
122
+
123
+ ## Store
124
+
125
+ The engine’s folder for one database, outside the vault: `<data home>/<database id>/`. It holds the settings, the tokens, the journal, the transaction logs, the change feed and the logs. Results name its files with a `store:` prefix. See [Run the engine as a service](https://datanotes.dev/administration/run-the-service/#where-the-engine-keeps-its-store).
126
+
127
+ ## Store backup
128
+
129
+ The [store](#store) kept as a git repository of its own and pushed to a private remote, such as a GitHub repository. It keeps the journal, the transaction logs, the change feed and the named tokens’ hashes, never the settings or a secret. Every 60 seconds by default, when the store changed, it commits between two operations, then pushes. `datanotes store restore` brings it back on a new machine. See [Back up the history](https://datanotes.dev/guides/history/back-up/).
130
+
131
+ ## Table
132
+
133
+ A set of rows with the same columns, defined in the metastore. See [Tables](https://datanotes.dev/guides/database-objects/tables/).
134
+
135
+ ## Token
136
+
137
+ A credential for the HTTP API, sent as `Authorization: Bearer`. The owner token can do everything; a named token has only the permissions you give it. See [Tokens and permissions](https://datanotes.dev/guides/security/tokens/).
138
+
139
+ ## Transaction log
140
+
141
+ The numbered versions of a table with history on, in `transaction_log/` in the engine’s store. See [How it works](https://datanotes.dev/start/how-it-works/#the-transaction-log-keeps-every-version).
142
+
143
+ ## Vault
144
+
145
+ The folder of notes the engine serves. Note editors such as Obsidian, Foam or Zettlr work on a folder like this one too. A vault is optional: with `--database`, the database folder is the folder the engine serves. With `--vault`, the engine serves a whole vault, and the database is a folder inside it. Either way, rows and ordinary notes link to each other, and the engine serves every note. Paths are relative to the folder the engine serves, and the engine never writes outside it. Not every note is a row. See [How it works](https://datanotes.dev/start/how-it-works/#the-engine-runs-on-a-database-folder-or-on-a-vault).
146
+
147
+ ## Version
148
+
149
+ One numbered state of a table in its transaction log. `select_rows` reads a table at a version or a time. See [Table history and time travel](https://datanotes.dev/guides/history/table-history/).
150
+
151
+ ## View
152
+
153
+ A query stored under a name in the metastore, read like a table. See [Views](https://datanotes.dev/guides/database-objects/views/).
154
+
155
+ ## Webhook
156
+
157
+ A web address the engine posts the change feed to. See [Follow the change feed and webhooks](https://datanotes.dev/develop/change-feed-and-webhooks/).
158
+
159
+ ## Wikilink
160
+
161
+ A link between notes written `[[Note]]`, or `[[Note|alias]]` with an alias as the text it shows. A link column holds wikilinks to rows of its `ref` table. See [Relations and hierarchies](https://datanotes.dev/guides/database-objects/relations/).
@@ -0,0 +1,116 @@
1
+ # Auxiliary operations
2
+
3
+ > Operations that describe and check the database, configure it and maintain its indexes.
4
+
5
+ Operations that describe and check the database, configure it and maintain its indexes. 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
+ ## `list_tables`
10
+
11
+ **List Tables** · read-only
12
+
13
+ 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 are defined in `metastore.yaml` (catalog → schema → table): read it freely, but it is read-only for agents and changes only through the schema operations (create_table, add_column, …). Returns `{tables, views}`: `views` lists the stored views (same fields, no path): select them like tables. `system.information_schema` is read with `select_rows`.
14
+
15
+ Call this first to find the table for what the user reports (match their words against name, description and aliases), and before creating tables or columns so you reuse existing ones instead of creating duplicates.
16
+
17
+ Examples: [Tables](https://datanotes.dev/guides/database-objects/tables/), [Views](https://datanotes.dev/guides/database-objects/views/).
18
+
19
+ ## `describe_table`
20
+
21
+ **Describe Table** · read-only
22
+
23
+ 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).
24
+
25
+ Before adding a column (e.g. a new metric), read `columns` and match your concept against `name`, `label`, `aliases` and `description`; reuse an existing column when it means the same.
26
+
27
+ `missing_descriptions` (`{table, columns}`), present only when something has no description (a table defined before descriptions were required), names what lacks one: write them with alter_table `description` and alter_column `changes.description`, asking the user when the meaning is unclear.
28
+
29
+ Examples: [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/).
30
+
31
+ | Parameter | Type | Required | Default | Description |
32
+ | --------- | ------ | -------- | ------- | ----------- |
33
+ | `table` | string | yes | | |
34
+
35
+ ## `describe_database`
36
+
37
+ **Describe Database** · read-only
38
+
39
+ 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`). A table or base defined before descriptions were required has `missing_descriptions`: what lacks one, for alter_table / alter_column (define_base for a base) to fill, so every table and column says what it holds.
40
+
41
+ Examples: [Catalogs, schemas and the database](https://datanotes.dev/guides/database-objects/catalogs-and-schemas/), [Hand edits](https://datanotes.dev/guides/data-quality/hand-edits/).
42
+
43
+ ## `configure_database`
44
+
45
+ **Configure Database** · destructive write
46
+
47
+ 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). Returns describe_database. Renaming `root` moves the folder (links to its notes are rewritten; the tables’ archive and `exclude` folders inside it follow); the move is listed in the journal as `move_database` (undo and time travel read older entries with the new paths) and cannot be undone. Settings changes are not journaled (no `migration_id`, nothing for undo_migration): to revert, call it again with the previous values.
48
+
49
+ The metastore changes only through operations: never edit metastore.yaml by hand (no validation).
50
+
51
+ 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/), [Table history and time travel](https://datanotes.dev/guides/history/table-history/).
52
+
53
+ | Parameter | Type | Required | Default | Description |
54
+ | ------------------- | ---------- | -------- | ------- | ----------- |
55
+ | `root` | string \\ | null | | `null` |
56
+ | `default_catalog` | string \\ | null | | `null` |
57
+ | `default_schema` | string \\ | null | | `null` |
58
+ | `default_partition` | string \\ | null | | `null` |
59
+ | `default_filename` | string \\ | null | | `null` |
60
+ | `archive_folder` | string \\ | null | | `null` |
61
+ | `timezone` | string \\ | null | | `null` |
62
+ | `history` | boolean \\ | null | | `null` |
63
+ | `autolink` | boolean \\ | null | | `null` |
64
+
65
+ ## `check_table`
66
+
67
+ **Check Table** · read-only
68
+
69
+ 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). A CHECK violation has code `check` and the CHECK’s name as `constraint` (every other code names its `column`), as in the `violations` of list_changes. Use it to find rows edited by hand that break the schema. Without `table`, every table is checked: each row then names its `table`, `tables_checked` counts the tables checked, and a table that cannot be checked is listed in `errors` ({table, error}) while the others are. The rows with violations are paged: `limit` (default 500, at most 5000) from `offset`; `total` counts them all. (Hand edits are also checked as they happen: see `violations` in list_changes.)
70
+
71
+ Examples: [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/).
72
+
73
+ | Parameter | Type | Required | Default | Description |
74
+ | --------- | --------- | -------- | ------- | -------------------------------------------- |
75
+ | `table` | string \\ | null | | `null` |
76
+ | `limit` | integer | | `500` | Rows with violations returned (paging). |
77
+ | `offset` | integer | | `0` | Rows with violations skipped first (paging). |
78
+
79
+ ## `infer_table`
80
+
81
+ **Infer Table** · read-only
82
+
83
+ Read-only schema inference from notes’ front matter.
84
+
85
+ * `folder` (recursive; “” = whole vault) and/or `paths`: notes not yet in a table. Returns `columns` (type, enum `values`, link `ref` to the table most targets belong to, `required`, `unique`, `dense`, `from` when the front matter key is not a valid column name, `stats`), `proposal`, the create_table arguments (`name`, `description`, `filename` or `time_column`, `columns`), and `adopt` ready for adopt_rows (`paths`, `rename`, `relocate: false`), plus `hints` to read. The notes cannot say what the table and its columns mean: `description` is null on the proposal and on every column. Write each one (ask the user when unsure), and review the names, enums and required columns, before you pass the proposal to create_table, which refuses null descriptions.
86
+ * `table`: keys the table’s rows use but the table does not declare (candidates for add_column, each with a description to write, or keys to drop from rows). A string column becomes an enum when its values repeat: at least 3 notes, at most `max_enum_values` distinct values (default 12), each used twice on average, short texts.
87
+
88
+ Examples: [Hand edits](https://datanotes.dev/guides/data-quality/hand-edits/), [Import existing notes](https://datanotes.dev/guides/read-and-write/import-notes/).
89
+
90
+ | Parameter | Type | Required | Default | Description |
91
+ | ----------------- | ------------ | -------- | ------- | ----------- |
92
+ | `folder` | string \\ | null | | `null` |
93
+ | `paths` | string\[] \\ | null | | `null` |
94
+ | `table` | string \\ | null | | `null` |
95
+ | `name` | string \\ | null | | `null` |
96
+ | `max_enum_values` | integer \\ | null | | `null` |
97
+
98
+ ## `describe_semantic_index`
99
+
100
+ **Describe Semantic Index** · read-only
101
+
102
+ The semantic search index: `enabled`, `provider`, `model`, `files`, `passages`, `pending`, `running`, `last_sync`, `last_error`. sync_semantic_index brings it up to date.
103
+
104
+ Examples: [Find notes by meaning](https://datanotes.dev/guides/search/semantic/).
105
+
106
+ ## `sync_semantic_index`
107
+
108
+ **Sync Semantic Index** · destructive write
109
+
110
+ 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). `rebuild: true` re-embeds everything: slow, and costs money with a paid provider — ask first.
111
+
112
+ Examples: [Find notes by meaning](https://datanotes.dev/guides/search/semantic/).
113
+
114
+ | Parameter | Type | Required | Default | Description |
115
+ | --------- | ------- | -------- | ------- | ----------------------------------------------- |
116
+ | `rebuild` | boolean | | `false` | Re-embed every note, not only the changed ones. |
@@ -0,0 +1,168 @@
1
+ # History operations
2
+
3
+ > Operations on the journal, a table's versions, the change feed and webhooks: undo, time travel, restore and vacuum.
4
+
5
+ Operations on the journal, a table’s versions, the change feed and webhooks: undo, time travel, restore and vacuum. 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
+ ## `list_migrations`
10
+
11
+ **List Migrations** · read-only
12
+
13
+ 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). Filters: `op` (e.g. “update_rows”), `table` (substring of the table name, e.g. “personal.tasks.task”), `since` (ISO date). `limit` default 50. The journal is kept in the engine’s store, outside the vault (`store:journal/`); entries older than 90 days are dropped.
14
+
15
+ Examples: [Hand edits](https://datanotes.dev/guides/data-quality/hand-edits/), [Journal and undo](https://datanotes.dev/guides/history/journal-and-undo/).
16
+
17
+ | Parameter | Type | Required | Default | Description |
18
+ | --------- | ---------- | -------- | ------- | ----------- |
19
+ | `limit` | integer \\ | null | | `null` |
20
+ | `op` | string \\ | null | | `null` |
21
+ | `table` | string \\ | null | | `null` |
22
+ | `since` | string \\ | null | | `null` |
23
+
24
+ ## `undo_migration`
25
+
26
+ **Undo Migration** · destructive write
27
+
28
+ Revert a journaled table operation by its `migration_id`. Refused (nothing written) when any touched note changed since; the conflicts are listed. Also refused when the revert would leave rows breaking a CHECK that follows links or a `ref_where` / `ref_by` (rows it writes, or rows that link to them), listed like the refusals of other writes with the way out (fix the row, or drop the rule). The rules are those of the schema the revert puts back: undoing a rename_value / rename_column puts the old names back with the rows, and a rule the revert puts back must hold on every row. A `batch` is checked as a whole first (nothing written when refused), then reverted operation by operation, from the last; when one finds a note changed since, those after it stay reverted and a retry skips them. An undo is journaled like any operation: undoing it (the `migration_id` of its answer; `undoes` names the operation undone) is a redo, whatever the operation (a batch included). The revert is a new version (`UNDO`) in the transaction log; undoing a table’s rename or move takes its whole log back to the old name, the versions made under the new one included.
29
+
30
+ The schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).
31
+
32
+ Examples: [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/).
33
+
34
+ | Parameter | Type | Required | Default | Description |
35
+ | -------------- | ------ | -------- | ------- | ----------- |
36
+ | `migration_id` | string | yes | | |
37
+
38
+ ## `describe_history`
39
+
40
+ **Describe History** · read-only
41
+
42
+ 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). An EXTERNAL_EDIT’s `operation_metrics.violations` counts the rules this table’s rows break because of the hand edits it holds (each once): the edited rows whose front matter changed and the rows of the table linking to them, a removed or renamed row included (rows of other tables count in their table; a body-only edit is not checked); every rule its rows break when its definition was edited in metastore.yaml. Absent when nothing was checked, or when the edits were logged right before an engine write (the change feed has them); check_table lists the rows invalid now. Works for dropped tables too (full `catalog.schema.table`). Use a version with `select_rows` (time travel), `table_changes` or `restore_table`. Without `table`: the history of the whole database — the commits of every table with a log (dropped ones included), newest first, each with its `table` (the result’s `tables` lists the logged tables). An operation that changed several tables (a cascade, inverse links, restore_database) commits to each with the same `migration_id`, and the operations of a `batch` carry its id as `batch`: their commits list in `tables` every table that operation (or batch) committed to. Pick a moment for `restore_database` from it (`timestamp`, or `before_migration` with a `migration_id` or a `batch`). `limit` (default 50) counts commits; `since` (ISO date or date-time): only commits at or after it.
43
+
44
+ Examples: [Table history and time travel](https://datanotes.dev/guides/history/table-history/), [Restore a table or the database](https://datanotes.dev/guides/history/restore/).
45
+
46
+ | Parameter | Type | Required | Default | Description |
47
+ | --------- | ---------- | -------- | ------- | ----------- |
48
+ | `table` | string \\ | null | | `null` |
49
+ | `limit` | integer \\ | null | | `null` |
50
+ | `since` | string \\ | null | | `null` |
51
+
52
+ ## `table_changes`
53
+
54
+ **Table Changes** · read-only
55
+
56
+ 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`. Use it to answer “what changed since …” without diffing full tables.
57
+
58
+ Examples: [Table history and time travel](https://datanotes.dev/guides/history/table-history/).
59
+
60
+ | Parameter | Type | Required | Default | Description |
61
+ | --------------- | ---------- | -------- | ------- | ----------- |
62
+ | `table` | string | yes | | |
63
+ | `start_version` | integer | yes | | |
64
+ | `end_version` | integer \\ | null | | `null` |
65
+
66
+ ## `restore_table`
67
+
68
+ **Restore Table** · destructive write
69
+
70
+ 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). History is not rewritten: the restore is a new version, and `undo_migration` reverts it. Refused (rows listed, with the way out) when the rows it writes, or rows that link to them, would break a CHECK that follows links or a `ref_where` / `ref_by` (as the restored definition has them: a rule added since does not hold the old rows). Run with `dry_run` first and show the user what changes.
71
+
72
+ The schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).
73
+
74
+ Examples: [Restore a table or the database](https://datanotes.dev/guides/history/restore/).
75
+
76
+ | Parameter | Type | Required | Default | Description |
77
+ | ----------- | ---------- | -------- | ------- | ----------- |
78
+ | `table` | string | yes | | |
79
+ | `version` | integer \\ | null | | `null` |
80
+ | `timestamp` | string \\ | null | | `null` |
81
+ | `dry_run` | boolean | | `false` | |
82
+
83
+ ## `restore_database`
84
+
85
+ **Restore Database** · destructive write
86
+
87
+ 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). Every table that keeps a transaction log goes back, rows and definition: rows added since are deleted, changed rows get their old content, removed rows come back; a table created since is dropped with its rows moved to its archive folder (as drop_table with mode “archive”: nothing is hard-deleted), a table dropped since comes back. Tables already as they were are left alone (`unchanged`, no new version). One operation: each restored table gets a RESTORE version, all with one `migration_id`, and `undo_migration` on it reverts them all. Refused as a whole, nothing written (rows listed, with the way out), when a row it leaves would break a CHECK that follows links or a `ref_where` / `ref_by`, across tables, as the restored definitions have them. Tables without a log (history off, or vacuumed before that time) cannot be rewound: they stay as they are, listed in `skipped` with the reason (tell the user). Views, bases and the database settings are not rewound (the logs keep tables), nor a rename or move of a table (undo_migration on it does that). Returns `restored_to`, `tables` (per table: `action` restore / drop / recreate, `version`, `creates`, `texts`, `deletes`, `archived`), `unchanged` and `skipped`. Run with `dry_run` first and show the user what changes; describe_history without `table` shows the moments.
88
+
89
+ The schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).
90
+
91
+ Examples: [Restore a table or the database](https://datanotes.dev/guides/history/restore/).
92
+
93
+ | Parameter | Type | Required | Default | Description |
94
+ | ------------------ | --------- | -------- | ------- | ----------- |
95
+ | `timestamp` | string \\ | null | | `null` |
96
+ | `before_migration` | string \\ | null | | `null` |
97
+ | `dry_run` | boolean | | `false` | |
98
+
99
+ ## `vacuum_table`
100
+
101
+ **Vacuum Table** · destructive write
102
+
103
+ Delete transaction-log history older than `retain_from_version` (default: keep only the latest version); time travel before it becomes impossible. Rows are not touched. `dry_run` defaults to true: it lists the log files that would go. Only on the user’s explicit request.
104
+
105
+ Examples: [Vacuum old history](https://datanotes.dev/guides/history/vacuum/).
106
+
107
+ | Parameter | Type | Required | Default | Description |
108
+ | --------------------- | ---------- | -------- | ------- | ----------- |
109
+ | `table` | string | yes | | |
110
+ | `retain_from_version` | integer \\ | null | | `null` |
111
+ | `dry_run` | boolean | | `true` | |
112
+
113
+ ## `list_changes`
114
+
115
+ **List Changes** · read-only
116
+
117
+ Change feed across all tables: numbered row changes (`seq`), oldest first, from engine writes and from hand edits (`source: external`). Each has `table`, `kind` (insert, update, delete, move, metastore, unreadable), `op` (the operation that made it), `path`, `row_id`, `changes` ({column: {before, after}}), `actor`, `migration_id`. Hand edits are compared in batches (0.7 s after the last vault change, at most 5 s after the first), in the order they happened, renames included. A hand edit that creates, changes, renames or removes a row is checked against the tables’ rules (as check_table does) with the rows that link to it: the last event of each row in the batch has `violations` (\[{path, violations: \[{code, column | constraint (the CHECK’s name), index, message}]}]), what the edit breaks (a rule a row already broke is not listed); empty when it breaks nothing, absent when nothing was checked (engine events, a check that failed). A hand edit of metastore.yaml that changes tables’ entries checks every row of those tables: on its `metastore` event. At most 100 per event; `violations_total` then counts them all. A note renamed or moved by hand (a row or a plain note) has the links to its old path rewritten across the vault once the vault is quiet (4 s without a change; not while git pulls, rebases or merges; setting repairLinksOnHandMove, on by default), and its move event does not report them as broken_link: that repair’s events (`op: repair_links`) follow the batch and name the moves in `cause` (\[{path, old_path, seq}], `seq` of the row’s move event). A hand edit that leaves a row’s front matter unreadable (broken YAML) is a `kind: unreadable` event with one violation of code `unreadable`: every read leaves the row out until the note is fixed, and the fix is an update of the row’s last readable state (an insert for a new note). Agents’ tool calls (reported by MCP servers) are `kind: tool_call` events (`call`: tool, args, ok, duration_ms, value, served_by), returned only when `kinds` includes tool_call. Pass the returned `last` as `since` next time (`head` is the newest number); `wait_ms` (max 60000) waits for a new change (long poll); `limit` max 5000. `gap: true` means older changes were dropped: re-read the tables. `where` filters rows as in select_rows (on the values after the change). Per-table versions: `table_changes`.
118
+
119
+ Examples: [Hand edits](https://datanotes.dev/guides/data-quality/hand-edits/), [Change data feed](https://datanotes.dev/guides/history/change-data-feed/).
120
+
121
+ | Parameter | Type | Required | Default | Description |
122
+ | --------------- | ------------- | ------------- | ------------- | ----------- |
123
+ | `since` | integer | | `0` | |
124
+ | `tables` | string\[] \\ | null | | `null` |
125
+ | `kinds` | `"insert"` \\ | `"update"` \\ | `"delete"` \\ | `"move"` \\ |
126
+ | `columns` | string\[] \\ | null | | `null` |
127
+ | `where` | object \\ | null | | `null` |
128
+ | `exclude_actor` | string \\ | null | | `null` |
129
+ | `limit` | integer | | `500` | |
130
+ | `wait_ms` | integer | | `0` | |
131
+
132
+ ## `list_webhooks`
133
+
134
+ **List Webhooks** · read-only
135
+
136
+ 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`. Secrets are not shown.
137
+
138
+ Examples: [Change data feed](https://datanotes.dev/guides/history/change-data-feed/).
139
+
140
+ ## `create_webhook`
141
+
142
+ **Create Webhook** · destructive write
143
+
144
+ 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. Events are those of `list_changes` (hand edits with their `violations`; the hand edits the service has seen are recorded before it stops). Starts from now unless `since`. Returns the webhook with its `secret` — shown only here: give it to the receiver. Only on the user’s explicit request: a webhook sends the database’s changes (and, with `since`, its past ones) to that address.
145
+
146
+ Examples: [Change data feed](https://datanotes.dev/guides/history/change-data-feed/).
147
+
148
+ | Parameter | Type | Required | Default | Description |
149
+ | --------------- | ------------- | ------------- | ------------- | ----------- |
150
+ | `url` | string | yes | | |
151
+ | `tables` | string\[] \\ | null | | `null` |
152
+ | `kinds` | `"insert"` \\ | `"update"` \\ | `"delete"` \\ | `"move"` \\ |
153
+ | `columns` | string\[] \\ | null | | `null` |
154
+ | `exclude_actor` | string \\ | null | | `null` |
155
+ | `where` | object \\ | null | | `null` |
156
+ | `since` | integer \\ | null | | `null` |
157
+
158
+ ## `delete_webhook`
159
+
160
+ **Delete Webhook** · destructive write
161
+
162
+ Stop and remove a webhook (by `id` from list_webhooks).
163
+
164
+ Examples: [Change data feed](https://datanotes.dev/guides/history/change-data-feed/).
165
+
166
+ | Parameter | Type | Required | Default | Description |
167
+ | --------- | ------ | -------- | ------- | ----------- |
168
+ | `id` | string | yes | | |