@serene-pub/contracts 0.6.0-pr-4 → 0.6.0-pr-5

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.
package/dist/tasks.js CHANGED
@@ -18,7 +18,7 @@ export const contextBudget = pin(describeTaskDefinition({
18
18
  * Where the window comes from.
19
19
  *
20
20
  * The context window belongs to the sampling config, never to a knob
21
- * on a node (17 §1a) — and the executor resolves a `sampling` slot to
21
+ * on a node — and the executor resolves a `sampling` slot to
22
22
  * the config's switched-on *values*, so this stays a pure Task reading
23
23
  * data it was handed rather than a Query looking one up.
24
24
  *
@@ -29,14 +29,14 @@ export const contextBudget = pin(describeTaskDefinition({
29
29
  sampling: { kind: 'sampling', quick: true },
30
30
  /**
31
31
  * The connection the reply is sent on — for the model's own
32
- * context window (0114), which caps the sampling config's when
32
+ * context window, which caps the sampling config's when
33
33
  * the model states one.
34
34
  *
35
35
  * Shared with the generating step in every shipped spec
36
36
  * (`slot.connectionOf('generate')`), on the same terms as
37
37
  * `sampling` above: the budget has to be sized to the window the
38
38
  * request is actually sent against, and the ONE computation of
39
- * that window (R-8) reads both halves off the same resolved pair.
39
+ * that window reads both halves off the same resolved pair.
40
40
  */
41
41
  connection: { kind: 'connection' },
42
42
  params: {
@@ -140,7 +140,7 @@ export const concatCandidates = pin(describeTaskDefinition({
140
140
  }));
141
141
  /**
142
142
  * **Eligibility** — the hard gates between the mechanisms and the ranker
143
- * (C2; owner rulings R2 and R4, 2026-09-30; built 2026-10-02).
143
+ * (owner rulings of 2026-09-30; built 2026-10-02).
144
144
  *
145
145
  * Scoring and eligibility are separate on purpose: a hard rule must not compete
146
146
  * numerically with a soft one and lose. This node scores nothing. It takes the
@@ -158,7 +158,7 @@ export const concatCandidates = pin(describeTaskDefinition({
158
158
  * 2. **Secrecy.** A `relationships` candidate that is somebody's secret
159
159
  * (`payload.secretOf`, the holder's participant reference) is ineligible for
160
160
  * any other `speaker`. Unwired or null, the producers' own scope decided.
161
- * 3. **Presence** (R4). A candidate about a cast member (`payload.lorebookBindingId`)
161
+ * 3. **Presence.** A candidate about a cast member (`payload.lorebookBindingId`)
162
162
  * whose member has presences on the line and none holding at `at` — the
163
163
  * member is not in the world then. A member with no presences is always
164
164
  * present.
@@ -210,9 +210,9 @@ const rankPorts = {
210
210
  * A declared out-port rather than an implementation detail, because it is
211
211
  * what Assemble allocates from — and because a ranker swapped in by a
212
212
  * plugin has to produce it too, or the budget panel goes blank the moment
213
- * anyone changes rankers (16 §5c).
213
+ * anyone changes rankers.
214
214
  *
215
- * Shape `S.decisions` (R64): a node publishing it is recorded in the
215
+ * Shape `S.decisions`: a node publishing it is recorded in the
216
216
  * ranking store automatically — a plugin's ranker included.
217
217
  */
218
218
  decisions: S.decisions,
@@ -223,7 +223,7 @@ const rankPorts = {
223
223
  * **signal** matrix, which is cross-source and stays here.
224
224
  *
225
225
  * ⚠ No longer the members of `share` / `maxEntries` / `minEntries`: those are
226
- * per-source and live on the sources (R-7 P5, `bandIntentFields`), so a plugin
226
+ * per-source and live on the sources (`bandIntentFields`), so a plugin
227
227
  * adding a sixth band declares its own intent on its own definition and never
228
228
  * touches this list. Its candidates score by `presetScore` or by the ranker's
229
229
  * lore signal set — a per-band signal row for a plugin band is a follow-up,
@@ -264,9 +264,9 @@ const SOURCES = [
264
264
  ];
265
265
  /**
266
266
  * How the shares the sources declared are turned into token budgets — the one
267
- * thing about shares that is genuinely the ranker's (16 §5a: Assemble "keeps
268
- * only what is genuinely global: total budget, truncation policy, and how
269
- * weights normalize").
267
+ * thing about shares that is genuinely the ranker's (Assemble keeps only what
268
+ * is genuinely global: total budget, truncation policy, and how weights
269
+ * normalize).
270
270
  *
271
271
  * `relative` is what ships and is arithmetically what has always run: every
272
272
  * band with a share above zero gets `pool × share / Σ shares`, so only the
@@ -276,10 +276,10 @@ const SOURCES = [
276
276
  * scales them all down together only when they add up to more than one. In
277
277
  * both, whatever a band cannot spend is swept to the others in score order.
278
278
  *
279
- * ⚠ **The per-source maps this file used to declare here are gone** (R-7 P5,
280
- * 2026-09-16). `share`, `maxEntries` and `minEntries` — five-band maps keyed
281
- * `{messages, worldLore, characterLore, history, relationships}` — were the
282
- * per-source table 16 §5a rejected, kept on the ranker rather than on
279
+ * ⚠ **The per-source maps this file used to declare here are gone**
280
+ * (2026-09-16). `share`, `maxEntries` and `minEntries` — five-band maps keyed
281
+ * `{messages, worldLore, characterLore, history, relationships}` — were a
282
+ * per-source table the design rejects, kept on the ranker rather than on
283
283
  * Assemble. Each source declares its own now (`bandIntentFields`) and the
284
284
  * ranker reads them off the candidates it is handed (`BandIntent` in the SDK);
285
285
  * migration 0135 moved every stored value to the node that owns it. What is
@@ -330,8 +330,8 @@ const SHARE_NORMALISATION = {
330
330
  * not "cannot apply": the scorer has no per-source branches, so turning
331
331
  * `nameMatch` on for messages is moving a slider, not asking for a feature.
332
332
  *
333
- * On `rank-hybrid` alone, like its `scripts` hook and for the same reason
334
- * (S3): the `rank-recall` example ranks without signals, and widening a
333
+ * On `rank-hybrid` alone, like its `scripts` hook and for the same reason:
334
+ * the `rank-recall` example ranks without signals, and widening a
335
335
  * sibling's declared surface is a hash change on a type nobody meant to touch.
336
336
  */
337
337
  const SIGNAL_WEIGHT_FIELDS = {
@@ -374,8 +374,8 @@ const SIGNAL_WEIGHT_FIELDS = {
374
374
  * by construction, so the first question scores every present character's
375
375
  * private lore alike and distinguishes nothing.
376
376
  *
377
- * ⚠ **The world-lore half is graded now, and this weight moved with it**
378
- * (design §13.10, retrieval plan phase 3). It used to be a binary substring
377
+ * ⚠ **The world-lore half is graded now, and this weight moved with it**.
378
+ * It used to be a binary substring
379
379
  * test — does the entry's title or keys contain a cast name, `Al` firing on
380
380
  * `Alchemy` — worth exactly `{0, 0.2}`. It is now the rarity-weighted,
381
381
  * word-boundary, two-sided overlap the admission gate already used: what the
@@ -611,7 +611,7 @@ const SIGNAL_WEIGHT_FIELDS = {
611
611
  },
612
612
  };
613
613
  /**
614
- * How much each way of *finding* an entry counts (retrieval plan §1, phase 3).
614
+ * How much each way of *finding* an entry counts.
615
615
  *
616
616
  * The signal weights above are the right data at the wrong altitude.
617
617
  * Nobody thinks in "tf-idf", and a reader who wants less guessing and more
@@ -646,7 +646,7 @@ const SIGNAL_WEIGHT_FIELDS = {
646
646
  * to say "keys only" or "stop guessing" — and is a thing to want.
647
647
  *
648
648
  * On `rank-hybrid` alone, like the signal matrix and `scoreLedAllocation` and for
649
- * the same reason (S3): the `rank-recall` example does not score with signals,
649
+ * the same reason: the `rank-recall` example does not score with signals,
650
650
  * and widening a sibling's declared surface is a hash change on a type nobody
651
651
  * meant to touch.
652
652
  */
@@ -688,13 +688,13 @@ const MECHANISM_WEIGHTS = {
688
688
  },
689
689
  };
690
690
  /**
691
- * Which allocation precedence the selection runs under (design §7).
691
+ * Which allocation precedence the selection runs under.
692
692
  *
693
693
  * Off is what ships, and off is the shipped engine exactly: the shares split
694
694
  * the window into fixed bands and each source fills its own. A turn that needs
695
695
  * no history still reserves history's band, and one relevant world-lore entry
696
696
  * larger than a sixth of the window cannot be kept however it scored — which is
697
- * the thing design §7 calls backwards.
697
+ * the precedence the design calls backwards.
698
698
  *
699
699
  * On, the precedence inverts to *score allocates, minimums guarantee, shares
700
700
  * cap*: the minimums are met first exactly as before, then one pool is spent
@@ -719,7 +719,7 @@ const MECHANISM_WEIGHTS = {
719
719
  * is what leaves the parity corpus measuring the shipped path.
720
720
  *
721
721
  * On `rank-hybrid` alone, like the signal matrix and the `scripts` hook and for
722
- * the same reason (S3): the `rank-recall` example does not run this selection,
722
+ * the same reason: the `rank-recall` example does not run this selection,
723
723
  * and widening a sibling's declared surface is a hash change on a type nobody
724
724
  * meant to touch.
725
725
  */
@@ -740,7 +740,7 @@ export const rankHybrid = pin(describeTaskDefinition({
740
740
  kind: 'parameters',
741
741
  facet: 'weights',
742
742
  schema: {
743
- // Cross-source only (R-7 P5). Ahead of the nine, because it
743
+ // Cross-source only. Ahead of the nine, because it
744
744
  // is the altitude a reader starts at: the grouped mechanisms
745
745
  // first, the individual signals under them for anyone who
746
746
  // wants that far in, then how the sources' shares divide
@@ -752,10 +752,10 @@ export const rankHybrid = pin(describeTaskDefinition({
752
752
  },
753
753
  },
754
754
  /**
755
- * The post-retrieval hook (18 §4a): user chains over the candidate
755
+ * The post-retrieval hook: user chains over the candidate
756
756
  * pool before ranking sees it. Spread onto this type alone rather
757
757
  * than into `rankSlots` — widening a sibling's accepted set is a
758
- * hash change on a type nobody meant to touch (S3).
758
+ * hash change on a type nobody meant to touch.
759
759
  */
760
760
  scripts: {
761
761
  kind: 'scripts',
@@ -802,8 +802,8 @@ export const rankHybrid = pin(describeTaskDefinition({
802
802
  * while the numbers sat one node upstream.
803
803
  *
804
804
  * Spread onto this type alone rather than into `rankPorts` —
805
- * the same reason the `scripts` hook above is, one construct up
806
- * (S3). The `rank-recall` example computes no per-band usage;
805
+ * the same reason the `scripts` hook above is, one construct up.
806
+ * The `rank-recall` example computes no per-band usage;
807
807
  * giving it a port it cannot fill would move a hash to declare
808
808
  * a promise it does not keep.
809
809
  *
@@ -827,8 +827,8 @@ export const rankHybrid = pin(describeTaskDefinition({
827
827
  * first.
828
828
  *
829
829
  * And it carries the **semantic mechanism's one switch**, `searchByMeaning`,
830
- * because it is the first node of the mechanism's chain (2026-09-29, genre
831
- * uplift C3) — `auto | on | off`, shipping `auto`, which searches whenever an
830
+ * because it is the first node of the mechanism's chain (2026-09-29) —
831
+ * `auto | on | off`, shipping `auto`, which searches whenever an
832
832
  * embedding model is set up, wherever it runs (owner, 2026-09-30).
833
833
  * @experimental
834
834
  */
@@ -906,7 +906,7 @@ export const queryWindows = pin(describeTaskDefinition({
906
906
  * per turn in API mode. `maxEntries` is a ceiling now, and
907
907
  * ships non-zero so that turning this on does something.
908
908
  * It was then a boolean defaulting to off for one day
909
- * (C3), which spent nothing and searched nothing.
909
+ * (2026-09-29), which spent nothing and searched nothing.
910
910
  */
911
911
  searchByMeaning: {
912
912
  type: 'enum',
@@ -971,7 +971,7 @@ export const queryWindows = pin(describeTaskDefinition({
971
971
  * to replace. The Query retrieves and computes similarity; this decides.
972
972
  *
973
973
  * `similarity` is a port because MMR needs to compare candidates to each other
974
- * and a Task cannot ask the host for anything (F11). It is a matrix of cosines,
974
+ * and a Task cannot ask the host for anything. It is a matrix of cosines,
975
975
  * not the embeddings — derived, bounded, and not reversible into the vectors.
976
976
  * @experimental
977
977
  */
@@ -986,7 +986,7 @@ export const rankSemantic = pin(describeTaskDefinition({
986
986
  schema: {
987
987
  /**
988
988
  * ⚠ No `currentWindow` / `recentWindow` here, and there
989
- * were (culled 2026-09-16, R-12). They size the two query
989
+ * were (culled 2026-09-16). They size the two query
990
990
  * windows — how many messages form the 'current' and the
991
991
  * 'recent' question — which `core:task/query-windows@1`
992
992
  * cuts and declares as its own params. Declared here too,
@@ -1103,7 +1103,7 @@ export const rankSemantic = pin(describeTaskDefinition({
1103
1103
  },
1104
1104
  }));
1105
1105
  /**
1106
- * A plugin's ranker — same kind, same shape, so the swap list offers it (16 §5c).
1106
+ * A plugin's ranker — same kind, same shape, so the swap list offers it.
1107
1107
  *
1108
1108
  * Named `rankRecall`, not `rankSemantic`: binding names derive from the id's
1109
1109
  * name segment and ignore the namespace, so this and `core:task/rank-semantic@1`
@@ -1141,8 +1141,7 @@ const ASSEMBLE_TEMPLATE_SCOPE = {
1141
1141
  name: { type: 'string' },
1142
1142
  message: { type: 'string', optional: true },
1143
1143
  /**
1144
- * 🚧 The line's files, placed (PLAN-composer-attachments
1145
- * §3.5): media markers, inlined text files and placeholders,
1144
+ * 🚧 The line's files, placed: media markers, inlined text files and placeholders,
1146
1145
  * from `core:task/place-attachments@1`. Absent on a line
1147
1146
  * with no files, and on every line of a spec with no
1148
1147
  * placement step.
@@ -1181,7 +1180,7 @@ const ASSEMBLE_TEMPLATE_SCOPE = {
1181
1180
  },
1182
1181
  },
1183
1182
  /**
1184
- * 🚧 The session's **author's note**, placed (2026-10-02, AN1) — the
1183
+ * 🚧 The session's **author's note**, placed (2026-10-02) — the
1185
1184
  * person's own steering text for this session, at its own depth, with no
1186
1185
  * token trigger. Not the post-history reminder: that one is the pipeline's
1187
1186
  * and the card's "how to respond"; this is the person's "what is true now".
@@ -1205,7 +1204,7 @@ export const assemble = pin(describeTaskDefinition({
1205
1204
  timeoutMs: 1000,
1206
1205
  slots: {
1207
1206
  // An *assembly* template: its scope really is the input ports, so this half of
1208
- // 16 §4's claim holds.
1207
+ // the claim holds.
1209
1208
  template: {
1210
1209
  kind: 'template',
1211
1210
  // Handlebars FIRST, then Liquid: the first entry is what a new
@@ -1215,14 +1214,14 @@ export const assemble = pin(describeTaskDefinition({
1215
1214
  // layout, not a dialect: the same arrangement is expressible in
1216
1215
  // either, and a slot naming one makes the other unselectable
1217
1216
  // everywhere. Jinja is absent because core renders neither
1218
- // parity nor helpers for it (12 §2a).
1217
+ // parity nor helpers for it.
1219
1218
  acceptedEngines: [handlebars.id, liquid.id],
1220
1219
  facet: 'templates',
1221
1220
  /**
1222
1221
  * Assemble's own names — what `render()` writes onto the context
1223
1222
  * AFTER spreading the prompts and the builder's context, so these
1224
- * are the last word (typed templates P3, edited in place — owner
1225
- * ruling Q4).
1223
+ * are the last word (typed templates, edited in place by owner
1224
+ * ruling).
1226
1225
  *
1227
1226
  * Corrected 2026-09-27: this declared `blocks`, `budget` as two
1228
1227
  * bare names and `prompts` — `blocks` is a param that reorders the
@@ -1263,7 +1262,7 @@ export const assemble = pin(describeTaskDefinition({
1263
1262
  currentDate: 'core:var/current-date@1',
1264
1263
  },
1265
1264
  /**
1266
- * Open (typed templates P2, edited in place — owner ruling Q4):
1265
+ * Open (typed templates, edited in place by owner ruling):
1267
1266
  * every band declared upstream of `candidates` is rendered too,
1268
1267
  * under its key and through its variable's layout — a plugin's
1269
1268
  * source adds its band here by declaring it.
@@ -1309,16 +1308,16 @@ export const assemble = pin(describeTaskDefinition({
1309
1308
  * ⚠ No `truncation` here, and there was one — an enum of
1310
1309
  * `oldest-first | lowest-weight`, "what gets dropped first
1311
1310
  * when the context is over budget" — declared, rendered,
1312
- * and read by nothing (culled 2026-09-16, R-12). What LORE
1311
+ * and read by nothing (culled 2026-09-16). What LORE
1313
1312
  * fits is decided upstream by the ranker's `select`, per
1314
1313
  * band, against `share`, `maxEntries`, `minEntries` and
1315
1314
  * `scoreLedAllocation` on `core:task/rank-hybrid@1`, and
1316
1315
  * this node renders the decisions it is handed. A second
1317
1316
  * drop rule for lore here would be a second owner of one
1318
- * decision. NOMENCLATURE §25 records the cull.
1317
+ * decision.
1319
1318
  *
1320
1319
  * ⚠ The TRANSCRIPT is the exception, because nobody else
1321
- * owns it (B2, 2026-10-03): no shipped spec ranks a message
1320
+ * owns it (2026-10-03): no shipped spec ranks a message
1322
1321
  * candidate, so the conversation's rows were never fitted
1323
1322
  * at all and a long session went out larger than the
1324
1323
  * window. The host's binding measures what it rendered and,
@@ -1403,7 +1402,7 @@ export const assemble = pin(describeTaskDefinition({
1403
1402
  * shape on this edge got no finding, and a plugin ASSEMBLER had
1404
1403
  * nothing to read to learn the port existed.
1405
1404
  *
1406
- * `S.decisions`, matching `rankPorts.out.decisions` (R64) — a
1405
+ * `S.decisions`, matching `rankPorts.out.decisions` — a
1407
1406
  * decision is a candidate with its arithmetic attached, and the
1408
1407
  * panel reads the same objects the allocator does. Typed, so a
1409
1408
  * plugin ranker wired here publishes the shape the ranking store
@@ -1448,15 +1447,15 @@ export const assemble = pin(describeTaskDefinition({
1448
1447
  groups: S.json,
1449
1448
  /**
1450
1449
  * The annex a template may read, as `annex.<owner>.<key>`
1451
- * (typed templates P6, edited in place — owner ruling Q4).
1450
+ * (typed templates, edited in place by owner ruling).
1452
1451
  *
1453
1452
  * Fed ONLY by `core:query/session-annex@1` with `view:
1454
1453
  * 'template'`: every DECLARED key of every owner in scope —
1455
1454
  * core, the enabled plugins — for the session's genre, keyed by
1456
1455
  * owner. A key no declaration covers never arrives, and a
1457
- * declaration refuses secrets at write time (R61), so what
1456
+ * declaration refuses secrets at write time, so what
1458
1457
  * reaches a template is what an owner said may be kept there
1459
- * (owner ruling Q1: "nothing dangerous should ever be stored
1458
+ * (owner ruling: "nothing dangerous should ever be stored
1460
1459
  * there"). Law T2 refuses anything else wired here, and a
1461
1460
  * template-view read wired anywhere else.
1462
1461
  *
@@ -1478,7 +1477,7 @@ const contextPorts = {
1478
1477
  in: {
1479
1478
  cast: S.sessionCast,
1480
1479
  /**
1481
- * Whose voice the reply is, when a next-speaker node decided (19 §5).
1480
+ * Whose voice the reply is, when a next-speaker node decided.
1482
1481
  * Optional: unwired, the speaker still rides the cast bundle (the
1483
1482
  * scope's value), which is how every spec worked before the node
1484
1483
  * existed — and how the narrator's context, which has no speaker,
@@ -1522,7 +1521,7 @@ const PROMPTS_DESCRIPTION = 'The written instructions this pipeline sends the mo
1522
1521
  const VARIABLES_DESCRIPTION = 'How each part of the prompt is laid out — JSON, prose, or whatever you write. Duplicate one to change it.';
1523
1522
  /**
1524
1523
  * What a context builder's `templateContext` carries, in the template type
1525
- * language (typed templates P3, 2026-09-27) — so a template editor offers
1524
+ * language (typed templates, 2026-09-27) — so a template editor offers
1526
1525
  * `{{{characters}}}` with a type, and `templateScopeAt` puts these keys in
1527
1526
  * the scope of whatever template renders the builder's output.
1528
1527
  *
@@ -1552,6 +1551,8 @@ export const TEMPLATE_CONTEXT_SCHEMA = {
1552
1551
  scenario: { type: 'string', description: 'The scenario, resolved and laid out.' },
1553
1552
  characterNames: { type: 'string', description: '“A, B, and C” — every enabled character’s name (none at speaker-only detail).' },
1554
1553
  personaNames: { type: 'string', description: '“A, B, and C” — every persona’s name.' },
1554
+ /** 🚧 `core:var/likenesses@1` — everyone on stage's likeness prompt, laid out. */
1555
+ likenesses: { type: 'string', description: 'Everyone on stage’s likeness prompt, by name, laid out (JSON by default).' },
1555
1556
  exampleDialogue: { type: 'string', description: 'The speaker’s example dialogue.' },
1556
1557
  postHistoryInstructions: { type: 'string', description: 'The post-history instructions, resolved.' },
1557
1558
  relationshipsPerspectives: { type: 'string', description: 'How the speaker regards everyone.' },
@@ -1611,6 +1612,8 @@ const sharedRenders = {
1611
1612
  postHistoryInstructions: 'core:var/post-history-instructions@1',
1612
1613
  characterNames: 'core:var/character-names@1',
1613
1614
  personaNames: 'core:var/persona-names@1',
1615
+ /** 🚧 Everyone on stage's likeness prompt. */
1616
+ likenesses: 'core:var/likenesses@1',
1614
1617
  };
1615
1618
  /**
1616
1619
  * The reply pipeline's context builder.
@@ -1626,7 +1629,7 @@ const sharedRenders = {
1626
1629
  *
1627
1630
  * A type is the unit that declares a configurable surface — it is how a plugin
1628
1631
  * declares one, and `RegistryEntry.slots` carries the declaration precisely so
1629
- * core can render a form without executing the plugin that owns it (12 §2, F6).
1632
+ * core can render a form without executing the plugin that owns it.
1630
1633
  * Narrowing per-spec instead would have meant the row said one thing and the
1631
1634
  * running pipeline another, which is the defect widening that column fixed.
1632
1635
  *
@@ -1638,7 +1641,7 @@ export const buildTemplateContext = pin(describeTaskDefinition({
1638
1641
  id: 'core:task/build-template-context@1',
1639
1642
  i18n: { name: { en: 'Build template context' } },
1640
1643
  timeoutMs: 2000,
1641
- /** What `templateContext` carries — typed templates P3; policy, so no pin moves. */
1644
+ /** What `templateContext` carries — typed templates; policy, so no pin moves. */
1642
1645
  portSchemas: { out: { main: TEMPLATE_CONTEXT_SCHEMA, templateContext: TEMPLATE_CONTEXT_SCHEMA } },
1643
1646
  /**
1644
1647
  * The example-dialogue pick. Declaring it is what gets `ctx.random` — the
@@ -1684,7 +1687,7 @@ export const buildTemplateContext = pin(describeTaskDefinition({
1684
1687
  },
1685
1688
  },
1686
1689
  /**
1687
- * The pre-assemble context hook (18 §4a): user chains over the
1690
+ * The pre-assemble context hook: user chains over the
1688
1691
  * finished template context — conditional style guides, seeded
1689
1692
  * event tables — after this node resolves it and before anything
1690
1693
  * renders it.
@@ -1694,7 +1697,7 @@ export const buildTemplateContext = pin(describeTaskDefinition({
1694
1697
  * template-context *data* (`context.injections`, resolved to
1695
1698
  * `injectionsByIndex` beside `postHistory.targetIndex`), rendered
1696
1699
  * by the template's own message loop. Splicing them into the list
1697
- * behind the template's back would be the §20 defect again, one
1700
+ * behind the template's back would repeat an old defect one
1698
1701
  * layer down: a position the template cannot express, an author
1699
1702
  * cannot see, and a corpus cannot check.
1700
1703
  */
@@ -1732,7 +1735,7 @@ export const buildTemplateContext = pin(describeTaskDefinition({
1732
1735
  * narrate spec never supplies these because graph context
1733
1736
  * needs a speaker's perspective and a narrator has none — so
1734
1737
  * widening the shared map would give it two ports it must
1735
- * leave empty forever, and move its hash to say so (S3).
1738
+ * leave empty forever, and move its hash to say so.
1736
1739
  */
1737
1740
  relationshipsPerspectives: S.json,
1738
1741
  relationshipsKnown: S.json,
@@ -1762,8 +1765,8 @@ export const buildTemplateContext = pin(describeTaskDefinition({
1762
1765
  speakerName: S.text,
1763
1766
  speakerCharacter: S.json,
1764
1767
  /**
1765
- * Who is speaking, as a participant reference (R-18 (3); U5g,
1766
- * 2026-09-16) — the turn strategy's `speaker`. Read for one
1768
+ * Who is speaking, as a participant reference (2026-09-16)
1769
+ * — the turn strategy's `speaker`. Read for one
1767
1770
  * thing: an **envoy** (`envoy:<slug>`) has no character row, so
1768
1771
  * its card — name and description, off the genre's declaration
1769
1772
  * the cast read carries — is compiled here where a cast
@@ -1795,23 +1798,22 @@ export const buildTemplateContext = pin(describeTaskDefinition({
1795
1798
  state: S.json,
1796
1799
  /**
1797
1800
  * What the person typed with the press, for an action that
1798
- * reads its composer text as **direction** (lair pass B17,
1799
- * 2026-09-27): the Lair's Trigger trap and Reveal, and
1800
- * Whodunit's Search — what the detective is looking for (genre
1801
- * uplift C2, 2026-09-29). Rendered as
1801
+ * reads its composer text as **direction** (2026-09-27): the
1802
+ * Lair's Trigger trap and Reveal, and Whodunit's Search — what
1803
+ * the detective is looking for (2026-09-29). Rendered as
1802
1804
  * `{{turnDirection}}` — the same name, and the same meaning,
1803
- * `build-scene-context@1` gives the Lair's reply (B11). Absent
1805
+ * `build-scene-context@1` gives the Lair's reply. Absent
1804
1806
  * when blank, so a prompt writes `{{#if turnDirection}}…{{/if}}`
1805
1807
  * and a press with nothing typed leaves it to the prompt.
1806
1808
  * Declared here rather than in `contextPorts`, like `state`
1807
1809
  * above; the narrator and side-character builders declare
1808
- * their own (C2). Unwired on every spec whose composer text is
1810
+ * their own. Unwired on every spec whose composer text is
1809
1811
  * a line somebody said.
1810
1812
  */
1811
1813
  turnDirection: S.text,
1812
1814
  /**
1813
1815
  * The places the lorebook holds, for an envoy that talks about
1814
- * the world from outside it (lair re-plan R6, 2026-09-28): the
1816
+ * the world from outside it (2026-09-28): the
1815
1817
  * Lair's Castellan in the Sanctum. A
1816
1818
  * `core:query/lorebook-entries@1` listing, rendered exactly as
1817
1819
  * the planner's and the scene's port of this name is —
@@ -1822,7 +1824,7 @@ export const buildTemplateContext = pin(describeTaskDefinition({
1822
1824
  locationEntries: S.json,
1823
1825
  /**
1824
1826
  * The story's newest rows, for a speaker who talks ABOUT the
1825
- * story from another channel (lair re-plan R6): the Castellan
1827
+ * story from another channel: the Castellan
1826
1828
  * in the Sanctum reads `main`'s last few rows. Transcript rows
1827
1829
  * (a `session-history@1` read), rendered as prose — one
1828
1830
  * `Name: line` per row, named as the transcript names them, no
@@ -1832,8 +1834,8 @@ export const buildTemplateContext = pin(describeTaskDefinition({
1832
1834
  */
1833
1835
  recentStory: S.messages,
1834
1836
  /**
1835
- * The session's genre fields, by their own names (lair re-plan
1836
- * R13, 2026-09-28): `{{sanctumSteers}}` for the Castellan in
1837
+ * The session's genre fields, by their own names (2026-09-28):
1838
+ * `{{sanctumSteers}}` for the Castellan in
1837
1839
  * the Sanctum, whose instructions say whether its talk shapes
1838
1840
  * the next turn. The planner's and the scene's `fields`, on the
1839
1841
  * same terms. Declared on THIS type alone, like `state`;
@@ -1841,7 +1843,7 @@ export const buildTemplateContext = pin(describeTaskDefinition({
1841
1843
  */
1842
1844
  fields: S.json,
1843
1845
  /**
1844
- * The speaker's own running notes (lair re-plan R13, owner
1846
+ * The speaker's own running notes (owner ruling of
1845
1847
  * 2026-09-28): the Castellan's **scratchpad**, the Lair's annex
1846
1848
  * field `castellan-scratchpad`, read for it alone
1847
1849
  * (`session-annex@1`'s AI view, with its own reference as the
@@ -1909,12 +1911,12 @@ export const buildNarratorContext = pin(describeTaskDefinition({
1909
1911
  in: {
1910
1912
  ...contextPorts.in,
1911
1913
  /**
1912
- * What the person asked this narration to do (genre uplift
1913
- * C2, 2026-09-29): the narrator modal's text or `/narrate
1914
+ * What the person asked this narration to do (2026-09-29):
1915
+ * the narrator modal's text or `/narrate
1914
1916
  * <text>` — the turn's triggering text, `$.input.text`.
1915
1917
  * Rendered as `{{turnDirection}}`, the name and the meaning
1916
1918
  * `build-template-context@1` and `build-scene-context@1` give
1917
- * it (B11); absent when blank, so a row writes
1919
+ * it; absent when blank, so a row writes
1918
1920
  * `{{#if turnDirection}}…{{/if}}` and an undirected narration
1919
1921
  * renders exactly what it did before.
1920
1922
  *
@@ -1968,7 +1970,7 @@ export const buildNarratorContext = pin(describeTaskDefinition({
1968
1970
  * the card; the id stays where the host can act on it.
1969
1971
  *
1970
1972
  * ⚠ **The OUT-port `speaker` is the other half of that sentence** (added
1971
- * 2026-09-17, W1). The half-working control was a speaker id that changed the
1973
+ * 2026-09-17). The half-working control was a speaker id that changed the
1972
1974
  * prompt's voice and not the lore; the repair is not an in-port but a lane
1973
1975
  * inside the same clause reading the answer this node already computed —
1974
1976
  * `core:query/character-lore@1` takes `speaker`, so the voice and its private
@@ -2017,8 +2019,8 @@ export const buildSideCharacterContext = pin(describeTaskDefinition({
2017
2019
  * because a typed name is all there is.
2018
2020
  *
2019
2021
  * `characterId` (a row id) or `ref` (a participant reference,
2020
- * `character:<id>` — what a pressed option carries, plan A28
2021
- * review) names the speaker BY ROW, and then the row is who
2022
+ * `character:<id>` — what a pressed option carries) names the
2023
+ * speaker BY ROW, and then the row is who
2022
2024
  * speaks: the name is a label, never a second lookup, so two
2023
2025
  * people sharing a name stay two people and a row the cast does
2024
2026
  * not seat is still the person it names. A fact with neither
@@ -2047,7 +2049,7 @@ export const buildSideCharacterContext = pin(describeTaskDefinition({
2047
2049
  plan: S.json,
2048
2050
  /**
2049
2051
  * The rooms, listed (`core:query/lorebook-entries@1`), as the
2050
- * planner and the scene get them (lair pass R8, 2026-09-28):
2052
+ * planner and the scene get them (2026-09-28):
2051
2053
  * `{{knownLocations}}` and the one the party stand in as
2052
2054
  * `{{locationEntry}}`, so a voice can name the room it is in
2053
2055
  * now that nobody narrates it first. Unwired, neither renders.
@@ -2055,7 +2057,7 @@ export const buildSideCharacterContext = pin(describeTaskDefinition({
2055
2057
  locationEntries: S.json,
2056
2058
  /**
2057
2059
  * A place described only in prose, as `{{locationPassage}}`
2058
- * (lair pass R9, 2026-09-28): the paragraph
2060
+ * (2026-09-28): the paragraph
2059
2061
  * `core:task/undescribed-name@1` found describing the room the
2060
2062
  * party are about to walk into (its `passage`), when no entry
2061
2063
  * describes it — that room's text for this turn. Blank or
@@ -2064,7 +2066,7 @@ export const buildSideCharacterContext = pin(describeTaskDefinition({
2064
2066
  locationPassage: S.text,
2065
2067
  /**
2066
2068
  * What the person asked this side character's turn to do
2067
- * (genre uplift C2, 2026-09-29) — the narrator modal's text,
2069
+ * (2026-09-29) — the narrator modal's text,
2068
2070
  * which feeds both of its halves. `{{turnDirection}}`, on the
2069
2071
  * terms `build-narrator-context@1` states; wired by
2070
2072
  * `core:spec/chat-side-character` alone, so a genre's voices
@@ -2079,7 +2081,7 @@ export const buildSideCharacterContext = pin(describeTaskDefinition({
2079
2081
  * Who this voice is, as a **participant reference** — the row
2080
2082
  * the fact named (`characterId` or `ref`), else
2081
2083
  * `character:<id>` for a name the cast holds, else null for a
2082
- * free-form one. Additive, 2026-09-17 (W1). A lore read wired
2084
+ * free-form one. Additive, 2026-09-17. A lore read wired
2083
2085
  * to it takes null as unwired, so the run's scope decides for
2084
2086
  * a free-form voice.
2085
2087
  *
@@ -2125,7 +2127,7 @@ export const buildSideCharacterContext = pin(describeTaskDefinition({
2125
2127
  * `SlotNamesOf<typeof buildPlannerContext>` `never`, so a handler bound to the
2126
2128
  * three surfaces could type-check reading NO slot and declare NO slot read,
2127
2129
  * which is the "declares least, checked least" hole `nodeInput.ts` warns about.
2128
- * Found when the surfaces gained `reads` declarations (R-12, 2026-09-16).
2130
+ * Found when the surfaces gained `reads` declarations (2026-09-16).
2129
2131
  */
2130
2132
  const agentContextSlots = (promptFields) => ({
2131
2133
  prompts: {
@@ -2187,22 +2189,22 @@ export const buildPlannerContext = pin(describeTaskDefinition({
2187
2189
  fields: S.json,
2188
2190
  /**
2189
2191
  * What the person just sent, when the genre reads it as
2190
- * **direction** rather than as a line somebody said (lair pass
2191
- * B11, 2026-09-27) — the Lair's composer. On the template
2192
+ * **direction** rather than as a line somebody said
2193
+ * (2026-09-27) — the Lair's composer. On the template
2192
2194
  * context and in the prompt as `{{turnDirection}}`; empty or
2193
2195
  * absent on a turn nobody directed (a Continue), so a prompt
2194
2196
  * writes `{{#if turnDirection}}…{{/if}}`. A genre whose composer
2195
2197
  * text is a participant's line leaves it unwired: that line is
2196
2198
  * already in the transcript. *Turn* direction, never bare
2197
2199
  * `direction`: that word is the Lair's standing-note state slot
2198
- * (`core:slot/direction@1`), a different fact (R1, renamed
2199
- * 2026-09-27).
2200
+ * (`core:slot/direction@1`), a different fact (one word, one
2201
+ * meaning; renamed 2026-09-27).
2200
2202
  */
2201
2203
  turnDirection: S.text,
2202
2204
  /**
2203
2205
  * The places the lorebook holds — a
2204
2206
  * `core:query/lorebook-entries@1` listing of location entries
2205
- * (lair pass B13, 2026-09-27). On the template context as
2207
+ * (2026-09-27). On the template context as
2206
2208
  * `{{knownLocations}}` (their names, one line) and
2207
2209
  * `{{locationEntry}}` (the entry whose name is the world's
2208
2210
  * `location` slot — where the party are, its exits included),
@@ -2212,7 +2214,7 @@ export const buildPlannerContext = pin(describeTaskDefinition({
2212
2214
  */
2213
2215
  locationEntries: S.json,
2214
2216
  /**
2215
- * **Side talk** (lair re-plan R13, 2026-09-28): what was said on
2217
+ * **Side talk** (2026-09-28): what was said on
2216
2218
  * another channel since the story's last line — the Lair's
2217
2219
  * Sanctum talk, read by `session-history@1` with
2218
2220
  * `unplayedOnly`. Transcript rows, rendered as prose into
@@ -2224,15 +2226,15 @@ export const buildPlannerContext = pin(describeTaskDefinition({
2224
2226
  */
2225
2227
  sideTalk: S.messages,
2226
2228
  /**
2227
- * The planner's own running notes (lair re-plan R13, owner
2229
+ * The planner's own running notes (owner ruling of
2228
2230
  * 2026-09-28): the Castellan's **scratchpad**, rendered as
2229
2231
  * `{{scratchpad}}`. Absent when unwired or blank; the Lair
2230
2232
  * wires it beside `sideTalk`.
2231
2233
  */
2232
2234
  scratchpad: S.text,
2233
2235
  /**
2234
- * **How the cast stand with each other** (genre plan F6(a),
2235
- * 2026-09-29): the ranker's allocated candidates, of which the
2236
+ * **How the cast stand with each other** (2026-09-29): the
2237
+ * ranker's allocated candidates, of which the
2236
2238
  * builder reads the `relationships` band's `castRelationships`
2237
2239
  * lane — `core:query/relationship-search@1` read with nobody
2238
2240
  * speaking. Rendered as `{{castRelationships}}`: JSON keyed by
@@ -2299,22 +2301,22 @@ export const buildSceneContext = pin(describeTaskDefinition({
2299
2301
  fields: S.json,
2300
2302
  /**
2301
2303
  * What the person just sent, when the genre reads it as
2302
- * **direction** rather than as a line somebody said (lair pass
2303
- * B11, 2026-09-27) — the Lair's composer. On the template
2304
+ * **direction** rather than as a line somebody said
2305
+ * (2026-09-27) — the Lair's composer. On the template
2304
2306
  * context and in the prompt as `{{turnDirection}}`; empty or
2305
2307
  * absent on a turn nobody directed (a Continue), so a prompt
2306
2308
  * writes `{{#if turnDirection}}…{{/if}}`. A genre whose composer
2307
2309
  * text is a participant's line leaves it unwired: that line is
2308
2310
  * already in the transcript. *Turn* direction, never bare
2309
2311
  * `direction`: that word is the Lair's standing-note state slot
2310
- * (`core:slot/direction@1`), a different fact (R1, renamed
2311
- * 2026-09-27).
2312
+ * (`core:slot/direction@1`), a different fact (one word, one
2313
+ * meaning; renamed 2026-09-27).
2312
2314
  */
2313
2315
  turnDirection: S.text,
2314
2316
  /**
2315
2317
  * The places the lorebook holds — a
2316
2318
  * `core:query/lorebook-entries@1` listing of location entries
2317
- * (lair pass B13, 2026-09-27). On the template context as
2319
+ * (2026-09-27). On the template context as
2318
2320
  * `{{knownLocations}}` (their names, one line) and
2319
2321
  * `{{locationEntry}}` (the room the world's `location` names,
2320
2322
  * else the planner's location hint — where the party are, its
@@ -2325,7 +2327,7 @@ export const buildSceneContext = pin(describeTaskDefinition({
2325
2327
  */
2326
2328
  locationEntries: S.json,
2327
2329
  /**
2328
- * **Side talk** (lair re-plan R13, 2026-09-28), on the
2330
+ * **Side talk** (2026-09-28), on the
2329
2331
  * planner's terms: the Lair's Sanctum talk since the story's
2330
2332
  * last line, rendered as prose into `{{sideTalk}}` — for the
2331
2333
  * Castellan's narration, wired while the session's _Sanctum
@@ -2335,7 +2337,7 @@ export const buildSceneContext = pin(describeTaskDefinition({
2335
2337
  sideTalk: S.messages,
2336
2338
  /**
2337
2339
  * How the cast stand with each other, on the narrator's terms
2338
- * — the same port as the planner's (F6(a), 2026-09-29), rendered
2340
+ * — the same port as the planner's (2026-09-29), rendered
2339
2341
  * as `{{castRelationships}}`. See `buildPlannerContext`.
2340
2342
  */
2341
2343
  castRelationships: S.candidates,
@@ -2438,6 +2440,16 @@ export const buildKeeperContext = pin(describeTaskDefinition({
2438
2440
  * prompt naming `{{tone}}` rendered a blank.
2439
2441
  */
2440
2442
  fields: S.json,
2443
+ /**
2444
+ * 🚧 **How much time the player chose** (live scenes §15 G6,
2445
+ * 2026-10-13): a collected clock step, `{ by, unit }` — the
2446
+ * inlet's `clockStep` on a *Time passes…* press. Spelled on the
2447
+ * template context as `{{clockStep}}` (`3 hours`, `1 day`,
2448
+ * `2 hours back`), so the keeper describes what the world does
2449
+ * over the span the player picked rather than one notch of
2450
+ * the time of day. Absent when unwired or not a step.
2451
+ */
2452
+ clockStep: S.json,
2441
2453
  },
2442
2454
  out: contextPorts.out,
2443
2455
  },
@@ -2457,11 +2469,11 @@ export const processMessages = pin(describeTaskDefinition({
2457
2469
  timeoutMs: 1000,
2458
2470
  slots: {
2459
2471
  /**
2460
- * The message-rewrite hook (18 §4a), on the *processed* list —
2472
+ * The message-rewrite hook, on the *processed* list —
2461
2473
  * names resolved, per-message interpolation done. `transform` only:
2462
2474
  * `messages/inject` deliberately does **not** live here. Injection
2463
2475
  * is a statement about *position in the rendered conversation*, and
2464
- * position belongs to the template (§20, ruling of 2026-08-23) —
2476
+ * position belongs to the template (ruling of 2026-08-23) —
2465
2477
  * inject chains attach on the context builders, land as
2466
2478
  * `context.injections`, and the template's own loop renders them.
2467
2479
  * Splicing rows into this list would be a position the template
@@ -2483,8 +2495,7 @@ export const processMessages = pin(describeTaskDefinition({
2483
2495
  seedName: S.text,
2484
2496
  /**
2485
2497
  * Text the model is being asked to CONTINUE — the seed line's
2486
- * body rather than a message of its own (ruling 2026-09-08,
2487
- * D-2).
2498
+ * body rather than a message of its own (ruling 2026-09-08).
2488
2499
  *
2489
2500
  * ⚠ **Absent on an ordinary turn, and that is the normal case.**
2490
2501
  * There is no `optional` marker for a port: a port nothing wires
@@ -2549,8 +2560,7 @@ export const proseTranscript = pin(describeTaskDefinition({
2549
2560
  },
2550
2561
  }));
2551
2562
  /**
2552
- * 🚧 **Where each line's attachments go** (PLAN-composer-attachments §3.5; owner
2553
- * D2/D3, 2026-10-02).
2563
+ * 🚧 **Where each line's attachments go** (owner rulings of 2026-10-02).
2554
2564
  *
2555
2565
  * Pure. Takes the processed lines and the attachments by message, and gives
2556
2566
  * each line an `attachments` string the template renders after the line's text
@@ -2617,11 +2627,11 @@ export const placeAttachments = pin(describeTaskDefinition({
2617
2627
  },
2618
2628
  }));
2619
2629
  /**
2620
- * The turn-order pool, orderer and strategies (PLAN-turn-order §4.4, R3/R8;
2621
- * re-ported in place 2026-09-22, pre-release).
2630
+ * The turn-order pool, orderer and strategies (re-ported in place
2631
+ * 2026-09-22, pre-release).
2622
2632
  *
2623
- * Turn order is **state**, not a decision made inside the reply run
2624
- * (§3). One spec per genre — `core:spec/<genre>-turn-order` — answers a session event by
2633
+ * Turn order is **state**, not a decision made inside the reply run.
2634
+ * One spec per genre — `core:spec/<genre>-turn-order` — answers a session event by
2625
2635
  * reading the cast and the history, pooling who *may* be seated, ordering
2626
2636
  * them, turning them into entries, and writing the result to
2627
2637
  * `sessions.metadata.turnOrder`. The reply run then fires an entry; it
@@ -2638,9 +2648,9 @@ export const placeAttachments = pin(describeTaskDefinition({
2638
2648
  * - **a strategy** turns candidates into *entries*: who speaks, where, and
2639
2649
  * what to fire. It is the last node before the write.
2640
2650
  *
2641
- * ⚠ **No `speaker` in-port, and no halt** (§4.4, §6). An explicit pick never
2642
- * enters a strategy — a person's pick is fired directly (`fireTurnEntry`,
2643
- * §4.6) and the next recompute sees the row it produced — and a strategy
2651
+ * ⚠ **No `speaker` in-port, and no halt**. An explicit pick never
2652
+ * enters a strategy — a person's pick is fired directly (`fireTurnEntry`)
2653
+ * and the next recompute sees the row it produced — and a strategy
2644
2654
  * that seats nobody publishes an **empty order**, which is an answer. The
2645
2655
  * halt (`nobody is due`) and the `characterId` port went with the decider
2646
2656
  * they belonged to.
@@ -2675,7 +2685,7 @@ const turnStrategy = (id, label, extras = {}) => describeTaskDefinition({
2675
2685
  * in candidate order. A character spoke when a non-hidden, non-narrator row
2676
2686
  * after the last user row carries its id; an envoy when `metadata.speaker`
2677
2687
  * carries its reference; a persona when a user row carries its `personaId`
2678
- * — which is how a session knows it is the person's turn (R15).
2688
+ * — which is how a session knows it is the person's turn.
2679
2689
  * @experimental
2680
2690
  */
2681
2691
  export const turnRoundRobin = pin(turnStrategy('core:task/turn-round-robin@1', 'Round robin'));
@@ -2683,7 +2693,7 @@ export const turnRoundRobin = pin(turnStrategy('core:task/turn-round-robin@1', '
2683
2693
  * A seeded uniform pick over the not-yet-spoken candidates — one entry.
2684
2694
  * `declaresRandomness`, so a replayed run re-rolls identically; an
2685
2695
  * unrelated recompute may roll differently, which is documented rather than
2686
- * prevented (§4.4).
2696
+ * prevented.
2687
2697
  * @experimental
2688
2698
  */
2689
2699
  export const turnRandom = pin(turnStrategy('core:task/turn-random@1', 'Random', {
@@ -2728,7 +2738,7 @@ export const turnManual = pin(turnStrategy('core:task/turn-manual@1', 'Manual'))
2728
2738
  */
2729
2739
  export const turnNarrator = pin(turnStrategy('core:task/turn-narrator@1', 'Narrator replies'));
2730
2740
  /**
2731
- * The pool (§4.4): who *may* be seated this recompute, from the settings
2741
+ * The pool: who *may* be seated this recompute, from the settings
2732
2742
  * document's cast and the history.
2733
2743
  *
2734
2744
  * Its four params are the whole of a genre's or a session's say over
@@ -2839,7 +2849,7 @@ export const turnPool = pin(describeTaskDefinition({
2839
2849
  },
2840
2850
  ports: {
2841
2851
  in: {
2842
- /** The settings document's cast, envoys included (§4.12). */
2852
+ /** The settings document's cast, envoys included. */
2843
2853
  cast: S.sessionCast,
2844
2854
  /** The session's visible history, ascending. */
2845
2855
  messages: S.messages,
@@ -2848,7 +2858,7 @@ export const turnPool = pin(describeTaskDefinition({
2848
2858
  },
2849
2859
  }));
2850
2860
  /**
2851
- * The first orderer (R8): mentioned candidates sort to the front.
2861
+ * The first orderer: mentioned candidates sort to the front.
2852
2862
  *
2853
2863
  * A composable node rather than a seventh strategy, because "who was named"
2854
2864
  * and "whose turn it is" are two questions — a session can have the
@@ -2889,7 +2899,64 @@ export const turnMentioned = pin(describeTaskDefinition({
2889
2899
  },
2890
2900
  }));
2891
2901
  /**
2892
- * Tool calling's two pure halves (20 §9). A *tool* is any same-shaped
2902
+ * Card strokes — marks each keyword stroke fired or not against the recent
2903
+ * transcript; never ranks, never budgets.
2904
+ *
2905
+ * A card painted in strokes (`strokes.ts`) carries keyword strokes: prose that
2906
+ * belongs in the prompt only when one of its keys was said. Unrun, every
2907
+ * enabled stroke is in — the card's cached `description`/`personality` — and
2908
+ * nothing is lost but room. Placed before the context builder, this stamps
2909
+ * `fired` on every stroke of every cast member (`resolveStrokes`), and the
2910
+ * builder then compiles `always` + fired ones only and puts the resolved list
2911
+ * on the card (`core:var/characters@1`'s optional `strokes`).
2912
+ *
2913
+ * The host answers each keyword condition with the lore keyword **matcher**
2914
+ * — the same match modes and regex time limit, one matcher at the seam — but
2915
+ * a stroke is not a lorebook entry: it never reaches the ranker, the lore
2916
+ * budget or `select`, and never competes with lore for room.
2917
+ *
2918
+ * `cast` in, `cast` out, so it slots between the cast read and the builder
2919
+ * without either changing; a card with no strokes passes through as it came.
2920
+ * The window is the last `scanDepth` rows of `messages`, defaulting to the
2921
+ * lore scan's 10 for the reason given there: a round grows with the cast.
2922
+ * Pure — the explicit step "no magic in core" asks for, placed in a spec.
2923
+ *
2924
+ * ⏸ Paused 2026-10-11 (owner): no core spec places this step and the app hides strokes behind `STROKES_ENABLED`; kept so stored documents and the registry hash stay stable.
2925
+ * @experimental
2926
+ */
2927
+ export const cardStrokes = pin(describeTaskDefinition({
2928
+ id: 'core:task/card-strokes@1',
2929
+ i18n: {
2930
+ name: { en: 'Card strokes' },
2931
+ description: {
2932
+ en: 'Marks each keyword stroke fired or not against the recent transcript; never ranks, never budgets.',
2933
+ },
2934
+ },
2935
+ timeoutMs: 1000,
2936
+ slots: {
2937
+ params: {
2938
+ kind: 'parameters',
2939
+ facet: 'behavior',
2940
+ schema: {
2941
+ scanDepth: {
2942
+ type: 'integer',
2943
+ default: 10,
2944
+ min: 1,
2945
+ label: { en: 'Messages scanned for stroke keywords' },
2946
+ description: {
2947
+ en: "How many recent messages are read for a keyword stroke's keys.",
2948
+ },
2949
+ },
2950
+ },
2951
+ },
2952
+ },
2953
+ ports: {
2954
+ in: { cast: S.sessionCast, messages: S.messages },
2955
+ out: { main: S.sessionCast, cast: S.sessionCast },
2956
+ },
2957
+ }));
2958
+ /**
2959
+ * Tool calling's two pure halves. A *tool* is any same-shaped
2893
2960
  * provider — a sandboxed plugin hook canonically — and these tasks only
2894
2961
  * decide how the model learns about it and how its answer is read back.
2895
2962
  * Between them sits the ordinary generate step; around them sits the loop
@@ -2987,7 +3054,7 @@ export const joinText = pin(describeTaskDefinition({
2987
3054
  }));
2988
3055
  /**
2989
3056
  * A document's lists, as one **folded section** a reply carries collapsed
2990
- * (lair pass B5, decision D5, 2026-09-27).
3057
+ * (2026-09-27).
2991
3058
  *
2992
3059
  * The producer the message outlets' `sections` in-port was built for: a
2993
3060
  * planner's document is structure, and the person reading the reply wants its
@@ -3035,7 +3102,7 @@ export const listSection = pin(describeTaskDefinition({
3035
3102
  sections: S.foldedSections,
3036
3103
  /**
3037
3104
  * The same lines as a markdown list, one `- ` item per line
3038
- * (lair pass R8, 2026-09-28) — for a message whose BODY is the
3105
+ * (2026-09-28) — for a message whose BODY is the
3039
3106
  * list: the Lair's beats row in the Sanctum. Empty when
3040
3107
  * nothing was listed.
3041
3108
  */
@@ -3044,8 +3111,8 @@ export const listSection = pin(describeTaskDefinition({
3044
3111
  },
3045
3112
  }));
3046
3113
  /**
3047
- * A list, split into its **first** item and the **rest**, in order (lair pass
3048
- * R8, 2026-09-28).
3114
+ * A list, split into its **first** item and the **rest**, in order
3115
+ * (2026-09-28).
3049
3116
  *
3050
3117
  * A data reference is `{node, port}` with no sub-path, and `parse-json@1`'s
3051
3118
  * `path` selects a key or an index but never a tail — so a spec that treats
@@ -3254,14 +3321,14 @@ export const makeChoices = pin(describeTaskDefinition({
3254
3321
  /**
3255
3322
  * What the question is about, by name — stamped on the block
3256
3323
  * as its `referent` and handed back by `read-answer@1` to the
3257
- * run the press fires (lair pass B12, 2026-09-27: the room the
3324
+ * run the press fires (2026-09-27: the room the
3258
3325
  * party knocked at). Blank or absent writes none.
3259
3326
  */
3260
3327
  referent: S.text,
3261
3328
  /**
3262
3329
  * Where the question was asked **from**, by name — stamped on
3263
3330
  * the block as its `vantage` and handed back by
3264
- * `read-answer@1`, beside `referent` (plan A27, 2026-09-30:
3331
+ * `read-answer@1`, beside `referent` (2026-09-30:
3265
3332
  * the room the Lair's planner said the party stood in as
3266
3333
  * they knocked). JSON because it is usually read off a
3267
3334
  * model's document (`parse-json@1`'s `value`); anything but
@@ -3306,7 +3373,7 @@ export const readAnswer = pin(describeTaskDefinition({
3306
3373
  question: S.text,
3307
3374
  /**
3308
3375
  * What the question was about, by name — the block's
3309
- * `referent`, as the asking run stamped it (lair pass B12);
3376
+ * `referent`, as the asking run stamped it;
3310
3377
  * empty when it named nothing, never null, so a write wired
3311
3378
  * to it still offers the field at its review gate (a review
3312
3379
  * form shows only the fields a payload carries).
@@ -3314,7 +3381,7 @@ export const readAnswer = pin(describeTaskDefinition({
3314
3381
  referent: S.text,
3315
3382
  /**
3316
3383
  * Where the question was asked from, by name — the block's
3317
- * `vantage`, as the asking run stamped it (plan A27); null
3384
+ * `vantage`, as the asking run stamped it; null
3318
3385
  * when it named nowhere.
3319
3386
  */
3320
3387
  vantage: S.json,
@@ -3332,7 +3399,7 @@ export const readAnswer = pin(describeTaskDefinition({
3332
3399
  * first parameter a user with long posts reaches for.
3333
3400
  * @internal
3334
3401
  */
3335
- export const batchMessages = pin(describeTaskDefinition({
3402
+ const batchMessagesAt1 = pin(describeTaskDefinition({
3336
3403
  id: 'core:task/batch-messages@1',
3337
3404
  i18n: { name: { en: 'Batch messages' } },
3338
3405
  timeoutMs: 2000,
@@ -3342,7 +3409,7 @@ export const batchMessages = pin(describeTaskDefinition({
3342
3409
  * that the drafting step generates against.
3343
3410
  *
3344
3411
  * The context window belongs to the sampling config, never to a knob
3345
- * on a node (17 §1a), and the executor resolves a `sampling` slot to
3412
+ * on a node, and the executor resolves a `sampling` slot to
3346
3413
  * the config's switched-on *values* — so this stays a pure Task
3347
3414
  * reading data it was handed rather than a Query looking one up. Same
3348
3415
  * shape and same reason as `core:task/context-budget@1`.
@@ -3406,6 +3473,174 @@ export const batchMessages = pin(describeTaskDefinition({
3406
3473
  out: { main: S.drafts, batches: S.drafts },
3407
3474
  },
3408
3475
  }));
3476
+ /**
3477
+ * 🚧 What a genre's **transcript template** may read, section by section
3478
+ * (live scenes §12.1/§14). The template is one Handlebars source holding
3479
+ * three inline partials — `{{#*inline "preamble"}}`, `{{#*inline "line"}}`
3480
+ * and `{{#*inline "aside"}}` — and the binding renders each on its own:
3481
+ * `preamble` once, `line` per story message, `aside` per aside row. Text
3482
+ * outside the three partials is never rendered. A section the template does
3483
+ * not define falls back to the shipped Default's.
3484
+ */
3485
+ const TRANSCRIPT_TEMPLATE_SCOPE = {
3486
+ scene: {
3487
+ type: 'object',
3488
+ optional: true,
3489
+ description: 'The scene, in `preamble`: its name, place and date when the host knows them.',
3490
+ fields: {
3491
+ name: { type: 'string', optional: true },
3492
+ place: { type: 'string', optional: true },
3493
+ date: { type: 'string', optional: true },
3494
+ },
3495
+ },
3496
+ cast: {
3497
+ type: 'list',
3498
+ description: 'Who was present, in `preamble`, by name.',
3499
+ of: { type: 'object', fields: { name: { type: 'string' } } },
3500
+ },
3501
+ messageId: { type: 'number', description: 'In `line` and `aside`: the message this unit renders.' },
3502
+ name: { type: 'string', description: 'In `line` and `aside`: who wrote the line, as the session names them.' },
3503
+ role: { type: 'string', description: "In `line` and `aside`: 'user', 'assistant' or 'system'." },
3504
+ text: { type: 'string', description: "In `line` and `aside`: the message's text." },
3505
+ attachments: {
3506
+ type: 'string',
3507
+ description: "In `line` and `aside`: the files the message shows, each named on a line of its own — `[image: cat.png — a grey cat]`, `[file: notes.txt]` — carrying its own leading line break when the message has text, so it renders straight after `{{{text}}}`, as `place-attachments@1`'s does. Empty when the message shows none. A summary is drafted from text, so a file reaches it as its name.",
3508
+ },
3509
+ channel: { type: 'string', description: 'In `aside`: the channel the row was written on — `sanctum`, `sanctum:2`.' },
3510
+ };
3511
+ /**
3512
+ * 🚧 Lay a scene's messages out as text, one **transcript unit** per message
3513
+ * — the genre's own words for what a line and an aside look like (live
3514
+ * scenes §12.1, §14, 2026-10-13).
3515
+ *
3516
+ * ## Why a template, and why it is the spec's
3517
+ *
3518
+ * A summary of the Lair has to say the Sanctum is talk the party never hear;
3519
+ * a summary of Chat has nothing to say about it. That difference is
3520
+ * presentation, so it is a template on this node's `template` slot, and the
3521
+ * shipped template is the summarize-scene spec's Default — a genre ships its
3522
+ * own by building its spec with `summarizeScene(…, { transcript })`, and an
3523
+ * admin edits it in the Pipelines view like any other template.
3524
+ *
3525
+ * ## The outlet
3526
+ *
3527
+ * `preamble` — the rendered `preamble` section, once. `units` — every
3528
+ * story line and aside in reading order (each aside after the story line it
3529
+ * is attached to), `{ messageId, text, tokens }`: the batch cut needs the
3530
+ * count, and the message id is what makes a draft traceable to its rows.
3531
+ * Pure: no model, no write. An empty span renders an empty `units`.
3532
+ * @experimental
3533
+ */
3534
+ export const renderTranscript = pin(describeTaskDefinition({
3535
+ id: 'core:task/render-transcript@1',
3536
+ i18n: { name: { en: 'Lay out the transcript' } },
3537
+ timeoutMs: 2000,
3538
+ slots: {
3539
+ template: {
3540
+ kind: 'template',
3541
+ acceptedEngines: [handlebars.id],
3542
+ facet: 'templates',
3543
+ variables: TRANSCRIPT_TEMPLATE_SCOPE,
3544
+ description: 'How the transcript a summary is drafted from reads: three sections — the preamble, a story line, and an aside. Leave empty to use the built-in layout.',
3545
+ },
3546
+ },
3547
+ ports: {
3548
+ in: {
3549
+ /** The story's rows (`summarize-source@2`'s `messages`). */
3550
+ messages: S.messages,
3551
+ /** The aside rows (`summarize-source@2`'s `asides`). */
3552
+ asides: S.messages,
3553
+ /**
3554
+ * The files by message, from `core:query/history-attachments@1`
3555
+ * over the story rows — `batch-messages@1`'s port, for its
3556
+ * reason: a message that is only a picture still reaches the
3557
+ * draft as something. Each story line's files are named into
3558
+ * the `line` section's `attachments`. Unwired, or a message
3559
+ * with no files, and the line renders as it would without.
3560
+ */
3561
+ attachments: S.mediaByMessage,
3562
+ /**
3563
+ * 🚧 The aside rows' files by message, from a second
3564
+ * `core:query/history-attachments@1` over the asides (lane
3565
+ * E): each aside's files are named into the `aside`
3566
+ * section's `attachments`. Unwired, an aside renders as it
3567
+ * would without.
3568
+ */
3569
+ asideAttachments: S.mediaByMessage,
3570
+ /** Who was present — the session's cast read. */
3571
+ cast: S.sessionCast,
3572
+ /**
3573
+ * The scene being summarized: its name, place and date where the
3574
+ * host knows them. Wired to the summarize request in the shipped
3575
+ * specs; the binding reads the request's `scene` field.
3576
+ */
3577
+ scene: S.json,
3578
+ },
3579
+ out: {
3580
+ main: S.transcriptUnits,
3581
+ preamble: S.text,
3582
+ units: S.transcriptUnits,
3583
+ },
3584
+ },
3585
+ }));
3586
+ /**
3587
+ * 🚧 Cut a rendered transcript into batches a model can hold — `@1`'s cut,
3588
+ * over **text** (live scenes §14, 2026-10-13).
3589
+ *
3590
+ * `@1` cuts message rows and formats them itself; this one is handed units the
3591
+ * transcript template already laid out, counts each unit's `tokens`, and opens
3592
+ * every batch with the `preamble` so each draft knows the scene it is in. A
3593
+ * unit is never split. Out: `batches`, one string per batch, in order. An
3594
+ * empty `units` cuts to no batches. `@1` stays for the shared summarize specs.
3595
+ * @experimental
3596
+ */
3597
+ const batchMessagesAt2 = pin(describeTaskDefinition({
3598
+ id: 'core:task/batch-messages@2',
3599
+ i18n: { name: { en: 'Batch the transcript' } },
3600
+ timeoutMs: 2000,
3601
+ slots: {
3602
+ /**
3603
+ * The window the cut is clamped to — wired by REFERENCE to the
3604
+ * drafting step's sampling, for `@1`'s reason: a batch cut against
3605
+ * one window and drafted against another overflows silently.
3606
+ */
3607
+ sampling: { kind: 'sampling', quick: true },
3608
+ params: {
3609
+ kind: 'parameters',
3610
+ facet: 'weights',
3611
+ schema: {
3612
+ batchTokens: {
3613
+ type: 'integer',
3614
+ default: 2560,
3615
+ label: { en: 'How much chat each batch holds' },
3616
+ description: {
3617
+ en: 'Tokens of transcript one summary draft is written from. Capped by the drafting step\u2019s Context Tokens, less room for the prompt and the draft itself.',
3618
+ },
3619
+ },
3620
+ minBatchMessages: {
3621
+ type: 'integer',
3622
+ default: 1,
3623
+ description: 'Never cut a batch smaller than this many messages.',
3624
+ },
3625
+ },
3626
+ },
3627
+ },
3628
+ ports: {
3629
+ in: { preamble: S.text, units: S.transcriptUnits },
3630
+ out: { main: S.drafts, batches: S.drafts },
3631
+ },
3632
+ }));
3633
+ /**
3634
+ * Cut a summary's material into batches — both pins on one export (04 §4b):
3635
+ * `C.batchMessages.v1(…)` cuts message rows, `C.batchMessages.v2(…)` cuts a
3636
+ * rendered transcript. `id` and `descriptor` stay `@1`'s; `@2`'s descriptor
3637
+ * rides its constructor (`typeof C.batchMessages.v2` types a binding).
3638
+ * @internal
3639
+ */
3640
+ export const batchMessages = {
3641
+ ...batchMessagesAt1,
3642
+ v2: Object.assign(batchMessagesAt2.v2, { descriptor: batchMessagesAt2.descriptor }),
3643
+ };
3409
3644
  // ── Stats and states ────────────────────────────────────────────────────────
3410
3645
  /** @experimental */
3411
3646
  export const setState = pin(describeTaskDefinition({
@@ -3444,13 +3679,19 @@ export const setState = pin(describeTaskDefinition({
3444
3679
  // [{ owner: { kind, id }, slotId, value, base? } | { owner, entryId, delta, base? }]
3445
3680
  // `scope` is what says which session, and therefore which message a
3446
3681
  // change is anchored to — a change with no anchor is one a swipe
3447
- // could not take back.
3682
+ // could not take back. 🚧 A clock line `{ kind: 'clock', by, unit }`
3683
+ // (★3) is held by `propose` as a clock proposal and passed over by
3684
+ // `apply` — see `resolve-state-changes@1`'s `clock` out-port. One
3685
+ // marked `skipped` (a sentence: the story has no clock to take it,
3686
+ // live scenes §15 G16) is written to the session's ledger as a
3687
+ // skipped clock move in either mode — never proposed, never moved
3688
+ // — and its row id rides `main.skipped`.
3448
3689
  in: {
3449
3690
  changes: S.json,
3450
3691
  scope: S.sessionScope,
3451
3692
  /**
3452
- * The **state version** the changes are deltas against (plans/29
3453
- * R-15 *Staleness and order*; U5f) — the session-state query's
3693
+ * The **state version** the changes are deltas against — the
3694
+ * session-state query's
3454
3695
  * `version`, for every change that does not carry its own
3455
3696
  * `base`. In `apply` mode a base behind the current version is
3456
3697
  * **rebased**: a change whose slot is untouched since the base
@@ -3463,8 +3704,8 @@ export const setState = pin(describeTaskDefinition({
3463
3704
  */
3464
3705
  base: S.json,
3465
3706
  /**
3466
- * **The row the WORLD's changes are filed at** (lair pass R8,
3467
- * 2026-09-28): a message this run wrote earlier, as that
3707
+ * **The row the WORLD's changes are filed at** (2026-09-28): a
3708
+ * message this run wrote earlier, as that
3468
3709
  * write's result. Optional, and only for world-owned changes
3469
3710
  * (the session and its places); a cast member's change still
3470
3711
  * files at that member's own latest line (the turn lock).
@@ -3489,12 +3730,12 @@ export const setState = pin(describeTaskDefinition({
3489
3730
  },
3490
3731
  }));
3491
3732
  /**
3492
- * A room name, unless something already describes it (lair pass R7,
3493
- * 2026-09-28; replaced `core:task/unlisted-name@1`).
3733
+ * A room name, unless something already describes it (2026-09-28; replaced
3734
+ * `core:task/unlisted-name@1`).
3494
3735
  *
3495
3736
  * The Lair's planner names the room the party are about to walk into when it
3496
3737
  * thinks nobody has built it, and the turn stops to ask the dungeon's master
3497
- * to describe it (owner ruling 2, 2026-09-28: *ask, unless it is already
3738
+ * to describe it (owner ruling, 2026-09-28: *ask, unless it is already
3498
3739
  * described in prose or the lorebook*). This is the deterministic check after
3499
3740
  * the planner's judgement. Lookups, in order; the first hit wins:
3500
3741
  *
@@ -3523,7 +3764,7 @@ export const setState = pin(describeTaskDefinition({
3523
3764
  * hard-codes a genre's slug: a spec that wants a side channel's prose to count
3524
3765
  * reads it and names it here.
3525
3766
  *
3526
- * ## Which room is this one (places plan B6, 2026-09-29)
3767
+ * ## Which room is this one (2026-09-29)
3527
3768
  *
3528
3769
  * The same lookup answers the Lair's other question: *which room do the party
3529
3770
  * stand in?* — the world's `location` stat, resolved against the rooms, so
@@ -3539,7 +3780,7 @@ export const setState = pin(describeTaskDefinition({
3539
3780
  * find a namesake. So a value with an `entryId` is answered by the listed
3540
3781
  * entry with that id (`describedBy` `entry`), and by nothing when no
3541
3782
  * listing holds it — archived, or hidden from this read.
3542
- * - **`fallbackName`** (plan A27, 2026-09-30): what to look for when `name`
3783
+ * - **`fallbackName`** (2026-09-30): what to look for when `name`
3543
3784
  * (at `path`) names nothing — for the Lair, the room its planner said the
3544
3785
  * party stood in as they knocked (the knock's `vantage`). The world's
3545
3786
  * value wins and the hint stands in only while it names nothing: the
@@ -3598,8 +3839,8 @@ export const undescribedName = pin(describeTaskDefinition({
3598
3839
  },
3599
3840
  },
3600
3841
  /**
3601
- * Where the name is inside `name`, as a dotted path (places
3602
- * plan B6) — the Lair reads `world.location` off a
3842
+ * Where the name is inside `name`, as a dotted path — the
3843
+ * Lair reads `world.location` off a
3603
3844
  * session-state document. Empty reads `name` itself.
3604
3845
  */
3605
3846
  path: {
@@ -3621,7 +3862,7 @@ export const undescribedName = pin(describeTaskDefinition({
3621
3862
  * `value`), or a document holding it at `path`; anything but a
3622
3863
  * string is no name, and nothing is undescribed — save a lore
3623
3864
  * reference (`{ entryId }`), which is the listed entry it
3624
- * references (B6).
3865
+ * references.
3625
3866
  */
3626
3867
  name: S.json,
3627
3868
  /**
@@ -3689,8 +3930,9 @@ export const undescribedName = pin(describeTaskDefinition({
3689
3930
  *
3690
3931
  * A spec wires `$.input.sessionScope` (or a literal) — something durable. The
3691
3932
  * run's seed is a different string every turn and a pick keyed on it would
3692
- * move between two questions. It is `scopeKey` and not `key` (R3, named
3693
- * 2026-09-17, before anything shipped): *key* alone is the option key on a
3933
+ * move between two questions. It is `scopeKey` and not `key` (a qualified
3934
+ * name, never the bare noun; named 2026-09-17, before anything shipped):
3935
+ * *key* alone is the option key on a
3694
3936
  * choice, the identity a candidate is scored under, and a settings field's
3695
3937
  * name, and this port is none of them — it is the scope the pick is made
3696
3938
  * within.
@@ -3770,7 +4012,7 @@ export const pickByHash = pin(describeTaskDefinition({
3770
4012
  /**
3771
4013
  * Where it sat in the list **as handed in**, not among the
3772
4014
  * identifiable entries. `pickIndex` rather than `index`
3773
- * (R3): a bare *index* is a database index, a message's
4015
+ * (qualified, never the bare noun): a bare *index* is a database index, a message's
3774
4016
  * position and a list offset all at once.
3775
4017
  */
3776
4018
  pickIndex: S.json,
@@ -3799,7 +4041,7 @@ export const pickByHash = pin(describeTaskDefinition({
3799
4041
  *
3800
4042
  * ## The key is a participant reference
3801
4043
  *
3802
- * `character:<id>`, the reference vocabulary (R-18 (3)) — not a name, which
4044
+ * `character:<id>`, the reference vocabulary — not a name, which
3803
4045
  * two cast members can share and an author can edit, and not a bare id, which
3804
4046
  * says nothing about what it identifies. It survives the round trip: the key
3805
4047
  * lands on the pressed option, `core:task/read-answer@1` publishes it as
@@ -3847,7 +4089,7 @@ export const castChoices = pin(describeTaskDefinition({
3847
4089
  /**
3848
4090
  * Which half of the room to leave out.
3849
4091
  *
3850
- * A persona is a character the player voices (0132), so
4092
+ * A persona is a character the player voices, so
3851
4093
  * both halves are cast members and which one a question
3852
4094
  * is about depends entirely on the question: *who do you
3853
4095
  * accuse* is asked about the suspects and must not offer
@@ -3915,7 +4157,7 @@ export const castChoices = pin(describeTaskDefinition({
3915
4157
  * ## The gap it closes
3916
4158
  *
3917
4159
  * A junction branches on **one** port, and `equalsPath` compares two paths of
3918
- * **one** document (D-4a). So the grammar can ask *is the accused the culprit?*
4160
+ * **one** document. So the grammar can ask *is the accused the culprit?*
3919
4161
  * only once something has put the accused and the culprit in the same
3920
4162
  * document, and nothing in core did: no task merged two json ports, and the
3921
4163
  * obvious repair — a second in-port on the junction — is not a repair, it is a
@@ -4008,4 +4250,405 @@ export const pair = pin(describeTaskDefinition({
4008
4250
  },
4009
4251
  }));
4010
4252
  // ── Contracts batch 2: the two-document pair ────────────────────── end ──────
4253
+ // ── Pictures: the cut-out (image generation I4, 2026-10-12) ────────────────
4254
+ /**
4255
+ * 🚧 Each picture, with its background removed — a **cut-out**.
4256
+ *
4257
+ * The step after `core:oracle/generate-image@1` when the pair could not draw a
4258
+ * transparent background itself (`cutOut: native-or-task`). The host runs a
4259
+ * local matting model (BiRefNet-lite, ONNX) over each picture and stores the
4260
+ * result as a new PNG with an alpha channel; the source picture is left as it
4261
+ * was.
4262
+ *
4263
+ * ## Same list in, same list out
4264
+ *
4265
+ * One item out per item in, in order. An item that was cut out is replaced by
4266
+ * a reference to its cut-out; every other field the item carried — its series
4267
+ * `key` included — travels across unchanged, so a keyed outlet downstream
4268
+ * files each cut-out under the label it was drawn for. An item that is not an
4269
+ * image passes through untouched.
4270
+ *
4271
+ * ## `mode`
4272
+ *
4273
+ * - `auto` (default) skips a picture that already has a transparent
4274
+ * background: its media meta says `transparent: 'native'` (the pair drew
4275
+ * it), it is itself a cut-out (`cutOutOf`), or its pixels already carry
4276
+ * transparency.
4277
+ * - `always` cuts every picture out, whatever it says about itself.
4278
+ * - `off` hands the list on unchanged — the switch a spec author flips to see
4279
+ * the raw pictures without rewiring.
4280
+ *
4281
+ * Pure given its input: the same pictures make the same cut-outs (the media
4282
+ * store dedupes identical bytes). The first run on a machine downloads the
4283
+ * matting model once, which is why the timeout is idle rather than wall.
4284
+ * @experimental
4285
+ */
4286
+ export const cutOut = pin(describeTaskDefinition({
4287
+ id: 'core:task/cut-out@1',
4288
+ i18n: {
4289
+ name: { en: 'Cut out' },
4290
+ description: {
4291
+ en: 'Removes the background from each picture, leaving it transparent. Downloads a small background-removal model the first time.',
4292
+ },
4293
+ },
4294
+ timeoutMs: 120000,
4295
+ timeoutKind: 'idle',
4296
+ slots: {
4297
+ params: {
4298
+ kind: 'parameters',
4299
+ schema: {
4300
+ mode: {
4301
+ type: 'enum',
4302
+ of: ['auto', 'always', 'off'],
4303
+ members: [
4304
+ {
4305
+ key: 'auto',
4306
+ label: { en: 'When needed' },
4307
+ description: { en: 'Skips pictures that already have a transparent background.' },
4308
+ },
4309
+ {
4310
+ key: 'always',
4311
+ label: { en: 'Always' },
4312
+ description: { en: 'Cuts every picture out, even one that is already transparent.' },
4313
+ },
4314
+ {
4315
+ key: 'off',
4316
+ label: { en: 'Off' },
4317
+ description: { en: 'Hands the pictures on unchanged.' },
4318
+ },
4319
+ ],
4320
+ default: 'auto',
4321
+ quick: true,
4322
+ description: 'Which pictures get their background removed.',
4323
+ },
4324
+ },
4325
+ },
4326
+ },
4327
+ ports: {
4328
+ in: { media: S.mediaList },
4329
+ out: { main: S.mediaList, media: S.mediaList },
4330
+ },
4331
+ }));
4332
+ // ── Pictures: the sprite series (image generation I5, 2026-10-12) ──────────
4333
+ /**
4334
+ * 🚧 The pictures a **Sprite set fill** asks for — one image series item per
4335
+ * sprite label.
4336
+ *
4337
+ * Each item is `{ key, vars }`:
4338
+ *
4339
+ * - `key` is the label made filename-safe (trimmed, case-folded, spaces to
4340
+ * `-`, anything else dropped, collisions suffixed `joy`, `joy-2`). A key
4341
+ * is an address, never prose: the picture's description comes from
4342
+ * `vars.labelPhrase`, never from the key.
4343
+ * - `vars.label` is the sprite label as the card spells it, which is what
4344
+ * `core:outlet/attach-sprite@1` files the picture under.
4345
+ * - `vars.labelPhrase` is the label's **sprite label phrase** — the
4346
+ * `phrases` prompt field, one `label: phrase` per line (*Sprite label
4347
+ * phrases*, editable like any prompt row). A label with no line falls back
4348
+ * to the label word itself.
4349
+ * - `vars.likeness` / `vars.likenessNegative` carry the card's likeness, so
4350
+ * the picture step's prompt rows can say `{{likeness}}` per item.
4351
+ *
4352
+ * The phrases and the sprite picker's labels stay two vocabularies, never
4353
+ * merged: the picker never reads a phrase. Pure given its input — no read, no call.
4354
+ * @experimental
4355
+ */
4356
+ export const buildSpriteSeries = pin(describeTaskDefinition({
4357
+ id: 'core:task/build-sprite-series@1',
4358
+ i18n: {
4359
+ name: { en: 'Sprite series' },
4360
+ description: {
4361
+ en: 'Turns the sprite labels to draw into one picture request each, with a short description of each expression.',
4362
+ },
4363
+ },
4364
+ timeoutMs: 5000,
4365
+ slots: {
4366
+ prompts: {
4367
+ kind: 'prompts',
4368
+ quick: true,
4369
+ facet: 'prompts',
4370
+ description: 'How each sprite label is described to the picture model: one "label: phrase" per line.',
4371
+ fields: {
4372
+ phrases: { type: 'text' },
4373
+ },
4374
+ },
4375
+ },
4376
+ ports: {
4377
+ in: {
4378
+ /** The sprite labels to draw, as the card spells them. */
4379
+ labels: S.json,
4380
+ likeness: S.text,
4381
+ likenessNegative: S.text,
4382
+ },
4383
+ out: {
4384
+ main: S.imageSeries,
4385
+ series: S.imageSeries,
4386
+ /** The labels kept, in order — blanks and repeats dropped. */
4387
+ labels: S.json,
4388
+ },
4389
+ },
4390
+ }));
4391
+ // ── Pictures: proofs (image generation I8, 2026-10-12) ─────────────────────
4392
+ /**
4393
+ * 🚧 **Proofs** — *n* identical pictures to choose from, as an image
4394
+ * series. A photographer's proof prints: the
4395
+ * same shot several times, one kept. Not a retrieval **candidate**, which is
4396
+ * something that might reach a prompt.
4397
+ *
4398
+ * Each item is `{ key, vars: {} }` with keys `"1"` … `"n"`: the same picture
4399
+ * asked for *n* times, so every item renders the same prompt. That sameness
4400
+ * is what lets the host pack the series as ONE batch call on a pair whose
4401
+ * drawing sheet takes `perCall ≥ n` (a hosted API's `n`, a ComfyUI graph's
4402
+ * batch size); a pair that draws one picture per call loops. The spec never
4403
+ * knows which.
4404
+ *
4405
+ * `count` is read as a whole number and clamped to 1–8 (the default
4406
+ * `seriesMax`); anything that is not a number is 1. The Portrait form offers
4407
+ * 1–4. Pure given its input — no read, no call.
4408
+ * @experimental
4409
+ */
4410
+ export const buildProofs = pin(describeTaskDefinition({
4411
+ id: 'core:task/build-proofs@1',
4412
+ i18n: {
4413
+ name: { en: 'Proofs' },
4414
+ description: {
4415
+ en: 'Asks for the same picture several times, so there are a few to choose from.',
4416
+ },
4417
+ },
4418
+ timeoutMs: 5000,
4419
+ ports: {
4420
+ in: {
4421
+ /** How many pictures: a whole number, clamped to 1–8. */
4422
+ count: S.json,
4423
+ },
4424
+ out: {
4425
+ main: S.imageSeries,
4426
+ series: S.imageSeries,
4427
+ },
4428
+ },
4429
+ }));
4430
+ // ── The Scene action (DESIGN-image-generation §6.4, I9, 2026-10-12) ─────────
4431
+ /**
4432
+ * 🚧 A model's reply, cleaned into a picture prompt — the step between the
4433
+ * Scene action's **scene prompt** (a quiet text call asked for a tag list)
4434
+ * and the picture step.
4435
+ *
4436
+ * A text model asked for "a comma-separated tag list and nothing else"
4437
+ * still answers with a fence, a `Prompt:` label, quotes round the whole
4438
+ * line or a list one tag per line. Each is undone here: fences and the
4439
+ * label dropped, wrapping quotes stripped, line breaks and bullets turned
4440
+ * into commas, empty tags and repeated commas and spaces collapsed, a
4441
+ * trailing full stop removed. Prose survives as prose — only its line
4442
+ * breaks become commas. Pure: no read, no model.
4443
+ *
4444
+ * An empty result halts: a picture of nothing is not a picture.
4445
+ * @experimental
4446
+ */
4447
+ export const cleanImagePrompt = pin(describeTaskDefinition({
4448
+ id: 'core:task/clean-image-prompt@1',
4449
+ i18n: {
4450
+ name: { en: 'Clean picture prompt' },
4451
+ description: { en: "Tidies a model's reply into one line a picture model can read." },
4452
+ },
4453
+ timeoutMs: 500,
4454
+ ports: {
4455
+ in: { text: S.text },
4456
+ out: { main: S.text, prompt: S.text },
4457
+ },
4458
+ }));
4459
+ /**
4460
+ * 🚧 Where the Scene action's picture goes — its **placement**: posted as a
4461
+ * message, set as the session's backdrop, or both.
4462
+ *
4463
+ * The `placement` parameter is the admin's (Admin › Pipelines, the Scene
4464
+ * pipeline's config); a press may name its own in its payload
4465
+ * (`{ placement: 'backdrop' }` — the Backdrop widget's *Illustrate*), and a
4466
+ * named one wins. Published as two flags, `message` and `backdrop`, because
4467
+ * a junction branch reads one truthy value: each outlet sits behind its own.
4468
+ * Pure: no read, no model.
4469
+ * @experimental
4470
+ */
4471
+ export const picturePlacement = pin(describeTaskDefinition({
4472
+ id: 'core:task/picture-placement@1',
4473
+ i18n: {
4474
+ name: { en: 'Placement' },
4475
+ description: { en: 'Decides whether the picture is posted, set as the backdrop, or both.' },
4476
+ },
4477
+ timeoutMs: 500,
4478
+ slots: {
4479
+ params: {
4480
+ kind: 'parameters',
4481
+ facet: 'behavior',
4482
+ schema: {
4483
+ placement: {
4484
+ type: 'enum',
4485
+ of: ['message', 'backdrop', 'both'],
4486
+ members: [
4487
+ {
4488
+ key: 'message',
4489
+ label: { en: 'Post it' },
4490
+ description: { en: 'Posts the picture in the session as a message.' },
4491
+ },
4492
+ {
4493
+ key: 'backdrop',
4494
+ label: { en: 'Backdrop' },
4495
+ description: { en: "Sets the picture as the session's backdrop, and posts nothing." },
4496
+ },
4497
+ {
4498
+ key: 'both',
4499
+ label: { en: 'Both' },
4500
+ description: { en: 'Posts the picture and sets it as the backdrop.' },
4501
+ },
4502
+ ],
4503
+ default: 'both',
4504
+ label: { en: 'Placement' },
4505
+ description: 'Where the picture goes. A press that names its own placement uses that.',
4506
+ },
4507
+ },
4508
+ },
4509
+ },
4510
+ ports: {
4511
+ in: {
4512
+ /** The press's payload; its `placement`, when one of the three, wins. */
4513
+ payload: S.json,
4514
+ },
4515
+ out: {
4516
+ main: S.json,
4517
+ /** `message`, `backdrop` or `both` — what was decided. */
4518
+ placement: S.text,
4519
+ /** True when the picture is posted as a message. */
4520
+ message: S.json,
4521
+ /** True when the picture is set as the backdrop. */
4522
+ backdrop: S.json,
4523
+ },
4524
+ },
4525
+ }));
4526
+ /**
4527
+ * 🚧 A **clock step**: how far the story clock moves, decided — `{ by, unit }`
4528
+ * and whether it moves at all (2026-10-13, PROPOSAL-live-scenes §6).
4529
+ *
4530
+ * Two uses, one shape. *Time passes…* hands it the press's collected
4531
+ * `step` (`input.clockStep`), which wins. Chat's reply hands it nothing and
4532
+ * reads its own parameters — **By** (0, the default, is off) and **Unit** —
4533
+ * exposed as the session setting *Each reply advances the clock by …*. Either
4534
+ * way the step publishes `moves` (true when `by` is a whole number other than
4535
+ * zero), and the *Advance story clock* outlet sits behind a junction on it,
4536
+ * so a step of nothing is never written and never refused. Pure: no read, no
4537
+ * model, never the clock itself.
4538
+ * @experimental
4539
+ */
4540
+ export const clockStep = pin(describeTaskDefinition({
4541
+ id: 'core:task/clock-step@1',
4542
+ i18n: {
4543
+ name: { en: 'Clock step' },
4544
+ description: { en: 'Decides how far the story clock moves: a number of minutes, hours, days, months or years.' },
4545
+ },
4546
+ timeoutMs: 500,
4547
+ slots: {
4548
+ params: {
4549
+ kind: 'parameters',
4550
+ facet: 'behavior',
4551
+ schema: {
4552
+ by: {
4553
+ type: 'integer',
4554
+ default: 0,
4555
+ label: { en: 'By' },
4556
+ description: { en: 'How many units the clock moves. 0 moves nothing; negative goes back.' },
4557
+ },
4558
+ unit: {
4559
+ type: 'enum',
4560
+ of: ['minutes', 'hours', 'days', 'months', 'years'],
4561
+ members: [
4562
+ { key: 'minutes', label: { en: 'Minutes' } },
4563
+ { key: 'hours', label: { en: 'Hours' } },
4564
+ { key: 'days', label: { en: 'Days' } },
4565
+ { key: 'months', label: { en: 'Months' } },
4566
+ { key: 'years', label: { en: 'Years' } },
4567
+ ],
4568
+ default: 'minutes',
4569
+ label: { en: 'Unit' },
4570
+ description: { en: 'What to count.' },
4571
+ },
4572
+ },
4573
+ },
4574
+ },
4575
+ ports: {
4576
+ in: {
4577
+ /** A collected step, `{ by, unit }` — wins over the parameters when it reads. */
4578
+ step: S.json,
4579
+ /**
4580
+ * When truthy, the clock does not move (`moves` false). Chat's
4581
+ * reply wires the row it re-drives (`input.messageId`), so a
4582
+ * regenerate, a swipe or an extend never ticks the clock twice.
4583
+ */
4584
+ unless: S.json,
4585
+ },
4586
+ out: {
4587
+ main: S.json,
4588
+ /** True when the clock moves: `by` is a whole number other than zero. */
4589
+ moves: S.json,
4590
+ /** The signed amount — what *Advance story clock* takes on its `by` port. */
4591
+ by: S.json,
4592
+ /** The unit — what *Advance story clock* takes on its `unit` port. */
4593
+ unit: S.text,
4594
+ },
4595
+ },
4596
+ }));
4597
+ /**
4598
+ * **Run a script** — the script step (2026-10-12).
4599
+ *
4600
+ * The node itself does nothing: it passes its input through to `main`, and
4601
+ * the `core:script:data/transform@1` scripts attached after `main` transform
4602
+ * it in order, each handed the value the one before returned. That is what
4603
+ * lets an admin write a custom task in-app without a plugin — the body is a
4604
+ * sandboxed script, the contract is JSON in, JSON out.
4605
+ * @experimental
4606
+ */
4607
+ export const runScript = pin(describeTaskDefinition({
4608
+ id: 'core:task/run-script@1',
4609
+ i18n: {
4610
+ name: { en: 'Run a script' },
4611
+ description: {
4612
+ en: 'Passes its input through; the scripts attached after it transform the value, each handed what the one before returned.',
4613
+ },
4614
+ },
4615
+ timeoutMs: 2000,
4616
+ slots: {
4617
+ scripts: {
4618
+ kind: 'scripts',
4619
+ accepts: ['core:script:data/transform@1'],
4620
+ port: 'main',
4621
+ phase: 'after',
4622
+ description: 'The script, or scripts, this step runs over its input. Each is handed the value the one before returned.',
4623
+ },
4624
+ /**
4625
+ * The time each script in the chain may take.
4626
+ * Read by the HOST's script applier off the scope chain, not by the
4627
+ * binding — the binding never sees the chain. A script past it is
4628
+ * stopped and recorded `err` with the time in its reason, and the
4629
+ * value it was handed goes on. Unset, the seam default applies (the
4630
+ * same 250 ms).
4631
+ */
4632
+ params: {
4633
+ kind: 'parameters',
4634
+ facet: 'weights',
4635
+ schema: {
4636
+ budgetMs: {
4637
+ type: 'integer',
4638
+ min: 1,
4639
+ max: 1000,
4640
+ default: 250,
4641
+ label: { en: 'Script time limit (ms)' },
4642
+ description: {
4643
+ en: 'How long each script in this step may run. A script that runs longer is stopped, and the value it was handed goes on unchanged.',
4644
+ },
4645
+ },
4646
+ },
4647
+ },
4648
+ },
4649
+ ports: {
4650
+ in: { input: S.json },
4651
+ out: { main: S.json },
4652
+ },
4653
+ }));
4011
4654
  //# sourceMappingURL=tasks.js.map