Skip to content

test(mcp): match HTTP trace rows by request identity - #1335

Merged
yyjeqhc merged 1 commit into
yyjeqhc:mainfrom
skygunner:contrib/mcp-trace-identity-match-20261028
Oct 28, 2026
Merged

yyjeqhc merged 1 commit into
yyjeqhc:mainfrom
skygunner:contrib/mcp-trace-identity-match-20261028

Conversation

@skygunner

Copy link
Copy Markdown
Contributor

Problem

stateless_full_trace_correlates_only_hashed_openai_window located the tools/list ActionAudit row with durable_rows.last(). Trace persistence is asynchronous, so row order is not a stable identifier for that request: any later row for the same Window makes the assertion fail for reasons unrelated to the behavior under test, and the failure message points at the wrong contract.

Change

Test-only. The test now:

  • issues one further unrelated tools/call in the same Window after tools/list, so the tools/list row is no longer expected to be last;
  • matches the row by identity (action_name == "toolsList") and requires exactly one match, reporting the whole row set on failure;
  • keeps every invariant the positional assertion covered (operation mcp_tools_list, window_meaningful == 0, no recorder gap);
  • additionally requires the matched row's trace id to differ from both tools/call trace ids, so a row cannot satisfy the assertion by belonging to another request.

Production logging order and all identity/privacy assertions are unchanged.

Validation

cargo test --locked -p webcodex --lib stateless_full_trace_correlates_only_hashed_openai_window
  -> 1 passed; 3834 filtered out

With the old positional assertion restored (and the interleaved request present), the same test fails:
  assertion failed: left: "toolsCall", right: "toolsList"
  test result: FAILED. 0 passed; 1 failed; 3834 filtered out

This demonstrates the old assumption fails as soon as another request persists after tools/list; the filtered assertion is independent of persistence order. Not run here: Windows/macOS lanes (no environment available).

Trace persistence is asynchronous, so the last persisted row is not a stable identifier for the tools/list request. Match it by action identity, require exactly one match, keep the previous invariants, and cover an interleaved later request.

@yyjeqhc yyjeqhc left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the scoped implementation and regression coverage against its source baseline; CI and diff checks pass. No blocking issue identified.

@yyjeqhc
yyjeqhc merged commit ec1229d into yyjeqhc:main Oct 28, 2026
18 checks passed
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.

2 participants