Skip to content

feat(engine): make Runtime init lazy for read-only Code/Tooling (#269) - #281

Open
AntoineToussaint wants to merge 1 commit into
mainfrom
issue-269-decouple-read-only-code-tooling-from-runtime-initialization
Open

feat(engine): make Runtime init lazy for read-only Code/Tooling (#269)#281
AntoineToussaint wants to merge 1 commit into
mainfrom
issue-269-decouple-read-only-code-tooling-from-runtime-initialization

Conversation

@AntoineToussaint

Copy link
Copy Markdown
Contributor

Closes #269.

Summary

  • Read-only Code/Tooling calls (ExecuteCode, GetSemanticIndex) now start the production agent without running the Runtime lifecycle. Runtime Load/Init moved out of AgentSupervisor.acquire into a lazy, mutex-guarded ensureRuntime, mirroring the existing initializeBuilder pattern. Only Build/Test/Lint/Stop initialize the runtime, on first use.
  • Runtime-init failures are still wrapped as *agentInitializationError, so Service.Test keeps returning the existing typed env-blocked (runtime-initialization) response.
  • This drops startup latency and, crucially, lets semantic recovery run on malformed projects that would otherwise be blocked by an unready toolchain/environment — supporting Expose per-code-unit semantic projection through the Gateway #268 and codefly-dev/mind#369.

Behavior verified

A new real-agent test (pkg/engine) drives the production python agent against malformed source: GetProjectInfo recovers the module/language and GetSemanticIndex returns a DEGRADED index with a parse_failed issue — both with the runtime never initialized (runtimeOK == false). The first Test then initializes the runtime lazily (runtimeOK == true).

Known coordination (mind#369)

The generic agent (0.0.21, used for jvm/dotnet) still binds its Code source directory during Runtime.Load; without it, its code server only sees the ephemeral service.codefly.yaml and reports language "unknown". Moving that binding to agent startup — the way the python agent already works — is codefly-dev/mind#369. Until a decoupled generic agent is published and sourceworkspace.GenericPluginVersion is bumped past 0.0.21, TestGatewayInspectsJVMAndDotNetCodeUnitsThroughGenericAgent is skipped. The skip is gated on that version constant, so bumping the pin re-enables the proof automatically.

Test plan

  • go test ./pkg/engine/ (incl. new malformed-source decoupling proof)
  • go test ./pkg/gateway/ (python/node runtime proof still green; jvm/dotnet inspection gated on generic-agent bump)
  • go test ./pkg/control/ ./pkg/mcp/
  • go build ./..., go vet ./pkg/engine/ ./pkg/gateway/
  • Full go test ./...

🤖 Generated with Claude Code

…ling (#269)

Read-only Code/Tooling calls (ExecuteCode, GetSemanticIndex) previously
acquired an AgentSession that unconditionally ran Runtime Load/Init, coupling
project inspection to toolchain/environment readiness and blocking semantic
recovery on malformed projects.

Move runtime Load/Init out of AgentSupervisor.acquire into a lazy,
mutex-guarded ensureRuntime (mirroring initializeBuilder). Only Build/Test/Lint/
Stop initialize the runtime, on first use. Failures stay wrapped as
*agentInitializationError so Test keeps returning the typed env-blocked
response.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

Decouple read-only Code/Tooling from Runtime initialization

1 participant