@cordfuse/politik 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/EXECUTION.md +766 -0
  2. package/LICENSE +21 -0
  3. package/POLITIK-ARCHITECTURE.md +676 -0
  4. package/PROTOCOLS.md +1106 -0
  5. package/README.md +193 -0
  6. package/RESEARCH.md +475 -0
  7. package/RUNTIME.md +1355 -0
  8. package/bin/politik.js +31 -0
  9. package/docs/adr/0001-chamber-transport.md +67 -0
  10. package/docs/adr/0002-charter-schema.md +142 -0
  11. package/docs/adr/0003-state-json-schema.md +134 -0
  12. package/docs/adr/0004-motion-enactment.md +215 -0
  13. package/docs/adr/0005-hansard-format.md +171 -0
  14. package/docs/adr/0006-protocol-behavioral-enforcement.md +89 -0
  15. package/docs/adr/0007-protocol-mechanics.md +100 -0
  16. package/docs/adr/0008-session-storage.md +108 -0
  17. package/docs/adr/0009-match-primitive.md +74 -0
  18. package/package.json +55 -0
  19. package/protocols/CONTRIBUTING.md +130 -0
  20. package/protocols/adversarial-collaboration.yml +28 -0
  21. package/protocols/corporate.yml +35 -0
  22. package/protocols/elimination-tournament.yml +41 -0
  23. package/protocols/emergency-response-ics.yml +27 -0
  24. package/protocols/jury-deliberation.yml +32 -0
  25. package/protocols/monarchy.yml +31 -0
  26. package/protocols/parliamentary.yml +66 -0
  27. package/protocols/peer-review.yml +44 -0
  28. package/protocols/republic.yml +36 -0
  29. package/protocols/socialism-collective.yml +31 -0
  30. package/protocols/solo.yml +32 -0
  31. package/src/actors.ts +742 -0
  32. package/src/agents.ts +318 -0
  33. package/src/canon.ts +173 -0
  34. package/src/capability.ts +336 -0
  35. package/src/charter.ts +545 -0
  36. package/src/cli.ts +2174 -0
  37. package/src/conflict.ts +211 -0
  38. package/src/containment.ts +155 -0
  39. package/src/crisis.ts +381 -0
  40. package/src/division.ts +609 -0
  41. package/src/doctor.ts +168 -0
  42. package/src/election.ts +233 -0
  43. package/src/envelope.ts +223 -0
  44. package/src/escalation.ts +320 -0
  45. package/src/fault.ts +241 -0
  46. package/src/federation.ts +299 -0
  47. package/src/git.ts +163 -0
  48. package/src/hansard.ts +201 -0
  49. package/src/heartbeat.ts +282 -0
  50. package/src/index.ts +43 -0
  51. package/src/init.ts +396 -0
  52. package/src/integrity.ts +153 -0
  53. package/src/ledger.ts +341 -0
  54. package/src/lockfs.ts +58 -0
  55. package/src/projection.ts +293 -0
  56. package/src/prorogation.ts +307 -0
  57. package/src/protocol-sdk.ts +248 -0
  58. package/src/protocol.ts +241 -0
  59. package/src/providers/github.ts +347 -0
  60. package/src/quorum.ts +137 -0
  61. package/src/runner.ts +534 -0
  62. package/src/scm.ts +142 -0
  63. package/src/spawn.ts +160 -0
  64. package/src/standings.ts +143 -0
  65. package/src/state.ts +179 -0
  66. package/src/templates/parliamentary.ts +359 -0
  67. package/src/tournament.ts +200 -0
  68. package/src/transport.ts +190 -0
  69. package/src/tree.ts +371 -0
