Skip to content

Commit fe4e8ea

Browse files
committed
Separate live revisions from stamped versions
Use index.html as mutable page source. Activate each valid save as an immutable content-addressed revision, then stamp exact revisions into sequential public versions. Scope events and projections to revisions, keep pinned versions stable, and show draft and validation state across the browser, CLI, docs, and examples.
1 parent 75cc9d5 commit fe4e8ea

96 files changed

Lines changed: 2960 additions & 2070 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎README.md‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ dashboard that keeps up while a long job runs. When the project needs a widget t
1111
doesn't exist, the agent writes one, and the same theme and checks cover it.
1212

1313
Underneath is a messaging and collaboration bus. Select any line and comment on it
14-
like a shared doc — or answer it with one press, `ok` `no` `lost` `cut` `more` —
15-
or drag a card, or rewrite a draft in your own words: it all reaches the session as
16-
structured events, and the agent answers in the margin and ships a revised version. The browser follows along on its own. Leaf is a plugin —
14+
like a shared doc, or drag a card, or rewrite a draft in your own words: it all
15+
reaches the session as structured events, and the agent answers in the margin and
16+
updates the page. You can also answer with one press: `ok` `no` `lost` `cut` `more`.
17+
Every valid save becomes a live revision; meaningful checkpoints become immutable
18+
stamped versions. The browser follows along on its own. Leaf is a plugin —
1719
Claude Code and Codex so far.
1820

1921
![leaf demo](docs/demo.gif)

‎docs/examples.html‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ <h2>The pages</h2>
101101

102102
<dt><a href="../examples/live-progress.html">Live progress</a></dt>
103103
<dd>
104-
A cutover rehearsal the agent republishes as each check finishes. Behind a
105-
session the counts and statuses move under the reader without a refresh; the
106-
page here stands at the middle state.
104+
A cutover rehearsal the agent updates as each check finishes. Behind a
105+
session each valid save moves the counts and statuses under the reader
106+
without a refresh; the page here stands at the middle state.
107107
</dd>
108108

109109
<dt><a href="../examples/heat-loss.html">Heating review</a></dt>
@@ -118,14 +118,14 @@ <h2>The pages</h2>
118118
<dd>
119119
Everything open against a release, as a board the user re-triages by
120120
dragging. Each move reaches the agent as an action and holds its place on
121-
later versions.
121+
later revisions.
122122
</dd>
123123

124124
<dt><a href="../examples/command-hub.html">Command hub</a></dt>
125125
<dd>
126126
A fleet of agents on one rewrite: what each holds, where every task stands,
127127
and the two decisions gating the work — the standing page an orchestrator
128-
republishes as it moves.
128+
updates live as it moves.
129129
</dd>
130130

131131
<dt><a href="../examples/release-notes.html">Release notes</a></dt>

‎docs/how-it-works.html‎

Lines changed: 48 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -223,28 +223,33 @@ <h3 id="loop-shell">One turn, from the agent's side</h3>
223223
<pre id="loop-transcript"><code>$ leaf page init ./review
224224
initialized /home/you/review
225225

226-
# the agent writes ./review/versions/v1.html — an ordinary file write
226+
# the agent writes ./review/index.html — an ordinary file write
227227

228-
$ leaf version publish ./review --version 1 --text "Two ways to shed load — which?"
229-
✓ v1.html: parses, widgets validate, one module script + theme link, ids and decisions carried over, nothing overflows the 720px column
228+
$ leaf version check ./review
229+
✓ index.html: parses, widgets validate, one module script + theme link, ids and decisions carried over, nothing overflows the 720px column
230+
231+
$ leaf version stamp ./review --text "Two ways to shed load — which?"
232+
{"kind": "note", "version": 1, "revision": 1, "text": "Two ways to shed load — which?", …}
230233

231234
$ leaf wait ./review
232235
# … held here, for as long as the reader takes …
233236
{"page": "/home/you/review", "threads": []}
234-
{"kind": "action", "author": "user", "version": 1, "widget": "shed", "action": "choose", "detail": {"options": ["opt-drop"]}, "id": "a0a372ca", "ts": "2026-08-16T02:35:07-07:00", "seq": 2}
235-
{"kind": "comment", "author": "user", "version": 1, "text": "Rejecting at the door is right for the API, but the batch importer retries blindly — it would hammer us. Drop oldest there.", "anchor": {"section": "shed", "quote": "Callers get a 429 immediately"}, "id": "a56486d1", "ts": "2026-08-16T02:35:07-07:00", "seq": 3}
237+
{"kind": "action", "author": "user", "revision": 1, "widget": "shed", "action": "choose", "detail": {"options": ["opt-drop"]}, "id": "a0a372ca", "ts": "2026-08-16T02:35:07-07:00", "seq": 2}
238+
{"kind": "comment", "author": "user", "revision": 1, "text": "Rejecting at the door is right for the API, but the batch importer retries blindly — it would hammer us. Drop oldest there.", "anchor": {"section": "shed", "quote": "Callers get a 429 immediately"}, "id": "a56486d1", "ts": "2026-08-16T02:35:07-07:00", "seq": 3}
236239

