Skip to content

Add the Runtime value, lay out the core's layers, and add the harness - #49

Merged
andreisavu merged 1 commit into
mainfrom
claude/pr1-split-plan-tgrf6p
Sep 9, 2026
Merged

Add the Runtime value, lay out the core's layers, and add the harness#49
andreisavu merged 1 commit into
mainfrom
claude/pr1-split-plan-tgrf6p

Conversation

@andreisavu

Copy link
Copy Markdown
Contributor

PR 1 of the stack that SPLIT_PLAN.md on #48 cuts from that branch. No behaviour change.

The one idea

A host owns a Runtime, and the core is laid out in layers that Biome holds.

  • host/runtime.ts. The clock, the session opener, the model call, the catalog, the rooms that run and the workspace names that are taken live on one value. startSession, readSession and defineWorkspace take a Runtime and default to defaultRuntime. Every Date call in src routes through the runtime's clock, and the view a seat reads carries the time it was built at. session.ts keeps its shape: only its globals move into the runtime it is handed.
  • The layers. types, define, render are the vocabulary; host/ holds what a host owns; tools/ holds the workspace and its backends; session.ts composes them. biome.jsonc carries one noRestrictedImports override per layer, as the final tree has it, plus the two cross-package rules. The overrides for wire, log/, room/ and seat/ name directories no file is in yet; they are harmless until PR 2 and PR 3 fill them.
  • types.ts gains the host contracts (Clock, SessionOpener, ModelResolver) and BUILTIN_TOOL_NAMES, so the vocabulary imports nothing that does anything. Backlog items 1 and 5 close.

The tests that pin it

  • test/runtime.test.ts: two runtimes in one process run the same name and neither reads the other; a room on JSONL reads back through a second runtime over the same directory.
  • test/matrix.test.ts: four scenarios (test/support/scenarios.ts) on both storages (memory, jsonl), on a clock the test moves by hand, held to the shared invariants (test/support/invariants.ts). The live tier re-exports the same invariants.
  • The existing session, roster, presence, assistant and workspace suites pass unchanged, which is the point.

Extract

git cherry-pick -x 90d5871 from #48, then runtime.ts moved to host/, the three workspace files moved to tools/, the contracts moved to types.ts, and the Biome overrides added. Trimmed per the plan: Transport, the transport option, wake, retry, evict, checkpoint on the runtime; SQLite, tappedOpener and faultyOpener in the test storage; inherited and the lease check in the invariants. One deviation: wrangler.jsonc is left out of the test task's inputs in turbo.jsonc until PR 14 adds the package that has one.

What a later PR adds on top

  • PR 2: log/log.ts in place of record.ts, the serial commit queue.
  • PR 3: wire.ts, seat/, Transport and RunningRoom as the wire sees it.
  • PR 5: wake, retry and evict on the runtime; resumeSession.
  • PR 6: the faulty and tapped openers, the chaos tier.
  • PR 13: the SQLite storage and the third column of the matrix.

Checks

pnpm format && pnpm check is green. The build prints three TS4023 lines from test/live/support.ts that main prints too; they are outside this PR. Every doc link resolves, and the vocabulary override was checked to refuse an import of ./host/runtime.ts from types.ts.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SJjjR3S6iwqEbDXsRDJgiq


Generated by Claude Code

A host owns a Runtime: the clock, the session opener, the model call,
the catalog, the rooms that run and the workspace names that are taken.
startSession, readSession and defineWorkspace take one and default to
defaultRuntime. Every Date call in src routes through the runtime's
clock, and the view a seat reads carries the time it was built at.
session.ts keeps its shape: only its globals move into the runtime it
is handed.

The core gains its layers, and Biome holds them with one
noRestrictedImports override per layer. The vocabulary is types, define
and render. host/ holds what a host owns. tools/ holds what an agent's
tools reach into. session.ts composes them. runtime.ts moves to host/,
the three workspace files move to tools/, and the host contracts
(Clock, SessionOpener, ModelResolver) and BUILTIN_TOOL_NAMES move to
types.ts. Backlog items 1 and 5 close.

The harness gains a fake clock, the two storages (memory, and JSONL over
a temporary directory), the two workspace backends, the shared
invariants, and four scenarios that matrix.test.ts runs on both
storages. runtime.test.ts proves two runtimes share nothing and that a
room on JSONL reads back through a second runtime.

This is PR 1 of the stack SPLIT_PLAN.md cuts from #48. It carries
90d5871 from that branch, moved into the layout of 8f0c1bc.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SJjjR3S6iwqEbDXsRDJgiq
@andreisavu
andreisavu merged commit 1c2b54c into main Sep 9, 2026
6 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.

2 participants