@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.
@@ -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. Claude Code loads it, but 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. 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.",
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",
@@ -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
- * `kind:name` ∪ each `blocks()`-declared embedded member's host-scoped
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
  /**
@@ -10,9 +10,9 @@
10
10
  */
11
11
  import { fileURLToPath } from "node:url";
12
12
  import { isDeepStrictEqual } from "node:util";
13
- import { isTextSpan, resolveLeaf } from "./prose.js";
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 { hostAddress, leafAddress, nestedAddress } from "./member-address.js";
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("when clause missing guard predicate");
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
- // Build a row for the guard predicate's arguments, then copy those fields
39
- // into this row alongside the guard_predicate and body.
40
- const guardRow = clauseRow({ predicate: guardPredicate, severity: clause.severity }, undefined);
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
- field: guardRow.field,
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 `kind:name` address, the same identity
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 = hostAddress(member.kind, member.name);
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 `kind:name` address. A `blocks()` composed body keys each child
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 `kind:name` address like a `text` body; an embedded value's `Text`-leaf
594
- * mentions are keyed to that leaf's own `<member>/<kind>/<key>/<child-path>`
595
- * address ([`embeddedLeafMentionRows`]). A `file()` body names none. Recorded off
596
- * the raw authored address, unconditionally — resolution is `emit`'s own refusal
597
- * (`emit.ts`), not this row's concern.
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 = hostAddress(member.kind, member.name);
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(member.name, value));
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(hostName, value) {
634
+ function embeddedLeafMentionRows(host, value) {
631
635
  const rows = [];
632
- const addressed = (childPath) => leafAddress(hostName, value.kind, value.key, childPath);
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 `kind:name` address and the include target'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 {@link resolveLeaf}) and a `file()` body names none.
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 = hostAddress(member.kind, member.name);
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 `kind:name` address and the input's path resolved
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 = hostAddress(member.kind, member.name);
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
- * each `Text`-authored leaf resolved to its final stored string
709
- * ([`NestedMemberRow`]), mention-resolution-checked against `scope` the identical
710
- * way `emit.ts`'s `renderMemberToml` checks the same leaf on its way into the
711
- * rendered fence — plus the `placed_edges` record `emit` observed while rendering the
712
- * same value, which is the only way an edge's placement reaches the engine.
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 context = (childPath) => `member.${value.kind} ${value.key}: leaf \`${childPath}\``;
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. Only a composed body's embedded values carry
778
- * them (a `file()`/`text` body — and a composed body's prose spans — name none); the
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 = hostAddress(member.kind, member.name);
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
- export function registrationRows(harness) {
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
- export function tapHookRows(harness) {
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
- * `kind:name` ∪ each `blocks()`-declared embedded member's host-scoped
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(hostAddress(member.kind, member.name));
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(hostAddress(member.kind, member.name), value.kind, value.key));
1009
+ set.add(nestedAddress(memberAddress(member), value.kind, value.key));
1017
1010
  }
1018
1011
  }
1019
1012
  return set;