Skip to content

test(agents): pin the delivery.details pass-through nothing was testing - #988

Merged
lilyshen0722 merged 1 commit into
mainfrom
test/delivery-details-channel
Aug 18, 2026
Merged

lilyshen0722 merged 1 commit into
mainfrom
test/delivery-details-channel

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

Follow-up I owed the pod after #981, kept separate because it is backend and #981 is CLI-only.

What is unguarded

normalizeDeliveryMeta (agentEventService.ts:576) whitelists outcome, reason and messageId, and passes details through as an opaque object into a Schema.Types.Mixed field.

That pass-through is the only way a wrapper attaches structured context to an ack without a schema migration. #981 uses it to record which cascade settings produced a refusal, so "which cap was this seat running" becomes a group-by on rows that already persist, rather than a boot log nobody keeps and nothing joins to the events it caused.

There was no test for this function at all.

Why the regression is quiet

Tightening the whitelist to rebuild the object key by key — the natural cleanup for someone reading this function cold — drops details. The ack still returns 200. The row still persists. Every suite stays green. The instrument just goes dark, and the next person to query it concludes the wrappers never sent anything.

Verified by making exactly that edit locally: two of these four tests go red against it.

Test design notes

  • Identity, not just equality. expect(meta.details).toBe(details) — a whitelist that rebuilds details field by field satisfies toEqual today and drops whatever a caller adds tomorrow.
  • The non-object case carries its own positive control. An assertion that something is dropped is satisfied by a version that drops everything — which is the regression itself — so the same test also asserts a valid object survives the same call shape.
  • The outcome-fallback test is a control of the other kind. This function does normalise, so the pass-through is a deliberate exception rather than an absence of validation. A version that validated nothing would satisfy the details tests and fail that one.
  • reason is asserted verbatim because the wrapper's stand-down gate matches it with === (cli/src/commands/agent.js:1111); unlike outcome, it must not be normalised.

No production code changes.

🤖 Generated with Claude Code

`normalizeDeliveryMeta` whitelists outcome/reason/messageId and passes
`details` through as an opaque object into a Schema.Types.Mixed field.
That pass-through is the only way a wrapper attaches structured context to
an ack without a schema migration — #981 uses it to record which cascade
settings produced a refusal, so "which cap did this seat run" becomes a
query instead of a boot log nobody keeps.

Nothing exercised it. There was no test for this function at all.

The regression it guards is quiet by construction: tightening the
whitelist to rebuild the object key by key drops `details`, the ack still
succeeds, the row still persists, every suite stays green, and the
instrument goes dark. Verified by simulating exactly that edit — two of
these four go red against it.

Includes the identity assertion, not just equality: a whitelist that
rebuilds `details` field by field passes toEqual today and drops whatever
a caller adds tomorrow.

The non-object case carries its own positive control. An assertion that
something is dropped is satisfied by a version that drops everything —
which is the regression itself — so it also asserts a valid object
survives the same call shape. The outcome-fallback test is a control of
the other kind: this function does normalise, so the pass-through is a
deliberate exception rather than an absence of validation, and a version
that validated nothing would satisfy the details tests and fail that one.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@lilyshen0722
lilyshen0722 merged commit 80ddc27 into main Aug 18, 2026
11 checks passed
@lilyshen0722
lilyshen0722 deleted the test/delivery-details-channel branch August 18, 2026 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant