Skip to content

Commit 082b549

Browse files
agent-relay-code[bot]kjgbot
authored andcommitted
chore: apply pr-reviewer fixes for #148
1 parent f6a9d4e commit 082b549

1 file changed

Lines changed: 24 additions & 5 deletions

File tree

docs/specs/2026-06-07-integration-event-redrive.md

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ on a sibling helper, not hand-subscribe to broker events:
8383
sendMessageAndWaitForInjected(
8484
projectId: string,
8585
input: SendMessageInput,
86-
options?: { timeoutMs?: number }
86+
options?: { timeoutMs?: number; signal?: AbortSignal }
8787
): Promise<{ eventId: string; targets: string[] }>
8888
```
8989

@@ -100,8 +100,16 @@ Semantics:
100100
timeout.
101101
- Target handling matches the existing helper: use returned `targets` when
102102
present; for direct agent sends with no targets, fall back to `[input.to]`.
103-
- Unsupported brokers may return no `eventId` or no targets; the bridge treats
104-
those as accepted-only and commits immediately, preserving current behavior.
103+
- Unsupported brokers may return no usable `event_id`; the bridge treats those as
104+
accepted-only and commits immediately, preserving current behavior. A direct
105+
agent send with no returned targets is not unsupported: it falls back to
106+
`[input.to]` and must still wait for `delivery_injected`. Channel/project
107+
fanout with no concrete targets is the residual case described below.
108+
- Before waiting for `delivery_injected`, BrokerManager should detect support
109+
from broker session metadata, such as an explicit capability flag or the
110+
protocol/version threshold that introduced `delivery_injected`. If the session
111+
is known not to support the signal, return an accepted-only result immediately
112+
and record `deliveryInjectedUnsupported` instead of waiting for timeout.
105113

106114
The helper may internally reuse the current `sendMessageAndWaitForDelivery`
107115
mechanics: send once, capture `event_id` / targets, subscribe internally, filter
@@ -114,6 +122,13 @@ background confirmation task, attach `.then(commit).catch(release)`, and return
114122
from the pacer callback immediately after starting the send attempt. The pacer
115123
rate-limits starts, not confirmation completion.
116124

125+
Background confirmation tasks must be project-scoped and cancellable. The bridge
126+
should keep an `AbortController` per active confirmation task, pass its
127+
`signal` to `sendMessageAndWaitForInjected()`, and abort all pending
128+
confirmations from `close(projectId)` before disposing the pacer. Abort should
129+
release provisional claims without emitting delivery-failure warnings for a
130+
project that is intentionally closing.
131+
117132
Coverage result: relay-worker confirmed `delivery_injected` is emitted for the
118133
agent transports the integration bridge can inject to. Local PTY workers emit it
119134
after writing the injection bytes and carriage return. Headless/app-server
@@ -185,8 +200,10 @@ Behavior:
185200
copies while confirmation is still pending.
186201
- When confirmation times out or fails, the provisional claim is removed. A later
187202
replay of the same logical key/content hash can inject again.
188-
- A blind claim can still learn the first later content hash as in #145, but that
189-
hash stays provisional until delivery is confirmed.
203+
- A blind claim can still learn the first later content hash as in #145. When
204+
the hash is learned, move the existing `blindClaim` into `contentHashes` under
205+
that hash and clear `blindClaim`; the moved claim stays provisional until
206+
delivery is confirmed.
190207
- Genuine edits with new content hashes continue to inject independently.
191208
192209
For non-Slack integration events, the existing recent-injection map becomes the
@@ -264,6 +281,8 @@ Add integration-event bridge tests on top of the existing #145 suite:
264281
`sendMessageAndWaitForDelivery`.
265282
- Unsupported injection confirmation commits accepted sends immediately and
266283
emits low-noise telemetry.
284+
- Project close aborts pending background confirmations, releases provisional
285+
claims, and does not log delivery-failure warnings for the intentional abort.
267286
268287
Add broker tests for relay-worker's helper extension:
269288

0 commit comments

Comments
 (0)