@dtmd/temper 0.0.21 → 0.0.23

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/src/emit.js CHANGED
@@ -10,10 +10,10 @@
10
10
  */
11
11
  import { fileURLToPath } from "node:url";
12
12
  import { readFileSync } from "node:fs";
13
- import { checkMentions, defersToGate, isTextSpan, renderText, resolveLeaf } from "./prose.js";
13
+ import { checkMentions, defersToGate, isTextSpan, renderText, resolveEmbeddedLeaves } from "./prose.js";
14
14
  import { permissionUnion } from "./needs.js";
15
15
  import { compareStrings, compileDeclarations, declaredAddresses, declaredAtLocusKinds, declaredRequirements, encodeSeam, mergedRegistrationRows, settingsRows, uniqueMap, } from "./declarations.js";
16
- import { bareLookupKey, edgeLookupKey, hostAddress, nestedAddress } from "./member-address.js";
16
+ import { bareLookupKey, edgeLookupKey, hostAddress, isOneSegment, memberAddress, nestedAddress, } from "./member-address.js";
17
17
  /** The {@link MentionScope} a set of {@link ResolveOptions} names — its two sets, each defaulting to empty. */
18
18
  function scopeOf(options) {
19
19
  return {
@@ -62,47 +62,92 @@ function joinSlash(...parts) {
62
62
  return parts.filter((part) => part !== "" && part !== ".").join("/");
63
63
  }
64
64
  /**
65
- * `name` spliced through `pattern`'s single `*` — the one name-through-a-glob map, shared
66
- * by a flat `at` glob and a host template's path pattern. A `*`-free pattern is a fixed
67
- * path, left verbatim. `starredSegment` admits a single-`*` segment glob whose one `*` stars
68
- * a whole leading directory segment (a starred-segment kind's locus), landing `<name>/<file>`;
69
- * every other caller passes `false`, where a `/` beside the `*` is a stray directory the
70
- * splice cannot place.
65
+ * `name` spliced through `pattern`'s lone `*` — the one name-through-a-glob rule, and the
66
+ * only one: every flat `at` glob and every host template's path pattern places through it.
67
+ *
68
+ * A leading `**\/` collapses to zero segments, because an any-depth prefix names where the
69
+ * glob *matches*, never where a projection *lands*. What remains is placement: literal
70
+ * segments verbatim, the name into the final segment's lone `*` (`**\/CLAUDE.md` → the
71
+ * fixed `CLAUDE.md`, `**\/sub/*.json` → `sub/<name>.json`), and a `*`-free pattern wholly
72
+ * fixed. `starredSegment` is the one admission on top: a `*\/<file>` glob whose `*` stars a
73
+ * whole leading directory segment, landing `<name>/<file>` — there the name identifies the
74
+ * directory, not the leaf. Every other caller passes `false`.
71
75
  *
72
76
  * # Throws
73
- * If `pattern` carries a `*` yet is neither single-star nor single-segment (and not the
74
- * admitted leading-segment case): the splice would leave a stray literal `*` or directory
75
- * segment behind.
77
+ * If what remains after the collapse carries more than one `*`, or its one `*` sits above
78
+ * the final segment and is not the admitted starred-segment case: the splice would leave a
79
+ * stray literal `*` behind, or star a directory the member name does not identify.
76
80
  */
77
81
  function spliceName(kindName, pattern, name, starredSegment) {
78
- const stars = pattern.split("*").length - 1;
79
- const leadingSegment = starredSegment && stars === 1 && pattern.startsWith("*/");
80
- if (stars > 0 && !leadingSegment && (stars > 1 || pattern.includes("/"))) {
81
- throw new Error(`kind \`${kindName}\`: glob \`${pattern}\` is neither a single-segment single-\`*\` ` +
82
- `pattern nor an any-depth \`**\` glob — a member name splices through neither.`);
82
+ const placed = pattern.startsWith("**/") ? pattern.slice(3) : pattern;
83
+ const stars = placed.split("*").length - 1;
84
+ const starInLeaf = placed.lastIndexOf("*") > placed.lastIndexOf("/");
85
+ const leadingSegment = starredSegment && stars === 1 && placed.startsWith("*/");
86
+ if (stars > 0 && !leadingSegment && (stars > 1 || !starInLeaf)) {
87
+ throw new Error(`kind \`${kindName}\`: glob \`${pattern}\` maps its member name onto no one path — a ` +
88
+ `name splices through exactly one \`*\`, confined to the glob's final segment (a ` +
89
+ `leading \`**/\` collapses to nothing, and literal leading segments are fixed ` +
90
+ `placement); this glob carries more than one \`*\`, or a \`*\` above the leaf.`);
91
+ }
92
+ return placed.replace("*", name);
93
+ }
94
+ /**
95
+ * The placement a member of `facts` named `name` takes **inside the locus its pattern is
96
+ * rooted at** — the half an `at` kind and a nested file child derive identically, since a
97
+ * host template's path pattern stands to its host's unit exactly as an `at` kind's glob
98
+ * stands to its `governs` root (`specs/model/representation.md`, "locus").
99
+ *
100
+ * A **directory** unit owns a directory and seats its entry file inside it, so the pattern
101
+ * names that entry file and the member's own name is the directory: the leading segment
102
+ * drops and `<name>/` takes its place, which is what makes `*\/SKILL.md` and a template's
103
+ * `*\/PAGE.md` land the same shape. Every other shape places its name through the one
104
+ * splice rule ({@link spliceName}), a starred-segment kind's `*\/<file>` included.
105
+ *
106
+ * # Throws
107
+ * Whatever {@link spliceName} throws when the pattern maps the name onto no one path.
108
+ */
109
+ function placementInUnit(facts, pattern, name) {
110
+ if (facts.unitShape === "directory") {
111
+ const slash = pattern.indexOf("/");
112
+ return joinSlash(name, slash < 0 ? pattern : pattern.slice(slash + 1));
83
113
  }
84
- return pattern.replace("*", name);
114
+ return spliceName(facts.name, pattern, name, facts.unitShape === "starred-segment");
85
115
  }
86
116
  /**
87
117
  * The unit `host`'s file children compose their paths under — a directory unit's own
88
118
  * directory, since a template's path pattern is relative to the parent's unit.
89
119
  *
120
+ * Composed from the host's **own projection**, never read off its locus columns: a
121
+ * directory unit seats its entry file inside the directory it owns, so the directory is
122
+ * that projection less its final segment. A host at an `at` locus supplies
123
+ * `<root>/<name>`; a host that is itself a nested file child supplies an interior under
124
+ * *its* own host's unit, so depth is unbounded and one rule composes every layer —
125
+ * exactly as the engine's `nested_file_path` (`src/drift.rs`) composes it.
126
+ *
90
127
  * # Throws
91
128
  * If the host owns no directory unit: a lone file has no interior for a child to sit in.
129
+ * Propagates every refusal the host's own path derivation raises.
92
130
  */
93
131
  function hostUnit(host, context) {
94
- if (host.facts.locus.kind === "at" && host.facts.unitShape === "directory") {
95
- return joinSlash(host.facts.locus.root, host.name);
132
+ if (host.facts.unitShape !== "directory") {
133
+ throw new Error(`${context}: its host \`${memberAddress(host)}\` owns no directory unit — a template's ` +
134
+ `path pattern is relative to the host's unit, and a lone file has no interior for a ` +
135
+ `child to sit in (specs/model/representation.md, "locus").`);
96
136
  }
97
- throw new Error(`${context}: its host \`${hostAddress(host.kind, host.name)}\` owns no directory unit — a template's ` +
98
- `path pattern is relative to the host's unit, and a lone file has no interior for a ` +
99
- `child to sit in (specs/model/representation.md, "locus").`);
137
+ const projection = projectionPath(host);
138
+ const slash = projection.lastIndexOf("/");
139
+ if (slash < 0) {
140
+ throw new Error(`${context}: its host \`${memberAddress(host)}\` projects to \`${projection}\`, which names ` +
141
+ `no directory for a child to sit in (specs/model/representation.md, "locus").`);
142
+ }
143
+ return projection.slice(0, slash);
100
144
  }
101
145
  /**
102
146
  * A nested file child's harness-relative locus: its host member's unit joined with the
103
- * host template's path pattern, its own name spliced through the pattern. The pattern is
104
- * the host kind's declared fact and the child kind governs no glob, so one home owns the
105
- * path and no child contends with its host's own locus.
147
+ * host template's path pattern, its own name placed through the pattern
148
+ * ({@link placementInUnit}). The pattern is the host kind's declared fact and the child
149
+ * kind governs no glob, so one home owns the path and no child contends with its host's
150
+ * own locus.
106
151
  *
107
152
  * # Throws
108
153
  * If the child names no host, or its host's kind templates no file layer for the child's
@@ -116,20 +161,30 @@ function nestedFilePath(member) {
116
161
  }
117
162
  const template = (host.facts.templates ?? []).find((layer) => layer.kind.key === member.kind && layer.path !== undefined);
118
163
  if (template?.path === undefined) {
119
- throw new Error(`${context}: its host \`${hostAddress(host.kind, host.name)}\` templates no file layer for kind ` +
164
+ throw new Error(`${context}: its host \`${memberAddress(host)}\` templates no file layer for kind ` +
120
165
  `\`${member.kind}\` — the path pattern is the host kind's declared fact, and there is ` +
121
166
  `none to compose against (specs/model/representation.md, "locus").`);
122
167
  }
123
- return joinSlash(hostUnit(host, context), spliceName(member.kind, template.path, member.name, false));
168
+ return joinSlash(hostUnit(host, context), placementInUnit(member.facts, template.path, member.name));
124
169
  }
125
170
  /**
126
- * The harness-relative locus `member` projects onto: a directory unit lands its entry
127
- * file under `<root>/<name>/`; a lone file splices the name through the glob's single
128
- * `*` (an any-depth glob — a memory kind's `**\/CLAUDE.md` — lands the root `<name>.md`,
129
- * and a `*`-free glob is a fixed path left verbatim); a nested file child composes its
130
- * path under its host's unit ({@link nestedFilePath}). The engine derives the same locus
131
- * from the same facts (`src/drift.rs`'s `member_projection_path`); the two must agree,
132
- * since a hook's rendered link is written from this side and reaped from that one.
171
+ * The harness-relative locus `member` projects onto: a file member places its name inside
172
+ * the locus its own `governs` glob is rooted at ({@link placementInUnit}); a nested file
173
+ * child places it inside its host's unit instead, through that same rule and its host
174
+ * kind's declared template pattern ({@link nestedFilePath}). The engine
175
+ * derives the same locus from the same facts (`src/drift.rs`'s `member_projection_path`);
176
+ * the two must agree, since a hook's rendered link is written from this side and reaped
177
+ * from that one.
178
+ *
179
+ * The property both derivations owe is a **round trip**: the path a member is placed at is
180
+ * one the kind's own glob finds again when `check` walks the locus, so placement and
181
+ * discovery are one agreement rather than two spellings that happen to coincide. A path
182
+ * outside its glob is written and locked yet ungoverned — the kind counted `(0)` with no
183
+ * finding to name it. The engine holds the round trip with the glob engine it already has
184
+ * (`UngovernedProjection`); this side has no matcher, so what it holds is the half a
185
+ * matcher is not needed for — a member name carrying the `/` a path is placed with
186
+ * ({@link refuseSegmentedName}) — and `tests/projection_path_seam.rs` gates the property
187
+ * itself, per unit shape, over what emit actually wrote.
133
188
  *
134
189
  * # Throws
135
190
  * If the kind is embedded (no standalone projection), or the member's glob or host
@@ -145,14 +200,7 @@ function projectionPath(member) {
145
200
  if (facts.locus.kind === "nested-file")
146
201
  return nestedFilePath(member);
147
202
  const { root, glob } = facts.locus;
148
- if (facts.unitShape === "directory") {
149
- const slash = glob.indexOf("/");
150
- return joinSlash(root, member.name, slash < 0 ? glob : glob.slice(slash + 1));
151
- }
152
- if (glob.includes("**"))
153
- return joinSlash(root, `${member.name}.md`);
154
- const starredSegment = facts.unitShape === "starred-segment";
155
- return joinSlash(root, spliceName(facts.name, glob, member.name, starredSegment));
203
+ return joinSlash(root, placementInUnit(facts, glob, member.name));
156
204
  }
157
205
  /**
158
206
  * `to`'s path as read from the document at `from` — the shared leading segments drop
@@ -212,7 +260,7 @@ function edgeTargetFacts(host, value, leaves, options) {
212
260
  throw new Error(`${reference}, which resolves to no composed member — an edge target's facts are ` +
213
261
  `derived, never fabricated (specs/model/pipeline.md, "Emit", the "Refusing" bullet).`);
214
262
  }
215
- facts[edge.field] = resolvedTargetFacts(host, target, lookup, reference);
263
+ facts[edge.field] = resolvedTargetFacts(host, target, reference);
216
264
  }
217
265
  return { facts, deferred };
218
266
  }
@@ -250,25 +298,26 @@ function isNested(target) {
250
298
  }
251
299
  /**
252
300
  * The four derived facts one resolved edge target contributes, read off the target
253
- * itself and never off the citing instance. A top-level member answers with its own
254
- * identity and its own projection; an embedded value answers with its own kind and key,
255
- * its canonical `<host-address>/<kind>/<key>` address (whichever spelling the leaf
256
- * authored), and its *host's* projection — an embedded member owns no file, so the file
257
- * its rendering lands in is the host's.
301
+ * itself and never off the citing instance. A member answers with its own identity, its own
302
+ * {@link memberAddress} — the canonical one, whichever of its spellings the leaf authored,
303
+ * so a file child cited by its bare key still renders the host-qualified address it
304
+ * resolves at — and its own projection; an embedded value answers with its own kind and
305
+ * key, its canonical `<host-address>/<kind>/<key>` address, and its *host's* projection —
306
+ * an embedded member owns no file, so the file its rendering lands in is the host's.
258
307
  *
259
308
  * # Throws
260
309
  * If a bare `kind:key` is carried by more than one host — an ambiguous address names
261
310
  * nothing, and the full spelling is what tells the carriers apart — or if the target,
262
311
  * or the host carrying it, owns no projection to point at.
263
312
  */
264
- function resolvedTargetFacts(host, target, lookup, reference) {
313
+ function resolvedTargetFacts(host, target, reference) {
265
314
  const noProjection = () => new Error(`${reference}, which owns no projection to reference (specs/model/representation.md, "locus").`);
266
315
  if (!isNested(target)) {
267
316
  if (!isProjected(target))
268
317
  throw noProjection();
269
318
  return {
270
319
  name: target.name,
271
- address: lookup,
320
+ address: memberAddress(target),
272
321
  kind: target.kind,
273
322
  path: relativeProjection(projectionPath(host), projectionPath(target)),
274
323
  repoRootedPath: projectionPath(target),
@@ -286,40 +335,22 @@ function resolvedTargetFacts(host, target, lookup, reference) {
286
335
  const carrierPath = projectionPath(carrier);
287
336
  return {
288
337
  name: value.key,
289
- address: nestedAddress(hostAddress(carrier.kind, carrier.name), value.kind, value.key),
338
+ address: nestedAddress(memberAddress(carrier), value.kind, value.key),
290
339
  kind: value.kind,
291
340
  path: relativeProjection(projectionPath(host), carrierPath),
292
341
  repoRootedPath: carrierPath,
293
342
  };
294
343
  }
295
344
  /**
296
- * Resolve one embedded member's value's leaves — top-level and each
297
- * collection entry's — to their final stored strings, and derive its edge fields'
298
- * target facts off the resolved leaves: a `Text`-authored leaf
299
- * resolves the way `resolveBody` resolves a member-level `Text` body (mention
300
- * resolution-checked against `mentionable`, loud on a dangling address); a
301
- * bare-string leaf is unchanged. The one resolution point shared by the
302
- * default TOML view and a kind's own `render` hook, so refusing on a dangling
303
- * embedded-kind leaf mention never depends on whether the kind declares
304
- * `render` (`pipeline.md`, "Emit", the "Refusing" bullet).
345
+ * One embedded member value as a kind's `render` hook receives it: the shared leaf
346
+ * walk ({@link resolveEmbeddedLeaves}, scoped by {@link scopeOf}) plus this module's
347
+ * own job — the edge fields' target facts derived off the resolved top-level leaves.
348
+ * Called on both the default-TOML and the `render`-hook path before either reads a
349
+ * leaf, so refusing on a dangling embedded-kind leaf mention never depends on whether
350
+ * the kind declares `render` (`pipeline.md`, "Emit", the "Refusing" bullet).
305
351
  */
306
352
  function resolveMemberLeaves(host, value, options) {
307
- const scope = scopeOf(options);
308
- const context = (childPath) => `member.${value.kind} ${value.key}: leaf \`${childPath}\``;
309
- const leaves = {};
310
- for (const [key, leaf] of Object.entries(value.leaves)) {
311
- leaves[key] = resolveLeaf(leaf, scope, context(key));
312
- }
313
- const collections = {};
314
- for (const [collection, entries] of Object.entries(value.collections)) {
315
- collections[collection] = entries.map((entry) => {
316
- const entryLeaves = {};
317
- for (const [leaf, text] of Object.entries(entry.leaves)) {
318
- entryLeaves[leaf] = resolveLeaf(text, scope, context(`${collection}.${entry.key}.${leaf}`));
319
- }
320
- return { key: entry.key, leaves: entryLeaves };
321
- });
322
- }
353
+ const { leaves, collections } = resolveEmbeddedLeaves(value, scopeOf(options));
323
354
  return {
324
355
  kind: value.kind,
325
356
  key: value.key,
@@ -440,7 +471,7 @@ function edgePlacements(harness, options) {
440
471
  continue;
441
472
  const placed = placedEdges(member, value, options);
442
473
  if (placed !== undefined) {
443
- entries.push([nestedAddress(hostAddress(member.kind, member.name), value.kind, value.key), placed]);
474
+ entries.push([nestedAddress(memberAddress(member), value.kind, value.key), placed]);
444
475
  }
445
476
  }
446
477
  }
@@ -481,7 +512,7 @@ function renderedExtents(harness, options) {
481
512
  continue;
482
513
  const block = renderMemberBlock(member, value, options);
483
514
  entries.push([
484
- nestedAddress(hostAddress(member.kind, member.name), value.kind, value.key),
515
+ nestedAddress(memberAddress(member), value.kind, value.key),
485
516
  {
486
517
  lines: renderedLineCount(block),
487
518
  // Unicode scalar values, matching Rust's `chars().count()` — iterating a string
@@ -632,32 +663,65 @@ function settingsResidue(harness) {
632
663
  }
633
664
  /**
634
665
  * The harness's composed members by address — the table an embedded value's edge field
635
- * resolves its target against. A top-level member keys the identical way
636
- * {@link declaredAddresses} spells a member address, so an edge field and a mention name
637
- * a member the same way; a nested member keys under both of its own spellings
638
- * ({@link nestedTargets}), so an embedded edge target resolves at emit as a top-level one
639
- * does.
666
+ * resolves its target against. Every member keys by its own address ({@link memberAddress}),
667
+ * the identical way {@link declaredAddresses} spells one, so an edge field and a mention
668
+ * name a member the same way; a nested member keys under both of its own spellings — an
669
+ * embedded value through {@link nestedTargets}, a file child through its own address here
670
+ * and {@link bareFileChildTargets} — so a nested edge target resolves at emit as a
671
+ * top-level one does.
640
672
  *
641
673
  * A projected member's address is its file, so two at one address are a collision and
642
- * refuse loud. A registration member's address is its *group key* — a `hook` registers on
643
- * its event, and Claude Code admits any number of matcher groups per event — so several
644
- * legitimately share one address and the table keeps the last composed (the pre-0.0.16
645
- * reading; an edge targeting that shared address resolves ambiguously, the open fork
646
- * `(hook-member-identity)` in `.flume/plan/open-questions.md`). Refusing them broke
647
- * `emit` on every harness with two hooks on one event (0.0.16).
674
+ * refuse loud. A nested file child's address carries its host, so two hosts each carrying a
675
+ * `home` are two addresses rather than one name twice — the collision a corpus-wide
676
+ * `<kind>:<name>` keying raised for a corpus that is perfectly well-formed. A registration
677
+ * member's address is its *group key* — a `hook` registers on its event, and Claude Code
678
+ * admits any number of matcher groups per event — so several legitimately share one address
679
+ * and the table keeps the last composed (the pre-0.0.16 reading; an edge targeting that
680
+ * shared address resolves ambiguously, the open fork `(hook-member-identity)` in
681
+ * `.flume/plan/open-questions.md`). Refusing them broke `emit` on every harness with two
682
+ * hooks on one event (0.0.16).
648
683
  */
649
684
  function memberTable(harness) {
650
685
  const table = uniqueMap([
651
686
  ...harness.members
652
687
  .filter((member) => !isRegistration(member))
653
- .map((member) => [hostAddress(member.kind, member.name), member]),
688
+ .map((member) => [memberAddress(member), member]),
689
+ ...bareFileChildTargets(harness),
654
690
  ...nestedTargets(harness),
655
691
  ]);
656
692
  for (const member of harness.members.filter(isRegistration)) {
657
- table.set(hostAddress(member.kind, member.name), member);
693
+ table.set(memberAddress(member), member);
658
694
  }
659
695
  return table;
660
696
  }
697
+ /**
698
+ * Every nested **file** child under the bare `<kind>:<name>` short form as well as its own
699
+ * host-qualified address — the same second spelling {@link nestedTargets} gives an embedded
700
+ * member, so the two nested grains resolve alike.
701
+ *
702
+ * A bare key names a nested member only while a single host carries it, so a name several
703
+ * hosts spell enters under no bare key at all and an edge citing it refuses as an address
704
+ * resolving to no composed member ({@link edgeTargetFacts}) — loud, with the whole
705
+ * `<host-address>/<kind>/<key>` spelling always available to tell the carriers apart. The
706
+ * ambiguity is not refused *here*, because uniqueness is the resolver's bar and not the
707
+ * corpus's: one name two hosts carry and nothing cites still composes.
708
+ */
709
+ function bareFileChildTargets(harness) {
710
+ const carriers = new Map();
711
+ for (const member of harness.members) {
712
+ if (member.host === undefined || isRegistration(member))
713
+ continue;
714
+ const key = bareLookupKey(member.kind, member.name);
715
+ const carried = carriers.get(key);
716
+ if (carried === undefined)
717
+ carriers.set(key, [member]);
718
+ else
719
+ carried.push(member);
720
+ }
721
+ return [...carriers]
722
+ .filter(([, carried]) => carried.length === 1)
723
+ .map(([key, carried]) => [key, carried[0]]);
724
+ }
661
725
  /**
662
726
  * Every composed embedded value as member-table entries, under both of its spellings: the
663
727
  * full `<host-address>/<kind>/<key>` address, whose one carrier is the host whose body
@@ -678,7 +742,7 @@ function nestedTargets(harness) {
678
742
  if (isTextSpan(value))
679
743
  continue;
680
744
  const target = { host: member, value };
681
- qualified.push([nestedAddress(hostAddress(member.kind, member.name), value.kind, value.key), [target]]);
745
+ qualified.push([nestedAddress(memberAddress(member), value.kind, value.key), [target]]);
682
746
  const key = bareLookupKey(value.kind, value.key);
683
747
  const carriers = bare.get(key);
684
748
  if (carriers === undefined)
@@ -689,21 +753,54 @@ function nestedTargets(harness) {
689
753
  }
690
754
  return [...qualified, ...bare];
691
755
  }
756
+ /**
757
+ * Refuse a projected member whose **name** carries the `/` an address is cut at
758
+ * ({@link isOneSegment}) — the bar `kind.ts`'s `refuseSegmentedKey` already holds one grain
759
+ * down, for an embedded member's key.
760
+ *
761
+ * A member's name is its own first address segment and, at every `at` locus, the identity a
762
+ * projection path is spliced from: a file stem, or the one directory segment the kind's glob
763
+ * stars. A `/` in it therefore does two things at once — it shifts every address beneath the
764
+ * member by a segment, and it places the projection outside the glob the kind declares, so
765
+ * the file is written where no discovery walk looks. The engine refuses the same name
766
+ * (`src/drift.rs`'s `MemberNameSeparator`), and this half is the loud one: at compose time
767
+ * the author can still rename.
768
+ *
769
+ * Total over the projected set rather than inside {@link spliceName}, which a directory-unit
770
+ * member's path never reaches.
771
+ *
772
+ * # Throws
773
+ * If `name` is empty or carries `/`.
774
+ */
775
+ function refuseSegmentedName(kind, name) {
776
+ if (isOneSegment(name))
777
+ return;
778
+ throw new Error(`member \`${name}\` of kind \`${kind}\`: a member's name is one address segment — ` +
779
+ `non-empty and carrying no \`/\`, the separator its address is cut at and the one a ` +
780
+ `projection path is placed with; a name carrying it addresses another member's leaf ` +
781
+ `and places outside the kind's own glob`);
782
+ }
692
783
  /** The harness's projected members as payload members, deterministically kind-then-name ordered. */
693
784
  function orderedMembers(harness, options) {
694
785
  return [...harness.members]
695
786
  .filter(isProjected)
696
787
  .sort((a, b) => compareStrings(a.kind, b.kind) || compareStrings(a.name, b.name))
697
- .map((member) => ({
698
- kind: member.kind,
699
- name: member.name,
700
- host: member.host && hostAddress(member.host.kind, member.host.name),
701
- // The generated row carries a mutable field list; the member's is read-only,
702
- // so copy each pair into a fresh tuple — the same values, a shape the row accepts.
703
- fields: member.fields.map(([name, value]) => [name, value]),
704
- body: resolveBody(member, options),
705
- source_path: fileSourcePath(member),
706
- }));
788
+ .map((member) => {
789
+ refuseSegmentedName(member.kind, member.name);
790
+ return {
791
+ kind: member.kind,
792
+ name: member.name,
793
+ // The host's **own whole address**, never its `kind:name` alone: the engine reads
794
+ // this column to find the host's host when it composes a child's path, so a
795
+ // flattened spelling would strand every layer above the nearest one.
796
+ host: member.host && memberAddress(member.host),
797
+ // The generated row carries a mutable field list; the member's is read-only,
798
+ // so copy each pair into a fresh tuple — the same values, a shape the row accepts.
799
+ fields: member.fields.map(([name, value]) => [name, value]),
800
+ body: resolveBody(member, options),
801
+ source_path: fileSourcePath(member),
802
+ };
803
+ });
707
804
  }
708
805
  /**
709
806
  * Compile the whole face in one deterministic pass: the declaration rows (its
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * A kind's declared **collection address** row — the manifest a registration member
3
- * surfaces in and the key path it keys at, the presence-coupled pair
4
- * [`KindFactRow::collection_address`] carries. Absent from a [`KindFactRow`] means the
5
- * kind owns its own file locus.
3
+ * surfaces in, the key path it keys at, and the shape its entry takes: the
4
+ * presence-coupled triple [`KindFactRow::collection_address`] carries. Absent from a
5
+ * [`KindFactRow`] means the kind owns its own file locus.
6
6
  */
7
7
  export type CollectionAddressRow = {
8
8
  /**
@@ -15,7 +15,11 @@ export type CollectionAddressRow = {
15
15
  */
16
16
  key_path: string;
17
17
  /**
18
- * The entry's declared shape — whether it's an object, scalar, or group-array.
18
+ * The entry's declared shape — `object`, `scalar(field)`, or
19
+ * `group-array(member_key;lifted_fields)`, a closed vocabulary the engine's kind lift
20
+ * rejects an unknown value from. Required: the shape is the kind's own declared fact,
21
+ * never derivable from the key path (two kinds keying at `hooks.<Event>` may lift
22
+ * different group fields).
19
23
  */
20
- entry_shape: string | null;
24
+ entry_shape: string;
21
25
  };
@@ -14,9 +14,15 @@ export type PayloadMember = {
14
14
  */
15
15
  name: string;
16
16
  /**
17
- * The `kind:name` address of the host member this member's unit composes under —
18
- * carried by a **nested file** child, whose path is its host's unit joined with the
19
- * host template's pattern; absent at every other locus.
17
+ * The host member's **own whole address** — the member this one's unit composes
18
+ * under. Carried by a **nested file** child, whose path is its host's unit joined
19
+ * with the host template's pattern; absent at every other locus.
20
+ *
21
+ * `<kind>:<name>` for a top-level host, and the host's own
22
+ * `<host-address>/<kind>/<key>` when the host is itself nested: deriving this
23
+ * member's path means deriving its host's unit, which means knowing the host's own
24
+ * host, so the column carries the whole chain rather than the nearest link
25
+ * (`specs/model/representation.md`, "nesting").
20
26
  */
21
27
  host?: string;
22
28
  /**
@@ -35,3 +35,4 @@ export type { TemplateRow } from "./TemplateRow.js";
35
35
  export type { ValueType } from "./ValueType.js";
36
36
  export type { Verifier } from "./Verifier.js";
37
37
  export { GUARD_COMMAND, SESSION_START_COMMAND } from "./gate-commands.js";
38
+ export { TAP_EVENT_HOOKS } from "./tap-hooks.js";
@@ -1 +1,2 @@
1
1
  export { GUARD_COMMAND, SESSION_START_COMMAND } from "./gate-commands.js";
2
+ export { TAP_EVENT_HOOKS } from "./tap-hooks.js";
@@ -0,0 +1,18 @@
1
+ export declare const TAP_EVENT_HOOKS: {
2
+ readonly InstructionsLoaded: {
3
+ readonly event: "InstructionsLoaded";
4
+ readonly matcher: ".*";
5
+ };
6
+ readonly SkillInvoked: {
7
+ readonly event: "PostToolUse";
8
+ readonly matcher: "Skill";
9
+ };
10
+ readonly UserPromptExpansion: {
11
+ readonly event: "UserPromptExpansion";
12
+ readonly matcher: ".*";
13
+ };
14
+ readonly ToolUse: {
15
+ readonly event: "PostToolUse";
16
+ readonly matcher: ".*";
17
+ };
18
+ };
@@ -0,0 +1,7 @@
1
+ // This file carries temper's tap-hook registrations, generated from the engine's own table. Do not edit this file manually.
2
+ export const TAP_EVENT_HOOKS = {
3
+ "InstructionsLoaded": { event: "InstructionsLoaded", matcher: ".*" },
4
+ "SkillInvoked": { event: "PostToolUse", matcher: "Skill" },
5
+ "UserPromptExpansion": { event: "UserPromptExpansion", matcher: ".*" },
6
+ "ToolUse": { event: "PostToolUse", matcher: ".*" },
7
+ };