@christang/keel 5.85.0 → 5.87.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/README.md +31 -7
- package/README.zh-CN.md +13 -0
- package/assets/bootstrap/AGENTS.md +2 -2
- package/assets/openspec/schemas/keel-spec-driven/schema.yaml +3 -3
- package/assets/openspec/schemas/keel-spec-driven/templates/tasks.md +3 -3
- package/bin/keel.js +55 -7
- 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/plugins/keel/agents/keel-single-task-goal-claude.md +1 -1
- package/plugins/keel/agents/keel-single-task-goal-codex.md +1 -1
- package/plugins/keel/skills/keel-run-single-task-goal/SKILL.md +2 -2
- package/plugins/keel/skills/keel-run-single-task-goal/guidance.md +1 -1
- package/scripts/validate_plugin.py +785 -19
- package/src/core/capabilities.js +2 -2
- package/src/core/chat/cli.js +77 -7
- package/src/core/chat/notice.js +37 -0
- package/src/core/chat/slack.js +4 -1
- package/src/core/chat/store.js +6 -1
- package/src/core/chat/view.js +5 -1
- package/src/core/chat/wake.js +386 -0
- package/src/core/config.js +36 -10
- package/src/core/projection.js +43 -24
- package/src/core/task-contract.js +3 -3
package/src/core/config.js
CHANGED
|
@@ -18,6 +18,9 @@ const STANDING_AUTHORIZATION_ACTIONS = [
|
|
|
18
18
|
// older than the running Keel (#164). It acts on this checkout, so it takes
|
|
19
19
|
// no scope, and it never covers committing what the refresh wrote.
|
|
20
20
|
"protocol-refresh",
|
|
21
|
+
// Answering, in the named chat group, a record addressed to the session's
|
|
22
|
+
// role (#195). Scoped: in a Slack-enabled group a reply leaves the machine.
|
|
23
|
+
"chat-reply",
|
|
21
24
|
];
|
|
22
25
|
|
|
23
26
|
// The actions whose credential reaches further than the checkout the
|
|
@@ -27,7 +30,7 @@ const STANDING_AUTHORIZATION_ACTIONS = [
|
|
|
27
30
|
// actions are declared with the resource they may reach and refused bare —
|
|
28
31
|
// accepting the bare form as a convenience would make the narrow form optional
|
|
29
32
|
// and the wide one the default, which is the decision inverted.
|
|
30
|
-
const SCOPED_AUTHORIZATION_ACTIONS = new Set(["issue"]);
|
|
33
|
+
const SCOPED_AUTHORIZATION_ACTIONS = new Set(["issue", "chat-reply"]);
|
|
31
34
|
|
|
32
35
|
// `<owner>/<repo>`: two non-empty segments and nothing else. The shape is
|
|
33
36
|
// checked and the existence is not, for the reason `triage` never fetches an
|
|
@@ -35,12 +38,19 @@ const SCOPED_AUTHORIZATION_ACTIONS = new Set(["issue"]);
|
|
|
35
38
|
// deterministic evaluation its verdict rests on.
|
|
36
39
|
const AUTHORIZATION_SCOPE_PATTERN = /^[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+$/;
|
|
37
40
|
|
|
41
|
+
// Each scoped action's form and shape. `chat-reply` names a chat group, whose
|
|
42
|
+
// names follow the chat's own pattern (src/core/chat/store.js).
|
|
43
|
+
const AUTHORIZATION_SCOPES = {
|
|
44
|
+
issue: { form: "<owner>/<repo>", pattern: AUTHORIZATION_SCOPE_PATTERN },
|
|
45
|
+
"chat-reply": { form: "<group>", pattern: /^[a-z0-9][a-z0-9-]{0,31}$/ },
|
|
46
|
+
};
|
|
47
|
+
|
|
38
48
|
// How the accepted names are spelled back to an author: the scoped ones carry
|
|
39
49
|
// their form, so the list is copyable rather than a name the next message
|
|
40
50
|
// refuses.
|
|
41
51
|
const STANDING_AUTHORIZATION_ACCEPTED_FORMS = STANDING_AUTHORIZATION_ACTIONS.map(
|
|
42
52
|
(action) =>
|
|
43
|
-
SCOPED_AUTHORIZATION_ACTIONS.has(action) ? `${action}
|
|
53
|
+
SCOPED_AUTHORIZATION_ACTIONS.has(action) ? `${action}:${AUTHORIZATION_SCOPES[action].form}` : action
|
|
44
54
|
);
|
|
45
55
|
|
|
46
56
|
// One declared entry, split into the action and the resource it names. Returns
|
|
@@ -58,7 +68,7 @@ function classifyAuthorizationEntry(entry) {
|
|
|
58
68
|
return { ok: true, entry, action, scope: null };
|
|
59
69
|
}
|
|
60
70
|
if (scope === null) return { ok: false, entry, action, reason: "missing-scope" };
|
|
61
|
-
if (!
|
|
71
|
+
if (!AUTHORIZATION_SCOPES[action].pattern.test(scope)) {
|
|
62
72
|
return { ok: false, entry, action, reason: "malformed-scope" };
|
|
63
73
|
}
|
|
64
74
|
return { ok: true, entry, action, scope };
|
|
@@ -246,7 +256,18 @@ function standingAuthorizationUnknownMessage(unknown, problems = []) {
|
|
|
246
256
|
// names are ... issue" beside "unrecognized action: issue" would contradict
|
|
247
257
|
// itself. Name what is missing instead, and why this one name carries it.
|
|
248
258
|
for (const problem of problems) {
|
|
249
|
-
if (problem.reason === "missing-scope") {
|
|
259
|
+
if (problem.reason === "missing-scope" && problem.action === "chat-reply") {
|
|
260
|
+
notes.push(
|
|
261
|
+
"`chat-reply` names no chat group; write it as `chat-reply:<group>`, "
|
|
262
|
+
+ "one entry per group. In a Slack-enabled group a reply leaves the "
|
|
263
|
+
+ "machine, so each group whose replies may go out is named."
|
|
264
|
+
);
|
|
265
|
+
} else if (problem.reason === "malformed-scope" && problem.action === "chat-reply") {
|
|
266
|
+
notes.push(
|
|
267
|
+
`\`${problem.entry}\` does not name a chat group as \`<group>\` — `
|
|
268
|
+
+ "lowercase letters, digits, and hyphens, starting with a letter or digit."
|
|
269
|
+
);
|
|
270
|
+
} else if (problem.reason === "missing-scope") {
|
|
250
271
|
notes.push(
|
|
251
272
|
`\`${problem.action}\` names no repository; write it as `
|
|
252
273
|
+ `\`${problem.action}:<owner>/<repo>\`. The credentials that open an `
|
|
@@ -277,11 +298,17 @@ function readStandingAuthorization(repo) {
|
|
|
277
298
|
// Additive: `declared` stays the entries as written, so the capsule's
|
|
278
299
|
// inherited autonomy line reads back what the file says.
|
|
279
300
|
const scopes = new Map();
|
|
301
|
+
// `chat-reply` may be declared once per group, so its scopes are kept as a
|
|
302
|
+
// list, and `scopes` carries them joined for the surfaces that print one.
|
|
303
|
+
const chatReplyGroups = [];
|
|
280
304
|
for (const entry of configList(repo, "authorize")) {
|
|
281
305
|
const classified = classifyAuthorizationEntry(entry);
|
|
282
306
|
if (classified.ok) {
|
|
283
307
|
declared.push(entry);
|
|
284
|
-
scopes.set(classified.action, classified.scope);
|
|
308
|
+
if (!scopes.has(classified.action)) scopes.set(classified.action, classified.scope);
|
|
309
|
+
if (classified.action === "chat-reply" && !chatReplyGroups.includes(classified.scope)) {
|
|
310
|
+
chatReplyGroups.push(classified.scope);
|
|
311
|
+
}
|
|
285
312
|
continue;
|
|
286
313
|
}
|
|
287
314
|
unknown.push(entry);
|
|
@@ -294,11 +321,13 @@ function readStandingAuthorization(repo) {
|
|
|
294
321
|
return {
|
|
295
322
|
declared: [],
|
|
296
323
|
scopes: new Map(),
|
|
324
|
+
chatReplyGroups: [],
|
|
297
325
|
unknown,
|
|
298
326
|
message: standingAuthorizationUnknownMessage(unknown, problems),
|
|
299
327
|
};
|
|
300
328
|
}
|
|
301
|
-
|
|
329
|
+
if (chatReplyGroups.length) scopes.set("chat-reply", chatReplyGroups.join(", "));
|
|
330
|
+
return { declared, scopes, chatReplyGroups, unknown, message: null };
|
|
302
331
|
}
|
|
303
332
|
|
|
304
333
|
// `full_mode_paths:` — the paths whose change always routes Full, whatever the
|
|
@@ -386,10 +415,7 @@ function configMap(repo, key) {
|
|
|
386
415
|
return entries;
|
|
387
416
|
}
|
|
388
417
|
|
|
389
|
-
//
|
|
390
|
-
// there is no separate on/off entry, because a tier with no permission and a
|
|
391
|
-
// permission with no tier are both incomplete, and one field cannot disagree
|
|
392
|
-
// with itself. An absent declaration delegates nothing, which is the default.
|
|
418
|
+
// Optional capability metadata; absence does not forbid model-chosen delegation.
|
|
393
419
|
function readDelegationPolicy(repo) {
|
|
394
420
|
const block = configMap(repo, "delegation");
|
|
395
421
|
const tier = block.tier;
|
package/src/core/projection.js
CHANGED
|
@@ -2,13 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
// Keel 4.1.0 one-way native projection contract.
|
|
4
4
|
|
|
5
|
-
const fs = require("fs");
|
|
6
|
-
const path = require("path");
|
|
7
|
-
|
|
8
5
|
const { readDelegationPolicy } = require("./config");
|
|
9
6
|
const { resolveContext } = require("./context");
|
|
10
7
|
const { loadTaskContract } = require("./task-contract");
|
|
11
8
|
const { probeCapabilities } = require("./capabilities");
|
|
9
|
+
const { guardStatus } = require("./guard");
|
|
12
10
|
|
|
13
11
|
const EVENTS = new Set([
|
|
14
12
|
"startup",
|
|
@@ -43,31 +41,44 @@ function blocked(target, event, reason, warnings = []) {
|
|
|
43
41
|
// that wrote successfully under one proves nothing about having been checked —
|
|
44
42
|
// there is no observable difference afterwards, which is why the condition has
|
|
45
43
|
// to be answered here.
|
|
46
|
-
function delegationRefusal(repo,
|
|
44
|
+
function delegationRefusal(repo, capsule, change, taskId, fingerprint) {
|
|
47
45
|
// The policy is read directly rather than through the capsule, because the
|
|
48
46
|
// capsule cannot express the difference this refusal turns on. A tier outside
|
|
49
47
|
// the vocabulary fails closed at the config layer and reaches the capsule as
|
|
50
48
|
// no delegation at all — identical to a repository that declared nothing. One
|
|
51
49
|
// of those should proceed silently and the other must be reported, so the
|
|
52
50
|
// unresolved declaration has to be seen where it still exists.
|
|
53
|
-
const { unknown, accepted } = readDelegationPolicy(repo);
|
|
51
|
+
const { unknown: configuredUnknown, accepted } = readDelegationPolicy(repo);
|
|
52
|
+
const declaredTier = capsule.delegation?.tier;
|
|
53
|
+
const unknown = declaredTier
|
|
54
|
+
? (accepted.includes(declaredTier) ? [] : [declaredTier])
|
|
55
|
+
: configuredUnknown;
|
|
54
56
|
if (unknown.length > 0) {
|
|
55
57
|
return (
|
|
56
|
-
`Delegation declares tier "${unknown.join(", ")}"
|
|
57
|
-
+ `
|
|
58
|
+
`Delegation declares invalid tier metadata "${unknown.join(", ")}". `
|
|
59
|
+
+ `Accepted: ${accepted.join(", ")}. Keel refuses `
|
|
58
60
|
+ "rather than substituting a tier, because work would otherwise run at "
|
|
59
61
|
+ "a capability nobody declared while reporting success."
|
|
60
62
|
);
|
|
61
63
|
}
|
|
62
|
-
if (
|
|
63
|
-
|
|
64
|
+
if (capsule.mode !== "implementation" || capsule.touch.length === 0
|
|
65
|
+
|| capsule.touch.includes("none")) {
|
|
66
|
+
return "Implementation delegation requires an implementation task with a Touch write boundary.";
|
|
67
|
+
}
|
|
68
|
+
const guard = guardStatus(repo);
|
|
69
|
+
if (guard.status !== "active") {
|
|
64
70
|
return (
|
|
65
|
-
|
|
66
|
-
+
|
|
67
|
-
+ "
|
|
68
|
-
+ "for the selected task, then delegate."
|
|
71
|
+
`Delegation requires an active write guard; status is ${guard.status}. `
|
|
72
|
+
+ guard.problems.map((item) => item.message).join(" ")
|
|
73
|
+
+ " Run `keel gate task-start` for the selected task, then delegate."
|
|
69
74
|
);
|
|
70
75
|
}
|
|
76
|
+
const manifest = guard.manifest;
|
|
77
|
+
if (manifest.change !== change || manifest.task !== taskId
|
|
78
|
+
|| manifest.fingerprint.value !== fingerprint.value
|
|
79
|
+
|| JSON.stringify([...manifest.touch].sort()) !== JSON.stringify([...capsule.touch].sort())) {
|
|
80
|
+
return "Delegation requires a guard matching the selected task, fingerprint and Touch boundary.";
|
|
81
|
+
}
|
|
71
82
|
return null;
|
|
72
83
|
}
|
|
73
84
|
|
|
@@ -149,9 +160,7 @@ function projectRuntime(repo, options) {
|
|
|
149
160
|
? "goal"
|
|
150
161
|
: event === "task-view"
|
|
151
162
|
? "task-view"
|
|
152
|
-
:
|
|
153
|
-
? "subagent"
|
|
154
|
-
: null;
|
|
163
|
+
: null;
|
|
155
164
|
if (requiredAuthorization && !authorization.has(requiredAuthorization)) {
|
|
156
165
|
return blocked(
|
|
157
166
|
options.target,
|
|
@@ -163,6 +172,9 @@ function projectRuntime(repo, options) {
|
|
|
163
172
|
|
|
164
173
|
const contract = loaded.contract;
|
|
165
174
|
const capsule = contract.capsule;
|
|
175
|
+
const subagentMode = options.subagentMode
|
|
176
|
+
|| (authorization.has("subagent") && (capsule.delegation || readDelegationPolicy(repo).declared)
|
|
177
|
+
? "implementation" : "helper");
|
|
166
178
|
const capabilities = probeCapabilities(repo, options.target);
|
|
167
179
|
const capability = capabilities.capabilities[capabilityKey(event)];
|
|
168
180
|
const warnings = [...context.warnings];
|
|
@@ -194,22 +206,29 @@ function projectRuntime(repo, options) {
|
|
|
194
206
|
if (event === "subagent-stop") {
|
|
195
207
|
projection.returnAuthority = "report-and-evidence-only";
|
|
196
208
|
}
|
|
209
|
+
if (event.startsWith("subagent-")) {
|
|
210
|
+
projection.subagentMode = subagentMode;
|
|
211
|
+
projection.hostPolicy = "Host policy remains authoritative; projection does not spawn or prove enforcement.";
|
|
212
|
+
projection.prohibitions = [...projection.prohibitions,
|
|
213
|
+
"must not update task execution records or contract authority: checkbox, Contract, Evidence, Review, Covers, Touch, Verify or Acceptance"];
|
|
214
|
+
if (subagentMode === "helper") {
|
|
215
|
+
projection.prohibitions = [...projection.prohibitions, "must not write product or task record files"];
|
|
216
|
+
}
|
|
217
|
+
}
|
|
197
218
|
// Delegation extends the brief Keel already publishes rather than adding a
|
|
198
219
|
// carrier beside the host's own agent interface. The host spawns; this is the
|
|
199
220
|
// one-way view of OpenSpec it is handed.
|
|
200
|
-
if (event === "subagent-start") {
|
|
201
|
-
const refusal = delegationRefusal(repo, capsule.
|
|
221
|
+
if (event === "subagent-start" && subagentMode === "implementation") {
|
|
222
|
+
const refusal = delegationRefusal(repo, capsule, change, taskId, contract.fingerprint);
|
|
202
223
|
if (refusal) return blocked(options.target, event, refusal, warnings);
|
|
203
224
|
}
|
|
204
|
-
if (event === "subagent-start" &&
|
|
225
|
+
if (event === "subagent-start" && subagentMode === "implementation") {
|
|
205
226
|
projection.delegation = {
|
|
206
|
-
tier: capsule.delegation
|
|
207
|
-
source: capsule.delegation
|
|
227
|
+
tier: capsule.delegation?.tier || null,
|
|
228
|
+
source: capsule.delegation?.source || "selected-task-write-authority",
|
|
208
229
|
writeBoundary: capsule.touch,
|
|
209
230
|
note:
|
|
210
|
-
"Keel carries
|
|
211
|
-
+ "target resolves it. Keel cannot observe which model executed, so "
|
|
212
|
-
+ "the tier is what is recorded and never a claim about what ran.",
|
|
231
|
+
"Keel carries an optional declared tier, never infers one, and does not select or observe a model. The current agent re-runs every M<n> check before recording Evidence.",
|
|
213
232
|
};
|
|
214
233
|
}
|
|
215
234
|
|
|
@@ -1436,7 +1436,7 @@ function compileTaskContract(repo, change, task) {
|
|
|
1436
1436
|
if (!autonomy.some((item) => /^Pre-authorized fallback:/i.test(item))) {
|
|
1437
1437
|
autonomy.push("Pre-authorized fallback: none");
|
|
1438
1438
|
}
|
|
1439
|
-
//
|
|
1439
|
+
// Optional capability metadata, resolved as the autonomy boundary above is: the
|
|
1440
1440
|
// task keeps whatever it authored, the repository declaration supplies only
|
|
1441
1441
|
// what the task left silent, and the entry names its source. A declaration
|
|
1442
1442
|
// that could overwrite an authored tier would make the capsule unreadable on
|
|
@@ -1554,8 +1554,8 @@ function compileTaskContract(repo, change, task) {
|
|
|
1554
1554
|
// change the compiled capsule for every task everywhere, moving every
|
|
1555
1555
|
// recorded anchor and drifting every live change in every consumer repo on
|
|
1556
1556
|
// upgrade — for repositories that declared nothing and asked for nothing.
|
|
1557
|
-
// Omission
|
|
1558
|
-
//
|
|
1557
|
+
// Omission preserves existing anchors without inventing a tier.
|
|
1558
|
+
// A repository that does declare gets a different capsule,
|
|
1559
1559
|
// which is honest, because its execution genuinely differs.
|
|
1560
1560
|
...(delegation.tier ? { delegation } : {}),
|
|
1561
1561
|
prohibitions: [
|