dreamteamer 0.32.0 → 0.33.1

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 (67) hide show
  1. package/README.md +4 -2
  2. package/collections/agents.collection.yaml +41 -32
  3. package/collections/collections.collection.yaml +68 -230
  4. package/collections/command-bindings.collection.yaml +37 -43
  5. package/collections/commands.collection.yaml +50 -35
  6. package/collections/mixins.collection.yaml +49 -0
  7. package/collections/modules.collection.yaml +76 -122
  8. package/collections/repos.collection.yaml +53 -56
  9. package/collections/skills.collection.yaml +32 -21
  10. package/collections/ui-views.collection.yaml +57 -46
  11. package/mixins/docs.mixin.yaml +21 -0
  12. package/mixins/entity.mixin.yaml +22 -0
  13. package/package.json +5 -3
  14. package/scripts/migrate-descriptors-v2.mjs +795 -0
  15. package/skills/using-dreamteamer/SKILL.md +27 -24
  16. package/skills/using-dreamteamer/references/agents.md +1 -1
  17. package/skills/using-dreamteamer/references/before-you-build.md +1 -5
  18. package/skills/using-dreamteamer/references/collections.md +450 -348
  19. package/skills/using-dreamteamer/references/commands.md +49 -35
  20. package/skills/using-dreamteamer/references/data-modeling.md +342 -319
  21. package/skills/using-dreamteamer/references/extensions.md +8 -5
  22. package/skills/using-dreamteamer/references/getting-started.md +6 -4
  23. package/skills/using-dreamteamer/references/records.md +43 -34
  24. package/skills/using-dreamteamer/references/skills.md +4 -3
  25. package/skills/using-dreamteamer/references/ui-components.md +30 -32
  26. package/skills/using-dreamteamer/references/ui-views.md +122 -124
  27. package/src/api.d.ts +22 -2
  28. package/src/api.js +16 -1
  29. package/src/check.js +55 -40
  30. package/src/checkout.js +14 -13
  31. package/src/cli.js +118 -71
  32. package/src/collections-cli.js +136 -144
  33. package/src/commit.js +9 -8
  34. package/src/compile-collections.js +346 -0
  35. package/src/compile.js +232 -1068
  36. package/src/descriptor-v2.js +165 -0
  37. package/src/descriptor.js +90 -0
  38. package/src/doctor.js +57 -0
  39. package/src/events.js +11 -10
  40. package/src/extensions.js +48 -10
  41. package/src/field-values.js +7 -6
  42. package/src/fields.js +254 -0
  43. package/src/filter.js +45 -1
  44. package/src/fractional-index.js +2 -2
  45. package/src/harnesses.js +80 -52
  46. package/src/history.js +3 -3
  47. package/src/init.js +74 -46
  48. package/src/namespace.js +23 -9
  49. package/src/placement.js +26 -16
  50. package/src/presentation.js +153 -299
  51. package/src/record-commands.js +12 -12
  52. package/src/records-api.d.ts +106 -7
  53. package/src/records-api.js +2 -1
  54. package/src/records.js +20 -14
  55. package/src/ref.js +3 -39
  56. package/src/relations.js +23 -24
  57. package/src/runtime.js +12 -35
  58. package/src/schema-ops.js +1181 -1275
  59. package/src/store.js +212 -82
  60. package/src/template.js +100 -24
  61. package/src/temporal.js +11 -3
  62. package/src/views.js +176 -0
  63. package/src/workspace.js +14 -0
  64. package/src/yaml.js +66 -5
  65. package/collection-templates/docs.collection-template.yaml +0 -17
  66. package/collection-templates/entity.collection-template.yaml +0 -20
  67. package/collections/collection-templates.collection.yaml +0 -20
@@ -5,366 +5,467 @@ One descriptor file: `modules/<module>/collections/<name>.collection.yaml`. The
5
5
 
6
6
  Two references divide this territory: the *judgment* — grain, relations, enums vs vocabularies,
7
7
  what deserves to be a collection at all — lives in `data-modeling.md`; the **mechanics** live
8
- here. You are here either authoring a descriptor or staring at a compile message, and the
9
- reference is organized for both:
8
+ here. The meta-descriptor `.dreamteamer/collections/collections.collection.yaml` states every key
9
+ in one line each; this reference says how they behave:
10
10
 
11
11
  | the question | read |
12
12
  |---|---|
13
- | what compile actually does to my source | the pipeline |
13
+ | what a descriptor holds — keys, types, ids, display | the descriptor · fields · ids and templates · display |
14
+ | what compile does to my source, and what a message means | the pipeline · the message catalog |
14
15
  | create or change shape with the CLI | the system and field verbs |
