@junghanacs/entwurf 0.41.2 → 0.45.0

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.
Files changed (41) hide show
  1. package/AGENTS.md +1 -0
  2. package/CHANGELOG.md +159 -0
  3. package/ENTWURF.json +236 -0
  4. package/README.md +12 -7
  5. package/docs/setup-clean-host.md +8 -8
  6. package/mcp/entwurf-bridge/dist/ENTWURF.json +236 -0
  7. package/mcp/entwurf-bridge/dist/mcp/entwurf-bridge/src/index.js +27 -188
  8. package/mcp/entwurf-bridge/dist/pi-extensions/lib/agent-guidance.js +299 -0
  9. package/mcp/entwurf-bridge/dist/pi-extensions/lib/entwurf-v2-surface.js +21 -25
  10. package/mcp/entwurf-bridge/dist/pi-extensions/lib/entwurf-v2-visible-resume.js +15 -11
  11. package/mcp/entwurf-bridge/dist/pi-extensions/lib/mux-fresh-call.js +23 -20
  12. package/mcp/entwurf-bridge/dist/pi-extensions/lib/mux-resume-call.js +18 -16
  13. package/mcp/entwurf-bridge/dist/pi-extensions/lib/remote-pair-send.js +7 -4
  14. package/mcp/entwurf-bridge/dist/pi-extensions/meta-bridge-pi-durable.js +23 -45
  15. package/mcp/entwurf-bridge/src/index.ts +121 -319
  16. package/package.json +3 -2
  17. package/pi-extensions/lib/agent-guidance.ts +341 -0
  18. package/pi-extensions/lib/entwurf-v2-surface.ts +25 -31
  19. package/pi-extensions/lib/entwurf-v2-visible-resume.ts +15 -16
  20. package/pi-extensions/lib/mux-fresh-call.ts +23 -26
  21. package/pi-extensions/lib/mux-resume-call.ts +18 -19
  22. package/pi-extensions/lib/remote-pair-send.ts +7 -4
  23. package/pi-extensions/meta-bridge-pi-durable.ts +23 -64
  24. package/run.sh +9 -0
  25. package/scripts/build-bridge.sh +10 -0
  26. package/scripts/check-capability-bundle-reach.ts +86 -0
  27. package/scripts/check-entwurf-self-address.ts +3 -3
  28. package/scripts/check-entwurf-v2-surface.ts +94 -98
  29. package/scripts/check-gate-qualification.ts +9 -7
  30. package/scripts/check-mux-resume-call.ts +20 -3
  31. package/scripts/mutants/agent-guidance.json +160 -0
  32. package/scripts/mutants/bridge-boot-resume.json +6 -8
  33. package/scripts/mutants/capability-bundle-reach.json +124 -0
  34. package/scripts/mutants/control-send-receipt.json +21 -4
  35. package/scripts/mutants/mux-fresh-call.json +14 -3
  36. package/scripts/mutants/mux-resume-call.json +28 -3
  37. package/scripts/mutants/pi-durable.json +17 -5
  38. package/scripts/mutants/remote-pair-send.json +21 -2
  39. package/scripts/mutants/self-address.json +10 -10
  40. package/scripts/mutants/v2-surface.json +50 -64
  41. package/scripts/mutants/v2-visible-resume.json +11 -0
@@ -21,6 +21,12 @@ import assert from "node:assert/strict";
21
21
  import * as fs from "node:fs/promises";
22
22
  import * as path from "node:path";
23
23
  import { fileURLToPath } from "node:url";
24
+ import {
25
+ ENTWURF_DELIVERY_RESULT_CLAUSES,
26
+ ENTWURF_REJECT_HINTS,
27
+ ENTWURF_SLOTTED_REJECT_HINTS,
28
+ ENTWURF_TOOL_GUIDANCE,
29
+ } from "../pi-extensions/lib/agent-guidance.ts";
24
30
  import type { EntwurfV2RunResult } from "../pi-extensions/lib/entwurf-v2-runner.ts";
