Add the Runtime value, lay out the core's layers, and add the harness - #49
Merged
Conversation
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
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.
PR 1 of the stack that
SPLIT_PLAN.mdon #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,readSessionanddefineWorkspacetake aRuntimeand default todefaultRuntime. EveryDatecall insrcroutes through the runtime's clock, and the view a seat reads carries the time it was built at.session.tskeeps its shape: only its globals move into the runtime it is handed.types,define,renderare the vocabulary;host/holds what a host owns;tools/holds the workspace and its backends;session.tscomposes them.biome.jsonccarries onenoRestrictedImportsoverride per layer, as the final tree has it, plus the two cross-package rules. The overrides forwire,log/,room/andseat/name directories no file is in yet; they are harmless until PR 2 and PR 3 fill them.types.tsgains the host contracts (Clock,SessionOpener,ModelResolver) andBUILTIN_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.Extract
git cherry-pick -x 90d5871from #48, thenruntime.tsmoved tohost/, the three workspace files moved totools/, the contracts moved totypes.ts, and the Biome overrides added. Trimmed per the plan:Transport, thetransportoption,wake,retry,evict,checkpointon the runtime; SQLite,tappedOpenerandfaultyOpenerin the test storage;inheritedand the lease check in the invariants. One deviation:wrangler.jsoncis left out of thetesttask's inputs inturbo.jsoncuntil PR 14 adds the package that has one.What a later PR adds on top
log/log.tsin place ofrecord.ts, the serial commit queue.wire.ts,seat/,TransportandRunningRoomas the wire sees it.wake,retryandevicton the runtime;resumeSession.Checks
pnpm format && pnpm checkis green. The build prints three TS4023 lines fromtest/live/support.tsthatmainprints too; they are outside this PR. Every doc link resolves, and the vocabulary override was checked to refuse an import of./host/runtime.tsfromtypes.ts.🤖 Generated with Claude Code
https://claude.ai/code/session_01SJjjR3S6iwqEbDXsRDJgiq
Generated by Claude Code