swarm repositories / source
aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: 471fc9a9a931479071e721ba053d6bdec3fce0e2 (plain)
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
# Fidget Spinner

Fidget Spinner is a local-first, agent-first experimental DAG for autonomous
program optimization, source capture, and experiment adjudication.

It is aimed at the ugly, practical problem of replacing sprawling experiment
markdown in worktree-heavy optimization projects such as `libgrid` with a
structured local system of record.

The current shape is built around four ideas:

- the DAG is canonical truth
- frontier state is a derived projection
- project payload schemas are local and flexible
- core-path work is hypothesis-owned and experiment-gated

## Current Scope

Implemented today:

- typed Rust core model
- per-project SQLite store under `.fidget_spinner/`
- project-local schema file
- light-touch project field types: `string`, `numeric`, `boolean`, `timestamp`
- hidden and visible node annotations
- core-path and off-path node classes
- CLI for local project work
- hardened stdio MCP host via `mcp serve`
- minimal web navigator via `ui serve`
- replay-aware disposable MCP worker runtime
- MCP health and telemetry tools
- bundled `fidget-spinner` base skill
- bundled `frontier-loop` specialization

Not implemented yet:

- long-lived daemon
- full web UI
- remote runners
- strong markdown migration
- cross-project indexing

## Local Install

Install the release CLI into `~/.local/bin` and refresh the bundled skill
symlinks in `~/.codex/skills` with:

```bash
./scripts/install-local.sh
```

Pass a different local install root or skill destination explicitly if needed:

```bash
./scripts/install-local.sh /tmp/fidget-local /tmp/codex-skills
```

## Quickstart

Initialize the current directory as a Fidget Spinner project:

```bash
cargo run -p fidget-spinner-cli -- init --project . --name fidget-spinner --namespace local.fidget-spinner
```

Create a frontier:

```bash
cargo run -p fidget-spinner-cli -- frontier init \
  --project . \
  --label "repo evolution" \
  --objective "improve the local MVP" \
  --contract-title "fidget spinner self-host frontier" \
  --benchmark-suite smoke \
  --promotion-criterion "cleaner and more capable" \
  --primary-metric-key research_value \
  --primary-metric-unit count \
  --primary-metric-objective maximize
```

Register project-level metric and run-dimension vocabulary before recording a
lot of experiments:

```bash
cargo run -p fidget-spinner-cli -- schema upsert-field \
  --project . \
  --name scenario \
  --class hypothesis \
  --class analysis \
  --presence recommended \
  --severity warning \
  --role projection-gate \
  --inference manual-only \
  --type string
```

```bash
cargo run -p fidget-spinner-cli -- metric define \
  --project . \
  --key wall_clock_s \
  --unit seconds \
  --objective minimize \
  --description "elapsed wall time"
```

```bash
cargo run -p fidget-spinner-cli -- dimension define \
  --project . \
  --key scenario \
  --type string \
  --description "workload family"
```

```bash
cargo run -p fidget-spinner-cli -- dimension define \
  --project . \
  --key duration_s \
  --type numeric \
  --description "time budget in seconds"
```

Record low-ceremony off-path work:

```bash
cargo run -p fidget-spinner-cli -- tag add \
  --project . \
  --name dogfood/mvp \
  --description "Self-hosted MVP dogfood notes"
```

```bash
cargo run -p fidget-spinner-cli -- source add \
  --project . \
  --title "next feature slate" \
  --summary "Investigate the next tranche of high-value product work." \
  --body "Investigate pruning, richer projections, and libgrid schema presets." \
  --tag dogfood/mvp
```

```bash
cargo run -p fidget-spinner-cli -- note quick \
  --project . \
  --title "first tagged note" \
  --summary "Tag-aware note capture is live." \
  --body "Tag-aware note capture is live." \
  --tag dogfood/mvp
```

Record a core-path hypothesis and open an experiment against it:

```bash
cargo run -p fidget-spinner-cli -- hypothesis add \
  --project . \
  --frontier <frontier-id> \
  --title "inline metric table" \
  --summary "Rendering candidate metrics on cards will improve navigator utility." \
  --body "Surface experiment metrics and objective-aware deltas directly on change cards."
```

```bash
cargo run -p fidget-spinner-cli -- experiment open \
  --project . \
  --frontier <frontier-id> \
  --hypothesis-node <hypothesis-node-id> \
  --title "navigator metric card pass" \
  --summary "Evaluate inline metrics on experiment-bearing cards."
```

```bash
cargo run -p fidget-spinner-cli -- metric keys --project .
```

```bash
cargo run -p fidget-spinner-cli -- metric best \
  --project . \
  --key wall_clock_s \
  --dimension scenario=belt_4x5 \
  --dimension duration_s=60 \
  --source run-metric
```

Serve the local MCP surface in unbound mode:

```bash
cargo run -p fidget-spinner-cli -- mcp serve
```

Serve the minimal local navigator:

```bash
cargo run -p fidget-spinner-cli -- ui serve --path . --bind 127.0.0.1:8913
```

`ui serve --path` is permissive: it accepts the project root, the
`.fidget_spinner/` directory itself, descendants inside that directory, or a
parent directory containing one unique descendant store.

Then bind the session from the client with:

