@junghanacs/entwurf 0.24.0 → 0.25.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 (64) hide show
  1. package/CHANGELOG.md +455 -0
  2. package/DELIVERY.md +24 -1
  3. package/README.md +2 -2
  4. package/VERIFY.md +19 -1
  5. package/demo/README.md +5 -2
  6. package/docs/acp-backend-rail.md +49 -2
  7. package/docs/setup-clean-host.md +4 -4
  8. package/mcp/entwurf-bridge/dist/mcp/entwurf-bridge/src/index.js +5 -4
  9. package/mcp/entwurf-bridge/dist/pi-extensions/lib/control-send-receipt.js +101 -0
  10. package/mcp/entwurf-bridge/dist/pi-extensions/lib/entwurf-v2-contract.js +6 -2
  11. package/mcp/entwurf-bridge/dist/pi-extensions/lib/entwurf-v2-production.js +17 -1
  12. package/mcp/entwurf-bridge/dist/pi-extensions/lib/entwurf-v2-runner.js +4 -0
  13. package/mcp/entwurf-bridge/dist/pi-extensions/lib/entwurf-v2-send.js +53 -6
  14. package/mcp/entwurf-bridge/dist/pi-extensions/lib/entwurf-v2-surface.js +38 -3
  15. package/mcp/entwurf-bridge/dist/pi-extensions/lib/herdr-fresh-call.js +13 -3
  16. package/mcp/entwurf-bridge/dist/pi-extensions/lib/herdr-placement.js +11 -0
  17. package/mcp/entwurf-bridge/dist/protocol.js +0 -7
  18. package/mcp/entwurf-bridge/dist/scripts/doctor-pi-provider.js +40 -3
  19. package/mcp/entwurf-bridge/dist/scripts/herdr-rails.mjs +72 -0
  20. package/mcp/entwurf-bridge/src/index.ts +5 -4
  21. package/package.json +10 -9
  22. package/pi-extensions/entwurf-control.ts +27 -154
  23. package/pi-extensions/lib/compaction-send-guard.ts +5 -3
  24. package/pi-extensions/lib/control-send-receipt.ts +108 -0
  25. package/pi-extensions/lib/entwurf-v2-contract-schema.ts +1 -1
  26. package/pi-extensions/lib/entwurf-v2-contract.ts +6 -2
  27. package/pi-extensions/lib/entwurf-v2-production.ts +19 -1
  28. package/pi-extensions/lib/entwurf-v2-runner.ts +23 -1
  29. package/pi-extensions/lib/entwurf-v2-send.ts +82 -6
  30. package/pi-extensions/lib/entwurf-v2-surface.ts +42 -3
  31. package/pi-extensions/lib/herdr-fresh-call.ts +13 -3
  32. package/pi-extensions/lib/herdr-placement.ts +11 -0
  33. package/protocol.js +0 -8
  34. package/run.sh +197 -29
  35. package/scripts/check-entwurf-v2-surface.ts +289 -10
  36. package/scripts/check-gate-qualification.ts +7 -4
  37. package/scripts/check-herdr-fresh-call.ts +10 -2
  38. package/scripts/check-herdr-placement.ts +51 -0
  39. package/scripts/check-herdr-plugin-build.ts +11 -4
  40. package/scripts/check-herdr-plugin.ts +745 -38
  41. package/scripts/check-mux-launcher-fence.ts +37 -0
  42. package/scripts/check-pi-launch.ts +7 -4
  43. package/scripts/check-release-gate-outcomes.ts +165 -0
  44. package/scripts/doctor-pi-provider.ts +44 -4
  45. package/scripts/herdr-rails.mjs +75 -0
  46. package/scripts/meta-bridge-state.py +18 -1
  47. package/scripts/mutants/bridge-command-boot.json +38 -0
  48. package/scripts/mutants/control-send-receipt.json +235 -0
  49. package/scripts/mutants/herdr-fresh-call.json +4 -4
  50. package/scripts/mutants/herdr-plugin-build.json +7 -11
  51. package/scripts/mutants/herdr-plugin.json +177 -9
  52. package/scripts/mutants/meta-retire.json +22 -0
  53. package/scripts/mutants/pack-install.json +4 -4
  54. package/scripts/mutants/pi-floor.json +17 -0
  55. package/scripts/mutants/release-gate.json +48 -0
  56. package/scripts/mutants/retired-sent-surface.json +32 -0
  57. package/scripts/mutants/v2-surface.json +7 -7
  58. package/scripts/smoke-codex-fresh-live.ts +94 -13
  59. package/scripts/smoke-herdr-fresh-call-live.ts +15 -8
  60. package/scripts/smoke-herdr-raw-install-live.sh +59 -2
  61. package/scripts/smoke-meta-install-state.sh +107 -1
  62. package/scripts/smoke-mux-lifecycle-live.ts +9 -2
  63. package/scripts/smoke-pi-provider-state.sh +106 -0
  64. package/scripts/smoke-setup-verdict.sh +18 -2
