Repository navigation
feat(engine): Atrium convergence — engine module, stability contract, clock-injectability, supply-chain, event-sourced rehydration - #120
Merged
Conversation
…t.Clock (#116) All ~11 time.Now() reads in the engine core (engine/ minus engine/adapter/) now flow through a nil-safe Engine.now() helper, which reads the injected port.Clock or returns the zero time when no Clock is configured (preserving the loop's existing optional-Clock contract). This makes the engine fully clock-injectable so an embedding host can drive every wall-clock read deterministically. The ephemeral in-memory child sessions (guardrail checker, fork judge, ask reviewer, model router) previously derived their ids from time.Now().UnixNano(), which aliases two children onto one id under a fixed fake clock. They now use a childSerial atomic counter — collision-free under any clock. An engine/arch AST guard (TestNoWallClockInEngineCore, with a liveness self-check) forbids time.Now/Since/Until in core non-test code. Behavioral tests (TestEngineNow, TestChildSerialDistinctUnderFixedClock) and an e2e wiring test (TestSubagentChildCreatedAtFromInjectedClock) added. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
engine/ is now module github.com/stacklok/mecatl/engine consumed locally via a committed go.work (monorepo, not a repo split). External consumers of engine/agent get the tiny closure (x/sync + doublestar + goleak), not the heavy toolhive/k8s/otel/grpc/SDK cone. A dedicated GOWORK=off CI job proves the hygiene; CI/Taskfile cover both modules; ADR 0036 records the why. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
) engine/COMPATIBILITY.md declares the 7-core-package public surface + v0.x discipline; a text API-snapshot freshness gate (internal/apicheck, golden -update idiom) fails CI on any unflagged change to the exported surface — capturing const VALUES (wire enums) and exported struct fields/methods/ interfaces; the guarded set is mechanically equal to engine/arch.CorePackages; gorelease is a release-time advisory; ADR 0037 records the decision. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
A `vuln` CI job runs pinned govulncheck for the root AND engine modules; the engine library is gated with NO allowlist (clean), the root app allowlists two unfixable-upstream docker CVEs (GO-2026-4887/4883, transitive via toolhive, reachable only in internal/, Fixed: N/A) as documented accepted-risk while still failing on any NEW reachable vuln; `.github/dependabot.yml` keeps both go.mod files + SHA-pinned actions current (grouped, weekly). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…construction contract + EvUserPrompt (#115) Ship engine/adapter/eventsource.Fold (EventLog+SessionMeta -> *session.Session) as the reference event-sourced SessionStore.Load rehydration; pin the reconstruction contract (COMPATIBILITY.md + port.SessionStore doc) — which aggregate fields must round-trip vs are run-scoped; add EvUserPrompt so the durable log records and the fold reconstructs user-role turns (closing the "log can't show what the user asked" gap, ADR 0027 row 11); only the provider-private reasoning-replay fields remain a documented limitation; reuse sessnap.RestoreState; determinism + awaiting-drivable + reasoning-divergence + contract-drift tests; ADR 0038. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…039 (#118) CI govulncheck flagged three newly-disclosed REACHABLE stdlib vulnerabilities, all fixed in the Go standard library at go1.26.4: - GO-2026-5037 (CVE-2026-27145) — crypto/x509: quadratic VerifyHostname cost on large DNS SAN lists (DoS). Fixed in: go1.26.4. Reachable via the HTTP client TLS path (root only); engine unaffected. - GO-2026-5038 (CVE-2026-42504) — mime: WordDecoder.DecodeHeader excessive CPU on malicious encoded-words (DoS). Fixed in: go1.26.4. - GO-2026-5039 (CVE-2026-42507) — net/textproto: user input echoed in error messages (log/error injection). Fixed in: go1.26.4. All three are Go-stdlib vulns governed by the `go` directive version that `go-version-file: go.mod` feeds setup-go. The repo declared `go 1.26.3`, so CI provisioned go1.26.3 and govulncheck reported the trio. Bumping the `go` directive to 1.26.4 in both modules (and go.work) is the minimal, durable fix (decision rule 1: upstream fix exists -> bump, preferred over allowlist). No go.sum changes — stdlib only. No new allowlist entries. The ENGINE module is now clean under the strict (no-allowlist) gate. The 2 docker CVEs (GO-2026-4887/4883, Fixed: N/A) remain the only allowlisted, accepted-risk root findings. Verified: root gate (allowlist 4887/4883) exit 0; engine strict gate exit 0; gate self-test all pass; go build (root+engine GOWORK=off); go test -race (root+engine); golangci-lint+vet (both); task api:check (no API drift); engine dep-closure still tiny; mecademo full offline session; task tidy stable. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
JAORMX
marked this pull request as ready for review
June 19, 2026 10:42
JAORMX
added a commit
that referenced
this pull request
Jun 19, 2026
…-convergence arc Holistic post-merge documentation pass (recon -> fix/enhance -> agent review) over the per-area surfaces the #120 merge left untouched: - Architecture pages: ports.md (12 ports incl. SessionLease; the event-sourced SessionStore.Load contract; clock-injectability), domain-model.md (EvUserPrompt + the full Event field list), observability.md (the 3rd EventLog consumer = eventsource.Fold + the two Load implementations), deployment-and-hardening.md (#118 govulncheck/dependabot + go 1.26.4), api-surface.md / extensibility.md / architecture.md (engine-as-importable-module + stability contract), and the modelith model (EventLog now reconstructs user turns, with the replay caveat). - docs/design/PRODUCTION-READINESS.md: cloud-native Phase 4 (leasing) -> shipped; add the engine-convergence (ADR 0036/0037/0038) + supply-chain (#118) rows. - Skills: cut-release gains the engine/vX.Y.Z submodule-tag mechanics (first tag engine/v0.1.0); perf-optimization reflects the two-module (go.work) reality. - AGENTS.md: EvUserPrompt as the third log-only event (lean) + engine-contract See-also. README/usage: importable-engine feature + eventsource.Fold pointer. - llms.txt regenerated; matlatl --strict green (0 broken/orphan/unreachable). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #113 #114 #115 #116 #118.
The
atrium-convergenceissue set: makeengine/a clean, dependable, embeddable library so Atrium can import the core and inject its own adapters (LLM-Gateway, MCP-Gateway, an event-log-as-system-of-record session store, its own event schema) — true co-evolution instead of vendoring/divergence. Built on top of PR #119 (session leasing). Kept a monorepo (multi-module workspace, not a repo split).Each issue went through the full dev-pipeline (architect → implement → independent review panel → iterate → commit-per-issue).
What landed
time.Now()sites in the engine core route through the injectedport.Clockvia a nil-safeEngine.now(); ephemeral child-session ids use an atomic counter (collision-safe under a fake clock, unlikeUnixNano); an AST arch guard forbidstime.Now/Since/Untilin core non-test code.engine/go.mod(github.com/stacklok/mecatl/engine) consumed locally via a committedgo.work. An external consumer ofengine/agentnow gets a tiny graph —golang.org/x/sync+doublestar(+goleaktest) — not mecatl's toolhive/k8s/otel/grpc/SDK cone. A dedicatedGOWORK=offCI job proves the hygiene. CI/Taskfile cover both modules. ADR 0036.engine/COMPATIBILITY.mddeclares the 7-core-package public surface + v0.x discipline; a text API-snapshot freshness gate (internal/apicheck, golden-updateidiom) fails CI on any unflagged change — capturing const values (wire enums) and exported fields/methods; the guarded set is mechanically equal toarch.CorePackages.goreleaseis a release-time advisory. ADR 0037.govulncheckper module — engine strict & clean; the root app hard-gates but allowlists two unfixable-upstream docker CVEs (transitive via toolhive, reachable only ininternal/) as documented accepted-risk, fail-closed, still failing on any new reachable vuln.dependabot.ymlfor both go.mod files + SHA-pinned actions.engine/adapter/eventsource.Fold(EventLog +SessionMeta→*session.Session) is the reference event-sourcedSessionStore.Load; the reconstruction contract (which aggregate fields must round-trip vs are run-scoped) is pinned inCOMPATIBILITY.md+ theport.SessionStoredoc. A new log-onlyEvUserPromptevent makes the durable log record — and the fold reconstruct — user-role turns (closing a latent ADR-0027 gap: the durable log previously couldn't show what the user asked). ADR 0038.Notable design decisions & documented limitations
go.workis committed (standard monorepo practice; invisible to externalgo get). Rootgo.modgainsrequire …/engine+replace …/engine => ./engine.EvUserPromptis log-only (appended to the durable log, skipped on the live client wire — theEvApproval/EvCompactionArchiveprecedent; the driving client already has the prompt). Child-content isolation (gauntlet ACP: accept client-provided streaming-HTTP MCP servers #7) holds and is security-reviewed + mutation-guarded: a child's prompt never reaches the parent log.Message.Reasoning,Message.ProviderPhase,ToolCall.ItemID) are not event-carried, so a pure event-fold is byte-identical-replay-faithful only for providers that don't use them; an event-log-SoR host must carry them in its own event schema. mecatl's own resume still uses the snapshot (which carries them).GO-2026-4887/GO-2026-4883(docker/docker via toolhive,Fixed: N/A) — accepted-risk, dated, root-only; engine is strict.Verification (10/10 gates green on the integrated branch)
Root + engine
go build/go test -race; theGOWORK=offengine-standalone build+test; lint +go vetboth modules; the API stability gate; the vuln gate (engine clean, root allowlisted, fail-closed self-test); offlinego run ./cmd/mecademo(full session, now showinguser_prompt);matlatl --strictdocs (0 broken/orphan/unreachable);task tidystable; the engine dep-closure confirmed tiny.Notes
e2e-livelabel added to run the live OpenRouter suite (real spend, like feat(cloud-native): cross-process single-writer session leasing (Phase 4) (#60) #119).🤖 Generated with Claude Code