@christang/keel 5.179.0 → 5.180.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.
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/assets/bootstrap/AGENTS.md +1 -1
- package/bin/keel.js +113 -2
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/plugins/keel/.claude-plugin/plugin.json +1 -1
- package/plugins/keel/.codex-plugin/plugin.json +1 -1
- package/scripts/validate_plugin.py +159 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.180.0",
|
|
4
4
|
"description": "Keel OpenSpec execution discipline: stateless continuity, task capsules, deterministic gates, and expectation alignment for Codex and Claude Code.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "TanglmChris",
|
package/README.md
CHANGED
|
@@ -1003,7 +1003,7 @@ keel --init [--target <t>] [--dry-run] [--force-template-update]
|
|
|
1003
1003
|
keel --install [--target <t>] [--dry-run] [--force-template-update] [--with-git-hooks]
|
|
1004
1004
|
keel --check | --doctor [--target <t>]
|
|
1005
1005
|
keel --uninstall | --clear [--target <t>] [--dry-run] # --clear is the same removal
|
|
1006
|
-
keel --update [--dry-run] [--source <npm package or git spec>]
|
|
1006
|
+
keel --update [--dry-run] [--source <npm package or git spec>] [--adopt] # --adopt: restart idle background sessions on the new plugin
|
|
1007
1007
|
keel --version | --help
|
|
1008
1008
|
|
|
1009
1009
|
# OpenSpec, through the CLI Keel bundles
|
package/README.zh-CN.md
CHANGED
|
@@ -846,7 +846,7 @@ keel --init [--target <t>] [--dry-run] [--force-template-update]
|
|
|
846
846
|
keel --install [--target <t>] [--dry-run] [--force-template-update] [--with-git-hooks]
|
|
847
847
|
keel --check | --doctor [--target <t>]
|
|
848
848
|
keel --uninstall | --clear [--target <t>] [--dry-run] # --clear 是同一种移除
|
|
849
|
-
keel --update [--dry-run] [--source <npm package or git spec>]
|
|
849
|
+
keel --update [--dry-run] [--source <npm package or git spec>] [--adopt] # --adopt:让空闲的后台会话重启到新插件上
|
|
850
850
|
keel --version | --help
|
|
851
851
|
|
|
852
852
|
# OpenSpec,通过 Keel 捆绑的 CLI 运行
|
package/bin/keel.js
CHANGED
|
@@ -106,7 +106,7 @@ Usage:
|
|
|
106
106
|
keel --install [repo] [--target claude|codex|opencode] [--dry-run] [--force-template-update] [--with-git-hooks]
|
|
107
107
|
keel --clear [repo] [--target claude|codex|opencode] [--dry-run]
|
|
108
108
|
keel --uninstall [repo] [--target claude|codex|opencode] [--dry-run]
|
|
109
|
-
keel --update [--dry-run] [--source npm-package-or-git-spec]
|
|
109
|
+
keel --update [--dry-run] [--source npm-package-or-git-spec] [--adopt]
|
|
110
110
|
keel --check [repo] [--target claude|codex|opencode]
|
|
111
111
|
keel --doctor [repo] [--target claude|codex|opencode]
|
|
112
112
|
keel --version
|
|
@@ -179,6 +179,7 @@ function parseArgs(argv) {
|
|
|
179
179
|
forceTemplateUpdate: false,
|
|
180
180
|
withGitHooks: false,
|
|
181
181
|
updateSource: null,
|
|
182
|
+
adopt: false,
|
|
182
183
|
help: false,
|
|
183
184
|
version: false,
|
|
184
185
|
change: null,
|
|
@@ -355,6 +356,10 @@ function parseArgs(argv) {
|
|
|
355
356
|
parsed.withGitHooks = true;
|
|
356
357
|
continue;
|
|
357
358
|
}
|
|
359
|
+
if (arg === "--adopt") {
|
|
360
|
+
parsed.adopt = true;
|
|
361
|
+
continue;
|
|
362
|
+
}
|
|
358
363
|
if (arg === "--target") {
|
|
359
364
|
index += 1;
|
|
360
365
|
if (index >= argv.length) {
|
|
@@ -987,7 +992,12 @@ function claudeKeel(executable) {
|
|
|
987
992
|
const entry = (Array.isArray(listed) ? listed : [])
|
|
988
993
|
.find((item) => item && typeof item.id === "string" && item.id.startsWith("keel@"));
|
|
989
994
|
if (!entry) return null;
|
|
990
|
-
return {
|
|
995
|
+
return {
|
|
996
|
+
id: entry.id,
|
|
997
|
+
market: entry.id.slice("keel@".length),
|
|
998
|
+
version: entry.version || null,
|
|
999
|
+
lastUpdated: entry.lastUpdated || null,
|
|
1000
|
+
};
|
|
991
1001
|
}
|
|
992
1002
|
|
|
993
1003
|
// The Codex marketplace needs only its catalog and the plugin it names; a
|
|
@@ -1378,11 +1388,106 @@ function runGlobalUpdate(options) {
|
|
|
1378
1388
|
const results = [
|
|
1379
1389
|
updateGlobalCli(options, npm, source),
|
|
1380
1390
|
updateClaudePlugin(options, npm),
|
|
1391
|
+
adoptClaudeSessions(options),
|
|
1381
1392
|
updateCodexPlugin(options),
|
|
1382
1393
|
];
|
|
1383
1394
|
return results.every(Boolean) ? 0 : 1;
|
|
1384
1395
|
}
|
|
1385
1396
|
|
|
1397
|
+
function waitForExit(pid, limitMs) {
|
|
1398
|
+
if (!Number.isInteger(pid) || pid <= 0) return true;
|
|
1399
|
+
const deadline = Date.now() + limitMs;
|
|
1400
|
+
for (;;) {
|
|
1401
|
+
try {
|
|
1402
|
+
process.kill(pid, 0);
|
|
1403
|
+
} catch {
|
|
1404
|
+
return true;
|
|
1405
|
+
}
|
|
1406
|
+
if (Date.now() >= deadline) return false;
|
|
1407
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 200);
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
// A Claude background session keeps the plugin it loaded (#424). A hand-over
|
|
1412
|
+
// adopts the update, because it starts a new process; a session that does not
|
|
1413
|
+
// change shift stays on the old one. Each running background session started
|
|
1414
|
+
// before the installed plugin's `lastUpdated` is named, and with --adopt each
|
|
1415
|
+
// idle one is restarted: `claude stop`, a wait for its process to exit (a
|
|
1416
|
+
// resume before that starts a copy, #395), then `claude --bg --resume <id>`
|
|
1417
|
+
// with no prompt and no flag, which keeps its id and runs no turn (measured
|
|
1418
|
+
// 2026-10-21, Claude Code 2.1.304). A busy or waiting session, one under a
|
|
1419
|
+
// task's write guard, and the session running this are left.
|
|
1420
|
+
function adoptClaudeSessions(options) {
|
|
1421
|
+
const component = "claude sessions";
|
|
1422
|
+
const executable = process.env.KEEL_UPDATE_CLAUDE || "claude";
|
|
1423
|
+
if (options.dryRun) {
|
|
1424
|
+
if (options.adopt) {
|
|
1425
|
+
process.stdout.write("keel: would restart each idle background session started before the installed plugin: "
|
|
1426
|
+
+ "claude stop <id>, then claude --bg --resume <session id>\n");
|
|
1427
|
+
}
|
|
1428
|
+
return true;
|
|
1429
|
+
}
|
|
1430
|
+
const plugin = claudeKeel(executable);
|
|
1431
|
+
const updatedAt = Date.parse((plugin && plugin.lastUpdated) || "");
|
|
1432
|
+
if (!plugin || plugin.failed || !Number.isFinite(updatedAt)) return true;
|
|
1433
|
+
const listed = hostQuery(executable, ["agents", "--json"]);
|
|
1434
|
+
const rows = !listed.failed && Array.isArray(listed.json) ? listed.json : null;
|
|
1435
|
+
if (!rows) {
|
|
1436
|
+
if (!options.adopt) return true;
|
|
1437
|
+
updateLine(component, "failed", `\`claude agents --json\` ${listed.failed || "listed no sessions"}, so none was adopted`);
|
|
1438
|
+
return false;
|
|
1439
|
+
}
|
|
1440
|
+
const own = process.env.CLAUDE_CODE_SESSION_ID || "";
|
|
1441
|
+
const older = rows.filter((row) => row && row.kind === "background" && row.status && row.sessionId
|
|
1442
|
+
&& row.sessionId !== own && Number(row.startedAt) < updatedAt);
|
|
1443
|
+
if (older.length === 0) return true;
|
|
1444
|
+
const named = (row) => `${row.name || row.sessionId.slice(0, 8)} (${row.id || row.sessionId.slice(0, 8)})`;
|
|
1445
|
+
if (!options.adopt) {
|
|
1446
|
+
updateLine(component, "manual", `${older.length} started before the plugin was installed and still run the skills they loaded: `
|
|
1447
|
+
+ `${older.map(named).join(", ")}; \`keel --update --adopt\` restarts the idle ones, and a shift change starts its new session on the installed plugin`);
|
|
1448
|
+
return true;
|
|
1449
|
+
}
|
|
1450
|
+
const adopted = [];
|
|
1451
|
+
const left = [];
|
|
1452
|
+
const failed = [];
|
|
1453
|
+
for (const row of older) {
|
|
1454
|
+
if (row.status !== "idle") {
|
|
1455
|
+
left.push(`${named(row)}, ${row.status}`);
|
|
1456
|
+
continue;
|
|
1457
|
+
}
|
|
1458
|
+
if (row.cwd && fs.existsSync(path.join(row.cwd, "keel", "guard.json"))) {
|
|
1459
|
+
left.push(`${named(row)}, under a task's write guard`);
|
|
1460
|
+
continue;
|
|
1461
|
+
}
|
|
1462
|
+
const stopped = hostRun(executable, ["stop", row.id || row.sessionId.slice(0, 8)]);
|
|
1463
|
+
if (stopped.error || stopped.status !== 0) {
|
|
1464
|
+
failed.push(`${named(row)}: \`claude stop\` ${hostFailure(stopped)}`);
|
|
1465
|
+
continue;
|
|
1466
|
+
}
|
|
1467
|
+
if (!waitForExit(Number(row.pid), 15 * 1000)) {
|
|
1468
|
+
failed.push(`${named(row)}: its process ${row.pid} was still running 15 s after \`claude stop\``);
|
|
1469
|
+
continue;
|
|
1470
|
+
}
|
|
1471
|
+
const resumed = spawnSync(executable, ["--bg", "--resume", row.sessionId], {
|
|
1472
|
+
encoding: "utf8",
|
|
1473
|
+
cwd: row.cwd && fs.existsSync(row.cwd) ? row.cwd : undefined,
|
|
1474
|
+
shell: process.platform === "win32",
|
|
1475
|
+
timeout: 60 * 1000,
|
|
1476
|
+
});
|
|
1477
|
+
if (resumed.error || resumed.status !== 0) {
|
|
1478
|
+
failed.push(`${named(row)}: \`claude --bg --resume\` ${hostFailure(resumed)}; \`claude attach ${row.id || row.sessionId.slice(0, 8)}\` reopens it`);
|
|
1479
|
+
continue;
|
|
1480
|
+
}
|
|
1481
|
+
adopted.push(named(row));
|
|
1482
|
+
}
|
|
1483
|
+
const parts = [];
|
|
1484
|
+
if (adopted.length) parts.push(`adopted ${adopted.join(", ")} — restarted on the installed plugin, same session, no turn run`);
|
|
1485
|
+
if (left.length) parts.push(`left ${left.join("; ")} — each adopts at its next shift change or another --adopt`);
|
|
1486
|
+
if (failed.length) parts.push(`could not adopt ${failed.join("; ")}`);
|
|
1487
|
+
updateLine(component, failed.length ? "failed" : "updated", parts.join("; "));
|
|
1488
|
+
return failed.length === 0;
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1386
1491
|
function runPython(script, args) {
|
|
1387
1492
|
if (!fs.existsSync(script)) {
|
|
1388
1493
|
process.stderr.write(`keel: missing packaged script: ${script}\n`);
|
|
@@ -2758,6 +2863,9 @@ function runAction(options) {
|
|
|
2758
2863
|
if (options.withGitHooks && options.action !== "install") {
|
|
2759
2864
|
fail("--with-git-hooks only applies to --install");
|
|
2760
2865
|
}
|
|
2866
|
+
if (options.adopt && options.action !== "update") {
|
|
2867
|
+
fail("--adopt only applies to --update");
|
|
2868
|
+
}
|
|
2761
2869
|
|
|
2762
2870
|
if (options.action === "openspec") {
|
|
2763
2871
|
const openspec = findOpenSpecCommand();
|
|
@@ -3040,6 +3148,9 @@ function main() {
|
|
|
3040
3148
|
return require("../src/core/agents").runAgents(process.argv.slice(3));
|
|
3041
3149
|
}
|
|
3042
3150
|
const options = parseArgs(process.argv.slice(2));
|
|
3151
|
+
if (options.adopt && options.action !== "update") {
|
|
3152
|
+
fail("--adopt only applies to --update");
|
|
3153
|
+
}
|
|
3043
3154
|
if (options.help || (!options.action && !options.version)) {
|
|
3044
3155
|
printHelp();
|
|
3045
3156
|
return 0;
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@christang/keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.180.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@christang/keel",
|
|
9
|
-
"version": "5.
|
|
9
|
+
"version": "5.180.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@fission-ai/openspec": "^1.4.1"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.180.0",
|
|
4
4
|
"description": "Keel OpenSpec execution discipline: stateless continuity, task capsules, deterministic gates, and expectation alignment for Codex and Claude Code.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "TanglmChris",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.180.0",
|
|
4
4
|
"description": "Keel OpenSpec execution discipline: stateless continuity, task capsules, deterministic gates, and expectation alignment for Codex and Claude Code.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "TanglmChris",
|
|
@@ -51,8 +51,8 @@ REQUIRED_SCRIPTS = [
|
|
|
51
51
|
"scripts/validate_plugin.py",
|
|
52
52
|
]
|
|
53
53
|
|
|
54
|
-
PACKAGE_VERSION = "5.
|
|
55
|
-
PROTOCOL_VERSION = "5.
|
|
54
|
+
PACKAGE_VERSION = "5.180.0"
|
|
55
|
+
PROTOCOL_VERSION = "5.180.0"
|
|
56
56
|
LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
|
|
57
57
|
OPENSPEC_SCHEMA_NAME = "keel-spec-driven"
|
|
58
58
|
# Mirrors KEEL_PACKAGE_NAME in scripts/install_to_repo.py, one of the two
|
|
@@ -25323,6 +25323,162 @@ process.exit(0);
|
|
|
25323
25323
|
"""
|
|
25324
25324
|
|
|
25325
25325
|
|
|
25326
|
+
# A claude for #424: the Keel plugin, the background sessions `agents --json`
|
|
25327
|
+
# lists, `stop` (which kills the row's process, as the host does a moment after
|
|
25328
|
+
# returning), and `--bg --resume`, which records whether the old process was
|
|
25329
|
+
# still alive when it ran.
|
|
25330
|
+
ADOPT_FAKE_CLAUDE = r"""const fs = require("fs");
|
|
25331
|
+
const args = process.argv.slice(2);
|
|
25332
|
+
const joined = args.join(" ");
|
|
25333
|
+
const statePath = process.env.FAKE_STATE;
|
|
25334
|
+
const state = JSON.parse(fs.readFileSync(statePath, "utf8"));
|
|
25335
|
+
const save = () => fs.writeFileSync(statePath, JSON.stringify(state));
|
|
25336
|
+
fs.appendFileSync(process.env.FAKE_LOG, JSON.stringify({ args, cwd: process.cwd() }) + "\n");
|
|
25337
|
+
const alive = (pid) => { try { process.kill(pid, 0); return true; } catch { return false; } };
|
|
25338
|
+
if (joined === "plugin list --json") {
|
|
25339
|
+
process.stdout.write(JSON.stringify([{ id: "keel@keel-marketplace", version: state.version,
|
|
25340
|
+
lastUpdated: state.lastUpdated }]));
|
|
25341
|
+
} else if (joined === "plugin update keel@keel-marketplace") {
|
|
25342
|
+
state.version = "5.1.0";
|
|
25343
|
+
save();
|
|
25344
|
+
} else if (joined === "agents --json") {
|
|
25345
|
+
process.stdout.write(JSON.stringify(state.rows));
|
|
25346
|
+
} else if (args[0] === "stop") {
|
|
25347
|
+
const row = state.rows.find((item) => item.id === args[1]);
|
|
25348
|
+
if (row) {
|
|
25349
|
+
setTimeout(() => { try { process.kill(row.pid, "SIGKILL"); } catch {} }, 300);
|
|
25350
|
+
delete row.status;
|
|
25351
|
+
save();
|
|
25352
|
+
}
|
|
25353
|
+
process.stdout.write(`stopped ${args[1]}\n`);
|
|
25354
|
+
setTimeout(() => process.exit(0), 400);
|
|
25355
|
+
return;
|
|
25356
|
+
} else if (args[0] === "--bg" && args[1] === "--resume") {
|
|
25357
|
+
const row = state.rows.find((item) => item.sessionId === args[2]);
|
|
25358
|
+
fs.appendFileSync(process.env.FAKE_LOG, JSON.stringify({ resumed: args[2], oldAlive: row ? alive(row.pid) : null }) + "\n");
|
|
25359
|
+
if (row) { row.status = "idle"; row.startedAt = Date.now(); save(); }
|
|
25360
|
+
process.stdout.write(`backgrounded · ${args[2].slice(0, 8)} · resumed\n`);
|
|
25361
|
+
}
|
|
25362
|
+
process.exit(0);
|
|
25363
|
+
"""
|
|
25364
|
+
|
|
25365
|
+
|
|
25366
|
+
def validate_update_adopts_idle_sessions_scenario() -> int:
|
|
25367
|
+
"""Issue #424: a release reaches the running background sessions on request.
|
|
25368
|
+
|
|
25369
|
+
Each Claude background session keeps the plugin it loaded. A hand-over starts
|
|
25370
|
+
a new process, so it adopts the update; a session that does not change shift
|
|
25371
|
+
stays on the old one. Measured on 2026-10-21 (Claude Code 2.1.304), stop and
|
|
25372
|
+
resume with no prompt restarts it on the installed plugin without a turn.
|
|
25373
|
+
`--adopt` does that for the idle sessions started before the update, and
|
|
25374
|
+
leaves busy, guarded, and its own session alone.
|
|
25375
|
+
"""
|
|
25376
|
+
label = "update-adopts-idle-sessions:"
|
|
25377
|
+
t0 = 1792540800000 # 2026-10-21T00:00:00Z, the update's lastUpdated
|
|
25378
|
+
with tempfile.TemporaryDirectory(prefix="keel-adopt-424-", ignore_cleanup_errors=True) as raw:
|
|
25379
|
+
tmp = Path(raw)
|
|
25380
|
+
fake = tmp / "fake-claude.js"
|
|
25381
|
+
write_text(fake, ADOPT_FAKE_CLAUDE)
|
|
25382
|
+
launcher = tmp / "fake-claude"
|
|
25383
|
+
write_text(launcher, f'#!/bin/sh\nexec node "{fake}" "$@"\n')
|
|
25384
|
+
launcher.chmod(0o755)
|
|
25385
|
+
npm_fake = tmp / "fake-npm.js"
|
|
25386
|
+
write_text(npm_fake, UPDATE_FAKE)
|
|
25387
|
+
npm = tmp / "fake-npm"
|
|
25388
|
+
write_text(npm, f'#!/bin/sh\nFAKE_HOST=npm exec node "{npm_fake}" "$@"\n')
|
|
25389
|
+
npm.chmod(0o755)
|
|
25390
|
+
guarded = tmp / "guarded"
|
|
25391
|
+
write_text(guarded / "keel" / "guard.json", "{}\n")
|
|
25392
|
+
sleepers: list[int] = []
|
|
25393
|
+
|
|
25394
|
+
def row(name: str, sid: str, status: str, started: int, cwd: Path) -> dict:
|
|
25395
|
+
# Not this process's child: a killed child stays a zombie until reaped,
|
|
25396
|
+
# and a zombie still answers kill(pid, 0), which a host process never does.
|
|
25397
|
+
pid = int(subprocess.run(["sh", "-c", "sleep 300 >/dev/null 2>&1 & echo $!"], text=True,
|
|
25398
|
+
capture_output=True, check=True).stdout.strip())
|
|
25399
|
+
sleepers.append(pid)
|
|
25400
|
+
return {"kind": "background", "name": name, "sessionId": sid, "id": sid[:8], "status": status,
|
|
25401
|
+
"state": "working", "pid": pid, "cwd": str(cwd), "startedAt": started}
|
|
25402
|
+
|
|
25403
|
+
def run(*extra: str) -> tuple[subprocess.CompletedProcess, list[dict]]:
|
|
25404
|
+
log = tmp / "log.jsonl"
|
|
25405
|
+
log.write_text("")
|
|
25406
|
+
rows = [
|
|
25407
|
+
row("lead · old idle", "aaaaaaaa-0000-0000-0000-000000000001", "idle", t0 - 3600000, tmp),
|
|
25408
|
+
row("verify · old busy", "bbbbbbbb-0000-0000-0000-000000000002", "busy", t0 - 3600000, tmp),
|
|
25409
|
+
row("rtl · old guarded", "cccccccc-0000-0000-0000-000000000003", "idle", t0 - 3600000, guarded),
|
|
25410
|
+
row("pm · fresh idle", "dddddddd-0000-0000-0000-000000000004", "idle", t0 + 3600000, tmp),
|
|
25411
|
+
row("maint · this session", "eeeeeeee-0000-0000-0000-000000000005", "busy", t0 - 3600000, tmp),
|
|
25412
|
+
]
|
|
25413
|
+
(tmp / "state.json").write_text(json.dumps({"version": "5.0.0", "lastUpdated": "2026-10-21T00:00:00.000Z", "rows": rows}))
|
|
25414
|
+
env = dict(os.environ)
|
|
25415
|
+
env.update({"KEEL_UPDATE_NPM": str(npm), "KEEL_UPDATE_CLAUDE": str(launcher),
|
|
25416
|
+
"KEEL_UPDATE_CODEX": str(tmp / "no-codex"), "FAKE_LOG": str(log),
|
|
25417
|
+
"FAKE_STATE": str(tmp / "state.json"), "CLAUDE_CODE_SESSION_ID": rows[4]["sessionId"]})
|
|
25418
|
+
env.pop("KEEL_UPDATE_SOURCE", None)
|
|
25419
|
+
result = subprocess.run(["node", str(ROOT / "bin/keel.js"), "--update", *extra], cwd=tmp, env=env,
|
|
25420
|
+
text=True, capture_output=True, check=False, timeout=90)
|
|
25421
|
+
# The npm fake logs arrays to the same file; the claude fake logs objects.
|
|
25422
|
+
entries = [json.loads(line) for line in log.read_text().splitlines() if line.strip()]
|
|
25423
|
+
return result, [entry for entry in entries if isinstance(entry, dict)]
|
|
25424
|
+
|
|
25425
|
+
try:
|
|
25426
|
+
adopted, calls = run("--adopt")
|
|
25427
|
+
stops = [c["args"][1] for c in calls if c.get("args", [None])[0] == "stop"]
|
|
25428
|
+
resumes = [c for c in calls if c.get("args", [None])[:2] == ["--bg", "--resume"]]
|
|
25429
|
+
witnessed = [c for c in calls if "resumed" in c]
|
|
25430
|
+
line = next((l for l in adopted.stdout.splitlines() if l.startswith("keel update: claude sessions:")), "")
|
|
25431
|
+
if adopted.returncode != 0:
|
|
25432
|
+
report(f"{label} keel --update --adopt exited {adopted.returncode}: {adopted.stdout!r} {adopted.stderr!r}")
|
|
25433
|
+
return 1
|
|
25434
|
+
if stops != ["aaaaaaaa"]:
|
|
25435
|
+
report(f"{label} --adopt stopped {stops!r}, not only the idle session started before the update.")
|
|
25436
|
+
return 1
|
|
25437
|
+
if len(resumes) != 1 or resumes[0]["args"] != ["--bg", "--resume", "aaaaaaaa-0000-0000-0000-000000000001"]:
|
|
25438
|
+
report(f"{label} --adopt did not resume the stopped session with exactly `--bg --resume <id>`: {resumes!r}")
|
|
25439
|
+
return 1
|
|
25440
|
+
if resumes[0]["cwd"] != os.path.realpath(tmp) and resumes[0]["cwd"] != str(tmp):
|
|
25441
|
+
report(f"{label} the resume ran in {resumes[0]['cwd']!r}, not the session's worktree {str(tmp)!r}.")
|
|
25442
|
+
return 1
|
|
25443
|
+
if not witnessed or witnessed[0]["oldAlive"]:
|
|
25444
|
+
report(f"{label} the resume ran while the stopped session's process was still alive: {witnessed!r}")
|
|
25445
|
+
return 1
|
|
25446
|
+
for needle in ("adopted", "lead · old idle", "verify · old busy", "rtl · old guarded"):
|
|
25447
|
+
if needle not in line:
|
|
25448
|
+
report(f"{label} the claude sessions line does not name {needle!r}: {line!r}")
|
|
25449
|
+
return 1
|
|
25450
|
+
for absent in ("pm · fresh idle", "maint · this session"):
|
|
25451
|
+
if absent in line:
|
|
25452
|
+
report(f"{label} the claude sessions line names {absent!r}, which is not on an older plugin or is this session: {line!r}")
|
|
25453
|
+
return 1
|
|
25454
|
+
|
|
25455
|
+
named, calls = run()
|
|
25456
|
+
line = next((l for l in named.stdout.splitlines() if l.startswith("keel update: claude sessions:")), "")
|
|
25457
|
+
if any(c.get("args", [None])[0] == "stop" or c.get("args", [None])[:2] == ["--bg", "--resume"] for c in calls):
|
|
25458
|
+
report(f"{label} keel --update without --adopt stopped or resumed a session: {calls!r}")
|
|
25459
|
+
return 1
|
|
25460
|
+
for needle in ("lead · old idle", "verify · old busy", "rtl · old guarded", "keel --update --adopt"):
|
|
25461
|
+
if needle not in line:
|
|
25462
|
+
report(f"{label} without --adopt the claude sessions line does not name {needle!r}: {line!r}")
|
|
25463
|
+
return 1
|
|
25464
|
+
finally:
|
|
25465
|
+
for pid in sleepers:
|
|
25466
|
+
try:
|
|
25467
|
+
os.kill(pid, signal.SIGKILL)
|
|
25468
|
+
except ProcessLookupError:
|
|
25469
|
+
pass
|
|
25470
|
+
refused = subprocess.run(["node", str(ROOT / "bin/keel.js"), "--adopt"], cwd=ROOT, text=True,
|
|
25471
|
+
capture_output=True, check=False)
|
|
25472
|
+
if refused.returncode != 2:
|
|
25473
|
+
report(f"{label} --adopt outside --update exited {refused.returncode}, not 2: {refused.stderr!r}")
|
|
25474
|
+
return 1
|
|
25475
|
+
if label.rstrip(":") not in {name for name, _ in SCENARIOS}:
|
|
25476
|
+
report(f"{label} the scenario registry does not include it.")
|
|
25477
|
+
return 1
|
|
25478
|
+
report(f"{label.rstrip(':')} scenario passed.")
|
|
25479
|
+
return 0
|
|
25480
|
+
|
|
25481
|
+
|
|
25326
25482
|
def validate_update_covers_installed_hosts_scenario() -> int:
|
|
25327
25483
|
"""Issue #204: one owner-run `keel --update` covers every installed component.
|
|
25328
25484
|
|
|
@@ -41773,6 +41929,7 @@ SCENARIOS: tuple = (
|
|
|
41773
41929
|
("update-host-query-timeout", validate_update_host_query_timeout_scenario),
|
|
41774
41930
|
("update-codex-from-disk", validate_update_codex_from_disk_scenario),
|
|
41775
41931
|
("update-registry-lag", validate_update_registry_lag_scenario),
|
|
41932
|
+
("update-adopts-idle-sessions", validate_update_adopts_idle_sessions_scenario),
|
|
41776
41933
|
("refresh-covers-every-target", validate_refresh_covers_every_target_scenario),
|
|
41777
41934
|
("directory-branch-advances", validate_directory_branch_advances_scenario),
|
|
41778
41935
|
("release-notes-name-the-directory-branch", validate_release_notes_name_the_directory_branch_scenario),
|