Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/23768-datasources-default-host-reserved.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@objectstack/skills': patch
---

docs(skills): the `objectstack-data` datasources rule states that `default` is host-reserved — the host connects it from `OS_DATABASE_URL`, and a stack that declares a datasource named `default` is refused (#23768)

Clause-②: no

`skills/objectstack-data/rules/datasources.md`'s opening paragraph read "Most apps need only the `default` datasource; declare more to read/write a separate or external database." "Declare more" implied that `default` is declared too, and a stack whose `datasources` collection carries an entry named `default` is refused at `defineStack`, `os validate`, publish and boot: the host declares and connects `default` itself. The sentence is replaced by the rule the spec and runtime hold: `default` is host-reserved, the host connects it from `OS_DATABASE_URL`, a stack that declares a datasource named `default` is refused, and a datasource is declared under its own name only to read/write a separate or external database. The added words are paid for inside the same file by deleting two restatements of the field reference: "`external` settings are required when `schemaMode !== 'managed'`" (the schema refuses the omission itself) and "Set `autoConnect: true` to force a live connection" (the auto-connect list two lines above already names it). No behaviour changes; nothing an author writes changes.
10 changes: 5 additions & 5 deletions skills/objectstack-data/rules/datasources.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

A **datasource** (`defineDatasource`, a `*.datasource.ts` metadata file) is a
connection to a data store. Objects route to one via their `datasource` field
(default: `'default'`). Most apps need only the `default` datasource; declare more
to read/write a **separate** or **external** database.
(default: `'default'`). `default` is host-reserved: the host connects it from
`OS_DATABASE_URL`, and a stack that declares a datasource named `default` is
refused. Declare a datasource under its own name only to read/write a
**separate** or **external** database.

Full field reference: `node_modules/@objectstack/spec/src/data/datasource.zod.ts`.

Expand All @@ -15,8 +17,6 @@ Full field reference: `node_modules/@objectstack/spec/src/data/datasource.zod.ts
| `external` | A mature external DB ObjectStack does **not** own; DDL forbidden; boot mismatch **fails**. |
| `validate-only` | Like `external`, but a mismatch **warns** instead of failing boot. |

`external` settings are **required** when `schemaMode !== 'managed'`.

## Federated (external) objects

An object on an external datasource binds to its remote table via `external`:
Expand Down Expand Up @@ -55,7 +55,7 @@ objects' read metadata registered **automatically at boot** — no `onEnable` /
4. a **`datasourceMapping` rule routes at least one object to it**.

A `managed` datasource that nothing routes to stays **metadata-only** — visible but
not connected. Set `autoConnect: true` to force a live connection.
not connected.

⚠️ A `datasourceMapping` rule is **routing, not a hint**. A rule pointing at a
datasource that cannot be connected fails the boot, and a query against a mapped
Expand Down
Loading