Repository navigation
Commit 67faff9
committed
✨ Run and resume one REPL execution
Slice B of #848: the execution kernel. An injected host can create or open one
retained execution, submit the reference entry, run it with the ordinary core
runtime, watch immutable Journal-derived models beside explicit live overlays,
pause and continue expansion, answer one question, and cold-reopen the same
history through ordinary replay. There is no component tree, no terminal and no
command; this is the layer between the Journal and whatever draws it.
`journal.ts` is the storage design in full: one append-only NDJSON file of
`serializeDurableEvent` records and nothing else — no manifest, no projected
model, no cache, no checkpoint index, no sidecar. Reading is hostile: every line
goes through `parseDurableEvent`, a file whose last record has no terminating
newline is a write that did not finish, a target that is not a regular file is
refused before it is read, and no refusal quotes what the file held. Creation is
exclusive, because a name already taken is somebody else's history and appending
to it would join two executions into one. Writing stays single-writer, which is
the `DurableStream` contract rather than a claim this feature strengthens.
Nothing in the kernel chooses a runtime. Reading, existence, kind and directory
creation are `@effectionx/fs` operations; the two this repository's portable
layer does not offer — creating a name exclusively and appending to it — cross
the contextual host boundary instead, and the storage root arrives as an
argument rather than being found in a home directory or an environment.
`session.ts` runs both directions through one path. A fresh session validates
the submitted document against the environment the run would use, so an entry
that cannot run leaves the history empty and the draft editable rather than
admitting an entry whose only history is its own failure. A cold session parses,
projects and replays in a scope the caller can drop, and hands back nothing
until admission — the execution settling, the first new record reaching the
file, or the first question reaching this process. Before that point a
divergence, a stale answer or a malformed record is a refusal with no append and
no provider call; after it, a failure is an outcome the transcript shows.
The append observer has the session's lifetime. Its removal is registered before
the callback is published and clears only the callback this session installed,
because the stream outlives the session watching it — a repository hands the
same one to whoever opens the execution next — and a callback left behind would
reproject into, and signal, a session whose scope is gone. Live output is
consumed as it arrives inside that same scope: an overlay that filled in at
close would be showing what the document rendered, but never *so far*.
`expansion.ts` pauses XMD expansion without cancelling anything, over ordinary
middleware and with no new core primitive. Three operations bracket a walk today
and a fourth is published for a host that declares structural syntax; eight
steps inside a walk are gates, `DocumentOutput.output` among them, which is what
covers prose. A walk is satisfied when it holds a continuation or all of its
active children are satisfied, and expansion is paused when every active walk
is. A hold is a suspended `action()`, so teardown unwinds through it and
releases nothing, and Continue resolves each current hold once and re-runs
nothing. The boundary partition is three declared lists per wrapped Api —
walks, gates, and the members deliberately neither — so a member core adds later
belongs to no list and the inventory says so.
`elicitation.ts` presents one question shape and refuses anything else as an
`ElicitationProviderError` before a value is yielded. A choice the form does not
offer is an incomplete interaction, not a rejected answer: the request stays
open and nothing appends. A value the schema rejects is the other case, and core
records it as a durable `err`.
The reference entry now displays its generated source before the fragment is
admitted, which is what makes that order observable rather than inferred. X2
counts the work a run performs where performing it happens — the component
source read and the eval compilation, not the durable records that replay
restores — with a positive control so a counter that never moves cannot read as
proof of replay.
Four review corrections. Everything a session owns — its append observer, its
execution task, its output consumer and its question watcher — now lives in one
provisional scope built as a child of the caller's. An accepted session is torn
down with its owner; a refused reconstruction is torn down *before* the refusal
is returned, because a refused cold open that left a live observer behind would
keep reprojecting into a session nobody was ever given.
The Continue capability is exposed only by the process that owns holds.
`session.expansion` stays readable everywhere, because any surface may show
that expansion is paused; `session.controller` is absent — not a controller
whose Continue does nothing — for a settled history replay restored whole, an
execution with no entry, and a run that has finished.
P1 now exercises the distinction the mode name rests on: a question is work
that has already started, so a pause requested while one is pending cannot take
effect until it settles. Its record reaches the Journal while the request is
outstanding, and only then does expansion report paused and stop moving.
The corrupt-history control counts provider entry rather than assuming it, with
a positive control for every counter the negatives rely on — a count that could
never increment would otherwise read as proof of replay.1 parent 970bc0d commit 67faff9
8 files changed
Lines changed: 2135 additions & 2 deletions
File tree
- packages/cli
- src/repl
- tests
- fixtures/repl
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
0 commit comments