@metaobjectsdev/sdk 0.20.15 → 0.21.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.
@@ -330,8 +330,12 @@ Per finding: `file:line` → what → generated-equivalent exists? → recommend
330
330
  ## Prompt anti-patterns (hunt per site; classify: fully-modeled / partial / fully-inline)
331
331
 
332
332
  - Inline prompt strings (triple-quoted / template-literal constants in service code).
333
- - Untyped payloads (`str.format(**dict)` / f-strings / ad-hoc dicts) — payload should be an
334
- `object.value` with `origin.*` (`passthrough` / `aggregate` / `collection`) fields.
333
+ - Untyped payloads (`str.format(**dict)` / f-strings / ad-hoc dicts) — payload should be a declared
334
+ shape: an `object.value` (caller-supplied fields; `origin.passthrough` only FR-015 parameter
335
+ lineage) or, when fields derive by `aggregate` / `collection` / `computed` / `first`, a
336
+ **sourceless `object.projection`** carrying those origins (#210 — assembly origins on an
337
+ `object.value` fail load with `ERR_SUBTYPE_RULE_VIOLATION`; `@payloadRef` accepts the sourceless
338
+ projection).
335
339
  - Silent-degradation hack (`try/except KeyError` or `?? ''` around formatting) — flag every instance.
336
340
  - Hand-rolled output parsing (regex / XML / ad-hoc JSON) vs declared `template.output` +
337
341
  generated `parse*` / `safeParse*` / `extract*` parser — **generated in all five ports**
@@ -28,7 +28,7 @@ Both carry the generic attrs:
28
28
 
29
29
  | Attr | Required | Purpose |
30
30
  |---|---|---|
