Skip to content

refactor(execution_engine): drop unnecessary Mutex around EngineLookup, fix JS runner error message - #83

Merged
jhamill34 merged 1 commit into
mainfrom
claude/fix-engine-lookup-mutex
Aug 26, 2026
Merged

refactor(execution_engine): drop unnecessary Mutex around EngineLookup, fix JS runner error message#83
jhamill34 merged 1 commit into
mainfrom
claude/fix-engine-lookup-mutex

Conversation

@jhamill34

Copy link
Copy Markdown
Owner

What changed

Two distinct fixes from issue #16, both in usecases/execution_engine:

1. Drop the unnecessary Mutex around EngineLookup

EngineLookup's methods (get_service, get_credentials) only take &self — there's no mutation in the trait's contract. The Mutex wrapping it in Engine (Arc<Mutex<dyn EngineLookup + Send + Sync>>) was unneeded synchronization, inherited from apid's own unrelated mutation needs rather than required by the trait itself. Confirmed storage/in_memory_storage::OperationRepos already implements EngineLookup unlocked (&self-only), proving the lock was purely incidental.

  • Engine.lookup is now Arc<dyn EngineLookup + Send + Sync> (no Mutex).
  • The now-unused error::ExecutionEngine::PoisonedLock variant is removed.
  • apid's OperationRepos is legitimately mutated elsewhere (the background loader), so that lock is preserved but now encapsulated behind a new LockedLookup adapter (binary/apid/src/main.rs) that implements EngineLookup by locking internally — Engine itself no longer needs to know a lock exists.
  • runners/workflow_runner's test fixtures updated to match the new unlocked signature.

2. Fix a copy-paste bug in Engine::run's SimpleCode dispatch

The JAVASCRIPT branch's "runner not found" error incorrectly reported "Code runner not found for python" (copy-pasted from the PYTHON branch). Fixed by factoring the duplicated Python/JS dispatch blocks into one dispatch_code_runner helper parameterized on the language key — this structurally prevents the class of bug (the error message is now generated from the actual lang_key parameter, not a branch-specific hardcoded string).

Closes #16

Test plan

  • Added run_reports_the_correct_language_when_no_javascript_code_runner_is_registered, verified genuine red (reintroduced the "python" bug temporarily, confirmed the test fails for the right reason) before confirming green.
  • cargo build --workspace --all-features — clean.
  • cargo test --workspace --all-features — all green, 0 failures.
  • cargo clippy -p execution_engine -p workflow_runner -p apid --all-targets --all-features — no new errors/warnings introduced.
  • cargo fmt --all -- --check — clean.

Generated by Claude Code

…p, fix JS runner error message

EngineLookup's methods only take &self - there's no mutation - so the
Mutex wrapping it in Engine (and the PoisonedLock error variant it
required) was unneeded synchronization inherited from apid's own
mutation needs, not the trait's contract. apid's OperationRepos is
legitimately mutated elsewhere (background loader), so that lock is
now encapsulated behind a new LockedLookup adapter instead of leaking
into Engine's field type.

Also fixes a copy-paste bug where Engine::run's JAVASCRIPT SimpleCode
dispatch reported "Code runner not found for python" on a missing JS
runner, by factoring the duplicated Python/JS dispatch blocks into one
dispatch_code_runner helper parameterized on the language key.

Closes #16

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019EKR96FrBygNE1sfscQ6CG
@jhamill34
jhamill34 merged commit a92c9d5 into main Aug 26, 2026
5 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.

execution_engine: unnecessary Mutex around a read-only trait, plus a copy-paste bug in the JS runner branch's error message

2 participants