Skip to content

feat(engine): add isolated kernel history foundation - #2639

Merged
jbeda merged 11 commits into
mainfrom
impl/session-history-kernel
Nov 1, 2026
Merged

jbeda merged 11 commits into
mainfrom
impl/session-history-kernel

Conversation

@jbeda

@jbeda jbeda commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Introduce the isolated kernel's history foundation, without changing production execution entry points:

  • Add strongly typed resource/history IDs and opaque commit CIDs.
  • Define owned persistence DTOs and bounded canonical DAG-CBOR commit codecs; commit identity includes sequence and root/parent linkage.
  • Add history.History for conditional append, explicit uncertain-append resolution, and bounded reads through a pinned commit reference.
  • Define a byte-facing backend contract and provide an in-memory adapter plus reusable conformance/fault-injection checks.
  • Add API snapshots and narrow architecture/layering guards. Organize design rationale and clarify canonical session mutation ownership.

The codec uses Atmos v0.8.0, which raises the engine and local consumers' minimum Go version to 1.27.3. Associated manifest, dependency-floor test, and prerequisite documentation changes are intentional.

Contract highlights

  • Append performs one conditional backend call, with no preliminary observation or hidden retry. Canonical identity can be calculated before submission for fresh-context recovery after an uncertain outcome.
  • Reads validate canonical bytes, indexed identity, sequence/ancestry, both requested endpoints, and explicit resource bounds. Error results do not expose partial authoritative pages or acceptance verdicts.
  • Records retain opaque payloads. Storage acceptance does not establish valid session transitions, execution authority, or permission to disclose payloads.
  • Memory backend acceptance is process-local: it is not a claim of crash durability or stale-writer fencing.

Scope and next milestone

This PR deliberately stops at a coherent history foundation. It does not add a session aggregate, coordinator, execution loop, writer ownership/fencing, production storage adapter, or server/client integration.

The next agreed integration milestone is an isolated history-backed run using a real LLM and a mock tool, with a thin client if needed. It will bring session semantics, coordination, and a minimal loop together; demonstrate intent/result commit gates; reconstruct equivalent accepted state after discarding live kernel objects; and prove honest interrupted/uncertain outcomes without reexecuting tools. Deterministic offline tests remain separate from live-provider smoke checks. That future work is not implemented here.

Verification

Existing slice-level evidence recorded locally before the final commit:

  • Full standalone engine build/tests (GOWORK=off).
  • Focused standalone race tests for IDs, kernel, architecture, and history adapters.
  • Focused 386 tests, pinned engine lint, API snapshot checks, and strict documentation checks.
  • Four-axis incremental review of the final backend simplification: no unresolved findings or reviewer failures. Earlier unchanged slices retain their earlier review evidence; this is not a new whole-branch review.

Fresh PR-preparation results against rebased head e9f521eca (Go 1.27.3):

  • task lint
  • task --concurrency 3 test:race — initial run failed in root internal/apicheck; all engine tests passed. The API checker dynamically loaded engine packages from the root module, whose tidy graph does not retain Atmos checksums. The checksum-only workaround in 917c154ee failed CI's tidy gate and is superseded by 6e612fe85: load packages from the engine module directory and remove the unnecessary root checksums. After task tidy, the complete internal/apicheck suite passes with GOWORK=off GOPROXY=off, -mod=readonly, and -race. task test:module-metadata also passes. Full-suite verification is left to CI at the operator's request.
  • task docs
  • task api:check — workspace-mode pass; does not cover the standalone-root failure above.
  • go run ./cmd/mecademo — verified tool call, permission ask/approval, and final result (existing production-runtime offline smoke test, not the future kernel milestone).

Pre-rebase lint/race runs were stopped before changing the tree. Follow-up fixes change only API-check tooling and root checksum metadata; no dependency versions or production code changed.

Draft pending CI and human review. Rebased without conflicts onto origin/main at c3adf8f7a; git range-diff confirmed all nine original branch commits are patch-identical. The checksum fix is a separate follow-up commit.

