swarm repositories / source
aboutsummaryrefslogtreecommitdiff
path: root/docs/architecture.md
blob: 2882c72c03638904bca3da4f93b95955dac469be (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
# Fidget Spinner Architecture

## Runtime Shape

The current runtime is intentionally simple and hardened:

```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
    |   +-- frontier / hypothesis / experiment / artifact services
    |   +-- navigator projections
    |
    v
<project root>/.fidget_spinner/
```

There is no long-lived daemon yet. The CLI binary owns the stdio host and the
local navigator.

## Package Boundary

The package contains three coupled crates:

- `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`

These are one release unit.

## Storage Topology

Every initialized project owns a private state root:

```text
<project root>/.fidget_spinner/
    project.json
    state.sqlite
```

Why this shape:

- migrations stay local
- backup and portability stay simple
- no global store is required
- git remains the code substrate instead of being mirrored into Spinner

## Canonical Types

### Frontier

Frontier is a scope and grounding object, not a graph vertex.

It owns:

- label
- objective
- status
- brief

And it partitions hypotheses and experiments.

### Hypothesis

Hypothesis is a true graph vertex. It carries:

- title
- summary
- exactly one paragraph of body
- tags
- influence parents

### Experiment

Experiment is also a true graph vertex. It carries:

- one mandatory owning hypothesis
- optional influence parents
- title
- summary
- tags
- status
- outcome when closed

The outcome contains:

- backend
- command envelope
- run dimensions
- primary metric
- supporting metrics
- verdict
- rationale
- optional analysis

### Artifact

Artifact is metadata plus a locator for an external thing. It attaches to
frontiers, hypotheses, and experiments. Spinner never reads or stores the
artifact body.

## Graph Semantics

Two relations matter:

### Ownership

Every experiment has exactly one owning hypothesis.

This is the canonical tree spine.

### Influence

Hypotheses and experiments may both cite later hypotheses or experiments as
influence parents.

This is the sparse DAG over the canonical tree.

The product should make the ownership spine easy to read and the influence
network available without flooding the hot path.

## SQLite Shape

The store is normalized around the new ontology:

- `frontiers`
- `frontier_briefs`
- `hypotheses`
- `experiments`
- `vertex_influences`
- `artifacts`
- `artifact_attachments`
- `metric_definitions`
- `run_dimension_definitions`
- `experiment_metrics`
- `events`

The important boundary is this:

- hypotheses and experiments are the scientific ledger
- artifacts are reference sidecars
- frontier projections are derived

## Presentation Model

The system is designed to be hostile to accidental context burn.

`frontier.open` is the only sanctioned overview dump. It should be enough to
answer:

- where the frontier stands
- which tags are active
- which metrics are live
- which hypotheses are active
- which experiments are open

Everything after that should require deliberate traversal:

- `hypothesis.read`
- `experiment.read`
- `artifact.read`

Artifact reads stay metadata-only by design.

## Replay Model

The MCP host owns:

- the public JSON-RPC session
- initialize-before-use semantics
- replay contracts
- health and telemetry
- host rollout

The worker owns:

- project-store access
- tool execution
- typed success and fault results

Reads and safe operational surfaces may be replayed after retryable worker
faults. Mutating operations are never auto-replayed unless they are explicitly
designed to be safe.

## Navigator

The local navigator mirrors the same philosophy:

- root page lists frontiers
- frontier page is the only overview page
- hypothesis and experiment pages are detail reads
- artifacts are discoverable but never expanded into body dumps

The UI should help a model or operator walk the graph conservatively, not tempt
it into giant all-history feeds.