@dtmd/temper 0.0.21 → 0.0.22
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/assembly.js +1 -1
- package/dist/src/declarations.d.ts +4 -40
- package/dist/src/declarations.js +62 -69
- package/dist/src/emit.js +199 -102
- package/dist/src/generated/PayloadMember.d.ts +9 -3
- package/dist/src/member-address.d.ts +97 -28
- package/dist/src/member-address.js +104 -34
- package/dist/src/prose.d.ts +39 -3
- package/dist/src/prose.js +41 -5
- package/package.json +3 -3
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,
|
|
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
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
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
|
|
74
|
-
* admitted
|
|
75
|
-
*
|
|
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
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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.
|
|
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.
|
|
95
|
-
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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
|
|
104
|
-
* the host kind's declared fact and the child
|
|
105
|
-
* path and no child contends with its host's
|
|
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 \`${
|
|
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),
|
|
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
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
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
|
-
|
|
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,
|
|
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
|
|
254
|
-
*
|
|
255
|
-
* its
|
|
256
|
-
*
|
|
257
|
-
* its
|
|
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,
|
|
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:
|
|
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(
|
|
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
|
-
*
|
|
297
|
-
*
|
|
298
|
-
* target facts off the resolved leaves
|
|
299
|
-
*
|
|
300
|
-
*
|
|
301
|
-
*
|
|
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
|
|
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(
|
|
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(
|
|
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.
|
|
636
|
-
* {@link declaredAddresses} spells
|
|
637
|
-
* a member the same way; a nested member keys under both of its own spellings
|
|
638
|
-
*
|
|
639
|
-
*
|
|
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
|
|
643
|
-
*
|
|
644
|
-
*
|
|
645
|
-
*
|
|
646
|
-
*
|
|
647
|
-
*
|
|
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) => [
|
|
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(
|
|
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(
|
|
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
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
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
|
|
@@ -14,9 +14,15 @@ export type PayloadMember = {
|
|
|
14
14
|
*/
|
|
15
15
|
name: string;
|
|
16
16
|
/**
|
|
17
|
-
* The
|
|
18
|
-
*
|
|
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
|
/**
|