Skip to content

Commit 1c5edad

Browse files
committed
Build the Command Hub coordination loop
Let packages declare host operations through widgets while Leaf handles the durable request and receipt lifecycle. Validate offers and typed references at the authoring, message, and event boundaries, then project pending and settled work consistently into pages and threads. Use the protocol in the Command Hub to derive asks, stopped work, fleet views, operation subjects, and action controls from the goal tree. Cover request races, retries, receipts, typed references, browser rendering, and server admission.
1 parent 1aca513 commit 1c5edad

47 files changed

Lines changed: 3287 additions & 372 deletions

Some content is hidden

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

‎CLAUDE.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@ for typed external data. A source id keeps one contract for the page's lifetime.
6868
`plugins/leaf/skills/leaf/references/internals/page-storage.md` defines the
6969
complete layout.
7070

71+
A request is a durable, non-undoable one-shot instruction whose external effect
72+
may precede its receipt. The append door admits one pending request per declared
73+
seat atomically; failure reopens the seat and success completes it. Exactly one
74+
terminal receipt names each accepted request. Page seats are scoped to their
75+
authored revision, while a seat in frozen thread markup lasts for that document's
76+
whole lifetime. Packages own verbs, host meaning, guidance, and UI; Leaf owns only
77+
the typed transport and canonical lifecycle projection. A package may declare that a
78+
ready request is a reader ask; acceptance hands the turn to the host, success closes it,
79+
and failure returns it through that same projection.
80+
7181
### Validate once and share readings
7282

7383
Validate each input at its boundary: browser events at `POST /api/event`,

‎docs/packages.html‎

Lines changed: 47 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -281,15 +281,16 @@ <h2>Add a CSS-only widget</h2>
281281
<td><code>x-ask</code></td>
282282
<td>
283283
What x-ask declares: an instance is the complete reading and arrival
284-
region for exactly one non-quoted nested x-awaits widget. The region
285-
carries the heading, context, and evidence the reader needs before the
286-
control; the nested widget still owns the answer and its fold. The
287-
banner, Asks tray, <code>a</code>/<code>A</code> walk, standing ring,
288-
and <code>page state</code> name the region while action eligibility and
289-
replay name the nested widget. An arrival focuses that widget's
290-
answering control but scrolls to the region's start.
291-
<code>version check</code> requires one non-quoted nested x-awaits
292-
source so the two identities cannot be ambiguous.
284+
region for exactly one non-quoted nested widget declaring x-awaits or
285+
x-request.ask. The region carries the heading, context, and evidence the
286+
reader needs before the control; the nested widget still owns the answer
287+
and its fold or request lifecycle. The banner, Asks tray,
288+
<code>a</code>/<code>A</code> walk, standing ring, and
289+
<code>page state</code> name the region while action eligibility,
290+
replay, and request projection name the nested widget. An arrival
291+
focuses that widget's answering control but scrolls to the region's
292+
start. <code>version check</code> requires one non-quoted nested
293+
declared ask source so the two identities cannot be ambiguous.
293294
</td>
294295
</tr>
295296
<tr>
@@ -472,10 +473,15 @@ <h2>Add a CSS-only widget</h2>
472473
<tr>
473474
<td><code>x-refers</code></td>
474475
<td>
475-
Attributes whose values name another element on the page (an option's
476-
<code>for</code>), which <code>version check</code> holds to an id the
477-
version carries and the runtime renders as a reference the reader can
478-
follow.
476+
A map from attributes whose values name another element to their target
477+
contracts. An empty contract accepts any element id (an option's
478+
<code>for</code>). A typed contract names a shared registry map with
479+
<code>via</code> and an equality predicate with <code>where</code>;
480+
<code>version check</code> then requires both an existing id and a
481+
target tag whose declaration in that package-owned map matches the
482+
predicate. This lets a package distinguish a goal, worker, or evidence
483+
reference without Leaf knowing those roles or tags. The runtime renders
484+
every valid value as a reference the reader can follow.
479485
</td>
480486
</tr>
481487
<tr>
@@ -500,6 +506,34 @@ <h2>Add a CSS-only widget</h2>
500506
$report's.
501507
</td>
502508
</tr>
509+
<tr>
510+
<td><code>x-request</code></td>
511+
<td>
512+
One-shot operations the reader asks the external host to perform.
513+
<code>offers</code> maps each direct child widget tag to its required
514+
string-enum verb attribute, deriving the commands a particular holder
515+
presents; every live holder must carry at least one such direct offer
516+
and may offer each verb only once. <code>verbs</code> declares every
517+
command's complete detail schema. Optional <code>bind</code> maps
518+
required string detail fields to required immutable string attributes on
519+
this widget, so a crafted request cannot retarget the operation.
520+
<code>ask: true</code> makes the ready lifecycle a reader ask:
521+
acceptance hands the turn to the host, pending and completed leave the
522+
reader's list, and failure returns it. A page holder has one lifecycle
523+
per revision; a holder in frozen thread markup has one for that
524+
document's whole lifetime. Pending excludes another request, failure
525+
reopens it, and success completes it. Each request is durable and not
526+
undoable because the host may already have acted.
527+
<code>leaf receipt</code> appends exactly one linked
528+
<code>succeeded</code> or <code>failed</code> outcome, and
529+
<code>watchRequestLifecycle</code> supplies the holder's
530+
server-projected request seat, exact request/receipt attempts, latest
531+
attempt, and ready/pending/completed phase to its package module. Leaf
532+
transports and validates the protocol but does not interpret verbs or
533+
execute them; package-owned guidance tells the host what each verb
534+
means, and external data carries replaceable evidence produced by it.
535+
</td>
536+
</tr>
503537
<tr>
504538
<td><code>x-retired-when</code></td>
505539
<td>

