@christang/keel 5.231.12 → 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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keel",
3
- "version": "5.231.12",
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,4 +1,4 @@
1
- <!-- keel:start version=5.231.12 -->
1
+ <!-- keel:start version=5.231.13 -->
2
2
  ## Keel Bootstrap
3
3
 
4
4
  - Start every session with `keel context`; OpenSpec artifacts and Git are the durable authority, and memory or transcripts may only inform.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@christang/keel",
3
- "version": "5.231.12",
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.12",
9
+ "version": "5.231.13",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@fission-ai/openspec": "1.14.0"
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.231.12",
5
+ "version": "5.231.13",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keel",
3
- "version": "5.231.12",
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.12",
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",
@@ -66,6 +66,50 @@ test('list managed roles offline without draining or changing the shared mailbox
66
66
  assert.equal(connections, 0);
67
67
  });
68
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
+
69
113
  test('managed CLI lifecycle, mailbox scheduling and frame boundaries',async()=>{
70
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;
71
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.12"
38
+ PACKAGE_VERSION = "5.231.13"
39
39
 
40
40
 
41
- PROTOCOL_VERSION = "5.231.12"
41
+ PROTOCOL_VERSION = "5.231.13"
42
42
 
43
43
 
44
44
  LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
@@ -123,11 +123,17 @@ function deliveryKey(record) {
123
123
  }
124
124
 
125
125
  function deliveryReceipt(role, record) {
126
- const claim = role.deliveries?.[deliveryKey(record)];
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 = !claim ? "unrecorded" : turn ? "delivered" : "unknown";
136
+ const state = turn ? "delivered" : present ? "unknown" : "unrecorded";
131
137
  return { role: role.role, record, state, thread, turn };
132
138
  }
133
139
 
@@ -357,6 +363,7 @@ async function run(args) {
357
363
  : `Codex delivery ${receipt.record}: ${receipt.state}${receipt.thread ? ` (thread ${receipt.thread})` : ""}${suffix}`) + "\n");
358
364
  return 0;
359
365
  }
366
+ let priorReceipt;
360
367
  if (action === "start" && !options.role) throw Error("start needs --role");
361
368
  if (["deliver", "handover", "recover"].includes(action)) {
362
369
  if (!recorded) throw Error("operation needs a managed --role");
@@ -367,7 +374,11 @@ async function run(args) {
367
374
  // The durable decision must be read under the lock this call now owns.
368
375
  recorded = JSON.parse(fs.readFileSync(file, "utf8"));
369
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");
370
- if (action === "deliver" && (!options.record || !options.text)) throw Error("deliver needs --record and --text");
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
+ }
371
382
  if (action === "handover" && !options.note) throw Error("handover needs --note");
372
383
  }
373
384
  if (action === "start") {
@@ -438,14 +449,8 @@ async function run(args) {
438
449
  let thread = (await client.call("thread/read", {threadId: recorded.thread, includeTurns: false})).thread;
439
450
  const owned = value => value && value.id === recorded.thread && value.cwd === recorded.worktree;
440
451
  if (!owned(thread)) throw Error("managed role identity mismatch");
441
- const claims = recorded.deliveries || {};
442
- const key = options.record ? deliveryKey(options.record) : null;
443
- if (action === "deliver" && claims[key]) {
444
- // Deduplication is a recorded outcome, not a reason to load a thread.
445
- if (claims[key].state !== "delivered" || typeof claims[key].turn !== "string" || !claims[key].turn) {
446
- throw Error("delivery outcome unknown; claim retained, no retry started");
447
- }
448
- 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});
449
454
  } else {
450
455
  if (action === "deliver" && thread.status && (thread.status.type === "notLoaded" || ((recorded.approvalsReviewer || savedPolicy) && thread.status.type === "idle"))) {
451
456
  // Only this recorded owned identity may be loaded. Keep this same
@@ -466,6 +471,8 @@ async function run(args) {
466
471
  if (thread.status.type === "active") {
467
472
  Object.assign(result, {state: "waiting", thread: recorded.thread});
468
473
  } else if (action === "deliver") {
474
+ const claims = recorded.deliveries ?? {};
475
+ const key = deliveryKey(options.record);
469
476
  claims[key] = {record: options.record, state: "pending", thread: recorded.thread};
470
477
  let prompt = options.text;
471
478
  if (require("./managed-task-result").currentTodo(where, recorded, options.record)) {