```json
{"name":"project.bind","arguments":{"path":"<project-root-or-nested-path>"}}
```

If the target root is an existing empty directory, `project.bind` now
bootstraps `.fidget_spinner/` automatically instead of requiring a separate
`init` step. Non-empty uninitialized directories still fail rather than being
guessed into existence.

Install the bundled skills into Codex:

```bash
cargo run -p fidget-spinner-cli -- skill install
```

## Store Layout

Each initialized project gets:

```text
.fidget_spinner/
    project.json
    schema.json
    state.sqlite
    blobs/
```

`schema.json` is the model-facing contract for project-local payload fields and
their validation tiers. Fields may now optionally declare a light-touch
`value_type` of `string`, `numeric`, `boolean`, or `timestamp`; mismatches are
diagnostic warnings rather than ingest blockers.

`.fidget_spinner/` is local state. In git-backed projects it usually belongs in
`.gitignore` or `.git/info/exclude`.

## Model-Facing Surface

The current MCP tools are:

- `system.health`
- `system.telemetry`
- `project.bind`
- `project.status`
- `project.schema`
- `schema.field.upsert`
- `schema.field.remove`
- `tag.add`
- `tag.list`
- `frontier.list`
- `frontier.status`
- `frontier.init`
- `node.create`
- `hypothesis.record`
- `experiment.open`
- `experiment.list`
- `experiment.read`
- `node.list`
- `node.read`
- `node.annotate`
- `node.archive`
- `note.quick`
- `source.record`
- `metric.define`
- `metric.keys`
- `metric.best`
- `metric.migrate`
- `run.dimension.define`
- `run.dimension.list`
- `experiment.close`
- `skill.list`
- `skill.show`

Nontrivial MCP tools follow the shared presentation contract:

- `render=porcelain|json` chooses terse text vs structured JSON rendering
- `detail=concise|full` chooses triage payload vs widened detail
- porcelain is default and is intentionally not just pretty-printed JSON

Operationally, the MCP now runs as a stable host process that owns the public
JSON-RPC session and delegates tool execution to an internal worker subprocess.
Safe replay is only allowed for explicitly read-only operations and resources.
Mutating tools are never auto-replayed after worker failure.

Notes now require an explicit `tags` list. Tags are repo-local registry entries
created with `tag.add`, each with a required human description. `note.quick`
accepts `tags: []` when no existing tag applies, but the field itself is still
mandatory so note classification is always conscious.

`source.record` now also accepts optional `tags`, so rich imported documents
can join the same campaign/subsystem index as terse notes without falling back
to the generic escape hatch.

`note.quick`, `source.record`, and generic `node create` for `note`/`source`
now enforce the same strict prose split: `title` is terse identity, `summary`
is the triage/search layer, and `body` holds the full text. List-like surfaces
stay on `title` + `summary`; full prose is for explicit reads only.

Schema authoring no longer has to happen by hand in `.fidget_spinner/schema.json`.
The CLI exposes `schema upsert-field` / `schema remove-field`, and the MCP
surface exposes the corresponding `schema.field.upsert` / `schema.field.remove`
tools. The CLI uses space-separated subcommands; the MCP uses dotted tool names.

Metrics and run dimensions are now project-level registries. Frontier contracts
still declare the evaluation metric vocabulary, but closed experiments report
only thin `key=value` metrics plus typed run dimensions. `metric.define` can
enrich metric descriptions, CLI `dimension define` / MCP `run.dimension.define`
preregister slicers such as `scenario` or `duration_s`, `metric.keys`
discovers rankable numeric signals, and `metric.best` ranks one key within
optional exact dimension filters.
Legacy `benchmark_suite` data is normalized into a builtin string dimension on
store open, and `metric.migrate` can be invoked explicitly as an idempotent
repair pass.

The intended flow is:

1. inspect `system.health`
2. `project.bind` to the target project root or any nested path inside it
3. read `project.status`, `tag.list`, and `frontier.list`
4. read `experiment.list` if the session may be resuming in-flight work
5. read `project.schema` only when payload rules are actually relevant
6. pull context from the DAG
7. use `source.record` for documentary context and `note.quick` for atomic takeaways
8. record a `hypothesis` before core-path work
9. open the live experiment explicitly with `experiment.open`
10. seal core-path work with `experiment.close`

## Git And The Ledger

Git remains useful for code history, bisect, and sensible commit messages, but
the Fidget Spinner ledger is about the science rather than about reproducing git
inside the experiment record.

Core-path closure does not require a git-backed project. The canonical record is
the hypothesis, run slice, parsed metrics, verdict, and rationale.

## Workspace Layout

- `crates/fidget-spinner-core`: domain model and invariants
- `crates/fidget-spinner-store-sqlite`: per-project store and atomic writes
- `crates/fidget-spinner-cli`: CLI plus hardened stdio MCP host and worker
- `assets/codex-skills/fidget-spinner`: bundled base skill asset
- `assets/codex-skills/frontier-loop`: bundled skill asset

## Docs

- [docs/product-spec.md](docs/product-spec.md)
- [docs/architecture.md](docs/architecture.md)
- [docs/libgrid-dogfood.md](docs/libgrid-dogfood.md)

## Checks

```bash
./check.py
./check.py deep
```