‎examples/command-hub.html‎

Lines changed: 73 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ <h1>Atlas importer rewrite</h1>
6464
<lf-task id="parser-stream" status="done">
6565
<strong>Streaming core</strong> Constant memory over the full corpus.
6666
</lf-task>
67-
<lf-task id="parser-cdata" status="done">
67+
<lf-task id="parser-cdata" status="active">
6868
<strong>CDATA edge cases</strong> Eleven legacy exports replay cleanly.
6969
<lf-agent id="w-2" state="working" on="parser-cdata">
7070
<strong>w-2</strong> CDATA specialist: escaped-markup corpus cases.
@@ -74,39 +74,43 @@ <h1>Atlas importer rewrite</h1>
7474
</lf-task>
7575
<lf-task
7676
id="parser-dedupe"
77-
status="stalled"
77+
status="blocked"
7878
stopped-at="2026-08-21T08:12:00-07:00"
7979
>
8080
<strong>Deduplicate the corpus snapshot</strong> Three hours of worker
8181
activity produced no commit. Last worktree:
82-
<a href="#tree-w-2">atlas/xml-cdata</a>.
82+
<a href="#tree-w-5">atlas/dedupe-attempt</a>.
8383
<lf-agent id="w-5" state="reaped" on="parser-dedupe">
8484
<strong>w-5</strong> Dedupe specialist, reaped after three hours without a
8585
commit; its branch and evidence remain inspectable.
8686
<lf-worktree id="tree-w-5" source="atlas-worktrees"></lf-worktree>
8787
</lf-agent>
88-
<lf-ask id="ask-dedupe-region">
89-
<lf-options
90-
id="ask-dedupe"
91-
label="What should happen to the stalled work?"
92-
choose
93-
>
94-
<lf-option id="dedupe-restart" for="parser-dedupe" recommended>
95-
<strong>Restart with a fresh worker</strong> Preserve the branch,
96-
commits, and comments; reap the old worker.
97-
</lf-option>
98-
<lf-option id="dedupe-snooze" for="parser-dedupe">
99-
<strong>Park it for tomorrow</strong> Keep the branch and take it out
100-
of today's plan.
101-
</lf-option>
102-
<lf-option id="dedupe-drop" for="parser-dedupe">
103-
<strong>Drop it</strong> Archive the branch; corpus storage stays at
104-
40 GB for this rewrite.
105-
</lf-option>
106-
</lf-options>
107-
</lf-ask>
88+
<lf-operations
89+
id="dedupe-operations"
90+
target="parser-dedupe"
91+
worker="w-5"
92+
worktree="tree-w-5"
93+
label="What should the host do with the stalled work?"
94+
>
95+
<lf-operation verb="restart" recommended>
96+
<strong>Restart with a fresh worker</strong> Preserve the branch,
97+
commits, and comments; reap the old worker.
98+
</lf-operation>
99+
<lf-operation verb="park">
100+
<strong>Park it for tomorrow</strong> Keep the branch and take it out of
101+
today's plan.
102+
</lf-operation>
103+
<lf-operation verb="drop">
104+
<strong>Drop it</strong> Archive the branch; corpus storage stays at 40
105+
GB for this rewrite.
106+
</lf-operation>
107+
</lf-operations>
108108
</lf-task>
109-
<lf-task id="parser-zero" status="active">
109+
<lf-task
110+
id="parser-zero"
111+
status="active"
112+
stopped-at="2026-08-21T08:46:00-07:00"
113+
>
110114
<strong>Choose the zero-row behavior</strong> This policy is consequential
111115
enough to wait for an explicit choice.
112116
<lf-ask id="ask-zero-region">
@@ -128,41 +132,37 @@ <h1>Atlas importer rewrite</h1>
128132
</lf-task>
129133
</lf-task>
130134