31
- | `@payloadRef` | yes | the `object.value` declaring the payload shape |
31
+ | `@payloadRef` | yes | the `object.value` — or sourceless `object.projection` (#210) — declaring the payload shape |
32
32
  | `@textRef` | yes for `template.prompt` and a `template.output @kind: document` (the default) — a `template.output @kind: email` carries **no** `@textRef`; it uses `@subjectRef` + `@htmlBodyRef` (+ optional `@textBodyRef`) instead | the 2-layer logical text reference `group/source`, resolved by a provider |
33
33
  | `@format` | no | `text` (default) / `html` / `xml` / `csv` / `json` / `markdown` / `spreadsheet` — drives the escaper |
34
34
  | `@maxChars` | no | build-time size budget |
@@ -41,7 +41,8 @@ selects how the output-format prompt fragment presents the payload shape to an L
41
41
  (see "the output-format prompt fragment" below); `@requiredTags` names output tags
42
42
  the rendered text must contain (`verify` checks it) on both subtypes.
43
43
  `template.prompt` additionally carries `@responseRef` — naming the response
44
- value-object the prompt expects, for typed LLM-call trace derivation.
44
+ shape (an `object.value` or sourceless `object.projection`, #210) the prompt
45
+ expects, for typed LLM-call trace derivation.
45
46
 
46
47
  A third, structurally different subtype is also registered core vocabulary:
47
48
  **`template.toolcall`** (`@toolName` + `@payloadRef`, ADR-0011) — a vendor-agnostic
@@ -50,27 +51,27 @@ LLM tool-call envelope with no renderable text body (the body IS the
50
51
  `@format` attrs above). The vocabulary exists today; MCP exposure of declared
51
52
  prompts/tools is roadmap, not shipped — don't promise it.
52
53
 
53
- ## The payload is an `object.value` projection
54
-
55
- The payload is **not** an entity — it's an `object.value` whose every field carries
56
- an `origin.*` child saying where its value comes from. Three origin subtypes:
57
-
58
- | Origin | Behavior |
59
- |---|---|
60
- | `origin.passthrough @from "Entity.field"` | payload property matches the source field |
61
- | `origin.aggregate @agg <count\|sum\|avg\|min\|max>` | `count`→long, `avg`→double, others match source |
62
- | `origin.collection @via "Parent.rel"` | a list of a nested payload, assembled from a relationship |
63
-
64
- These are the **payload-assembly** origins the vocabulary this skill covers.
65
- **Projection** read models (`object.projection` over an entity) carry a fuller origin
66
- vocabulary the `@agg` predicate quantifiers `any`/`all`, the `collect` array rollup,
67
- plus `origin.computed` (a closed `@expr` grammar) and `origin.first` (an argmax-style
68
- pick) those live in the `metaobjects-authoring` skill and
69
- `docs/features/source-kinds.md`, not here: don't reach for them on a payload VO.
70
-
71
- Declaring the payload as a projection is what makes payload bloat visible: adding a
72
- field to the prompt is a diff on the `object.value`, and a renamed source field
73
- breaks the build instead of silently degrading the prompt.
54
+ ## The payload is a shape you declare — an `object.value`, or a sourceless `object.projection`
55
+
56
+ The payload is **not** an entity — it's a declared shape whose fields ARE the
57
+ prompt's typed surface: an `object.value` (caller-supplied fields;
58
+ `origin.passthrough` only — FR-015 parameter lineage), or a **sourceless
59
+ `object.projection`** (#210 no `source.*` child, own or inherited) when fields
60
+ derive by assembly. Every port's payload codegen is
61
+ **declared-type-authoritative (#270)**: a field's generated type comes only from its
62
+ declared `field.<subType>` + `isArray` + `@objectRef`, and a nested payload is a
63
+ declared `field.object @objectRef` to another `object.value` (`isArray: true` for a
64
+ list — nested targets stay value-only, loader-enforced). The caller supplies the
65
+ field values at render time. An `origin.*` child on a payload field is IGNORED for
66
+ typing and the assembly origins (`aggregate` / `collection` / `computed` /
67
+ `first`) are ILLEGAL on an `object.value` host (`ERR_SUBTYPE_RULE_VIOLATION`, #210):
68
+ an origin-derived payload lives on the sourceless projection, which `@payloadRef`
69
+ accepts. Projections generally are covered by the `metaobjects-authoring` skill and
70
+ `docs/features/source-kinds.md`, not here.
71
+
72
+ Declaring the payload shape is what makes payload bloat visible: adding a field to
73
+ the prompt is a diff on the declared shape, and `verify` catches template/payload
74
+ drift at build time instead of letting a prompt silently degrade.
74
75
 
75
76
  ```json
76
77
  {
@@ -81,12 +82,10 @@ breaks the build instead of silently degrading the prompt.
81
82
  "object.value": {
82
83
  "name": "WelcomePayload",
83
84
  "children": [
84
- { "field.string": { "name": "displayName",
85
- "children": [ { "origin.passthrough": { "@from": "Author.name" } } ] } },
86
- { "field.long": { "name": "postCount",
87
- "children": [ { "origin.aggregate": { "@agg": "count", "@of": "Post.id", "@via": "Author.posts" } } ] } },
85
+ { "field.string": { "name": "displayName" } },
86
+ { "field.long": { "name": "postCount" } },
88
87
  { "field.object": { "name": "posts", "@objectRef": "PostSummary",
89
- "children": [ { "origin.collection": { "@via": "Author.posts" } } ] } }
88
+ "isArray": true } }
90
89
  ]
91
90
  }
92
91
  },
@@ -94,8 +93,7 @@ breaks the build instead of silently degrading the prompt.
94
93
  "object.value": {
95
94
  "name": "PostSummary",
96
95
  "children": [
97
- { "field.string": { "name": "title",
98
- "children": [ { "origin.passthrough": { "@from": "Post.title" } } ] } }
96
+ { "field.string": { "name": "title" } }
99
97
  ]
100
98
  }
101
99
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metaobjectsdev/sdk",
3
- "version": "0.20.15",
3
+ "version": "0.21.0",
4
4
  "description": "Workspace helpers and agent-docs utilities for MetaObjects projects.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -56,7 +56,7 @@
56
56
  "access": "public"
57
57
  },
58
58
  "dependencies": {
59
- "@metaobjectsdev/metadata": "0.20.15",
59
+ "@metaobjectsdev/metadata": "0.21.0",
60
60
  "zod": "^3.23.0"
61
61
  },
62
62
  "devDependencies": {