package/EXECUTION.md ADDED
@@ -0,0 +1,766 @@
1
+ # POLITIK — EXECUTION PLAN
2
+
3
+ **Attribution:** Steve Krisjanovs, Cordfuse
4
+
5
+ Phased implementation plan (phases 0–11) and the Politik Tree hierarchical architecture.
6
+
7
+ See [POLITIK-ARCHITECTURE.md](POLITIK-ARCHITECTURE.md) for CANON and the engine layer.
8
+
9
+ ---
10
+
11
+ ## EXECUTION PLAN
12
+
13
+ ### PHASE 0 — Naming ✅ COMPLETE
14
+ ```
15
+ [x] Name the framework — POLITIK
16
+ [x] Verify npm namespace — @cordfuse/politik (verify before first publish)
17
+ [x] Verify GitHub org namespace — cordfuse/politik
18
+ [x] Verify Docker Hub namespace — cordfuse/politik
19
+ [ ] Register all namespaces privately
20
+ [x] Update this document with confirmed name — done
21
+ ```
22
+ ### PHASE 0.5 — Prior Art ✅ COMPLETE
23
+ ```
24
+ [x] Create private GitHub repo — cordfuse/politik
25
+ [x] Initial commit — markdown docs only
26
+ [x] Tag v0.1.0-architecture
27
+ [x] Enable Zenodo on repo
28
+ [x] Create public GitHub release from tag
29
+ [x] Zenodo DOI minted — 10.5281/zenodo.19490359
30
+ [x] DOI confirmed — doi.org/10.5281/zenodo.19490359
31
+ ```
32
+
33
+ ### PHASE 1 — Architecture Lock
34
+
35
+ ADRs live in [`docs/adr/`](docs/adr/). An item is ticked only when a decision is
36
+ recorded **and** nothing blocks it.
37
+
38
+ ```
39
+ [x] Finalize CANON primitive layer names — POLITIK-ARCHITECTURE.md
40
+ [x] Finalize protocol schema format — POLITIK-ARCHITECTURE.md
41
+ [x] Finalize broadcast envelope format — POLITIK-ARCHITECTURE.md
42
+ [x] Finalize session repo structure — POLITIK-ARCHITECTURE.md
43
+ [x] Transport hook: git-based default (zero infrastructure, reference transport; Crosstalk is one such implementation), NATS an opt-in latency upgrade (Tailscale + NATS for multi-machine) — libp2p rejected (over-built for known permissioned assemblies). See ADR-0001.
44
+ [x] Finalize CHARTER.md spec — ADR-0002 (Accepted)
45
+ [x] Finalize STATE.json schema — ADR-0003 (Accepted)
46
+ [x] Finalize SCM provider interface spec — return types settled in src/scm.ts
47
+ [x] Document all decisions in ADRs — 0001, 0002, 0003 Accepted
48
+ [ ] Draft arXiv preprint — unified paper (framework + experiment)
49
+ ```
50
+
51
+ **Both rulings are settled. `POLITIK-ARCHITECTURE.md` was not amended.**
52
+
53
+ 1. **`mode` / `record_mode`** are protocol-level keys only. The `session:` block
54
+ never legitimately owned them — `quorum: 1` already declares a solo session,
55
+ and the Hansard is required by default. Corrected in RUNTIME.md. See ADR-0002.
56
+ 2. **`CONSTITUTIONAL_CRISIS` is a cause of suspension**, not a sixth state and
57
+ not a free-standing fault. RUNTIME.md § Constitutional Capture already
58
+ specifies that it auto-suspends the session. CANON stays at five states. See
59
+ ADR-0003.
60
+
61
+ **Settled in the scaffold.** The SCM provider interface named its methods but no
62
+ return types — a signature exercise rather than a governance decision. Return
63
+ types are now fixed in `src/scm.ts`, where every call is async and every mutation
64
+ returns a typed handle so the Hansard writer has something attributable to
65
+ record.
66
+
67
+ *Correction:* this section previously said the interface names *ten* methods.
68
+ `POLITIK-ARCHITECTURE.md` § SCM PROVIDER ABSTRACTION lists **eleven**. The
69
+ architecture document is authoritative and the implementation follows it.
70
+
71
+ ### PHASE 2 — Reference Implementation (GitHub SCM)
72
+
73
+ Stack: Node + TypeScript, npm `@cordfuse/politik`, binary `politik`. Tests run
74
+ on `node:test` via tsx. Everything except the SCM provider and the CLI is pure —
75
+ no I/O, no clock, no randomness.
76
+
77
+ ```
78
+ [x] Scaffold cordfuse/politik private repo — package.json, tsconfig, CI-ready
79
+ [x] Implement CHARTER.md parser and validator — src/charter.ts (ADR-0002 rules 1-8)
80
+ [x] Implement session repo initializer (Writ Drop)— src/init.ts
81
+ [x] Implement GitHub SCM provider — src/providers/github.ts (see note)
82
+ [x] Implement broadcast envelope parser — src/envelope.ts
83
+ [x] Implement first-actor-per-constituency election— src/election.ts + src/lockfs.ts
84
+ [x] Implement Hansard commit writer — src/hansard.ts
85
+ [x] Implement Point of Order workflow — src/escalation.ts
86
+ [x] Implement Speaker email notification — provider notify() + session workflow
87
+ [x] Implement quorum check — src/quorum.ts
88
+ [x] Implement prorogation workflow — src/prorogation.ts
89
+ ```
90
+
91
+ **Note — `openDiscussion` is deferred to Phase 4.** GitHub exposes discussion
92
+ creation only through GraphQL, and its category *ID* requirement conflicts with
93
+ the `category` parameter in the interface. Adopting it would put a second
94
+ protocol and a second auth path inside an otherwise REST-only provider. Nothing
95
+ in Phase 2 exercises the debate floor. The method throws a 501 rather than
96
+ silently succeeding.
97
+
98
+ **Note — Speaker notification has two delivery paths.** `ScmProvider.notify()`
99
+ opens a labelled issue @-mentioning the actor, which GitHub turns into email via
100
+ the recipient's own notification settings. Separately, the session repo
101
+ initializer installs `.github/workflows/point-of-order.yml` (RUNTIME.md § Point
102
+ of Order Workflow) for direct SMTP delivery on push to `escalations/`. The
103
+ workflow's path filter excludes rulings — a ruling is the Speaker's own reply,
104
+ and notifying them of it would loop. It requires three repository secrets
105
+ (`MAIL_USERNAME`, `MAIL_PASSWORD`, `SPEAKER_EMAIL`) and fails loudly without
106
+ them, because an escalation nobody hears is the exact failure this flow exists
107
+ to prevent.
108
+
109
+ **Verified live.** The provider was exercised against a real GitHub repository:
110
+ Writ Drop committed as a single commit (blobs → tree → commit → ref), label
111
+ created, escalation issue filed, suspension state committed, notification
112
+ delivered, `openDiscussion` refused as designed.
113
+
114
+ ### PHASE 3 — Agent Compatibility Layer
115
+
116
+ Implemented in `src/agents.ts` (registry, invocation shapes, prompt injection)
117
+ and `src/spawn.ts` (process lifecycle). The registry is a data table, not a class
118
+ per agent — agents differ only in argv shape and auth story.
119
+
120
+ ```
121
+ [x] Claude Code integration and test — PASS, live
122
+ [x] Gemini CLI integration and test — PASS, live (needs --skip-trust)
123
+ [x] OpenCode integration and test — PASS, live
124
+ [x] Codex CLI integration and test — PASS, live (exec subcommand, in a git repo)
125
+ [x] Antigravity integration and test — PASS, live (added; see note)
126
+ [~] Qwen Code integration and test — implemented; local auth unconfigured
127
+ [ ] Aider integration and test — not installed on this host
128
+ [ ] Goose integration and test — not installed on this host
129
+ [x] Document prompt injection format per agent
130
+ [x] Document headless invocation per agent
131
+ ```
132
+
133
+ **Live results.** Each agent was driven through `spawnAgent()` with a trivial
134
+ prompt and had to return a specific token. Five passed.
135
+
136
+ **Cost measurement — five of nine agents report usage.** The LEDGER was
137
+ `unmeasured` for everything but Claude Code until the adapters were probed
138
+ directly:
139
+
140
+ | Agent | Tokens | Cost | Model |
141
+ |---|---|---|---|
142
+ | Claude Code | yes | yes | yes |
143
+ | OpenCode | yes | yes | yes |
144
+ | Gemini CLI | yes | — | yes |
145
+ | Codex CLI | yes | — | — |
146
+ | Qwen Code | yes (same shape as Gemini) | — | yes |
147
+ | Antigravity | — | — | — |
148
+ | GitHub Copilot | — | — | — |
149
+ | Aider, Goose | not installed | — | — |
150
+
151
+ Where a vendor does not report spend the row records `unmeasured`, never a
152
+ figure derived from a rate card. An estimate dressed as a measurement is the one
153
+ failure this ledger exists to avoid.
154
+
155
+ **Supported set.** The agents in active use — and the ones the LEDGER is kept
156
+ honest for — are **Claude Code, Antigravity (`agy`), Codex, OpenCode**. **GitHub
157
+ Copilot** is now in the registry too (see below), with live measurement pending a
158
+ subscription. Everything else stays in the registry and runs, but is not on the
159
+ critical path.
160
+
161
+ **Backlog (active).**
162
+
163
+ | Agent | Blocker | To close |
164
+ |---|---|---|
165
+ | Antigravity | usage only emits under `--dangerously-skip-permissions` | capture one real sample, then add its ledger parser |
166
+ | GitHub Copilot | needs an active Copilot subscription with the CLI policy enabled | verify live, then capture usage shape for its parser |
167
+
168
+ **GitHub Copilot — added (auth model corrected).** The registry originally
169
+ excluded Copilot as an IDE tool "with no headless prompt" and required every
170
+ agent to run headless via an API key. Both premises were wrong: the agentic
171
+ `copilot -p --allow-all-tools` has a headless prompt, and headless auth is not
172
+ API-key-only — a persisted OAuth token runs unattended (proven live this session
173
+ for Claude, Codex, OpenCode, agy). `canRunHeadless` now accepts any
174
+ non-interactive credential (OAuth, API key, AWS), and Copilot is in the registry
175
+ with OAuth headless auth. Its ledger parser lands once a real usage sample is
176
+ captured against an active subscription — same as Antigravity.
177
+
178
+ **Roadmap — help wanted (outside the used set).** Gemini, Qwen, Aider, Goose.
179
+ Gemini and Qwen already report tokens and keep working; Aider and Goose record
180
+ `unmeasured`. All ship as runnable agents. Verifying or adding their measurement
181
+ is **deferred and open for a PR** — a missing parser returns `null`, never a
182
+ fabricated number. Not on the v1 critical path.
183
+
184
+ Phase 3 is otherwise complete.
185
+
186
+ **Antigravity added.** `agy` supports `-p`/`--print` headless, is a
187
+ Cordfuse-supported CLI, and was absent from the compatibility table. Verified
188
+ live and added to both the table and the registry.
189
+
190
+ **Two spec errors found by live testing**, both corrected in RUNTIME.md
191
+ § Politik Compatible:
192
+
193
+ 1. **Codex CLI was documented as `codex "..."`.** That form starts an
194
+ interactive TUI and fails headlessly with `stdin is not a terminal`. The
195
+ headless form is `codex exec "..."`. Codex additionally requires the working
196
+ directory to be a git repository — always true of a session repo, but not of
197
+ an arbitrary temp directory.
198
+ 2. **Gemini CLI refuses to run in an untrusted directory**, exiting 55. It needs
199
+ `--skip-trust`, now carried as a required headless arg rather than left to
200
+ the caller.
201
+
202
+ **Prompt injection format.** One format for every agent: role and mandate,
203
+ granted verbs, Standing Orders, Hansard excerpt (agents are stateless — the
204
+ record is their context), the business at hand, then the rules of the floor.
205
+ Deliberately uniform: per-agent prompt tuning would void the cross-protocol
206
+ comparisons the research layer depends on.
207
+
208
+ ### PHASE 4 — Parliamentary Protocol (reference protocol)
209
+
210
+ ```
211
+ [x] Implement CANON → Parliamentary vocabulary mapping — src/protocol.ts + protocols/parliamentary.yml
212
+ [x] CHARTER.md template (Parliamentary) — src/templates/parliamentary.ts
213
+ [x] Role templates (Speaker, Minister, Backbencher, …) — one per CANON role, five in total
214
+ [x] Standing Orders template — prose body of the Charter template
215
+ [x] Hansard format spec — ADR-0005 (Accepted)
216
+ [x] GitHub label taxonomy — LABEL_TAXONOMY, nine labels
217
+ [x] GitHub Projects Order Paper template — ORDER-PAPER.md
218
+ [x] GitHub Milestone workflow — a Milestone is a sitting; see note
219
+ ```
220
+
221
+ **The protocol layer is translation, not behaviour.** A protocol maps CANON
222
+ terms to an industry vocabulary for the interface and for humans. Nothing in a
223
+ manifest changes engine behaviour except four declared flags — `no_escalation`,
224
+ `no_record`, `immutable_charter`, and the `record_mode` that ADR-0002 rule 5
225
+ tests against. A DIVISION is a DIVISION whether it renders as "Division" or
226
+ "Sprint Review".
227
+
228
+ **Record types stay in CANON.** A Parliamentary session records
229
+ `POINT_OF_ORDER`, never "Point of Order" (ADR-0005 ruling 3). Translation is
230
+ presentation; the record must stay machine-comparable across protocols, which is
231
+ what makes the research layer possible at all.
232
+
233
+ **Unmapped terms warn rather than fail.** A protocol that omits a term falls
234
+ back to the CANON word, which is readable by design. Refusing to load an
235
+ incomplete manifest would make authoring a protocol needlessly brittle.
236
+
237
+ **Hansard format settled.** ADR-0005 ratifies the two choices Phase 2 had to
238
+ make provisionally — entries at H2 under the document's H1 title, and an open
239
+ record-type set — and adds five further rulings covering the heading format,
240
+ mandatory attribution, single-line fields, mechanical append-only, and the
241
+ principle that reading the record is never authoritative (git history is).
242
+ `src/hansard.ts` needed no change.
243
+
244
+ **Milestone workflow.** A Milestone is a sitting: the business intended for one
245
+ continuous stretch of a proceeding, mapped in ORDER-PAPER.md. Closing it is part
246
+ of prorogation — `prorogue()` returns `milestone_to_close` and the GitHub
247
+ provider implements `closeMilestone()`. No separate automation is required.
248
+
249
+ **Verified end to end** through the CLI: `scaffold` → `validate` → `init` →
250
+ `status`. The scaffolded Charter passes Writ Drop validation against the
251
+ Parliamentary protocol, including rule 5 — the template uses `merge_commit`
252
+ because Parliamentary declares `record_mode: distributed`, under which squash is
253
+ rejected. A test asserts this so the template and the validator cannot drift.
254
+
255
+ **New CLI command:** `politik scaffold --out <dir> [--quorum <n>]` writes the
256
+ Charter, Order Paper and role files for editing. Deliberately separate from
257
+ `init`: scaffolding produces prose for a Speaker to read and edit, `init` drops
258
+ the Writ and opens the session. Conflating them would convene a session on an
259
+ unread template.
260
+
261
+ ### PHASE 5 — Protocol Library
262
+
263
+ **Framing note:** Parliamentary is protocol #1, not a privileged mode.
264
+ All protocols are equal. The framework is protocol-agnostic.
265
+
266
+ **Shipped with framework (reference protocols):** all ten in `protocols/`,
267
+ every one lint-clean.
268
+
269
+ ```
270
+ [x] Parliamentary Democracy (reference protocol — ships first) parliamentary.yml
271
+ [x] Agile / Scrum agile.yml
272
+ [x] Military Operation military.yml
273
+ [x] Criminal Trial / Legal legal.yml
274
+ [x] Corporate / Board corporate.yml
275
+ [x] Battle Royale battle-royale.yml
276
+ [x] League Season (sports) league-season.yml
277
+ [x] Elimination Tournament — Single elimination-tournament.yml
278
+ [x] Peer Review (scientific research) peer-review.yml
279
+ [x] Red Team / Blue Team Science red-blue-team.yml
280
+ ```
281
+
282
+ All five modes are represented: constitutional (parliamentary, agile, legal,
283
+ corporate, league-season, peer-review), authoritarian (military,
284
+ red-blue-team), and darwinist (battle-royale, elimination-tournament). Ephemeral
285
+ and immutable have no reference protocol yet — they appear in the community
286
+ list.
287
+
288
+ **Power inversions are declared, never inferred.** `legal.yml` gives the Jury
289
+ (OBSERVER) a domain veto over the final Division; `peer-review.yml` lets a
290
+ reviewer reject on methodology alone. Both contradict the trust hierarchy, which
291
+ is exactly why CANON models them as `domain_veto` rather than deriving them.
292
+
293
+ **One mapping conflict found in PROTOCOLS.md.** Red Team / Blue Team lists
294
+ OPERATOR and MEMBER twice each, once per side (Red Team Lead / Blue Team Lead).
295
+ A CANON role cannot map to two terms. Resolved by rendering both side-neutrally
296
+ ("Team Lead", "Team Agent") and carrying the side in each actor's
297
+ `mandate_alignment` — mandate is an actor property, vocabulary is protocol-wide.
298
+
299
+ **Ship shortly after (community-ready protocols):**
300
+ ```
301
+ [ ] Republic (US-style)
302
+ [ ] Open Source / RFC
303
+ [ ] DevOps / Incident Response
304
+ [ ] Film / TV Production
305
+ [ ] Clinical / Hospital
306
+ [ ] Emergency Response / ICS
307
+ [ ] MMO Raid / Guild
308
+ [ ] Startup
309
+ [ ] Hackathon
310
+ [ ] Adversarial Collaboration (scientific research)
311
+ [ ] Replication Crisis (scientific research)
312
+ [ ] Pre-registration / Open Science (scientific research)
313
+ [ ] Grand Challenge (scientific research)
314
+ ```
315
+
316
+ **Community contribution protocols (documented, PRs welcome):**
317
+ ```
318
+ Politics: Socialism, Fascism, Monarchy
319
+ Sports: Double Elimination, Round Robin, Swiss System,
320
+ Draft/Fantasy, Olympic/Multi-Sport, Motorsport/F1,
321
+ eSports Match
322
+ Military: Intelligence/Espionage (ephemeral), Cybersecurity/Red Team
323
+ Legal: Arbitration, Jury Deliberation (ephemeral record)
324
+ Healthcare: Clinical Trial/Research
325
+ Business: Investment/Trading, Auction House
326
+ Education: Academic/University, Debate Competition
327
+ Creative: Theatre, Music Recording, Game Development
328
+ Community: Organized Crime (ephemeral), Religion (immutable),
329
+ Neighbourhood/HOA, Pirate Crew
330
+ Novel: Improv Theatre (ephemeral), Archaeological Dig,
331
+ Antarctic Expedition
332
+ Game Theory: Formal analytical structures (Zero-Sum, Cooperative,
333
+ Prisoner's Dilemma, Stag Hunt, Auction/Mechanism Design,
334
+ Iterated Game, Coalition Formation, Signalling Game)
335
+ — embedded in protocol definitions post-research,
336
+ not user-selectable protocols
337
+ ```
338
+
339
+ **Protocol SDK:**
340
+ ```
341
+ [x] Protocol schema format specification — POLITIK-ARCHITECTURE.md + src/protocol.ts
342
+ [x] Protocol validator (lints against CANON) — src/protocol-sdk.ts, politik protocol lint
343
+ [x] Protocol template generator — politik protocol new
344
+ [x] Community contribution guide — protocols/CONTRIBUTING.md
345
+ ```
346
+
347
+ **Loadable is not coherent.** `parseProtocol` answers "will this manifest
348
+ load?"; the linter answers "is it coherent?" A manifest with `mode: darwinist`
349
+ and `no_escalation: false` loads cleanly and then produces a session that accepts
350
+ appeals a Darwinist protocol has no mechanism to resolve. The linter separates
351
+ errors (unusable — a term CANON does not have, two roles sharing one label, an
352
+ ephemeral record mode that still claims to record) from warnings (likely
353
+ mistakes — non-semver version, unmapped role, flags inconsistent with the mode).
354
+
355
+ **Warnings are not silently suppressed.** `red-blue-team.yml` ships with one:
356
+ PROTOCOLS.md gives the Referee — who *is* AUTHORITY — a domain veto, which is
357
+ mechanically redundant since AUTHORITY already holds VETO. The manifest keeps it
358
+ to stay faithful to the published protocol, and a comment explains why the
359
+ warning is expected. The linter found this in the framework's own library.
360
+
361
+ **New CLI surface:**
362
+ ```
363
+ politik protocol lint <manifest.yml>
364
+ politik protocol new <name> [--mode <mode>] [--out <dir>]
365
+ ```
366
+
367
+ The generated skeleton maps every CANON role, primitive and verb to itself, so
368
+ the full translatable surface is visible in the file rather than discoverable
369
+ only from documentation.
370
+
371
+ ### PHASE 6 — Platform Testing
372
+
373
+ `politik doctor` probes a host and reports whether a session can run there and
374
+ with which agents. The matrix below is what that probe has actually returned —
375
+ not a table of expectations. Unverified rows are marked as such and stay
376
+ unticked; a checkbox nobody exercised is worse than an empty one, because it
377
+ reads as evidence.
378
+
379
+ **Verified**
380
+
381
+ ```
382
+ [x] Linux bare metal — OAuth steve-cachyos, Node 26, 6 agents, ollama present
383
+ [x] Linux Docker — API key node:22-alpine + git, full lifecycle + the whole test suite
384
+ [x] Ollama local — zero auth detected and reported by doctor
385
+ ```
386
+
387
+ Linux bare metal: `doctor` reports READY with six agents installed
388
+ (claude-code, gemini-cli, opencode, qwen-code, codex-cli, antigravity); five of
389
+ those were driven live in Phase 3.
390
+
391
+ Linux Docker: `doctor` → `scaffold` → `validate` → `init` → `status` →
392
+ `prorogue` all completed inside `node:22-alpine`, and the full test suite ran
393
+ green in the container. `doctor` correctly reported NOT READY (exit 1) in a
394
+ container *without* git, which is the check earning its keep.
395
+
396
+ **Unverified — no host available**
397
+
398
+ ```
399
+ [ ] macOS bare metal — OAuth Steves-Air; SSH access revoked
400
+ [ ] macOS Docker — OAuth + DISPLAY same
401
+ [ ] Windows Pro bare metal — OAuth no Node/agent install on the Windows test host
402
+ [ ] WSL2 + Docker — API key STEVE-DESKTOP not reachable from this session
403
+ [ ] Windows Home bare metal — OAuth no host
404
+ [ ] VPS headless — API key none provisioned; cost acknowledged
405
+ [ ] Codespaces — API key not provisioned; cost acknowledged
406
+ ```
407
+
408
+ Each closes out by running `politik doctor` on the host and recording the
409
+ output. No code change is expected — but Phase 3 found two spec errors that way,
410
+ so "expected" is not "verified".
411
+
412
+ **Two findings from containerised testing**
413
+
414
+ 1. **Unhandled `EPIPE`.** `politik status | head` crashed with a stack trace
415
+ when the reader closed the pipe early. Normal Unix pipeline behaviour, not an
416
+ error — the binary now exits quietly, as every other CLI does. Found by
417
+ piping output inside the container, not by any test.
418
+ 2. **`doctor` requires git, not merely prefers it.** A container with Node but
419
+ no git reports FAIL and exit 1. The repository *is* the session; without git
420
+ there is no substrate, so this is correctly fatal rather than a warning.
421
+
422
+ **OAuth does not survive a headless container.** Agents whose local auth is
423
+ OAuth cannot complete a browser login without a display, so `doctor` warns when
424
+ it finds OAuth-default agents inside a container and points at API keys — the
425
+ documented headless path (RUNTIME.md § Cloud / Headless).
426
+
427
+ ### PHASE 7 — SCM Provider SDK
428
+
429
+ **Cordfuse ships and maintains the GitHub reference implementation only.** The
430
+ three alternative providers are community contributions, as marked below and in
431
+ POLITIK-ARCHITECTURE.md § SCM PROVIDER ABSTRACTION (`gitlab ← community
432
+ contribution`). One provider maintained properly is worth more than four
433
+ maintained thinly.
434
+
435
+ ```
436
+ [x] Document SCM provider interface — docs/SCM-PROVIDERS.md
437
+ [x] Provider contribution guide — docs/SCM-PROVIDERS.md § Contributing
438
+ [ ] GitLab provider (community) — not a Cordfuse deliverable
439
+ [ ] Gitea provider (community) — not a Cordfuse deliverable
440
+ [ ] Forgejo provider (community) — not a Cordfuse deliverable
441
+ ```
442
+
443
+ The Cordfuse scope of this phase is complete. The three unticked rows stay
444
+ unticked until someone contributes them; they are not outstanding work on this
445
+ side.
446
+
447
+ **A provider is transport and platform mapping only.** It never decides whether
448
+ a Motion carried, whether an actor may vote, or whether a session is suspended —
449
+ those are settled before a provider method is called. `merge()` enacts a Motion;
450
+ it does not check that the Motion carried, because that answer belongs in the
451
+ Hansard. A provider making governance decisions has moved logic out of the
452
+ record's reach, which defeats the framework.
453
+
454
+ **Eight contracts** are documented: async everywhere, typed handles rather than
455
+ bare strings, one commit per `commit()` call, unfavourable outcomes as results
456
+ rather than exceptions, no credentials in error messages, loud failure on
457
+ unimplementable methods, explicit role→permission mapping declared as a design
458
+ decision, and documented merge-strategy approximations.
459
+
460
+ **Injectable transport is a requirement, not a suggestion.** The reference
461
+ provider takes `fetch` as a constructor option, which is what lets its twenty
462
+ tests assert exact request shapes with no network and no token. A provider that
463
+ hard-codes its client cannot be tested without credentials, and those tests
464
+ never get run.
465
+
466
+ ### PHASE 7.5 — Session Runner (the engine loop)
467
+
468
+ **Not in the original plan, and its absence was the plan's most serious gap.**
469
+
470
+ Phases 2–7 delivered components: Charter parser, validator, initializer, SCM
471
+ provider, envelope parser, election mutex, Hansard writer, quorum, escalation,
472
+ prorogation, agent registry, spawner, protocol layer, templates. Every one
473
+ tested. Not one of them *runs a session* — and nothing in `src/` called
474
+ `spawnAgent`, `composePrompt` or `standForElection` outside their own tests.
475
+
476
+ Politik was a complete set of parts with no engine.
477
+
478
+ ```
479
+ [x] Session runner — src/runner.ts
480
+ [x] politik run — CLI command
481
+ [x] First live session — two Motions tabled by real agents
482
+ ```
483
+
484
+ The loop: **broadcast → elect → compose → spawn → capture → record → settle.**
485
+ Deliberately thin. Every decision it makes was already made somewhere pure and
486
+ testable; the runner sequences and does I/O. A governance question answered here
487
+ would be in the wrong place.
488
+
489
+ **First live session (`live-001`, Parliamentary, quorum 2).** A real git
490
+ session repo. Claude Code seated twice as OPERATOR — `minister-alpha` and
491
+ `minister-bravo` — each tabling a Motion:
492
+
493
+ - `motions/motion-001.md` — every Motion must state its Rollback Plan
494
+ - `motions/motion-002.md` — Points of Order must cite the Standing Order invoked
495
+
496
+ Both drafted in Parliamentary vocabulary, both committed by the agent itself,
497
+ both recorded as attributed `MOTION_TABLED` entries in an append-only Hansard.
498
+ The framework governed a session.
499
+
500
+ **The live run found a bug nothing else could have.** Turn 1 recorded
501
+ `Files touched: none` while the agent had in fact written *and committed* a
502
+ Motion. Change detection used `git status --porcelain`, which is clean precisely
503
+ *because* the agent committed — and the Standing Orders this framework ships
504
+ tell agents "commit your result; uncommitted work does not exist". The runner's
505
+ detection contradicted the framework's own instructions. Now diffs committed
506
+ work (`HEAD` before/after) as well as the working tree.
507
+
508
+ No unit test would have caught it: the assertion would have encoded the same
509
+ wrong assumption. It took running the thing.
510
+
511
+ **Refusals enforced:** unknown agent, not a session repo, session not CONVENED
512
+ (naming the suspension cause), and a constituency the Charter does not seat. The
513
+ runner reads `STATE.json` before acting like every other actor — a runner exempt
514
+ from the session's own governance would be the one participant above it.
515
+
516
+ ---
517
+
518
+ ---
519
+
520
+ ## AUDIT CLOSED — 2026-07-25
521
+
522
+ A full source-vs-documentation audit was run and recorded in
523
+ [`docs/AUDIT.md`](docs/AUDIT.md). **Every code finding is now closed.**
524
+
525
+ The two that mattered — both real, both fixed:
526
+
527
+ 1. **The SCM provider was dead code at runtime.** Eleven methods, 21 tests, a
528
+ live verification — and nothing in `src/` ever called it, so `ASSENT`
529
+ recorded a decision that changed nothing. Now wired: a Motion carried by
530
+ Division and enacted by Assent **merged a real pull request** (`#1` on
531
+ `politik-live-002`, merge commit `c6b48c91`).
532
+ 2. **The transport was equally unwired.** `runTurn` synthesized its envelope, so
533
+ no broadcast had ever been *received*. Now wired: `politik broadcast`
534
+ publishes, `politik run --claim` polls and takes business it is eligible for.
535
+
536
+ Also fixed: the `RecordMode` split (`charter.ts` declared a vocabulary 8 of 10
537
+ shipped protocols could not express), the **unenforceable** AUTHORITY-is-human
538
+ rule (the schema had nowhere to declare a machine, so the framework's one hard
539
+ constitutional rule was a comment asserting a check that did not exist), a
540
+ meaningless `quorum.present`, and three unreachable suspension causes —
541
+ `DEADLOCK`, `SPEAKER_ORDER` and `DISPUTED_EXIT` are now all constructible.
542
+
543
+ One audit finding was **rejected**: rule 3 counting declared slots rather than
544
+ seated actors is correct, because Writ Drop runs before any actor is seated.
545
+
546
+ **Provider is optional, not mandatory.** The spec pulls both ways — "Run local,
547
+ run free" against "the motion system (Pull Requests)". Resolved as: git is the
548
+ mandatory substrate, the platform is an optional projection over it.
549
+
550
+ Phase 8 remains unstarted.
551
+
552
+ ---
553
+
554
+ ### PHASE 8 — Public Launch
555
+ ```
556
+ [ ] All namespaces secured
557
+ [ ] README hero section with tagline
558
+ [ ] Architecture documentation complete
559
+ [ ] At least 2 protocols shipped
560
+ [ ] At least 5 agents tested
561
+ [ ] GitHub template repo configured
562
+ [ ] Docker images published
563
+ [ ] npm package published
564
+ [ ] Homebrew tap (macOS/Linux)
565
+ [ ] Announcement — TBD channel
566
+ ```
567
+
568
+ ### PHASE 8.5 — Obsidian Visualisation Layer (post-v1, pre-academic)
569
+
570
+ **Target:** After v1.0.0 stable, before the enterprise research phase.
571
+
572
+ **What it is:** An optional visual layer on top of the Politik tree. Each node in the 1:N hierarchy is represented as a markdown file in an Obsidian vault. Obsidian's native graph view renders the tree visually — nodes, parent-child relationships, sibling clusters, STATE.json status as frontmatter tags.
573
+
574
+ **Why it matters:** A Speaker managing a complex Politik tree with dozens of sessions across multiple micro layers needs a map. Obsidian is that map. GitHub is the territory. With the MCP bridge, Claude Code has both open simultaneously.
575
+
576
+ **The toolchain:**
577
+ ```
578
+ Obsidian vault ← visual representation of the Politik tree
579
+ one markdown file per node
580
+ frontmatter: level, state, parent, cost_to_date
581
+
582
+ obsidian-mcp plugin ← MCP server exposing vault to Claude Code
583
+ semantic search across the tree
584
+ read/write vault files via MCP protocol
585
+
586
+ GitHub MCP ← the actual Hansard, LEDGER, STATE.json data
587
+ live session data from the repos
588
+
589
+ Claude Code (Speaker) ← both MCPs connected simultaneously
590
+ "show all FAULT_ACTOR sessions under saas-backend
591
+ in the last 30 days" → reads Obsidian graph +
592
+ GitHub Hansard data to answer
593
+ ```
594
+
595
+ **The sync script:** A Politik CLI command (`politik sync-vault`) reads all repos in the tree and regenerates the Obsidian vault markdown. Not real-time — on-demand or scheduled. Adds frontmatter tags for STATE.json status so Obsidian's graph view can colour-code by state: green (`CONVENED`), amber (`SUSPENDED`), grey (`PROROGUED`), red (`SUSPENDED` with `suspension.cause: CONSTITUTIONAL_CRISIS`). Constitutional crisis is a cause of suspension, not a state of its own — see ADR-0003.
596
+
597
+ **Existing MCP options (all open source, as of 2025):**
598
+ - `obsidian-mcp-tools` — Claude Desktop integration, semantic search, template execution
599
+ - `obsidian-claude-code-mcp` — Claude Code + Claude Desktop simultaneous connection via WebSocket and HTTP/SSE
600
+ - `mcp-obsidian` — simple REST API bridge, works with any MCP client
601
+
602
+ **Not a v1 requirement.** The tree works without visualisation. Sessions run. Hansards commit. LEDGER tracks cost. The Obsidian layer is a Speaker tooling convenience — valuable once the tree has enough nodes to benefit from a visual map.
603
+
604
+ **Versioning target:** v1.x.x — ships as an optional community integration after v1.0.0 stable.
605
+
606
+ ### PHASE 9 — Academic Collaboration
607
+
608
+ **Finding collaborators:**
609
+ ```
610
+ [ ] Identify SE researcher candidates
611
+ → Google Scholar: "empirical software engineering" "AI agents"
612
+ → arXiv cs.SE recent papers on agent collaboration
613
+ → Target: university CS departments with empirical SE focus
614
+
615
+ [ ] Identify game theory researcher candidates
616
+ → Google Scholar: "mechanism design" "multi-agent"
617
+ → arXiv cs.GT recent papers
618
+ → EC conference author lists
619
+ ```
620
+
621
+ **Collaboration structure:**
622
+ ```
623
+ [ ] Align on authorship order before writing begins
624
+ [ ] Agree on IP ownership — framework stays Cordfuse
625
+ [ ] Agree on paper scope — one unified paper, framework + experiment inseparable
626
+ [ ] Agree on venue targets: arXiv cs.MA + cs.SE, then ICSE or EC
627
+ [ ] Establish working cadence
628
+ ```
629
+
630
+ ### PHASE 10 — Research & Publication
631
+
632
+ **One Unified Paper — Framework + Experiment + Game Theory:**
633
+ ```
634
+ [ ] Draft abstract and introduction
635
+ [ ] CANON primitive layer formal description
636
+ [ ] Protocol taxonomy formal description
637
+ [ ] Git substrate design rationale
638
+ [ ] Game theory formal models per protocol (game theorist leads)
639
+ [ ] Nash Equilibrium predictions documented before experiments run
640
+ [ ] Identical engineering problems selected as test cases
641
+ [ ] Politik sessions run under each protocol
642
+ [ ] Results measured:
643
+ - Code quality (defect rate, test coverage, complexity)
644
+ - Speed (time to completion)
645
+ - Collaboration patterns (escalation rate, Division rate, deadlock rate)
646
+ - LEDGER cost-per-outcome across protocols
647
+ - Nash Eq convergence — did agents behave as predicted?
648
+ [ ] Statistical analysis (SE researcher leads)
649
+ [ ] Discussion: which protocols suit which problem types
650
+ [ ] Agile comparison — is it optimal or just default?
651
+ [ ] Submit to arXiv cs.MA + cs.SE simultaneously (SE researcher provides endorsement)
652
+ [ ] arXiv DOI recorded — update Zenodo entry to cross-reference
653
+ [ ] Target venue submission: ICSE or EC (Economics and Computation)
654
+ ```
655
+
656
+ ---
657
+
658
+ ---
659
+
660
+ ---
661
+
662
+ ## THE POLITIK TREE — HIERARCHICAL INHERITANCE AND CASCADE THEORY
663
+
664
+ ### The 1:N Node Architecture
665
+
666
+ Every node in Politik is a Proceeding. A leaf node — one with no children — is a session. A node with children is a parent. The tree has no fixed depth — as shallow as Universe → Session or as deep as Organisation → Division → Department → Team → Sub-team → Sprint → Ticket → Sub-ticket → Task. There is no architectural limit.
667
+
668
+ ```
669
+ Any node can be:
670
+ - A leaf (session — no children, does the work)
671
+ - A parent (contains child nodes, governs them)
672
+ - Both simultaneously (works AND governs children)
673
+
674
+ Actors can be declared at ANY node level.
675
+ Actors can be promoted or demoted across ANY node boundary.
676
+ Settings inherit downward. Restrictions compound. Nothing overrides upward.
677
+ ```
678
+
679
+ A real example from a software organisation:
680
+
681
+ ```
682
+ org/politik-root ← constitutional layer
683
+ └── org/politik-cordfuse ← company global
684
+ └── org/politik-bc-development ← domain team
685
+ └── org/politik-sprint-2026-04 ← monthly sprint
686
+ └── org/politik-PROJ-112 ← jira ticket (leaf — does the work)
687
+ └── org/politik-PROJ-112a ← sub-ticket (if scope expands)
688
+ ```
689
+
690
+ Every node has a Charter (inheriting from parent), a Hansard (scoped to its level), a STATE.json, and a LEDGER. The moment a leaf gains a child it becomes a parent — no special migration, no architectural change, just a new repo with `inherits_from` pointing at it.
691
+
692
+ ### Actors Are Mobile Across the Tree
693
+
694
+ An actor declared at the team MICRO level is available to any session under that MICRO. An actor can be:
695
+
696
+ - **Promoted upward** — a high-performing session-level MEMBER promoted to OPERATOR at the Sprint level, available across all sprint tickets
697
+ - **Demoted downward** — an actor scoped to a specific sub-ticket because their hard skills are only relevant there
698
+ - **Transferred laterally** — an actor moved from one branch of the tree to another by AUTHORITY at the appropriate parent node
699
+
700
+ All mobility is Hansard-attributed at the node level where the decision was made.
701
+
702
+ ### Every Node Has a Scoped Hansard
703
+
704
+ ```
705
+ ROOT Hansard ← constitutional events: CASCADE_ALERT, QUARANTINE,
706
+ RESTRUCTURE, PROMOTE_SCOPE, DEMOTE_SCOPE
707
+
708
+ GLOBAL Hansard ← org-wide: actor profile changes, constraint modifications,
709
+ sprint gates, session open/close registry
710
+
711
+ MICRO Hansard ← team-level: sub-team decisions, actor assignments,
712
+ local fault patterns, performance summaries
713
+
714
+ LEAF Hansard ← full session record: every motion, division, escalation,
715
+ fault, cost entry (the Hansard already fully designed)
716
+ ```
717
+
718
+ The chain of Hansards from leaf to root is the complete forensic record of how any decision was made, propagated, or failed at every level of the organisation.
719
+
720
+ ### Cascade Failure and Recovery — Within the Human/Organisational Domain
721
+
722
+ The tree structure makes cascade failure visible and containable in a way no previous governance framework has achieved. When a leaf node hits CONSTITUTIONAL_CRISIS, the failure propagates upward through the Hansard chain. Each parent node records its piece of the cascade. The root either quarantines the branch or restructures it.
723
+
724
+ **Organisational examples where this pattern is directly applicable:**
725
+
726
+ **2008 financial crisis** — Bear Stearns was a leaf node that hit FAULT_CRITICAL. The cascade propagated to Lehman Brothers (sibling leaf), then to the US financial system (parent GLOBAL), then to global capital markets (ROOT). No CASCADE_ALERT mechanism existed. No QUARANTINE was issued in time. RESTRUCTURE (TARP) cost $700 billion. A Politik tree with CASCADE_ALERT would have flagged the pattern when Bear Stearns first showed fault signals.
727
+
728
+ **Enron 2001** — GLOBAL CONSTITUTIONAL_CRISIS through deliberate AUTHORITY fraud. QUARANTINE (SEC freeze). RESTRUCTURE (bankruptcy). The physical audit records — the closest human analog to a Hansard — were destroyed by Arthur Andersen. Criminal charges followed. The Hansard, being append-only and cryptographically linked, cannot be destroyed.
729
+
730
+ **The 2003 Northeast blackout** — a SESSION-level alarm failure in an Ohio utility cascaded to 55 million people in 8 seconds because the tree had no CASCADE_ALERT and no QUARANTINE mechanism. Circuit breakers (the human equivalent of QUARANTINE) triggered too slowly.
731
+
732
+ **Agile methodology adoption** — a MICRO-level protocol developed by small software teams was PROMOTE_SCOPE'd to a universal knowledge-work practice without Hansard evidence to justify it at that scale. The performance data that would have bounded the appropriate scope did not exist. Politik produces exactly that data.
733
+
734
+ **Healthy organisational cascade (upward propagation):** Double-blind peer review was invented in one small corner of physics in the 1930s. It produced demonstrably better outcomes (the Hansard showed it). It was PROMOTE_SCOPE'd to the scientific GLOBAL and eventually to all academic domains. This is how proven protocols should propagate — up the tree, backed by evidence.
735
+
736
+ ### CASCADE_ALERT and Pattern Detection
737
+
738
+ When a failure pattern appears in multiple sibling nodes — same archetype configuration, same protocol, same fault signature — the parent node issues CASCADE_ALERT. This is the equivalent of an epidemiological R₀ calculation: if one failure is producing more than one downstream failure across siblings, the pattern is self-sustaining and requires intervention before it reaches the parent level.
739
+
740
+ ```yaml
741
+ cascade_alert:
742
+ trigger: same_fault_signature_in_siblings >= 2
743
+ window_days: 30
744
+ action: warn_at_writ_drop
745
+ notify: AUTHORITY
746
+ ```
747
+
748
+ Future sessions chartering the flagged configuration receive a Writ Drop warning. The Speaker can proceed — but the risk is documented and attributed. Over time, the ROOT Hansard becomes a pattern library of governance failures and their signatures, available to every node in the tree.
749
+
750
+ ### Broader Implications — An Invitation to Other Researchers
751
+
752
+ The hierarchical cascade inheritance model formalised in this work — configurable constraint propagation, attributed Hansard recording at every node level, and pattern detection across sibling nodes — shares structural properties with a broad class of complex adaptive systems studied across disciplines. The authors note these structural parallels without claiming them as contributions of this work, and invite researchers in adjacent fields to evaluate whether the formal model has utility beyond the software engineering and organisational governance domain for which it was designed:
753
+
754
+ **Epidemiology** — cascade propagation from index case through community clusters to regional outbreaks maps directly to the SESSION → MICRO → GLOBAL → ROOT cascade model. The CASCADE_ALERT threshold is mathematically analogous to R₀. QUARANTINE is the public health intervention. The Hansard is the contact tracing record.
755
+
756
+ **Organisational science and management theory** — the actor capability profile system (personality archetype, soft skills, hard skills, model grade, performance history) with Hansard feedback loops represents a formal model of team composition and organisational learning that could be empirically evaluated against existing theories of team performance and institutional memory.
757
+
758
+ **Network science and complex systems** — the failure propagation model through inheritance hierarchies with configurable quarantine thresholds may be of interest to researchers studying cascades in interconnected networks, including power grids, financial systems, and supply chains.
759
+
760
+ **Political science and institutional theory** — the Constitutional Capture failure mode, the virtue/vice actor model, and the PROMOTE/DEMOTE/HIRE/FIRE doctrine with full Hansard attribution represent a formal computational model of institutional corruption and recovery that may be of interest to researchers in democratic theory and comparative politics.
761
+
762
+ The authors make no claims about these domains. The formal model is presented for the software engineering and multi-agent AI research community. The structural parallels are noted as invitations, not contributions.
763
+
764
+
765
+ ---
766
+