@genesislcap/ai-assistant 15.49.0 → 15.50.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 (52) hide show
  1. package/dist/custom-elements.json +100 -2
  2. package/dist/dts/genesis/config.d.ts +31 -0
  3. package/dist/dts/genesis/config.d.ts.map +1 -1
  4. package/dist/dts/genesis/consumes.d.ts.map +1 -1
  5. package/dist/dts/genesis/index.d.ts +2 -2
  6. package/dist/dts/genesis/index.d.ts.map +1 -1
  7. package/dist/dts/genesis/reference-check.d.ts +4 -3
  8. package/dist/dts/genesis/reference-check.d.ts.map +1 -1
  9. package/dist/dts/genesis/reference-existence.d.ts +3 -3
  10. package/dist/dts/genesis/reference-existence.d.ts.map +1 -1
  11. package/dist/dts/genesis/review-model.d.ts +59 -4
  12. package/dist/dts/genesis/review-model.d.ts.map +1 -1
  13. package/dist/dts/genesis/types.d.ts +43 -0
  14. package/dist/dts/genesis/types.d.ts.map +1 -1
  15. package/dist/dts/genesis/write-commit.d.ts +2 -2
  16. package/dist/dts/genesis/write-commit.d.ts.map +1 -1
  17. package/dist/dts/genesis/write-op.d.ts +34 -0
  18. package/dist/dts/genesis/write-op.d.ts.map +1 -0
  19. package/dist/dts/genesis/write-outcome.d.ts +2 -2
  20. package/dist/dts/genesis/write-outcome.d.ts.map +1 -1
  21. package/dist/dts/genesis/write-payload.d.ts +3 -3
  22. package/dist/dts/genesis/write-payload.d.ts.map +1 -1
  23. package/dist/dts/genesis/write-plan.d.ts +18 -7
  24. package/dist/dts/genesis/write-plan.d.ts.map +1 -1
  25. package/dist/dts/genesis/write-review/write-review.d.ts +6 -0
  26. package/dist/dts/genesis/write-review/write-review.d.ts.map +1 -1
  27. package/dist/dts/genesis/write-review/write-review.styles.d.ts.map +1 -1
  28. package/dist/dts/genesis/write-review/write-review.template.d.ts.map +1 -1
  29. package/dist/dts/genesis/write-tools.d.ts +2 -2
  30. package/dist/dts/genesis/write-tools.d.ts.map +1 -1
  31. package/dist/dts/genesis/write-turn.d.ts +5 -3
  32. package/dist/dts/genesis/write-turn.d.ts.map +1 -1
  33. package/dist/esm/genesis/config.js +204 -5
  34. package/dist/esm/genesis/consumes.js +5 -0
  35. package/dist/esm/genesis/index.js +1 -1
  36. package/dist/esm/genesis/review-model.js +62 -10
  37. package/dist/esm/genesis/write-op.js +18 -0
  38. package/dist/esm/genesis/write-outcome.js +13 -6
  39. package/dist/esm/genesis/write-payload.js +22 -10
  40. package/dist/esm/genesis/write-plan.js +121 -12
  41. package/dist/esm/genesis/write-review/write-review.js +20 -1
  42. package/dist/esm/genesis/write-review/write-review.styles.js +14 -0
  43. package/dist/esm/genesis/write-review/write-review.template.js +25 -7
  44. package/dist/esm/genesis/write-tools.js +304 -74
  45. package/dist/esm/genesis/write-turn.js +9 -5
  46. package/dist/genesis-consumes.cjs +6 -1
  47. package/dist/genesis-consumes.cjs.map +2 -2
  48. package/dist/genesis-consumes.mjs +6 -1
  49. package/dist/genesis-consumes.mjs.map +2 -2
  50. package/docs/genesis.md +171 -45
  51. package/package.json +17 -17
  52. package/scripts/smoke-genesis-consumes-node.mjs +14 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/genesis/consumes.ts"],
