Handle batched code mode tail events - #211
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
There was a problem hiding this comment.
Pull request overview
This PR updates the Workshop backend’s code-mode Tail loopback handling to tolerate a specific, known-valid batched trace delivery pattern (verify() and run() arriving together), ensuring the run() trace is preserved while malformed batches still fail closed.
Changes:
- Special-case
[verify, run]2-event trace batches by keeping only theruntrace before applying the existing singleton validation. - Add a regression test covering the valid
[verify, run]batch and several malformed batch shapes.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/workshop-backend/src/overseer.ts | Adds a targeted special-case to preserve run() traces when batched with verify() while retaining strict validation for other batches. |
| packages/workshop-backend/tests/code-mode-tail.test.ts | Adds a regression test ensuring [verify, run] delivers exactly one run trace and malformed batches deliver none. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| const methods = events.map(event => event.event && "rpcMethod" in event.event | ||
| ? event.event.rpcMethod : undefined); | ||
| if (events.length === 2 && methods.includes("verify") && methods.includes("run")) { | ||
| events = [events[methods.indexOf("run")]]; | ||
| } |
There was a problem hiding this comment.
Replaced map/includes/indexOf with an explicit two-element check. It derives the two rpcMethod values directly and selects the run item for the verify/run pair while leaving every other batch on the existing fail-closed path.
|
Have you actually observed a problem here in practice? As far as I know, the "verify" and "run" events will never be batched in the way that this PR seems to be trying to handle, and I've never observed this happening myself nor can I find any evidence in our logs. |
|
No — I did not capture a production |
What does this change?
Part of #209.
When a code-mode Tail batch consists of exactly one
verify()and onerun(), keeps the run tracebefore applying the existing exactly-one-event validation. This avoids discarding the valid run
output while all other unexpected batches still fail closed.
Why is this obviously correct and trivially verifiable?
The special case requires exactly two events and both expected RPC method names. The existing
singleton validation and single-verify early return remain unchanged for every other case. The
regression test asserts one delivery for
[verify, run]and no delivery for malformed batches.No bindings, authorization, or execution policy changes.
Verification: focused RED/GREEN reproduction, Workshop unit tests (285/285), integration tests
(2 passed, 4 existing skips), Workshop build/typecheck, full repository tests and lint, and
git diff --checkall pass on Node 24.Checklist