Skip to content

refactor(runtime): split tool invocation pipeline into explicit stages - #1027

Merged
yyjeqhc merged 3 commits into
mainfrom
refactor/tool-invocation-pipeline
Oct 11, 2026
Merged

yyjeqhc merged 3 commits into
mainfrom
refactor/tool-invocation-pipeline

Conversation

@swjnxyf

@swjnxyf swjnxyf commented Oct 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

This refactor separates the two largest tool-invocation control paths into explicit stages without changing the public execution contract.

  • Split the canonical ToolRuntime kernel into dedicated admission and recording stages while keeping dispatch, permission, Session authority, correlation, and post-record projection ordering intact.
  • Split MCP tools/call into parsing, surface admission, specialized gateway dispatch, runtime execution, and response projection modules.
  • Parse the canonical Stateless MCP 2026 _wc envelope directly into typed invocation metadata instead of rebuilding legacy wrapper fields internally.
  • Preserve existing bounds, normalization, validation/error precedence, control-sidecar privacy, adaptive gateway routing, App admission, recorder provenance, and fail-closed behavior.
  • Add focused regression coverage for kernel admission/recording ordering and the invocation-envelope contract.

Review notes

This is intentionally a structural refactor. It does not add a new tool surface, execution authority, retry path, Session inference rule, or durability/replay mechanism.

The review specifically checked that:

  • protocol/App capability checks still happen before recorder/business parsing where required;
  • recording Workflow Sessions remain provenance/evidence only and cannot become business Session authority;
  • cross-Session collaboration still authorizes both ends before comparing Project scope;
  • specialized MCP/Plugin/SSH gateway paths retain their existing routing and error behavior;
  • canonical execution still dispatches exactly once before recording/postprocess stages;
  • model-facing projections, Job/audit correlation, MCP App private metadata, and compact-execution presentation retain their prior ordering;
  • malformed _wc input remains bounded and privacy-safe, with stable error precedence.

Validation

  • cargo fmt --all -- --check
  • git diff --check main...HEAD
  • bash scripts/workspace_boundary_check.sh
  • cargo test --locked --profile dogfood -p webcodex --lib
    • 3462 passed, 0 failed, 10 ignored

I also ran the full library suite with --features experimental-code-mode. It consistently exposes one existing timing-sensitive peer-collaboration test:

tool_runtime::tests::peer_collaboration::ack_required_peer_message_repeats_on_omission_and_current_ack_suppresses_it

The same test passes in isolation, and the exact same full-suite failure was reproduced on the base main commit f00e6236b488df3e47ff0d885b31f0760b0aa1d5 in a clean detached worktree. It is therefore not introduced by this refactor and was not folded into this PR.

No review-fix commit was needed after the structural review.

Parse canonical _wc fields directly into invocation metadata and return typed control parse errors. Preserve wire errors, validation precedence, normalization and bounds; v0.4.6 already rejects legacy top-level invocation fields. Replace obsolete wrapper fixtures with envelope contract regressions.
@yyjeqhc
yyjeqhc force-pushed the refactor/tool-invocation-pipeline branch from b05d95e to c738478 Compare October 11, 2026 05:06
@yyjeqhc
yyjeqhc merged commit f17be19 into main Oct 11, 2026
15 checks passed
@yyjeqhc
yyjeqhc deleted the refactor/tool-invocation-pipeline branch October 11, 2026 05:17
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