Skip to content

Integration test suite: ThreadPoolExecutor through TraverseRuntime (spec 047) #507

Description

@enricopiovesan

Summary

Write integration tests that wire `ThreadPoolExecutor` through the full `TraverseRuntime` stack — registry, router, placement, trace — and verify end-to-end correctness under concurrent load. These tests live in `crates/traverse-runtime/tests/thread_pool_integration.rs`.

Governing Spec

  • `047-thread-pool-executor`

Blocked by

Test inventory

Drop-in replacement

Test name What it proves
`native_executor_and_thread_pool_produce_identical_output` Same capability, same input — `NativeExecutor` and `ThreadPoolExecutor` return byte-identical `Value` output
`thread_pool_executor_satisfies_capability_executor_trait_object` `Box` can hold a `ThreadPoolExecutor` — compiles and executes

Router integration

Test name What it proves
`router_routes_to_thread_pool_executor` A capability registered with `ArtifactType::Native` and resolved through the placement router executes correctly via pool
`router_concurrent_requests_to_same_capability` 8 concurrent `execute_capability()` calls through the router — all return correct results, no deadlock
`router_concurrent_requests_to_different_capabilities` 4 concurrent calls to 4 distinct capabilities — each receives its own correct output

Trace correctness

Test name What it proves
`concurrent_executions_produce_isolated_traces` 4 concurrent executions produce 4 distinct trace entries — no cross-contamination in `TraceStore`
`trace_capability_id_matches_executed_capability` Trace entry `capability_id` matches the dispatched capability for each concurrent call
`failed_execution_recorded_in_trace` A capability that returns `ExecutorError` produces a trace entry with failure status

Event broker integration

Test name What it proves
`event_published_by_pool_thread_reaches_broker` A capability executing on a pool thread can publish an event; the broker records it
`concurrent_event_publishers_no_broker_corruption` 4 capabilities each publishing 3 events concurrently — broker contains all 12, no duplicates, no data races

Workflow traversal

Test name What it proves
`workflow_with_thread_pool_executor_completes_all_steps` A 3-step workflow using `ThreadPoolExecutor` for native capabilities completes with correct final output
`workflow_step_failure_halts_traversal` A workflow step returning error halts traversal at that step — subsequent steps not executed

WASM path unchanged

Test name What it proves
`wasm_capability_bypasses_thread_pool` A WASM capability registered alongside native capabilities executes via `WasmExecutor` — `ThreadPoolExecutor` is not invoked for it

Definition of Done

  • All 13 tests above exist in `crates/traverse-runtime/tests/thread_pool_integration.rs`
  • All tests pass with `cargo test -p traverse-runtime --test thread_pool_integration`
  • No test uses `unwrap()` or `expect()` in assertion paths
  • Concurrent tests use `std::thread::scope` or equivalent — no `unsafe` thread spawning
  • Trace correctness tests inspect `TraceStore` contents directly after execution
  • WASM path test uses the expedition example WASM binary from `examples/expedition/`
  • `bash scripts/ci/spec_alignment_check.sh` passes
  • PR body declares ````047-thread-pool-executor```` in `## Governing Spec`

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent:codexClaimed by CodexqualityQuality gates, CI, coverage, and engineering standardsreadyReady to implement under an approved governing specruntimeRuntime, execution, state, and trace workspecSpec and planning related work

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions