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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
//! The composite "start a conversation" verb (DESIGN §3.4, §8.1, §15 M6 Z3):
//! **a pure planner + a step executor**, the one flow that turns Enter-in-a-box
//! into a running lernie loop.
//!
//! §3.4's two orthogonal axes, one composer. *Where* a prompt goes — the
//! [`Target`] workspace: the focused one, or, in a world with zero workspaces, a
//! freshly **minted** name (bootstrap is the empty case of the general path,
//! never a wizard). *What* it carries — the [`Payload`] rung: **bare** (an empty
//! composer), **path** (a work directory), or **ball** (a picked/created ball).
//!
//! [`plan`] is the pure planner: given the resolved [`PlanInputs`] (the target
//! *name* and the payload) it returns the ordered [`Step`] sequence — the amended
//! §8.1 order **seed → `lernie new` → `bl` mutations → prompt**, so every
//! substrate step precedes every `bl` mutation and a failed substrate can never
//! mint an orphaned claim. Every step is idempotent-or-convergent, so re-running
//! `plan` after a partial failure yields the shorter remainder: a bound ball
//! drops [`Step::Claim`], an existing workspace's [`Step::EnsureWorkspace`] is a
//! no-op skip. A **new** ball defers its id to a single [`Step::Create`]; the
//! executor re-plans the freshly-minted (Ready, unclaimed) ball — the
//! new→existing transition *is* the convergence, not a special case.
//!
//! The effectful half — the mint, the piped `bl`/`lernie` executors, the claim
//! cross-check, and the detached `lernie prompt` — lives in [`exec`]; the goal
//! composition and the pre-mint preview in [`goal`]. Identity is **harness
//! stamped at fire**, never editable prefill (§3.3): [`goal::preview`] renders
//! the greyed `You are <name>.` prediction pre-submit, and [`exec::execute_prompt`]
//! prepends the phase-1 [`identity_preamble`] as it fires.
use crateJoinState;
use PathBuf;
pub use ;
pub use ;
pub use ;
/// The **where** axis (§3.4): the target workspace a prompt lands in, resolved to
/// a `(name, path)` in [`prepare`] before [`plan`]. Minting is the empty case of
/// the general path (bootstrap or the explicit + New verb), not a branch.
/// The ball a start targets (§3.4 ball rung): an **existing** ball (id + join
/// state known, from the roster) or a **new** ball whose id `bl create` mints.
/// The **what** axis (§3.4): the payload rung, each the one below plus inputs.
/// The **unresolved** start request the shell hands [`prepare`] / [`preview`]:
/// the two axes plus the roots and the mint's occupied-set claimants. `home` is
/// the bare rung's driver cwd (`~`, resolved from the env at the shell boundary).
/// The **resolved** plan input (§8.1) [`plan`] is a pure function of: the target
/// workspace `name` and its `workspace` path (both minted-or-existing) and the
/// payload, plus the roots the worktree/seed paths derive from. The mint already
/// happened (in [`prepare`]); everything here is disk-and-join state. `name` is
/// the workspace leaf — the `--as`/`YOG_NAME`/identity stamp — and `workspace` is
/// its resolved absolute path (`<names-root>/<name>` for a mint, the focused path
/// for an existing one), the single source both the planner and the composer read.
/// One step of the start flow (§8.1). The sequence is a projection; [`prepare`]
/// runs the mutating steps in order and **defers** [`Prompt`](Step::Prompt) to
/// the composer (fired later, edited, by [`execute_prompt`]).
/// The pure planner (§8.1): the amended-order step sequence to reach a running
/// loop. Substrate first (seed, `lernie new`), then the ball rung's `bl`
/// mutations (create for a new ball — the id defers the rest to a re-plan; else
/// claim when unclaimed), then the deferred prompt. Re-run after any step and it
/// converges to the shorter remainder.
/// Whether the start flow must claim (§3.5, §8.1): a ready, unclaimed ball. A
/// ball already bound to its workspace ([`JoinState::Bound`]) drops the claim —
/// resume, not a second mint; re-claiming would trip bl's benign double-claim.
pub
/// Whether the roster offers a ▶ Start affordance for this join state (§3.5,
/// §11): a ready ball. A [`JoinState::Bound`] ball already has a running
/// workspace (re-prompt is the composer's job, §3.4).
/// Whether the roster offers a ▶ Continue (resume) affordance for this join state
/// (§8.1 resume, addendum): a [`JoinState::Bound`] ball. [`plan`] is total over
/// every join state — it will happily plan for a claimed-elsewhere ball — so this
/// predicate is the **only** guard against resuming a ball this yog does not own;
/// it must stay covered, never a shell-glue check. Routes through the same planner
/// (prompt-only, since [`claim_needed`] is false for a bound ball).