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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
|
# Fidget Spinner Architecture
## Current Shape
The current MVP implementation is intentionally narrower than the eventual full
product:
```text
agent host
|
| bundled fidget-spinner skills + stdio MCP
v
spinner MCP host
|
+-- public JSON-RPC transport
+-- session seed capture and restore
+-- explicit project binding
+-- tool catalog and replay contracts
+-- health and telemetry
+-- hot rollout / re-exec
|
+-- disposable MCP worker
| |
| +-- per-project SQLite store
| +-- per-project blob directory
| +-- git/worktree introspection
| +-- atomic experiment closure
|
v
<project root>/.fidget_spinner/
```
There is no long-lived daemon yet. The first usable slice runs MCP from the CLI
binary, but it already follows the hardened host/worker split required for
long-lived sessions and safe replay behavior.
## Package Boundary
The package currently contains three coupled layers:
- `fidget-spinner-core`
- `fidget-spinner-store-sqlite`
- `fidget-spinner-cli`
And two bundled agent assets:
- `assets/codex-skills/fidget-spinner/SKILL.md`
- `assets/codex-skills/frontier-loop/SKILL.md`
Those parts should be treated as one release unit.
## Storage Topology
Every initialized project owns a private state root:
```text
<project root>/.fidget_spinner/
project.json
schema.json
state.sqlite
blobs/
```
Why this shape:
- schema freedom stays per project
- migrations stay local
- backup and portability stay simple
- we avoid premature pressure toward a single global schema
Cross-project search can come later as an additive index.
## State Layers
### 1. Global engine spine
The engine depends on a stable, typed spine stored in SQLite:
- nodes
- node annotations
- node edges
- frontiers
- runs
- metrics
- experiments
- event log
This layer powers traversal, indexing, archiving, and frontier projection.
### 2. Project payload layer
Each node stores a project payload as JSON, namespaced and versioned by the
project schema in `.fidget_spinner/schema.json`.
This is where domain-specific richness lives.
Project field specs may optionally declare a light-touch `value_type` of:
- `string`
- `numeric`
- `boolean`
- `timestamp`
These are intentionally soft hints for validation and rendering, not rigid
engine-schema commitments.
### 3. Annotation sidecar
Annotations are stored separately from payload and are default-hidden unless
explicitly surfaced.
That separation is important. It prevents free-form scratch text from silently
mutating into a shadow schema.
## Validation Model
Validation has three tiers.
### Storage validity
Hard-fail conditions:
- malformed engine envelope
- broken ids
- invalid enum values
- broken relational integrity
### Semantic quality
Project field expectations are warning-heavy:
- missing recommended fields emit diagnostics
- missing projection-gated fields remain storable
- mistyped typed fields emit diagnostics
- ingest usually succeeds
### Operational eligibility
Specific actions may refuse incomplete records.
Examples:
- core-path experiment closure requires complete run/result/note/verdict state
- future promotion helpers may require a projection-ready hypothesis payload
## SQLite Schema
### `nodes`
Stores the global node envelope:
- id
- class
- track
- frontier id
- archived flag
- title
- summary
- schema namespace
- schema version
- payload JSON
- diagnostics JSON
- agent session id
- timestamps
### `node_annotations`
Stores sidecar free-form annotations:
- annotation id
- owning node id
- visibility
- optional label
- body
- created timestamp
### `node_edges`
Stores typed DAG edges:
- source node id
- target node id
- edge kind
The current edge kinds are enough for the MVP:
- `lineage`
- `evidence`
- `comparison`
- `supersedes`
- `annotation`
### `frontiers`
Stores derived operational frontier records:
- frontier id
- label
- root contract node id
- status
- timestamps
Important constraint:
- the root contract node itself also carries the same frontier id
That keeps frontier filtering honest.
### `runs`
Stores run envelopes:
- run id
- run node id
- frontier id
- backend
- status
- run dimensions
- command envelope
- started and finished timestamps
### `metrics`
Stores primary and supporting run metrics:
- run id
- metric key
- value
- unit
- optimization objective
### `experiments`
Stores the atomic closure object for core-path work:
- experiment id
- frontier id
- hypothesis node id
- run node id and run id
- optional analysis node id
- decision node id
- title
- summary
- verdict
- note payload
- created timestamp
This table is the enforcement layer for frontier discipline.
### `events`
Stores durable audit events:
- event id
- entity kind
- entity id
- event kind
- payload
- created timestamp
## Core Types
### Node classes
Core path:
- `contract`
- `hypothesis`
- `run`
- `analysis`
- `decision`
Off path:
- `source`
- `source`
- `note`
### Node tracks
- `core_path`
- `off_path`
Track is derived from class, not operator whim.
### Frontier projection
The frontier projection currently exposes:
- frontier record
- open experiment count
- completed experiment count
- verdict counts
This projection is derived from canonical state and intentionally rebuildable.
## Write Surfaces
### Low-ceremony off-path writes
These are intentionally cheap:
- `note.quick`, but only with explicit tags from the repo-local registry
- `source.record`, optionally tagged into the same repo-local taxonomy
- generic `node.create` for escape-hatch use
- `node.annotate`
### Low-ceremony core-path entry
`hypothesis.record` exists to capture intent before worktree state becomes muddy.
### Atomic core-path closure
`experiment.close` is the important write path.
It persists, in one transaction:
- run node
- run record
- decision node
- experiment record
- lineage and evidence edges
- frontier touch and verdict accounting inputs
That atomic boundary is the answer to the ceremony/atomicity pre-mortem.
## MCP Surface
The MVP MCP server is stdio-only and follows newline-delimited JSON-RPC message
framing. The public server is a stable host. It owns initialization state,
replay policy, telemetry, and host rollout. Execution happens in a disposable
worker subprocess.
Presentation is orthogonal to payload detail:
- `render=porcelain|json`
- `detail=concise|full`
Porcelain is the terse model-facing surface, not a pretty-printed JSON dump.
### Host responsibilities
- own the public JSON-RPC session
- enforce initialize-before-use
- classify tools and resources by replay contract
- retry only explicitly safe operations after retryable worker faults
- expose health and telemetry
- re-exec the host binary while preserving initialization seed and counters
### Worker responsibilities
- open the per-project store
- execute tool logic and resource reads
- return typed success or typed fault records
- remain disposable without losing canonical state
## Minimal Navigator
The CLI also exposes a minimal localhost navigator through `ui serve`.
Current shape:
- left rail of repo-local tags
- single linear node feed in reverse chronological order
- full entry rendering in the main pane
- lightweight hyperlinking for text fields
- typed field badges for `string`, `numeric`, `boolean`, and `timestamp`
This is intentionally not a full DAG canvas. It is a text-first operator window
over the canonical store.
## Binding Bootstrap
`project.bind` may bootstrap a project store when the requested target root is
an existing empty directory.
That is intentionally narrow:
- empty root: initialize and bind
- non-empty uninitialized root: fail
- existing store anywhere above the requested path: bind to that discovered root
### Fault model
Faults are typed by:
- kind: `invalid_input`, `not_initialized`, `transient`, `internal`
- stage: `host`, `worker`, `store`, `transport`, `protocol`, `rollout`
Those faults are surfaced both as JSON-RPC errors and as structured tool
errors, depending on call type.
### Replay contracts
The tool catalog explicitly marks each operation as one of:
- `safe_replay`
- `never_replay`
Current policy:
- reads such as `project.status`, `project.schema`, `tag.list`, `frontier.list`,
`frontier.status`, `node.list`, `node.read`, `skill.list`, `skill.show`, and
resource reads
are safe to replay once after a retryable worker fault
- mutating tools such as `tag.add`, `frontier.init`, `node.create`, `hypothesis.record`,
`node.annotate`, `node.archive`, `note.quick`, `source.record`, and
`experiment.close` are never auto-replayed
This is the hardening answer to side-effect safety.
Implemented server features:
- tools
- resources
### Tools
Implemented tools:
- `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`
- `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`
### Resources
Implemented resources:
- `fidget-spinner://project/config`
- `fidget-spinner://project/schema`
- `fidget-spinner://skill/fidget-spinner`
- `fidget-spinner://skill/frontier-loop`
### Operational tools
`system.health` returns a typed operational snapshot. Concise/default output
stays on immediate session state; full detail widens to the entire health
object:
- initialization state
- binding state
- worker generation and liveness
- current executable path
- launch-path stability
- rollout-pending state
- last recorded fault in full detail
`system.telemetry` returns cumulative counters:
- requests
- successes
- errors
- retries
- worker restarts
- host rollouts
- last recorded fault
- per-operation counts and last latencies
### Rollout model
The host fingerprints its executable at startup. If the binary changes on disk,
or if a rollout is explicitly requested, the host re-execs itself after sending
the current response. The re-exec carries forward:
- initialization seed
- project binding
- telemetry counters
- request id sequence
- worker generation
- one-shot rollout and crash-test markers
This keeps the public session stable while still allowing hot binary replacement.
## CLI Surface
The CLI remains thin and operational.
Current commands:
- `init`
- `schema show`
- `schema upsert-field`
- `schema remove-field`
- `frontier init`
- `frontier status`
- `node add`
- `node list`
- `node show`
- `node annotate`
- `node archive`
- `note quick`
- `tag add`
- `tag list`
- `source add`
- `metric define`
- `metric keys`
- `metric best`
- `metric migrate`
- `dimension define`
- `dimension list`
- `experiment close`
- `mcp serve`
- `ui serve`
- hidden internal `mcp worker`
- `skill list`
- `skill install`
- `skill show`
The CLI is not the strategic write plane, but it is the easiest repair and
bootstrap surface. Its naming is intentionally parallel but not identical to
the MCP surface:
- CLI subcommands use spaces such as `schema upsert-field` and `dimension define`
- MCP tools use dotted names such as `schema.field.upsert` and `run.dimension.define`
## Bundled Skill
The bundled `fidget-spinner` and `frontier-loop` skills should
be treated as part of the product, not stray prompts.
Their job is to teach agents:
- DAG first
- schema first
- cheap off-path pushes
- disciplined core-path closure
- archive rather than delete
- and, for the frontier-loop specialization, how to run an indefinite push
The asset lives in-tree so it can drift only via an explicit code change.
## Full-Product Trajectory
The full product should add, not replace, the MVP implementation.
Planned next layers:
- `spinnerd` as a long-lived local daemon
- HTTP and SSE
- read-mostly local UI
- runner orchestration beyond direct process execution
- interruption recovery and resumable long loops
- archive and pruning passes
- optional cross-project indexing
The invariant for that future work is strict:
- keep the DAG canonical
- keep frontier state derived
- keep project payloads local and flexible
- keep off-path writes cheap
- keep core-path closure atomic
- keep host-owned replay contracts explicit and auditable
|