@junghanacs/entwurf 0.14.0 → 0.14.1
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/AGENTS.md +12 -1
- package/CHANGELOG.md +29 -0
- package/README.md +15 -6
- package/docs/external-mcp-host.md +1 -1
- package/mcp/entwurf-bridge/dist/mcp/entwurf-bridge/src/index.js +12 -5
- package/mcp/entwurf-bridge/dist/pi-extensions/lib/classify-tmux-cwd.js +47 -0
- package/mcp/entwurf-bridge/dist/pi-extensions/lib/mux-fresh-call.js +45 -3
- package/mcp/entwurf-bridge/dist/pi-extensions/lib/mux-resume-call.js +18 -47
- package/mcp/entwurf-bridge/src/index.ts +14 -5
- package/package.json +1 -1
- package/pi-extensions/entwurf-control.ts +13 -4
- package/pi-extensions/lib/classify-tmux-cwd.ts +50 -0
- package/pi-extensions/lib/mux-fresh-call.ts +57 -4
- package/pi-extensions/lib/mux-resume-call.ts +21 -53
- package/scripts/check-gate-qualification.ts +2 -1
- package/scripts/check-mux-resume-call.ts +11 -10
- package/scripts/meta-bridge-state.py +75 -1
- package/scripts/mutants/meta-retire.json +47 -0
- package/scripts/mutants/mux-fresh-call.json +48 -4
- package/scripts/mutants/mux-resume-call.json +3 -3
- package/scripts/smoke-entwurf-chain-live.ts +11 -3
- package/scripts/smoke-meta-install-state.sh +169 -3
|
@@ -161,6 +161,14 @@ async function main(): Promise<void> {
|
|
|
161
161
|
ENTWURF_META_MAILBOX_DIR: mailboxDir,
|
|
162
162
|
ENTWURF_META_RECEIVERS_DIR: receiversDir,
|
|
163
163
|
};
|
|
164
|
+
// The MCP bridge prefers PI_SESSION_ID+PI_AGENT_ID over a meta-sender marker when both
|
|
165
|
+
// are present. A runner that is itself a pi --entwurf-control session (release-gate,
|
|
166
|
+
// an agent preparing a cut) would otherwise stamp every Claude hop with the RUNNER's
|
|
167
|
+
// garden id — hop 1 then fails "B saw A's real garden id" while the payload still
|
|
168
|
+
// traverses. Strip the carriers so A's SessionStart marker is the only authority.
|
|
169
|
+
const childEnv: NodeJS.ProcessEnv = { ...process.env, ...worldEnv };
|
|
170
|
+
delete childEnv.PI_SESSION_ID;
|
|
171
|
+
delete childEnv.PI_AGENT_ID;
|
|
164
172
|
|
|
165
173
|
const nonce = `ENTWURF-CHAIN-${crypto.randomBytes(5).toString("hex").toUpperCase()}`;
|
|
166
174
|
console.error(`[smoke-entwurf-chain-live] repo: ${REPO_ROOT}`);
|
|
@@ -194,7 +202,7 @@ async function main(): Promise<void> {
|
|
|
194
202
|
const c = spawn(
|
|
195
203
|
"pi",
|
|
196
204
|
[...REPO_EXTENSION_ARGS, "--entwurf-control", "--provider", acpProvider, "--model", acpModel, "--mode", "rpc"],
|
|
197
|
-
{ cwd: world, stdio: ["pipe", "pipe", "pipe"], env:
|
|
205
|
+
{ cwd: world, stdio: ["pipe", "pipe", "pipe"], env: childEnv },
|
|
198
206
|
);
|
|
199
207
|
children.push(c);
|
|
200
208
|
c.stdout?.on("data", (b: Buffer) => {
|
|
@@ -215,7 +223,7 @@ async function main(): Promise<void> {
|
|
|
215
223
|
const b = spawn(
|
|
216
224
|
"pi",
|
|
217
225
|
[...REPO_EXTENSION_ARGS, "--entwurf-control", "--provider", gptProvider, "--model", gptModel, "--mode", "rpc"],
|
|
218
|
-
{ cwd: world, stdio: ["pipe", "pipe", "pipe"], env:
|
|
226
|
+
{ cwd: world, stdio: ["pipe", "pipe", "pipe"], env: childEnv },
|
|
219
227
|
);
|
|
220
228
|
children.push(b);
|
|
221
229
|
b.stdout?.on("data", (x: Buffer) => {
|
|
@@ -265,7 +273,7 @@ async function main(): Promise<void> {
|
|
|
265
273
|
cwd: world,
|
|
266
274
|
encoding: "utf8",
|
|
267
275
|
timeout: CLAUDE_TURN_TIMEOUT_MS,
|
|
268
|
-
env:
|
|
276
|
+
env: childEnv,
|
|
269
277
|
});
|
|
270
278
|
const claudeOut = `${claudeRun.stdout ?? ""}\n${claudeRun.stderr ?? ""}`;
|
|
271
279
|
ok("A's native Claude Code turn ran", claudeRun.status === 0);
|
|
@@ -6,6 +6,7 @@ set -euo pipefail
|
|
|
6
6
|
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
7
7
|
REPO="$(cd "$HERE/.." && pwd)"
|
|
8
8
|
export REPO
|
|
9
|
+
export PYTHONDONTWRITEBYTECODE=1
|
|
9
10
|
STATE="$REPO/scripts/meta-bridge-state.py"
|
|
10
11
|
STORE_DOCTOR="$REPO/scripts/meta-bridge-store-doctor.ts"
|
|
11
12
|
# shellcheck source=scripts/meta-bridge-hook-log.sh
|
|
@@ -192,6 +193,136 @@ JSON
|
|
|
192
193
|
|
|
193
194
|
py() { python3 "$STATE" "$@" --repo "$REPO" --asm "$ASM"; }
|
|
194
195
|
|
|
196
|
+
# #71 retirement cells: drive the production leaf directly so JSON scalar type,
|
|
197
|
+
# malformed provenance and one-shot convergence cannot hide inside the larger
|
|
198
|
+
# install fixture below. Three cells carry [QK:] claims backed by exact-once
|
|
199
|
+
# mutants in scripts/mutants/meta-retire.json; each prints its token on the
|
|
200
|
+
# FAILURE line, because signatureOnFailureLine ignores any line starting with
|
|
201
|
+
# `ok`. Cells keep running after a failure so one planted defect reddens exactly
|
|
202
|
+
# its own claim instead of masking the ones behind it.
|
|
203
|
+
if python3 - "$STATE" <<'PY'
|
|
204
|
+
import copy, importlib.util, sys
|
|
205
|
+
|
|
206
|
+
spec = importlib.util.spec_from_file_location("meta_bridge_state", sys.argv[1])
|
|
207
|
+
assert spec and spec.loader
|
|
208
|
+
m = importlib.util.module_from_spec(spec)
|
|
209
|
+
spec.loader.exec_module(m)
|
|
210
|
+
NAME = "skipDangerousModePermissionPrompt"
|
|
211
|
+
PATH = [NAME]
|
|
212
|
+
MISSING = object()
|
|
213
|
+
|
|
214
|
+
def entry(existed, value):
|
|
215
|
+
return {"kind": "scalar", "path": PATH, "original": {"existed": existed, "value": value}}
|
|
216
|
+
|
|
217
|
+
def fixture(current=MISSING, old_entry=MISSING):
|
|
218
|
+
settings = {} if current is MISSING else {NAME: current}
|
|
219
|
+
keys = {} if old_entry is MISSING else {NAME: copy.deepcopy(old_entry)}
|
|
220
|
+
state = {"files": {"settings": {"keys": keys}}}
|
|
221
|
+
return state, settings
|
|
222
|
+
|
|
223
|
+
def run(current=MISSING, old_entry=MISSING):
|
|
224
|
+
state, settings = fixture(current, old_entry)
|
|
225
|
+
m.relinquish_retired_scalar(state, settings, NAME, PATH, True)
|
|
226
|
+
return state, settings
|
|
227
|
+
|
|
228
|
+
failed = 0
|
|
229
|
+
|
|
230
|
+
def cell(sig, label, fn):
|
|
231
|
+
global failed
|
|
232
|
+
text = f"{sig} {label}".strip()
|
|
233
|
+
try:
|
|
234
|
+
fn()
|
|
235
|
+
except Exception as exc:
|
|
236
|
+
print(f" FAIL {text}: {exc!r}")
|
|
237
|
+
failed = 1
|
|
238
|
+
return
|
|
239
|
+
print(f" ok {text}")
|
|
240
|
+
|
|
241
|
+
def compare_type_cells():
|
|
242
|
+
assert NAME not in run(True, entry(False, None))[1]
|
|
243
|
+
assert run(True, entry(True, False))[1][NAME] is False
|
|
244
|
+
assert run(True, entry(True, True))[1][NAME] is True
|
|
245
|
+
assert run(False, entry(True, False))[1][NAME] is False
|
|
246
|
+
assert NAME not in run(MISSING, entry(True, False))[1]
|
|
247
|
+
value = run(1, entry(True, False))[1][NAME]
|
|
248
|
+
assert type(value) is int and value == 1
|
|
249
|
+
|
|
250
|
+
cell(
|
|
251
|
+
"[QK:META-RETIRE-COMPARE-TYPE]",
|
|
252
|
+
"only an exact bool true with proven provenance is restored; 1 is not true",
|
|
253
|
+
compare_type_cells,
|
|
254
|
+
)
|
|
255
|
+
|
|
256
|
+
def malformed_cells():
|
|
257
|
+
for bad_entry in [
|
|
258
|
+
{"kind": "map-entry", "path": PATH, "original": {"existed": False, "value": None}},
|
|
259
|
+
{"kind": "scalar", "path": PATH, "original": {"existed": "no", "value": None}},
|
|
260
|
+
]:
|
|
261
|
+
state, settings = fixture(True, bad_entry)
|
|
262
|
+
before = copy.deepcopy((state, settings))
|
|
263
|
+
try:
|
|
264
|
+
m.relinquish_retired_scalar(state, settings, NAME, PATH, True)
|
|
265
|
+
except m.StateError:
|
|
266
|
+
pass
|
|
267
|
+
else:
|
|
268
|
+
raise AssertionError("malformed retired provenance was accepted")
|
|
269
|
+
assert (state, settings) == before
|
|
270
|
+
|
|
271
|
+
cell(
|
|
272
|
+
"[QK:META-RETIRE-MALFORMED-SILENT]",
|
|
273
|
+
"malformed provenance fails loud and mutates neither settings nor state",
|
|
274
|
+
malformed_cells,
|
|
275
|
+
)
|
|
276
|
+
|
|
277
|
+
def fresh_cells():
|
|
278
|
+
for current in [True, False, 1, MISSING]:
|
|
279
|
+
state, settings = run(current)
|
|
280
|
+
expected = {} if current is MISSING else {NAME: current}
|
|
281
|
+
assert settings == expected and NAME not in state["files"]["settings"]["keys"]
|
|
282
|
+
|
|
283
|
+
cell(
|
|
284
|
+
"[QK:META-RETIRE-FRESH-TOUCH]",
|
|
285
|
+
"a provenance-less value is the operator's and is never touched",
|
|
286
|
+
fresh_cells,
|
|
287
|
+
)
|
|
288
|
+
|
|
289
|
+
def one_shot_cells():
|
|
290
|
+
state, settings = fixture(True, entry(True, False))
|
|
291
|
+
m.relinquish_retired_scalar(state, settings, NAME, PATH, True)
|
|
292
|
+
assert settings[NAME] is False and NAME not in state["files"]["settings"]["keys"]
|
|
293
|
+
before = copy.deepcopy((state, settings))
|
|
294
|
+
m.relinquish_retired_scalar(state, settings, NAME, PATH, True)
|
|
295
|
+
assert (state, settings) == before
|
|
296
|
+
|
|
297
|
+
# Recommended, not claimed: one-shot convergence and the disjoint-set guard ride
|
|
298
|
+
# along as ordinary cells so the proof budget stays at the three claims above.
|
|
299
|
+
cell("", "relinquishment consumes the entry once, so a re-run cannot restore again", one_shot_cells)
|
|
300
|
+
|
|
301
|
+
def structural_cells():
|
|
302
|
+
assert not m._managed_scalar_names & m._retired_scalar_names
|
|
303
|
+
# settings_state_keys is the sole reader of the ownership ledger, and
|
|
304
|
+
# load_state validates only the envelope. A corrupt files/settings/keys shape
|
|
305
|
+
# must stop with an operator diagnostic BEFORE any write — never a bare
|
|
306
|
+
# KeyError raised from inside apply(), and never a silent pass that would let
|
|
307
|
+
# relinquishment reason about ownership it cannot actually read.
|
|
308
|
+
for broken in [{}, {"files": {}}, {"files": {"settings": {}}}, {"files": {"settings": {"keys": []}}}]:
|
|
309
|
+
settings = {NAME: True}
|
|
310
|
+
before = copy.deepcopy((broken, settings))
|
|
311
|
+
try:
|
|
312
|
+
m.relinquish_retired_scalar(broken, settings, NAME, PATH, True)
|
|
313
|
+
except m.StateError:
|
|
314
|
+
pass
|
|
315
|
+
else:
|
|
316
|
+
raise AssertionError(f"corrupt state ledger accepted: {broken!r}")
|
|
317
|
+
assert (broken, settings) == before
|
|
318
|
+
|
|
319
|
+
cell("", "retired/managed sets stay disjoint and a corrupt key ledger fails closed", structural_cells)
|
|
320
|
+
sys.exit(failed)
|
|
321
|
+
PY
|
|
322
|
+
then ok "#71 retirement leaf: provenance, bool strictness, malformed refusal, one-shot convergence"
|
|
323
|
+
else bad "#71 retirement leaf cells failed (traceback above)"
|
|
324
|
+
fi
|
|
325
|
+
|
|
195
326
|
DEV_STATUSLINE="$(python3 "$STATE" desired-statusline --repo "$REPO" | python3 -c 'import json,sys; print(json.load(sys.stdin)["command"])')"
|
|
196
327
|
if [ "$DEV_STATUSLINE" = "$REPO/scripts/meta-bridge-statusline.sh" ]; then ok "dev statusLine pins the checkout script"; else bad "dev statusLine command drifted: $DEV_STATUSLINE"; fi
|
|
197
328
|
FAKE_INSTALLED_REPO="$TMP/npmroot/node_modules/@junghanacs/entwurf"
|
|
@@ -212,10 +343,26 @@ assert s['files']['settings']['keys']['env.DISABLE_AUTOCOMPACT']['original']['va
|
|
|
212
343
|
assert s['files']['settings']['keys']['statusLine']['original']['value']['command'] == '/old/user/statusline.sh'
|
|
213
344
|
assert s['files']['settings']['keys']['promptSuggestionEnabled']['original']['value'] is True
|
|
214
345
|
assert s['files']['settings']['keys']['autoCompactEnabled']['original']['existed'] is False
|
|
346
|
+
assert 'skipDangerousModePermissionPrompt' not in s['files']['settings']['keys']
|
|
215
347
|
assert s['files']['claudeRoot']['keys']['mcpServers.entwurf-bridge']['original']['value']['command'] == 'old'
|
|
216
348
|
PY
|
|
217
|
-
then ok "state captures original scalar/map values and is mode 0600"; else bad "state did not capture original values / mode 0600"; fi
|
|
349
|
+
then ok "state captures original scalar/map values, excludes the retired scalar, and is mode 0600"; else bad "state did not capture original values / retirement / mode 0600"; fi
|
|
218
350
|
|
|
351
|
+
# Simulate an upgrade from 0.14.0: the old state proves entwurf changed false→true.
|
|
352
|
+
# New apply must restore false and consume that ownership exactly once.
|
|
353
|
+
python3 - <<'PY'
|
|
354
|
+
import json, os
|
|
355
|
+
cfg=os.environ['CLAUDE_CONFIG_DIR']
|
|
356
|
+
sp=cfg + '/settings.json'; stp=cfg + '/entwurf.install-state.json'
|
|
357
|
+
settings=json.load(open(sp)); state=json.load(open(stp))
|
|
358
|
+
settings['skipDangerousModePermissionPrompt']=True
|
|
359
|
+
state['files']['settings']['keys']['skipDangerousModePermissionPrompt']={
|
|
360
|
+
'kind':'scalar', 'path':['skipDangerousModePermissionPrompt'],
|
|
361
|
+
'original':{'existed':True, 'value':False}
|
|
362
|
+
}
|
|
363
|
+
json.dump(settings, open(sp,'w'), indent=2); open(sp,'a').write('\n')
|
|
364
|
+
json.dump(state, open(stp,'w'), indent=2); open(stp,'a').write('\n')
|
|
365
|
+
PY
|
|
219
366
|
py apply >/dev/null
|
|
220
367
|
if python3 - <<'PY'
|
|
221
368
|
import json, os
|
|
@@ -231,7 +378,9 @@ assert settings['env']['KEEP_ME'] == 'yes'
|
|
|
231
378
|
assert settings['statusLine']['command'] == os.environ['REPO'] + '/scripts/meta-bridge-statusline.sh'
|
|
232
379
|
for key in ['promptSuggestionEnabled','awaySummaryEnabled','autoMemoryEnabled','verbose','autoCompactEnabled','showTurnDuration','terminalProgressBarEnabled','useAutoModeDuringPlan','enableWorkflows','workflowKeywordTriggerEnabled']:
|
|
233
380
|
assert settings[key] is False, key
|
|
234
|
-
assert settings['skipDangerousModePermissionPrompt'] is
|
|
381
|
+
assert settings['skipDangerousModePermissionPrompt'] is False
|
|
382
|
+
state=json.load(open(cfg + '/entwurf.install-state.json'))
|
|
383
|
+
assert 'skipDangerousModePermissionPrompt' not in state['files']['settings']['keys']
|
|
235
384
|
for item in ['Bash','Read','Write','Edit','Grep','Glob','WebFetch','WebSearch','Skill','mcp__entwurf-bridge__*']:
|
|
236
385
|
assert item in settings['permissions']['allow'], item
|
|
237
386
|
assert settings['permissions']['allow'].count('Read') == 1
|
|
@@ -249,7 +398,24 @@ then ok "apply installs managed keyset without clobbering unrelated keys"; else
|
|
|
249
398
|
# (agent-config merge, hand edit) overwrites a pi-owned key, check must fail loud
|
|
250
399
|
# AND name the drifted key so doctor can surface which one. Adversarial flips
|
|
251
400
|
# below; restore with apply afterward so the later cases see a clean keyset.
|
|
252
|
-
if py check >/dev/null 2>&1; then ok "survival check passes
|
|
401
|
+
if py check >/dev/null 2>&1; then ok "survival check passes after relinquishing the retired scalar"; else bad "survival check failed right after retirement apply"; fi
|
|
402
|
+
MANAGED_JSON="$(py managed-keys)"
|
|
403
|
+
if printf '%s' "$MANAGED_JSON" | grep -q 'skipDangerousModePermissionPrompt'; then bad "managed-keys still claims the retired operator key"; else ok "managed-keys returns skipDangerousModePermissionPrompt to the operator"; fi
|
|
404
|
+
# A provenance-less true cannot be changed safely, but doctor/check must make it visible.
|
|
405
|
+
python3 - <<'PY'
|
|
406
|
+
import json, os
|
|
407
|
+
p=os.environ['CLAUDE_CONFIG_DIR'] + '/settings.json'
|
|
408
|
+
d=json.load(open(p)); d['skipDangerousModePermissionPrompt']=True
|
|
409
|
+
json.dump(d, open(p,'w'), indent=2); open(p,'a').write('\n')
|
|
410
|
+
PY
|
|
411
|
+
RETIRED_NOTE="$(py check)"
|
|
412
|
+
if printf '%s' "$RETIRED_NOTE" | grep -q 'operator-owned'; then ok "check advises on a provenance-less true without claiming ownership"; else bad "check hid the provenance-less retired true"; fi
|
|
413
|
+
python3 - <<'PY'
|
|
414
|
+
import json, os
|
|
415
|
+
p=os.environ['CLAUDE_CONFIG_DIR'] + '/settings.json'
|
|
416
|
+
d=json.load(open(p)); d['skipDangerousModePermissionPrompt']=False
|
|
417
|
+
json.dump(d, open(p,'w'), indent=2); open(p,'a').write('\n')
|
|
418
|
+
PY
|
|
253
419
|
SURVIVAL_SNAP="$TMP/settings-survival-snapshot.json"
|
|
254
420
|
cp "$CLAUDE_CONFIG_DIR/settings.json" "$SURVIVAL_SNAP" # exact restore point (array-replace below would drop user items)
|
|
255
421
|
python3 - <<'PY'
|