131-
<lf-task
132-
id="goal-schema"
133-
status="active"
134-
when="week 3"
135-
talk
136-
stopped-at="2026-08-21T07:20:00-07:00"
137-
>
135+
<lf-task id="goal-schema" status="active" when="week 3" talk>
138136
<strong>Reconcile schema and ledger</strong> Two goals and the nightly wait
139137
behind the schema choice.
140138
<lf-task
141139
id="schema-choice"
142-
status="active"
140+
status="review"
143141
stopped-at="2026-08-21T07:20:00-07:00"
144142
>
145143
<strong>Choose the additive schema</strong> Both columns are nullable; the
146144
migration and reverse path are green.
147-
<lf-agent id="w-8" state="working" on="schema-choice">
145+
<lf-agent id="w-8" state="waiting" on="schema-choice">
148146
<strong>w-8</strong> Schema-choice specialist: migration and
149147
reconciliation evidence.
150148
<lf-worktree id="tree-w-8" source="atlas-worktrees"></lf-worktree>
151149
</lf-agent>
152-
<lf-ask id="ask-schema-region">
153-
<lf-options id="ask-schema" label="Land the schema migration?" choose>
154-
<lf-option id="schema-land" for="schema-choice" recommended>
155-
<lf-chip tone="ok">tests green</lf-chip
156-
><lf-chip>unblocks 4 leaves</lf-chip>
157-
<strong>Land it now</strong> Shadow reads before anything depends on
158-
it.
159-
</lf-option>
160-
<lf-option id="schema-hold" for="schema-choice">
161-
<lf-chip tone="warn">4 idle behind it</lf-chip>
162-
<strong>Hold for the backfill</strong> One larger review tomorrow.
163-
</lf-option>
164-
</lf-options>
165-
</lf-ask>
150+
<lf-operations
151+
id="schema-operations"
152+
target="schema-choice"
153+
worker="w-8"
154+
worktree="tree-w-8"
155+
label="What should the host do with the schema branch?"
156+
>
157+
<lf-operation verb="land" recommended>
158+
<strong>Land it now</strong> Tests are green, it unblocks the dependent
159+
work, and shadow reads begin before anything depends on it.
160+
</lf-operation>
161+
<lf-operation verb="hold">
162+
<strong>Hold for the backfill</strong> Keep the dependent work idle and
163+
take one larger review tomorrow.
164+
</lf-operation>
165+
</lf-operations>
166166
</lf-task>
167167
<lf-task id="schema-backfill" status="planned" needs="schema-choice">
168168
<strong>Backfill reconciliation fields</strong>
@@ -196,38 +196,40 @@ <h1>Atlas importer rewrite</h1>
196196
</lf-task>
197197
</lf-task>
198198

199-
<lf-task
200-
id="goal-api"
201-
status="active"
202-
when="week 4"
203-
talk
204-
stopped-at="2026-08-21T10:35:00-07:00"
205-
>
199+
<lf-task id="goal-api" status="active" when="week 4" talk>
206200
<strong>Publish the parser contract</strong> Review the branch, not its
207201
author. A line comment routes to a fresh evidence worker and stays anchored
208202
here.
209-
<lf-task id="api-shape" status="active">
203+
<lf-task
204+
id="api-shape"
205+
status="review"
206+
stopped-at="2026-08-21T10:35:00-07:00"
207+
>
210208
<strong>Review the public result type</strong>
211-
<lf-agent id="w-3" state="working" on="api-shape">
209+
<lf-agent id="w-3" state="waiting" on="api-shape">
212210
<strong>w-3</strong> Public-contract specialist: result types and
213211
compatibility tests.
214212
<lf-worktree id="tree-w-3" source="atlas-worktrees"></lf-worktree>
215213
</lf-agent>
216-
<lf-ask id="ask-api-region">
217-
<lf-options id="ask-api" label="Disposition for atlas/public-api" choose>
218-
<lf-option id="api-land" for="api-shape" recommended>
219-
<strong>Land</strong> The compatibility suite is green.
220-
</lf-option>
221-
<lf-option id="api-revise" for="api-shape">
222-
<strong>Request changes</strong> Restate this card and dispatch a
223-
fresh revision worker; the request remains in the record.
224-
</lf-option>
225-
<lf-option id="api-override" for="api-shape">
226-
<strong>Land as-is — discard revision</strong> Explicitly overtake a
227-
standing change request and reap its reviser.
228-
</lf-option>
229-
</lf-options>
230-
</lf-ask>
214+
<lf-operations
215+
id="api-operations"
216+
target="api-shape"
217+
worker="w-3"
218+
worktree="tree-w-3"
219+
label="What should the host do with atlas/public-api?"
220+
>
221+
<lf-operation verb="land" recommended>
222+
<strong>Land</strong> The compatibility suite is green.
223+
</lf-operation>
224+
<lf-operation verb="request-changes">
225+
<strong>Request changes</strong> Restate this card and dispatch a fresh
226+
revision worker; the request remains in the record.
227+
</lf-operation>
228+
<lf-operation verb="land-as-is">
229+
<strong>Land as-is — discard revision</strong> Explicitly overtake a
230+
standing change request and reap its reviser.
231+
</lf-operation>
232+
</lf-operations>
231233
</lf-task>
232234
<lf-task id="api-errors" status="planned" needs="api-shape">
233235
<strong>Map structured failures</strong>

0 commit comments

Comments
 (0)