4
- "sourcesContent": ["/**\n * What this version of the assistant reads from a generated AI config\n * (`@genesislcap/ai-assistant/genesis/consumes`).\n *\n * @remarks\n * Its own entry point, loadable in bare Node, because the seed's CI reads it in a Node step and\n * `./genesis` cannot be: that entry is bundler-target ESM, and its closure registers custom\n * elements, which need a DOM. So this module imports nothing at run time. A type from `./types`\n * is all it may take, and a test holds it to that. The Node build bundles it to\n * `dist/genesis-consumes.mjs` and `.cjs`, and a smoke test loads both without a DOM.\n *\n * @packageDocumentation\n * @beta\n */\nimport type { GenesisAiConsumes } from './types';\n\nexport type { GenesisAiConsumes } from './types';\n\n/**\n * What this version of the assistant reads from a generated AI config: the resource kinds it\n * accepts, the resource fields its validator or a tool reads, and the `vendor` and `tier` values\n * it accepts.\n *\n * @remarks\n * The generator must not emit what the installed assistant does not read, or a new kind is left out\n * and a new field ignored \u2014 and an older assistant used to block entirely on a kind it did not know.\n * Nothing in the generator can say which version will run its output. So the app's seed declares\n * what it expects, and the seed's CI checks that declaration against this constant, exported from\n * the version it installs. That makes this the single statement of what an assistant consumes, and\n * it carries no version number because it needs none.\n *\n * A test holds it to the code: its kinds are the ones validation accepts, and its fields are the\n * ones read. A change that teaches the validator a kind, or a tool a field, updates it in the same\n * commit.\n *\n * A resource this version does not read is only left out, but an unknown `vendor` or `tier` still\n * blocks the whole assistant, so those are here too. They are written out rather than imported\n * from foundation-ai, which this entry must not load; a test holds them equal to its\n * `AI_TIER_VENDORS` and `AI_TIER_IDS`, which the validator checks against.\n *\n * @beta\n */\nexport const GENESIS_AI_CONSUMES: GenesisAiConsumes = Object.freeze({\n kinds: Object.freeze(['request', 'event', 'query'] as const),\n resourceFields: Object.freeze([\n 'name',\n 'kind',\n 'op',\n 'context',\n 'maxRows',\n 'customCode',\n 'references',\n ] as const),\n vendors: Object.freeze(['anthropic', 'gemini'] as const),\n tiers: Object.freeze(['low', 'high', 'reasoning'] as const),\n});\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA0CO,IAAM,sBAAyC,OAAO,OAAO;AAAA,EAClE,OAAO,OAAO,OAAO,CAAC,WAAW,SAAS,OAAO,CAAU;AAAA,EAC3D,gBAAgB,OAAO,OAAO;AAAA,IAC5B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAU;AAAA,EACV,SAAS,OAAO,OAAO,CAAC,aAAa,QAAQ,CAAU;AAAA,EACvD,OAAO,OAAO,OAAO,CAAC,OAAO,QAAQ,WAAW,CAAU;AAC5D,CAAC;",
4
+ "sourcesContent": ["/**\n * What this version of the assistant reads from a generated AI config\n * (`@genesislcap/ai-assistant/genesis/consumes`).\n *\n * @remarks\n * Its own entry point, loadable in bare Node, because the seed's CI reads it in a Node step and\n * `./genesis` cannot be: that entry is bundler-target ESM, and its closure registers custom\n * elements, which need a DOM. So this module imports nothing at run time. A type from `./types`\n * is all it may take, and a test holds it to that. The Node build bundles it to\n * `dist/genesis-consumes.mjs` and `.cjs`, and a smoke test loads both without a DOM.\n *\n * @packageDocumentation\n * @beta\n */\nimport type { GenesisAiConsumes } from './types';\n\nexport type { GenesisAiConsumes } from './types';\n\n/**\n * What this version of the assistant reads from a generated AI config: the resource kinds it\n * accepts, the resource fields its validator or a tool reads, and the `vendor` and `tier` values\n * it accepts.\n *\n * @remarks\n * The generator must not emit what the installed assistant does not read, or a new kind is left out\n * and a new field ignored \u2014 and an older assistant used to block entirely on a kind it did not know.\n * Nothing in the generator can say which version will run its output. So the app's seed declares\n * what it expects, and the seed's CI checks that declaration against this constant, exported from\n * the version it installs. That makes this the single statement of what an assistant consumes, and\n * it carries no version number because it needs none.\n *\n * A test holds it to the code: its kinds are the ones validation accepts, and its fields are the\n * ones read. A change that teaches the validator a kind, or a tool a field, updates it in the same\n * commit.\n *\n * A resource this version does not read is only left out, but an unknown `vendor` or `tier` still\n * blocks the whole assistant, so those are here too. They are written out rather than imported\n * from foundation-ai, which this entry must not load; a test holds them equal to its\n * `AI_TIER_VENDORS` and `AI_TIER_IDS`, which the validator checks against.\n *\n * @beta\n */\nexport const GENESIS_AI_CONSUMES: GenesisAiConsumes = Object.freeze({\n kinds: Object.freeze(['request', 'event', 'query'] as const),\n resourceFields: Object.freeze([\n 'name',\n 'kind',\n 'op',\n 'context',\n 'maxRows',\n 'customCode',\n 'references',\n 'shape',\n 'entity',\n 'key',\n 'inputs',\n 'effects',\n ] as const),\n vendors: Object.freeze(['anthropic', 'gemini'] as const),\n tiers: Object.freeze(['low', 'high', 'reasoning'] as const),\n});\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA0CO,IAAM,sBAAyC,OAAO,OAAO;AAAA,EAClE,OAAO,OAAO,OAAO,CAAC,WAAW,SAAS,OAAO,CAAU;AAAA,EAC3D,gBAAgB,OAAO,OAAO;AAAA,IAC5B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAU;AAAA,EACV,SAAS,OAAO,OAAO,CAAC,aAAa,QAAQ,CAAU;AAAA,EACvD,OAAO,OAAO,OAAO,CAAC,OAAO,QAAQ,WAAW,CAAU;AAC5D,CAAC;",
6
6
  "names": []
7
7
  }
@@ -8,7 +8,12 @@ var GENESIS_AI_CONSUMES = Object.freeze({
8
8
  "context",
9
9
  "maxRows",
10
10
  "customCode",
11
- "references"
11
+ "references",
12
+ "shape",
13
+ "entity",
14
+ "key",
15
+ "inputs",
16
+ "effects"
12
17
  ]),
13
18
  vendors: Object.freeze(["anthropic", "gemini"]),
14
19
  tiers: Object.freeze(["low", "high", "reasoning"])
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/genesis/consumes.ts"],
4
- "sourcesContent": ["/**\n * What this version of the assistant reads from a generated AI config\n * (`@genesislcap/ai-assistant/genesis/consumes`).\n *\n * @remarks\n * Its own entry point, loadable in bare Node, because the seed's CI reads it in a Node step and\n * `./genesis` cannot be: that entry is bundler-target ESM, and its closure registers custom\n * elements, which need a DOM. So this module imports nothing at run time. A type from `./types`\n * is all it may take, and a test holds it to that. The Node build bundles it to\n * `dist/genesis-consumes.mjs` and `.cjs`, and a smoke test loads both without a DOM.\n *\n * @packageDocumentation\n * @beta\n */\nimport type { GenesisAiConsumes } from './types';\n\nexport type { GenesisAiConsumes } from './types';\n\n/**\n * What this version of the assistant reads from a generated AI config: the resource kinds it\n * accepts, the resource fields its validator or a tool reads, and the `vendor` and `tier` values\n * it accepts.\n *\n * @remarks\n * The generator must not emit what the installed assistant does not read, or a new kind is left out\n * and a new field ignored \u2014 and an older assistant used to block entirely on a kind it did not know.\n * Nothing in the generator can say which version will run its output. So the app's seed declares\n * what it expects, and the seed's CI checks that declaration against this constant, exported from\n * the version it installs. That makes this the single statement of what an assistant consumes, and\n * it carries no version number because it needs none.\n *\n * A test holds it to the code: its kinds are the ones validation accepts, and its fields are the\n * ones read. A change that teaches the validator a kind, or a tool a field, updates it in the same\n * commit.\n *\n * A resource this version does not read is only left out, but an unknown `vendor` or `tier` still\n * blocks the whole assistant, so those are here too. They are written out rather than imported\n * from foundation-ai, which this entry must not load; a test holds them equal to its\n * `AI_TIER_VENDORS` and `AI_TIER_IDS`, which the validator checks against.\n *\n * @beta\n */\nexport const GENESIS_AI_CONSUMES: GenesisAiConsumes = Object.freeze({\n kinds: Object.freeze(['request', 'event', 'query'] as const),\n resourceFields: Object.freeze([\n 'name',\n 'kind',\n 'op',\n 'context',\n 'maxRows',\n 'customCode',\n 'references',\n ] as const),\n vendors: Object.freeze(['anthropic', 'gemini'] as const),\n tiers: Object.freeze(['low', 'high', 'reasoning'] as const),\n});\n"],
5
- "mappings": ";AA0CO,IAAM,sBAAyC,OAAO,OAAO;AAAA,EAClE,OAAO,OAAO,OAAO,CAAC,WAAW,SAAS,OAAO,CAAU;AAAA,EAC3D,gBAAgB,OAAO,OAAO;AAAA,IAC5B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAU;AAAA,EACV,SAAS,OAAO,OAAO,CAAC,aAAa,QAAQ,CAAU;AAAA,EACvD,OAAO,OAAO,OAAO,CAAC,OAAO,QAAQ,WAAW,CAAU;AAC5D,CAAC;",
4
+ "sourcesContent": ["/**\n * What this version of the assistant reads from a generated AI config\n * (`@genesislcap/ai-assistant/genesis/consumes`).\n *\n * @remarks\n * Its own entry point, loadable in bare Node, because the seed's CI reads it in a Node step and\n * `./genesis` cannot be: that entry is bundler-target ESM, and its closure registers custom\n * elements, which need a DOM. So this module imports nothing at run time. A type from `./types`\n * is all it may take, and a test holds it to that. The Node build bundles it to\n * `dist/genesis-consumes.mjs` and `.cjs`, and a smoke test loads both without a DOM.\n *\n * @packageDocumentation\n * @beta\n */\nimport type { GenesisAiConsumes } from './types';\n\nexport type { GenesisAiConsumes } from './types';\n\n/**\n * What this version of the assistant reads from a generated AI config: the resource kinds it\n * accepts, the resource fields its validator or a tool reads, and the `vendor` and `tier` values\n * it accepts.\n *\n * @remarks\n * The generator must not emit what the installed assistant does not read, or a new kind is left out\n * and a new field ignored \u2014 and an older assistant used to block entirely on a kind it did not know.\n * Nothing in the generator can say which version will run its output. So the app's seed declares\n * what it expects, and the seed's CI checks that declaration against this constant, exported from\n * the version it installs. That makes this the single statement of what an assistant consumes, and\n * it carries no version number because it needs none.\n *\n * A test holds it to the code: its kinds are the ones validation accepts, and its fields are the\n * ones read. A change that teaches the validator a kind, or a tool a field, updates it in the same\n * commit.\n *\n * A resource this version does not read is only left out, but an unknown `vendor` or `tier` still\n * blocks the whole assistant, so those are here too. They are written out rather than imported\n * from foundation-ai, which this entry must not load; a test holds them equal to its\n * `AI_TIER_VENDORS` and `AI_TIER_IDS`, which the validator checks against.\n *\n * @beta\n */\nexport const GENESIS_AI_CONSUMES: GenesisAiConsumes = Object.freeze({\n kinds: Object.freeze(['request', 'event', 'query'] as const),\n resourceFields: Object.freeze([\n 'name',\n 'kind',\n 'op',\n 'context',\n 'maxRows',\n 'customCode',\n 'references',\n 'shape',\n 'entity',\n 'key',\n 'inputs',\n 'effects',\n ] as const),\n vendors: Object.freeze(['anthropic', 'gemini'] as const),\n tiers: Object.freeze(['low', 'high', 'reasoning'] as const),\n});\n"],
5
+ "mappings": ";AA0CO,IAAM,sBAAyC,OAAO,OAAO;AAAA,EAClE,OAAO,OAAO,OAAO,CAAC,WAAW,SAAS,OAAO,CAAU;AAAA,EAC3D,gBAAgB,OAAO,OAAO;AAAA,IAC5B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAU;AAAA,EACV,SAAS,OAAO,OAAO,CAAC,aAAa,QAAQ,CAAU;AAAA,EACvD,OAAO,OAAO,OAAO,CAAC,OAAO,QAAQ,WAAW,CAAU;AAC5D,CAAC;",
6
6
  "names": []
7
7
  }
