@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/assembly.js +1 -1
- package/dist/src/builtins.d.ts +12 -23
- package/dist/src/builtins.js +38 -22
- package/dist/src/contract.d.ts +3 -1
- package/dist/src/contract.js +3 -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/CollectionAddressRow.d.ts +9 -5
- package/dist/src/generated/PayloadMember.d.ts +9 -3
- package/dist/src/generated/index.d.ts +1 -0
- package/dist/src/generated/index.js +1 -0
- package/dist/src/generated/tap-hooks.d.ts +18 -0
- package/dist/src/generated/tap-hooks.js +7 -0
- 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/assembly.js
CHANGED
|
@@ -68,7 +68,7 @@ export const rootDefaultContract = [
|
|
|
68
68
|
}),
|
|
69
69
|
clause(locusDeclared(), {
|
|
70
70
|
severity: "advisory",
|
|
71
|
-
guidance: "A document sits at a governed locus that your program declares no member for.
|
|
71
|
+
guidance: "A document sits at a governed locus that your program declares no member for. temper maintains nothing about it: `emit` never writes or reaps it, `guard` never bound it, and every address under it resolves to nothing — so it reads as governed configuration while being governed by no one. Where the locus is one the harness itself loads — a built-in kind's — it is live context on top of that; where the kind is your own, who reads it is yours to know and not temper's to claim. Declare the member in the program and re-emit; for a directory whose documents are authored in place rather than projected, declare its kind `local` so `check` derives the rows at read time instead. Advisory because a tree mid-adoption legitimately carries documents the program has not reached yet; dial this label to `required` — or re-declare the clause — once every document at a governed locus should be one you declared.",
|
|
72
72
|
}),
|
|
73
73
|
clause(engineMatches(), {
|
|
74
74
|
severity: "advisory",
|
package/dist/src/builtins.d.ts
CHANGED
|
@@ -407,18 +407,6 @@ export declare const HOOK_HANDLER_KEY = "hooks";
|
|
|
407
407
|
/** The one group-level field a matcher group lifts beside its handlers — {@link Hook}'s
|
|
408
408
|
* `matcher`, and the other half of the group's identity the join keys on (same source). */
|
|
409
409
|
export declare const HOOK_MATCHER_KEY = "matcher";
|
|
410
|
-
/**
|
|
411
|
-
* A hook member's **name** — its lifecycle `event`, then `:` and the matcher's authored
|
|
412
|
-
* bytes; the bare event where the group binds no matcher
|
|
413
|
-
* (`hook:PostToolUse:Edit|Write`, `hook:SessionStart`).
|
|
414
|
-
*
|
|
415
|
-
* Name and collection key part company because the **group** is the member and the event
|
|
416
|
-
* keys them all: Claude Code nests several matcher groups under one event, and two
|
|
417
|
-
* members at one address is a malformed lock. The matcher is joined verbatim, never
|
|
418
|
-
* normalized — `Edit|Write` and `Edit, Write` are two groups on the wire and two members
|
|
419
|
-
* here — which is also why an authored empty matcher joins as the empty bytes it is.
|
|
420
|
-
*/
|
|
421
|
-
export declare function hookMemberName(event: string, matcher: string | undefined): string;
|
|
422
410
|
/**
|
|
423
411
|
* The `hooks.<Event>` collection key a hook member's name was joined onto — its text
|
|
424
412
|
* before its own first `:`. The inverse of {@link hookMemberName} for the one reader that
|
|
@@ -1203,18 +1191,19 @@ export declare const hookDefaultContract: readonly Clause[];
|
|
|
1203
1191
|
* projects its tap hook at. The event-name is the author-facing token a telemetry
|
|
1204
1192
|
* verifier names (`contract.ts`'s `telemetry`, the `roster.rs` admissibility set); the
|
|
1205
1193
|
* `event` is the `hooks.<Event>` key the tap registers under, and the `matcher` scopes
|
|
1206
|
-
* the fire to the telemetry-relevant subset —
|
|
1207
|
-
* (code.claude.com/docs/en/hooks, retrieved 2026-08-26)
|
|
1194
|
+
* the fire to the telemetry-relevant subset — a load reason, a command name, a tool name,
|
|
1195
|
+
* each an external fact (code.claude.com/docs/en/hooks, retrieved 2026-08-26).
|
|
1196
|
+
*
|
|
1197
|
+
* The pairing's one home is the engine's own `TAP_HOOK_BINDINGS` table
|
|
1198
|
+
* (`src/builtin_kind.rs`), which states and cites each event's own matcher and resolves the
|
|
1199
|
+
* table through an exhaustive match over the `TapEvent` it already classifies hook payloads
|
|
1200
|
+
* into — and which `check` reads for the admissibility set too, so the names a telemetry
|
|
1201
|
+
* verifier may declare and the names a tap hook is synthesized for are one enumeration. The
|
|
1202
|
+
* binding read here is machine-written across the `generated/` seam from that table and held
|
|
1203
|
+
* byte-equal by the seam gate (`tests/it/seam_bindings_current.rs`).
|
|
1208
1204
|
*
|
|
1209
|
-
*
|
|
1210
|
-
*
|
|
1211
|
-
* include, compact), so always-on members that load at session start are recorded.
|
|
1212
|
-
* - `SkillInvoked` is a skill invocation, surfaced under `PostToolUse` with the tool-name
|
|
1213
|
-
* matcher `Skill` — the tap's own read of a skill call.
|
|
1214
|
-
* - `UserPromptExpansion` fires on a command expansion; its matcher filters the command
|
|
1215
|
-
* name, `.*` capturing every one.
|
|
1216
|
-
* - `ToolUse` fires after any tool call; its matcher filters the tool name, `.*`
|
|
1217
|
-
* capturing every one.
|
|
1205
|
+
* The widened annotation stays: `tapHookRows` looks up an author-supplied event name, which
|
|
1206
|
+
* the generated literal's own narrow key type would refuse.
|
|
1218
1207
|
*/
|
|
1219
1208
|
export declare const TELEMETRY_EVENT_HOOKS: Readonly<Record<string, {
|
|
1220
1209
|
readonly event: string;
|
package/dist/src/builtins.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* `@dtmd/temper/claude-code` subpath
|
|
10
10
|
* — never from the root.
|
|
11
11
|
*/
|
|
12
|
+
import { TAP_EVENT_HOOKS } from "./generated/index.js";
|
|
12
13
|
import { kind } from "./kind.js";
|
|
13
14
|
import { isNameQualifier } from "./member-address.js";
|
|
14
15
|
import { allowedChars, clause, closedKeys, degree, deny, enumOf, extent, forbiddenKeys, globValid, maxLen, mentionReachable, minLen, nameMatchesDir, optional, required, shape, type, uniqueName, when, } from "./contract.js";
|
|
@@ -159,7 +160,7 @@ export const HOOK_MATCHER_KEY = "matcher";
|
|
|
159
160
|
* normalized — `Edit|Write` and `Edit, Write` are two groups on the wire and two members
|
|
160
161
|
* here — which is also why an authored empty matcher joins as the empty bytes it is.
|
|
161
162
|
*/
|
|
162
|
-
|
|
163
|
+
function hookMemberName(event, matcher) {
|
|
163
164
|
return matcher === undefined ? event : `${event}:${matcher}`;
|
|
164
165
|
}
|
|
165
166
|
/**
|
|
@@ -851,6 +852,25 @@ export const mcp = kind({
|
|
|
851
852
|
* never stranded by temper's release cadence.
|
|
852
853
|
*/
|
|
853
854
|
export const mcpDefaultContract = [];
|
|
855
|
+
/**
|
|
856
|
+
* The cite behind {@link pathsGateGuidance} — one doc page and three dated probes: the
|
|
857
|
+
* gating hard-error, and the two negative findings that a shell read and a search read
|
|
858
|
+
* open no path gate. Dated facts go stale together, so they live in one place: a re-probe
|
|
859
|
+
* re-dates this const and every clause reading it moves with it.
|
|
860
|
+
*/
|
|
861
|
+
const PATHS_GATE_CITE = "https://code.claude.com/docs/en/skills (retrieved 2026-07-16; gating hard-error verified against 2.1.211; shell and search reads open no path gate, probed on Claude Code 2.1.281, 2026-09-24)";
|
|
862
|
+
/**
|
|
863
|
+
* The `mentionReachable("paths", "paths")` clause's guidance, for a member kind that
|
|
864
|
+
* carries a `paths` gate and can mention another that does. The reachability argument is
|
|
865
|
+
* a property of the gate mechanic, not of either kind, so the two default contracts that
|
|
866
|
+
* bind this clause — `skill` and `rule` — differ in exactly one word: the noun naming the
|
|
867
|
+
* mentioning member.
|
|
868
|
+
*/
|
|
869
|
+
function pathsGateGuidance(member) {
|
|
870
|
+
return ("A mention of a gated member is actionable only where that member can be invoked. A `paths` gate removes its member from every invocation channel until a file tool (read, edit, write) touches a matching path, and invoking a gated member from outside its gate hard-errors (`Unknown skill`) — the harness then tells the user it doesn't exist. " +
|
|
871
|
+
`So a ${member} that loads where its target cannot be invoked hands Claude an obligation it cannot act on. Two remedies: scope this ${member}'s \`paths\` to the target's gate, or ungate the target. ` +
|
|
872
|
+
"Advisory because the containment test is literal — every glob here must appear verbatim in the gate — so a semantically narrower glob (`src/**/*.ts` inside `src/**`) false-fires; retune or drop this clause in your own contract when it does. The judgment is over the gates, not over how they open: only a file tool (read, edit, write) opens a path gate — a shell read of a matching path, or a search tool's, opens none — so a session that works inside the gate through the shell alone loads neither member, and nothing static can see that.");
|
|
873
|
+
}
|
|
854
874
|
/**
|
|
855
875
|
* The default contract for `skill` — Anthropic's documented skill contract: the Agent
|
|
856
876
|
* Skills open standard (agentskills.io), Anthropic's platform upload
|
|
@@ -947,8 +967,8 @@ export const skillDefaultContract = [
|
|
|
947
967
|
}),
|
|
948
968
|
clause(mentionReachable("paths", "paths"), {
|
|
949
969
|
severity: "advisory",
|
|
950
|
-
guidance: "
|
|
951
|
-
cite:
|
|
970
|
+
guidance: pathsGateGuidance("skill"),
|
|
971
|
+
cite: PATHS_GATE_CITE,
|
|
952
972
|
}),
|
|
953
973
|
];
|
|
954
974
|
/**
|
|
@@ -1056,8 +1076,8 @@ export const ruleDefaultContract = [
|
|
|
1056
1076
|
}),
|
|
1057
1077
|
clause(mentionReachable("paths", "paths"), {
|
|
1058
1078
|
severity: "advisory",
|
|
1059
|
-
guidance: "
|
|
1060
|
-
cite:
|
|
1079
|
+
guidance: pathsGateGuidance("rule"),
|
|
1080
|
+
cite: PATHS_GATE_CITE,
|
|
1061
1081
|
}),
|
|
1062
1082
|
];
|
|
1063
1083
|
/**
|
|
@@ -1224,25 +1244,21 @@ export const hookDefaultContract = [
|
|
|
1224
1244
|
* projects its tap hook at. The event-name is the author-facing token a telemetry
|
|
1225
1245
|
* verifier names (`contract.ts`'s `telemetry`, the `roster.rs` admissibility set); the
|
|
1226
1246
|
* `event` is the `hooks.<Event>` key the tap registers under, and the `matcher` scopes
|
|
1227
|
-
* the fire to the telemetry-relevant subset —
|
|
1228
|
-
* (code.claude.com/docs/en/hooks, retrieved 2026-08-26)
|
|
1247
|
+
* the fire to the telemetry-relevant subset — a load reason, a command name, a tool name,
|
|
1248
|
+
* each an external fact (code.claude.com/docs/en/hooks, retrieved 2026-08-26).
|
|
1249
|
+
*
|
|
1250
|
+
* The pairing's one home is the engine's own `TAP_HOOK_BINDINGS` table
|
|
1251
|
+
* (`src/builtin_kind.rs`), which states and cites each event's own matcher and resolves the
|
|
1252
|
+
* table through an exhaustive match over the `TapEvent` it already classifies hook payloads
|
|
1253
|
+
* into — and which `check` reads for the admissibility set too, so the names a telemetry
|
|
1254
|
+
* verifier may declare and the names a tap hook is synthesized for are one enumeration. The
|
|
1255
|
+
* binding read here is machine-written across the `generated/` seam from that table and held
|
|
1256
|
+
* byte-equal by the seam gate (`tests/it/seam_bindings_current.rs`).
|
|
1229
1257
|
*
|
|
1230
|
-
*
|
|
1231
|
-
*
|
|
1232
|
-
* include, compact), so always-on members that load at session start are recorded.
|
|
1233
|
-
* - `SkillInvoked` is a skill invocation, surfaced under `PostToolUse` with the tool-name
|
|
1234
|
-
* matcher `Skill` — the tap's own read of a skill call.
|
|
1235
|
-
* - `UserPromptExpansion` fires on a command expansion; its matcher filters the command
|
|
1236
|
-
* name, `.*` capturing every one.
|
|
1237
|
-
* - `ToolUse` fires after any tool call; its matcher filters the tool name, `.*`
|
|
1238
|
-
* capturing every one.
|
|
1258
|
+
* The widened annotation stays: `tapHookRows` looks up an author-supplied event name, which
|
|
1259
|
+
* the generated literal's own narrow key type would refuse.
|
|
1239
1260
|
*/
|
|
1240
|
-
export const TELEMETRY_EVENT_HOOKS =
|
|
1241
|
-
InstructionsLoaded: { event: "InstructionsLoaded", matcher: ".*" },
|
|
1242
|
-
SkillInvoked: { event: "PostToolUse", matcher: "Skill" },
|
|
1243
|
-
UserPromptExpansion: { event: "UserPromptExpansion", matcher: ".*" },
|
|
1244
|
-
ToolUse: { event: "PostToolUse", matcher: ".*" },
|
|
1245
|
-
};
|
|
1261
|
+
export const TELEMETRY_EVENT_HOOKS = TAP_EVENT_HOOKS;
|
|
1246
1262
|
/**
|
|
1247
1263
|
* Every documented `.mcp.json` server transport — the closed set a server entry's `type`
|
|
1248
1264
|
* is drawn from (code.claude.com/docs/en/mcp, retrieved 2026-07-15). `stdio` is the
|
package/dist/src/contract.d.ts
CHANGED
|
@@ -387,7 +387,9 @@ export declare const script: (path: string) => Verifier;
|
|
|
387
387
|
* A telemetry verifier — the named documented harness events the emitted tap records
|
|
388
388
|
* to a local-locus log, judged by reading the field record. Each name must be a
|
|
389
389
|
* documented harness lifecycle event — the gate checks each resolves, never records
|
|
390
|
-
* into it.
|
|
390
|
+
* into it. The vocabulary is the engine's own `TAP_HOOK_BINDINGS` table
|
|
391
|
+
* (`src/builtin_kind.rs`), machine-written across the `generated/` seam and read by
|
|
392
|
+
* `builtins.ts`'s `TELEMETRY_EVENT_HOOKS`.
|
|
391
393
|
*/
|
|
392
394
|
export declare const telemetry: (events: readonly string[]) => Verifier;
|
|
393
395
|
/**
|
package/dist/src/contract.js
CHANGED
|
@@ -315,7 +315,9 @@ export const script = (path) => ({ species: "script", path });
|
|
|
315
315
|
* A telemetry verifier — the named documented harness events the emitted tap records
|
|
316
316
|
* to a local-locus log, judged by reading the field record. Each name must be a
|
|
317
317
|
* documented harness lifecycle event — the gate checks each resolves, never records
|
|
318
|
-
* into it.
|
|
318
|
+
* into it. The vocabulary is the engine's own `TAP_HOOK_BINDINGS` table
|
|
319
|
+
* (`src/builtin_kind.rs`), machine-written across the `generated/` seam and read by
|
|
320
|
+
* `builtins.ts`'s `TELEMETRY_EVENT_HOOKS`.
|
|
319
321
|
*/
|
|
320
322
|
export const telemetry = (events) => ({ species: "telemetry", events });
|
|
321
323
|
/** An identity helper — types a requirement literal at the keystroke. */
|
|
@@ -46,49 +46,12 @@ export interface RenderedExtent {
|
|
|
46
46
|
* unmeasured member's `extent` stays undecidable, never a zero read as a pass.
|
|
47
47
|
*/
|
|
48
48
|
export type RenderedExtents = ReadonlyMap<string, RenderedExtent>;
|
|
49
|
-
/**
|
|
50
|
-
* The `registration` rows — every fields-only registration member (a hook, an MCP server)
|
|
51
|
-
* erased for the manifest write face, kind-then-key sorted so double emit is byte-stable.
|
|
52
|
-
* Each carries its **collection key** (`kind`/`key`), its collection address
|
|
53
|
-
* (`manifest`/`keyPath`, the wire's snake_case `key_path`), and its folded typed fields —
|
|
54
|
-
* the entry value the engine's write face places under `key`. The authored half alone:
|
|
55
|
-
* the synthesized tap hooks join these rows in {@link mergedRegistrationRows}, which is
|
|
56
|
-
* what both readers of the family take.
|
|
57
|
-
*
|
|
58
|
-
* The row's `key` is where the entry **writes**, which for every kind but one is the
|
|
59
|
-
* member's own name. A hook's name joins its matcher onto the event because the group is
|
|
60
|
-
* the member, while the group still writes under `hooks.<Event>` — so the row keys the
|
|
61
|
-
* event back off the name ({@link hookCollectionKey}) and the member's address keeps the
|
|
62
|
-
* join.
|
|
63
|
-
*
|
|
64
|
-
* # Throws
|
|
65
|
-
* If a fields-only member declares no collection address — it surfaces in no host manifest.
|
|
66
|
-
*/
|
|
67
|
-
export declare function registrationRows(harness: Harness): RegistrationRow[];
|
|
68
49
|
/**
|
|
69
50
|
* Builds a collision-safe dedup key for a tap hook (event, matcher) pair.
|
|
70
51
|
* Two distinct pairs cannot produce the same key (e.g., ("Foo", "BarBaz") ≠ ("FooBar", "Baz")).
|
|
71
52
|
* @internal
|
|
72
53
|
*/
|
|
73
54
|
export declare function buildTapHookDedupeKey(event: string, matcher: string): string;
|
|
74
|
-
/**
|
|
75
|
-
* The synthesized tap-hook `registration` rows — one deduped `hooks.<Event>`
|
|
76
|
-
* registration per (lifecycle event, matcher) any telemetry verifier names. Scans the
|
|
77
|
-
* same requirement sources {@link requirementRows} reads (assembly `require` ∪ each
|
|
78
|
-
* member's `requires`), keeps the telemetry-species verifiers ({@link Verifier}), and
|
|
79
|
-
* unions the lifecycle events they name into one dumb registration apiece: the tap
|
|
80
|
-
* records every fire and read time joins raw events to members, so however many
|
|
81
|
-
* verifiers name an event it takes exactly one hook — the derived-aggregate precedent
|
|
82
|
-
* the permission union sets ({@link permissionUnion}). Each row is one matcher group
|
|
83
|
-
* running {@link TAP_COMMAND} under the event's documented matcher
|
|
84
|
-
* ({@link TELEMETRY_EVENT_HOOKS}), its key-path and fields sourced from the provider face
|
|
85
|
-
* ({@link tapHookRegistration}, `builtins.ts`); an event-name outside that table is the
|
|
86
|
-
* roster's inadmissibility finding, never a row. Synthesized in isolation here — whether a
|
|
87
|
-
* row stands alone or joins an authored group at the same pair is
|
|
88
|
-
* {@link mergedRegistrationRows}'s call, so this pass need not know what the program
|
|
89
|
-
* authored.
|
|
90
|
-
*/
|
|
91
|
-
export declare function tapHookRows(harness: Harness): RegistrationRow[];
|
|
92
55
|
/**
|
|
93
56
|
* Every `registration` row the program carries — the authored fields-only members
|
|
94
57
|
* ({@link registrationRows}) with the synthesized tap hooks ({@link tapHookRows}) **joined
|
|
@@ -118,14 +81,15 @@ export declare function settingsRows(harness: Harness): SettingsRow[];
|
|
|
118
81
|
/** Every requirement name a `satisfies` claim may fill — assembly `require` ∪ member `requires`. */
|
|
119
82
|
export declare function declaredRequirements(harness: Harness): Set<string>;
|
|
120
83
|
/**
|
|
121
|
-
* Every address a mention may name — declared requirement names ∪ each member's
|
|
122
|
-
*
|
|
84
|
+
* Every address a mention may name — declared requirement names ∪ each member's own
|
|
85
|
+
* {@link memberAddress} ∪ each `blocks()`-declared embedded member's host-scoped
|
|
123
86
|
* `<host-kind>:<host-name>/<kind>/<key>` address. Shared by `emit.ts` (a
|
|
124
87
|
* member-level `Text` body's mentions) and this module (an embedded member's
|
|
125
88
|
* `Text` leaves) — the one resolution-check set, so a leaf mention and a member
|
|
126
89
|
* mention are held to the identical bar. The embedded address is host-scoped,
|
|
127
90
|
* never a flat `<kind>:<key>` — flat would force corpus-wide key uniqueness on
|
|
128
|
-
* embedded kinds
|
|
91
|
+
* embedded kinds, and a nested **file** child's own address carries its host for
|
|
92
|
+
* exactly that reason: two hosts may each carry a `home`, and a mention names one.
|
|
129
93
|
*/
|
|
130
94
|
export declare function declaredAddresses(harness: Harness): Set<string>;
|
|
131
95
|
/**
|
package/dist/src/declarations.js
CHANGED
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { fileURLToPath } from "node:url";
|
|
12
12
|
import { isDeepStrictEqual } from "node:util";
|
|
13
|
-
import { isTextSpan,
|
|
13
|
+
import { isTextSpan, resolveEmbeddedLeaves } from "./prose.js";
|
|
14
14
|
import { HOOK_HANDLER_KEY, HOOK_MATCHER_KEY, SETTINGS_MANIFEST, TELEMETRY_EVENT_HOOKS, hook, hookCollectionKey, tapHookRegistration, } from "./builtins.js";
|
|
15
|
-
import {
|
|
15
|
+
import { leafAddress, memberAddress, nestedAddress } from "./member-address.js";
|
|
16
16
|
/**
|
|
17
17
|
* Compile one `Clause` into its lock row: the shared `key`/`field`/`severity`/
|
|
18
18
|
* `guidance`/`cite` columns — the clause's four channels surviving erasure
|
|
@@ -28,34 +28,26 @@ import { hostAddress, leafAddress, nestedAddress } from "./member-address.js";
|
|
|
28
28
|
*/
|
|
29
29
|
function clauseRow(clause, kind) {
|
|
30
30
|
const { predicate } = clause;
|
|
31
|
-
// For a `when` clause, extract the guard predicate's key and arguments,
|
|
32
|
-
// then convert the body to nested rows.
|
|
33
31
|
if (predicate.key === "when") {
|
|
34
32
|
const guardPredicate = clause.when_guard;
|
|
35
33
|
if (!guardPredicate) {
|
|
36
|
-
throw new Error(
|
|
34
|
+
throw new Error(`a \`when\` clause carries no guard predicate — a guarded clause is one guard plus ` +
|
|
35
|
+
`the body it gates (specs/model/contract.md, "clause").`);
|
|
37
36
|
}
|
|
38
|
-
//
|
|
39
|
-
//
|
|
40
|
-
|
|
37
|
+
// The guard's argument columns ride through *whole*: a `when` row is the guard's own
|
|
38
|
+
// row with the clause's seven columns set over it, so a column a newly-guardable
|
|
39
|
+
// predicate adds reaches a guard's row by construction rather than by maintaining a
|
|
40
|
+
// list here. `src/contract.rs` `predicate_from_row` is the total counterpart on the
|
|
41
|
+
// read side, rebuilding the guard row by the same spread.
|
|
42
|
+
const { kind: _kind, predicate: guardKey, severity: _severity, guidance: _guidance, cite: _cite, guard_predicate: _guardPredicate, body: _body, ...guardColumns } = clauseRow({ predicate: guardPredicate, severity: clause.severity }, undefined);
|
|
41
43
|
return {
|
|
44
|
+
...guardColumns,
|
|
42
45
|
kind,
|
|
43
46
|
predicate: "when",
|
|
44
47
|
severity: clause.severity,
|
|
45
48
|
guidance: clause.guidance,
|
|
46
49
|
cite: clause.cite,
|
|
47
|
-
|
|
48
|
-
guard_predicate: guardRow.predicate,
|
|
49
|
-
value_type: guardRow.value_type,
|
|
50
|
-
shape: guardRow.shape,
|
|
51
|
-
bound: guardRow.bound,
|
|
52
|
-
unit: guardRow.unit,
|
|
53
|
-
charset: guardRow.charset,
|
|
54
|
-
keys: guardRow.keys,
|
|
55
|
-
values: guardRow.values,
|
|
56
|
-
range: guardRow.range,
|
|
57
|
-
section: guardRow.section,
|
|
58
|
-
sections: guardRow.sections,
|
|
50
|
+
guard_predicate: guardKey,
|
|
59
51
|
body: clause.when_body ? clause.when_body.map((c) => clauseRow(c, undefined)) : undefined,
|
|
60
52
|
};
|
|
61
53
|
}
|
|
@@ -571,14 +563,15 @@ function assemblyFactRows(harness, kinds) {
|
|
|
571
563
|
}
|
|
572
564
|
/**
|
|
573
565
|
* The `satisfies` rows — every member's fill claims, member-then-requirement sorted.
|
|
574
|
-
* The `member` is the filler's own
|
|
566
|
+
* The `member` is the filler's own {@link memberAddress}, the same identity
|
|
575
567
|
* `mentionRows` writes, so the read side joins on a kind-qualified label a same-named
|
|
576
|
-
* member of another kind can never collide with
|
|
568
|
+
* member of another kind can never collide with — and a nested file child joins on the
|
|
569
|
+
* host-qualified one it resolves at, never a name its host's sibling also carries.
|
|
577
570
|
*/
|
|
578
571
|
function satisfiesRows(harness) {
|
|
579
572
|
const rows = [];
|
|
580
573
|
for (const member of harness.members) {
|
|
581
|
-
const address =
|
|
574
|
+
const address = memberAddress(member);
|
|
582
575
|
for (const requirement of member.satisfies) {
|
|
583
576
|
rows.push({ member: address, requirement });
|
|
584
577
|
}
|
|
@@ -588,18 +581,21 @@ function satisfiesRows(harness) {
|
|
|
588
581
|
/**
|
|
589
582
|
* The `mention` rows — every member's authored `n` targets, member-then-target
|
|
590
583
|
* sorted. `text`-kind prose contributes one row per mention, keyed to the
|
|
591
|
-
* member's own
|
|
584
|
+
* member's own {@link memberAddress}. A `blocks()` composed body keys each child
|
|
592
585
|
* to what it is: a prose span's mentions are host-level, keyed to the member's
|
|
593
|
-
* own
|
|
594
|
-
* mentions are keyed to that leaf's own
|
|
595
|
-
* address
|
|
596
|
-
*
|
|
597
|
-
*
|
|
586
|
+
* own address like a `text` body; an embedded value's `Text`-leaf
|
|
587
|
+
* mentions are keyed to that leaf's own
|
|
588
|
+
* `<host-address>/<kind>/<key>/<child-path>` address
|
|
589
|
+
* ([`embeddedLeafMentionRows`]), headed by the very `address` computed here —
|
|
590
|
+
* every row site in this function composes a host's address through
|
|
591
|
+
* {@link memberAddress}, the leaf branch included. A `file()` body names none.
|
|
592
|
+
* Recorded off the raw authored address, unconditionally — resolution is
|
|
593
|
+
* `emit`'s own refusal (`emit.ts`), not this row's concern.
|
|
598
594
|
*/
|
|
599
595
|
function mentionRows(harness) {
|
|
600
596
|
const rows = [];
|
|
601
597
|
for (const member of harness.members) {
|
|
602
|
-
const address =
|
|
598
|
+
const address = memberAddress(member);
|
|
603
599
|
if (member.prose?.kind === "text") {
|
|
604
600
|
for (const mention of member.prose.mentions) {
|
|
605
601
|
rows.push({ member: address, target: mention.target.address });
|
|
@@ -613,7 +609,7 @@ function mentionRows(harness) {
|
|
|
613
609
|
}
|
|
614
610
|
}
|
|
615
611
|
else {
|
|
616
|
-
rows.push(...embeddedLeafMentionRows(
|
|
612
|
+
rows.push(...embeddedLeafMentionRows(address, value));
|
|
617
613
|
}
|
|
618
614
|
}
|
|
619
615
|
}
|
|
@@ -626,10 +622,18 @@ function mentionRows(harness) {
|
|
|
626
622
|
* collection entry's leaves addressed `<collection>.<entry>.<field>` (one layer
|
|
627
623
|
* deep, matching the row's own shape) — each row keyed to the leaf's own
|
|
628
624
|
* structural address ({@link leafAddress}). A bare-string leaf names no mention.
|
|
625
|
+
*
|
|
626
|
+
* `host` is the hosting member's **own whole address** ({@link memberAddress}), at
|
|
627
|
+
* whatever grain the host sits: `kind:name` for a top-level host, the host's whole
|
|
628
|
+
* `<host-address>/<kind>/<key>` address under a nested one. A nested file child's
|
|
629
|
+
* identity *is* its host-qualified address (`compose.rs`'s `host_qualified`), so a
|
|
630
|
+
* head spelled off the bare name alone would name no member at `read.rs`'s
|
|
631
|
+
* `resolve_leaf` — and two sibling children each keyed `home` would head one string
|
|
632
|
+
* where the grammar scopes them to their hosts.
|
|
629
633
|
*/
|
|
630
|
-
function embeddedLeafMentionRows(
|
|
634
|
+
function embeddedLeafMentionRows(host, value) {
|
|
631
635
|
const rows = [];
|
|
632
|
-
const addressed = (childPath) => leafAddress(
|
|
636
|
+
const addressed = (childPath) => leafAddress(host, value.kind, value.key, childPath);
|
|
633
637
|
for (const [field, leaf] of Object.entries(value.leaves)) {
|
|
634
638
|
if (typeof leaf === "string")
|
|
635
639
|
continue;
|
|
@@ -652,13 +656,13 @@ function embeddedLeafMentionRows(hostName, value) {
|
|
|
652
656
|
}
|
|
653
657
|
/**
|
|
654
658
|
* The `include` rows — every member's `text`-body includes, in member-then-authored
|
|
655
|
-
* order. Each carries the host member's
|
|
659
|
+
* order. Each carries the host member's own {@link memberAddress} and the include target's
|
|
656
660
|
* path resolved against the stating module ({@link fileURLToPath} over the include's own
|
|
657
661
|
* `moduleUrl`), never the workspace — the engine reads, splices, and fingerprints it.
|
|
658
662
|
* Member order stays authored (never target-sorted): the body's include slots ride the
|
|
659
663
|
* same order, so the engine pairs the k-th slot with the k-th row. Includes ride a `text`
|
|
660
664
|
* body and a composed body's prose spans alike, in authored order across the interleave; an
|
|
661
|
-
* embedded leaf carries none (refused at
|
|
665
|
+
* embedded leaf carries none (refused at `prose.ts`'s `resolveLeaf`) and a `file()` body names none.
|
|
662
666
|
*/
|
|
663
667
|
function includeRows(harness) {
|
|
664
668
|
const rows = [];
|
|
@@ -666,7 +670,7 @@ function includeRows(harness) {
|
|
|
666
670
|
rows.push({ member: address, source_path: fileURLToPath(new URL(include.path, include.moduleUrl)) });
|
|
667
671
|
};
|
|
668
672
|
for (const member of harness.members) {
|
|
669
|
-
const address =
|
|
673
|
+
const address = memberAddress(member);
|
|
670
674
|
if (member.prose?.kind === "text") {
|
|
671
675
|
for (const include of member.prose.includes)
|
|
672
676
|
push(address, include);
|
|
@@ -684,7 +688,7 @@ function includeRows(harness) {
|
|
|
684
688
|
}
|
|
685
689
|
/**
|
|
686
690
|
* The `input` rows — every member's declared inputs, in member-then-authored order.
|
|
687
|
-
* Each carries the declaring member's
|
|
691
|
+
* Each carries the declaring member's own {@link memberAddress} and the input's path resolved
|
|
688
692
|
* against the stating module ({@link fileURLToPath} over the input's own `moduleUrl`),
|
|
689
693
|
* never the workspace — exactly as an include's is; the engine reads and fingerprints
|
|
690
694
|
* it, and splices nothing.
|
|
@@ -696,7 +700,7 @@ function includeRows(harness) {
|
|
|
696
700
|
function inputRows(harness) {
|
|
697
701
|
const rows = [];
|
|
698
702
|
for (const member of harness.members) {
|
|
699
|
-
const address =
|
|
703
|
+
const address = memberAddress(member);
|
|
700
704
|
for (const declared of member.inputs) {
|
|
701
705
|
rows.push({ member: address, source_path: fileURLToPath(new URL(declared.path, declared.moduleUrl)) });
|
|
702
706
|
}
|
|
@@ -704,29 +708,15 @@ function inputRows(harness) {
|
|
|
704
708
|
return rows;
|
|
705
709
|
}
|
|
706
710
|
/**
|
|
707
|
-
* One host member's declared embedded-member value as its declaration row
|
|
708
|
-
*
|
|
709
|
-
* (
|
|
710
|
-
*
|
|
711
|
-
*
|
|
712
|
-
*
|
|
711
|
+
* One host member's declared embedded-member value as its declaration row
|
|
712
|
+
* ([`NestedMemberRow`]) — its leaves through the shared walk
|
|
713
|
+
* ({@link resolveEmbeddedLeaves}), the identical resolution `emit.ts` runs on the same
|
|
714
|
+
* leaf's way into the rendered fence — plus the `placed_edges` record `emit` observed
|
|
715
|
+
* while rendering the same value, which is the only way an edge's placement reaches
|
|
716
|
+
* the engine.
|
|
713
717
|
*/
|
|
714
718
|
function nestedMemberRow(host, value, scope, placements, extents) {
|
|
715
|
-
const
|
|
716
|
-
const leaves = {};
|
|
717
|
-
for (const [field, leaf] of Object.entries(value.leaves)) {
|
|
718
|
-
leaves[field] = resolveLeaf(leaf, scope, context(field));
|
|
719
|
-
}
|
|
720
|
-
const collections = {};
|
|
721
|
-
for (const [collection, entries] of Object.entries(value.collections)) {
|
|
722
|
-
collections[collection] = entries.map((entry) => {
|
|
723
|
-
const entryLeaves = {};
|
|
724
|
-
for (const [field, leaf] of Object.entries(entry.leaves)) {
|
|
725
|
-
entryLeaves[field] = resolveLeaf(leaf, scope, context(`${collection}.${entry.key}.${field}`));
|
|
726
|
-
}
|
|
727
|
-
return { key: entry.key, leaves: entryLeaves };
|
|
728
|
-
});
|
|
729
|
-
}
|
|
719
|
+
const { leaves, collections } = resolveEmbeddedLeaves(value, scope);
|
|
730
720
|
const key = nestedAddress(host, value.kind, value.key);
|
|
731
721
|
const placed = placements?.get(key);
|
|
732
722
|
const extent = extents?.get(key);
|
|
@@ -774,8 +764,10 @@ function admissionsByHost(harness) {
|
|
|
774
764
|
}
|
|
775
765
|
/**
|
|
776
766
|
* The `nested_member` rows — every host member's `blocks()`-declared embedded-member
|
|
777
|
-
* values, host-then-kind-then-key sorted
|
|
778
|
-
*
|
|
767
|
+
* values, host-then-kind-then-key sorted, each keyed to its host's own
|
|
768
|
+
* {@link memberAddress} so a host that is itself a nested file child keys by the
|
|
769
|
+
* host-qualified address `check` resolves it at. Only a composed body's embedded values
|
|
770
|
+
* carry them (a `file()`/`text` body — and a composed body's prose spans — name none); the
|
|
779
771
|
* fence rendering itself is unchanged
|
|
780
772
|
* (`emit.ts`'s `resolveBody`) — this row is a second *read* of the same authored
|
|
781
773
|
* value, never a second copy the engine reads back (0018).
|
|
@@ -792,7 +784,7 @@ function nestedMemberRows(harness, admissions, scope, placements, extents) {
|
|
|
792
784
|
for (const member of harness.members) {
|
|
793
785
|
if (member.prose?.kind !== "blocks")
|
|
794
786
|
continue;
|
|
795
|
-
const host =
|
|
787
|
+
const host = memberAddress(member);
|
|
796
788
|
for (const value of member.prose.values) {
|
|
797
789
|
if (isTextSpan(value))
|
|
798
790
|
continue;
|
|
@@ -825,7 +817,7 @@ function nestedMemberRows(harness, admissions, scope, placements, extents) {
|
|
|
825
817
|
* # Throws
|
|
826
818
|
* If a fields-only member declares no collection address — it surfaces in no host manifest.
|
|
827
819
|
*/
|
|
828
|
-
|
|
820
|
+
function registrationRows(harness) {
|
|
829
821
|
return harness.members
|
|
830
822
|
.filter((member) => member.facts.shape === "fields")
|
|
831
823
|
.map((member) => {
|
|
@@ -875,7 +867,7 @@ export function buildTapHookDedupeKey(event, matcher) {
|
|
|
875
867
|
* {@link mergedRegistrationRows}'s call, so this pass need not know what the program
|
|
876
868
|
* authored.
|
|
877
869
|
*/
|
|
878
|
-
|
|
870
|
+
function tapHookRows(harness) {
|
|
879
871
|
const deduped = new Map();
|
|
880
872
|
const collect = (requirement) => {
|
|
881
873
|
if (requirement.verifier?.species !== "telemetry")
|
|
@@ -995,25 +987,26 @@ export function declaredRequirements(harness) {
|
|
|
995
987
|
return set;
|
|
996
988
|
}
|
|
997
989
|
/**
|
|
998
|
-
* Every address a mention may name — declared requirement names ∪ each member's
|
|
999
|
-
*
|
|
990
|
+
* Every address a mention may name — declared requirement names ∪ each member's own
|
|
991
|
+
* {@link memberAddress} ∪ each `blocks()`-declared embedded member's host-scoped
|
|
1000
992
|
* `<host-kind>:<host-name>/<kind>/<key>` address. Shared by `emit.ts` (a
|
|
1001
993
|
* member-level `Text` body's mentions) and this module (an embedded member's
|
|
1002
994
|
* `Text` leaves) — the one resolution-check set, so a leaf mention and a member
|
|
1003
995
|
* mention are held to the identical bar. The embedded address is host-scoped,
|
|
1004
996
|
* never a flat `<kind>:<key>` — flat would force corpus-wide key uniqueness on
|
|
1005
|
-
* embedded kinds
|
|
997
|
+
* embedded kinds, and a nested **file** child's own address carries its host for
|
|
998
|
+
* exactly that reason: two hosts may each carry a `home`, and a mention names one.
|
|
1006
999
|
*/
|
|
1007
1000
|
export function declaredAddresses(harness) {
|
|
1008
1001
|
const set = declaredRequirements(harness);
|
|
1009
1002
|
for (const member of harness.members) {
|
|
1010
|
-
set.add(
|
|
1003
|
+
set.add(memberAddress(member));
|
|
1011
1004
|
if (member.prose?.kind !== "blocks")
|
|
1012
1005
|
continue;
|
|
1013
1006
|
for (const value of member.prose.values) {
|
|
1014
1007
|
if (isTextSpan(value))
|
|
1015
1008
|
continue;
|
|
1016
|
-
set.add(nestedAddress(
|
|
1009
|
+
set.add(nestedAddress(memberAddress(member), value.kind, value.key));
|
|
1017
1010
|
}
|
|
1018
1011
|
}
|
|
1019
1012
|
return set;
|