@christang/keel 5.146.0 → 5.147.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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keel",
3
- "version": "5.146.0",
3
+ "version": "5.147.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,4 +1,4 @@
1
- <!-- keel:start version=5.146.0 -->
1
+ <!-- keel:start version=5.147.0 -->
2
2
  ## Keel Bootstrap
3
3
 
4
4
  - Start every session with `keel context`; OpenSpec artifacts and Git are the only durable authority — never native memory, goals, or transcripts.
package/bin/keel.js CHANGED
@@ -1015,17 +1015,22 @@ function hostRun(executable, args) {
1015
1015
 
1016
1016
  // A read-only `plugin list --json` normally answers in 1–3 s, and once hung
1017
1017
  // for minutes through a proxy (#354). It gets its own short limit, and a query
1018
- // that fails is reported as one, never as a host with no Keel.
1018
+ // that fails is reported as one, never as a host with no Keel. A query that
1019
+ // times out is retried once: on the owner's link the same query took 58 s
1020
+ // once and about 1 s on the next runs (#365).
1019
1021
  function hostQuery(executable, args) {
1020
1022
  const limit = Number(process.env.KEEL_UPDATE_QUERY_TIMEOUT_MS) || 30 * 1000;
1021
- const result = spawnSync(executable, args, {
1023
+ const run = () => spawnSync(executable, args, {
1022
1024
  encoding: "utf8",
1023
1025
  shell: process.platform === "win32",
1024
1026
  timeout: limit,
1025
1027
  });
1028
+ const timedOut = (attempt) => attempt.error && attempt.error.code === "ETIMEDOUT";
1029
+ let result = run();
1030
+ if (timedOut(result)) result = run();
1026
1031
  if (result.error && result.error.code === "ENOENT") return { absent: true };
1027
- if (result.error && result.error.code === "ETIMEDOUT") {
1028
- return { failed: `timed out after ${limit / 1000} s` };
1032
+ if (timedOut(result)) {
1033
+ return { failed: `timed out twice, after ${limit / 1000} s each` };
1029
1034
  }
1030
1035
  if (result.error) return { failed: result.error.message };
1031
1036
  // On Windows the call goes through cmd.exe, which reports a missing command
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@christang/keel",
3
- "version": "5.146.0",
3
+ "version": "5.147.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@christang/keel",
9
- "version": "5.146.0",
9
+ "version": "5.147.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@fission-ai/openspec": "^1.4.1"
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@christang/keel",
3
3
  "displayName": "Keel",
4
4
  "description": "Keel OpenSpec execution discipline CLI for Claude Code, Codex, and OpenCode.",
5
- "version": "5.146.0",
5
+ "version": "5.147.0",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keel",
3
- "version": "5.146.0",
3
+ "version": "5.147.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.146.0",
3
+ "version": "5.147.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",
@@ -49,8 +49,8 @@ REQUIRED_SCRIPTS = [
49
49
  "scripts/validate_plugin.py",
50
50
  ]
51
51
 
52
- PACKAGE_VERSION = "5.146.0"
53
- PROTOCOL_VERSION = "5.146.0"
52
+ PACKAGE_VERSION = "5.147.0"
53
+ PROTOCOL_VERSION = "5.147.0"
54
54
  LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
55
55
  OPENSPEC_SCHEMA_NAME = "keel-spec-driven"
56
56
  # Mirrors KEEL_PACKAGE_NAME in scripts/install_to_repo.py, one of the two
@@ -23838,8 +23838,15 @@ const args = process.argv.slice(2);
23838
23838
  fs.appendFileSync(process.env.FAKE_LOG, JSON.stringify([host, ...args]) + "\n");
23839
23839
  // FAKE_LIST_SLEEP_<HOST> holds `plugin list --json` for N seconds, and
23840
23840
  // FAKE_LIST_EXIT_<HOST> makes it exit with that status (#354).
23841
+ // FAKE_LIST_SLEEP_TIMES_<HOST> holds only the first N such calls (#365); the
23842
+ // count is written before the hold, since a held call is killed.
23841
23843
  if (args.join(" ") === "plugin list --json") {
23842
- const hold = Number(process.env[`FAKE_LIST_SLEEP_${host.toUpperCase()}`] || "0");
23844
+ let hold = Number(process.env[`FAKE_LIST_SLEEP_${host.toUpperCase()}`] || "0");
23845
+ const times = Number(process.env[`FAKE_LIST_SLEEP_TIMES_${host.toUpperCase()}`] || "Infinity");
23846
+ const counter = `${process.env.FAKE_STATE}.held-${host}`;
23847
+ const held = fs.existsSync(counter) ? Number(fs.readFileSync(counter, "utf8")) : 0;
23848
+ if (held >= times) hold = 0;
23849
+ else if (hold > 0) fs.writeFileSync(counter, String(held + 1));
23843
23850
  if (hold > 0) Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, hold * 1000);
23844
23851
  const code = process.env[`FAKE_LIST_EXIT_${host.toUpperCase()}`];
23845
23852
  if (code) process.exit(Number(code));
@@ -24103,7 +24110,7 @@ def validate_update_host_query_timeout_scenario() -> int:
24103
24110
  if "absent" in codex:
24104
24111
  report(f"{label} a hung codex plugin list --json was reported absent: {codex!r}")
24105
24112
  return 1
24106
- for needle in ("failed", "codex plugin list --json", "timed out after 1.5 s"):
24113
+ for needle in ("failed", "codex plugin list --json", "1.5 s"):
24107
24114
  if needle not in codex:
24108
24115
  report(f"{label} the hung-query line does not name {needle!r}: {codex!r}")
24109
24116
  return 1
@@ -24224,6 +24231,77 @@ def validate_update_claude_refresh_retry_scenario() -> int:
24224
24231
  return 0
24225
24232
 
24226
24233
 
24234
+ def validate_update_host_query_retry_scenario() -> int:
24235
+ """Issue #365: `codex plugin list --json` usually answers in about 1 s and
24236
+ sometimes took 58 s through the owner's proxy.
24237
+
24238
+ A query that times out is retried once before the component reads
24239
+ `failed`, so one slow spell no longer leaves the plugin a release behind.
24240
+ """
24241
+ label = "update-host-query-retry:"
24242
+ listing = ["codex", "plugin", "list", "--json"]
24243
+ with tempfile.TemporaryDirectory(prefix="keel-update-365-", ignore_cleanup_errors=True) as raw:
24244
+ tmp = Path(raw)
24245
+ fake = tmp / "fake.js"
24246
+ write_text(fake, UPDATE_FAKE)
24247
+ launchers = {}
24248
+ for host in ("npm", "claude", "codex"):
24249
+ launcher = tmp / f"fake-{host}"
24250
+ write_text(launcher, f'#!/bin/sh\nFAKE_HOST={host} exec node "{fake}" "$@"\n')
24251
+ launcher.chmod(0o755)
24252
+ launchers[host] = launcher
24253
+ source = tmp / "codex-source"
24254
+ write_text(source / "hooks/codex.json", "{}\n")
24255
+
24256
+ def update(times: str):
24257
+ log, state = tmp / "log.jsonl", tmp / "state.json"
24258
+ for stale in (log, state, tmp / "state.json.held-codex"):
24259
+ if stale.exists():
24260
+ stale.unlink()
24261
+ log.write_text("")
24262
+ env = dict(os.environ)
24263
+ env.update({
24264
+ "KEEL_UPDATE_NPM": str(launchers["npm"]), "KEEL_UPDATE_CLAUDE": str(launchers["claude"]),
24265
+ "KEEL_UPDATE_CODEX": str(launchers["codex"]), "KEEL_UPDATE_QUERY_TIMEOUT_MS": "4000",
24266
+ "CODEX_HOME": str(tmp / "codex-home"), "FAKE_LOG": str(log), "FAKE_STATE": str(state),
24267
+ "FAKE_CODEX_SOURCE": str(source),
24268
+ "FAKE_LIST_SLEEP_CODEX": "15", "FAKE_LIST_SLEEP_TIMES_CODEX": times,
24269
+ })
24270
+ env.pop("KEEL_UPDATE_SOURCE", None)
24271
+ started = time.monotonic()
24272
+ result = subprocess.run(["node", str(ROOT / "bin/keel.js"), "--update"], cwd=tmp, env=env,
24273
+ text=True, capture_output=True, check=False, timeout=120)
24274
+ calls = [json.loads(line) for line in log.read_text().splitlines() if line.strip()]
24275
+ line = next((l for l in result.stdout.splitlines() if l.startswith("keel update: codex plugin:")), "")
24276
+ return result, calls, line, time.monotonic() - started
24277
+
24278
+ result, calls, line, _ = update("1")
24279
+ if "5.0.0 -> 5.1.0" not in line:
24280
+ report(f"{label} a query that timed out once did not go on to update the Codex plugin: {line!r}")
24281
+ return 1
24282
+ if result.returncode != 0:
24283
+ report(f"{label} a query that answered on retry left keel --update exiting {result.returncode}: {result.stdout!r}")
24284
+ return 1
24285
+
24286
+ result, calls, line, took = update("9")
24287
+ for needle in ("failed", "codex plugin list --json", "timed out twice", "4 s"):
24288
+ if needle not in line:
24289
+ report(f"{label} a lasting hang's line does not name {needle!r}: {line!r}")
24290
+ return 1
24291
+ runs = sum(1 for c in calls if c[:4] == listing)
24292
+ if runs != 2:
24293
+ report(f"{label} a lasting hang ran the query {runs} time(s), not 2: {calls!r}")
24294
+ return 1
24295
+ if took > 25:
24296
+ report(f"{label} two 4 s attempts held keel --update for {took:.1f} s.")
24297
+ return 1
24298
+ if "update-host-query-retry" not in {name for name, _ in SCENARIOS}:
24299
+ report(f"{label} scenario is not registered.")
24300
+ return 1
24301
+ report("update-host-query-retry scenario passed.")
24302
+ return 0
24303
+
24304
+
24227
24305
  def validate_update_codex_refresh_retry_scenario() -> int:
24228
24306
  """Issue #329: a slow link can cut Codex's whole-repository marketplace clone.
24229
24307
 
@@ -41602,6 +41680,7 @@ SCENARIOS: tuple = (
41602
41680
  ("adopted-update-is-silent-unless-reload", validate_adopted_update_is_silent_unless_reload_scenario),
41603
41681
  ("update-covers-installed-hosts", validate_update_covers_installed_hosts_scenario),
41604
41682
  ("update-codex-refresh-retry", validate_update_codex_refresh_retry_scenario),
41683
+ ("update-host-query-retry", validate_update_host_query_retry_scenario),
41605
41684
  ("update-claude-refresh-retry", validate_update_claude_refresh_retry_scenario),
41606
41685
  ("update-host-query-timeout", validate_update_host_query_timeout_scenario),
41607
41686
  ("refresh-covers-every-target", validate_refresh_covers_every_target_scenario),