@@ -282,6 +282,112 @@ if doctor >/dev/null 2>&1; then die "doctor(drift): should FAIL (state owns but
282
282
  ok "doctor(drift): FAILS on state-owned + effective-drifted"
283
283
  rm -f "$STATE"
284
284
 
285
+ # ── H-3a..d: the RECORDED managed command is the canonical one (#116 M3-b2 plugin mode) ──
286
+ # `register-pi-provider.py --plugin-runtime` writes an ABSOLUTE bridge under the certified stable
287
+ # runtime into BOTH the settings entry and the install-state `command` (:332-342, :368-369), because
288
+ # a Herdr-plugin host has nothing entwurf on PATH and a bare name cannot resolve there. The
289
+ # `ownership` field in that state is the PREIMAGE classification — what stood at the key BEFORE this
290
+ # install — so `absent` means "we created it" and `managed-current` means "we rewrote our own", and
291
+ # NEITHER means "unowned". A doctor whose only non-drift shape is the bare bin therefore calls every
292
+ # plugin-mode host red while the bridge it points at boots and serves all eight verbs. The canonical
293
+ # command is the one the state RECORDS; the stable runtime root is the writer's business and is
294
+ # deliberately not re-derived here.
295
+ PLUGIN_BRIDGE="$SB/runtime/active/node_modules/.bin/entwurf-bridge"
296
+ mkdir -p "$(dirname "$PLUGIN_BRIDGE")"
297
+ write_mcp_fake "$PLUGIN_BRIDGE"
298
+ THIRD_BRIDGE="$SB/bin/third-party-bridge"
299
+ write_mcp_fake "$THIRD_BRIDGE"
300
+ # $1 ownership, $2 recorded command (omit to record NO command at all)
301
+ write_state() {
302
+ if [ "$#" -ge 2 ]; then
303
+ python3 -c 'import json,sys; json.dump({"schemaVersion":1,"managedSettingsPath":sys.argv[1],"scope":"user","key":"entwurfProvider.mcpServers.entwurf-bridge","ownership":sys.argv[3],"command":sys.argv[4],"installerRoot":"/fake/root","preimage":None}, open(sys.argv[2],"w"))' "$GLOBAL" "$STATE" "$1" "$2"
304
+ else
305
+ python3 -c 'import json,sys; json.dump({"schemaVersion":1,"managedSettingsPath":sys.argv[1],"scope":"user","key":"entwurfProvider.mcpServers.entwurf-bridge","ownership":sys.argv[3],"installerRoot":"/fake/root","preimage":None}, open(sys.argv[2],"w"))' "$GLOBAL" "$STATE" "$1"
306
+ fi
307
+ }
308
+ set_effective() { printf '{"entwurfProvider":{"mcpServers":{"entwurf-bridge":{"command":"%s"}}}}\n' "$1" > "$GLOBAL"; printf '{}\n' > "$PROJECT"; }
309
+
310
+ # H-3a: both preimage classifications a plugin install can record, against the command it recorded.
311
+ set_effective "$PLUGIN_BRIDGE"
312
+ write_state absent "$PLUGIN_BRIDGE"
313
+ set +e
314
+ OUT_ABSENT="$(doctor 2>&1)"; RC_ABSENT=$?
315
+ write_state managed-current "$PLUGIN_BRIDGE"
316
+ OUT_CURRENT="$(doctor 2>&1)"; RC_CURRENT=$?
317
+ set -e
318
+ want "[QK:PI-DOCTOR-PLUGIN-COMMAND-IS-NOT-DRIFT] doctor(effective == recorded managed command): GREEN for preimage ownership absent AND managed-current — a plugin-mode host is not drifted" \
319
+ "[ '$RC_ABSENT' -eq 0 ] && [ '$RC_CURRENT' -eq 0 ]"
320
+ want "doctor(plugin command): the green names the RECORDED command as the canonical one" \
321
+ "printf '%s' \"\$OUT_ABSENT\" | grep -q 'the managed command this install recorded'"
322
+ want "doctor(plugin command): ownership is still reported, not silently dropped" \
323
+ "printf '%s' \"\$OUT_CURRENT\" | grep -q 'ownership=managed-current'"
324
+ want "doctor(plugin command): the boot evidence is still the exact verb set (#81 unweakened)" \
325
+ "printf '%s' \"\$OUT_ABSENT\" | grep -q 'exact entwurf verb set'"
326
+
327
+ # H-3b: REAL drift, in BOTH spellings the effective command can take. Every command here BOOTS on
328
+ # purpose: a cell whose command also failed to resolve would go red for the runtime reason and prove
329
+ # nothing about the ownership axis (that is H-3's shape, and it is why this is a separate cell).
330
+ # (i) a third absolute path the record never named
331
+ # (ii) the BARE name — the escape that a `!isBare`-scoped comparison lets through, because the
332
+ # bare bridge boots and the ownership compare never runs. "Spellable as our old default" is
333
+ # not evidence that it is the command this install wrote, so both must red the same way.
334
+ set_effective "$THIRD_BRIDGE"
335
+ write_state managed-current "$PLUGIN_BRIDGE"
336
+ set +e
337
+ OUT="$(doctor 2>&1)"; RC=$?
338
+ set_effective "entwurf-bridge"
339
+ OUT_BARE="$(doctor 2>&1)"; RC_BARE=$?
340
+ set -e
341
+ want "[QK:PI-DOCTOR-REAL-DRIFT-STILL-RED] doctor(effective != recorded managed command): FAILS for a third absolute path AND for the bare name — a managed key pointing somewhere we never wrote is drift however it is spelled" \
342
+ "[ '$RC' -ne 0 ] && [ '$RC_BARE' -ne 0 ]"
343
+ want "doctor(real drift, third path): the failure names BOTH the recorded command and the effective one" \
344
+ "printf '%s' \"\$OUT\" | grep -q \"records '$PLUGIN_BRIDGE'\" && printf '%s' \"\$OUT\" | grep -q \"effective command is '$THIRD_BRIDGE'\""
345
+ want "doctor(real drift, BARE): names recorded/effective too — a booting bare bridge does not buy the record's green" \
346
+ "printf '%s' \"\$OUT_BARE\" | grep -q \"records '$PLUGIN_BRIDGE'\" && printf '%s' \"\$OUT_BARE\" | grep -q \"effective command is 'entwurf-bridge'\""
347
+ want "doctor(real drift): the drift verdict is independent of the boot, which PASSED in both spellings — not a vacuous red" \
348
+ "printf '%s' \"\$OUT\" | grep -q 'configured override BOOTS' && printf '%s' \"\$OUT_BARE\" | grep -q 'and it BOOTS'"
349
+
350
+ # H-3c: a LEGACY record — one written before `command` existed — keeps the verdict it has always
351
+ # had. Repairing the plugin-mode defect must not migrate the state schema or hand an amnesty to
352
+ # records the doctor cannot compare: a green here would be one nobody measured. Both directions are
353
+ # pinned in ONE cell because they are one claim — non-bare stays red, and the bare bin (which never
354
+ # reaches the ownership branch at all) stays green.
355
+ write_state managed-legacy # no `command` key at all
356
+ set_effective "$THIRD_BRIDGE"
357
+ set +e
358
+ OUT_LEGACY_NONBARE="$(doctor 2>&1)"; RC_LEGACY_NONBARE=$?
359
+ set_effective "entwurf-bridge"
360
+ OUT_LEGACY_BARE="$(doctor 2>&1)"; RC_LEGACY_BARE=$?
361
+ set -e
362
+ want "[QK:PI-DOCTOR-LEGACY-STATE-UNCHANGED] doctor(managed record with NO recorded command): byte-equivalent to before — non-bare red, bare green; this repair grants no schema amnesty" \
363
+ "[ '$RC_LEGACY_NONBARE' -ne 0 ] && [ '$RC_LEGACY_BARE' -eq 0 ]"
364
+ want "doctor(legacy record, non-bare): keeps the ORIGINAL drift wording, not the recorded-command one" \
365
+ "printf '%s' \"\$OUT_LEGACY_NONBARE\" | grep -q \"but the effective command drifted to '$THIRD_BRIDGE'\" && ! printf '%s' \"\$OUT_LEGACY_NONBARE\" | grep -q 'state records'"
366
+ # An ownership word this doctor does not know is NOT a managed record, even when the recorded
367
+ # command matches the effective one exactly. A string that happens to agree is not authority.
368
+ write_state some-future-word "$THIRD_BRIDGE"
369
+ set_effective "$THIRD_BRIDGE"
370
+ set +e
371
+ OUT_UNKNOWN="$(doctor 2>&1)"; RC_UNKNOWN=$?
372
+ set -e
373
+ want "doctor(unknown ownership word + matching command): falls through to the OLD logic — red as a non-bare owned entry, never a managed green" \
374
+ "[ '$RC_UNKNOWN' -ne 0 ] && printf '%s' \"\$OUT_UNKNOWN\" | grep -q 'but the effective command drifted to' && ! printf '%s' \"\$OUT_UNKNOWN\" | grep -q 'the managed command this install recorded'"
375
+ want "doctor(legacy record, bare): the green is still the bare-bin BOOTS line, untouched by the ownership branch" \
376
+ "printf '%s' \"\$OUT_LEGACY_BARE\" | grep -q 'bare stable bin' && printf '%s' \"\$OUT_LEGACY_BARE\" | grep -q 'and it BOOTS'"
377
+
378
+ # H-3d: no install-state at all. A non-bare override that boots stays the operator's choice and an
379
+ # honest note — the pre-Task-2 and never-installed hosts are untouched by everything above. No QK
380
+ # signature: this path is guarded by no mutant of its own, it is here so a regression in it cannot
381
+ # hide behind the cells that do carry one.
382
+ rm -f "$STATE"
383
+ set_effective "$THIRD_BRIDGE"
384
+ OUT="$(doctor)"; RC=$?
385
+ want "doctor(non-bare override, NO install-state): unchanged — runtime judged, ownership left alone, exit 0" \
386
+ "[ '$RC' -eq 0 ]"
387
+ want "doctor(no state): still names it an UNOWNED override rather than adopting it" \
388
+ "printf '%s' \"\$OUT\" | grep -q 'UNOWNED override'"
389
+ rm -f "$STATE"
390
+
285
391
  # H-4: bare-but-dangling (bin not on PATH) → FAIL