25
31
  import {
26
32
  actionableRejectHint,
@@ -28,17 +34,7 @@ import {
28
34
  type SurfaceEntwurfV2Params,
29
35
  toDispatchInput,
30
36
  } from "../pi-extensions/lib/entwurf-v2-surface.ts";
31
-
32
- /** Cut ONE model-facing string out of a registration block so two descriptions in the same
33
- * block cannot satisfy an assertion for each other (round-4 masking, 2026-07-27). Returns ""
34
- * when either marker is missing, which the callers' `length > 120` guard turns into a loud
35
- * failure rather than a silent pass. */
36
- function sliceDescription(block: string, startMarker: string, endMarker: string): string {
37
- const s = block.indexOf(startMarker);
38
- if (s === -1) return "";
39
- const e = block.indexOf(endMarker, s + startMarker.length);
40
- return e === -1 ? "" : block.slice(s, e);
41
- }
37
+ import { FRESH_CUT_PRESCRIPTION } from "../pi-extensions/lib/meta-session.ts";
42
38
 
43
39
  let passed = 0;
44
40
  function ok(label: string, cond: boolean): void {
@@ -47,17 +43,6 @@ function ok(label: string, cond: boolean): void {
47
43
  passed++;
48
44
  }
49
45
 
50
- /**
51
- * Collapse a model-facing string's SOURCE form into the text the model actually reads:
52
- * drop TS string-concat glue between adjacent literals and normalize whitespace.
53
- */
54
- function modelText(slice: string): string {
55
- return slice
56
- .replace(/["']\s*\+\s*["']/g, "")
57
- .replace(/\s+/g, " ")
58
- .trim();
59
- }
60
-
61
46
  /**
62
47
  * F-2 (2026-07-27): the two model-facing surfaces described the lock, `mode`, and the
63
48
  * unsupported-citizen outcome set in ways the code does not support. Measured against
@@ -77,13 +62,11 @@ function modelText(slice: string): string {
77
62
  * Applied to BOTH surfaces from one predicate so they cannot drift apart again.
78
63
  */
79
64
  function assertRailSemantics(tag: string, longDescRaw: string, intentDescRaw: string, modeDescRaw: string): void {
80
- // Compare the text the MODEL reads, not the shape the author happened to type. pi-native
81
- // wraps inside one template literal; the MCP surface wraps by `+`-concatenating literals.
82
- // Without this normalization the same sentence matches on one surface and not the other,
83
- // and the assertion silently measures line-wrapping instead of meaning.
84
- const longDesc = modelText(longDescRaw);
85
- const intentDesc = modelText(intentDescRaw);
86
- const modeDesc = modelText(modeDescRaw);
65
+ // Inputs are decoded product strings, not TS scaffolding. Keep these semantic predicates
66
+ // separate from the exact, unnormalized pre-extraction byte oracle beside the reader.
67
+ const longDesc = longDescRaw;
68
+ const intentDesc = intentDescRaw;
69
+ const modeDesc = modeDescRaw;
87
70
  ok(
88
71
  `${tag} — long description scopes the per-target lock to the control-socket DOMAIN [QK:V2SURF-MCP-LOCK-DOMAIN]`,
89
72
  /control-socket-DOMAIN\s+dispatch/.test(longDesc) && /lock-free/.test(longDesc),
@@ -155,7 +138,7 @@ function assertRailSemantics(tag: string, longDescRaw: string, intentDescRaw: st
155
138
  * DORMANT HONESTY — the model-facing replacement for the retired `V2SURF-MERGED-REJECT` claim,
156
139
  * whose subject (two distinct OWNED rejects) left with the `owned-outcome` intent.
157
140
  *
158
- * After the visible-first cut a dormant socket-domain citizen is unreachable by every verb, and
141
+ * After the visible-first cut a dormant socket-domain citizen rejects delivery by v2, and
159
142
  * these four strings are the only place a caller learns that BEFORE spending a dispatch. So each
160
143
  * one must, on its own:
161
144
  * - name the reason it will actually get back (`dormant-fire-forget-unsupported`);
@@ -175,7 +158,7 @@ function assertRailSemantics(tag: string, longDescRaw: string, intentDescRaw: st
175
158
  * run unlabelled behind it — still real assertions, just not this claim's signature.
176
159
  */
177
160
  function assertDormantHonesty(tag: string, rawText: string): void {
178
- const text = modelText(rawText);
161
+ const text = rawText;
179
162
  const at = text.indexOf("owned-outcome");
180
163
  ok(
181
164
  `${tag} — names the withdrawn intent owned-outcome and says "withdrawn" beside it (not as an offer) [QK:V2SURF-DORMANT-HONESTY]`,
@@ -192,18 +175,23 @@ function assertDormantHonesty(tag: string, rawText: string): void {
192
175
  * PEERS DEAD-ROW HONESTY. `entwurf_peers` is a FACT surface and stays one: this claim must never
193
176
  * be satisfiable by adding a per-row action/routing field, which is why it is asserted on the
194
177
  * DESCRIPTION and paired with a negative that forbids the row-level fix. What the description owes
195
- * a caller is that `dead` is a reported fact carrying no invitation — the citizen is dormant and,
196
- * since the visible-first cut, reachable by no verb at all.
178
+ * a caller is that `dead` is a reported fact carrying no delivery invitation. A separately
179
+ * requested, proven-dormant Pi/Claude lifecycle can reopen the same id without submitting a prompt.
197
180
  */
198
181
  function assertPeersDeadRowHonesty(tag: string, rawBlock: string): void {
199
- const text = modelText(rawBlock);
182
+ const text = rawBlock;
200
183
  ok(
201
- `${tag} — entwurf_peers says a dead/dormant row is a REPORTED FACT that grants no action [QK:V2SURF-PEERS-DEAD-ROW]`,
202
- /REPORTED FACT/.test(text) && /grants no action/.test(text) && /not an invitation to dispatch/.test(text),
184
+ `${tag} — entwurf_peers reports dead delivery unavailable, no action grant, and separate explicit-operator promptless resume [QK:V2SURF-PEERS-DEAD-ROW]`,
185
+ /REPORTED FACT/.test(text) &&
186
+ /grants no action/.test(text) &&
187
+ /not an invitation to dispatch/.test(text) &&
188
+ /no entwurf_v2 delivery is available while it is dormant/.test(text) &&
189
+ /Only on an explicit operator request, the separate entwurf_resume_call/.test(text) &&
190
+ /proven-dormant Pi or Claude Code citizen under the same id, submitting no prompt/.test(text),
203
191
  );
204
192
  ok(
205
- `${tag} — entwurf_peers calls a dead row currently unreachable by any verb`,
206
- /dormant/.test(text) && /unreachable by any verb/.test(text),
193
+ `${tag} — entwurf_peers does not turn delivery dormancy into a ban on every lifecycle verb`,
194
+ /dormant/.test(text) && !/unreachable by any verb/.test(text),
207
195
  );
208
196
  // The forbidden repair: teaching the row itself to carry a verb. The facts-only rule is what
209
197
  // keeps this surface from becoming a second dispatch table, so a description that promised a
@@ -214,14 +202,6 @@ function assertPeersDeadRowHonesty(tag: string, rawBlock: string): void {
214
202
  );
215
203
  }
216
204
 
217
- /**
218
- * Containment-disjointness is NOT enough to prove a description slice is tight. Round 5
219
- * (2026-07-27) shipped a "long description" slice of 4,468 chars that SPANNED the parameter
220
- * entries because a bare `description:` marker matched the `target` param first — and two
221
- * over-wide slices can still be mutually non-containing. So pin the ABSENCE of every
222
- * parameter marker in the long-description slice: if the slice ever swallows the schema
223
- * again, this fails instead of silently satisfying the schema's own text.
224
- */
225
205
  /**
226
206
  * HOST TRUNCATION CAP. Measured 2026-07-30 on both Claude ACP and stock Claude Code: a tool
227
207
  * description longer than this is cut mid-sentence and the tail is replaced with `… [truncated]`.
@@ -230,30 +210,12 @@ function assertPeersDeadRowHonesty(tag: string, rawBlock: string): void {
230
210
  * to choose an intent. Every other assertion in this file checks that a sentence is PRESENT in
231
211
  * source; none of them can see that the host threw half of it away. This one can.
232
212
  *
233
- * Judged on `modelText` (the rendered string), not the source slice: pi-native wraps inside one
234
- * template literal and the MCP surface `+`-concatenates, so only the normalized text has the
235
- * length the host actually measures.
213
+ * Judged on the decoded JSON string, with no source scaffolding or whitespace normalization.
214
+ * Exact current fields are checked separately against frozen originals plus reviewed literal amendments.
236
215
  */
237
216
  const HOST_DESCRIPTION_CAP = 2048;
238
217
 
239
- /**
240
- * The string the HOST measures, recovered from either surface's source scaffolding: drop the
241
- * `description:` key and the outer template-literal / string-literal fence, and unescape `\"`.
242
- * Counting the raw slice instead would charge the text for punctuation the model never sees —
243
- * and the two surfaces carry DIFFERENT punctuation, so the cap would mean two different things.
244
- */
245
- function renderedDescription(raw: string): string {
246
- const flat = modelText(raw);
247
- // Anchor on the description's own first word rather than on scaffolding: the two surfaces put
248
- // DIFFERENT preludes in front of it (the MCP slice starts at the tool name), and counting those
249
- // would report a number the host never measures — a cap gate that cites the wrong length gets
250
- // quoted as if it were the real one.
251
- const from = flat.indexOf("CANONICAL");
252
- return (from >= 0 ? flat.slice(from) : flat).replace(/[`"],?$/, "").replace(/\\"/g, '"');
253
- }
254
-
255
- function assertDescriptionFitsHostCap(tag: string, longDescRaw: string): void {
256
- const rendered = renderedDescription(longDescRaw);
218
+ function assertDescriptionFitsHostCap(tag: string, rendered: string): void {
257
219
  ok(
258
220
  `${tag} — long description fits the host's ${HOST_DESCRIPTION_CAP}-char cap (${rendered.length}) ` +
259
221
  "[QK:V2SURF-DESC-FITS-HOST-CAP]",
@@ -261,12 +223,6 @@ function assertDescriptionFitsHostCap(tag: string, longDescRaw: string): void {
261
223
  );
262
224
  }
263
225
 
264
- function assertLongDescExcludesParams(tag: string, longDesc: string, markers: readonly string[]): void {
265
- for (const marker of markers) {
266
- ok(`${tag} — long description slice excludes the \`${marker}\` parameter marker`, !longDesc.includes(marker));
267
- }
268
- }
269
-
270
226
  const HERE = path.dirname(fileURLToPath(import.meta.url));
271
227
  const REPO = path.join(HERE, "..");
272
228
  const SURFACE_SRC = path.join(REPO, "pi-extensions/lib/entwurf-v2-surface.ts");
@@ -587,9 +543,24 @@ async function main(): Promise<void> {
587
543
  !/DELIVERED|\bdelivered\b/.test(dirtyRefused.text) &&
588
544
  // and every one of them keeps the thing the operator must act on
589
545
  [dirtyBusy, dirtyMailbox, dirtyRefused].every(
590
- (r) => r.isError && r.text.includes("DIRTY") && r.text.includes("do NOT retry"),
546
+ (r) =>
547
+ r.isError &&
548
+ r.text.includes("DIRTY") &&
549
+ r.text.includes("do NOT retry automatically") &&
550
+ r.text.includes("operator resolve the lock") &&
551
+ !r.text.includes("would double-deliver"),
591
552
  ),
592
553
  );
554
+ // #154 E1a: the two static clauses of this receipt are authored in root ENTWURF.json; the
555
+ // syntax around them stays here, so the whole rendered line is compared, not a fragment.
556
+ const dirtyClause = ENTWURF_DELIVERY_RESULT_CLAUSES["dirty-lock"];
557
+ ok(
558
+ "[QK:V2SURF-DELIVERY-RESULT-CLAUSES-FROM-ROOT] the dirty-lock receipt renders the root finalized-rejected and dirty-lock clauses byte for byte inside its code-owned syntax",
559
+ dirtyBusy.text ===
560
+ `entwurf_v2 control-socket finalized as queued-steer, and ${dirtyClause}\n error: release boom` &&
561
+ dirtyRefused.text ===
562
+ `entwurf_v2 control-socket finalized as rejected (compacting) — ${ENTWURF_DELIVERY_RESULT_CLAUSES["finalized-rejected"]}, and ${dirtyClause}\n error: release boom`,
563
+ );
593
564
 
594
565
  // plain execution-failed → error
595
566
  const failed: EntwurfV2RunResult = {
@@ -683,6 +654,25 @@ async function main(): Promise<void> {
683
654
  rls.includes("restart it under the current runtime") &&
684
655
  rls.includes("meta-bridge-fresh-cut"),
685
656
  );
657
+ // #154 E1b: the text on either side of the fix command is authored in root ENTWURF.json and the
658
+ // command comes from its owner, so the WHOLE hint is compared against that composition — the
659
+ // phrase checks above stay, and a hand-kept copy of the text that still carries them dies here.
660
+ const rlsRoot = ENTWURF_SLOTTED_REJECT_HINTS["record-less-socket"];
661
+ ok(
662
+ "[QK:V2SURF-RECORD-LESS-SOCKET-HINT-FROM-ROOT] the record-less-socket hint is exactly the root text before the fix command, the command from its meta-session owner, and the root text after it",
663
+ rls === `${rlsRoot.beforeFreshCutPrescription}${FRESH_CUT_PRESCRIPTION}${rlsRoot.afterFreshCutPrescription}`,
664
+ );
665
+ // #154 C1-B: the five static hints are authored in root ENTWURF.json. This is the WIRING
666
+ // claim — what the surface returns is the Root value for every declared reason — compared
667
+ // against the loaded Root, never a fixture, so a Root prose mutant still dies at its own
668
+ // semantic QK above. The C0 byte oracle lives beside the reader (GUIDANCE-REJECT-HINTS-ORIGINAL).
669
+ const unwired = Object.entries(ENTWURF_REJECT_HINTS)
670
+ .filter(([reason, text]) => actionableRejectHint(reason) !== text)
671
+ .map(([reason]) => reason);
672
+ ok(
673
+ `2D: every static reject hint the surface renders is the root ENTWURF.json value [QK:V2SURF-REJECT-HINTS-FROM-ROOT] (unwired: ${JSON.stringify(unwired)})`,
674
+ Object.keys(ENTWURF_REJECT_HINTS).length === 5 && unwired.length === 0,
675
+ );
686
676
  }
687
677
 
688
678
  // ── 6: RETIRED — parseEntwurfPrefixRootsEnv / ENTWURF_PREFIX_ROOTS ────────
@@ -776,14 +766,10 @@ async function main(): Promise<void> {
776
766
  // Same shipped-rail completeness rule as the pi-native surface (4), and split the SAME
777
767
  // two ways: the long tool description and the `intent` param description must EACH be
778
768
  // true on their own (see the round-4 masking note in block 4).
779
- // Same fail-loud rule as block 4: a missing marker would make `slice(0, -1)` return
780
- // nearly the whole block and sail past the length guard, so assert the boundary first.
781
- const mcpSchemaStart = v2Block.indexOf("\t{");
782
- ok("5: MCP — schema boundary marker is present (slice cannot silently widen)", mcpSchemaStart > 0);
783
- const mcpLongDesc = v2Block.slice(0, mcpSchemaStart);
784
- const mcpIntentDesc = sliceDescription(v2Block, "intent: z", "message: z");
769
+ const mcpLongDesc = ENTWURF_TOOL_GUIDANCE.entwurf_v2.descriptions.mcp;
770
+ const mcpIntentDesc = ENTWURF_TOOL_GUIDANCE.entwurf_v2.parameters.intent;
785
771
  ok(
786
- "5: MCP — long/intent slices are disjoint (neither can satisfy the other's claim)",
772
+ "5: MCP — long/intent strings are disjoint (neither can satisfy the other's claim)",
787
773
  mcpLongDesc.length > 0 &&
788
774
  mcpIntentDesc.length > 0 &&
789
775
  !mcpLongDesc.includes(mcpIntentDesc) &&
@@ -799,11 +785,12 @@ async function main(): Promise<void> {
799
785
  }
800
786
  ok("5: MCP — long description denies native-push a mailbox", /NO mailbox/.test(mcpLongDesc));
801
787
  ok(
802
- "5: MCP — long description steers live/alive peer → fire-and-forget",
803
- /liveness=alive/.test(mcpLongDesc) && /fire-and-forget/.test(mcpLongDesc),
788
+ "5: MCP — long description says a live socket can receive fire-and-forget, and unsupported is not reachability",
789
+ /A live socket can receive fire-and-forget/.test(mcpLongDesc) &&
790
+ /not reachability/.test(mcpLongDesc) &&
791
+ !/liveness=alive\s*→\s*fire-and-forget/.test(mcpLongDesc),
804
792
  );
805
- assertLongDescExcludesParams("5: MCP", mcpLongDesc, ["target: z", "intent: z", "mode: z", "wants_reply: z"]);
806
- const mcpModeDesc = sliceDescription(v2Block, "mode: z", "wants_reply: z");
793
+ const mcpModeDesc = ENTWURF_TOOL_GUIDANCE.entwurf_v2.parameters.mode;
807
794
  assertRailSemantics("5: MCP", mcpLongDesc, mcpIntentDesc, mcpModeDesc);
808
795
  assertDescriptionFitsHostCap("5: MCP", mcpLongDesc);
809
796
 
@@ -817,21 +804,20 @@ async function main(): Promise<void> {
817
804
  "5: MCP — entwurf_peers block has a REAL end boundary (next server.tool present)",
818
805
  peersStart !== -1 && peersAfter > peersStart,
819
806
  );
820
- const peersBlock = src.slice(peersStart, peersAfter);
821
- ok("5: MCP — entwurf_peers block is isolated (non-vacuous)", peersBlock.length > 200);
807
+ const peersText = ENTWURF_TOOL_GUIDANCE.entwurf_peers.descriptions.mcp;
822
808
  ok(
823
809
  "5: MCP — entwurf_peers names the THIRD answer (a reject), not just the two allow rails",
824
- /mailbox-undeliverable/.test(peersBlock) && /native-push-target-dead/.test(peersBlock),
810
+ /mailbox-undeliverable/.test(peersText) && /native-push-target-dead/.test(peersText),
825
811
  );
826
812
  ok(
827
813
  "5: MCP — entwurf_peers no longer claims `unsupported` does NOT mean unreachable",
828
- !/does NOT mean unreachable/.test(peersBlock),
814
+ !/does NOT mean unreachable/.test(peersText),
829
815
  );
830
816
  // Visible-first cut, operator-surface half: a dormant citizen still gets a row here, and a
831
817
  // caller who reads "it is in the list" as "I can dispatch to it" spends a dispatch to find
832
818
  // out otherwise. The FACT stays a fact — no per-row action field, no routing verb, which is
833
819
  // the rule this surface exists under — so the correction has to live in the description.
834
- assertPeersDeadRowHonesty("5: MCP", peersBlock);
820
+ assertPeersDeadRowHonesty("5: MCP", peersText);
835
821
 
836
822
  // F-7: entwurf_inbox_read described itself as draining "your own" inbox while the handler
837
823
  // passes the CALLER-SUPPLIED gardenId straight to readMetaInbox with no comparison against
@@ -845,7 +831,7 @@ async function main(): Promise<void> {
845
831
  inboxStart !== -1 && inboxAfter > inboxStart,
846
832
  );
847
833
  const inboxBlock = src.slice(inboxStart, inboxAfter);
848
- const inboxText = modelText(inboxBlock);
834
+ const inboxText = ENTWURF_TOOL_GUIDANCE.entwurf_inbox_read.descriptions.mcp;
849
835
  ok("5: MCP — entwurf_inbox_read block is isolated (non-vacuous)", inboxText.length > 200);
850
836
  ok(
851
837
  "5: MCP — entwurf_inbox_read states the garden id is CALLER-SUPPLIED and unverified [QK:V2SURF-INBOX-SCOPE-HONESTY]",
@@ -971,20 +957,27 @@ async function main(): Promise<void> {
971
957
  // rail's four boundaries are the ONLY receiver-acceptance values; a mailbox answers with an
972
958
  // ENQUEUE receipt and native-push with an INJECTION, and folding those into the boundary union
973
959
  // would tell a caller that `mailbox-enqueued` is something a receiver observed about its own
974
- // queues. Missing either rail is red — the earlier draft listed `mailbox-enqueued` beside the
960
+ // queues. The socket dispatch may re-resolve to a mailbox leg and report mailbox-enqueued;
961
+ // that exception must name the leg, not silently invent a fifth receiver queue boundary.
962
+ // Missing either rail is red — the earlier draft listed `mailbox-enqueued` beside the
975
963
  // four and left native-push out entirely, and nothing noticed.
976
964
  {
977
- const outcomeSites = ["mcp/entwurf-bridge/src/index.ts"];
965
+ const outcomeSites = [
966
+ {
967
+ rel: "ENTWURF.json tools.entwurf_v2.descriptions.mcp",
968
+ text: ENTWURF_TOOL_GUIDANCE.entwurf_v2.descriptions.mcp,
969
+ },
970
+ ];
978
971
  const missing: string[] = [];
979
- for (const rel of outcomeSites) {
980
- const text = await fs.readFile(path.join(REPO, rel), "utf8");
972
+ for (const { rel, text } of outcomeSites) {
981
973
  const at = text.indexOf("reports ONE");
982
974
  const blurb = at < 0 ? "" : text.slice(at, at + 900);
983
975
  if (!/acceptance boundary/i.test(blurb)) missing.push(`${rel}: control receiver acceptance boundary`);
984
976
  for (const b of ["sent", "queued-steer", "queued-follow-up", "accepted-unknown-boundary"]) {
985
977
  if (!blurb.includes(b)) missing.push(`${rel}: boundary ${b}`);
986
978
  }
987
- if (!/those four only/i.test(blurb)) missing.push(`${rel}: the four-only scope of the boundary union`);
979
+ if (!blurb.includes("those four, or `mailbox-enqueued` on a re-resolved mailbox leg"))
980
+ missing.push(`${rel}: the four receiver boundaries and the explicitly re-resolved mailbox leg`);
988
981
  if (!/mailbox ENQUEUE/i.test(blurb)) missing.push(`${rel}: mailbox enqueue receipt`);
989
982
  if (!/native-push INJECTION/i.test(blurb)) missing.push(`${rel}: native-push injection`);
990
983
  if (!/rejection|rejected/i.test(blurb)) missing.push(`${rel}: rejection`);
@@ -994,7 +987,7 @@ async function main(): Promise<void> {
994
987
  }
995
988
  }
996
989
  ok(
997
- `[QK:SEND-OUTCOME-LIST-NAMES-EVERY-RAIL] the tool description names each rail's own result — the control receiver's four acceptance boundaries (and that those four are the whole union), the mailbox ENQUEUE receipt, the native-push INJECTION, a rejection, and accepted-but-lock-dirty — so a caller is never told that one rail's vocabulary describes another's (missing: ${JSON.stringify(missing)})`,
990
+ `[QK:SEND-OUTCOME-LIST-NAMES-EVERY-RAIL] the tool description names each rail's own result — the control receiver's four acceptance boundaries (or mailbox-enqueued on an explicitly re-resolved mailbox leg), the mailbox ENQUEUE receipt, the native-push INJECTION, a rejection, and accepted-but-lock-dirty — so a caller is never told that one rail's vocabulary describes another's (missing: ${JSON.stringify(missing)})`,
998
991
  missing.length === 0,
999
992
  );
1000
993
  }
@@ -1029,7 +1022,10 @@ async function main(): Promise<void> {
1029
1022
  ];
1030
1023
  const gaps: string[] = [];
1031
1024
  for (const rel of sites) {
1032
- const text = await fs.readFile(path.join(REPO, rel), "utf8");
1025
+ const text =
1026
+ rel === "mcp/entwurf-bridge/src/index.ts"
1027
+ ? ENTWURF_TOOL_GUIDANCE.entwurf_v2.parameters.mode
1028
+ : await fs.readFile(path.join(REPO, rel), "utf8");
1033
1029
  for (const axis of axes) if (!axis.holds(text)) gaps.push(`${rel}: ${axis.name}`);
1034
1030
  if (/steer \((?:interrupt|immediate)|interrupt the current turn|steer = interrupt/i.test(text)) {
1035
1031
  gaps.push(`${rel}: still claims steer interrupts`);
@@ -3446,6 +3446,7 @@ let manifestCount: number;
3446
3446
  "acp-stream-hooks": 10,
3447
3447
  "acp-usage-accounting": 12,
3448
3448
  "acp-vendor-rejection": 4,
3449
+ "agent-guidance": 14,
3449
3450
  "agy-permission": 6,
3450
3451
  "bridge-boot-resume": 5,
3451
3452
  "bridge-command-boot": 12,
@@ -3453,12 +3454,13 @@ let manifestCount: number;
3453
3454
  "cc-retire-request": 15,
3454
3455
  "entwurf-v2-retire": 32,
3455
3456
  "capability-cache": 3,
3457
+ "capability-bundle-reach": 7,
3456
3458
  "codex-app-server-launch": 10,
3457
3459
  "codex-caller-seat": 28,
3458
3460
  "pi-retire-request": 6,
3459
3461
  "retirement-event": 16,
3460
3462
  "control-retire": 9,
3461
- "control-send-receipt": 19,
3463
+ "control-send-receipt": 20,
3462
3464
  "codex-native": 95,
3463
3465
  "native-push-paused": 1,
3464
3466
  "chain-terminus-publication": 1,
@@ -3472,7 +3474,7 @@ let manifestCount: number;
3472
3474
  "pi-bridge-sender": 4,
3473
3475
  "pi-mcp-bridge": 2,
3474
3476
  "pi-mcp-register": 3,
3475
- "pi-durable": 94,
3477
+ "pi-durable": 95,
3476
3478
  "copilot-receive": 20,
3477
3479
  "entwurf-peers": 1,
3478
3480
  "fresh-call-dispatch": 15,
@@ -3493,13 +3495,13 @@ let manifestCount: number;
3493
3495
  "meta-identity": 9,
3494
3496
  "meta-retire": 4,
3495
3497
  "mux-boundary": 16,
3496
- "mux-fresh-call": 66,
3498
+ "mux-fresh-call": 67,
3497
3499
  "mux-launcher-fence": 8,
3498
3500
  "mux-parent-artifact": 3,
3499
3501
  "pack-install": 9,
3500
3502
  "pi-package-ownership": 8,
3501
3503
  "qualification-ledger": 42,
3502
- "mux-resume-call": 13,
3504
+ "mux-resume-call": 15,
3503
3505
  "omp-birth": 13,
3504
3506
  "omp-fresh": 25,
3505
3507
  "omp-receive": 11,
@@ -3509,7 +3511,7 @@ let manifestCount: number;
3509
3511
  "remote-pair-installed-audit": 2,
3510
3512
  "remote-pair-receive": 10,
3511
3513
  "remote-pair-roundtrip": 9,
3512
- "remote-pair-send": 21,
3514
+ "remote-pair-send": 22,
3513
3515
  "remote-pair-transport": 4,
3514
3516
  "retired-sent-surface": 2,
3515
3517
  "resume-args": 6,
@@ -3518,8 +3520,8 @@ let manifestCount: number;
3518
3520
  "setup-verdict": 14,
3519
3521
  "source-install": 8,
3520
3522
  "typing-call-fence": 1,
3521
- "v2-surface": 14,
3522
- "v2-visible-resume": 40,
3523
+ "v2-surface": 16,
3524
+ "v2-visible-resume": 41,
3523
3525
  "win32-preview": 19,
3524
3526
  };
3525
3527
  const laneTally: Record<string, number> = {};
@@ -36,6 +36,7 @@ import fs from "node:fs";
36
36
  import os from "node:os";
37
37
  import path from "node:path";
38
38
  import { fileURLToPath } from "node:url";
39
+ import { ENTWURF_RESUME_LAUNCH_REJECT_HINTS, ENTWURF_TOOL_GUIDANCE } from "../pi-extensions/lib/agent-guidance.ts";
39
40
  import { classifyTmuxCwd } from "../pi-extensions/lib/classify-tmux-cwd.ts";
40
41
  import type { Placement } from "../pi-extensions/lib/mux-placement.ts";
41
42
  import {
@@ -216,6 +217,12 @@ function main(): void {
216
217
  "every reject reason has a hint a caller can act on — a reason without one is a reason they will guess about",
217
218
  reasons.every((r) => typeof RESUME_CALL_REJECT_HINT[r] === "string" && RESUME_CALL_REJECT_HINT[r].length > 0),
218
219
  );
220
+ ok(
221
+ "[QK:MUXRESUME-LAUNCH-REJECT-HINTS-FROM-ROOT] every launch-stage resume hint is the root ENTWURF.json text for its own reason, and the table names exactly the verb's reasons",
222
+ reasons.every((r) => RESUME_CALL_REJECT_HINT[r] === ENTWURF_RESUME_LAUNCH_REJECT_HINTS[r]) &&
223
+ JSON.stringify(Object.keys(RESUME_CALL_REJECT_HINT).sort()) === JSON.stringify([...reasons].sort()) &&
224
+ JSON.stringify(Object.keys(ENTWURF_RESUME_LAUNCH_REJECT_HINTS).sort()) === JSON.stringify([...reasons].sort()),
225
+ );
219
226
  ok(
220
227
  "[QK:MUXRESUME-RUNTIME-TABLE] the runtime is a closed per-backend table, pi → pi and claude-code → claude — never a command a caller supplies",
221
228
  JSON.stringify(RESUME_CALL_RUNTIME) === JSON.stringify({ pi: "pi", "claude-code": "claude" }),
@@ -227,9 +234,19 @@ function main(): void {
227
234
  "[QK:MUXRESUME-NO-IDENTITY] the module never mentions a garden id, a record, a lock or a transcript — it opens a place at a directory and knows nothing about whose citizen it is",
228
235
  !/gardenId|readAddressableMetaIdentity|acquireLock|transcriptPath/.test(SRC),
229
236
  );
237
+ // Every static form (from / bare / export-from) is parsed and dynamic loading is refused, so a
238
+ // fourth lane cannot enter through a shape the parser does not see. The one non-mux member is the
239
+ // node:fs-only guidance reader (#154 C1-D), whose own leaf-ness is GUIDANCE-READER-LEAF-IMPORTS.
240
+ const resumeImports = [
241
+ ...SRC.matchAll(/^\s*(?:import|export)\s[^;]*?\sfrom\s+["']([^"']+)["']/gm),
242
+ ...SRC.matchAll(/^\s*import\s+["']([^"']+)["']/gm),
243
+ ].map((m) => m[1]);
230
244
  ok(
231
- "it imports only the mux lane — no entwurf core, no delivery",
232
- !/from "\.\/entwurf-/.test(SRC) && !/meta-session/.test(SRC),
245
+ "[QK:MUXRESUME-IMPORT-SET] it imports exactly the mux lane plus the guidance reader — no entwurf core, no delivery, no dynamic import",
246
+ JSON.stringify([...resumeImports].sort()) ===
247
+ JSON.stringify(["./agent-guidance.ts", "./classify-tmux-cwd.ts", "./mux-launch.ts", "./mux-placement.ts"]) &&
248
+ !/\bimport\s*\(|\brequire\s*\(/.test(SRC) &&
249
+ !/meta-session/.test(SRC),
233
250
  );
234
251
  ok(
235
252
  "it uses the SHARED APPEND_FORMAT rather than adding a start-path field: `-P -F` prints its row BEFORE the child chdirs (measured — pane_current_path there still reports the CALLER's cwd), so a path field would be both free-form in a `|`-joined row and racy",
@@ -273,7 +290,7 @@ function main(): void {
273
290
 
274
291
  // ── the description contract ────────────────────────────────────────────────
275
292
  // Not prose parity — three claims an operator acts on, plus the host's own cap.
276
- const MCP_DESC = (MCP_SURFACE.split('"entwurf_resume_call",')[1] ?? "").split("{")[0];
293
+ const MCP_DESC = ENTWURF_TOOL_GUIDANCE.entwurf_resume_call.descriptions.mcp;
277
294
  const statesTheContract = (text: string): boolean =>
278
295
  /dormant/i.test(text) && /submits NO prompt/i.test(text) && /observation/i.test(text) && /launch/i.test(text);
279
296
 
@@ -0,0 +1,160 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "lane": "agent-guidance",
4
+ "mutants": [
5
+ {
6
+ "claim": "GUIDANCE-REVIEWED-REVISION",
7
+ "title": "a valid Root revision advances beyond the independently reviewed payload revision while every history entry and decoded tool string remains valid",
8
+ "subject": "ENTWURF.json",
9
+ "find": ["\t\"revision\": 11,", "\t\"history\": ["],
10
+ "replace": ["\t\"revision\": 12,", "\t\"history\": ["],
11
+ "gate": ["bash", "run.sh", "check-agent-guidance-beside"],
12
+ "timeoutSeconds": 120,
13
+ "signature": "[QK:GUIDANCE-REVIEWED-REVISION]",
14
+ "signatureSource": "pi-extensions/lib/agent-guidance.test.ts"
15
+ },
16
+ {
17
+ "claim": "GUIDANCE-CURRENT-DECODED-BYTES",
18
+ "title": "a valid authored parameter gains one space, so normalized/shared-constant comparisons would hide a reviewed-current byte break",
19
+ "subject": "ENTWURF.json",
20
+ "find": ["Target garden id (use entwurf_peers to discover)"],
21
+ "replace": ["Target garden id (use entwurf_peers to discover)"],
22
+ "gate": ["bash", "run.sh", "check-agent-guidance-beside"],
23
+ "timeoutSeconds": 120,
24
+ "signature": "[QK:GUIDANCE-CURRENT-DECODED-BYTES]",
25
+ "signatureSource": "pi-extensions/lib/agent-guidance.test.ts"
26
+ },
27
+ {
28
+ "claim": "GUIDANCE-REJECT-HINTS-ORIGINAL",
29
+ "title": "a valid static reject hint gains one space in the real JSON, which the reader and the surface wiring both carry faithfully, so only the C0 plus reviewed-revision-6 byte oracle can disagree",
30
+ "subject": "ENTWURF.json",
31
+ "find": ["native-push for this backend is paused (#152):"],
32
+ "replace": ["native-push for this backend is paused (#152):"],
33
+ "gate": ["bash", "run.sh", "check-agent-guidance-beside"],
34
+ "timeoutSeconds": 120,
35
+ "signature": "[QK:GUIDANCE-REJECT-HINTS-ORIGINAL]",
36
+ "signatureSource": "pi-extensions/lib/agent-guidance.test.ts"
37
+ },
38
+ {
39
+ "claim": "GUIDANCE-RESUME-REJECT-HINTS-ORIGINAL",
40
+ "title": "a valid static visible-resume reject hint gains one space in the real JSON, which the reader and the visible-resume wiring both carry faithfully, so only the C0 byte oracle can disagree",
41
+ "subject": "ENTWURF.json",
42
+ "find": ["tmux was never asked to open a window"],
43
+ "replace": ["tmux was never asked to open a window"],
44
+ "gate": ["bash", "run.sh", "check-agent-guidance-beside"],
45
+ "timeoutSeconds": 120,
46
+ "signature": "[QK:GUIDANCE-RESUME-REJECT-HINTS-ORIGINAL]",
47
+ "signatureSource": "pi-extensions/lib/agent-guidance.test.ts"
48
+ },
49
+ {
50
+ "claim": "GUIDANCE-RUNTIME-REVIEWED-FIELDS",
51
+ "title": "valid callback prose changes in the real JSON and reaches source tools/list, whose C0 plus reviewed-delta expectation must disagree",
52
+ "subject": "ENTWURF.json",
53
+ "find": ["No arguments, no fallback to a model-supplied target."],
54
+ "replace": ["No arguments, automatic fallback to a model-supplied target."],
55
+ "gate": ["bash", "run.sh", "check-agent-guidance-beside"],
56
+ "timeoutSeconds": 120,
57
+ "signature": "[QK:GUIDANCE-RUNTIME-REVIEWED-FIELDS]",
58
+ "signatureSource": "pi-extensions/lib/agent-guidance.test.ts"
59
+ },
60
+ {
61
+ "claim": "GUIDANCE-DURABLE-REVIEWED-FIELDS",
62
+ "title": "the actual durable short variant changes without touching the independent C0 plus reviewed-delta contact expectation",
63
+ "subject": "ENTWURF.json",
64
+ "find": ["Return this durable host's garden identity envelope"],
65
+ "replace": ["Return this durable host's alternate identity envelope"],
66
+ "gate": ["bash", "run.sh", "check-agent-guidance-beside"],
67
+ "timeoutSeconds": 120,
68
+ "signature": "[QK:GUIDANCE-DURABLE-REVIEWED-FIELDS]",
69
+ "signatureSource": "pi-extensions/lib/agent-guidance.test.ts"
70
+ },
71
+ {
72
+ "claim": "GUIDANCE-DUPLICATE-DECODED-KEYS",
73
+ "title": "grammar-only parsing skips the original token walk and accepts last-key-wins data",
74
+ "subject": "pi-extensions/lib/agent-guidance.ts",
75
+ "find": ["rejectDuplicateKeys(source);"],
76
+ "replace": ["// duplicate-key check removed by data-integrity mutant"],
77
+ "gate": ["bash", "run.sh", "check-agent-guidance-beside"],
78
+ "timeoutSeconds": 120,
79
+ "signature": "[QK:GUIDANCE-DUPLICATE-DECODED-KEYS]",
80
+ "signatureSource": "pi-extensions/lib/agent-guidance.test.ts"
81
+ },
82
+ {
83
+ "claim": "GUIDANCE-STRICT-SHAPE",
84
+ "title": "the shape reader no longer rejects missing or unknown members",
85
+ "subject": "pi-extensions/lib/agent-guidance.ts",
86
+ "find": ["actual.length !== wanted.length || actual.some((key, i) => key !== wanted[i])"],
87
+ "replace": ["false"],
88
+ "gate": ["bash", "run.sh", "check-agent-guidance-beside"],
89
+ "timeoutSeconds": 120,
90
+ "signature": "[QK:GUIDANCE-STRICT-SHAPE]",
91
+ "signatureSource": "pi-extensions/lib/agent-guidance.test.ts"
92
+ },
93
+ {
94
+ "claim": "GUIDANCE-INDEPENDENT-REVISION",
95
+ "title": "history length becomes payload revision, so history-only annotation silently changes it",
96
+ "subject": "pi-extensions/lib/agent-guidance.ts",
97
+ "find": ["freeze(data);"],
98
+ "replace": ["data.revision = data.history.length;\n\tfreeze(data);"],
99
+ "gate": ["bash", "run.sh", "check-agent-guidance-beside"],
100
+ "timeoutSeconds": 120,
101
+ "signature": "[QK:GUIDANCE-INDEPENDENT-REVISION]",
102
+ "signatureSource": "pi-extensions/lib/agent-guidance.test.ts"
103
+ },
104
+ {
105
+ "claim": "GUIDANCE-FIXED-MODULE-ROOT",
106
+ "title": "an ambient path selects replacement guidance instead of the module's fixed packaged source",
107
+ "subject": "pi-extensions/lib/agent-guidance.ts",
108
+ "find": ["new URL(\"../../ENTWURF.json\", import.meta.url)"],
109
+ "replace": ["process.env.ENTWURF_GUIDANCE_PATH ?? new URL(\"../../ENTWURF.json\", import.meta.url)"],
110
+ "gate": ["bash", "run.sh", "check-agent-guidance-beside"],
111
+ "timeoutSeconds": 120,
112
+ "signature": "[QK:GUIDANCE-FIXED-MODULE-ROOT]",
113
+ "signatureSource": "pi-extensions/lib/agent-guidance.test.ts"
114
+ },
115
+ {
116
+ "claim": "GUIDANCE-LAUNCH-REJECT-HINTS-ORIGINAL",
117
+ "title": "a valid static tmux launch-stage hint gains one space in the real JSON, which the reader, the fresh renderer and the compiled reader all carry faithfully, so only the C0 per-verb byte oracle can disagree",
118
+ "subject": "ENTWURF.json",
119
+ "find": ["the requested tmux session name is outside the shape"],
120
+ "replace": ["the requested tmux session name is outside the shape"],
121
+ "gate": ["bash", "run.sh", "check-agent-guidance-beside"],
122
+ "timeoutSeconds": 120,
123
+ "signature": "[QK:GUIDANCE-LAUNCH-REJECT-HINTS-ORIGINAL]",
124
+ "signatureSource": "pi-extensions/lib/agent-guidance.test.ts"
125
+ },
126
+ {
127
+ "claim": "GUIDANCE-DELIVERY-RESULT-CLAUSES-ORIGINAL",
128
+ "title": "a valid static delivery-result clause gains one space in the real JSON, which the reader, the v2-surface and remote-pair renderers and the compiled reader all carry faithfully, so only the 94d0594 byte oracle can disagree",
129
+ "subject": "ENTWURF.json",
130
+ "find": ["the receiver refused it; nothing was accepted"],
131
+ "replace": ["the receiver refused it; nothing was accepted"],
132
+ "gate": ["bash", "run.sh", "check-agent-guidance-beside"],
133
+ "timeoutSeconds": 120,
134
+ "signature": "[QK:GUIDANCE-DELIVERY-RESULT-CLAUSES-ORIGINAL]",
135
+ "signatureSource": "pi-extensions/lib/agent-guidance.test.ts"
136
+ },
137
+ {
138
+ "claim": "GUIDANCE-READER-LEAF-IMPORTS",
139
+ "title": "the reader gains a bare side-effect import, the weakest static form, which loads and runs fine, so only the leaf import-set parser can see the new dependency",
140
+ "subject": "pi-extensions/lib/agent-guidance.ts",
141
+ "find": ["import { readFileSync } from \"node:fs\";"],
142
+ "replace": ["import { readFileSync } from \"node:fs\";", "import \"node:path\";"],
143
+ "gate": ["bash", "run.sh", "check-agent-guidance-beside"],
144
+ "timeoutSeconds": 120,
145
+ "signature": "[QK:GUIDANCE-READER-LEAF-IMPORTS]",
146
+ "signatureSource": "pi-extensions/lib/agent-guidance.test.ts"
147
+ },
148
+ {
149
+ "claim": "GUIDANCE-SLOTTED-REJECT-HINTS-ORIGINAL",
150
+ "title": "a valid record-less-socket segment gains one space in the real JSON, which the reader and the surface composition both carry faithfully, so only the C0 segment and template oracle can disagree",
151
+ "subject": "ENTWURF.json",
152
+ "find": ["If a pre-record-era resident owns that socket"],
153
+ "replace": ["If a pre-record-era resident owns that socket"],
154
+ "gate": ["bash", "run.sh", "check-agent-guidance-beside"],
155
+ "timeoutSeconds": 120,
156
+ "signature": "[QK:GUIDANCE-SLOTTED-REJECT-HINTS-ORIGINAL]",
157
+ "signatureSource": "pi-extensions/lib/agent-guidance.test.ts"
158
+ }
159
+ ]
160
+ }