Skip to content

test(executorrpc): add an in-memory executor for the Files and Commands services - #2855

Merged
blkt merged 1 commit into
mainfrom
feat/2691-inmem-executor
Nov 18, 2026
Merged

blkt merged 1 commit into
mainfrom
feat/2691-inmem-executor

Conversation

@blkt

@blkt blkt commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Summary

A test-only in-memory executor, so each work stream can test against the executor contract without a real executor.

  • internal/executorrpc/memexecutor.Dial serves FileService and CommandService on one bufconn listener and returns a client connection. A nil service in Executor stays unregistered and answers Unimplemented.
  • Files reuses fileserver from feat(executorrpc): serve FileService from mecatl-executor serve #2853 over a memfs workspace, with memfs.ErrPathEscape registered as a path-escape error. Executor.FileOptions passes fileserver options through.
  • Commands is a scripted Runner behind the real commandserver.Server, so the call protocol is the production one. Script(cmd, fn) and Refuse(cmd, err) set up commands; helpers Exit, Stream, Block and OutcomeUnknown cover output streaming, blocking until cancelled, and an exit whose cleanup is unconfirmed. Running() reports scripts still running.
  • The package imports testing (like commandconformance) and stays inside the existing internal-executorrpc depguard allowlist.

Issue relationship

Closes #2691

Stacked on #2853 (#2694), which is stacked on #2832 (#2770); retarget to main once those merge.

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Dependency update
  • Documentation
  • Other (describe): test-only infrastructure

Test plan

Baseline checks

  • Linting (task lint)
  • Fast offline test suite (task test): covered by task test:race
  • Pre-review race suite (task test:race)
  • Offline demo (go run ./cmd/mecademo): tool call, permission ask and approval, and result; the demo doesn't use this package
  • Markdown changed: docs generation/link checks (task docs)
  • User docs/user-facing behavior changed: site build (task site:build)
  • Guarded engine API affected: compatibility check (task api:check)
  • Intentional engine API change: task api:update + engine/CHANGELOG.md

Also run: go test -race -count=10 ./internal/executorrpc/memexecutor/. Acceptance criteria:

  • TestFileServiceConformance runs fileconformance.Run (fsconformance Run, RunNamespace, RunMutationAffinity, RunExternalMutationConflict) through Dial, with the memfs workspace as the external actor.
  • TestCommandServiceConformance runs commandconformance.Run against the scripted runner. Further tests cover chunks streamed before exit, closing the call cancelling the script and returning Running() to 0, OUTCOME_UNKNOWN on a normal exit and after CancelCommand, and refused or unscripted commands never starting.
  • TestPathEscapeIsReported fails if the memfs.ErrPathEscape mapping is removed; fileconformance alone doesn't notice.
  • Nothing under engine/, fileserver or fileconformance changes.

task check:pr fails only on buf breaking against main, from the streaming RPCs in #2832; it clears once #2832 merges.

Changes

File Change
internal/executorrpc/memexecutor/memexecutor.go Executor and Dial
internal/executorrpc/memexecutor/commands.go Scripted Runner and script helpers
internal/executorrpc/memexecutor/commands_test.go commandconformance and Commands fake tests
internal/executorrpc/memexecutor/files_test.go fileconformance through Dial, path escape, unregistered service

User-facing change

None.

Special notes for reviewers

  • commandconformance's background-child scenarios pass trivially here: the fake has no child process, so they only prove the script saw its context end. Real child cleanup stays covered by commandserver against the real supervisor.
  • Every fileconformance read is a single message, because fileserver fixes the read chunk at 3 MiB and the suite uses small files. A multi-message conformance run would need a chunk-size option in fileserver; it was left out of scope.

@blkt
blkt added this pull request to stack #2854 November 17, 2026 22:12
@blkt blkt self-assigned this Nov 18, 2026
@blkt
blkt marked this pull request as ready for review November 18, 2026 08:12
@blkt
blkt force-pushed the feat/2691-inmem-executor branch from 611f8dc to adb1696 Compare November 18, 2026 09:03

@rdimitrov rdimitrov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Reusing the real fileserver/commandserver behind memfs and a scripted Runner keeps the fake on the production protocol, and the helpers cover the streaming, cancellation and unconfirmed-exit cases the work streams need. The notes on trivially-passing background-child scenarios and single-message reads are reasonable scope limits.

@blkt
blkt force-pushed the feat/2691-inmem-executor branch from adb1696 to 9cdbe20 Compare November 18, 2026 09:50
Base automatically changed from feat/2694-files-server to main November 18, 2026 10:06
…ds services

`memexecutor.Dial` serves `fileserver` over a `memfs` workspace and `commandserver` over a scripted `Runner` on one in-process listener, leaving a nil service unregistered. Tests run `fileconformance` and `commandconformance` through it and cover streaming, cancellation on call close, and unknown outcomes.

Closes #2691
@blkt
blkt force-pushed the feat/2691-inmem-executor branch from 9cdbe20 to 066b8f5 Compare November 18, 2026 10:06
@blkt
blkt enabled stacked auto-merge (squash) November 18, 2026 10:06
@blkt
blkt merged commit 3a9c4e0 into main Nov 18, 2026
43 checks passed
@blkt
blkt deleted the feat/2691-inmem-executor branch November 18, 2026 10:23
@blkt blkt mentioned this pull request Nov 18, 2026
@toolhive-release-app toolhive-release-app Bot mentioned this pull request Nov 18, 2026
2 tasks
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.

In-memory implementation of Files and Commands

2 participants