286
392
  printf '{"entwurfProvider":{"mcpServers":{"entwurf-bridge":{"command":"entwurf-bridge"}}}}\n' > "$GLOBAL"
287
393
  printf '{}\n' > "$PROJECT"
@@ -98,7 +98,17 @@ export PI_BIN="$ABSENT" CLAUDE_BIN="$ABSENT" AGY_BIN="$ABSENT" COPILOT_BIN="$ABS
98
98
 
99
99
  PASS=0
100
100
  ok() { PASS=$((PASS + 1)); printf ' ok %s\n' "$*"; }
101
- die() { printf 'FAIL: %s\n' "$*" >&2; exit 1; }
101
+ # A cell that judges output it CAPTURED hands that output over here before its `want`, so a
102
+ # red is readable from the run that produced it. The S-8 idempotence cell went red twice under
103
+ # gate qualification and green on every standalone rerun, and neither log could say why: the
104
+ # condition was a pipeline whose output went to `grep -q` and nowhere else. A rerun is not
105
+ # evidence about the run that failed.
106
+ FAIL_CONTEXT=""
107
+ die() {
108
+ printf 'FAIL: %s\n' "$*" >&2
109
+ [ -n "${FAIL_CONTEXT:-}" ] && printf '%s\n%s\n' "--- captured output of the failing step ---" "$FAIL_CONTEXT" >&2
110
+ exit 1
111
+ }
102
112
  want() { # $1 = label, $2 = shell condition
103
113
  if eval "$2"; then ok "$1"; else die "$1"; fi
104
114
  }