237240
$ leaf ack ./review 3</code></pre>
238241
<p id="loop-shell-read">
239-
The batch carries two events. The pick is an action, and every later version
242+
The batch carries two events. The pick is an action, and every later revision
240243
replays it, so the decision survives the page being rewritten under it. The
241244
comment carries the passage it was drawn on — the reader selected
242245
<em>Callers get a 429 immediately</em> and wrote against it — so the objection
243246
reaches the agent attached to the sentence that prompted it, rather than as a
244247
paraphrase of where they were looking. The pick belongs to no conversation and
245248
the comment opens its own, so the first line's <code>threads</code> is empty;
246249
a later reply in that thread names only the message it answers, and the
247-
exchange behind it comes along there. The agent answers by publishing v2.
250+
exchange behind it comes along there. The agent answers by updating
251+
<code>index.html</code>; the valid save goes live, and a meaningful checkpoint
252+
can then be stamped as v2.
248253
</p>
249254

250255
<p id="wait-trick">
@@ -287,44 +292,46 @@ <h3 id="loop-shell">One turn, from the agent's side</h3>
287292
<section id="agent">
288293
<h2>A command never edits the document</h2>
289294
<p id="agent-split">
290-
The agent has two ways in, and only one of them is HTML. A version is a file:
291-
the agent writes the whole document into the page directory, an ordinary file
292-
write with nothing mediating it. Everything it has to <em>say</em> goes
295+
The agent has two ways in, and only one of them is HTML. The source is a file:
296+
the agent writes the whole document to <code>index.html</code>, an ordinary
297+
file write with nothing mediating it. Everything it has to <em>say</em> goes
293298
through the <code>leaf</code> command instead — a reply in a thread, a comment
294-
it opens on a passage of its own, the changelog note that publishes a version
295-
— and each of those appends one event to the log. The log takes a command
296-
rather than a file write because it isn't the agent's alone: the browser
297-
appends to it too, and one writer is what gives every event an id to reply to
298-
and a place in the order.
299+
it opens on a passage of its own, the changelog note that stamps a version —
300+
and each of those appends one event to the log. The log takes a command rather
301+
than a file write because it isn't the agent's alone: the browser appends to
302+
it too, and one writer is what gives every event an id to reply to and a place
303+
in the order.
299304
</p>
300305
<p id="agent-render">
301306
So the agent's words reach the screen without the document changing. What the
302-
user looks at is the version composed with the log, recomposed on a two-second
303-
poll: the reply appears in a thread in the injected panel, the passage it
304-
answers is lit by the browser's highlight registry — which paints a range and
305-
touches no nodes — and the banner's line is whatever
307+
user looks at is the active revision composed with the log, recomposed on a
308+
two-second poll: the reply appears in a thread in the injected panel, the
309+
passage it answers is lit by the browser's highlight registry — which paints a
310+
range and touches no nodes — and the banner's line is whatever
306311
<code>leaf status</code> last wrote. Nothing in the document was rewritten to
307312
put any of it there, and it is the same composition that shows the user their
308-
own edits before a version carries them.
313+
own edits before a later revision carries them.
309314
</p>
310315
<p id="agent-versions">
311-
The HTML changes once per version, and even then nothing is edited in place: a
312-
revision is a new file beside the last one, <code>v2.html</code> next to
313-
<code>v1.html</code>, and <code>version publish</code> publishes it. Until the
314-
publication note lands the file is on disk and unreachable, and publishing
315-
lints it first, so a broken version is never exposed. The next poll moves the
316-
tab onto the new version, keeping the reader's place, and holds while the user
317-
is mid-comment or mid-drag. Coming back the other way,
318-
<code>leaf wait</code> starts after the last acknowledged user event, so a
319-
comment posted between a wait and its acknowledgement remains beyond the
320-
cursor and still lands.
316+
The HTML can change on every save, without spending a public version number.
317+
Leaf validates <code>index.html</code>, copies each changed valid save to an
318+
immutable revision such as <code>r2-a81c…html</code>, and moves the live root
319+
to it. An invalid save creates no revision, leaves the last valid one live,
320+
and shows its diagnostic. <code>version stamp</code> copies the exact current
321+
source to the next public file, such as <code>v2.html</code>, and records
322+
which revision it names. A tab at the root follows revisions while a tab
323+
pinned to v1 stays there. The next poll moves a live tab onto the new
324+
revision, keeping the reader's place, and holds while the user is mid-comment
325+
or mid-drag. Coming back the other way, <code>leaf wait</code> starts after
326+
the last acknowledged user event, so a comment posted between a wait and its
327+
acknowledgement remains beyond the cursor and still lands.
321328
</p>
322329
</section>
323330