API compatibility

  • Wire: no remote-observable API or production execution semantics change; no protocol major or feature identifier change. No client upgrade is required by this isolated foundation.
  • Go: additive packages and public history contracts; generated snapshots are included. The minimum Go toolchain increases to 1.27.3 for all engine consumers, even those not importing the codec. The history identity leaf refactor preserves the history.HistoryID alias/constructors but changes the defining/reflection package identity within the new experimental surface.
  • Stored data: defines a new isolated canonical history format; does not read, migrate, replace, or dual-write production session storage.

jbeda and others added 9 commits November 1, 2026 08:46
Introduce opaque comparable IDs with registered kinds, secure uniform generation, strict parsing, and a strongly typed history wrapper. Add public API snapshots and dependency guards without activating the kernel or changing existing session IDs.

Co-authored-by: Mecatl <[email protected]>
Keep history.HistoryID and its constructor/parser entry points as aliases and wrappers over the codec-independent history/id package. Guard the new package and disambiguate its API snapshot from engine/id.

Co-authored-by: Mecatl <[email protected]>
Group implementation reports by authority, representation, ownership, and extension boundaries. Explain the canonical history format and handwritten Atmos codec choice without session staging or raw benchmark dumps.

Co-authored-by: Mecatl <[email protected]>
Add strict fixed-profile CID text parsing and formatting at the isolated history format boundary. Keep content validation, codecs, and storage consumers outside this slice.

Co-authored-by: Mecatl <[email protected]>
Add mutable Commit and Record values with concrete deep-clone and fieldwise equality methods. Keep validation, codecs, and consumers deferred; document the ownership contract and generated-type tradeoff. Place package documentation in doc.go.

Co-authored-by: Mecatl <[email protected]>
Add strict v1 DAG-CBOR encoding and decoding, explicit resource limits, validation, and exact-byte commit identities. Organize format implementations by type and document kernel-local coding standards and the interim handwritten codec boundary.

Use Atmos v0.8.0 with the necessary Go 1.27.3 floor propagation and prerequisite corrections.

Co-authored-by: Mecatl <[email protected]>
Add one-based commit ordinals to validation, equality, canonical DAG-CBOR encoding and content identity. Keep parent-relative sequence validation at the future acceptance boundary and cover integer-width and malformed-envelope cases.

Keep kernel API snapshots current without compatibility bookkeeping during the experiment.

Co-authored-by: Mecatl <[email protected]>
Distinguish canonical mutation ownership from shared storage acceptance. Route loop and non-loop proposals through kernel coordination, keep checkpoints and relays derived, and capture acceptance scenarios without prescribing runtime topology.

Co-authored-by: Mecatl <[email protected]>
Add DTO-facing identification, one-call conditional append, retry resolution, and bounded fixed-endpoint reads. Keep canonical validation and protocol policy in History, with coherent observations and opaque byte persistence behind Backend.

Provide a concurrent memory backend and portable conformance tests covering sequence enforcement, read boundaries, ownership, resource limits, and uncertain acceptance.

Co-authored-by: Mecatl <[email protected]>
@jbeda
jbeda force-pushed the impl/session-history-kernel branch from a1178b7 to e9f521e Compare November 1, 2026 16:46
@jbeda
jbeda marked this pull request as ready for review November 1, 2026 16:47
jbeda and others added 2 commits November 1, 2026 09:14
Allow standalone root API checks to load the isolated history codec dependency without workspace checksums.

Co-authored-by: Mecatl <[email protected]>
Use the engine module directory when loading its public API so standalone root checks resolve engine dependencies from engine/go.sum. Remove root Atmos checksums that tidy correctly discards.

Co-authored-by: Mecatl <[email protected]>
@jbeda
jbeda merged commit 31aedf2 into main Nov 1, 2026
46 checks passed
@jbeda
jbeda deleted the impl/session-history-kernel branch November 1, 2026 17:51
@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.

1 participant