@@ -308,8 +318,14 @@ want "S-8: both extension units landed in the sandbox omp agent dir" \
308
318
  "[ -d '$HOME/.omp/agent/extensions/entwurf-meta-omp' ] && [ -d '$HOME/.omp/agent/extensions/entwurf-receive-omp' ]"
309
319
  want "S-8: the MCP hand wrote the pinned key and the setting reached the config the vendor reads" \
310
320
  "grep -q 'entwurf-bridge' '$HOME/.omp/agent/mcp.json' && [ \"\$(python3 '$REPO_DIR/scripts/omp-tool-surface.py' '$HOME/.omp/agent' | awk '/^verdict /{print \$2}')\" = 'xdev-off' ]"
321
+ # Captured rather than piped straight into `grep -q`: this is the cell that went red under
322
+ # qualification and green standalone, and the discarded output was the only place the reason
323
+ # could have been.
324
+ set +e; OUT8B="$(OMP_BIN="$FAKE_OMP/omp" ENTWURF_OMP_AGENT_DIR="$OMP_AGENT" PATH="$FAKE_OMP:$PATH" bash "$REPO_DIR/run.sh" setup "$PROJ8" 2>&1)"; set -e
325
+ FAIL_CONTEXT="$OUT8B"
311
326
  want "S-8: setup is idempotent — a second run over the composed host is still green" \
312
- "OMP_BIN='$FAKE_OMP/omp' ENTWURF_OMP_AGENT_DIR='$HOME/.omp/agent' PATH='$FAKE_OMP:$PATH' bash '$REPO_DIR/run.sh' setup '$PROJ8' 2>&1 | grep -q 'result: green (computed from the component outcomes above)'"
327
+ "printf '%s' \"\$OUT8B\" | grep -q 'result: green (computed from the component outcomes above)'"
328
+ FAIL_CONTEXT=""
313
329
  want_auth_untouched "S-8"
314
330
  # Reset the composed OMP state so the next cell decides on a clean host.
315
331
  rm -rf "$HOME/.omp" "$XDG_DATA_HOME/entwurf/omp-bridge" "$XDG_DATA_HOME/entwurf/omp-mcp" \