@cat-factory/integrations 0.173.1 → 0.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.
@@ -1 +1 @@
1
- {"version":3,"file":"WebhookRunLifecycleSink.d.ts","sourceRoot":"","sources":["../../../src/modules/notificationWebhook/WebhookRunLifecycleSink.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,KAAK,EACL,6BAA6B,EAC7B,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,eAAe,EAChB,MAAM,qBAAqB,CAAA;AAmB5B,MAAM,WAAW,mCAAmC;IAClD,6BAA6B,EAAE,6BAA6B,CAAA;IAC5D,YAAY,EAAE,YAAY,CAAA;IAC1B,KAAK,EAAE,KAAK,CAAA;IACZ,oFAAoF;IACpF,SAAS,CAAC,EAAE,OAAO,KAAK,CAAA;IACxB,yFAAyF;IACzF,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACrC,8FAA8F;IAC9F,eAAe,CAAC,EAAE,eAAe,CAAA;IACjC;;;;OAIG;IACH,OAAO,CAAC,EAAE,CACR,KAAK,EAAE,OAAO,EACd,OAAO,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,KAC/E,IAAI,CAAA;CACV;AAED,qBAAa,uBAAwB,YAAW,gBAAgB;IAClD,OAAO,CAAC,QAAQ,CAAC,IAAI;IAAjC,YAA6B,IAAI,EAAE,mCAAmC,EAAI;IAEpE,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAYlF;YAEa,IAAI;CA0CnB"}
1
+ {"version":3,"file":"WebhookRunLifecycleSink.d.ts","sourceRoot":"","sources":["../../../src/modules/notificationWebhook/WebhookRunLifecycleSink.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,KAAK,EACL,6BAA6B,EAC7B,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,eAAe,EAChB,MAAM,qBAAqB,CAAA;AAmB5B,MAAM,WAAW,mCAAmC;IAClD,6BAA6B,EAAE,6BAA6B,CAAA;IAC5D,YAAY,EAAE,YAAY,CAAA;IAC1B,KAAK,EAAE,KAAK,CAAA;IACZ,oFAAoF;IACpF,SAAS,CAAC,EAAE,OAAO,KAAK,CAAA;IACxB,yFAAyF;IACzF,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACrC,8FAA8F;IAC9F,eAAe,CAAC,EAAE,eAAe,CAAA;IACjC;;;;OAIG;IACH,OAAO,CAAC,EAAE,CACR,KAAK,EAAE,OAAO,EACd,OAAO,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,KAC/E,IAAI,CAAA;CACV;AAyBD,qBAAa,uBAAwB,YAAW,gBAAgB;IAClD,OAAO,CAAC,QAAQ,CAAC,IAAI;IAAjC,YAA6B,IAAI,EAAE,mCAAmC,EAAI;IAEpE,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAYlF;YAEa,IAAI;CAgDnB"}
@@ -1,4 +1,26 @@
1
1
  import { fanOutSignedWebhook } from './signedDelivery.js';
2
+ /**
3
+ * The delivery's dedupe key: `<runId>:<event>`, plus the step index AND its attempt on the one
4
+ * event a run emits repeatedly.
5
+ *
6
+ * BOTH halves of the step's identity, because the index alone is not one. A run re-runs a step in
7
+ * place: a companion bounces its producer for rework, a human-test gate rewinds to its upstream
8
+ * `deployer`, a `request-changes` loops a range. Each of those settles the same index again, so on
9
+ * the index alone a receiver following the family's mandatory `deliveryId` dedupe discards every
10
+ * re-completion, so a three-cycle rework loop arrives as one step boundary. The attempt is what
11
+ * keeps each boundary its own delivery while a durable REPLAY of one settle, which reports the same
12
+ * attempt, still collapses.
13
+ *
14
+ * Keyed off the event's own `step` rather than off its NAME, so the discriminator and the payload
15
+ * cannot disagree: a `run.step_completed` projected with no step would otherwise produce
16
+ * `…:run.step_completed:undefined` for every step of the run, collapsing them all onto one key at
17
+ * the receiver. Falling back to the run-scoped key is the honest answer there, and the engine's
18
+ * projection never takes it.
19
+ */
20
+ function stepScopedDeliveryId(event) {
21
+ const base = `${event.runId}:${event.event}`;
22
+ return event.step ? `${base}:${event.step.index}:${event.step.attempt}` : base;
23
+ }
2
24
  export class WebhookRunLifecycleSink {
3
25
  deps;
4
26
  constructor(deps) {
@@ -26,11 +48,16 @@ export class WebhookRunLifecycleSink {
26
48
  if (endpoints.length === 0)
27
49
  return;
28
50
  const body = {
29
- // `<runId>:<event>` stable across retries AND across a re-delivery, so it is the dedupe
30
- // key a receiver uses. Delivery is at-least-once by design (see the contract doc), and the
31
- // key has to carry that job alone: `sentAt` below and the projection's `occurredAt` are
51
+ // `<runId>:<event>`, stable across retries AND across a re-delivery, so it is the dedupe key
52
+ // a receiver uses. Delivery is at-least-once by design (see the contract doc), and the key
53
+ // has to carry that job alone: `sentAt` below and the projection's `occurredAt` are
32
54
  // re-stamped on a replay, so a receiver hashing the BODY would not collapse the repeat.
33
- deliveryId: `${event.runId}:${event.event}`,
55
+ //
56
+ // The STEP INDEX and its ATTEMPT join it on `run.step_completed`, because that is the one
57
+ // event a single run emits more than once: without the index every step of a run would
58
+ // dedupe onto the first one delivered, and without the attempt every re-run of one step
59
+ // would dedupe onto that step's first cycle.
60
+ deliveryId: stepScopedDeliveryId(event),
34
61
  sentAt: this.deps.clock.now(),
35
62
  workspaceId,
36
63
  event: event.event,
@@ -44,6 +71,7 @@ export class WebhookRunLifecycleSink {
44
71
  occurredAt: event.occurredAt,
45
72
  pullRequestUrl: event.pullRequestUrl,
46
73
  failure: event.failure,
74
+ step: event.step,
47
75
  },
48
76
  };
49
77
  await fanOutSignedWebhook(this.deps, endpoints, { payload: JSON.stringify(body), sentAt: body.sentAt }, (error, target) => this.deps.onError?.(error, {
@@ -1 +1 @@
1
- {"version":3,"file":"WebhookRunLifecycleSink.js","sourceRoot":"","sources":["../../../src/modules/notificationWebhook/WebhookRunLifecycleSink.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAuCzD,MAAM,OAAO,uBAAuB;IACL,IAAI;IAAjC,YAA6B,IAAyC;oBAAzC,IAAI;IAAwC,CAAC;IAE1E,KAAK,CAAC,eAAe,CAAC,WAAmB,EAAE,KAAwB;QACjE,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,CAAA;QACrC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,0FAA0F;YAC1F,6EAA6E;YAC7E,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE;gBACzB,WAAW;gBACX,KAAK,EAAE,KAAK,CAAC,KAAK;gBAClB,KAAK,EAAE,KAAK,CAAC,KAAK;aACnB,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,IAAI,CAAC,WAAmB,EAAE,KAAwB;QAC9D,MAAM,SAAS,GAAG,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,6BAA6B,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM;QACxF,uFAAuF;QACvF,6FAA6F;QAC7F,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CACxE,CAAA;QACD,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;YAAE,OAAM;QAElC,MAAM,IAAI,GAAuB;YAC/B,0FAA0F;YAC1F,2FAA2F;YAC3F,wFAAwF;YACxF,wFAAwF;YACxF,UAAU,EAAE,GAAG,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,EAAE;YAC3C,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE;YAC7B,WAAW;YACX,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,GAAG,EAAE;gBACH,KAAK,EAAE,KAAK,CAAC,KAAK;gBAClB,MAAM,EAAE,KAAK,CAAC,MAAM;gBACpB,SAAS,EAAE,KAAK,CAAC,SAAS;gBAC1B,UAAU,EAAE,KAAK,CAAC,UAAU;gBAC5B,YAAY,EAAE,KAAK,CAAC,YAAY;gBAChC,SAAS,EAAE,KAAK,CAAC,SAAS;gBAC1B,UAAU,EAAE,KAAK,CAAC,UAAU;gBAC5B,cAAc,EAAE,KAAK,CAAC,cAAc;gBACpC,OAAO,EAAE,KAAK,CAAC,OAAO;aACvB;SACF,CAAA;QACD,MAAM,mBAAmB,CACvB,IAAI,CAAC,IAAI,EACT,SAAS,EACT,EAAE,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,EACtD,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CAChB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE;YACzB,WAAW;YACX,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,SAAS,EAAE,MAAM,CAAC,EAAE;SACrB,CAAC,CACL,CAAA;IACH,CAAC;CACF"}
1
+ {"version":3,"file":"WebhookRunLifecycleSink.js","sourceRoot":"","sources":["../../../src/modules/notificationWebhook/WebhookRunLifecycleSink.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAuCzD;;;;;;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2FAA2F;YAC3F,oFAAoF;YACpF,wFAAwF;YACxF,EAAE;YACF,0FAA0F;YAC1F,uFAAuF;YACvF,wFAAwF;YACxF,6CAA6C;YAC7C,UAAU,EAAE,oBAAoB,CAAC,KAAK,CAAC;YACvC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE;YAC7B,WAAW;YACX,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,GAAG,EAAE;gBACH,KAAK,EAAE,KAAK,CAAC,KAAK;gBAClB,MAAM,EAAE,KAAK,CAAC,MAAM;gBACpB,SAAS,EAAE,KAAK,CAAC,SAAS;gBAC1B,UAAU,EAAE,KAAK,CAAC,UAAU;gBAC5B,YAAY,EAAE,KAAK,CAAC,YAAY;gBAChC,SAAS,EAAE,KAAK,CAAC,SAAS;gBAC1B,UAAU,EAAE,KAAK,CAAC,UAAU;gBAC5B,cAAc,EAAE,KAAK,CAAC,cAAc;gBACpC,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,IAAI,EAAE,KAAK,CAAC,IAAI;aACjB;SACF,CAAA;QACD,MAAM,mBAAmB,CACvB,IAAI,CAAC,IAAI,EACT,SAAS,EACT,EAAE,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,EACtD,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CAChB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE;YACzB,WAAW;YACX,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,SAAS,EAAE,MAAM,CAAC,EAAE;SACrB,CAAC,CACL,CAAA;IACH,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cat-factory/integrations",
3
- "version": "0.173.1",
3
+ "version": "0.174.0",
4
4
  "description": "External-system integration domain logic for the Agent Architecture Board (GitHub, documents, tasks, environments, runners).",
5
5
  "repository": {
6
6
  "type": "git",
@@ -24,15 +24,15 @@
24
24
  "access": "public"
25
25
  },
26
26
  "dependencies": {
27
- "@cat-factory/contracts": "0.353.0",
28
- "@cat-factory/kernel": "0.346.1",
27
+ "@cat-factory/contracts": "0.355.0",
28
+ "@cat-factory/kernel": "0.347.0",
29
29
  "ai": "^7.0.93",
30
30
  "p-map": "^7.0.7",
31
31
  "undici": "^8.10.2",
32
32
  "yaml": "^2.9.0"
33
33
  },
34
34
  "devDependencies": {
35
- "@cat-factory/caching": "0.20.83",
35
+ "@cat-factory/caching": "0.20.85",
36
36
  "typescript": "7.0.2",
37
37
  "valibot": "^1.4.2",
38
38
  "vitest": "^4.1.11"