@christang/keel 5.199.0 → 5.200.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/assets/bootstrap/AGENTS.md +1 -1
- 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/fake_slack.py +13 -0
- package/scripts/validation/chat.py +70 -0
- package/scripts/validation/common.py +2 -2
- package/scripts/validation/registry.py +4 -0
- package/src/core/chat/bridge.js +33 -5
- package/src/core/chat/slack.js +9 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.200.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/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@christang/keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.200.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.200.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.200.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.200.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/scripts/fake_slack.py
CHANGED
|
@@ -64,6 +64,9 @@ class FakeSlack:
|
|
|
64
64
|
# (token, channel) pairs `chat.postMessage` answers with
|
|
65
65
|
# `not_in_channel`, for a bot nobody invited.
|
|
66
66
|
self.not_in_channel: set[tuple[str, str]] = set()
|
|
67
|
+
# Methods answered with a chosen error body until cleared, such as a
|
|
68
|
+
# `missing_scope` with its `needed` field.
|
|
69
|
+
self.failing: dict[str, dict] = {}
|
|
67
70
|
# Which app token each Socket Mode connection was opened with.
|
|
68
71
|
self.socket_apps: dict[socket.socket, str] = {}
|
|
69
72
|
self.pending_apps: dict[str, str] = {}
|
|
@@ -93,6 +96,14 @@ class FakeSlack:
|
|
|
93
96
|
with self.lock:
|
|
94
97
|
self.rate_limit_next.append((method, retry_after))
|
|
95
98
|
|
|
99
|
+
def fail(self, method: str, body: dict | None) -> None:
|
|
100
|
+
"""Answer every call of `method` with `body` (HTTP 200), or normally again when `body` is None."""
|
|
101
|
+
with self.lock:
|
|
102
|
+
if body is None:
|
|
103
|
+
self.failing.pop(method, None)
|
|
104
|
+
else:
|
|
105
|
+
self.failing[method] = body
|
|
106
|
+
|
|
96
107
|
def calls_to(self, method: str) -> list[dict]:
|
|
97
108
|
with self.lock:
|
|
98
109
|
return [call for call in self.calls if call["method"] == method and not call.get("rate_limited")]
|
|
@@ -168,6 +179,8 @@ class FakeSlack:
|
|
|
168
179
|
self.calls.append({"method": method, "params": params, "rate_limited": True, "at": time.time()})
|
|
169
180
|
return 429, {"Retry-After": str(retry_after)}, {"ok": False, "error": "ratelimited"}
|
|
170
181
|
self.calls.append({"method": method, "params": params, "at": time.time()})
|
|
182
|
+
if method in self.failing:
|
|
183
|
+
return 200, {}, dict(self.failing[method])
|
|
171
184
|
token = str(params.get("_auth", "")).removeprefix("Bearer ")
|
|
172
185
|
identity = self.identities.get(token, {"user_id": "UBOT", "bot_id": "BBOT"})
|
|
173
186
|
if method == "auth.test":
|
|
@@ -2989,6 +2989,76 @@ def validate_chat_bridge_lifecycle_scenario() -> int:
|
|
|
2989
2989
|
return 0
|
|
2990
2990
|
|
|
2991
2991
|
|
|
2992
|
+
def validate_chat_bridge_logs_once_scenario() -> int:
|
|
2993
|
+
"""Issue #460: a failure that never changes is logged once, and a missing scope is named.
|
|
2994
|
+
|
|
2995
|
+
On 2026-10-25 the bridge log held 2944 copies of one project's
|
|
2996
|
+
`this repository has no remote` (one per archive sync) and 278 of
|
|
2997
|
+
`catch-up failed: … missing_scope` (one per reconnect), and none named
|
|
2998
|
+
the scope Slack said was missing. A running bridge now logs each repeating
|
|
2999
|
+
failure once, a recovery once, and names Slack's `needed` scopes.
|
|
3000
|
+
"""
|
|
3001
|
+
label = "chat-bridge-logs-once:"
|
|
3002
|
+
if chat_bridge_node_missing("chat-bridge-logs-once"):
|
|
3003
|
+
return 3
|
|
3004
|
+
FakeSlack = fake_slack_class()
|
|
3005
|
+
with tempfile.TemporaryDirectory(prefix="keel-chat-460-") as raw, FakeSlack() as slack:
|
|
3006
|
+
base = Path(raw)
|
|
3007
|
+
rtl, _, env = chat_scratch_group(base)
|
|
3008
|
+
chat_slack_config(rtl, {"soc": "CSOC"})
|
|
3009
|
+
benv = {**chat_bridge_environment(env, base / "home", slack), "KEEL_CHAT_ARCHIVE_EVERY_MS": "300"}
|
|
3010
|
+
run_keel(rtl, "chat", "bridge", "add", env=benv)
|
|
3011
|
+
slack.fail("conversations.history", {"ok": False, "error": "missing_scope", "needed": "channels:history", "provided": "chat:write"})
|
|
3012
|
+
|
|
3013
|
+
def history_calls() -> int:
|
|
3014
|
+
return len(slack.calls_to("conversations.history"))
|
|
3015
|
+
|
|
3016
|
+
bridge = start_chat_bridge(rtl, benv)
|
|
3017
|
+
stderr = ""
|
|
3018
|
+
try:
|
|
3019
|
+
if not slack.wait_for(lambda: slack.sockets and history_calls() >= 1, 10):
|
|
3020
|
+
report(f"{label} the bridge never connected and caught up: {stop_chat_bridge(bridge).strip()}")
|
|
3021
|
+
return 1
|
|
3022
|
+
# Each reconnect is a new `hello` and so a new catch-up, which fails the same way.
|
|
3023
|
+
for _ in range(3):
|
|
3024
|
+
calls = history_calls()
|
|
3025
|
+
slack.drop_connections()
|
|
3026
|
+
if not slack.wait_for(lambda: history_calls() > calls, 15):
|
|
3027
|
+
report(f"{label} the bridge did not catch up again after a reconnect: {stop_chat_bridge(bridge).strip()}")
|
|
3028
|
+
return 1
|
|
3029
|
+
slack.fail("conversations.history", None)
|
|
3030
|
+
calls = history_calls()
|
|
3031
|
+
slack.drop_connections()
|
|
3032
|
+
# The reconnect backoff doubles while sessions stay short: 2, 4, 8, then 16 s.
|
|
3033
|
+
if not slack.wait_for(lambda: history_calls() > calls and slack.sockets, 30):
|
|
3034
|
+
report(f"{label} the bridge did not catch up after the scope was granted: {stop_chat_bridge(bridge).strip()}")
|
|
3035
|
+
return 1
|
|
3036
|
+
time.sleep(2)
|
|
3037
|
+
finally:
|
|
3038
|
+
stderr = stop_chat_bridge(bridge)
|
|
3039
|
+
lines = stderr.splitlines()
|
|
3040
|
+
refusals = [line for line in lines if "this repository has no remote" in line]
|
|
3041
|
+
if len(refusals) != 1:
|
|
3042
|
+
report(f"{label} the archive refusal was logged {len(refusals)} times over syncs every 300 ms, not once: {stderr!r}")
|
|
3043
|
+
return 1
|
|
3044
|
+
failed = [line for line in lines if "catch-up failed" in line]
|
|
3045
|
+
if len(failed) != 1:
|
|
3046
|
+
report(f"{label} the same catch-up failure was logged {len(failed)} times over four connects, not once: {stderr!r}")
|
|
3047
|
+
return 1
|
|
3048
|
+
if "missing_scope: needs channels:history" not in failed[0]:
|
|
3049
|
+
report(f"{label} the catch-up failure does not name the missing scope: {failed[0]!r}")
|
|
3050
|
+
return 1
|
|
3051
|
+
recovered = [line for line in lines if "catch-up works again" in line]
|
|
3052
|
+
if len(recovered) != 1:
|
|
3053
|
+
report(f"{label} the catch-up's recovery was logged {len(recovered)} times, not once: {stderr!r}")
|
|
3054
|
+
return 1
|
|
3055
|
+
if "chat-bridge-logs-once" not in {name for name, _ in registry.SCENARIOS}:
|
|
3056
|
+
report(f"{label} scenario is not registered.")
|
|
3057
|
+
return 1
|
|
3058
|
+
report("chat-bridge-logs-once scenario passed.")
|
|
3059
|
+
return 0
|
|
3060
|
+
|
|
3061
|
+
|
|
2992
3062
|
def validate_chat_bridge_start_race_scenario() -> int:
|
|
2993
3063
|
"""Issue #226: start, stop, install, and status follow launchd's state.
|
|
2994
3064
|
|
|
@@ -35,10 +35,10 @@ os.environ["KEEL_UPDATE_CLAUDE"] = str(Path(tempfile.gettempdir()) / "keel-suite
|
|
|
35
35
|
os.environ["KEEL_UPDATE_CODEX"] = str(Path(tempfile.gettempdir()) / "keel-suite-has-no-codex")
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
PACKAGE_VERSION = "5.
|
|
38
|
+
PACKAGE_VERSION = "5.200.0"
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
PROTOCOL_VERSION = "5.
|
|
41
|
+
PROTOCOL_VERSION = "5.200.0"
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
|
|
@@ -101,6 +101,10 @@ SCENARIOS: tuple = (
|
|
|
101
101
|
"chat-bridge-start-race",
|
|
102
102
|
chat.validate_chat_bridge_start_race_scenario,
|
|
103
103
|
),
|
|
104
|
+
(
|
|
105
|
+
"chat-bridge-logs-once",
|
|
106
|
+
chat.validate_chat_bridge_logs_once_scenario,
|
|
107
|
+
),
|
|
104
108
|
(
|
|
105
109
|
"chat-owner-mention",
|
|
106
110
|
chat.validate_chat_owner_mention_scenario,
|
package/src/core/chat/bridge.js
CHANGED
|
@@ -892,6 +892,25 @@ function githubRepo(worktree) {
|
|
|
892
892
|
return result.status === 0 && match ? match[1] : null;
|
|
893
893
|
}
|
|
894
894
|
|
|
895
|
+
// A failure that repeats unchanged — an archive refusal at every sync, a
|
|
896
|
+
// catch-up failure at every reconnect — is logged once, again only when its
|
|
897
|
+
// line changes, and once more when it clears (#460 D1).
|
|
898
|
+
function onceLog(log) {
|
|
899
|
+
const last = new Map();
|
|
900
|
+
return {
|
|
901
|
+
failed(key, line) {
|
|
902
|
+
if (last.get(key) === line) return;
|
|
903
|
+
last.set(key, line);
|
|
904
|
+
log(line);
|
|
905
|
+
},
|
|
906
|
+
cleared(key, line) {
|
|
907
|
+
if (!last.has(key)) return;
|
|
908
|
+
last.delete(key);
|
|
909
|
+
log(line);
|
|
910
|
+
},
|
|
911
|
+
};
|
|
912
|
+
}
|
|
913
|
+
|
|
895
914
|
async function createContext(log, { needApp }) {
|
|
896
915
|
requireWebSocket();
|
|
897
916
|
const { bot, app } = lifecycle.tokens();
|
|
@@ -899,6 +918,7 @@ async function createContext(log, { needApp }) {
|
|
|
899
918
|
if (!bot) throw lifecycle.missingTokens("bot token");
|
|
900
919
|
const ctx = {
|
|
901
920
|
log,
|
|
921
|
+
once: onceLog(log),
|
|
902
922
|
token: bot,
|
|
903
923
|
appToken: app,
|
|
904
924
|
projects: prepareProjects(),
|
|
@@ -963,7 +983,11 @@ function socketSession(ctx, conn) {
|
|
|
963
983
|
if (data.type === "hello") {
|
|
964
984
|
conn.connected = true;
|
|
965
985
|
writeStatus(ctx);
|
|
966
|
-
|
|
986
|
+
const key = `catch-up:${conn.role || ""}`;
|
|
987
|
+
const whose = conn.role ? ` for ${conn.role}'s app` : "";
|
|
988
|
+
ctx.queue = ctx.queue.then(() => conn.onHello())
|
|
989
|
+
.then(() => { ctx.once.cleared(key, `catch-up works again${whose}.`); writeStatus(ctx); })
|
|
990
|
+
.catch((error) => ctx.once.failed(key, `catch-up failed${whose}: ${error.message}`));
|
|
967
991
|
return;
|
|
968
992
|
}
|
|
969
993
|
if (data.type === "disconnect") {
|
|
@@ -1065,20 +1089,24 @@ async function run(log) {
|
|
|
1065
1089
|
return stopped;
|
|
1066
1090
|
};
|
|
1067
1091
|
// Every ten minutes while connected, each project with archiving on is
|
|
1068
|
-
// synced to its keel-chat branch (D19).
|
|
1092
|
+
// synced to its keel-chat branch (D19). A refusal that never changes, such as
|
|
1093
|
+
// a repository with no remote, is logged once (#460 D1).
|
|
1094
|
+
const archiveEvery = /^\d+$/.test(process.env.KEEL_CHAT_ARCHIVE_EVERY_MS || "") ? Number(process.env.KEEL_CHAT_ARCHIVE_EVERY_MS) : 10 * 60 * 1000;
|
|
1069
1095
|
const archiveTimer = setInterval(() => {
|
|
1070
1096
|
if (!ctx.connected || ctx.stopping) return;
|
|
1071
1097
|
const archive = require("./archive");
|
|
1072
1098
|
for (const project of ctx.projects) {
|
|
1073
1099
|
if (!archive.archiveSettings(project.where.worktree).automatic) continue;
|
|
1100
|
+
const key = `archive:${project.where.project}`;
|
|
1074
1101
|
try {
|
|
1075
1102
|
const result = archive.sync(project.where);
|
|
1076
|
-
if (result.refused)
|
|
1103
|
+
if (result.refused) ctx.once.failed(key, `${project.where.project}: ${result.refused}`);
|
|
1104
|
+
else ctx.once.cleared(key, `${project.where.project}: archive sync works again.`);
|
|
1077
1105
|
} catch (error) {
|
|
1078
|
-
|
|
1106
|
+
ctx.once.failed(key, `${project.where.project}: archive sync failed: ${error.message}`);
|
|
1079
1107
|
}
|
|
1080
1108
|
}
|
|
1081
|
-
},
|
|
1109
|
+
}, archiveEvery);
|
|
1082
1110
|
archiveTimer.unref();
|
|
1083
1111
|
// Each second: honor a pause, notice a Keel upgrade, and send what is new.
|
|
1084
1112
|
const timer = setInterval(() => {
|
package/src/core/chat/slack.js
CHANGED
|
@@ -16,13 +16,17 @@ const FORM_METHODS = new Set([
|
|
|
16
16
|
"conversations.replies",
|
|
17
17
|
]);
|
|
18
18
|
|
|
19
|
+
// Slack names the scopes a `missing_scope` call needed and those the token
|
|
20
|
+
// has; the message names the needed ones, which is what the fix takes (#460 D2).
|
|
19
21
|
class SlackError extends Error {
|
|
20
|
-
constructor(method, error, { retryAfter = null, status = null } = {}) {
|
|
21
|
-
super(`Slack ${method} failed: ${error}${status ? ` (HTTP ${status})` : ""}`);
|
|
22
|
+
constructor(method, error, { retryAfter = null, status = null, needed = null, provided = null } = {}) {
|
|
23
|
+
super(`Slack ${method} failed: ${error}${needed ? `: needs ${needed}` : ""}${status ? ` (HTTP ${status})` : ""}`);
|
|
22
24
|
this.method = method;
|
|
23
25
|
this.error = error;
|
|
24
26
|
this.retryAfter = retryAfter;
|
|
25
27
|
this.status = status;
|
|
28
|
+
this.needed = needed;
|
|
29
|
+
this.provided = provided;
|
|
26
30
|
}
|
|
27
31
|
}
|
|
28
32
|
|
|
@@ -69,7 +73,9 @@ async function call(method, params, token) {
|
|
|
69
73
|
throw new SlackError(method, "response was not JSON", { status: response.status });
|
|
70
74
|
}
|
|
71
75
|
if (!parsed || parsed.ok !== true) {
|
|
72
|
-
throw new SlackError(method, (parsed && parsed.error) || "unknown_error", {
|
|
76
|
+
throw new SlackError(method, (parsed && parsed.error) || "unknown_error", {
|
|
77
|
+
status: response.status, needed: (parsed && parsed.needed) || null, provided: (parsed && parsed.provided) || null,
|
|
78
|
+
});
|
|
73
79
|
}
|
|
74
80
|
return parsed;
|
|
75
81
|
}
|