324331
<section id="pages">
325332
<h2>What a page is made of</h2>
326333
<p id="scaffold">
327-
A version is one complete HTML document, and the required scaffold is two
334+
A revision is one complete HTML document, and the required scaffold is two
328335
lines: the theme stylesheet and the runtime module. Everything between them is
329336
the agent's, drawn from the four building blocks below in ascending order of
330337
specialization; each earns its place only where the one before it has no way
@@ -529,17 +536,18 @@ <h2>Each page owns its layer</h2>
529536
<section id="gate">
530537
<h2>Nothing broken goes live</h2>
531538
<p>
532-
Before a version is published, <code>version check</code> lints it
533-
deterministically, with no browser: the HTML parses with balanced tags, the
534-
scaffold is exactly the theme link and the runtime module, every
539+
Before a source save becomes a revision, Leaf runs the same deterministic lint
540+
as <code>version check</code>, with no browser: the HTML parses with balanced
541+
tags, the scaffold is exactly the theme link and the runtime module, every
535542
<code>lf-*</code> element validates against the page's registry along with the
536543
head's <code>lf-*</code> metas, ids stay unique and every comment anchor from
537-
the previous version survives, and nothing is wider than the readable column.
538-
The changelog note runs the lint and refuses a failing version, so an open
539-
browser never sees one. Before a page's URL first goes out,
540-
<code>version check --render</code> also loads it in the machine's own Chrome
541-
and refuses what only a layout engine can see — a console error, a widget
542-
rendered into a box of no size, a sideways scroll — in both color schemes.
544+
the previous revision survives, and nothing is wider than the readable column.
545+
A stamp checks the exact current source again and refuses a failing source, so
546+
neither the live root nor a version can expose broken markup. Before a page's
547+
URL first goes out, <code>version check --render</code> also loads it in the
548+
machine's own Chrome and refuses what only a layout engine can see — a console
549+
error, a widget rendered into a box of no size, a sideways scroll — in both
550+
color schemes.
543551
</p>
544552
</section>
545553

‎docs/index.html‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,17 @@ <h2>What a page can do</h2>
9999
re-prioritize a board, click an option to decide it, accept or reject a
100100
proposed edit, or rewrite a draft (an email, a release note) in your own
101101
words. Each edit reaches the agent as a structured action and holds its
102-
place on every later version. A question can be answered off its own menu
102+
place on every later revision. A question can be answered off its own menu
103103
too: a group that takes a pick ends with one more option, an empty one you
104104
write yourself, so "none of these — do X instead" goes where the question
105105
was asked.
106106
</li>
107107
<li id="range-track">
108108
<strong>Track.</strong> A page can be a working dashboard rather than a
109109
document: the state of the resources you asked about, a queue draining, a
110-
checklist ticking over. The agent republishes as the work moves and your
111-
browser follows on its own, so you watch it happen rather than reading a
112-
summary afterwards.
110+
checklist ticking over. The agent saves updates as the work moves and your
111+
browser follows each valid revision on its own, so you watch it happen
112+
rather than reading a summary afterwards.
113113
</li>
114114
<li id="range-grow">
115115
<strong>Grow.</strong> When a task calls for a widget that doesn't exist —
@@ -178,12 +178,12 @@ <h2>Example: Review a plan</h2>
178178
width="1120"
179179
height="700"
180180
alt="A live leaf page. The user selects Backfill history and writes a
181-
comment while the passage stays highlighted. The agent replies, publishes a new version
181+
comment while the passage stays highlighted. The agent replies, saves a new revision
182182
whose rehearsal count advances, and the user drags an on-call task to During."
183183
/>
184184
<figcaption>
185185
The real loop, recorded by <code>scripts/record-demo.sh</code>: comment on a
186-
passage, watch a new version advance the work, then move a card.
186+
passage, watch a new revision advance the work, then move a card.
187187
</figcaption>
188188
</figure>
189189

