Repository navigation
Description
Context
Atrium (stacklok/atrium) is converging its in-house agent loop onto mecatl: instead of maintaining a hand-rolled function-calling loop and harvesting mecatl mechanisms by copy (the prior plan), Atrium wants to import the engine/ core as a library and inject its own adapters (LLM-Gateway egress, MCP-Gateway tool dispatch, an event-log-backed session store, its own event schema). The hexagonal split you've built — engine/ is the importable core, internal/adapter/* holds the heavy adapters — is exactly the shape that makes this possible. (See also the cloud-native-harness-kit discussion in #71 / #54.)
This issue covers the module-graph hygiene of consuming engine/ as a dependency.
What actually happens today (corrected)
Importing engine/agent does not bloat the consumer's binary — Go compiles only imported packages, so toolhive/k8s/wazero/the SDKs never compile in regardless. The cost is at the module-graph / MVS layer. Because the core packages live in the same module as the adapters, Go 1.17+ module-graph pruning still pulls github.com/stacklok/mecatl's direct require block (toolhive, k8s, openai-go, anthropic-sdk, mcp-sdk, grpc, otel) into the consumer's module graph as MVS participants.
Concrete consequences, in priority order:
- MVS version coupling on shared modules. Atrium and mecatl both depend on
google.golang.org/grpc,google.golang.org/protobuf, and OpenTelemetry. MVS takes the max, so a mecatl bump to any of those raises Atrium's floor — even though the importedengine/agentuses none of them. - SBOM /
go list -m all/ dependabot noise — the consumer's module graph enumerates k8s/toolhive/AWS as "dependencies," misleading for audits. go.sum/ graph-load size — minor.
Proposed work
- Add
engine/go.modwith module pathgithub.com/stacklok/mecatl/engine(Go 1.26.x to match root),require golang.org/x/sync(the verified sole non-stdlib dep of the core closure). - Convert the root module to a
go.work(or areplace) socmd/,internal/,e2e/,perf/keep consuming the localenginemodule. - Keep
engine/arch/layering_test.goas the standing guard — its doc already states the intent: "the engine tree can become its own module without dragging the host repo along." - Tag the new submodule (
engine/vX.Y.Z) through the existing release pipeline.
Acceptance
go get github.com/stacklok/mecatl/engine@<tag>from a fresh module pulls ago.sumwhose only non-stdlib entry isgolang.org/x/sync(+ its closure).- The root build, the
cmd/*binaries, and the e2e/perf suites still build and pass against the localenginemodule.
Priority
Strongly recommended, not a hard blocker. A consumer can import the root module today and get a clean binary; the split is about not coupling Atrium's grpc/protobuf/otel floor to mecatl's release cadence. Since both repos are Stacklok-owned, move fast, and share exactly those modules, that coupling is the concrete ongoing cost the split removes.
Tracking — "make engine consumable as an external library (Atrium convergence)"
- Promote
engine/to its own Go module so external consumers can import the core without the adapter dep-cone #113 — this issue: splitengine/into its own Go module (strongly recommended). - Adopt a stability / breaking-change contract for the
enginemodule surface #114 — adopt a stability / breaking-change contract for theenginesurface. - Document (and optionally ship) an event-sourced
SessionStore: which aggregate fields must round-trip for a host whose event log is the system of record #115 — document (and optionally ship) an event-sourcedSessionStorefor a host whose event log is the system of record. - Route the two
time.Now()child-session sites throughport.Clockfor full clock-injectability of the engine #116 — route the twotime.Now()child-session sites throughport.Clock. Make the approval-ask id correlatable to a host-supplied id (or pin the deterministic askID as a public contract) #117— withdrawn: host-mappable approval id. Closed not-planned — the session lease (Cloud-native Phase 4: cross-process single-writer enforcement (session leasing) #60 / PR feat(cloud-native): cross-process single-writer session leasing (Phase 4) (#60) #119) + the deterministicaskIDriding thepermission.askevent cover routing/correlation without an engine change.- Add govulncheck + dependabot to CI (esp. once the
enginemodule is published) #118 — add govulncheck + dependabot to CI.
#113 is the prerequisite for #114; #115, #116, #118 are independent.
Activity