package/docs/genesis.md CHANGED
@@ -7,9 +7,10 @@ model providers from the platform tier table, turns the app's resources into cha
7
7
  hands back one agent to bind to `<foundation-ai-assistant>`. It is what a generated app's mount
8
8
  code calls; the app supplies configuration, never a model id, endpoint or key.
9
9
 
10
- The API is `@beta`. Each `REQ_` resource and each query becomes a read tool. An `EVENT_` resource becomes a write
11
- tool that shows the user every row it would write and commits only the ones they select, unless
12
- it is one of the shapes that get none (see [Write tools](#write-tools)).
10
+ The API is `@beta`. Each `REQ_` resource and each query becomes a read tool. An `EVENT_` resource
11
+ becomes a write tool that shows the user every row it would write, or run a handler on, and commits
12
+ only the ones they select, unless it is one of the shapes that get none (see
13
+ [Write tools](#write-tools)). A `custom` event gets one only as a [row action](#row-actions).
13
14
 
14
15
  ---
15
16
 
@@ -107,6 +108,8 @@ that table, unless asked), then the extensions' prompt.
107
108
  | `maxRows` | Requests and queries: a whole number from 1 to 1000. Defaults to 50. |
108
109
  | `customCode` | Insert, modify and delete events only: the event's handler runs custom code. See [Custom code](#custom-code). |
109
110
  | `references` | Inserts and modifies: the values that must match another table's row. See [Reference checks](#reference-checks). |
111
+ | `key` | A modify's or a delete's primary-key fields, the only fields it names its row by (see [Naming a row by its key](#naming-a-row-by-its-key)), and a row action's. On anything else the resource is left out. |
112
+ | `shape`, `entity`, `inputs`, `effects` | A `custom` event's row action. See [Row actions](#row-actions). `entity` is accepted on any resource and read only there. |
110
113
 
111
114
  A rule about the config **as a whole** — `enabled`, `vendor`, `tier`, `systemPrompt`, and
112
115
  `resources` being a list — blocks the assistant. A rule about **one resource** leaves that resource
@@ -132,7 +135,8 @@ import { GENESIS_AI_CONSUMES } from '@genesislcap/ai-assistant/genesis/consumes'
132
135
  GENESIS_AI_CONSUMES;
133
136
  // {
134
137
  // kinds: ['request', 'event', 'query'],
135
- // resourceFields: ['name', 'kind', 'op', 'context', 'maxRows', 'customCode', 'references'],
138
+ // resourceFields: ['name', 'kind', 'op', 'context', 'maxRows', 'customCode', 'references',
139
+ // 'shape', 'entity', 'key', 'inputs', 'effects'],
136
140
  // vendors: ['anthropic', 'gemini'],
137
141
  // tiers: ['low', 'high', 'reasoning'],
138
142
  // }
@@ -156,7 +160,7 @@ kind, or a tool a field, updates it in the same change.
156
160
  `vendors` and `tiers` are the `vendor` and `tier` values this version accepts. They matter more
157
161
  than the rest: a resource this version does not read is only left out, but an unknown `vendor` or
158
162
  `tier` blocks the whole assistant. So the seed may check the config's `vendor` and `tier` against
159
- them too. The seed's check (S-6) reads `kinds` and `resourceFields` today. A test holds both lists
163
+ them too. The seed's check reads `kinds` and `resourceFields` today. A test holds both lists
160
164
  equal to foundation-ai's `AI_TIER_VENDORS` and `AI_TIER_IDS`, which the validator checks against.
161
165
 
162
166
  ---
@@ -269,12 +273,13 @@ than asking in chat and then acting on a "yes".
269
273
 
270
274
  The order matters, and is the whole safety argument:
271
275
 
272
- 1. the model's arguments become payloads, built against the event's own metadata. A modify is
273
- merged over the row as it currently stands; a delete is built from that row's own key;
276
+ 1. the model's arguments become payloads, built against the event's own metadata. A modify, and a
277
+ run of a row action, is merged over the row as it currently stands, with its key fields as the
278
+ row holds them; a delete is built from that row's own key;
274
279
  2. those payload objects are rendered in the review, **by reference**;
275
280
  3. the review resolves with row **indexes**, never rows, so nothing that comes back could be a
276
281
  rebuilt payload;
277
- 4. each selected modify or delete is re-read immediately before it is committed, and compared
282
+ 4. each selected modify, delete or run is re-read immediately before it is committed, and compared
278
283
  on every column the review showed. For a delete that is the whole row, not just the key it
279
284
  sends;
280
285
  5. what survives is committed — the objects from step 2.
@@ -291,8 +296,8 @@ the review shows it in full, to the second and beyond. The same goes for the mod
291
296
  value back. It is the server's own, and refusing it would leave the row unwritable over a field
292
297
  nobody is changing. An echo counts only when it is exactly that row's value: another row's time,
293
298
  or the row's time to the minute when it holds seconds, is refused. When the row holds a time for
294
- the field, the refusal adds "or leave it out to keep the row's value", because resending the day
295
- alone would overwrite that time.
299
+ the field, the refusal adds "or leave it out to keep the row's value" (not for a row action's
300
+ input, which cannot be left out), because resending the day alone would overwrite that time.
296
301
 
297
302
  A write tool reads a field's type from its event metadata's `GENESIS_TYPE`, and from `TYPE` only
298
303
  when there is no `GENESIS_TYPE`. `TYPE` names the Java class the value travels as, so a GSF 8.15
@@ -341,9 +346,10 @@ return any text, including a perfect copy of a write result. The key is random,
341
346
  return, so nothing that stores or returns data can know it. A session replayed from an earlier
342
347
  registration carries an older key, and its feedback then reads as data. An app with no event
343
348
  that could get a write tool carries no exception in its prompt at all. That includes an app whose
344
- events the config itself refuses: a `custom` op, a `rowSources` entry naming another source, a
345
- malformed `references`, or a modify or delete whose table's `REQ_` was left out. The metadata read later can still withhold a
346
- tool from an event the config allows, and that cannot be known at registration.
349
+ events the config itself refuses: a `custom` op that is not a row action, a `rowSources` entry
350
+ naming another source, a malformed `references`, or a modify, delete or row action whose table's
351
+ `REQ_` was left out. The metadata read later can still withhold a tool from an event the config
352
+ allows, and that cannot be known at registration.
347
353
  `createGenesisWriteTools` returns these events as `writableEvents`.
348
354
 
349
355
  Three rules hold for the rest of the **turn** (the answer to one user message), in code rather
@@ -352,7 +358,8 @@ than in the prompt: a denial per table, the other two per event:
352
358
  - after a **denial**, the write tools for that table refuse a proposal for the rest of the user's
353
359
  message, before anything is read or shown. A write tool's table comes from its name
354
360
  (`EVENT_<T>_INSERT`, `_MODIFY` or `_DELETE`), or, for a modify or delete without one, from its
355
- row source; a write tool with neither locks only itself. A row source that is a view locks under
361
+ row source, and for a row action from its `entity`, whatever else its code writes. A write tool
362
+ with none of these locks only itself. A row source that is a view locks under
356
363
  the view's name. The denial's `next` names the tools it locks;
357
364
  - the user may ask for changes on **four** reviews: the first proposal and three revisions. After
358
365
  the fourth request the model is told that was the last round, the next call is refused, and it
@@ -360,8 +367,9 @@ than in the prompt: a denial per table, the other two per event:
360
367
  - a proposal **identical** to the one the user just asked to change is refused without a review.
361
368
  Only another answer replaces it: a review in between that timed out does not. Proposals are
362
369
  compared on the payloads they would write, field by field by type, so `'900'` and
363
- `900` for an INT are the same proposal. A modify is compared on what it changes, so a column
364
- somebody else edited between the two reviews does not make a resend new. Rows are matched by
370
+ `900` for an INT are the same proposal. A modify is compared on what it changes, and a run of a
371
+ row action on its inputs, so a column somebody else edited between the two reviews does not
372
+ make a resend new. Rows are matched by
365
373
  the key the model named them by, in any order, and what a row's outcome would say (such as a
366
374
  blank kept as the row's value) is part of the proposal.
367
375
 
@@ -422,6 +430,121 @@ was left out.
422
430
  Registration uses it, and so does `createGenesisWriteTools` when it is called directly, since
423
431
  that factory does not validate its resources.
424
432
 
433
+ ### Row actions
434
+
435
+ A `custom` event gets a write tool only as a **row action**: a handler that runs on one existing
436
+ row of its own table. The generator emits one only for a handler whose code it can prove has that
437
+ shape, and states in the resource what the code does:
438
+
439
+ ```json
440
+ {
441
+ "name": "EVENT_RESPOND_RFQ",
442
+ "kind": "event",
443
+ "op": "custom",
444
+ "context": "Run the RESPOND_RFQ handler on one existing RFQ row. It changes that RFQ row. It needs TRADER_RESPONSE_PRICE.",
445
+ "shape": "row",
446
+ "entity": "RFQ",
447
+ "key": ["RFQ_ID"],
448
+ "inputs": [{ "field": "TRADER_RESPONSE_PRICE", "required": true }],
449
+ "effects": [{ "op": "modify", "table": "RFQ" }]
450
+ }
451
+ ```
452
+
453
+ | Field | Rule |
454
+ | --------- | ---------------------------------------------------------------------------------------------------------- |
455
+ | `shape` | `row`, the only shape this version runs. |
456
+ | `entity` | The handler's own table. Its rows are read through `REQ_<entity>`, which must be a request in the config. |
457
+ | `key` | The table's primary-key fields, at least one, each once. Never `RECORD_ID` or `TIMESTAMP`. |
458
+ | `inputs` | The other values the code reads, each `{ "field": …, "required": true }`. May be empty; never a key field. |
459
+ | `effects` | One `{ "op": "modify" \| "insert", "table": … }` per write in the code, in order. Exactly one modify, of `entity`. |
460
+
461
+ The bridge checks what it can. In the config: `shape` is `row`; `entity` and every name in the lists
462
+ is written as a table or field name (upper-case letters, digits and underscores); `key` is not
463
+ empty, names nothing twice, and never `RECORD_ID` or `TIMESTAMP`; each input is
464
+ `{ "field": …, "required": true }` and not a key field; each effect is a modify or an insert, and
465
+ there is exactly one modify, of `entity`; and `REQ_<entity>` is a request it can read. A row action
466
+ that fails one of these is left out with a warning, and the rest of the config is kept. When the
467
+ tool is built, the key fields and the inputs must be fields of the event, the row source must be
468
+ searchable by every key field, and no input may be one a model cannot set; otherwise it gets no
469
+ tool.
470
+
471
+ The rest it cannot check, so the generator guarantees it and a hand-written config must get it
472
+ right: `key` is the table's primary key, in its order; `inputs` are every other value the code
473
+ reads; and `effects` list every write the code makes, in the order it makes them.
474
+
475
+ A `custom` event with `references` is left out too, and so is any resource that is not a custom
476
+ event and carries `shape`, `inputs` or `effects`, or carries `key` and is not a modify or a delete:
477
+ a CRUD event, request or query that carried one of those was kept by earlier versions, and is now
478
+ left out. A `custom` event with no `shape` is
479
+ kept and gets no tool (see [What gets no write tool](#what-gets-no-write-tool)).
480
+
481
+ The model names each row by its key and gives every input; nothing else. The key is the declared
482
+ key fields, every one of them and no other: to run the handler on rows found by other values, the
483
+ model reads the table first to get their keys. The tool reads the row
484
+ through `REQ_<entity>`, and sends the whole row as read, except `RECORD_ID`, `TIMESTAMP` and any
485
+ column that is null in the row, with the inputs applied. A handler
486
+ declared on its table (`eventHandler<Rfq>`) takes every column of that table as its event's
487
+ fields, and a generated app refuses a payload that lacks a required one, so the row travels whole
488
+ for the same reason a modify's does. An input left blank is refused, never sent as the row's
489
+ value.
490
+
491
+ The review shows each row as it is now, with its key fields marked; each input shows the value
492
+ the handler is given, marked "input:". Unlike a delete's review, it shows only the event's own
493
+ fields, not every column the read returns. As in every review, `RECORD_ID` and `TIMESTAMP` are left
494
+ out. It never marks a change: what the row becomes is decided by the handler's code, which the
495
+ review cannot run. Under its header it says what that code wrote when the app was generated:
496
+
497
+ > Run RESPOND_RFQ on 1 RFQ row(s). Nothing is written until you choose rows and select Write.
498
+ > When this app was generated, the handler's code wrote: modify RFQ.
499
+ > The row is shown as it is now; the handler's code decides what changes.
500
+ > Other parts of the app can update more records in response to this.
501
+
502
+ Before each selected row is sent it is read again by its own key, as the row held it, and a row
503
+ that changed is not sent: it is reported as changed, naming what changed. A denial locks every
504
+ write tool on `entity` for the rest of the turn, the table's own insert, modify and delete
505
+ included, but not the tables the code also inserts into.
506
+
507
+ **An `EVENT_NACK` on a run means nothing was written.** That holds only because of what the
508
+ generator checks: it accepts a handler whose code never writes while validating and never
509
+ returns `nack()` after a write, and a `transactional = true` handler that throws rolls back what
510
+ it wrote, even after its first write. The `STATUS_CODE` inside the NACK says nothing about this: a
511
+ handler's own `nack()` arrives as `500 INTERNAL_ERROR`, and an exception its code throws (a
512
+ `requireNotNull`, say) as `400 REQUEST_FAILED`. Both read as `refused_by_app`. An exception the
513
+ database throws reads as `gone`, `duplicate` or `database_error` instead (see
514
+ [Reading the result](#reading-the-result)).
515
+
516
+ If you write or edit a row-action handler, keep to the same rules: it must be
517
+ `transactional = true`, it must never write in `onValidate`, and it must **never write and then
518
+ return `nack()`**. Those writes commit, and the user is told nothing was written. Throw instead, or
519
+ check before the first write.
520
+
521
+ The app's reason is shown only when it reads as plain prose: at most 160 characters of letters,
522
+ digits, spaces and `_ , . ' " ! ? % / ( ) -`, with nothing that looks like code. That rules out a
523
+ call such as `doThing(`, a dotted name such as `e.g.`, a code such as `RFQ-1234`, a class-like name
524
+ such as `TradeDao`, an IP address such as `10.0.0.1`, and a path from the root such as
525
+ `/opt/genesis`. Anything else, a colon, a semicolon or an accented letter included, shows no reason:
526
+ the user and the model see "no reason that can be shown here". `Cannot respond, RFQ is EXECUTED` is
527
+ shown; `Cannot respond: RFQ is EXECUTED` is not.
528
+
529
+ The effects, like `customCode`'s tables, are what the code did **when the app was generated**.
530
+ The config does not change when the code does; regenerating the app refreshes it.
531
+
532
+ ### Naming a row by its key
533
+
534
+ A modify or a delete the generator gave a `key`, the table's primary-key fields, is named by those
535
+ fields and no others, every one of them required. To change or remove rows found by other values,
536
+ the model reads the table first to get their keys; anything else it puts in the key is let go, so
537
+ a key that also names a field the write changes still changes it. Before the write, the row is
538
+ read again by its key as the row held it (a date as the model sent it), so a row that changed while
539
+ the review was open is reported as changed, naming what changed, rather than as gone. A modify's or
540
+ delete's key holding a date and time, which no read can match exactly, is set aside with a warning,
541
+ and the write is named as before. Without a `key`, a write is named by any fields its row source
542
+ can search by, as it always was.
543
+
544
+ Whatever names the row, a modify writes its key fields as the row holds them, never as the model
545
+ wrote them: a key the read matched one way is never sent another way, so the row written is the
546
+ row the review showed.
547
+
425
548
  ### A modify needs somewhere to read its rows from
426
549
 
427
550
  A generated CRUD modify **replaces** the record, so a payload carrying only the fields the model
@@ -433,14 +556,15 @@ can never see fields no read tool was allowed to return.
433
556
  assistant can read: in the config, not left out, and with a read tool of its own. That is a rule
434
557
  rather than a convenience: the read tools are the assistant's whole view of the app's data, so
435
558
  sourcing a row anywhere else would let a write see — and show a user, and carry into the chat's
436
- saved history — fields no read tool was allowed to return. A modify or delete with no such
437
- resource gets no write tool, and the console says why; nothing about it blocks the assistant.
559
+ saved history — fields no read tool was allowed to return. A modify, delete or row action with
560
+ no such resource gets no write tool, and the console says why; nothing about it blocks the
561
+ assistant.
438
562
 
439
- For a **modify**, the resource also has to **return every field the event writes**. A generated
440
- modify replaces the record, so a column the read cannot see is a column written null, and no
441
- row-by-row check can catch it: a field the row omits and one it genuinely holds as null look
442
- identical. A modify whose source falls short gets no tool, and the console names the missing
443
- columns.
563
+ For a **modify** or a **row action**, the resource also has to **return every field the event
564
+ writes**. A generated modify replaces the record, so a column the read cannot see is a column
565
+ written null, and no row-by-row check can catch it: a field the row omits and one it genuinely
566
+ holds as null look identical. A modify or row action whose source falls short gets no tool, and
567
+ the console names the missing columns.
444
568
 
445
569
  A **delete** is held to neither rule beyond being readable. It sends the fields its event
446
570
  declares, each read from the row, never from the model: for a delete declared over an index
@@ -486,37 +610,39 @@ name that matches an existing entity, view or query.
486
610
  `false` one included. Only when the tools are built directly: the validator leaves such a
487
611
  resource out first.
488
612
  - An event with a **`rowSources` entry** naming anything but its table's own `REQ_<T>` (above).
489
- - A **modify or delete with no row source**: its name carries no table, or its table's `REQ_<T>`
490
- is missing from the config or was left out (below).
613
+ - A **modify, delete or row action with no row source**: a modify's or delete's name carries no
614
+ table, or the table's `REQ_<T>` (a row action's comes from its `entity`) is missing from the
615
+ config, was left out, or is a query (below).
491
616
  - An event whose **`op` is missing** and whose name does not end in `_INSERT`, `_MODIFY` or
492
617
  `_DELETE`. The name settles it where it can; otherwise the resource is refused rather than
493
618
  guessed at, because the guess used to be `custom` — the path with the fewest guarantees. Only
494
619
  when the tools are built directly: the validator requires an `op` on every event first.
495
- - An event declared **`custom`** — which the app generator emits for every exposed custom
496
- handler, so this is not a rare shape. Every rule the write path follows was learned from
497
- Create-generated CRUD handlers, and a custom handler is the app's own code: **we do not know
498
- whether it replaces the record**, and a wrong guess writes nulls into columns nobody was
499
- shown, because the review renders the fields being *sent*. Nor can its answer be trusted the
500
- way a generated handler's can: a hand-written `onCommit` that writes and then returns `nack()`
501
- commits those writes (genesis-server 8.15.14, `TransactionalEventHandlerContainer`), so its
502
- NACK does not mean "not written". This is a deliberate hold, not a
503
- pending task — it will be revisited when custom handlers are next worked on, and until then
504
- the refusal is enforced by the type system rather than by a check somebody could relax.
620
+ - An event declared **`custom`** that is not a [row action](#row-actions). A custom handler is
621
+ the app's own code: without the shape the generator proved, **we do not know whether it
622
+ replaces the record**, and a wrong guess writes nulls into columns nobody was shown, because
623
+ the review renders the fields being *sent*. Nor can its answer be trusted: a hand-written
624
+ `onCommit` that writes and then returns `nack()` commits those writes (genesis-server 8.15.14,
625
+ `TransactionalEventHandlerContainer`), so its NACK does not mean "not written".
626
+ - A **row action** whose `key` or `inputs`, or a **modify or delete** whose `key`, name a field
627
+ its event does not declare, or a row action whose input is one a model may not set: maintained
628
+ by the platform, read-only, or a type this assistant does not set. Those are checked against the
629
+ event's metadata, which the config cannot see.
505
630
  - An event whose `op` **disagrees with its name** (an `EVENT_TRADE_DELETE` declared `insert`).
506
631
  One of the two is wrong, and the write path will not guess which.
507
632
  - An event whose metadata **cannot be read**, **describes no fields**, or names a field **without
508
633
  a type this assistant can write**. A type decides how a value travels (epoch millis, digits, an
509
634
  enum, text), and a guess writes the wrong value or fails the schema. The whole event, not just
510
635
  the field, because the field left out may be a required one.
511
- - A **modify** whose row source does not return every field it writes (above).
512
- - A **modify or delete** whose table's request resource has **no read tool**, because its
513
- `maxRows` is not a number. That only happens when the tools are built directly: the validator
514
- leaves such a request out. A write reads its rows only through a resource the assistant can read.
515
- - A **modify or delete** whose row source can be searched by **none of its fields**. The key a
516
- model may send is offered only from fields the row source can match by equality — its
517
- `CRITERIA_FIELDS` when it publishes them, typed, with readable allowed values, and not a
518
- timestamp — because that is what the read composes its criteria against. A field outside that
519
- set would only come back refused.
636
+ - A **modify or row action** whose row source does not return every field it writes (above).
637
+ - A **modify, delete or row action** whose table's request resource has **no read tool**,
638
+ because its `maxRows` is not a number. That only happens when the tools are built directly: the
639
+ validator leaves such a request out. A write reads its rows only through a resource the
640
+ assistant can read.
641
+ - A **modify, delete or row action** whose row source can be searched by **none of its
642
+ fields**, or not by every field of its declared `key`. The key a model may send is offered only
643
+ from fields the row source can match by equality — its `CRITERIA_FIELDS` when it publishes them,
644
+ typed, with readable allowed values, and not a timestamp — because that is what the read
645
+ composes its criteria against. A field outside that set would only come back refused.
520
646
  - An **insert or a modify with nothing a model may set**: every field is its key, maintained by
521
647
  the platform, or a `NANO_TIMESTAMP`. Every call to it would be refused. (A delete sets nothing
522
648
  by design — it sends the row's key — and is not affected.)
@@ -627,7 +753,7 @@ one — that is how a row gets written twice.
627
753
  | `invalid_payload` | Refused before the review, or the server found the details malformed. |
628
754
  | `changed_since_review` | Somebody changed the row while the review was open. Nothing was sent. |
629
755
  | `reference_gone` | A reference it sets matched no row when it was written. Nothing was sent. |
630
- | `gone` | The row a modify or delete named no longer exists. |
756
+ | `gone` | The row a modify, delete or run named no longer exists. |
631
757
  | `duplicate` | A record with that key already exists. |
632
758
  | `refused_by_app` | The app's own validation said no. Nothing to retry. |
633
759
  | `database_error` | The database refused it for another reason. |
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@genesislcap/ai-assistant",
3
3
  "description": "Genesis AI Assistant micro-frontend",
4
- "version": "15.49.0",
4
+ "version": "15.50.0",
5
5
  "license": "SEE LICENSE IN license.txt",
6
6
  "main": "dist/esm/index.js",
7
7
  "types": "dist/ai-assistant.d.ts",
@@ -92,31 +92,31 @@
92
92
  }
93
93
  },
94
94
  "devDependencies": {
95
- "@genesislcap/foundation-comms": "15.49.0",
96
- "@genesislcap/foundation-testing": "15.49.0",
97
- "@genesislcap/genx": "15.49.0",
98
- "@genesislcap/ts-builder": "15.49.0",
99
- "@genesislcap/uvu-playwright-builder": "15.49.0",
100
- "@genesislcap/vite-builder": "15.49.0",
101
- "@genesislcap/webpack-builder": "15.49.0",
95
+ "@genesislcap/foundation-comms": "15.50.0",
96
+ "@genesislcap/foundation-testing": "15.50.0",
97
+ "@genesislcap/genx": "15.50.0",
98
+ "@genesislcap/ts-builder": "15.50.0",
99
+ "@genesislcap/uvu-playwright-builder": "15.50.0",
100
+ "@genesislcap/vite-builder": "15.50.0",
101
+ "@genesislcap/webpack-builder": "15.50.0",
102
102
  "@types/dompurify": "^3.0.5",
103
103
  "@types/marked": "^5.0.2",
104
104
  "esbuild": "0.25.12"
105
105
  },
106
106
  "dependencies": {
107
- "@genesislcap/foundation-ai": "15.49.0",
108
- "@genesislcap/foundation-logger": "15.49.0",
109
- "@genesislcap/foundation-notifications": "15.49.0",
110
- "@genesislcap/foundation-redux": "15.49.0",
111
- "@genesislcap/foundation-ui": "15.49.0",
112
- "@genesislcap/foundation-utils": "15.49.0",
113
- "@genesislcap/rapid-design-system": "15.49.0",
114
- "@genesislcap/web-core": "15.49.0",
107
+ "@genesislcap/foundation-ai": "15.50.0",
108
+ "@genesislcap/foundation-logger": "15.50.0",
109
+ "@genesislcap/foundation-notifications": "15.50.0",
110
+ "@genesislcap/foundation-redux": "15.50.0",
111
+ "@genesislcap/foundation-ui": "15.50.0",
112
+ "@genesislcap/foundation-utils": "15.50.0",
113
+ "@genesislcap/rapid-design-system": "15.50.0",
114
+ "@genesislcap/web-core": "15.50.0",
115
115
  "dompurify": "^3.3.1",
116
116
  "marked": "^17.0.3"
117
117
  },
118
118
  "peerDependencies": {
119
- "@genesislcap/foundation-comms": "^15.49.0"
119
+ "@genesislcap/foundation-comms": "^15.50.0"
120
120
  },
121
121
  "peerDependenciesMeta": {
122
122
  "@genesislcap/foundation-comms": {
@@ -21,7 +21,20 @@ const require = createRequire(import.meta.url);
21
21
 
22
22
  const EXPECTED = {
23
23
  kinds: ['request', 'event', 'query'],
24
- resourceFields: ['name', 'kind', 'op', 'context', 'maxRows', 'customCode', 'references'],
24
+ resourceFields: [
25
+ 'name',
26
+ 'kind',
27
+ 'op',
28
+ 'context',
29
+ 'maxRows',
30
+ 'customCode',
31
+ 'references',
32
+ 'shape',
33
+ 'entity',
34
+ 'key',
35
+ 'inputs',
36
+ 'effects',
37
+ ],
25
38
  vendors: ['anthropic', 'gemini'],
26
39
  tiers: ['low', 'high', 'reasoning'],
27
40
  };