@christang/keel 5.172.0 → 5.174.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 -4
- package/README.md +5 -6
- package/README.zh-CN.md +3 -5
- package/assets/bootstrap/AGENTS.md +1 -1
- package/assets/openspec/schemas/keel-spec-driven/templates/tasks.md +5 -5
- package/bin/keel.js +106 -188
- 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 -2
- package/plugins/keel/scripts/pretooluse-guard.js +3 -4
- package/scripts/validate_plugin.py +190 -2446
- package/src/core/agents.js +57 -12
- package/src/core/capabilities.js +0 -53
- package/src/core/config.js +4 -37
- package/src/core/projection.js +42 -149
- package/src/core/task-contract.js +3 -30
- package/plugins/keel/agents/keel-single-task-goal-claude.md +0 -17
- package/plugins/keel/agents/keel-single-task-goal-codex.md +0 -16
- package/plugins/keel/skills/keel-run-single-task-goal/SKILL.md +0 -64
- package/plugins/keel/skills/keel-run-single-task-goal/guidance.md +0 -30
- package/src/core/goal.js +0 -242
- package/src/core/helper.js +0 -345
- package/src/core/tasksview.js +0 -123
package/src/core/agents.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
// External model CLIs
|
|
3
|
+
// External model CLIs (#219).
|
|
4
4
|
//
|
|
5
5
|
// Keel describes an external agent and compiles the brief it is handed; it never
|
|
6
6
|
// launches one. The session's own shell runs the command, which keeps Keel the
|
|
@@ -448,6 +448,61 @@ function renderBrief({ agent, mode, dir, projection, source, result, tmp }) {
|
|
|
448
448
|
return lines.join("\n");
|
|
449
449
|
}
|
|
450
450
|
|
|
451
|
+
// The task an external CLI is handed, compiled from the capsule (#414 moved it
|
|
452
|
+
// off the removed subagent projection). An implementation brief still needs the
|
|
453
|
+
// write guard active for this exact task: the host's guard never sees an
|
|
454
|
+
// external process, so this refusal is the only check its writes get before
|
|
455
|
+
// they happen, and an absent manifest would pass every one of them silently.
|
|
456
|
+
function compileTaskBrief(repo, options) {
|
|
457
|
+
const { selectTaskContract } = require("./projection");
|
|
458
|
+
const { guardStatus } = require("./guard");
|
|
459
|
+
const refused = (reason, warnings = []) => ({ status: "blocked", reasons: [reason], warnings });
|
|
460
|
+
const selected = selectTaskContract(repo, options);
|
|
461
|
+
if (selected.reason) return refused(selected.reason, selected.warnings);
|
|
462
|
+
const { change, taskId, contract, owner, warnings } = selected;
|
|
463
|
+
const capsule = contract.capsule;
|
|
464
|
+
if (options.mode === "implementation") {
|
|
465
|
+
if (capsule.mode !== "implementation" || capsule.touch.length === 0 || capsule.touch.includes("none")) {
|
|
466
|
+
return refused("An implementation brief requires an implementation task with a Touch write boundary.", warnings);
|
|
467
|
+
}
|
|
468
|
+
const guard = guardStatus(repo);
|
|
469
|
+
if (guard.status !== "active") {
|
|
470
|
+
return refused(
|
|
471
|
+
`An implementation brief requires an active write guard; status is ${guard.status}. `
|
|
472
|
+
+ guard.problems.map((item) => item.message).join(" ")
|
|
473
|
+
+ " Run `keel gate task-start` for the selected task first.",
|
|
474
|
+
warnings
|
|
475
|
+
);
|
|
476
|
+
}
|
|
477
|
+
const manifest = guard.manifest;
|
|
478
|
+
if (manifest.change !== change || manifest.task !== taskId
|
|
479
|
+
|| manifest.fingerprint.value !== contract.fingerprint.value
|
|
480
|
+
|| JSON.stringify([...manifest.touch].sort()) !== JSON.stringify([...capsule.touch].sort())) {
|
|
481
|
+
return refused("An implementation brief requires a write guard matching the selected task, fingerprint and Touch boundary.", warnings);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
const prohibitions = [
|
|
485
|
+
...capsule.prohibitions,
|
|
486
|
+
"must not update task execution records or contract authority: checkbox, Contract, Evidence, Review, Covers, Touch, Verify or Acceptance",
|
|
487
|
+
...(options.mode === "helper" ? ["must not write product or task record files"] : []),
|
|
488
|
+
];
|
|
489
|
+
return {
|
|
490
|
+
status: "ready",
|
|
491
|
+
source: { authority: "OpenSpec", owner, change, task: taskId },
|
|
492
|
+
projection: {
|
|
493
|
+
objective: capsule.task.title,
|
|
494
|
+
acceptance: capsule.acceptance,
|
|
495
|
+
read: capsule.read,
|
|
496
|
+
touch: capsule.touch,
|
|
497
|
+
evidenceContract: capsule.verification.commands.map((item) => `${item.label}: ${item.check}`),
|
|
498
|
+
fingerprint: contract.fingerprint,
|
|
499
|
+
prohibitions,
|
|
500
|
+
},
|
|
501
|
+
reasons: [],
|
|
502
|
+
warnings: [...warnings],
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
|
|
451
506
|
function compileBrief(repo, options) {
|
|
452
507
|
const blocked = (reasons, warnings = []) => ({
|
|
453
508
|
schemaVersion: 1, command: "agents brief", status: "blocked",
|
|
@@ -481,17 +536,7 @@ function compileBrief(repo, options) {
|
|
|
481
536
|
+ "Add one to agents.json under the Keel home directory.",
|
|
482
537
|
]);
|
|
483
538
|
}
|
|
484
|
-
|
|
485
|
-
// including the matching guard for implementation, applies here unchanged.
|
|
486
|
-
const { projectRuntime } = require("./projection");
|
|
487
|
-
const projected = projectRuntime(repo, {
|
|
488
|
-
projectionEvent: "subagent-start",
|
|
489
|
-
target: "claude",
|
|
490
|
-
subagentMode: options.mode,
|
|
491
|
-
change: options.change,
|
|
492
|
-
task: options.task,
|
|
493
|
-
authorizations: [],
|
|
494
|
-
});
|
|
539
|
+
const projected = compileTaskBrief(repo, options);
|
|
495
540
|
if (projected.status !== "ready") return blocked(projected.reasons, projected.warnings);
|
|
496
541
|
const projection = projected.projection;
|
|
497
542
|
const hits = egressHits([...(projection.read || []), ...(projection.touch || [])],
|
package/src/core/capabilities.js
CHANGED
|
@@ -16,16 +16,8 @@ const CAPABILITY_COMMANDS = {
|
|
|
16
16
|
"keel gate task-complete --change <change> --task <task> --json",
|
|
17
17
|
"gate.change-close":
|
|
18
18
|
"keel gate change-close --change <change> --action <sync|archive> --json",
|
|
19
|
-
"execution.goal":
|
|
20
|
-
"keel project --target <target> --event goal --authorize goal --json",
|
|
21
|
-
"execution.task-view":
|
|
22
|
-
"keel project --target <target> --event task-view --authorize task-view --json",
|
|
23
19
|
"execution.worktree":
|
|
24
20
|
"keel project --target <target> --event worktree --expected-owner <owner> --json",
|
|
25
|
-
"delegation.context":
|
|
26
|
-
"keel project --target <target> --event subagent-start --json",
|
|
27
|
-
"delegation.return":
|
|
28
|
-
"keel project --target <target> --event subagent-stop --json",
|
|
29
21
|
};
|
|
30
22
|
|
|
31
23
|
const SUPPORTED_TARGETS = new Set(["claude", "codex", "opencode"]);
|
|
@@ -143,55 +135,15 @@ function probeCapabilities(repo, target) {
|
|
|
143
135
|
schemaVersion: 1,
|
|
144
136
|
target,
|
|
145
137
|
capabilities,
|
|
146
|
-
helper: helperDiagnostics(repo, target, observation),
|
|
147
138
|
guard: guardDiagnostics(repo, target),
|
|
148
139
|
compaction: compactionDiagnostics(target),
|
|
149
140
|
warnings: [
|
|
150
141
|
"No capability is promoted above manual without verifiable runtime "
|
|
151
142
|
+ "activation, trust, version, and behavior evidence.",
|
|
152
|
-
"Helper absence never disables current-agent goal execution; goal, "
|
|
153
|
-
+ "gates, and the manual loop stay usable without any helper.",
|
|
154
143
|
],
|
|
155
144
|
};
|
|
156
145
|
}
|
|
157
146
|
|
|
158
|
-
function helperDiagnostics(repo, target, observation) {
|
|
159
|
-
// Each dimension is reported separately with its own enforced/advisory/manual
|
|
160
|
-
// level: byte-stability and nested-delegation prevention are enforced by Keel
|
|
161
|
-
// Core deterministically, native tool restriction and discovery stay advisory
|
|
162
|
-
// until runtime-probed, and actual native helper execution stays manual.
|
|
163
|
-
return {
|
|
164
|
-
discovery: {
|
|
165
|
-
level: "advisory",
|
|
166
|
-
evidence: observation,
|
|
167
|
-
},
|
|
168
|
-
toolRestriction: {
|
|
169
|
-
level: "advisory",
|
|
170
|
-
evidence:
|
|
171
|
-
"Native helper tool allowlists are runtime-configured and cannot be "
|
|
172
|
-
+ "verified from Keel Core.",
|
|
173
|
-
},
|
|
174
|
-
nestedDelegationPrevention: {
|
|
175
|
-
level: "enforced",
|
|
176
|
-
evidence:
|
|
177
|
-
"keel project helper compiles a non-delegating brief and refuses "
|
|
178
|
-
+ "nested helpers or spawned agents.",
|
|
179
|
-
},
|
|
180
|
-
byteStability: {
|
|
181
|
-
level: "enforced",
|
|
182
|
-
evidence:
|
|
183
|
-
"keel project helper --verify accepts a return only after before/after "
|
|
184
|
-
+ "repository byte identity and never cleans up.",
|
|
185
|
-
},
|
|
186
|
-
execution: {
|
|
187
|
-
level: "manual",
|
|
188
|
-
evidence:
|
|
189
|
-
"Native bounded-helper execution stays manual until runtime activation, "
|
|
190
|
-
+ "trust, and tool restriction are probed.",
|
|
191
|
-
},
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
|
|
195
147
|
function guardDiagnostics(repo, target) {
|
|
196
148
|
// The write guard is Claude-only in v4: the plugin ships a deterministic
|
|
197
149
|
// manifest-gated PreToolUse denial, but runtime activation, trust, and
|
|
@@ -285,11 +237,6 @@ function renderCapabilities(result) {
|
|
|
285
237
|
+ `command: ${capability.command}`
|
|
286
238
|
);
|
|
287
239
|
}
|
|
288
|
-
if (result.helper) {
|
|
289
|
-
for (const [dimension, entry] of Object.entries(result.helper)) {
|
|
290
|
-
lines.push(`helper ${dimension}: ${entry.level} - ${entry.evidence}`);
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
240
|
if (result.guard) {
|
|
294
241
|
for (const [dimension, entry] of Object.entries(result.guard)) {
|
|
295
242
|
lines.push(`guard ${dimension}: ${entry.level} - ${entry.evidence}`);
|
package/src/core/config.js
CHANGED
|
@@ -147,14 +147,6 @@ function sessionChatRole(repo) {
|
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
// The closed vocabulary of capability tiers a repository may declare for a
|
|
151
|
-
// delegated task. The names describe the capability the work requires, never
|
|
152
|
-
// the size of the work: a tier named for size would authorize the agent's guess
|
|
153
|
-
// about difficulty, which is the judgement 5.7.0 refused for triage. Keel names
|
|
154
|
-
// no concrete model — one is target-specific and expires at the next release,
|
|
155
|
-
// and the declaration must still be correct after both.
|
|
156
|
-
const DELEGATION_TIERS = ["routine", "standard", "deep"];
|
|
157
|
-
|
|
158
150
|
// Every declaration this module reads, in the order the file documents them. One
|
|
159
151
|
// list, so an assertion about the set can be derived from the set instead of
|
|
160
152
|
// restating it: the header check used to pin an English numeral and had been
|
|
@@ -166,7 +158,6 @@ const CONFIG_DECLARATIONS = [
|
|
|
166
158
|
"authorize",
|
|
167
159
|
"precedents",
|
|
168
160
|
"triage",
|
|
169
|
-
"delegation",
|
|
170
161
|
"full_mode_paths",
|
|
171
162
|
"executor_tier",
|
|
172
163
|
"merge",
|
|
@@ -543,8 +534,8 @@ function fullModePathsUnreadableMessage(unreadable) {
|
|
|
543
534
|
+ "then recognise the sibling the list does not name.";
|
|
544
535
|
}
|
|
545
536
|
|
|
546
|
-
// A nested block of `name: value` entries under one top-level key.
|
|
547
|
-
//
|
|
537
|
+
// A nested block of `name: value` entries under one top-level key. Patrol and
|
|
538
|
+
// shift need a key with a value rather than a bare list, so they cannot reuse
|
|
548
539
|
// configList; the reader stays line-oriented for the same reason the others do.
|
|
549
540
|
function configMap(repo, key) {
|
|
550
541
|
const configPath = path.join(repo, "keel", "config.yaml");
|
|
@@ -569,25 +560,6 @@ function configMap(repo, key) {
|
|
|
569
560
|
return entries;
|
|
570
561
|
}
|
|
571
562
|
|
|
572
|
-
// Optional capability metadata; absence does not forbid model-chosen delegation.
|
|
573
|
-
function readDelegationPolicy(repo) {
|
|
574
|
-
const block = configMap(repo, "delegation");
|
|
575
|
-
const tier = block.tier;
|
|
576
|
-
// The accepted set travels with every answer so a caller reporting a refusal
|
|
577
|
-
// can name the alternatives without importing the vocabulary itself. A copy,
|
|
578
|
-
// because a caller that sorted or spliced it in place would edit the closed
|
|
579
|
-
// set for everyone who read it afterward.
|
|
580
|
-
const accepted = [...DELEGATION_TIERS];
|
|
581
|
-
if (!tier) return { declared: false, tier: null, unknown: [], accepted };
|
|
582
|
-
// Fail closed, the same way an unrecognized `authorize:` action does: a
|
|
583
|
-
// declaration Keel cannot fully read authorizes nothing, because the author
|
|
584
|
-
// of a typo believes they declared what they typed.
|
|
585
|
-
if (!DELEGATION_TIERS.includes(tier)) {
|
|
586
|
-
return { declared: true, tier: null, unknown: [tier], accepted };
|
|
587
|
-
}
|
|
588
|
-
return { declared: true, tier, unknown: [], accepted };
|
|
589
|
-
}
|
|
590
|
-
|
|
591
563
|
// `external_agents:` — which external model CLIs this project allows, and the
|
|
592
564
|
// paths that must not be handed to one (#219). Absent allows nothing: every
|
|
593
565
|
// other declaration here authorizes nothing when absent, and sending the
|
|
@@ -672,10 +644,7 @@ function readExternalAgents(repo) {
|
|
|
672
644
|
const EXECUTOR_TIERS = ["standard", "high"];
|
|
673
645
|
const EXECUTOR_TIER_DEFAULT = "standard";
|
|
674
646
|
|
|
675
|
-
// The tier reaches guidance and nothing else.
|
|
676
|
-
// `delegation:`'s tier on purpose: that one names who runs a *delegated* task,
|
|
677
|
-
// and a repository may hand routine work to a weak delegate while its own
|
|
678
|
-
// session is strong, so one field cannot answer both without lying about one.
|
|
647
|
+
// The tier reaches guidance and nothing else.
|
|
679
648
|
function readExecutorTier(repo) {
|
|
680
649
|
const declared = configScalar(repo, "executor_tier");
|
|
681
650
|
const accepted = [...EXECUTOR_TIERS];
|
|
@@ -687,7 +656,7 @@ function readExecutorTier(repo) {
|
|
|
687
656
|
accepted,
|
|
688
657
|
};
|
|
689
658
|
}
|
|
690
|
-
// Fail closed, the same rule `
|
|
659
|
+
// Fail closed, the same rule `authorize:` follows — except
|
|
691
660
|
// that closed here means *reading* the guidance rather than skipping it. A
|
|
692
661
|
// misspelling must not silently buy the reduction it asked for.
|
|
693
662
|
if (!EXECUTOR_TIERS.includes(declared)) {
|
|
@@ -1069,7 +1038,6 @@ module.exports = {
|
|
|
1069
1038
|
readReadOnlyRoles,
|
|
1070
1039
|
readExternalAgents,
|
|
1071
1040
|
CONFIG_RELATIVE_PATH,
|
|
1072
|
-
DELEGATION_TIERS,
|
|
1073
1041
|
EXECUTOR_TIERS,
|
|
1074
1042
|
EXECUTOR_TIER_DEFAULT,
|
|
1075
1043
|
CONFIG_DECLARATIONS,
|
|
@@ -1077,7 +1045,6 @@ module.exports = {
|
|
|
1077
1045
|
SCOPED_AUTHORIZATION_ACTIONS,
|
|
1078
1046
|
readFullModePaths,
|
|
1079
1047
|
fullModePathsUnreadableMessage,
|
|
1080
|
-
readDelegationPolicy,
|
|
1081
1048
|
readExecutorTier,
|
|
1082
1049
|
readMergeDeclaration,
|
|
1083
1050
|
executorTierUnreadableMessage,
|
package/src/core/projection.js
CHANGED
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
// Keel 4.1.0 one-way native projection contract.
|
|
3
|
+
// Keel 4.1.0 one-way native projection contract. Since 5.173.0 (#414) it covers
|
|
4
|
+
// continuity and worktree views only: native goals, subagents, and task lists
|
|
5
|
+
// need no Keel projection.
|
|
4
6
|
|
|
5
|
-
const { readDelegationPolicy } = require("./config");
|
|
6
7
|
const { resolveContext } = require("./context");
|
|
7
8
|
const { loadTaskContract } = require("./task-contract");
|
|
8
9
|
const { probeCapabilities } = require("./capabilities");
|
|
9
|
-
const { guardStatus } = require("./guard");
|
|
10
10
|
|
|
11
11
|
const EVENTS = new Set([
|
|
12
12
|
"startup",
|
|
13
13
|
"resume",
|
|
14
14
|
"compaction",
|
|
15
|
-
"goal",
|
|
16
|
-
"task-view",
|
|
17
15
|
"worktree",
|
|
18
|
-
"subagent-start",
|
|
19
|
-
"subagent-stop",
|
|
20
16
|
]);
|
|
21
17
|
|
|
22
18
|
function blocked(target, event, reason, warnings = []) {
|
|
@@ -36,112 +32,64 @@ function blocked(target, event, reason, warnings = []) {
|
|
|
36
32
|
};
|
|
37
33
|
}
|
|
38
34
|
|
|
39
|
-
// Both refusals are decided before a delegate starts, never inferred from what
|
|
40
|
-
// it did. An absent manifest passes every write through silently, so a delegate
|
|
41
|
-
// that wrote successfully under one proves nothing about having been checked —
|
|
42
|
-
// there is no observable difference afterwards, which is why the condition has
|
|
43
|
-
// to be answered here.
|
|
44
|
-
function delegationRefusal(repo, capsule, change, taskId, fingerprint) {
|
|
45
|
-
// The policy is read directly rather than through the capsule, because the
|
|
46
|
-
// capsule cannot express the difference this refusal turns on. A tier outside
|
|
47
|
-
// the vocabulary fails closed at the config layer and reaches the capsule as
|
|
48
|
-
// no delegation at all — identical to a repository that declared nothing. One
|
|
49
|
-
// of those should proceed silently and the other must be reported, so the
|
|
50
|
-
// unresolved declaration has to be seen where it still exists.
|
|
51
|
-
const { unknown: configuredUnknown, accepted } = readDelegationPolicy(repo);
|
|
52
|
-
const declaredTier = capsule.delegation?.tier;
|
|
53
|
-
const unknown = declaredTier
|
|
54
|
-
? (accepted.includes(declaredTier) ? [] : [declaredTier])
|
|
55
|
-
: configuredUnknown;
|
|
56
|
-
if (unknown.length > 0) {
|
|
57
|
-
return (
|
|
58
|
-
`Delegation declares invalid tier metadata "${unknown.join(", ")}". `
|
|
59
|
-
+ `Accepted: ${accepted.join(", ")}. Keel refuses `
|
|
60
|
-
+ "rather than substituting a tier, because work would otherwise run at "
|
|
61
|
-
+ "a capability nobody declared while reporting success."
|
|
62
|
-
);
|
|
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") {
|
|
70
|
-
return (
|
|
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."
|
|
74
|
-
);
|
|
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
|
-
}
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
35
|
function capabilityKey(event) {
|
|
86
36
|
if (event === "startup") return "continuity.start";
|
|
87
37
|
if (["resume", "compaction"].includes(event)) return "continuity.reinject";
|
|
88
|
-
|
|
89
|
-
if (event === "task-view") return "execution.task-view";
|
|
90
|
-
if (event === "worktree") return "execution.worktree";
|
|
91
|
-
if (event === "subagent-start") return "delegation.context";
|
|
92
|
-
return "delegation.return";
|
|
38
|
+
return "execution.worktree";
|
|
93
39
|
}
|
|
94
40
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
throw new Error(`unsupported projection event: ${event || "<missing>"}`);
|
|
99
|
-
}
|
|
100
|
-
if (!["claude", "codex", "opencode"].includes(options.target)) {
|
|
101
|
-
throw new Error(`unsupported target: ${options.target}`);
|
|
102
|
-
}
|
|
103
|
-
|
|
41
|
+
// The selected task's compiled contract, or the reason there is none. Shared
|
|
42
|
+
// with `keel agents brief`, which hands the same task to an external CLI.
|
|
43
|
+
function selectTaskContract(repo, options) {
|
|
104
44
|
const context = resolveContext(repo, {
|
|
105
45
|
change: options.change,
|
|
106
46
|
task: options.task,
|
|
107
47
|
});
|
|
108
48
|
if (context.status !== "ready" || !context.selection) {
|
|
109
|
-
return
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
context.warnings
|
|
114
|
-
);
|
|
49
|
+
return {
|
|
50
|
+
reason: context.reasons.join(" ") || "Current OpenSpec context is not ready.",
|
|
51
|
+
warnings: context.warnings,
|
|
52
|
+
};
|
|
115
53
|
}
|
|
116
54
|
const change = context.selection.change;
|
|
117
55
|
const taskId = context.selection.task;
|
|
118
56
|
if (!taskId) {
|
|
119
|
-
return
|
|
120
|
-
options.target,
|
|
121
|
-
event,
|
|
122
|
-
"Projection requires one selected executable task.",
|
|
123
|
-
context.warnings
|
|
124
|
-
);
|
|
57
|
+
return { reason: "Projection requires one selected executable task.", warnings: context.warnings };
|
|
125
58
|
}
|
|
126
59
|
const loaded = loadTaskContract(repo, change, taskId);
|
|
127
60
|
if (!loaded || loaded.task.checked) {
|
|
128
|
-
return
|
|
129
|
-
options.target,
|
|
130
|
-
event,
|
|
131
|
-
"Selected durable task owner is missing or already complete.",
|
|
132
|
-
context.warnings
|
|
133
|
-
);
|
|
61
|
+
return { reason: "Selected durable task owner is missing or already complete.", warnings: context.warnings };
|
|
134
62
|
}
|
|
135
63
|
if (loaded.contract.diagnostics.length > 0) {
|
|
136
|
-
return
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
64
|
+
return {
|
|
65
|
+
reason: loaded.contract.diagnostics.map((item) => item.message).join(" "),
|
|
66
|
+
warnings: context.warnings,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
context,
|
|
71
|
+
change,
|
|
72
|
+
taskId,
|
|
73
|
+
contract: loaded.contract,
|
|
74
|
+
owner: `openspec/changes/${change}/tasks.md#${taskId}`,
|
|
75
|
+
warnings: context.warnings,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function projectRuntime(repo, options) {
|
|
80
|
+
const event = options.projectionEvent;
|
|
81
|
+
if (!EVENTS.has(event)) {
|
|
82
|
+
throw new Error(`unsupported projection event: ${event || "<missing>"}`);
|
|
83
|
+
}
|
|
84
|
+
if (!["claude", "codex", "opencode"].includes(options.target)) {
|
|
85
|
+
throw new Error(`unsupported target: ${options.target}`);
|
|
142
86
|
}
|
|
143
87
|
|
|
144
|
-
const
|
|
88
|
+
const selected = selectTaskContract(repo, options);
|
|
89
|
+
if (selected.reason) {
|
|
90
|
+
return blocked(options.target, event, selected.reason, selected.warnings);
|
|
91
|
+
}
|
|
92
|
+
const { context, change, taskId, contract, owner } = selected;
|
|
145
93
|
if (
|
|
146
94
|
event === "worktree"
|
|
147
95
|
&& (!options.expectedOwner || options.expectedOwner !== owner)
|
|
@@ -154,36 +102,9 @@ function projectRuntime(repo, options) {
|
|
|
154
102
|
);
|
|
155
103
|
}
|
|
156
104
|
|
|
157
|
-
const authorization = new Set(options.authorizations || []);
|
|
158
|
-
const requiredAuthorization =
|
|
159
|
-
event === "goal"
|
|
160
|
-
? "goal"
|
|
161
|
-
: event === "task-view"
|
|
162
|
-
? "task-view"
|
|
163
|
-
: null;
|
|
164
|
-
if (requiredAuthorization && !authorization.has(requiredAuthorization)) {
|
|
165
|
-
return blocked(
|
|
166
|
-
options.target,
|
|
167
|
-
event,
|
|
168
|
-
`${event} projection requires explicit ${requiredAuthorization} authorization.`,
|
|
169
|
-
context.warnings
|
|
170
|
-
);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
const contract = loaded.contract;
|
|
174
105
|
const capsule = contract.capsule;
|
|
175
|
-
const subagentMode = options.subagentMode
|
|
176
|
-
|| (authorization.has("subagent") && (capsule.delegation || readDelegationPolicy(repo).declared)
|
|
177
|
-
? "implementation" : "helper");
|
|
178
106
|
const capabilities = probeCapabilities(repo, options.target);
|
|
179
107
|
const capability = capabilities.capabilities[capabilityKey(event)];
|
|
180
|
-
const warnings = [...context.warnings];
|
|
181
|
-
if (options.nativeComplete) {
|
|
182
|
-
warnings.push(
|
|
183
|
-
"Native completion was ignored; only task-complete plus current-agent "
|
|
184
|
-
+ "durable updates can complete OpenSpec work."
|
|
185
|
-
);
|
|
186
|
-
}
|
|
187
108
|
const projection = {
|
|
188
109
|
objective: capsule.task.title,
|
|
189
110
|
acceptance: capsule.acceptance,
|
|
@@ -199,38 +120,9 @@ function projectRuntime(repo, options) {
|
|
|
199
120
|
(item) => `${item.label}: ${item.check}`
|
|
200
121
|
),
|
|
201
122
|
owner: capsule.owner,
|
|
202
|
-
helperAuthority: capsule.helperAuthority,
|
|
203
123
|
fingerprint: contract.fingerprint,
|
|
204
124
|
prohibitions: capsule.prohibitions,
|
|
205
125
|
};
|
|
206
|
-
if (event === "subagent-stop") {
|
|
207
|
-
projection.returnAuthority = "report-and-evidence-only";
|
|
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
|
-
}
|
|
218
|
-
// Delegation extends the brief Keel already publishes rather than adding a
|
|
219
|
-
// carrier beside the host's own agent interface. The host spawns; this is the
|
|
220
|
-
// one-way view of OpenSpec it is handed.
|
|
221
|
-
if (event === "subagent-start" && subagentMode === "implementation") {
|
|
222
|
-
const refusal = delegationRefusal(repo, capsule, change, taskId, contract.fingerprint);
|
|
223
|
-
if (refusal) return blocked(options.target, event, refusal, warnings);
|
|
224
|
-
}
|
|
225
|
-
if (event === "subagent-start" && subagentMode === "implementation") {
|
|
226
|
-
projection.delegation = {
|
|
227
|
-
tier: capsule.delegation?.tier || null,
|
|
228
|
-
source: capsule.delegation?.source || "selected-task-write-authority",
|
|
229
|
-
writeBoundary: capsule.touch,
|
|
230
|
-
note:
|
|
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.",
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
126
|
|
|
235
127
|
return {
|
|
236
128
|
schemaVersion: 1,
|
|
@@ -247,7 +139,7 @@ function projectRuntime(repo, options) {
|
|
|
247
139
|
contract,
|
|
248
140
|
projection,
|
|
249
141
|
reasons: [],
|
|
250
|
-
warnings,
|
|
142
|
+
warnings: [...context.warnings],
|
|
251
143
|
};
|
|
252
144
|
}
|
|
253
145
|
|
|
@@ -266,4 +158,5 @@ function renderProjection(result) {
|
|
|
266
158
|
module.exports = {
|
|
267
159
|
projectRuntime,
|
|
268
160
|
renderProjection,
|
|
161
|
+
selectTaskContract,
|
|
269
162
|
};
|
|
@@ -7,7 +7,6 @@ const path = require("path");
|
|
|
7
7
|
|
|
8
8
|
const {
|
|
9
9
|
CONFIG_RELATIVE_PATH,
|
|
10
|
-
readDelegationPolicy,
|
|
11
10
|
readStandingAuthorization,
|
|
12
11
|
} = require("./config");
|
|
13
12
|
|
|
@@ -1441,24 +1440,6 @@ function compileTaskContract(repo, change, task, options = {}) {
|
|
|
1441
1440
|
if (!autonomy.some((item) => /^Pre-authorized fallback:/i.test(item))) {
|
|
1442
1441
|
autonomy.push("Pre-authorized fallback: none");
|
|
1443
1442
|
}
|
|
1444
|
-
// Optional capability metadata, resolved as the autonomy boundary above is: the
|
|
1445
|
-
// task keeps whatever it authored, the repository declaration supplies only
|
|
1446
|
-
// what the task left silent, and the entry names its source. A declaration
|
|
1447
|
-
// that could overwrite an authored tier would make the capsule unreadable on
|
|
1448
|
-
// its own — you could not tell what this task decided from what the file did.
|
|
1449
|
-
const authoredTier = normalizeText(field(task, "Delegation")).toLowerCase();
|
|
1450
|
-
let delegation = { tier: null, source: null };
|
|
1451
|
-
if (authoredTier) {
|
|
1452
|
-
delegation = { tier: authoredTier, source: "task" };
|
|
1453
|
-
} else {
|
|
1454
|
-
const { tier } = readDelegationPolicy(repo);
|
|
1455
|
-
if (tier) {
|
|
1456
|
-
delegation = {
|
|
1457
|
-
tier,
|
|
1458
|
-
source: CONFIG_RELATIVE_PATH.split(path.sep).join("/"),
|
|
1459
|
-
};
|
|
1460
|
-
}
|
|
1461
|
-
}
|
|
1462
1443
|
// A question is unresolved authority when it is the subject of its Covers
|
|
1463
1444
|
// entry. Scanning the whole field also matched a resolved question named as
|
|
1464
1445
|
// supporting detail beside the fact that closed it, and the only fix
|
|
@@ -1551,18 +1532,10 @@ function compileTaskContract(repo, change, task, options = {}) {
|
|
|
1551
1532
|
couplingMode === "required" ? candidateBoundary : [],
|
|
1552
1533
|
designContract: coupledContract,
|
|
1553
1534
|
},
|
|
1554
|
-
//
|
|
1555
|
-
//
|
|
1556
|
-
//
|
|
1535
|
+
// Kept only so that no recorded fingerprint moves (#414, owner decision):
|
|
1536
|
+
// nothing reads it, and no rule about helpers stands behind it any more.
|
|
1537
|
+
// Removing it would drift every live task in every repository on upgrade.
|
|
1557
1538
|
helperAuthority: "read-only-evidence-only",
|
|
1558
|
-
// Present only when a tier actually resolved. An unconditional field would
|
|
1559
|
-
// change the compiled capsule for every task everywhere, moving every
|
|
1560
|
-
// recorded anchor and drifting every live change in every consumer repo on
|
|
1561
|
-
// upgrade — for repositories that declared nothing and asked for nothing.
|
|
1562
|
-
// Omission preserves existing anchors without inventing a tier.
|
|
1563
|
-
// A repository that does declare gets a different capsule,
|
|
1564
|
-
// which is honest, because its execution genuinely differs.
|
|
1565
|
-
...(delegation.tier ? { delegation } : {}),
|
|
1566
1539
|
prohibitions: [
|
|
1567
1540
|
"must not change Acceptance",
|
|
1568
1541
|
// repo-action is the one mode whose authorized effect is the repository
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: keel-single-task-goal-claude
|
|
3
|
-
description: Thin Claude activation adapter for one authorized OpenSpec task; single /goal within the 4,000-character budget; the current agent keeps sole write authority.
|
|
4
|
-
target: claude
|
|
5
|
-
role: single-task-goal-activation
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
# keel-single-task-goal-claude
|
|
9
|
-
|
|
10
|
-
Thin Claude adapter for the `keel-run-single-task-goal` skill. It activates one `/goal` for exactly one authorized OpenSpec task and never introduces a scheduler, global Stop hook, agent team, or cross-task authority.
|
|
11
|
-
|
|
12
|
-
- Activation: compile the view with `keel project goal --target claude --change C --task T --json`; the goal condition stays within the 4,000-character budget, and Keel refuses activation rather than omit Acceptance, fingerprint, or stop authority.
|
|
13
|
-
- Evidence: Claude's evaluator is transcript-only, so surface every command result and gate outcome before any success claim; only `keel gate task-complete` plus the current agent's durable checkbox complete the task.
|
|
14
|
-
- Helpers: Claude subagents used as helpers are bounded read-only evidence producers via `keel project helper`; they carry no write, delegation, acceptance, or completion authority, and their returns are accepted only after repository byte identity.
|
|
15
|
-
- Delegates: the model may choose implementation inside task `Touch` with a matching active guard; optional `delegation:` tiers are metadata, not extra permission. The current agent keeps sole write authority, re-runs each `M<n>` check itself before recording Evidence, and owns Review, gates, the checkbox, and completion. Host policy remains authoritative.
|
|
16
|
-
- Stop: terminate after one task on completion, drift, blocker, or premature native success; continuing requires a new explicit authorization and start fingerprint.
|
|
17
|
-
- Fallback: with disabled hooks, managed policy, or missing trust, report and run the identical manual Keel loop.
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: keel-single-task-goal-codex
|
|
3
|
-
description: Thin Codex activation adapter for one authorized OpenSpec task; bounded goal execution; the current agent keeps sole write authority.
|
|
4
|
-
target: codex
|
|
5
|
-
role: single-task-goal-activation
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
# keel-single-task-goal-codex
|
|
9
|
-
|
|
10
|
-
Thin Codex adapter for the `keel-run-single-task-goal` skill. It activates one bounded goal for exactly one authorized OpenSpec task and never introduces a scheduler, global stop hook, agent team, or cross-task authority.
|
|
11
|
-
|
|
12
|
-
- Activation: compile the view with `keel project goal --target codex --change C --task T --json`, then follow the single-task goal lifecycle. Where no callable goal surface exists, surface the exact command and treat the capability as advisory.
|
|
13
|
-
- Ownership: the current agent stays the sole holder of write authority and owns Review, gates, the checkbox, and completion; a native evaluator success never completes the task. A model-chosen delegate writes only inside task `Touch` with a matching active guard, and the current agent re-runs each `M<n>` check before recording Evidence. Optional tiers are metadata; host policy remains authoritative.
|
|
14
|
-
- Helpers: Codex subagents are used only as bounded read-only evidence producers via `keel project helper`; they carry no write, delegation, acceptance, or completion authority, and their returns are accepted only after repository byte identity.
|
|
15
|
-
- Stop: terminate after one task on completion, drift, blocker, or premature native success; continuing requires a new explicit authorization and start fingerprint.
|
|
16
|
-
- Fallback: without a callable Codex surface, run the identical manual Keel loop.
|