@christang/keel 5.231.11 → 5.231.13
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/bin/keel.js +1 -0
- 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/test_codex_host.js +101 -0
- package/scripts/validation/common.py +2 -2
- package/src/core/codex-host.js +64 -12
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.231.
|
|
3
|
+
"version": "5.231.13",
|
|
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/bin/keel.js
CHANGED
|
@@ -108,6 +108,7 @@ Usage:
|
|
|
108
108
|
keel worktrees add [--repo <path>] --path <path> --branch <new-branch> [--base <ref>] [--json]
|
|
109
109
|
keel sync status [--repo <path>] [--verify] [--remote <name>] [--json] (what exists only on this machine; fetches nothing, --verify asks the remote its sha)
|
|
110
110
|
keel patrol [--issues <file>] [--idle <dur>] [--since-last [--notify]] [--nudge] [--json] [--repo <path>] (the coordinator's patrol; keel patrol task prints its schedule)
|
|
111
|
+
keel codex list [--repo <path>] [--json] (read local managed role registrations offline)
|
|
111
112
|
keel codex status|start|deliver|handover|drain|recover [--repo <path>] [--role <role>] [--socket <path>] [--json] (managed Codex roles; explicit host identity)
|
|
112
113
|
keel codex status [--repo <path>] --role <role> --record <id> [--json] (read the durable delivery receipt locally)
|
|
113
114
|
keel codex inspect-registration --repo <path> --role <role> --thread <id> --socket <path> --authority <reference>
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@christang/keel",
|
|
3
|
-
"version": "5.231.
|
|
3
|
+
"version": "5.231.13",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@christang/keel",
|
|
9
|
-
"version": "5.231.
|
|
9
|
+
"version": "5.231.13",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@fission-ai/openspec": "1.14.0"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.231.
|
|
3
|
+
"version": "5.231.13",
|
|
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.231.
|
|
3
|
+
"version": "5.231.13",
|
|
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",
|
|
@@ -9,6 +9,107 @@ const fs=require('node:fs');
|
|
|
9
9
|
const {spawn}=require('node:child_process');
|
|
10
10
|
const cli=path.resolve(__dirname,'../bin/keel.js');
|
|
11
11
|
function run(args,action="status"){return new Promise(resolve=>{const p=spawn(process.execPath,['chat','tick'].includes(action)?[cli,action,...args]:[cli,'codex',action,...args]);let out='',err='';p.stdout.on('data',b=>out+=b);p.stderr.on('data',b=>err+=b);p.on('close',code=>resolve({code,out,err}));});}
|
|
12
|
+
test('list managed roles offline without draining or changing the shared mailbox', async t => {
|
|
13
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'keel-role-list-'));
|
|
14
|
+
t.after(() => fs.rmSync(dir, {recursive: true, force: true}));
|
|
15
|
+
require('node:child_process').execFileSync('git', ['init', '-q', dir]);
|
|
16
|
+
const store = require('../src/core/chat/store');
|
|
17
|
+
const where = store.requireLocation(dir);
|
|
18
|
+
async function list() {
|
|
19
|
+
const result = await run(['--repo', dir, '--json'], 'list');
|
|
20
|
+
assert.equal(result.code, 0, result.err);
|
|
21
|
+
return JSON.parse(result.out).roles;
|
|
22
|
+
}
|
|
23
|
+
assert.deepEqual(await list(), []);
|
|
24
|
+
assert.ok(!fs.existsSync(where.root));
|
|
25
|
+
const socket = path.join(dir, 'host.sock');
|
|
26
|
+
let connections = 0;
|
|
27
|
+
const server = require('node:net').createServer(peer => { connections++; peer.destroy(); });
|
|
28
|
+
await new Promise(resolve => server.listen(socket, resolve));
|
|
29
|
+
t.after(() => new Promise(resolve => server.close(resolve)));
|
|
30
|
+
const registry = path.join(where.root, 'codex-roles');
|
|
31
|
+
fs.mkdirSync(registry, {recursive: true});
|
|
32
|
+
const bindings = {};
|
|
33
|
+
for (const role of ['worker', 'paused', 'moved']) {
|
|
34
|
+
const worktree = path.join(dir, role);
|
|
35
|
+
bindings[worktree] = role === 'moved' ? 'other' : role;
|
|
36
|
+
fs.mkdirSync(worktree);
|
|
37
|
+
fs.writeFileSync(path.join(registry, role + '.json'), JSON.stringify({
|
|
38
|
+
state: 'managed', role, worktree, thread: role + '-thread', socket, deliveries: {private: 'secret'},
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
fs.writeFileSync(path.join(where.root, 'roles.json'), JSON.stringify(bindings));
|
|
42
|
+
store.createGroup(where, 'owner', 'team', ['worker', 'group-only']);
|
|
43
|
+
store.writeRecord(where, {group: 'team', kind: 'todo', from: 'owner', assignee: 'worker', text: 'pending'});
|
|
44
|
+
require('../src/core/chat/notice').park(where, 'paused', 'owner', 'maintenance');
|
|
45
|
+
fs.writeFileSync(path.join(registry, 'broken.json'), '{');
|
|
46
|
+
fs.writeFileSync(path.join(registry, 'broken-new.json'), JSON.stringify({state: 'creation-pending'}));
|
|
47
|
+
function snapshot() {
|
|
48
|
+
return fs.readdirSync(where.root, {recursive: true}).sort().map(name => {
|
|
49
|
+
const file = path.join(where.root, name);
|
|
50
|
+
return [name, fs.statSync(file).isFile() ? fs.readFileSync(file) : null];
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
const before = snapshot();
|
|
54
|
+
const rows = await list();
|
|
55
|
+
assert.deepEqual(rows.map(row => row.role), ['broken', 'broken-new', 'moved', 'paused', 'worker']);
|
|
56
|
+
assert.deepEqual(rows[0], {role: 'broken', state: 'invalid', worktree: null, thread: null, socket: null, parked: false, error: 'unreadable-registration'});
|
|
57
|
+
assert.equal(rows[1].error, 'creation-pending');
|
|
58
|
+
assert.equal(rows[2].error, 'binding-mismatch');
|
|
59
|
+
assert.equal(rows[2].state, 'invalid');
|
|
60
|
+
for (const row of rows.slice(3)) {
|
|
61
|
+
assert.deepEqual(row, {role: row.role, state: 'managed', worktree: path.join(dir, row.role),
|
|
62
|
+
thread: row.role + '-thread', socket, parked: row.role === 'paused'});
|
|
63
|
+
}
|
|
64
|
+
assert.deepEqual(await list(), rows);
|
|
65
|
+
assert.deepEqual(snapshot(), before);
|
|
66
|
+
assert.equal(connections, 0);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('damaged delivery claims stay unknown and refuse offline replay', async t => {
|
|
70
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'keel-damaged-claim-'));
|
|
71
|
+
t.after(() => fs.rmSync(dir, {recursive: true, force: true}));
|
|
72
|
+
require('node:child_process').execFileSync('git', ['init', '-q', dir]);
|
|
73
|
+
const store = require('../src/core/chat/store');
|
|
74
|
+
const where = store.requireLocation(dir);
|
|
75
|
+
store.createGroup(where, 'owner', 'team', ['worker']);
|
|
76
|
+
const todo = store.writeRecord(where, {group: 'team', kind: 'todo', from: 'owner', assignee: 'worker', text: 'verify artifact'});
|
|
77
|
+
const key = crypto.createHash('sha256').update(todo.id).digest('hex');
|
|
78
|
+
const registry = path.join(where.root, 'codex-roles', 'worker.json');
|
|
79
|
+
const base = {state: 'managed', role: 'worker', worktree: where.worktree, socket: path.join(dir, 'offline.sock'), thread: 'original'};
|
|
80
|
+
const args = ['--repo', dir, '--role', 'worker', '--record', todo.id, '--json'];
|
|
81
|
+
fs.mkdirSync(path.dirname(registry), {recursive: true});
|
|
82
|
+
const cases = [
|
|
83
|
+
[undefined, 'unrecorded'], [{}, 'unrecorded'],
|
|
84
|
+
[{[key]: null}, 'unknown'], [{[key]: false}, 'unknown'], [{[key]: 0}, 'unknown'], [{[key]: ''}, 'unknown'],
|
|
85
|
+
[null, 'invalid-map'], [false, 'invalid-map'], [[], 'invalid-map'],
|
|
86
|
+
];
|
|
87
|
+
for (const [deliveries, expected] of cases) {
|
|
88
|
+
const before = JSON.stringify({...base, deliveries});
|
|
89
|
+
fs.writeFileSync(registry, before);
|
|
90
|
+
const status = await run([...args, '--observe']);
|
|
91
|
+
const missing = expected === 'unrecorded';
|
|
92
|
+
if (expected === 'invalid-map') {
|
|
93
|
+
assert.notEqual(status.code, 0);
|
|
94
|
+
assert.match(status.err, /claim map/);
|
|
95
|
+
} else {
|
|
96
|
+
assert.equal(status.code, 0, status.err);
|
|
97
|
+
const receipt = JSON.parse(status.out);
|
|
98
|
+
assert.equal(receipt.state, expected, before);
|
|
99
|
+
assert.equal(receipt.observation.state, 'unknown');
|
|
100
|
+
}
|
|
101
|
+
const portable = await run(['--repo', dir, 'show', todo.id, '--json'], 'chat');
|
|
102
|
+
assert.equal(portable.code, 0, portable.err);
|
|
103
|
+
assert.equal(JSON.parse(portable.out).delivery.state, missing ? 'unobserved' : 'unknown');
|
|
104
|
+
if (!missing) {
|
|
105
|
+
const retry = await run([...args, '--text', 'must not run'], 'deliver');
|
|
106
|
+
assert.notEqual(retry.code, 0);
|
|
107
|
+
assert.match(retry.err, /outcome unknown/);
|
|
108
|
+
}
|
|
109
|
+
assert.equal(fs.readFileSync(registry, 'utf8'), before);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
|
|
12
113
|
test('managed CLI lifecycle, mailbox scheduling and frame boundaries',async()=>{
|
|
13
114
|
const dir=fs.mkdtempSync(path.join(os.tmpdir(),'keel-host-'));const sock=path.join(dir,'host.sock');const requests=[];const requestDetails=[];const peers=[];const blank=new Set(),lost=new Set();let active=true,serial=0,uncertain=false,invalidHost=false,injectNotice=false,unloaded=false,resumeActive=false,resumeFails=false,resumeMismatch=false,readMismatch=false,resumeDelay=false,initNameFails=false;
|
|
14
115
|
let observationTurn = null;
|
|
@@ -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.231.
|
|
38
|
+
PACKAGE_VERSION = "5.231.13"
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
PROTOCOL_VERSION = "5.231.
|
|
41
|
+
PROTOCOL_VERSION = "5.231.13"
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
|
package/src/core/codex-host.js
CHANGED
|
@@ -123,11 +123,17 @@ function deliveryKey(record) {
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
function deliveryReceipt(role, record) {
|
|
126
|
-
const
|
|
126
|
+
const {deliveries = {}} = role;
|
|
127
|
+
if (!deliveries || typeof deliveries !== "object" || Array.isArray(deliveries)) {
|
|
128
|
+
throw Error("managed delivery claim map invalid; outcome unknown");
|
|
129
|
+
}
|
|
130
|
+
const key = deliveryKey(record);
|
|
131
|
+
const present = Object.hasOwn(deliveries, key);
|
|
132
|
+
const claim = deliveries[key];
|
|
127
133
|
if (claim && claim.record !== record) throw Error("managed delivery claim identity mismatch");
|
|
128
134
|
const turn = claim?.state === "delivered" && typeof claim.turn === "string" && claim.turn ? claim.turn : null;
|
|
129
135
|
const thread = typeof claim?.thread === "string" && claim.thread ? claim.thread : null;
|
|
130
|
-
const state =
|
|
136
|
+
const state = turn ? "delivered" : present ? "unknown" : "unrecorded";
|
|
131
137
|
return { role: role.role, record, state, thread, turn };
|
|
132
138
|
}
|
|
133
139
|
|
|
@@ -244,6 +250,45 @@ async function observeDelivery(receipt, role, timeout) {
|
|
|
244
250
|
return observation;
|
|
245
251
|
}
|
|
246
252
|
|
|
253
|
+
function listManagedRoles(where) {
|
|
254
|
+
const fs = require('node:fs');
|
|
255
|
+
const store = require('./chat/store');
|
|
256
|
+
const {parkOf} = require('./chat/notice');
|
|
257
|
+
const directory = path.join(where.root, 'codex-roles');
|
|
258
|
+
let files;
|
|
259
|
+
try {
|
|
260
|
+
files = fs.readdirSync(directory, {withFileTypes: true});
|
|
261
|
+
} catch (error) {
|
|
262
|
+
if (error.code === 'ENOENT') return [];
|
|
263
|
+
throw error;
|
|
264
|
+
}
|
|
265
|
+
const bindings = store.readRoles(where.root);
|
|
266
|
+
const rows = files.filter(file => file.name.endsWith('.json')).map(file => {
|
|
267
|
+
const role = file.name.slice(0, -5);
|
|
268
|
+
const row = {role, state: 'invalid', worktree: null, thread: null, socket: null, parked: !!parkOf(where, role)};
|
|
269
|
+
let entry;
|
|
270
|
+
try {
|
|
271
|
+
if (!file.isFile()) return {...row, error: 'unreadable-registration'};
|
|
272
|
+
entry = JSON.parse(fs.readFileSync(path.join(directory, file.name), 'utf8'));
|
|
273
|
+
} catch {
|
|
274
|
+
return {...row, error: 'unreadable-registration'};
|
|
275
|
+
}
|
|
276
|
+
for (const key of ['worktree', 'thread', 'socket']) {
|
|
277
|
+
if (typeof entry?.[key] === 'string' && entry[key]) row[key] = entry[key];
|
|
278
|
+
}
|
|
279
|
+
if (entry?.state === 'creation-pending') return {...row, error: 'creation-pending'};
|
|
280
|
+
if (entry?.state !== 'managed' || entry.role !== role || !row.worktree || !row.thread || !row.socket) {
|
|
281
|
+
return {...row, error: 'invalid-registration'};
|
|
282
|
+
}
|
|
283
|
+
if (bindings[row.worktree] !== role || Object.values(bindings).filter(value => value === role).length !== 1) {
|
|
284
|
+
return {...row, error: 'binding-mismatch'};
|
|
285
|
+
}
|
|
286
|
+
row.state = 'managed';
|
|
287
|
+
return row;
|
|
288
|
+
});
|
|
289
|
+
return rows.sort((a, b) => a.role < b.role ? -1 : a.role > b.role ? 1 : 0);
|
|
290
|
+
}
|
|
291
|
+
|
|
247
292
|
async function run(args) {
|
|
248
293
|
const onboarding = require("./codex-onboarding");
|
|
249
294
|
if (onboarding.actions.includes(args[0])) return onboarding.run(args, {connect});
|
|
@@ -253,12 +298,13 @@ async function run(args) {
|
|
|
253
298
|
let registrationLock;
|
|
254
299
|
try {
|
|
255
300
|
const action = args.shift();
|
|
256
|
-
if (!["status", "start", "deliver", "handover", "drain", "recover"].includes(action)) throw Error("Usage: keel codex status|start|deliver|handover|drain|recover [--socket path] [--role name] [--repo path] [--thread id] [--timeout ms] [--json]");
|
|
301
|
+
if (!["list", "status", "start", "deliver", "handover", "drain", "recover"].includes(action)) throw Error("Usage: keel codex list|status|start|deliver|handover|drain|recover [--socket path] [--role name] [--repo path] [--thread id] [--timeout ms] [--json]");
|
|
257
302
|
const options = {socket: path.join(process.env.CODEX_HOME || path.join(os.homedir(), ".codex"), "app-server-control/app-server-control.sock"), timeout: 5000, repo: process.cwd()};
|
|
258
303
|
let explicitSocket = false;
|
|
259
304
|
let explicitTimeout = false;
|
|
260
305
|
while (args.length) {
|
|
261
306
|
const flag = args.shift();
|
|
307
|
+
if (action === "list" && !["--repo", "--json"].includes(flag)) throw Error("Usage: keel codex list [--repo path] [--json]");
|
|
262
308
|
if (flag === "--json") options.json = true;
|
|
263
309
|
else if (flag === "--observe") options.observe = true;
|
|
264
310
|
else if (["--socket", "--thread", "--timeout", "--role", "--repo", "--record", "--text", "--note", "--approvals-reviewer"].includes(flag)) {
|
|
@@ -279,6 +325,11 @@ async function run(args) {
|
|
|
279
325
|
if (!Number.isInteger(ms) || ms < 50 || ms > 60000) throw Error("timeout must be 50–60000 milliseconds");
|
|
280
326
|
const fs = require("node:fs");
|
|
281
327
|
const store = require("./chat/store");
|
|
328
|
+
if (action === "list") {
|
|
329
|
+
const roles = listManagedRoles(store.requireLocation(path.resolve(options.repo)));
|
|
330
|
+
process.stdout.write(JSON.stringify({roles}) + "\n");
|
|
331
|
+
return 0;
|
|
332
|
+
}
|
|
282
333
|
if (action === "drain") {
|
|
283
334
|
const deliveries = await wakeManaged(store.requireLocation(path.resolve(options.repo)), options.role);
|
|
284
335
|
process.stdout.write(JSON.stringify({deliveries}) + "\n");
|
|
@@ -312,6 +363,7 @@ async function run(args) {
|
|
|
312
363
|
: `Codex delivery ${receipt.record}: ${receipt.state}${receipt.thread ? ` (thread ${receipt.thread})` : ""}${suffix}`) + "\n");
|
|
313
364
|
return 0;
|
|
314
365
|
}
|
|
366
|
+
let priorReceipt;
|
|
315
367
|
if (action === "start" && !options.role) throw Error("start needs --role");
|
|
316
368
|
if (["deliver", "handover", "recover"].includes(action)) {
|
|
317
369
|
if (!recorded) throw Error("operation needs a managed --role");
|
|
@@ -322,7 +374,11 @@ async function run(args) {
|
|
|
322
374
|
// The durable decision must be read under the lock this call now owns.
|
|
323
375
|
recorded = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
324
376
|
if (recorded.state !== "managed" || recorded.role !== options.role || recorded.worktree !== where.worktree || recorded.socket !== options.socket) throw Error("managed role identity changed before operation lock");
|
|
325
|
-
if (action === "deliver"
|
|
377
|
+
if (action === "deliver") {
|
|
378
|
+
if (!options.record || !options.text) throw Error("deliver needs --record and --text");
|
|
379
|
+
priorReceipt = deliveryReceipt(recorded, options.record);
|
|
380
|
+
if (priorReceipt.state === "unknown") throw Error("delivery outcome unknown; claim retained, no retry started");
|
|
381
|
+
}
|
|
326
382
|
if (action === "handover" && !options.note) throw Error("handover needs --note");
|
|
327
383
|
}
|
|
328
384
|
if (action === "start") {
|
|
@@ -393,14 +449,8 @@ async function run(args) {
|
|
|
393
449
|
let thread = (await client.call("thread/read", {threadId: recorded.thread, includeTurns: false})).thread;
|
|
394
450
|
const owned = value => value && value.id === recorded.thread && value.cwd === recorded.worktree;
|
|
395
451
|
if (!owned(thread)) throw Error("managed role identity mismatch");
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
if (action === "deliver" && claims[key]) {
|
|
399
|
-
// Deduplication is a recorded outcome, not a reason to load a thread.
|
|
400
|
-
if (claims[key].state !== "delivered" || typeof claims[key].turn !== "string" || !claims[key].turn) {
|
|
401
|
-
throw Error("delivery outcome unknown; claim retained, no retry started");
|
|
402
|
-
}
|
|
403
|
-
Object.assign(result, {state: "already-delivered", turn: claims[key].turn});
|
|
452
|
+
if (priorReceipt?.state === "delivered") {
|
|
453
|
+
Object.assign(result, {state: "already-delivered", turn: priorReceipt.turn});
|
|
404
454
|
} else {
|
|
405
455
|
if (action === "deliver" && thread.status && (thread.status.type === "notLoaded" || ((recorded.approvalsReviewer || savedPolicy) && thread.status.type === "idle"))) {
|
|
406
456
|
// Only this recorded owned identity may be loaded. Keep this same
|
|
@@ -421,6 +471,8 @@ async function run(args) {
|
|
|
421
471
|
if (thread.status.type === "active") {
|
|
422
472
|
Object.assign(result, {state: "waiting", thread: recorded.thread});
|
|
423
473
|
} else if (action === "deliver") {
|
|
474
|
+
const claims = recorded.deliveries ?? {};
|
|
475
|
+
const key = deliveryKey(options.record);
|
|
424
476
|
claims[key] = {record: options.record, state: "pending", thread: recorded.thread};
|
|
425
477
|
let prompt = options.text;
|
|
426
478
|
if (require("./managed-task-result").currentTodo(where, recorded, options.record)) {
|