‎docs/session.js‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@
3535
const KEY = `leaf-demo:${location.pathname.replace(/\/versions\/v[1-9]\d*\.html$/, "")}`;
3636
// Which version this document is, read the way the runtime reads it.
3737
const VERSION = Number(location.pathname.match(/\/versions\/v([1-9]\d*)\.html$/)?.[1]);
38+
const REVISION = 1;
39+
const revisionMarker = document.createElement("meta");
40+
revisionMarker.name = "lf-revision";
41+
revisionMarker.content = String(REVISION);
42+
revisionMarker.dataset.lfRuntime = "";
43+
document.head.append(revisionMarker);
3844
const LAYER = await fetch("/registry.json")
3945
.then((response) => response.json())
4046
.then((registry) => registry.$layer.generation);
@@ -128,7 +134,21 @@ const state = () => ({
128134
// The versions this page has, which here is the one being read: the site publishes a
129135
// single version of each example. A second would want the list handed to this file
130136
// rather than guessed from a path, since a reader on v1 has to be offered v2.
131-
versions: [VERSION],
137+
active: {
138+
revision: REVISION,
139+
version: VERSION,
140+
url: `/versions/v${VERSION}.html`,
141+
label: `v${VERSION}`,
142+
activated_at: null,
143+
},
144+
versions: [
145+
{
146+
version: VERSION,
147+
revision: REVISION,
148+
url: `/versions/v${VERSION}.html`,
149+
},
150+
],
151+
source_error: null,
132152
// Nobody is behind this page and nobody is coming, which the runtime has a word for
133153
// and reads before it weighs anything else. Everything below it is then the honest
134154
// nothing a page outside a session loop has to report: no claim was ever written, no
@@ -201,7 +221,7 @@ window.fetch = (input, init) => {
201221
setTimeout(
202222
() =>
203223
append(
204-
{ kind: "reply", parent: minted.id, version: VERSION, text: ANSWER },
224+
{ kind: "reply", parent: minted.id, revision: REVISION, text: ANSWER },
205225
"claude",
206226
AGENT,
207227
),

‎examples/CLAUDE.md‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,17 @@ theme. When a sweep finds something here, ask which of the two let it through
7070
before adding a page: a page that only re-renders a shape nobody judges buys
7171
nothing.
7272

73-
## An example is one version, plus any log and data it ships beside it
73+
## An example is one stamped version, plus any log and data it ships beside it
7474

7575
`examples/layer.json` names the package paths shared by the corpus. Preview,
7676
lint, and site tooling all read that list, so the pages exercise the same vendored
7777
layer the website serves.
7878

79-
An example's markup is v1, and nothing ever revises it. That puts `restated` and
80-
`overruled` out of reach: each answers something only a later version does —
81-
`restated` retracts a decision, `overruled` keeps a version's own state over a
82-
report — and there is no later version here. `version check` refuses both.
79+
An example's markup is the source stamped as v1, and nothing ever revises it.
80+
That puts `restated` and `overruled` out of reach: each answers something only a
81+
later revision does — `restated` retracts a decision, `overruled` keeps a
82+
revision's own state over a report — and there is no later revision here.
83+
`version check` refuses both.
8384

8485
The log is a different matter: it was empty by default, not by nature. A thread
8586
is the one thing no markup describes, so an example that wants to show one ships

‎examples/gallery.html‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,8 @@ <h2>What should stop the ship</h2>
376376
Everything still open, including the two things I decided not to build at all.
377377
Where each card sits is my read of whether it should hold the ship, so move
378378
any card you would place differently. A grip takes the keyboard as well as the
379-
pointer. Whatever you decide about a card stays where you put it when I
380-
republish.
379+
pointer. Whatever you decide about a card stays where you put it as I update
380+
the page.
381381
</p>
382382
<lf-board id="off-punch">
383383
<lf-column id="off-col-ship" label="Blocks the ship">
@@ -1389,9 +1389,9 @@ <h2>Testing</h2>
13891389
<lf-tab id="gal-live-progress" label="Live progress">
13901390
<h1>Checkout cutover rehearsal</h1>
13911391
<p class="lede" id="lp-lede">
1392-
The agent republishes this page as each check finishes. The browser is following
1393-
the newest version, so statuses and counts change without a refresh. The
1394-
rollback drill is running now.
1392+
The agent saves this page as each check finishes. The browser follows each valid
1393+
revision, so statuses and counts change without a refresh. The rollback drill is
1394+
running now.
13951395
</p>
13961396

13971397
<lf-metrics id="lp-metrics">

‎examples/live-progress.html‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
<p class="eyebrow">live progress · rehearsal 4 of 5</p>
1717
<h1>Checkout cutover rehearsal</h1>
1818
<p class="lede" id="lp-lede">
19-
The agent republishes this page as each check finishes. The browser is following
20-
the newest version, so statuses and counts change without a refresh. The
21-
rollback drill is running now.
19+
The agent saves this page as each check finishes. The browser follows each valid
20+
revision, so statuses and counts change without a refresh. The rollback drill is
21+
running now.
2222
</p>
2323

2424
<lf-metrics id="lp-metrics">

0 commit comments

Comments
 (0)