@dtmd/temper 0.0.19 → 0.0.21
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.d.ts +20 -5
- package/dist/src/assembly.js +16 -6
- package/dist/src/builtins.d.ts +241 -52
- package/dist/src/builtins.js +248 -42
- package/dist/src/claude-code.d.ts +3 -2
- package/dist/src/claude-code.js +8 -1
- package/dist/src/contract.d.ts +20 -1
- package/dist/src/contract.js +20 -1
- package/dist/src/declarations.d.ts +43 -19
- package/dist/src/declarations.js +107 -23
- package/dist/src/emit.d.ts +9 -5
- package/dist/src/emit.js +70 -24
- package/dist/src/generated/AssemblyFactRow.d.ts +7 -5
- package/dist/src/generated/Declarations.d.ts +2 -2
- package/dist/src/generated/gate-commands.d.ts +2 -0
- package/dist/src/generated/gate-commands.js +3 -0
- package/dist/src/generated/index.d.ts +1 -0
- package/dist/src/generated/index.js +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/kind.d.ts +11 -4
- package/dist/src/kind.js +33 -2
- package/dist/src/member-address.d.ts +39 -0
- package/dist/src/member-address.js +43 -0
- package/dist/src/prose.d.ts +15 -10
- package/dist/src/prose.js +11 -6
- package/package.json +3 -3
package/dist/src/declarations.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
import { fileURLToPath } from "node:url";
|
|
12
12
|
import { isDeepStrictEqual } from "node:util";
|
|
13
13
|
import { isTextSpan, resolveLeaf } from "./prose.js";
|
|
14
|
-
import { SETTINGS_MANIFEST, TELEMETRY_EVENT_HOOKS, hook, tapHookRegistration } from "./builtins.js";
|
|
14
|
+
import { HOOK_HANDLER_KEY, HOOK_MATCHER_KEY, SETTINGS_MANIFEST, TELEMETRY_EVENT_HOOKS, hook, hookCollectionKey, tapHookRegistration, } from "./builtins.js";
|
|
15
15
|
import { hostAddress, leafAddress, nestedAddress } from "./member-address.js";
|
|
16
16
|
/**
|
|
17
17
|
* Compile one `Clause` into its lock row: the shared `key`/`field`/`severity`/
|
|
@@ -538,7 +538,17 @@ function verifierRow(verifier) {
|
|
|
538
538
|
}
|
|
539
539
|
/**
|
|
540
540
|
* The assembly-scope facts, in a stable order: the root member's declared `mode`, then
|
|
541
|
-
* one
|
|
541
|
+
* one `contract` declaredness marker per `expect`-bound kind (kind-sorted, as `expect`'s
|
|
542
|
+
* own clause rows are) plus the root's where the author declared one, then one edge row
|
|
543
|
+
* per kind edge field.
|
|
544
|
+
*
|
|
545
|
+
* The `contract` marker is what makes an authored empty clause array a declared contract:
|
|
546
|
+
* a clause row count cannot tell `expect(kind, [])` from a kind the program never bound,
|
|
547
|
+
* nor a root `contract: []` from silence, so declaredness rides its own fact and
|
|
548
|
+
* `compose`'s two rows-or-default branches read it (decision 0072). It names its kind in
|
|
549
|
+
* the row's `from` column — the same column an `edge` fact names its source kind in — and
|
|
550
|
+
* omits `from` entirely for the root, the kind-absent-means-root discriminator a root
|
|
551
|
+
* clause row already uses.
|
|
542
552
|
*
|
|
543
553
|
* `kinds` is every kind in play at *any* locus, not just the unit-owning ones that take
|
|
544
554
|
* a kind-fact row: an edge is a declared relationship at any grain, so an embedded
|
|
@@ -547,6 +557,11 @@ function verifierRow(verifier) {
|
|
|
547
557
|
*/
|
|
548
558
|
function assemblyFactRows(harness, kinds) {
|
|
549
559
|
const facts = [{ fact: "mode", value: harness.mode }];
|
|
560
|
+
for (const binding of [...harness.expect].sort((a, b) => compareStrings(a.kind.key, b.kind.key))) {
|
|
561
|
+
facts.push({ fact: "contract", from: binding.kind.key });
|
|
562
|
+
}
|
|
563
|
+
if (harness.contractDeclared)
|
|
564
|
+
facts.push({ fact: "contract" });
|
|
550
565
|
for (const kind of kinds) {
|
|
551
566
|
for (const edge of kind.edgeFields ?? []) {
|
|
552
567
|
facts.push({ fact: "edge", from: kind.name, field: edge.field, to: [...edge.to] });
|
|
@@ -688,14 +703,6 @@ function inputRows(harness) {
|
|
|
688
703
|
}
|
|
689
704
|
return rows;
|
|
690
705
|
}
|
|
691
|
-
/**
|
|
692
|
-
* One composed embedded value's key in an {@link EdgePlacements} table — its host's
|
|
693
|
-
* `kind:name` address plus the value's own kind and key, the same triple the
|
|
694
|
-
* `nested_member` row it feeds is identified by.
|
|
695
|
-
*/
|
|
696
|
-
export function placementKey(host, kind, key) {
|
|
697
|
-
return `${host}${kind}${key}`;
|
|
698
|
-
}
|
|
699
706
|
/**
|
|
700
707
|
* One host member's declared embedded-member value as its declaration row —
|
|
701
708
|
* each `Text`-authored leaf resolved to its final stored string
|
|
@@ -720,7 +727,7 @@ function nestedMemberRow(host, value, scope, placements, extents) {
|
|
|
720
727
|
return { key: entry.key, leaves: entryLeaves };
|
|
721
728
|
});
|
|
722
729
|
}
|
|
723
|
-
const key =
|
|
730
|
+
const key = nestedAddress(host, value.kind, value.key);
|
|
724
731
|
const placed = placements?.get(key);
|
|
725
732
|
const extent = extents?.get(key);
|
|
726
733
|
return {
|
|
@@ -803,11 +810,17 @@ function nestedMemberRows(harness, admissions, scope, placements, extents) {
|
|
|
803
810
|
/**
|
|
804
811
|
* The `registration` rows — every fields-only registration member (a hook, an MCP server)
|
|
805
812
|
* erased for the manifest write face, kind-then-key sorted so double emit is byte-stable.
|
|
806
|
-
* Each carries its
|
|
807
|
-
* the wire's snake_case `key_path`), and its folded typed fields —
|
|
808
|
-
* engine's write face places under `key`. The
|
|
809
|
-
*
|
|
810
|
-
*
|
|
813
|
+
* Each carries its **collection key** (`kind`/`key`), its collection address
|
|
814
|
+
* (`manifest`/`keyPath`, the wire's snake_case `key_path`), and its folded typed fields —
|
|
815
|
+
* the entry value the engine's write face places under `key`. The authored half alone:
|
|
816
|
+
* the synthesized tap hooks join these rows in {@link mergedRegistrationRows}, which is
|
|
817
|
+
* what both readers of the family take.
|
|
818
|
+
*
|
|
819
|
+
* The row's `key` is where the entry **writes**, which for every kind but one is the
|
|
820
|
+
* member's own name. A hook's name joins its matcher onto the event because the group is
|
|
821
|
+
* the member, while the group still writes under `hooks.<Event>` — so the row keys the
|
|
822
|
+
* event back off the name ({@link hookCollectionKey}) and the member's address keeps the
|
|
823
|
+
* join.
|
|
811
824
|
*
|
|
812
825
|
* # Throws
|
|
813
826
|
* If a fields-only member declares no collection address — it surfaces in no host manifest.
|
|
@@ -823,7 +836,7 @@ export function registrationRows(harness) {
|
|
|
823
836
|
}
|
|
824
837
|
return {
|
|
825
838
|
kind: member.kind,
|
|
826
|
-
key: member.name,
|
|
839
|
+
key: member.kind === hook.key ? hookCollectionKey(member.name) : member.name,
|
|
827
840
|
manifest: address.manifest,
|
|
828
841
|
key_path: address.keyPath,
|
|
829
842
|
// The generated row carries a mutable field list; the member's is read-only, so
|
|
@@ -853,11 +866,14 @@ export function buildTapHookDedupeKey(event, matcher) {
|
|
|
853
866
|
* unions the lifecycle events they name into one dumb registration apiece: the tap
|
|
854
867
|
* records every fire and read time joins raw events to members, so however many
|
|
855
868
|
* verifiers name an event it takes exactly one hook — the derived-aggregate precedent
|
|
856
|
-
* the permission union sets ({@link permissionUnion}). Each row
|
|
857
|
-
* under the event's documented matcher
|
|
858
|
-
*
|
|
859
|
-
* `builtins.ts`); an event-name outside that table is the
|
|
860
|
-
* finding, never a row.
|
|
869
|
+
* the permission union sets ({@link permissionUnion}). Each row is one matcher group
|
|
870
|
+
* running {@link TAP_COMMAND} under the event's documented matcher
|
|
871
|
+
* ({@link TELEMETRY_EVENT_HOOKS}), its key-path and fields sourced from the provider face
|
|
872
|
+
* ({@link tapHookRegistration}, `builtins.ts`); an event-name outside that table is the
|
|
873
|
+
* roster's inadmissibility finding, never a row. Synthesized in isolation here — whether a
|
|
874
|
+
* row stands alone or joins an authored group at the same pair is
|
|
875
|
+
* {@link mergedRegistrationRows}'s call, so this pass need not know what the program
|
|
876
|
+
* authored.
|
|
861
877
|
*/
|
|
862
878
|
export function tapHookRows(harness) {
|
|
863
879
|
const deduped = new Map();
|
|
@@ -889,6 +905,74 @@ export function tapHookRows(harness) {
|
|
|
889
905
|
};
|
|
890
906
|
});
|
|
891
907
|
}
|
|
908
|
+
/** A hook registration row's matcher — the group-level half of its identity, an omitted
|
|
909
|
+
* one read as the empty matcher it means (`"*"`/`""`/absent all name every tool). */
|
|
910
|
+
function groupMatcher(row) {
|
|
911
|
+
const found = row.fields.find(([name]) => name === HOOK_MATCHER_KEY)?.[1];
|
|
912
|
+
return typeof found === "string" ? found : "";
|
|
913
|
+
}
|
|
914
|
+
/** A hook registration row's handlers — the entries of its `hooks` array, or none where the
|
|
915
|
+
* row spells no array at all. */
|
|
916
|
+
function groupHandlers(row) {
|
|
917
|
+
const found = row.fields.find(([name]) => name === HOOK_HANDLER_KEY)?.[1];
|
|
918
|
+
return Array.isArray(found) ? found : [];
|
|
919
|
+
}
|
|
920
|
+
/** `row` with `extra` appended to its handler array — a fresh row over a fresh array, never
|
|
921
|
+
* a mutation: the authored array is the composing program's own value, and `emit` must be
|
|
922
|
+
* callable twice on one harness for the same bytes. */
|
|
923
|
+
function withHandlers(row, extra) {
|
|
924
|
+
const handlers = [...groupHandlers(row), ...extra];
|
|
925
|
+
const carried = row.fields.some(([name]) => name === HOOK_HANDLER_KEY);
|
|
926
|
+
const fields = row.fields.map(([name, value]) => name === HOOK_HANDLER_KEY ? [name, handlers] : [name, value]);
|
|
927
|
+
return { ...row, fields: carried ? fields : [...fields, [HOOK_HANDLER_KEY, handlers]] };
|
|
928
|
+
}
|
|
929
|
+
/**
|
|
930
|
+
* Every `registration` row the program carries — the authored fields-only members
|
|
931
|
+
* ({@link registrationRows}) with the synthesized tap hooks ({@link tapHookRows}) **joined
|
|
932
|
+
* in**, and the one home both readers take: `compileDeclarations` writes it to
|
|
933
|
+
* `declarations.registrations` and `emit.ts`'s public {@link RegistrationFact} view maps
|
|
934
|
+
* from it, so the seam payload and the `EmitResult` sibling cannot disagree on whether a
|
|
935
|
+
* tap joined an authored group (`specs/process/engineering.md`, "One job, one home").
|
|
936
|
+
*
|
|
937
|
+
* A tap hook is an ordinary matcher group, so a tap whose (event, matcher) an authored
|
|
938
|
+
* group already claims **is** that group's further handler rather than a second group at
|
|
939
|
+
* the same key (0075): its handlers append to the claimant's `hooks` array in tap order,
|
|
940
|
+
* and only an unclaimed pair mints a row of its own. The claimant is the first authored
|
|
941
|
+
* row at the pair — a repeated pair joins one group rather than fanning the tap across
|
|
942
|
+
* every one of them. Authored rows keep their own order and position, so the merge moves
|
|
943
|
+
* no byte that did not need to move.
|
|
944
|
+
*
|
|
945
|
+
* # Throws
|
|
946
|
+
* If a fields-only member declares no collection address ({@link registrationRows}).
|
|
947
|
+
*/
|
|
948
|
+
export function mergedRegistrationRows(harness) {
|
|
949
|
+
const authored = registrationRows(harness);
|
|
950
|
+
const claimant = new Map();
|
|
951
|
+
authored.forEach((row, index) => {
|
|
952
|
+
if (row.kind !== hook.key)
|
|
953
|
+
return;
|
|
954
|
+
const key = buildTapHookDedupeKey(row.key, groupMatcher(row));
|
|
955
|
+
if (!claimant.has(key))
|
|
956
|
+
claimant.set(key, index);
|
|
957
|
+
});
|
|
958
|
+
const joined = new Map();
|
|
959
|
+
const unclaimed = [];
|
|
960
|
+
for (const tap of tapHookRows(harness)) {
|
|
961
|
+
const index = claimant.get(buildTapHookDedupeKey(tap.key, groupMatcher(tap)));
|
|
962
|
+
if (index === undefined) {
|
|
963
|
+
unclaimed.push(tap);
|
|
964
|
+
continue;
|
|
965
|
+
}
|
|
966
|
+
const handlers = joined.get(index) ?? [];
|
|
967
|
+
handlers.push(...groupHandlers(tap));
|
|
968
|
+
joined.set(index, handlers);
|
|
969
|
+
}
|
|
970
|
+
const rows = authored.map((row, index) => {
|
|
971
|
+
const extra = joined.get(index);
|
|
972
|
+
return extra === undefined ? row : withHandlers(row, extra);
|
|
973
|
+
});
|
|
974
|
+
return [...rows, ...unclaimed];
|
|
975
|
+
}
|
|
892
976
|
/**
|
|
893
977
|
* The `settings` rows — the assembly's harness-level residual settings keys, each folded
|
|
894
978
|
* into the settings.json manifest's opaque residue at emit. Key-sorted so double emit is
|
|
@@ -987,7 +1071,7 @@ export function compileDeclarations(harness, placements, extents) {
|
|
|
987
1071
|
includes: includeRows(harness),
|
|
988
1072
|
inputs: inputRows(harness),
|
|
989
1073
|
nested_members: nestedMemberRows(harness, admissions, mentionScope(harness), placements, extents),
|
|
990
|
-
registrations:
|
|
1074
|
+
registrations: mergedRegistrationRows(harness),
|
|
991
1075
|
settings: settingsRows(harness),
|
|
992
1076
|
};
|
|
993
1077
|
}
|
package/dist/src/emit.d.ts
CHANGED
|
@@ -38,8 +38,9 @@ export interface ResolveOptions {
|
|
|
38
38
|
/** The addresses a mention may name — resolution-checked; a mention cannot dangle. */
|
|
39
39
|
readonly mentionable?: ReadonlySet<string>;
|
|
40
40
|
/**
|
|
41
|
-
* The discoverable (`at`-locus) kinds the program declares. A
|
|
42
|
-
* these whose member is not composed defers to `check` rather than refusing at emit
|
|
41
|
+
* The discoverable (`at`-locus) kinds the program declares. A reference naming one of
|
|
42
|
+
* these whose member is not composed defers to `check` rather than refusing at emit —
|
|
43
|
+
* a mention and an embedded value's edge target alike.
|
|
43
44
|
*/
|
|
44
45
|
readonly deferrableKinds?: ReadonlySet<string>;
|
|
45
46
|
/**
|
|
@@ -47,8 +48,10 @@ export interface ResolveOptions {
|
|
|
47
48
|
* resolves against to derive its target facts. Top-level members index at their
|
|
48
49
|
* `kind:name` address, and each composed embedded value at both of its own spellings:
|
|
49
50
|
* its full `<host-address>/<kind>/<key>` address and its bare `kind:key`.
|
|
50
|
-
*
|
|
51
|
-
*
|
|
51
|
+
* Refusal reaches exactly as far as the program's own universe, the one rule a mention
|
|
52
|
+
* and an edge target share: an address this table misses refuses, unless it names a kind
|
|
53
|
+
* {@link deferrableKinds} carries — then the member may be discovered on disk, and the
|
|
54
|
+
* field defers to `check` with no facts derived.
|
|
52
55
|
*/
|
|
53
56
|
readonly members?: ReadonlyMap<string, EdgeTarget>;
|
|
54
57
|
}
|
|
@@ -62,7 +65,8 @@ export interface ResolveOptions {
|
|
|
62
65
|
export interface RegistrationFact {
|
|
63
66
|
/** The erased registration kind — `hook`, `mcp-server` — joining `declarations.kinds`. */
|
|
64
67
|
readonly kind: string;
|
|
65
|
-
/** The
|
|
68
|
+
/** The collection key the entry writes under — a hook's event, a server's name. Not
|
|
69
|
+
* the member's own name where the two differ: a hook's name joins its matcher. */
|
|
66
70
|
readonly key: string;
|
|
67
71
|
/** The manifest collection address the registration surfaces at. */
|
|
68
72
|
readonly collectionAddress: {
|
package/dist/src/emit.js
CHANGED
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { fileURLToPath } from "node:url";
|
|
12
12
|
import { readFileSync } from "node:fs";
|
|
13
|
-
import { checkMentions, isTextSpan, renderText, resolveLeaf } from "./prose.js";
|
|
13
|
+
import { checkMentions, defersToGate, isTextSpan, renderText, resolveLeaf } from "./prose.js";
|
|
14
14
|
import { permissionUnion } from "./needs.js";
|
|
15
|
-
import { compareStrings, compileDeclarations, declaredAddresses, declaredAtLocusKinds, declaredRequirements, encodeSeam,
|
|
15
|
+
import { compareStrings, compileDeclarations, declaredAddresses, declaredAtLocusKinds, declaredRequirements, encodeSeam, mergedRegistrationRows, settingsRows, uniqueMap, } from "./declarations.js";
|
|
16
16
|
import { bareLookupKey, edgeLookupKey, hostAddress, 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) {
|
|
@@ -176,16 +176,23 @@ function relativeProjection(from, to) {
|
|
|
176
176
|
* selects them renders a reference true by construction; the four are the whole set.
|
|
177
177
|
*
|
|
178
178
|
* An unfilled leaf is no edge, so it contributes no entry: requiredness is the kind's
|
|
179
|
-
* own field schema, which fails in the author's program at compose time.
|
|
179
|
+
* own field schema, which fails in the author's program at compose time. A filled leaf
|
|
180
|
+
* whose address {@link defersToGate} admits derives none either — the program's own
|
|
181
|
+
* universe does not reach it, so the address rides the lock as authored and `check` owns
|
|
182
|
+
* its route verdict, exactly as a dangling mention defers (`pipeline.md`, "Emit", the
|
|
183
|
+
* "Refusing" bullet). Such a field is reported by name in {@link EdgeTargets.deferred}
|
|
184
|
+
* rather than dropped, so reading it refuses by name ({@link deferringTargets}) instead
|
|
185
|
+
* of surfacing as an absent key.
|
|
180
186
|
*
|
|
181
187
|
* # Throws
|
|
182
|
-
* If a filled leaf names no composed member
|
|
183
|
-
* point at, or names a bare nested key several hosts carry
|
|
184
|
-
* ({@link resolvedTargetFacts}).
|
|
185
|
-
* mention may: the reference is written now, and there is nothing true to write.
|
|
188
|
+
* If a filled leaf names no composed member and no declared `at`-locus kind either, names
|
|
189
|
+
* one that owns no projection to point at, or names a bare nested key several hosts carry
|
|
190
|
+
* ({@link resolvedTargetFacts}).
|
|
186
191
|
*/
|
|
187
192
|
function edgeTargetFacts(host, value, leaves, options) {
|
|
188
|
-
const
|
|
193
|
+
const facts = {};
|
|
194
|
+
const deferred = new Map();
|
|
195
|
+
const { deferrableKinds } = scopeOf(options);
|
|
189
196
|
const context = `member \`${host.name}\`: embedded value \`${value.key}\` of kind \`${value.kind}\``;
|
|
190
197
|
for (const edge of value.edgeFields ?? []) {
|
|
191
198
|
const address = leaves[edge.field];
|
|
@@ -195,12 +202,47 @@ function edgeTargetFacts(host, value, leaves, options) {
|
|
|
195
202
|
const target = options.members?.get(lookup);
|
|
196
203
|
const reference = `${context}: edge field \`${edge.field}\` names \`${address}\``;
|
|
197
204
|
if (target === undefined) {
|
|
205
|
+
// Judged on the address the author wrote, never `lookup`: the one-element-`to` lift
|
|
206
|
+
// spells a bare name as a host address for the member table alone, and a bare name
|
|
207
|
+
// names no discoverable member.
|
|
208
|
+
if (defersToGate(address, deferrableKinds)) {
|
|
209
|
+
deferred.set(edge.field, reference);
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
198
212
|
throw new Error(`${reference}, which resolves to no composed member — an edge target's facts are ` +
|
|
199
213
|
`derived, never fabricated (specs/model/pipeline.md, "Emit", the "Refusing" bullet).`);
|
|
200
214
|
}
|
|
201
|
-
|
|
215
|
+
facts[edge.field] = resolvedTargetFacts(host, target, lookup, reference);
|
|
202
216
|
}
|
|
203
|
-
return
|
|
217
|
+
return { facts, deferred };
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* The `targets` view a `render` hook receives: the resolved facts, plus a trap that
|
|
221
|
+
* refuses by name on a deferred edge field. Emit derives no facts for a target `check`
|
|
222
|
+
* owns, and a format cannot spell a reference off facts that do not exist — so the read
|
|
223
|
+
* is the failure, and it names the member, the value, the field and the address rather
|
|
224
|
+
* than surfacing as a `TypeError` off an absent key in the author's own template
|
|
225
|
+
* (invariant 6, "Loud or nothing").
|
|
226
|
+
*
|
|
227
|
+
* Only a string key in the deferred set is trapped: a symbol get — inspection, a `then`
|
|
228
|
+
* probe — reads through untouched. `ownKeys` is deliberately untrapped, so the deferred
|
|
229
|
+
* field stays invisible to {@link placedEdges}'s `Object.keys` and earns no
|
|
230
|
+
* `format-places-edges` obligation.
|
|
231
|
+
*/
|
|
232
|
+
function deferringTargets(targets) {
|
|
233
|
+
if (targets.deferred.size === 0)
|
|
234
|
+
return targets.facts;
|
|
235
|
+
return new Proxy(targets.facts, {
|
|
236
|
+
get(record, property, receiver) {
|
|
237
|
+
const reference = typeof property === "string" ? targets.deferred.get(property) : undefined;
|
|
238
|
+
if (reference !== undefined) {
|
|
239
|
+
throw new Error(`${reference}, whose target defers to \`check\` — emit derives no facts for it, so a ` +
|
|
240
|
+
`format cannot spell a reference off it (specs/model/pipeline.md, "Emit", the ` +
|
|
241
|
+
`"Refusing" bullet).`);
|
|
242
|
+
}
|
|
243
|
+
return Reflect.get(record, property, receiver);
|
|
244
|
+
},
|
|
245
|
+
});
|
|
204
246
|
}
|
|
205
247
|
/** Whether an address named the nested index — the embedded values one spelling reaches. */
|
|
206
248
|
function isNested(target) {
|
|
@@ -283,7 +325,7 @@ function resolveMemberLeaves(host, value, options) {
|
|
|
283
325
|
key: value.key,
|
|
284
326
|
leaves,
|
|
285
327
|
collections,
|
|
286
|
-
targets: edgeTargetFacts(host, value, leaves, options),
|
|
328
|
+
targets: deferringTargets(edgeTargetFacts(host, value, leaves, options)),
|
|
287
329
|
};
|
|
288
330
|
}
|
|
289
331
|
/**
|
|
@@ -356,10 +398,12 @@ function recordingView(resolved, edgeFields, placed) {
|
|
|
356
398
|
* declares one runs the hook against a {@link recordingView} and reports what it
|
|
357
399
|
* selected.
|
|
358
400
|
*
|
|
359
|
-
* The obligation ranges over the edges this value *fills*, never its kind's
|
|
360
|
-
* declared set: an unfilled field is no edge, so a format cannot omit it
|
|
361
|
-
*
|
|
362
|
-
*
|
|
401
|
+
* The obligation ranges over the edges this value *fills and resolves*, never its kind's
|
|
402
|
+
* whole declared set: an unfilled field is no edge, so a format cannot omit it, and a
|
|
403
|
+
* field whose target defers to `check` carries no facts to place — the route verdict is
|
|
404
|
+
* the gate's, not this clause's. `undefined` when the value leaves the set empty — there
|
|
405
|
+
* is nothing to place, so the row records nothing rather than an empty column on every
|
|
406
|
+
* ordinary value.
|
|
363
407
|
*
|
|
364
408
|
* This renders the value a second time, the way `nestedMemberRow` reads its leaves a
|
|
365
409
|
* second time: a hook is pure (emit double-verifies its own bytes), so the observing
|
|
@@ -369,7 +413,8 @@ function placedEdges(host, value, options) {
|
|
|
369
413
|
if ((value.edgeFields ?? []).length === 0)
|
|
370
414
|
return undefined;
|
|
371
415
|
const resolved = resolveMemberLeaves(host, value, options);
|
|
372
|
-
// `targets` carries exactly the filled edge fields — an unfilled one
|
|
416
|
+
// `targets` carries exactly the filled, resolved edge fields — an unfilled one and a
|
|
417
|
+
// deferred one each derive no facts.
|
|
373
418
|
const edgeFields = new Set(Object.keys(resolved.targets));
|
|
374
419
|
if (edgeFields.size === 0)
|
|
375
420
|
return undefined;
|
|
@@ -381,7 +426,7 @@ function placedEdges(host, value, options) {
|
|
|
381
426
|
}
|
|
382
427
|
/**
|
|
383
428
|
* Every composed embedded value's placed edge fields, keyed by the value's
|
|
384
|
-
* {@link
|
|
429
|
+
* {@link nestedAddress} — what `emit` hands {@link compileDeclarations} so each
|
|
385
430
|
* `nested_member` row carries its own format's placement record. Iterates exactly the
|
|
386
431
|
* values `nestedMemberRows` does, so every edge-bearing row it builds has an observation.
|
|
387
432
|
*/
|
|
@@ -395,7 +440,7 @@ function edgePlacements(harness, options) {
|
|
|
395
440
|
continue;
|
|
396
441
|
const placed = placedEdges(member, value, options);
|
|
397
442
|
if (placed !== undefined) {
|
|
398
|
-
entries.push([
|
|
443
|
+
entries.push([nestedAddress(hostAddress(member.kind, member.name), value.kind, value.key), placed]);
|
|
399
444
|
}
|
|
400
445
|
}
|
|
401
446
|
}
|
|
@@ -415,7 +460,7 @@ function renderedLineCount(block) {
|
|
|
415
460
|
}
|
|
416
461
|
/**
|
|
417
462
|
* Every composed embedded value's rendered extent — the line and character count of the
|
|
418
|
-
* block `emit` projected for it — keyed by its {@link
|
|
463
|
+
* block `emit` projected for it — keyed by its {@link nestedAddress}, what `emit` hands
|
|
419
464
|
* {@link compileDeclarations} so each `nested_member` row carries the span an `extent`
|
|
420
465
|
* clause budgets. Iterates exactly the values {@link edgePlacements} does, rendering each
|
|
421
466
|
* through the same {@link renderMemberBlock} the body projection uses (a hook is pure, so
|
|
@@ -436,7 +481,7 @@ function renderedExtents(harness, options) {
|
|
|
436
481
|
continue;
|
|
437
482
|
const block = renderMemberBlock(member, value, options);
|
|
438
483
|
entries.push([
|
|
439
|
-
|
|
484
|
+
nestedAddress(hostAddress(member.kind, member.name), value.kind, value.key),
|
|
440
485
|
{
|
|
441
486
|
lines: renderedLineCount(block),
|
|
442
487
|
// Unicode scalar values, matching Rust's `chars().count()` — iterating a string
|
|
@@ -560,15 +605,16 @@ function fileSourcePath(member) {
|
|
|
560
605
|
* The harness's registration write facts as the public {@link RegistrationFact} view —
|
|
561
606
|
* the seam's own `registration` rows mapped to the nested `collectionAddress` shape the
|
|
562
607
|
* `EmitResult` sibling exposes, so the two cannot disagree on what a manifest carries.
|
|
563
|
-
* The
|
|
564
|
-
* hooks a telemetry verifier synthesizes
|
|
565
|
-
*
|
|
608
|
+
* The rows are {@link mergedRegistrationRows}' — the fields-only registration members
|
|
609
|
+
* with the memberless tap hooks a telemetry verifier synthesizes joined into them — the
|
|
610
|
+
* one home `compileDeclarations` also reads for `declarations.registrations`, so a tap
|
|
611
|
+
* that joined an authored group did so for both faces or for neither.
|
|
566
612
|
*
|
|
567
613
|
* # Throws
|
|
568
614
|
* If a fields-only member declares no collection address — it surfaces in no manifest.
|
|
569
615
|
*/
|
|
570
616
|
function registrationFacts(harness) {
|
|
571
|
-
return
|
|
617
|
+
return mergedRegistrationRows(harness).map((row) => ({
|
|
572
618
|
kind: row.kind,
|
|
573
619
|
key: row.key,
|
|
574
620
|
collectionAddress: { manifest: row.manifest, keyPath: row.key_path },
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* One assembly-scope fact — the root member's own declarations plus the
|
|
3
|
-
* graph edges the harness binds: a `fact` discriminator (`mode`, `
|
|
4
|
-
* plus the columns that fact carries. Absent columns are omitted from
|
|
5
|
-
* lock, so each row round-trips to exactly what its producer wrote.
|
|
3
|
+
* graph edges the harness binds: a `fact` discriminator (`mode`, `contract`,
|
|
4
|
+
* `edge`) plus the columns that fact carries. Absent columns are omitted from
|
|
5
|
+
* the lock, so each row round-trips to exactly what its producer wrote.
|
|
6
6
|
*/
|
|
7
7
|
export type AssemblyFactRow = {
|
|
8
8
|
/**
|
|
9
|
-
* The fact discriminator: `mode` or `edge`.
|
|
9
|
+
* The fact discriminator: `mode`, `contract` or `edge`.
|
|
10
10
|
*/
|
|
11
11
|
fact: string;
|
|
12
12
|
/**
|
|
@@ -15,7 +15,9 @@ export type AssemblyFactRow = {
|
|
|
15
15
|
*/
|
|
16
16
|
value?: string;
|
|
17
17
|
/**
|
|
18
|
-
* An `edge` fact's source kind
|
|
18
|
+
* An `edge` fact's source kind, or the kind a `contract` fact marks a declared
|
|
19
|
+
* contract for — absent on a `contract` fact, which makes it the root's, the same
|
|
20
|
+
* kind-absent-means-root discriminator a top-level clause row uses.
|
|
19
21
|
*/
|
|
20
22
|
from?: string;
|
|
21
23
|
/**
|
|
@@ -43,8 +43,8 @@ export type Declarations = {
|
|
|
43
43
|
*/
|
|
44
44
|
requirements: Array<RequirementRow>;
|
|
45
45
|
/**
|
|
46
|
-
* The assembly-scope facts — the root member's declared enforcement `mode`,
|
|
47
|
-
* edges.
|
|
46
|
+
* The assembly-scope facts — the root member's declared enforcement `mode`, the
|
|
47
|
+
* declared-contract markers, edges.
|
|
48
48
|
*/
|
|
49
49
|
assembly: Array<AssemblyFactRow>;
|
|
50
50
|
/**
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const GUARD_COMMAND = "command -v temper >/dev/null 2>&1 || { echo \"temper: command not found\" >&2; exit 127; } && temper guard .";
|
|
2
|
+
export declare const SESSION_START_COMMAND = "command -v temper >/dev/null 2>&1 || { echo \"temper: command not found\" >&2; exit 127; } && temper check . --reporter session-start";
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// This file carries temper's gate commands, generated from the engine's own constants. Do not edit this file manually.
|
|
2
|
+
export const GUARD_COMMAND = "command -v temper >/dev/null 2>&1 || { echo \"temper: command not found\" >&2; exit 127; } && temper guard .";
|
|
3
|
+
export const SESSION_START_COMMAND = "command -v temper >/dev/null 2>&1 || { echo \"temper: command not found\" >&2; exit 127; } && temper check . --reporter session-start";
|
|
@@ -34,3 +34,4 @@ export type { Shape } from "./Shape.js";
|
|
|
34
34
|
export type { TemplateRow } from "./TemplateRow.js";
|
|
35
35
|
export type { ValueType } from "./ValueType.js";
|
|
36
36
|
export type { Verifier } from "./Verifier.js";
|
|
37
|
+
export { GUARD_COMMAND, SESSION_START_COMMAND } from "./gate-commands.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export { GUARD_COMMAND, SESSION_START_COMMAND } from "./gate-commands.js";
|
package/dist/src/index.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export { blocks, file, include, mentionOf, renderText, span, text } from "./pros
|
|
|
17
17
|
export type { Capability } from "./needs.js";
|
|
18
18
|
export { bash, capability, permissionUnion } from "./needs.js";
|
|
19
19
|
export type { Charset, Clause, ExtentUnit, Predicate, Requirement, Severity, Verifier } from "./contract.js";
|
|
20
|
-
export { allowedChars, clause, closedKeys, count, degree, deny, enumOf, extent, forbiddenKeys, formatPlacesEdges, fresh, globValid, locusDeclared, maxLen, membership, mentionReachable, minLen, mustDefine, nameMatchesDir, optional, range, reachable, reachedFrom, required, requireSections, requirement, script, sectionContains, shape, telemetry, type, unique, uniqueName, when, } from "./contract.js";
|
|
20
|
+
export { allowedChars, clause, closedKeys, count, degree, deny, engineMatches, enumOf, extent, forbiddenKeys, formatPlacesEdges, fresh, globValid, locusDeclared, maxLen, membership, mentionReachable, minLen, mustDefine, nameMatchesDir, optional, range, reachable, reachedFrom, required, requireSections, requirement, script, sectionContains, shape, telemetry, type, unique, uniqueName, when, } from "./contract.js";
|
|
21
21
|
export type { CollectionAddress, EdgeField, EdgeTargetFacts, EmbeddedMemberCollectionEntry, EmbeddedMemberValue, Format, Input, KindDefinition, KindFacts, KindOptions, KindRelocation, Layout, LayoutRegion, LeafSet, Locus, Member, MemberInit, Registration, Residue, ResolvedEmbeddedMemberCollectionEntry, ResolvedEmbeddedMemberValue, Shape, Template, UnitShape, } from "./kind.js";
|
|
22
22
|
export { embeddedMemberValue, kind, relocate } from "./kind.js";
|
|
23
23
|
export { input } from "./kind.js";
|
package/dist/src/index.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*/
|
|
15
15
|
export { blocks, file, include, mentionOf, renderText, span, text } from "./prose.js";
|
|
16
16
|
export { bash, capability, permissionUnion } from "./needs.js";
|
|
17
|
-
export { allowedChars, clause, closedKeys, count, degree, deny, enumOf, extent, forbiddenKeys, formatPlacesEdges, fresh, globValid, locusDeclared, maxLen, membership, mentionReachable, minLen, mustDefine, nameMatchesDir, optional, range, reachable, reachedFrom, required, requireSections, requirement, script, sectionContains, shape, telemetry, type, unique, uniqueName, when, } from "./contract.js";
|
|
17
|
+
export { allowedChars, clause, closedKeys, count, degree, deny, engineMatches, enumOf, extent, forbiddenKeys, formatPlacesEdges, fresh, globValid, locusDeclared, maxLen, membership, mentionReachable, minLen, mustDefine, nameMatchesDir, optional, range, reachable, reachedFrom, required, requireSections, requirement, script, sectionContains, shape, telemetry, type, unique, uniqueName, when, } from "./contract.js";
|
|
18
18
|
export { embeddedMemberValue, kind, relocate } from "./kind.js";
|
|
19
19
|
// Inputs — the files a member's claims rest on, fingerprinted by the lock and moved
|
|
20
20
|
// nowhere. A member-grain declaration, not a word in a body, so it rides here rather
|
package/dist/src/kind.d.ts
CHANGED
|
@@ -668,10 +668,17 @@ export interface ResolvedEmbeddedMemberValue {
|
|
|
668
668
|
/** Sibling collections, each entry's leaves already resolved. */
|
|
669
669
|
readonly collections: Readonly<Record<string, readonly ResolvedEmbeddedMemberCollectionEntry[]>>;
|
|
670
670
|
/**
|
|
671
|
-
* The target facts of each edge field this value *fills*, keyed by the edge
|
|
672
|
-
* own name — the data a `render` hook selects to spell a reference.
|
|
673
|
-
* field
|
|
674
|
-
* composed off a bare kind name, which carries none
|
|
671
|
+
* The target facts of each edge field this value *fills and resolves*, keyed by the edge
|
|
672
|
+
* field's own name — the data a `render` hook selects to spell a reference. Two cases
|
|
673
|
+
* read absent: an unfilled field (no edge at all), and a kind declaring no edge fields —
|
|
674
|
+
* or a value composed off a bare kind name, which carries none. A hook spelling a
|
|
675
|
+
* reference off such a key must therefore handle its absence. A third derives no facts
|
|
676
|
+
* but does not read absent: a filled field whose target defers to `check`, naming a
|
|
677
|
+
* declared `at`-locus kind's uncomposed member (`pipeline.md`, "Emit", the "Refusing"
|
|
678
|
+
* bullet) — reading it refuses by name at emit, naming the member, the value, the field
|
|
679
|
+
* and the authored address, rather than handing a hook an absent key to trip over. The
|
|
680
|
+
* default TOML view is unaffected either way, writing the authored address leaf whether
|
|
681
|
+
* the program resolves it or the gate does.
|
|
675
682
|
*/
|
|
676
683
|
readonly targets: Readonly<Record<string, EdgeTargetFacts>>;
|
|
677
684
|
}
|
package/dist/src/kind.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* rows. Identity travels by import, never by string — a `kind` reference is the imported
|
|
9
9
|
* value.
|
|
10
10
|
*/
|
|
11
|
+
import { isOneSegment } from "./member-address.js";
|
|
11
12
|
/**
|
|
12
13
|
* Declare a file a member's claims rest on — the lock fingerprints it and no byte
|
|
13
14
|
* reaches the projection. The path resolves against the stating module, so the call is
|
|
@@ -235,6 +236,7 @@ export function relocate(base, delta) {
|
|
|
235
236
|
export function embeddedMemberValue(init) {
|
|
236
237
|
const definition = typeof init.kind === "string" ? undefined : init.kind;
|
|
237
238
|
const kindKey = definition?.key ?? init.kind;
|
|
239
|
+
refuseSegmentedKey(kindKey, init.key);
|
|
238
240
|
refuseReservedLeaf(kindKey, init.key, init.leaves);
|
|
239
241
|
for (const [collection, entries] of Object.entries(init.collections ?? {})) {
|
|
240
242
|
for (const entry of entries) {
|
|
@@ -252,11 +254,40 @@ export function embeddedMemberValue(init) {
|
|
|
252
254
|
...(edgeFields !== undefined ? { edgeFields } : {}),
|
|
253
255
|
};
|
|
254
256
|
}
|
|
257
|
+
/**
|
|
258
|
+
* Refuse an embedded member's key that is not **one address segment** — empty, or carrying
|
|
259
|
+
* the `/` the member-address grammar cuts an address at ({@link isOneSegment}). A member's
|
|
260
|
+
* identity *is* its `<host-address>/<kind>/<key>` address, so a key carrying the separator
|
|
261
|
+
* spells an address one segment too long: `authority/rejected` spells what the sibling
|
|
262
|
+
* keyed `authority` spells for its `rejected` leaf, and every reader answers that address
|
|
263
|
+
* at leaf grain.
|
|
264
|
+
*
|
|
265
|
+
* Refused at compose for the posture {@link refuseReservedLeaf} states for the sibling
|
|
266
|
+
* case: a coincident address is loud at the authoring seam, where the author can still
|
|
267
|
+
* rename, never at emit over bytes already written (0051). The engine's own judge is not
|
|
268
|
+
* this one twice — it judges a committed lock (hand-edited, or written by an older SDK),
|
|
269
|
+
* this one judges the composing program.
|
|
270
|
+
*
|
|
271
|
+
* Scoped to the member's own key: a `collections` entry key lands inside the **leaf tail**,
|
|
272
|
+
* which the grammar defines as the whole remainder after the third slash, so it aliases
|
|
273
|
+
* nothing and is deliberately left legal.
|
|
274
|
+
*
|
|
275
|
+
* # Throws
|
|
276
|
+
* If `key` is empty or carries `/`.
|
|
277
|
+
*/
|
|
278
|
+
function refuseSegmentedKey(kind, key) {
|
|
279
|
+
if (isOneSegment(key))
|
|
280
|
+
return;
|
|
281
|
+
throw new Error(`embedded member \`${kind}\` \`${key}\`: a member's key is one address segment — ` +
|
|
282
|
+
`non-empty and carrying no \`/\`, the separator its address is cut at`);
|
|
283
|
+
}
|
|
255
284
|
/**
|
|
256
285
|
* Refuse a composed leaf named {@link RESERVED_LEAF} — the key a read member's own span
|
|
257
286
|
* owns, so a second meaning under it is a coincident leaf address, refused at compose
|
|
258
287
|
* rather than resolved by precedence (0051). Loud at the authoring seam, where the author
|
|
259
|
-
* can rename the field, not at emit over bytes already written.
|
|
288
|
+
* can rename the field, not at emit over bytes already written. The rename is the whole
|
|
289
|
+
* remedy: an embedded value carries leaves and collections alone, so there is no
|
|
290
|
+
* member-level prose here to move the words into.
|
|
260
291
|
*
|
|
261
292
|
* # Throws
|
|
262
293
|
* If `leaves` carries the reserved key.
|
|
@@ -265,5 +296,5 @@ function refuseReservedLeaf(kind, key, leaves) {
|
|
|
265
296
|
if (!Object.hasOwn(leaves, RESERVED_LEAF))
|
|
266
297
|
return;
|
|
267
298
|
throw new Error(`embedded member \`${kind}\` \`${key}\`: leaf \`${RESERVED_LEAF}\` is reserved for a ` +
|
|
268
|
-
`member's own span — rename the field
|
|
299
|
+
`member's own span — rename the field`);
|
|
269
300
|
}
|
|
@@ -51,6 +51,38 @@ export interface LeafAddress {
|
|
|
51
51
|
export declare function hostAddress(kind: string, name: string): string;
|
|
52
52
|
/** Spell a nested member's address from its host's address, its own kind and its key. */
|
|
53
53
|
export declare function nestedAddress(host: string, kind: string, key: string): string;
|
|
54
|
+
/**
|
|
55
|
+
* Whether `spelling` is exactly **one segment** of this grammar — non-empty, and carrying
|
|
56
|
+
* none of the `/` {@link segment} cuts an address at.
|
|
57
|
+
*
|
|
58
|
+
* The predicate every writer's caller judges a key by, because {@link nestedAddress} is
|
|
59
|
+
* infallible and the reader beneath it is not. A key carrying a `/` shifts every segment
|
|
60
|
+
* below it by one: `nestedAddress("spec:alpha", "decision", "authority/rejected")` spells
|
|
61
|
+
* the very address the member keyed `authority` spells for its `rejected` leaf, and every
|
|
62
|
+
* reader tries leaf grain first — so the member's own identity answers its sibling's leaf.
|
|
63
|
+
* An empty key spells an address {@link segment} admits at no grain at all.
|
|
64
|
+
* `specs/model/representation.md` ("member") makes both a malformed lock rather than a
|
|
65
|
+
* precedence rule: resolution is total, and coincident addresses are refused.
|
|
66
|
+
*
|
|
67
|
+
* The engine's `is_one_segment` is the same predicate at the seam's other end.
|
|
68
|
+
*/
|
|
69
|
+
export declare function isOneSegment(spelling: string): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Whether `spelling` may be joined onto a member's name as a **qualifier** — the text a
|
|
72
|
+
* name carries after its own `:` to tell two members apart that share a collection key (a
|
|
73
|
+
* hook's matcher: `PostToolUse:Edit|Write`).
|
|
74
|
+
*
|
|
75
|
+
* The bar is {@link isOneSegment}'s, less its non-emptiness: a qualifier joins a non-empty
|
|
76
|
+
* key, so the joined name is non-empty whatever the qualifier is, and an **empty**
|
|
77
|
+
* qualifier is a real authored spelling — a group whose `matcher` is `""` is its own group
|
|
78
|
+
* on the wire, and a matcher is carried verbatim, never normalized. What it may not carry
|
|
79
|
+
* is the `/` {@link segment} cuts an address at: the joined name is the first segment of
|
|
80
|
+
* every address beneath the member, so a `/` in it shifts every segment below by one and
|
|
81
|
+
* the member's own handler answers to an address naming no member at all.
|
|
82
|
+
*
|
|
83
|
+
* The engine's `is_name_qualifier` is the same predicate at the seam's other end.
|
|
84
|
+
*/
|
|
85
|
+
export declare function isNameQualifier(spelling: string): boolean;
|
|
54
86
|
/**
|
|
55
87
|
* Spell one leaf's address beneath a nested member. `member` is carried verbatim, so a
|
|
56
88
|
* writer holding the bare member id spells the short form the lock already commits
|
|
@@ -83,6 +115,13 @@ export declare function edgeLookupKey(address: string, to: readonly string[]): s
|
|
|
83
115
|
* ({@link parseNestedAddress}, {@link parseLeafAddress}) and no host address at all. The
|
|
84
116
|
* refusal lives here rather than at each caller, so a reader that asks "is this a host
|
|
85
117
|
* address?" never has to re-spell the separator to get the answer right.
|
|
118
|
+
*
|
|
119
|
+
* A name carrying a colon is not hypothetical: a hook's name is its lifecycle event, then
|
|
120
|
+
* `:` and its matcher's authored bytes (`hook:PostToolUse:Edit|Write`), because the
|
|
121
|
+
* matcher group — not the event — is the member. The grammar is unchanged by it: the
|
|
122
|
+
* split is at the first colon, so the kind comes off and the rest stays one name, and the
|
|
123
|
+
* qualifier joined onto it is judged by {@link isNameQualifier} rather than given a third
|
|
124
|
+
* segment.
|
|
86
125
|
*/
|
|
87
126
|
export declare function parseHostAddress(address: string): HostAddress | undefined;
|
|
88
127
|
/**
|