Skip to content

Draft: Session.open with layer-native EventLog composition - #61

Merged
K-Mistele merged 1 commit into
mainfrom
humanlayer/issue-60
Oct 13, 2026
Merged

K-Mistele merged 1 commit into
mainfrom
humanlayer/issue-60

Conversation

@humanlayer-channels-app

Copy link
Copy Markdown

Summary

Implements the API agreed in #60: Session.open({ agent }) initializes an empty log or adopts/resumes an existing session, followed by session.send(...).

  • EventLog is ambient in the internal graph; custom backends are supplied by ordinary Effect layer composition, never session options.
  • Missing EventLog allocates a session-fresh memory log, with one documented optional-service lint exception.
  • Existing identity is authoritative. Conflicting session IDs, malformed/nonempty history, noncontiguous sequence numbers, and duplicate session starts fail as defects before opening writes.
  • Removed startSession / resumeSession and the event-log descriptor APIs as a documented breaking change; migrated launchers, examples, and tests.
  • JSONL composition retains Layer.orDie acquisition policy. Host-built backends stay alive in the host/session scope and are not rebuilt by Fold.
  • Cloudflare now builds an EventLog-producing SQLite layer once per activation in the explicit object-lifetime scope, sharing its instance across emptiness checks, session opening, and entries RPCs. Storage acquisition stays in Alchemy's runtime-only returned Effect.
  • Updated README and Effect design guidance with ownership, memoization, and migration rules.

Verification

  • Full workspace bun run typecheck passed.
  • bun run lint passed (oxlint + typed lint).
  • fold-core: 337 tests passed.
  • fold-agent: 273 tests passed, 3 live Codex tests skipped.
  • Alchemy Cloudflare example: 25 tests passed.
  • New coverage includes automatic open/resume, identity/history safeguards, once-only acquisition/release, persistence across reopen, corrupt JSONL as a defect, and cross-session live subscription isolation.

Review notes

Intended as a draft for review. One supplied backend is one session and should have at most one active handle; memoization intentionally shares that service with the session's host consumers. SQLite integration is typechecked and API tests use the layer-native session API; no deployed Cloudflare smoke test was run.

Closes #60

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


HumanLayer Agent seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

}
}).pipe(Effect.orDie)
}).pipe(Effect.provide([DurableObjectEventLog.layer, Keepalive.layer, SessionExpiry.layer, Workspace.layer])),
}).pipe(Effect.provide([Keepalive.layer, SessionExpiry.layer, Workspace.layer])),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

event log? we should be using the DO event log shouldn't web - where did it go @humanlayer-channels-app?

@humanlayer-channels-app

Copy link
Copy Markdown
Author

Yes—we still use the Durable Object’s SQLite event log. It moved from the outer Effect.provide into the runtime-only initialization:

  • layerDurableObjectEventLog supplies EventLog, backed by raw.storage.sql.
  • ChatSession builds it once per activation, then passes that same logContext to Session.open via Effect.provideContext(logContext). The emptiness check and entries RPC also use that instance.

This keeps SQLite acquisition out of Alchemy’s planning phase and ensures the session and RPCs share one backend. It does not fall back to an in-memory log.

@K-Mistele
K-Mistele merged commit 1ddb186 into main Oct 13, 2026
4 of 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.

Refactor EventLog to use service and layer composition instead of a session option

2 participants