15
- | a brand-new module for a domain | declaring a module |
16
- | a prefix / a folder per domain | namespaces |
17
- | the same field set on several collections | `templates:` |
18
- | adding fields to another module's collection | `extends:` |
19
- | a reference into another module | the reference contract |
20
- | a data folder that already exists | registering an existing folder |
21
- | changing shape with records present | evolving a schema |
22
- | what a compile message means | the message catalog |
16
+ | a module, the `package.json` block, a namespace | declaring a module · the workspace manifest · namespaces |
17
+ | records inside their parent's folder | relationship-based storage |
18
+ | shared fields, another module's collection, a cross-module reference | mixins · overlays · the reference contract |
19
+ | a data folder that already exists, or shape changing under records | registering an existing folder · evolving a schema |
20
+
21
+ ## the descriptor
22
+
23
+ ```yaml
24
+ # modules/default/collections/people.collection.yaml
25
+ name: people
26
+ singular: person # the inflector leaves `people` as it is; `dt add person …` reads better
27
+ description: A person this workspace deals with — never the organisation, which is `companies`.
28
+ use_when: a person is named in a meeting, an email or a document — find or create them here first
29
+ storage:
30
+ suffix: person # <id>.person.md
31
+ fields:
32
+ name:
33
+ type: string
34
+ required: true
35
+ description: Full name, as they write it.
36
+ email:
37
+ type: email
38
+ unique: true
39
+ description: Where to write to them. Unique — two records with one address are one person.
40
+ notes:
41
+ type: markdown
42
+ body: true
43
+ description: Anything worth knowing, as prose.
44
+ ```
45
+
46
+ The top-level keys, closed (any other is a compile error naming the list):
47
+
48
+ | key | contract |
49
+ |---|---|
50
+ | `name` | the id; equals the filename; carries the namespace (`health/visits`) |
51
+ | `title` | the human label; default the title-cased bare name |
52
+ | `singular` | the word the CLI also accepts (`dt add person`); default the inflected bare name, namespace kept. Compile warns when the inflector cannot singularise the name, and refuses two collections answering to one word |
53
+ | `record_title` | how one record is labelled wherever it is referenced — a template; default the first of `title` · `name` · `subject`, else `{{ id }}`. Its first token must be a `string` or `markdown` field: it is what `dt add <collection> "<title>"` fills |
54
+ | `description` · `use_when` | what one record IS (naming the neighbour it is not) · the situations that bring a session here. Both feed the orientation block (`data-modeling.md` §18) |
55
+ | `internal` | workspace plumbing, left out of the domain listing — the engine's collections and the workspace module's only |
56
+ | `sensitive` | records never leave through an export; the same key on a field keeps one field back |
57
+ | `storage` | `path` (default `data/<name>`) · `format: md \| yaml \| json \| binary` (default `md`) · `shape: file \| folder` · `entry` (folder shape: the file that IS the record) · `suffix` (default the inflected bare name — an authored `singular` does not change it) · `under` (below) · `max_bytes` · `accept` (binary only) |
58
+ | `ids` | `from` and `pattern` — ids and templates, below |
59
+ | `mixins` · `overlay` | below |
60
+ | `fields` | the fields, in form order. **Required to be present** — it is what marks a descriptor; a `format: binary` collection writes `fields: {}` |
61
+ | `constraints` | a list of JSON Schema combinators for a rule across fields. Every property named must be a field, and an `if` must name `required` or it passes vacuously on a record lacking the field |
62
+ | `display` | nav · list · record · form, below |
63
+
64
+ ## fields
65
+
66
+ | `type` | stores | notes |
67
+ |---|---|---|
68
+ | `string` · `markdown` | text | `markdown` with `body: true` is the record's prose, one per collection, kept last |
69
+ | `boolean` · `integer` · `number` | as named | |
70
+ | `date` · `datetime` | `2026-10-02` · an instant with its offset | the CLI stamps the local offset on `"2026-10-02 12:00"` |
71
+ | `url` · `email` | text, format-checked | |
72
+ | `<collection>` | a reference, `<collection>/<id>` | the foreign key |
73
+ | `[a, b]` | a reference to one of several | the stored prefix disambiguates |
74
+ | `reference` | a reference to any collection | existence checked only; no mirror; warns outside the workspace module |
75
+ | `object` | a nested map, with `fields:` | with `many: true`, rows labelled by `item_title` |
76
+ | `map` | key → value, typed by `values:` | `values` omitted: an open map |
77
+ | `position` | the manual-order key `dt reorder` writes | one per collection, never `many` |
78
+
79
+ `many: true` makes a list of any type but `position`; constraints on a `many` field (`pattern`, `minimum`,
80
+ `maxLength`…) apply to each item. A collection may not be named after a type.
81
+
82
+ The field keys, closed — the order a field is best written in:
83
+
84
+ | key | contract |
85
+ |---|---|
86
+ | `type` · `title` | the type above · the label, default the title-cased name |
87
+ | `required` · `many` · `default` | as named; a default is filled in at `dt add` |
88
+ | `enum` | a list, or a map of value → `{ label, description, icon, color, background }`; on `type: string` only. Map order is band order. A value that is not kebab-case warns (`dt rename-value` renames one) |
89
+ | `unique` | no two records hold the same value, on any scalar field — enforced at write and by `check`, both claimants named; absent never claims |
90
+ | `mirror_of` | this field is the generated, read-only mirror of the named field on the `type` collection — the one relation spelling (`data-modeling.md` Part VI) |
91
+ | `on_delete` | `restrict` (the default on every reference) or `set-null`, refused on a required reference |
92
+ | `soft` | a reference whose target record — or collection — may not exist yet; `check` tolerates the miss, the stored value must still name an allowed collection |
93
+ | `sensitive` · `deprecated` | never exported · still validates, drawn nowhere, `dt add` warns on it |
94
+ | `body` | the prose field, `type: markdown` |
95
+ | `derived` · `virtual` | engine marks: stored but written only by the engine (`created`) · never stored (`id`, `last_modified`, a binary record's `ext` and `bytes`). A write naming either is refused |
96
+ | `passthrough` | the name keeps a harness's own spelling (`argument-hint`); without it a name that is not snake_case warns |
97
+ | `fields` · `values` · `item_title` | for `object`, `map`, rows of a `many` object |
98
+ | `examples` · `pattern` · `minimum` · `maximum` · `minItems` · `maxItems` · `minLength` · `maxLength` · `const` | passed to the validator; the first `examples` value is rendered into the orientation block's `write:` line |
99
+ | `display` | `editable` (`true` · `false` · `create`) · `hidden` (any of `list` · `form` · `record`) · `form_section` · `placeholder` · `unit` (`currency` · `percent` · `bytes` · a literal) · `unit_field` · `direction` · `width` · `viewer` · `editor` · `options` |
100
+ | `description` | what the value MEANS — the tooltip and the agent's guidance |
101
+
102
+ `display.editable: false` locks the surface and lets the CLI and syncs through; `mirror_of`,
103
+ `derived` and `virtual` refuse every writer. A required field with no default that is hidden from
104
+ the form or not editable is a compile error — nothing could create a record.
105
+
106
+ Every collection also carries three **injected** fields, never authored: `id` (virtual, the path),
107
+ `last_modified` (virtual, from git) and `created` — stamped into the frontmatter by `dt add`,
108
+ before the id is made, so `ids.from` may name it. A record written before the stamp existed reads
109
+ `created` from its id's date when `ids.from` names `created`, else from the commit that added the
110
+ file. A runtime kind (skills, agents…) has no `created`: compile writes those records.
111
+
112
+ ## ids and templates
113
+
114
+ ```yaml
115
+ ids:
116
+ from: '{{ date | date:YYYY/MM }}/{{ date | date }}--{{ patient | basename }}'
117
+ pattern: '^\d{4}/\d{2}/\d{4}-\d{2}-\d{2}--[a-z0-9-]+$'
118
+ ```
119
+
120
+ - **`from`** is a template, or an ordered list of them: the first whose fields are all present
121
+ wins, so `['{{ code }}', '{{ name | slug }}']` reads "the code, else the slugged name". Without
122
+ `ids`, ids come from `{{ name | slug }}` — a collection with no `name` field declares `from`.
123
+ - **A collision at `dt add` is refused by name**; `--id` is the escape, for an id the operator chose.
124
+ - **`pattern`** must admit everything `from` produces, `/` included when the id shards.
125
+ - **The grammar is one, everywhere** — `ids.from`, `record_title`, `item_title`,
126
+ `display.record.subtitle` and the layout options that take a template: `{{ field }}`,
127
+ `{{ field | filter }}`, `{{ field | filter:arg }}`. A field is a declared one or `id` ·
128
+ `created` · `last_modified`; `{{ seq }}` (a running number, `| pad:3`) exists only in an id.
129
+ Filters: `date[:fmt]` · `datetime` · `slug` · `pad:n` · `basename` — nothing else. An unknown
130
+ filter or field is a compile error naming the position.
131
+ - **A reference renders differently by position**: in an id, as the id it holds (`basename` takes
132
+ the last segment); in a display template, through the target's `record_title`.
133
+ - **`slug` of a name with no Latin letters** falls back to a short hash; the write succeeds and says
134
+ so. Give such a collection a Latin field to slug, or pass `--id`.
135
+
136
+ ## display — the collection's default view
137
+
138
+ ```yaml
139
+ display:
140
+ nav:
141
+ icon: pulse
142
+ order: 20
143
+ section: care # a free partition of the nav
144
+ list:
145
+ layout: table # the default; a surface's registered layout id
146
+ columns: [reason, patient, date, status]
147
+ sort: -date
148
+ options:
149
+ page_size: 50 # the layout's own keys
150
+ record:
151
+ layout: page # the default
152
+ subtitle: '{{ patient }} · {{ kind }}'
153
+ badge: status # drawn as a chip in the header
154
+ color_by: kind # a field whose enum map's colours tint rows and chips
155
+ form:
156
+ sections:
157
+ - title: Visit
158
+ fields: [reason, patient, date, status]
159
+ ```
160
+
161
+ This block IS what a bare collection route renders and what `dt list` prints as columns. A
162
+ ui-view carries the same block and changes only what it states (`ui-views.md`). Every field it
163
+ names must exist — columns, sort, badge, color_by, sections — or compile names the position.
164
+ Layout options that take a field are named for the role (`group_by`, `lanes_by`, `color_by`,
165
+ `start`, `end`, `lat`, `lng`); those taking a template end in what they label (`card_title`,
166
+ `bar_title`, `group_title`, `group_summary`). Both kinds are checked; any other option key rides
167
+ through to the surface unchecked.
23
168
 
24
169
  ## the pipeline — what compile does to a descriptor
25
170
 
26
- The compiled descriptor is not a copy of your source; it is the source **resolved**. Knowing the
27
- order explains most "why does the compiled file say that" questions:
28
-
29
- 1. **`templates:` merge in** — fields inserted *before* the `x-body` property, descriptor winning
30
- on any key it declares.
31
- 2. **`extends:` overlays merge onto the base** — properties per-property, `required` unioned,
32
- other keys extender-wins.
33
- 3. **Storage resolves** — `storage.path` defaults to `data/<name>` (namespace-nested);
34
- `storage.base` is derived (`runtime` iff the path IS one of the entity-kind folders — never
35
- author that); an `owns-data` module's path gets prefixed with the module root and its git repo
36
- recorded as `storage.repo`.
37
- 4. **`codec: file` collections get their derived schema** (`ext`, `bytes`) — an authored schema
38
- there is warned about and replaced; the bytes are the whole record.
39
- 5. **Validation, per collection** — still inside the merge loop, before any relation exists: the
40
- merged schema must itself compile as JSON Schema; `id.pattern` must be a valid regex;
41
- `sort_field` must name a real field; every `x-reference` target is checked against the module
42
- graph (below); at most one `x-body`.
43
- 6. **Relations materialize** — `x-inverse-of` folds onto the owner, mirrors are stamped
44
- (`readOnly`, `x-inverse-of`, `uniqueItems` on arrays), cardinality closes, and the
45
- relation-specific refusals fire here. The semantics are `data-modeling.md` Part VI; the point
46
- here is that this runs across ALL descriptors at once, because a relation spans two files.
47
- 7. **Labels derive** — after relations, so generated mirrors get titles too: `title` (title-cased
48
- bare name, namespace stripped), `title_template` (the `title`/`name`/`subject` probe, else
49
- `{{ id }}` — which is a smell, see `data-modeling.md` Part VII §31), and a `title` per field.
50
- Authored values always win; derivation never overwrites.
51
- 8. **Bytes dump** to `.dreamteamer/collections/<name>.collection.yaml`, with per-source hashes in
52
- the manifest — which is what lets `dt status` say precisely which source went stale.
53
-
54
- Consequence: **read the compiled file to know what IS; edit the source to change it.** They
55
- differ by design, and diffing them is often the fastest way to see what compile decided for you.
171
+ The compiled file is the authored keys, resolved, plus one `compiled:` block holding everything
172
+ compile decided. The order explains most "why does the compiled file say that" questions:
173
+
174
+ 1. **Mixins merge in**, in list order — fields before the body field; `storage`, `ids` and
175
+ `display` key by key where the descriptor is silent; `constraints` concatenate.
176
+ 2. **Overlays merge onto the base** — new fields before the body, a field the base has merged key
177
+ by key, every other key overlay-wins (`display` per sub-block).
178
+ 3. **Names are checked** — every field `display`, `ids.from`, `storage.under.parent` and every
179
+ template names; unknown keys in the closed blocks.
180
+ 4. **Storage and fields resolve** — the storage defaults (an `owns_data` module's path prefixed
181
+ with its root); a `format: binary` collection gets `ext` and `bytes` and may declare nothing
182
+ else; titles, `on_delete`, the injected fields; then the validator's JSON Schema, which must
183
+ itself compile, and `ids.pattern`, which must be a valid regex.
184
+ 5. **The reference contract**, then **relations** — every `mirror_of` checked against its owner
185
+ across ALL descriptors at once, because a relation spans two files — then placement.
186
+ 6. **Bytes dump** to `.dreamteamer/collections/<name>.collection.yaml`. `compiled` holds `defaults`
187
+ (every value compile supplied), `module`, `repo`, `runtime`, `under_collection`, `mirrors`,
188
+ `overlaid_by`, `unresolved_peers`, `fields` (resolved) and `json_schema`.
189
+
190
+ **Read the compiled file to know what IS; edit the source to change it.** `compiled.defaults` is
191
+ the diff between what you wrote and what holds.
56
192
 
57
193
  ## the system and field verbs — writes through a compile gate
58
194
 
59
- The one sanctioned way to write schema without hand-editing. Every verb round-trips through a
60
- **compile gate**, so a change that would not compile is rejected before it lands — and unlike a
61
- record write, a schema verb **commits its source write itself**, because an uncompilable or
62
- unpublished schema is not a state the workspace should sit in. The verbs and every flag live in
63
- `dt help` under "system verbs" and "field verbs" — read that, not prose. What help cannot tell you:
64
-
65
- - **The field verbs write the WORKSPACE module.** On a collection another module owns, `add-field`
66
- and `set-field` author an `extends:` overlay in the workspace module — which compiles only
67
- if the workspace module declares the owning module in `dreamteamer.dependencies` (the extends
68
- gate exempts nobody). `rm-field` has no overlay form at all — an overlay cannot remove an
69
- inherited field, so it refuses a module-shipped field by name. So on a module-owned collection:
70
- declare the dependency and let `add-field`/`set-field` write the overlay (the change stays
71
- workspace-local), or **edit the owning module's descriptor by hand** and compile (the change
72
- ships with the module) — the only exit for a removal. Pick by who should own the field —
73
- `data-modeling.md` Part III.
74
- - **`--type <collection>` beats the type sugar, always.** A type that names a collection in the
75
- runtime is a reference to it, whatever `string`/`enum`/`date`/`tags`/… would otherwise mean — so
76
- in a workspace that ships a `tags` collection, `--type tags` points at it and the relation flags
77
- work on it. Only a stated `--type` resolves this way; omitting it still means a plain string.
78
- - `rm-field` on a populated field **clears the values in the same write and reports the
79
- count** — a leftover key would make every later write to those records fail as unknown. It also
80
- prunes the field out of **the same descriptor's `list_fields` and `sort_field`** (that is the
81
- field's own presentation, and a dangling `sort_field` is a compile error), and **warns, by id,**
82
- about any ui-view whose `options.columns` still names it — a different source, so it is named
83
- rather than edited.
84
- - **`add-field` inserts before the `x-body` field**, on the same rule as a `templates:` merge
85
- below: property order is form order, and a record's body belongs last. `set-field` never
86
- reorders — an existing field keeps the place its author gave it.
87
- - **`dt rename collections/<old> <new>`** moves the descriptor **in the module that ships it**
88
- (its guard is against writes an `npm install` would erase, not against modules), plus the
89
- records, the filenames and every inbound reference — `x-reference` targets in other descriptors
90
- and ui-views included — in ONE commit. It refuses: a runtime source, an **overlaid** collection
91
- (the overlay's `extends` names the old id), a collection shipped from `node_modules/`, a taken
92
- name, and an undeclared target namespace; a refusal leaves nothing half-moved. It deliberately
93
- does NOT overrule two authored choices: a hand-set `storage.path` (records stay put, and it
94
- says so) and a `storage.suffix` that is not the singular of the old name.
95
- - An **empty value removes** in dotted `set-view` writes just as it does in `dt set` — so a
96
- setting whose meaningful value IS empty (`options.sort: ''`, see `ui-views.md`) is written
97
- QUOTED, which is what says "the empty string is the value": `'options.sort=""'`.
195
+ The sanctioned way to write schema without hand-editing. Every verb round-trips through a
196
+ **compile gate**, so a change that would not compile is rolled back — and unlike a record write, a
197
+ schema verb **commits its source write itself**. The verbs and flags are `dt help` under "system
198
+ verbs" and "field verbs". What help cannot tell you:
199
+
200
+ - **The field verbs write the OWNING module's descriptor** — the source that declares the
201
+ collection, wherever it sits. `--module <m>` names another module, and the field then lands in an
202
+ `overlay: true` descriptor there, which compiles only when `m` depends on the owner or names the
203
+ collection in `peer_collections`; the refusal prints the `dt set modules/<m> dependencies=…` that
204
+ fixes it. A module installed from `node_modules/` is read-only — overlay it.
205
+ - **`--type <collection>` is a reference**; `--many`, `--enum a,b`, `--mirror-of <field>` (the
206
+ mirror of the `--type` collection's `<field>`) and `--soft` spell the keys above. `add-field`
207
+ inserts before the body field; `set-field` never reorders.
208
+ - **`rm-field` clears the values in the same write and reports the count**, prunes the field from
209
+ its own columns, sort, badge and sections, and **refuses while another position names it** — a
210
+ view, a binding, a template — listing each one.
211
+ - **`rename-field`** rewrites the key in every record and every position that names it — templates,
212
+ `ids.from`, `display`, constraints, `storage.under.parent`, a mirror's `mirror_of`, views and
213
+ bindings — in ONE commit. **`rename-value`** does the same for one enum value.
214
+ - **`dt rename collections/<old> <new>`** moves the descriptor and its overlays, plus the
215
+ records, the filenames and every inbound reference, in ONE commit. It refuses a runtime source,
216
+ a placed collection (`relocate --to-root` first), an overlay that sets `storage`, one shipped
217
+ from `node_modules/`, a taken name and an undeclared target namespace. It keeps a hand-set
218
+ `storage.path` (records stay put, and it says so) and an authored `storage.suffix`.
219
+ - **`dt fmt [<collection>]`** rewrites inline descriptor sources to block style and the canonical
220
+ top-level key order, keeps every comment and the order of `fields`, and commits through the same
221
+ gate; `--dry-run` names the files it would change. A second run changes nothing.
222
+ - **`dt set collections/<c>`** writes `display.list.layout`, `display.record.*` and one layout option
223
+ at a time (`display.list.options.page_size=25`, the value read as JSON where it parses).
224
+ - **An empty value removes** in dotted writes (`dt set ui-views/<id> display.list.sort=`); a
225
+ setting whose meaningful value IS empty is written QUOTED: `'display.list.sort=""'`. A value
226
+ holding `{{ }}` is quoted the same way.
98
227
 
99
228
  ## declaring a module
100
229
 
101
- A module is a folder under `modules/<name>/` whose `package.json` carries **a `dreamteamer` key —
102
- `"dreamteamer": {}` is enough** — plus the kind folders it ships (`collections/`, `skills/`, …).
103
- Without that key the folder is **silently ignored** by discovery; with an unknown kind folder
104
- inside, compile errors. The module's `name` in package.json is its identity in `owner`,
105
- `extends:` and dependency declarations. What belongs in a module vs the workspace module is
106
- judgment — `data-modeling.md` Part III §8.
230
+ A module is a folder under `modules/<id>/` whose `package.json` carries **a `dreamteamer` key —
231
+ `"dreamteamer": {}` is enough** — plus the kind folders it ships (`collections/`, `skills/`,
232
+ `agents/`, `commands/`, `command-bindings/`, `ui-views/`, `mixins/`). Without the key the folder is
233
+ **silently ignored**; an unknown folder inside is a compile error unless `dreamteamer.ignore`
234
+ lists it. What belongs in a module is judgment — `data-modeling.md` Part III §8. A module's
235
+ `dreamteamer` block reads, for example, `{ "description": "…", "namespaces": ["billing"],
236
+ "dependencies": ["clinic"] }`.
237
+
238
+ | module key | what it holds |
239
+ |---|---|
240
+ | `title` · `description` | what to call the module · what the AREA is for — it heads the module's group in the orientation block |
241
+ | `namespaces` | the namespaces this module owns |
242
+ | `dependencies` | modules this one cannot compile without — an overlay needs its base. Acyclic |
243
+ | `peer_collections` | collections this module references but does not own, which may be absent |
244
+ | `owns_data` | its records live in its own clone, not the workspace's `data/` |
245
+ | `engine` | the engine range it needs; outside it, the module is refused whole |
246
+ | `env` · `vars` | the `.env` keys it needs · the `${env:…}` names its records use (the workspace must allow each) |
247
+ | `extension` · `ignore` · `local_assets` | an extension entry (`extensions.md`) · folders that are not kinds · gitignored files a worktree links |
107
248
 
108
249
  ## the workspace manifest — the `dreamteamer` block in `package.json`
109
250
 
110
- The workspace-level switches the engine reads live in one place. The keys, and where each is
111
- explained:
251
+ Keys are snake_case and closed: compile refuses an unknown one, naming the list. `dt init` writes
252
+ `workspace_module`, `data_path`, `harnesses`, `git_modules`, `disable` and `gitignore_runtime_folder`.
112
253
 
113
- | key | what it holds | detail |
114
- |---|---|---|
115
- | `workspace-module` | which module under `modules/` is the workspace's own | SKILL.md, the contract |
116
- | `data-path` | where records live, workspace-relative (default `data`) | — |
117
- | `namespaces` | the declared namespace prefixes | namespaces, below |
118
- | `vars` | the `.env` keys records may reference as `${env:KEY}` | records.md, templates |
119
- | `auto-commit` | whether a record write also commits (default off) | records.md, committing |
120
- | `harnesses` | which coding-agent adapters compile writes (`claude-code`, `codex`, …) | — |
121
- | `git-modules` | the lockfile map `dt install` restores | — |
122
- | `disable` | identity entities to drop from the compile, as `<module>/<entity>` | — |
123
-
124
- A MODULE's own `package.json` carries the `dreamteamer` key that makes it discoverable (declaring
125
- a module, above) plus `dreamteamer.dependencies` / `peerDependencies` when it reaches across the
126
- module graph (the reference contract, below).
254
+ | key | what it holds |
255
+ |---|---|
256
+ | `workspace_module` | which module under `modules/` is the workspace's own |
257
+ | `data_path` | where records live, workspace-relative |
258
+ | `namespaces` | namespaces declared at the workspace level (a module's own declaration is the one that travels) |
259
+ | `vars` | the `.env` keys records may reference as `${env:KEY}` (`records.md`) |
260
+ | `auto_commit` | whether a record write also commits (default off) |
261
+ | `harnesses` | which coding-agent adapters compile writes |
262
+ | `git_modules` | the lockfile map `dt install` restores into `git_modules/` |
263
+ | `disable` | what to drop from the compile: `modules/<id>` (a whole module, its code included) or `<kind>/<id>` (one entity) |
264
+ | `local_assets` · `postinstall` · `repos_path` · `gitignore_runtime_folder` | links a worktree gets · a script `dt install` runs · where `repos` records materialise · whether `.dreamteamer/` is gitignored |
265
+
266
+ The workspace's own instructions live in **`DREAMTEAMER.md`** at the root. Compile writes
267
+ `CLAUDE.md`, `AGENTS.md` and `GEMINI.md`: the generated orientation block first, then that file's
268
+ text, each in its own managed block. They are gitignored, so text written into them reaches no
269
+ other clone — edit `DREAMTEAMER.md`.
127
270
 
128
271
  ## namespaces — scoping a collection under a folder
129
272
 
130
- A collection name may carry a slash-delimited namespace, and it becomes real directory nesting:
131
-
132
273
  | declare in the OWNING MODULE's `package.json` | create it | lands in | referenced as |
133
274
  |---|---|---|---|
134
275
  | `"dreamteamer": {"namespaces": ["health"]}` | `dt add collections --name doctors --module clinic` | `data/health/doctors/` | `health/doctors/dana-levi` |
135
276
 
136
- A module declaring exactly ONE namespace **infers** it, and the resolved name is always echoed
137
- (`✔ health/doctors (namespace inferred from module clinic)`). Two or more declared and it refuses
138
- to guess: `--namespace health`. `--namespace ''` means no namespace. `--namespace x` where nobody
139
- declares `x` writes the declaration into the target module — which is what travels when the module
140
- is copied.
141
-
142
- - **The default namespace is the empty prefix.** `tasks` stays `data/tasks/` and `tasks/kickoff`,
143
- so common entities need no prefix and adopting namespaces migrates nothing. `default` is
144
- RESERVED — there is never a second spelling for one collection.
145
- - ⚠ **The namespace MUST be declared before the collection compiles.** An id is also a slash path
146
- (`meetings/2026/07/kickoff`), so `a/b/c` is ambiguous without the declared set; an undeclared
147
- prefix is a compile error rather than a reference that silently names a different collection.
148
- - **A MODULE declares the namespaces it owns** — `"dreamteamer": { "namespaces": ["hr"] }` in its
149
- own `package.json`, and the workspace's effective set is the **union** with its own
150
- `dreamteamer.namespaces`. This reversed in 0.19.0. The old rule ("the workspace only, never a
151
- module") had a real reason — a module that can declare a namespace can rename where another
152
- module's records live — but it made decision 130's own acceptance test, *"a module compiles alone
153
- in a bare workspace"*, unpassable for any namespaced module: the consuming workspace had to edit
154
- its manifest first, which is exactly the coupling that rule forbids.
155
- - **One owner per namespace.** Two modules declaring it is a compile error naming both.
156
- - **Using another module's namespace requires the dependency** — shipping `hr/<c>` while only
157
- `hr` declares `hr` means listing `hr` in your `dreamteamer.dependencies`. Without this rule the
158
- union would let you squat in another module's namespace silently.
159
- - **A workspace-level declaration a module also declares is a WARNING**, not an error, and
160
- `dt set modules/<m> namespaces=<ns>` removes the redundant workspace entry in the same write.
161
- - **The set is a function of the INSTALLED MODULE SET.** Removing or disabling a namespace-owning
162
- module re-splits every reference into it; `check` reports the dangle, and the compile error says
163
- the namespace was declared by a module you just removed. `default` stays reserved.
164
- - `--namespace health --name doctors` and `--name health/doctors` are the same thing. The
165
- descriptor lands at `collections/health/doctors.collection.yaml` — `collections/` is enumerated
166
- recursively, so the source tree mirrors the runtime — and the `suffix` comes off the bare name
167
- (`<id>.doctor.md`).
168
- - `x-reference: health/doctors`, `disable: "<module>/health/doctors"` and every record verb take
169
- the QUALIFIED name — it is the collection's identity everywhere. Only its *label* drops the
170
- prefix: the derived `title` comes from the bare name, because every surface already draws the
171
- namespace as a folder around it.
172
- - Nested namespaces work (`work/clients`); the longest declared prefix wins.
173
- - ⚠ **No collection may store records inside another's folder** — a namespace folder cannot
174
- itself be a collection root. Compile refuses it, because the outer collection would index the
175
- inner one's records as its own. The one DECLARED exception is the next section: a collection
176
- stored under the records of a folder-shape parent, where compile knows exactly which files
177
- belong to whom.
277
+ A module declaring exactly ONE namespace **infers** it, and the resolved name is echoed. Two or more
278
+ and it refuses to guess: `--namespace health`. `--namespace ''` means none.
279
+
280
+ - **The default namespace is the empty prefix** — `tasks` stays `data/tasks/` and `tasks/kickoff`.
281
+ `default` is RESERVED, so there is never a second spelling for one collection.
282
+ - ⚠ **A namespace must be declared before its collection compiles.** An id is also a slash path, so
283
+ `a/b/c` is ambiguous without the declared set; an undeclared prefix is a compile error.
284
+ - **One owner per namespace** — two modules declaring it is a compile error naming both — and
285
+ **using another module's namespace requires that module in `dependencies`**. The workspace's set
286
+ is the union of every module's plus its own, so it follows the INSTALLED modules: removing a
287
+ namespace-owning module re-splits every reference into it, and compile names the namespace.
288
+ - The descriptor lands at `collections/health/doctors.collection.yaml`; `type: health/doctors`,
289
+ `disable: [collections/health/doctors]` and every record verb take the QUALIFIED name. Only the
290
+ derived `title` drops the prefix. Nested namespaces work; the longest declared prefix wins.
291
+ - ⚠ **No collection may store records inside another's folder.** The one declared exception is
292
+ the next section, where compile knows which files belong to whom.
178
293
 
179
294
  ## relationship-based storage — records beside the record they belong to
180
295
 
181
- A collection can keep each record INSIDE the folder of the record it belongs to, so a company's
182
- folder holds the company's meetings and a browse of `data/companies/northwind/` shows the whole
183
- account. It is declared on the CHILD's `storage`, in one line, and changes nothing about what the
184
- collection IS:
296
+ A collection can keep each record INSIDE the folder of its parent record, so a browse of
297
+ `data/companies/northwind/` shows the whole account. It is declared on the CHILD:
298
+
299
+ ```yaml
300
+ # the parent, companies.collection.yaml — one folder per record
301
+ storage:
302
+ shape: folder
303
+ entry: company.md
304
+ ```
185
305
 
186
306
  ```yaml
187
307
  # modules/default/collections/meetings.collection.yaml
188
- storage: { path: data/meetings, suffix: meeting, under: { field: company, path: meetings } }
308
+ name: meetings
309
+ description: One calendar meeting — the event, never the company or the people in it.
310
+ use_when: anything with a date and attendees
311
+ storage:
312
+ under:
313
+ parent: company
314
+ subfolder: meetings
315
+ ids:
316
+ from: '{{ date | date:YYYY/MM }}/{{ name | slug }}'
317
+ pattern: '^\d{4}/\d{2}/[a-z0-9-]+$'
318
+ fields:
319
+ name:
320
+ type: string
321
+ required: true
322
+ description: The calendar title.
323
+ date:
324
+ type: date
325
+ required: true
326
+ description: The day it happens.
327
+ company:
328
+ type: companies
329
+ description: The account it belongs to — also which folder holds the file. Empty keeps it in data/meetings/.
189
330
  ```
190
331
 
191
332
  ```text
192
- data/companies/northwind/company.md ← the parent: shape: folder, entry: company.md
333
+ data/companies/northwind/company.md ← the parent: shape folder, entry company.md
193
334
  data/companies/northwind/meetings/2026/10/kickoff.meeting.md ← meetings/2026/10/kickoff, company: companies/northwind
194
335
  data/meetings/2026/10/offsite.meeting.md ← meetings/2026/10/offsite, no company: the FALLBACK root
195
336
  ```
196
337
 
197
- - **Still one logical collection.** `dt list meetings` is the union across every company folder
198
- and the fallback root, ordered by id; `dt get meetings/2026/10/kickoff` finds the file wherever it
199
- sits; a reference is `meetings/<id>` everywhere. Nothing is spelled per company — no descriptor,
200
- no skill, no view.
201
- - **The id is independent of placement.** `dt set meetings/<id> company=companies/harbor` MOVES
202
- the file into Harbor's folder and changes nothing else: not the id, not one inbound reference.
203
- Clearing the field moves it back to the fallback root. An id is unique across every root, and a
204
- second file claiming one is a `check` violation and a write refusal, never last-one-wins.
205
- - **`field`** is a scalar `x-reference` to exactly ONE collection (a list has no single folder; a
206
- union has no single parent). **`path`** is a relative folder inside each parent record's folder.
207
- compile derives `under.collection` from the field; nothing else is authored.
208
- - **The parent must be `shape: folder`** (`storage: { shape: folder, entry: company.md }`) — only
209
- a folder can hold anything beside the record. A file-shape collection that should become a
210
- parent changes its descriptor to folder shape, and `dt relocate <collection>` then moves each
211
- `<id>.<suffix>.md` into `<id>/<entry>` with its id unchanged (`check` names them until it runs).
212
- - **One level.** A placed collection cannot itself be a parent; the child is a text record
213
- (`md` · `yaml` · `json`, file shape) — an opaque or folder-shape child is refused for now. Two
214
- children of one parent need two different paths, and a path never equals the parent's entry.
215
- - **The field is the owner; the folder is observed placement.** A file found under the wrong
216
- company — moved by hand, or sitting in the fallback root from before the declaration existed — is
338
+ - **Still one collection.** `dt list meetings` is the union of every company folder and the
339
+ fallback root; `dt get meetings/2026/10/kickoff` finds the file wherever it sits; a reference is
340
+ `meetings/<id>` everywhere.
341
+ - **The id is independent of placement** (`under.id: independent`, the default).
342
+ `dt set meetings/<id> company=companies/harbor` MOVES the file and changes nothing else; clearing
343
+ the field moves it back. An id is unique across every root.
344
+ - **`under.id: nested`** makes the id BEGIN with the parent's id, for a collection whose identity
345
+ already leads with it — lab values per patient. Every `ids.from` must open with
346
+ `{{ <parent> | basename }}/`; the file drops that segment because the folder carries it
347
+ (`health/lab-values/dana-levi/2026-07-02--ldl` lives at
348
+ `data/health/patients/dana-levi/labs/2026-07-02--ldl.lab-value.yaml`). A change of parent is a
349
+ `dt rename`, never a `dt set`.
350
+ - **`parent`** is a scalar reference to exactly ONE collection, which must be `shape: folder`.
351
+ **`subfolder`** is a relative folder inside each parent record's folder, never its `entry`.
352
+ - **One level.** A placed collection cannot itself be a parent, and the child is a text record in
353
+ file shape. Two children of one parent need two subfolders.
354
+ - **The field is the owner; the folder is observed placement.** A file under the wrong parent is
217
355
  `placed under … but <field> is …` in `check`, which changes nothing. `dt relocate <collection>`
218
- (or `<collection>/<id>`, `--dry-run` first) moves files to where the compiled descriptor puts
219
- them and refuses a source with unpublished changes or an occupied destination. Editing some OTHER
220
- field never relocates as a side effect; nothing ever infers an owner from where a file was found.
221
- - **A parent with records inside its folder cannot be removed** — not with `--force` either;
222
- reassign or clear their owner first. Renaming the parent carries the folder with everything in
223
- it and rewrites the children's owner field; their ids do not change.
224
- - **Adopting it on existing data is three explicit steps**, each reviewable: make the parent folder
225
- shape and `relocate` it; add `under` to the child and compile (no file moves at compile — `check`
226
- reports every mismatch); `relocate` the child, `--dry-run` first. `dt commit` stages a moved
227
- record's old and new path together; `dt revert` of an owner change moves the file back.
228
- - **Removing or changing `under` is the same walk backwards, and compile holds the door.** While
229
- records still sit inside parent folders, a compile that drops the declaration, changes its
230
- `path`, or moves the PARENT collection's `storage.path` is REFUSED — the new descriptor would stop
231
- every reader seeing them. The order is
232
- `dt relocate <collection> --to-root` (every placed record back into the collection's own folder,
233
- ids unchanged, under the still-current declaration) → edit the descriptor → compile → `dt relocate
234
- <collection>` to place them under the new path. The same order renames a placed collection.
235
- - **`relocate` refuses before it moves anything**: a dangling or malformed owner field (fix the
236
- field first — it never makes a folder for a parent that does not exist), an occupied destination,
237
- a source with unpublished changes, or a destination behind a symlink. One problem refuses the
238
- whole plan; `--dry-run` reports it.
239
- - **Inside a parent's folder, only real entries count.** A symlink at a child root, on the way to
240
- one, or anywhere beneath one — a folder or a file — is never written through and never read as a
241
- record; `check` names it. The collection's own roots (`data/`, `storage.path`) are not subject to
242
- this; the rule is about what a record folder may contain.
243
- - **When NOT to use it.** A record several parents share equally, a record whose owner is usually
244
- unknown, or a collection nobody browses as a folder — keep conventional storage and a plain
245
- reference. Folder grouping is a browsing convenience, never a permission boundary.
246
-
247
- ## `templates:` — a live shared field set
356
+ (or `<collection>/<id>`, `--dry-run` first) moves files to where the field puts them, and
357
+ refuses whole on a dangling owner, an occupied destination, an unpublished source or a symlink.
358
+ - **A parent with records inside its folder cannot be removed** — not with `--force` either.
359
+ Renaming it carries the folder and rewrites the children's owner field.
360
+ - **Adopting it on existing data**: make the parent folder shape and `relocate` it; add `under`
361
+ to the child and compile (nothing moves at compile — `check` reports each mismatch); `relocate`
362
+ the child. **Removing or changing it** is the walk backwards — `dt relocate <collection>
363
+ --to-root`, edit, compile, `dt relocate <collection>` — and compile refuses the edit while records
364
+ would be stranded inside parent folders.
365
+ - **When NOT to use it**: a record several parents share equally, an owner usually unknown, a
366
+ collection nobody browses as a folder. It organises files; it grants nothing.
367
+
368
+ ## mixins — a live shared field set
248
369
 
249
370
  ```yaml
250
- name: meetings
251
- templates: [collection-templates/provenance] # merged at compile, every time
371
+ # modules/clinic/mixins/clinic-provenance.mixin.yaml
372
+ name: clinic-provenance
373
+ description: Who made the record, from what, and how much to trust it.
374
+ use_when: every clinic collection an agent may write — list it rather than restating the three fields
375
+ fields:
376
+ author:
377
+ type: string
378
+ description: Which agent made this record. Absent when a person wrote it.
379
+ source:
380
+ type: string
381
+ description: Where the information came from.
382
+ confidence:
383
+ type: string
384
+ default: normal
385
+ enum: [low, normal, high]
386
+ description: How much to trust this record. When low, say why in `source`.
252
387
  ```
253
388
 
254
- - **`templates:` is not `extends:`.** `extends: <module>/<collection>` means "this descriptor
255
- *overlays* another module's collection of the same name". `templates:` pulls in a field set and
256
- says nothing about module layering. A descriptor may use both.
257
- - **Precedence is template < base < overlay** — a descriptor always wins on a key it declares, so
258
- a collection can tighten a templated field (add an enum, change a default) without touching the
259
- template.
260
- - **The template is a declared SOURCE of every consumer**, so editing it marks them stale and
261
- `dt status` names them. Without that, the edit would apply to nothing and warn about nothing.
262
- - **Template properties insert before the `x-body` field** — property order is form order, and a
263
- record's body belongs last. Template `required` entries union in; other template keys apply
264
- only where the descriptor is silent.
265
- - ⚠ **A `templates:` ref must resolve inside the module that ships the descriptor**, or that
266
- module cannot be installed or copied on its own. This is the single most expensive mistake in
267
- the project's history: an extracted module whose every descriptor referenced a template living
268
- in the *consuming* workspace could not compile into a bare workspace at all, and nobody noticed
269
- for months. A collection-template id is an *identity* entity, so two modules cannot both ship
270
- `provenance` — scope the id per module (`crm-provenance`).
271
- - `--template X` at creation copies the fields in once. `templates:` is the live version; prefer
272
- it for anything you will want to change in one place later.
273
-
274
- ## `extends:` — overlaying another module's collection
389
+ A collection lists it: `mixins: [clinic-provenance]`. A mixin is a partial descriptor — `fields`,
390
+ and `storage`, `ids`, `display`, `constraints` where it says so — merged at every compile (the
391
+ pipeline, step 1), and a declared SOURCE of each consumer, so editing it marks them stale.
275
392
 
276
- ```yaml
277
- name: tasks
278
- extends: '@dreamteamer/dreamteamer/tasks'
279
- schema:
280
- properties:
281
- urgent: { type: boolean, default: false }
282
- ```
283
-
284
- Compile merges `schema.properties` per-property, unions `required`, and takes `storage`/`id` from
285
- the base unless the overlay explicitly declares them. Two modules extending the same base are
286
- applied in module-discovery order and the last wins on any shared key — so keep extenders
287
- **disjoint** and never rely on the collision. Two same-name descriptors where neither declares
288
- `extends` is a compile error; so is an `extends` value that does not name the actual base.
393
+ - **A descriptor cannot redeclare a mixin's field** — one source per field, a compile error naming
394
+ both. Tighten by writing the field in the descriptor and not listing the mixin, or by a second,
395
+ narrower mixin.
396
+ - ⚠ **A mixin id is global, so list only mixins your own module ships** (or the engine's): a
397
+ collection listing another module's mixin cannot be copied or installed without it, and compile
398
+ will not tell you. Scope the id per module (`clinic-provenance`, not `provenance`). The engine ships two every workspace has: `docs` (title · tags · content, a dated
399
+ id) and `entity` (name · tags · notes, a slug id). `dt add collections --mixins docs` lists one.
289
400
 
290
- Two gates around it:
401
+ ## overlays — adding fields to another module's collection
291
402
 
292
- - **An overlay must declare the base's module in `dreamteamer.dependencies`** — `extends` is the
293
- hardest dependency there is (the overlay does not compile at all without its base), so compile
294
- refuses the undeclared case. The workspace module gets **no exemption here** (unlike the
295
- mirror-stamp and wildcard gates, which do exempt it) — this is exactly the refusal you meet
296
- when a field verb targets a module-owned collection (the field verbs, above).
297
- - ⚠ **An overlay can add fields but cannot remove an inherited one.** If the shape is wrong for
298
- the module rather than just for this workspace, fix the base.
403
+ ```yaml
404
+ # modules/billing/collections/health/visits.collection.yaml
405
+ name: health/visits
406
+ overlay: true
407
+ fields:
408
+ claim:
409
+ type: billing/claims
410
+ mirror_of: visit
411
+ description: The claim this visit was billed under. Set `visit` on the claim.
412
+ ```
299
413
 
300
- ## `x-choices` — what an enum VALUE looks like
414
+ The base is the one source of `health/visits` without `overlay: true`; two bases are a name
415
+ collision. An overlay **compiles only when its module depends on the base's module, or names the
416
+ collection in `peer_collections`** — then it applies while the collection is installed and is
417
+ inert while it is not. The workspace module gets no exemption. Overlays from two modules apply in
418
+ discovery order; keep them **disjoint**. ⚠ **An overlay can add or tighten fields, never remove
419
+ one** — fix the base when the shape is wrong for the module rather than for this workspace.
301
420
 
302
- An enum value carries a label and nothing else by default: a surface gets `{ text, value }` and
303
- draws the value. `x-choices` is an OPTIONAL sparse map, keyed by the value, that gives a surface
304
- more to draw with — a board grouping by the field, a dropdown in a form, anything reading
305
- `edit_options.choices`.
421
+ ## enum maps — what a VALUE looks like
306
422
 
307
423
  ```yaml
308
- lane:
424
+ kind:
309
425
  type: string
310
- enum: [alpha, bravo, charlie]
311
- x-choices:
312
- alpha:
313
- label: Alpha team # what a surface shows; the stored VALUE is still `alpha`
314
- description: the one that ships
315
- icon: rocket # a codicon name …
316
- color: charts.blue # a theme colour id — the accent
317
- background: charts.blue # … and the fill
318
- bravo:
319
- icon: assets/icons/lucide/anchor # … OR a reference to a `codec: file` record
426
+ default: follow-up
427
+ enum:
428
+ intake:
429
+ label: Intake # what a surface shows; the stored value is still `intake`
430
+ icon: person-add
431
+ color: charts.blue # a theme colour id, never a hex
432
+ follow-up:
433
+ label: Follow-up
434
+ urgent: {}
320
435
  ```
321
436
 
322
- - **Sparse and additive.** Decorate one value, or none. A value with no entry projects exactly as it
323
- did before this keyword existed, so adding it changes nothing that already works.
324
- - **`enum` still owns the value set AND its order.** A map key cannot add, remove or reorder a
325
- value — which matters, because a grouped view takes its band order from the enum.
326
- - **Five keys, and only five** — `label` · `description` · `icon` · `color` · `background`, each an
327
- optional string. Anything else in an entry is dropped: the projection copies by name, so a
328
- descriptor cannot inject keys into a contract every surface reads.
329
- - **`label` becomes `text`.** So a workspace can relabel a value without touching the value, and no
330
- stored record moves.
331
- - **`icon` is a codicon name or a reference to a record of a `codec: file` collection.** A codicon
332
- name never contains a slash and a record reference always does, so the surface decides which
333
- without a second keyword.
334
- - **Colours are theme colour ids, not hex.** A hex is authored against one theme and wrong in the
335
- other.
336
- - **Both mistakes warn rather than fail** — a key that is not one of the enum's values, and the
337
- keyword on a field with no enum. See the message catalog below.
338
-
339
- ## the reference contract — `x-reference` across the module graph
340
-
341
- Every `x-reference` target must be one of: a **core** collection (the entity kinds plus `repos`)
342
- · a collection **owned by this module** (or a module contributing to this descriptor) · owned by
343
- a module named in **`dreamteamer.dependencies`** · or named in **`dreamteamer.peerDependencies`**
344
- as a collection. Anything else fails compile, with the fix in the message.
345
-
346
- The two declaration kinds are different on purpose. `dependencies` names MODULES, is hard (the
347
- target must be installed), and must be acyclic — compile prints the ring when it isn't.
348
- `peerDependencies` names COLLECTIONS and exists precisely for the ring case: two modules that
349
- each reference a concept the other owns would be an unbreakable cycle as module deps, and are two
350
- independent peer declarations instead. A peer that no installed module provides is recorded on
351
- the compiled descriptor as `unresolved_peers`, so `check` can excuse its dangling references
352
- without learning what a module is.
353
-
354
- `x-reference: '*'` (the open-world evidence field) is warned about outside the workspace module —
355
- an unverifiable cross-module surface — and tolerated inside it, because the workspace is the
356
- orchestrating parent. A cross-module `x-inverse` needs the dependency declared too, since it
357
- stamps a field onto the other module's collection.
437
+ A list (`enum: [a, b]`) and a map hold the same value set; the map adds, per value, any of
438
+ `label` · `description` · `icon` · `color` · `background`, each a string — anything else is dropped,
439
+ so a descriptor cannot inject keys into the contract every surface reads. **Map order is band
440
+ order**: a board grouped by the field draws its lanes in it. `icon` names an icon in the surface's
441
+ set, or is a reference to a record of a binary collection (a reference always holds a slash).
442
+
443
+ ## the reference contract — references across the module graph
444
+
445
+ Every reference target must be one of: an **engine** collection (the entity kinds plus `repos`) ·
446
+ a collection **owned by this module** · owned by a module in **`dependencies`** · or named in
447
+ **`peer_collections`** — or, for the workspace module, any installed collection. It is judged per
448
+ source: the module whose descriptor or overlay declares the field — or lists the mixin carrying it
449
+ — is the one that declares the target. Anything else fails compile with the fix in the message.
450
+
451
+ `dependencies` names MODULES, is hard and must be acyclic — compile prints the ring.
452
+ `peer_collections` names COLLECTIONS and exists for the ring case: two modules referencing each
453
+ other's concepts are two peer declarations instead. A peer nothing installed provides compiles,
454
+ is recorded in `compiled.unresolved_peers`, and `check` warns once with the count of references it
455
+ cannot resolve rather than failing them.
456
+
457
+ `type: reference` (any collection) is warned about outside the workspace module — an unverifiable
458
+ cross-module surface — and accepted inside it. A `soft: true` reference names its collections and
459
+ tolerates a missing record — for a value that is a declaration ("referred by Dr. X") rather than a
460
+ link the workspace already holds.
358
461
 
359
462
  ## registering an existing data folder
360
463
 
361
- 1. Sample the files: derive `suffix`/`codec` from the filenames (`<id>.<suffix>.<ext>`) and the
362
- id `pattern` from the id shapes actually present.
363
- 2. Collect frontmatter keys across files → `properties`; infer types from values. Values shaped
364
- `<collection>/<id>` are `x-reference` fields. No frontmatter at all → `required: []` with a
365
- comment saying why.
366
- 3. Point `storage.path` at the folder — an authored path always wins over the derived default;
367
- this is the first-class case it exists for.
464
+ 1. Sample the files: derive `storage.suffix` and `format` from the filenames (`<id>.<suffix>.<ext>`)
465
+ and `ids.pattern` from the id shapes actually present.
466
+ 2. Collect frontmatter keys across files → `fields`; infer types from values. Values shaped
467
+ `<collection>/<id>` are reference fields. No frontmatter at all → `fields` with only the body.
468
+ 3. Point `storage.path` at the folder — an authored path always wins over the default.
368
469
  4. **Never edit the records to fit an inferred schema.** Describe reality, compile, run `check`,
369
470
  then decide which violations are worth fixing in the data.
370
471
 
@@ -372,62 +473,63 @@ stamps a field onto the other module's collection.
372
473
 
373
474
  Widening (a new optional field, a new enum value) is always safe; narrowing (a new required
374
475
  field, a removed enum value) needs the data cleaned FIRST — measure, clean, *then* narrow, or
375
- every later `check` drowns in the flood. The judgment lives in `data-modeling.md` Part IX; the
376
- mechanical fact that lives here: **there is no `dt migrate`.** A record-based migration mechanism
377
- shipped once and was removed having never been used — every real schema change went around it as
378
- a **one-shot script you write, run once and commit with the records it rewrote**. Say in the
379
- commit message what it did; that message is the only ledger.
476
+ every later `check` drowns. The judgment is `data-modeling.md` Part IX; the mechanics: renames are
477
+ verbs (`rename`, `rename-field`, `rename-value`), and any other shape change across records is a
478
+ **one-shot script you write, run once and commit with the records it rewrote** — there is no
479
+ migration framework. Say in the commit message what it did; that message is the ledger.
380
480
 
381
- ## the message catalog — what compile is telling you
481
+ ## the message catalog — what compile and check are telling you
382
482
 
383
- Compile fails closed and names its reasons; this is the translation table for the ones a
384
- collection author actually meets. (⚠ = warning: it compiled, and you should still act.)
483
+ Compile fails closed and names its reasons. (⚠ = warning: it compiled, and you should still act.)
385
484
 
386
485
  | the message says | it means | the move |
387
486
  |---|---|---|
388
- | `name collision on <kind> "<id>"` | two modules ship the same identity entity — never merged or shadowed | rename yours, or `dreamteamer.disable` one |
389
- | `every descriptor declares 'extends' — no base found` | an overlay whose base is not installed | install or name the base |
390
- | `extends "…" does not name the base` | the value must be `<module>/<collection>` of the actual base | fix the ref |
391
- | `… does not declare '<module>' in dreamteamer.dependencies` | the extends gate — including a field verb's auto-overlay on a module-owned collection | declare the dependency, or edit the owning module's descriptor instead |
392
- | `has folder(s) that are not a known kind` | a typo'd kind, or a kind the engine dropped | fix the name, or declare `dreamteamer.ignore` |
393
- | ⚠ `both <kind>/ and system/<kind>/ exist` | a half-moved module — the flat copy wins, the nested one is NOT compiled | finish the move |
394
- | `schema is not a valid JSON Schema` | a malformed property — usually a string where an object belongs | fix the property it names |
395
- | `id.pattern is not a valid regular expression` | the typo would otherwise detonate inside a write | fix the pattern |
396
- | `sort_field "…" is not a field of its schema` | dragging would silently write to a field no reader sorts by | point it at a real field |
397
- | `field "…" uses x-display` | renamed keyword | delete it (a reference inherits the target's `title_template`) or use `x-title-template` |
398
- | `N fields declare x-body` | a record has ONE body — the text after the frontmatter | keep one |
399
- | `references "X", which … neither owns nor declares` | the reference contract | add the dependency or the peer, as the message says |
400
- | `cyclic module dependencies: a → b → a` | concept-level links declared as module deps | the collection belongs in `peerDependencies` |
401
- | relation refusals (`stamps a mirror onto…`, `declared on both sides…`) | the relation rules | `data-modeling.md` Part VI |
402
- | ⚠ `x-unique on "f" is inert` | a relation keyword with no relation — nothing enforces it | declare the inverse, or drop it |
403
- | ⚠ `x-choices on "f" has an entry for "k"` | it decorates enum VALUES and `k` is not one — a typo, or a value since removed | fix the spelling, or drop the entry |
404
- | ⚠ `x-choices on "f" is inert` | the keyword on a field that declares no enum — nothing reads it | give the field an enum, or drop the keyword |
405
- | ⚠ `collection … has no description` | it renders as a bare name in the orientation block every session loads | write the sentence (`data-modeling.md` §18) |
406
- | ⚠ `module "…" contributed no recognised sources` | its folders match no kind and it ships no UI bundle | usually a layout or naming mistake |
407
- | ⚠ `module X: <channel> copy shadows <channel> copy` | the same module delivered twice — the more local wins (npm-link semantics) | intended for dev; otherwise remove one |
408
-
409
- `check` has its own recurring messages, worth the same translation:
487
+ | `source(s) are in the v1 descriptor format` | a source in the format this engine does not read | run the converter it names; `UPDATING.md` has the walk |
488
+ | `unknown key … — a descriptor's keys are …` (or a field's, a storage's, a display's) | the closed lists | fix the key; the message lists the legal ones |
489
+ | `name collision on collection "<c>"` | two bases — a second source must be an overlay | `overlay: true`, or rename |
490
+ | `name collision on <kind> "<id>"` | two modules ship one entity — never merged | rename yours, or add `<kind>/<id>` to `dreamteamer.disable` |
491
+ | `every source declares overlay: true — no base found` | the base's module is not installed | install it, or declare the collection in `peer_collections` |
492
+ | `an overlay of "<c>", but module "<m>" neither depends on … nor declares …` | the overlay gate, the field verbs' `--module` included | `dt set modules/<m> dependencies=modules/<owner>` |
493
+ | `references "X", which module … neither owns nor declares` | the reference contract | add the dependency or the peer, as printed |
494
+ | `cyclic module dependencies: a → b → a` | concept links declared as module deps | move one to `peer_collections` |
495
+ | `has folder(s) that are not a known kind` | a typo'd kind, or a package folder | fix the name, or list it in `dreamteamer.ignore` |
496
+ | `display.list.columns names "x", which is not a field` (or sort, badge, sections…) | a name that does not exist | fix it — the message names the position |
497
+ | `record_title opens with "<f>", a <type> field` | `dt add "<title>"` fills the first token | open it with a string field |
498
+ | `is a SCALAR mirror, so <owner>.<f> must be a unique scalar reference` | one-to-one needs `unique: true` on the foreign key | declare it, or make the mirror `many` |
499
+ | `is a mirror, but <c> declares no body field` (or is binary, runtime, another repo) | the target cannot hold a generated field | add a body field, or drop the mirror |
500
+ | `every ids.from template must open with {{ <parent> \| basename }}/` | `under.id: nested` | lead the id with the parent |
501
+ | `internal: true is reserved` | a module put a domain collection in the plumbing partition | drop the line |
502
+ | `module X needs engine "…"` | its `engine` range excludes this engine; refused whole | upgrade dreamteamer, or disable it |
503
+ | ⚠ `"<name>" is not a plural the inflector knows` | `singular` falls back to the name | set `singular` (and `storage.suffix`) if `dt add` should take another word |
504
+ | ⚠ `field "<f>": names are snake_case` · `enum value "<v>" is not kebab-case` | a convention, not a rule — a rename is a record change | `dt rename-field` · `dt rename-value` when you choose |
505
+ | ⚠ `is type: reference outside the workspace module` | an unverifiable cross-module surface | name the collections it may target |
506
+ | ⚠ `has no description` · `use_when restates its description` | the orientation block renders a bare name, or the same words twice | write the sentence (`data-modeling.md` §18) |
507
+ | ⚠ `module X reads ${env:NAME} — add it to the workspace's dreamteamer.vars` | a module requests a var the workspace has not allowed | add the name to `dreamteamer.vars` |
508
+ | ⚠ `module X: <channel> copy shadows <channel> copy` | one module delivered twice — the more local wins | intended for dev; otherwise remove one |
509
+
510
+ `check` reports, and never modifies:
410
511
 
411
512
  | check reports | it means | the move |
412
513
  |---|---|---|
413
- | `<field>: stale` on a mirror | the generated mirror fell behind its owner — usually a hand-edited mirror | `dt relations rebuild <collection>` |
414
- | a dangling reference | the target id does not resolve — a deleted or hand-renamed record, or a typo | fix the ref, restore the target, or `dt rename` properly |
415
- | an `x-unique` collision, both claimants named | two records claim the same one-per-subject reference | decide which is real; retarget the other |
416
- | a FLOOD of enum/required violations right after a schema change | the schema narrowed before the data was cleaned | widen back, clean, then narrow (evolving, above) |
514
+ | `<field>: stale — run: dreamteamer relations rebuild <c>` | a mirror fell behind its owner — usually a hand edit | run it |
515
+ | `dangling reference "…" — no such record` | a deleted or hand-renamed target, or a typo | fix the ref, restore the target, or `dt rename` properly |
516
+ | `<field>: "<v>" is already taken by <c>/<id> (unique)` | two records claim one unique value | decide which is real; change the other |
517
+ | `placed under … but <field> is …` | a file in the wrong parent folder | `dt relocate <c>/<id>` |
518
+ | ⚠ `peer collection "<c>" is declared but not installed` | references into an absent peer, counted | expected when the module runs alone |
519
+ | a FLOOD of enum or required violations right after a schema change | the schema narrowed before the data was cleaned | widen back, clean, then narrow |
417
520
 
418
521
  *(one failure has no message: a module folder whose `package.json` lacks a `dreamteamer` key is
419
- silently not discovered — see declaring a module.)*
522
+ silently not discovered.)*
420
523
 
421
524
  ## common mistakes
422
525
 
423
526
  | mistake | reality |
424
527
  |---|---|
425
- | editing the compiled descriptor to change shape | `.dreamteamer/` is generated — edit the module source and compile |
426
- | tightening `required` before cleaning the data | check floods; widen, rewrite the data, then narrow |
427
- | a second same-name descriptor without `extends` | compile error by design |
428
- | a plain string where a ref belongs | use `x-reference` so `check` and `rename` can follow it |
429
- | a `templates:` ref pointing at another module | that module can no longer be copied or installed alone |
430
- | a field verb aimed at a module-owned collection, retried verbatim | add-field/set-field write a workspace overlay behind a dependency gate — declare the dependency or edit the owning module; rm-field refuses outright (edit the module) |
431
- | authoring `storage.path` under an entity-kind name | it compiles as a runtime collection and becomes unwritable |
432
- | hand-editing schema when a schema verb could express it | the verbs are compile-gated and commit their write; a hand edit can land uncompilable and sit unpublished |
528
+ | editing the compiled descriptor | `.dreamteamer/` is generated — edit the module source and compile |
529
+ | a second same-name descriptor without `overlay: true` | a name collision, by design |
530
+ | a plain string where a reference belongs | `type: <collection>` lets `check` and `rename` follow it |
531
+ | a `mixins:` id another module ships | that module can no longer be copied or installed alone |
532
+ | a `--module` field verb retried verbatim after the overlay refusal | declare the dependency it prints, or let the verb write the owning module |
533
+ | authored `singular` expecting the filenames to follow | `storage.suffix` is separate — set both |
534
+ | `storage.path` under an entity-kind name | it compiles as a runtime collection and becomes unwritable |
433
535
  | ignoring a ⚠ because compile said ✔ | every warning above is a defect with a deferred bill |