@ouro.bot/cli 0.1.0-alpha.1151 → 0.1.0-alpha.1153

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/changelog.json CHANGED
@@ -1,6 +1,18 @@
1
1
  {
2
2
  "_note": "This changelog is maintained as part of the PR/version-bump workflow. Agent-curated, not auto-generated. Agents read this file directly via read_file to understand what changed between versions.",
3
3
  "versions": [
4
+ {
5
+ "version": "0.1.0-alpha.1153",
6
+ "changes": [
7
+ "Releases no longer fail when npm lists a fresh version before it serves the version's tarball. The release check and the GitHub release step now wait, for up to about 20 minutes, for npm to serve that exact version's tarball, so each release still reaches npm and gets the GitHub release that hosts without npm access update from. 0.1.0-alpha.1151 hit this: npm still returned 404 for its tarball ten minutes after publishing it."
8
+ ]
9
+ },
10
+ {
11
+ "version": "0.1.0-alpha.1152",
12
+ "changes": [
13
+ "Let an agent land an external-event disposition it already investigated."
14
+ ]
15
+ },
4
16
  {
5
17
  "version": "0.1.0-alpha.1151",
6
18
  "changes": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.1151",
2
+ "runtimeVersion": "0.1.0-alpha.1153",
3
3
  "bundleSchemaVersion": 3,
4
4
  "lastUpdated": "2026-09-03T00:00:00.000Z"
5
5
  }
@@ -1,7 +1,7 @@
1
1
  <?xml version="1.0"?>
2
2
  <Container version="2">
3
3
  <Name>ouro-butler</Name>
4
- <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1151</Repository>
4
+ <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1153</Repository>
5
5
  <Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
6
6
  <Network>host</Network>
7
7
  <Shell>sh</Shell>
@@ -1310,10 +1310,51 @@ function validateDisposition(disposition) {
1310
1310
  assertBoundedText(disposition.ownerMessage.effectKey, "owner message key", 1_024);
1311
1311
  }
1312
1312
  }
1313
+ /**
1314
+ * The canonical prefix of an execution lease for a receipt:
1315
+ * `external-event:<agent>:<source>:<eventId>:generation:<N>:attempt:`.
1316
+ *
1317
+ * The attempt number is deliberately left off the comparison. A lease handed to a later attempt of
1318
+ * the SAME generation must not block the turn that is still working on it, while a lease for
1319
+ * another receipt or another generation must never be able to disposition this one. Comparing the
1320
+ * prefix against the receipt's own identity avoids parsing the owner at all, so an event id that
1321
+ * contains a colon cannot be misread.
1322
+ */
1323
+ function leaseOwnerPrefix(record) {
1324
+ return `external-event:${record.agent}:${record.source}:${record.eventId}:generation:${record.generation}:attempt:`;
1325
+ }
1313
1326
  function commitExternalEventDisposition(recordPath, input) {
1314
1327
  return withRecordLock(recordPath, () => {
1315
1328
  const record = readExternalEventRecord(recordPath);
1316
- assertClaim(record, input);
1329
+ // The disposition records the agent's classification of the generation it investigated, so it
1330
+ // has to survive the execution lease being released, expired, or handed to a later attempt of
1331
+ // the same generation while that turn was still working. The generation check and the
1332
+ // one-disposition-per-generation guard below are the safety net; a moved lease is not a reason
1333
+ // to throw away work the agent already did.
1334
+ if (record.generation !== input.expectedGeneration)
1335
+ throw new Error("External event CAS mismatch");
1336
+ // The caller's snapshot can legitimately be stale: the lease heartbeat advances the record
1337
+ // version every few seconds, so the version check is optional and only enforced when given.
1338
+ if (input.expectedVersion !== undefined && record.version !== input.expectedVersion)
1339
+ throw new Error("External event CAS mismatch");
1340
+ // The caller's lease must authorize THIS receipt at THIS generation. Two owner shapes are
1341
+ // accepted, because the owner is an opaque claim token in the general API and a canonical
1342
+ // execution lease in the daemon path:
1343
+ // 1. The exact claim owner the receipt carries right now ("worker-a", "lease-1", ...).
1344
+ // 2. A canonical lease for this receipt at this generation
1345
+ // (`external-event:<agent>:<source>:<eventId>:generation:<N>:attempt:<M>`), whose attempt
1346
+ // number is deliberately not compared: a lease handed to a later attempt of the same
1347
+ // generation is the same piece of work, and a turn routinely outlives its 30s lease.
1348
+ // Anything else is refused — a foreign receipt, another generation, another agent, or a
1349
+ // malformed owner. A released lease must not turn the owner check into a no-op, which is how
1350
+ // an unrelated owner at a matching generation number used to be able to disposition a
1351
+ // receipt it had no lease on.
1352
+ const ownerPrefix = leaseOwnerPrefix(record);
1353
+ const isCanonicalLease = input.owner.startsWith(ownerPrefix) && /^\d+$/u.test(input.owner.slice(ownerPrefix.length));
1354
+ if (!isCanonicalLease && record.claimOwner !== input.owner)
1355
+ throw new Error("External event claim owner mismatch");
1356
+ if (record.disposition != null)
1357
+ throw new Error("External event generation is already dispositioned");
1317
1358
  validateDisposition(input.disposition);
1318
1359
  if (input.disposition.nextWake.kind === "at" && (!input.disposition.awaitId || !Number.isFinite(Date.parse(input.disposition.nextWake.at)))) {
1319
1360
  throw new Error("External event time disposition requires an await receipt");
@@ -90,12 +90,29 @@ function prepareExternalEventDisposition(a, ctx) {
90
90
  : undefined;
91
91
  const expectedGeneration = Number(a.expectedGeneration);
92
92
  const classifiedRevision = String(a.classifiedRevision ?? "");
93
- if (!turnEvent || turnEvent.recordPath !== recordPath || turnEvent.agent !== agentName
94
- || turnEvent.generation !== expectedGeneration || turnEvent.observationRevision !== classifiedRevision
95
- || record.generation !== expectedGeneration || record.observationRevision !== classifiedRevision
96
- || record.executionState !== "running" || record.claimOwner !== turnEvent.claimOwner) {
93
+ // The lease authorizes the turn to classify THIS generation of THIS receipt. It does not have to
94
+ // still be held: the execution lease is short (30s) and a turn that reads evidence and reasons
95
+ // about it routinely outlives it, after which the daemon moves the receipt to retry_wait and
96
+ // clears the claim owner. That must not discard the agent's work, so authorization is checked
97
+ // against the stable identity the lease was minted with — agent, event id, generation and the
98
+ // observation revision handed to this turn — and each mismatch says which field was wrong.
99
+ // The receipt's own observationRevision is deliberately NOT compared: a newer observation can
100
+ // land on the receipt while this generation is still being worked, and the lease revision is
101
+ // the one the agent actually investigated.
102
+ if (!turnEvent)
97
103
  throw new Error("External event disposition is not authorized for this exact turn lease");
98
- }
104
+ if (turnEvent.agent !== agentName || record.agent !== agentName)
105
+ throw new Error("External event receipt does not belong to the current agent");
106
+ if (turnEvent.eventId !== record.eventId)
107
+ throw new Error("External event disposition event id does not match the turn lease");
108
+ if (turnEvent.generation !== expectedGeneration || record.generation !== expectedGeneration)
109
+ throw new Error("External event disposition generation does not match the turn lease");
110
+ if (turnEvent.observationRevision !== classifiedRevision)
111
+ throw new Error("External event disposition revision does not match the exact turn lease");
112
+ if (record.disposition != null)
113
+ throw new Error("External event generation is already dispositioned");
114
+ if (record.executionState === "dead_letter")
115
+ throw new Error("External event receipt is dead-lettered and cannot be dispositioned");
99
116
  const classification = String(a.classification);
100
117
  const decision = String(a.decision);
101
118
  const nextWake = String(a.nextWake);
@@ -197,7 +214,9 @@ function prepareExternalEventDisposition(a, ctx) {
197
214
  }
198
215
  const handled = (0, router_1.commitExternalEventDisposition)(recordPath, {
199
216
  owner: turnEvent.claimOwner,
200
- expectedVersion: record.version,
217
+ // No expectedVersion: the lease heartbeat advances the receipt version every few seconds,
218
+ // so the snapshot taken when the turn started is legitimately stale by commit time. The
219
+ // generation is the durable identity of what the agent investigated.
201
220
  expectedGeneration: record.generation,
202
221
  disposition: {
203
222
  classifiedRevision,
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1151",
3
+ "version": "0.1.0-alpha.1153",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@ouro.bot/cli",
9
- "version": "0.1.0-alpha.1151",
9
+ "version": "0.1.0-alpha.1153",
10
10
  "dependencies": {
11
11
  "@anthropic-ai/sdk": "^0.78.0",
12
12
  "@ouro.bot/friends": "0.1.0-alpha.18",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1151",
3
+ "version": "0.1.0-alpha.1153",
4
4
  "engines": {
5
5
  "node": ">=22"
6
6
  },