@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/RUNTIME.md ADDED
@@ -0,0 +1,1355 @@
1
+ # POLITIK — RUNTIME MECHANICS
2
+
3
+ **Attribution:** Steve Krisjanovs, Cordfuse
4
+
5
+ Session operations, escalation flows, actor lifecycle, cost model, platform support, governance tiers, and session fault handling.
6
+
7
+ See [POLITIK-ARCHITECTURE.md](POLITIK-ARCHITECTURE.md) for CANON and the engine layer.
8
+
9
+ ---
10
+
11
+ ## POINT OF ORDER — ESCALATION FLOW
12
+
13
+ ```
14
+ Agent hits decision requiring human judgement
15
+ ↓
16
+ Commits escalation to /escalations/[timestamp].md
17
+ ↓
18
+ GitHub Actions workflow triggers on path match
19
+ ↓
20
+ Speaker receives email notification
21
+ ↓
22
+ Session suspends (STATE.json → state: SUSPENDED,
23
+ suspension.cause: POINT_OF_ORDER)
24
+ ↓
25
+ Speaker reviews, commits ruling.md
26
+ ↓
27
+ GitHub Actions detects ruling commit
28
+ ↓
29
+ Session resumes (STATE.json → state: CONVENED, suspension: null)
30
+ ↓
31
+ Ruling recorded permanently in Hansard
32
+ ```
33
+
34
+ > **Vocabulary note.** Earlier drafts of this flow wrote the pause as
35
+ > `paused: true` / `paused: false`. ADR-0003 retired that field: `STATE.json`
36
+ > carries one CANON-valued `state`, and the reason is carried separately in
37
+ > `suspension.cause`. A pause and a stale heartbeat are different states, not
38
+ > two values of one boolean.
39
+
40
+ ### Point of Order Workflow
41
+ ```yaml
42
+ # .github/workflows/point-of-order.yml
43
+ name: Point of Order — Speaker Notification
44
+ on:
45
+ push:
46
+ paths:
47
+ - 'escalations/[0-9]*.md'
48
+ jobs:
49
+ notify-speaker:
50
+ runs-on: ubuntu-latest
51
+ steps:
52
+ - uses: actions/checkout@v4
53
+
54
+ - name: Read escalation
55
+ id: esc
56
+ run: |
57
+ FILE=$(ls escalations/*.md | grep -v ruling | tail -1)
58
+ echo "content<<EOF" >> $GITHUB_OUTPUT
59
+ cat "$FILE" >> $GITHUB_OUTPUT
60
+ echo "EOF" >> $GITHUB_OUTPUT
61
+
62
+ - name: Email Speaker
63
+ uses: dawidd6/action-send-mail@v3
64
+ with:
65
+ server_address: smtp.gmail.com
66
+ server_port: 465
67
+ username: ${{ secrets.MAIL_USERNAME }}
68
+ password: ${{ secrets.MAIL_PASSWORD }}
69
+ to: ${{ secrets.SPEAKER_EMAIL }}
70
+ subject: "⚖️ Point of Order — ${{ github.repository }}"
71
+ body: |
72
+ A Point of Order has been raised.
73
+
74
+ ${{ steps.esc.outputs.content }}
75
+
76
+ Session: ${{ github.server_url }}/${{ github.repository }}
77
+
78
+ Commit your ruling to: escalations/ruling-[n].md
79
+ Session is paused pending your response.
80
+ ```
81
+
82
+ ---
83
+
84
+ ## ACTOR ELIMINATION — LEGITIMATE VS BAD FAITH
85
+
86
+ ### The Core Problem
87
+
88
+ An actor exiting a session may have left for one of two fundamentally different reasons:
89
+
90
+ **Legitimate elimination** — the actor lost fairly under the protocol rules. Outscored in a Tournament. Outvoted in a Division. Failed to meet a performance threshold. The protocol worked as designed.
91
+
92
+ **Bad faith elimination** — the actor was removed through collusion, malice, envy, or procedural abuse. Another actor filed a false Point of Order. A coalition formed specifically to expel a competitor rather than to advance the session's goals. An OPERATOR abused PROMOTE/DEMOTE powers to suppress a MEMBER whose output threatened their standing.
93
+
94
+ This distinction matters. An immutable Hansard records that an actor was expelled. It does not automatically record *why* — or whether the why was legitimate.
95
+
96
+ Machine actors do not feel hatred or jealousy. But they can be **instructed** to eliminate rivals by human actors operating through the system, or by other machine actors whose prompts encode bad faith objectives. The Hansard is the defence — but only if the escalation mechanism is used correctly.
97
+
98
+ ### Exit Types
99
+
100
+ The following EXIT classifications must be declared in the Hansard at the point of actor removal:
101
+
102
+ | Exit Type | Code | Description |
103
+ |---|---|---|
104
+ | Performance | `EXIT_PERFORMANCE` | Actor failed to meet objective criteria defined in Charter |
105
+ | Protocol | `EXIT_PROTOCOL` | Actor violated Standing Orders — documented violation required |
106
+ | Division | `EXIT_DIVISION` | Actor removed by legitimate vote with quorum |
107
+ | Voluntary — Concession | `EXIT_VOLUNTARY_CONCESSION` | Actor evaluated the evidence, accepted they lost on merit, withdrew with integrity |
108
+ | Voluntary — Strategic | `EXIT_VOLUNTARY_STRATEGIC` | Actor withdrew before a Division to deny quorum, deprive rival of formal win, or avoid a recorded defeat |
109
+ | Voluntary — Coerced | `EXIT_VOLUNTARY_COERCED` | Actor was pressured, threatened, or manipulated into withdrawing. On paper voluntary. In practice expulsion by other means. Also known as "voluntold." |
110
+ | Darwinist | `EXIT_DARWINIST` | Protocol-mandated elimination (Battle Royale, Elimination Tournament) |
111
+ | Speaker | `EXIT_SPEAKER` | AUTHORITY ruled removal — Speaker ruling committed to Hansard |
112
+ | Disputed | `EXIT_DISPUTED` | Actor filed a Point of Order challenging their own removal |
113
+
114
+ ### The Voluntold Problem
115
+
116
+ `EXIT_VOLUNTARY_COERCED` is the most dangerous exit type in the taxonomy — not because it is violent but because it is invisible.
117
+
118
+ The coercion happens outside the session. An OPERATOR privately threatens a MEMBER. A coalition signals consequences. A human Speaker leans on an agent's prompt. The MEMBER files what looks like a clean voluntary exit. The Hansard shows nothing wrong.
119
+
120
+ This is "voluntold" — the actor technically chose to leave, but the choice was manufactured by someone else's pressure or manipulation.
121
+
122
+ It is common in real governance for exactly this reason: it produces all the outcomes of bad faith expulsion while generating none of the Hansard evidence that a disputed exit would create. The coercer gets the result. The record stays clean.
123
+
124
+ **The vices at work:**
125
+ - **Manipulation** by the coercing actor — engineering a desired outcome through pressure not procedure
126
+ - **Cowardice** by the coerced actor — withdrawing rather than filing a disputed exit and forcing the record
127
+ - **Wrath** as the underlying motivation — the coercer wanted the actor gone personally, not procedurally
128
+
129
+ **Partial mitigations — Charter-level:**
130
+
131
+ ```yaml
132
+ # Charter configuration options for voluntold mitigation
133
+
134
+ voluntary_exit_during_division:
135
+ require_concession_statement: true # Actor must commit reason to Hansard
136
+ cooling_off_minutes: 15 # Delay before exit is processed
137
+ auto_notify_speaker: true # Speaker notified even without escalation
138
+ allow_disputed_conversion: true # Actor can convert to EXIT_DISPUTED
139
+ # within the cooling-off window
140
+ ```
141
+
142
+ None of these catch a determined coercer operating entirely outside the session. But they create friction that makes the pattern visible over time. If the same OPERATOR repeatedly has MEMBERs "voluntarily" withdraw during active Divisions, the Hansard pattern speaks for itself. The audit trail is the deterrent.
143
+
144
+ **What the Hansard can detect:**
145
+
146
+ | Pattern | Signal |
147
+ |---|---|
148
+ | Serial voluntary exits | Multiple MEMBERs withdrawing during Divisions where the same OPERATOR is present |
149
+ | Timing correlation | EXIT_VOLUNTARY_STRATEGIC filed within seconds of a Division opening — no deliberation time |
150
+ | No concession statement | Voluntary exit during active Division with no stated reason — Charter violation if required |
151
+ | Repeat target | Same MEMBER voluntarily exits whenever same OPERATOR is present across multiple sessions |
152
+
153
+ **The hard truth:** A Speaker who is the coercer cannot be appealed to. This is the one scenario where the constitutional model fails — when the constitutional authority itself is corrupt. Politik has no answer to a bad faith Speaker beyond the Hansard record being visible to everyone who can read the repo. Transparency is the only remaining defence.
154
+
155
+ ### Disputed Exit Flow
156
+
157
+ Any actor facing removal may file a **Disputed Exit** before their session access is revoked. This is the machine equivalent of due process.
158
+
159
+ ```
160
+ Actor receives EXPEL motion
161
+ ↓
162
+ Actor commits escalation to /escalations/disputed-exit-[timestamp].md
163
+ (must happen before session access revoked — Charter defines window)
164
+ ↓
165
+ Session pauses automatically
166
+ ↓
167
+ Speaker receives notification
168
+ ↓
169
+ Speaker reviews Hansard — was the elimination procedurally valid?
170
+ ↓
171
+ Two possible rulings:
172
+ ruling: UPHELD → EXIT_PROTOCOL or EXIT_DIVISION confirmed
173
+ ruling: REVERSED → Actor reinstated, expelling actor flagged
174
+
175
+ Ruling committed to Hansard permanently — immutable record either way
176
+ ```
177
+
178
+ ### The Hansard as Integrity Layer
179
+
180
+ The immutable Hansard is the primary defence against bad faith elimination. Because every action is recorded with attribution, a disputed exit can be audited completely:
181
+
182
+ - Who filed the motion to expel?
183
+ - What was cited as the reason?
184
+ - Was that reason supported by prior Hansard entries?
185
+ - Did the expelling actor have a pattern of targeting this specific actor?
186
+ - Was quorum met for the Division?
187
+
188
+ A Speaker reviewing a disputed exit reads the Hansard like a judge reads a transcript. The record either supports the elimination or it doesn't.
189
+
190
+ ### Bad Faith Patterns — What the Hansard Can Detect
191
+
192
+ | Pattern | Hansard signal |
193
+ |---|---|
194
+ | Targeted harassment | Single actor repeatedly filing Points of Order against the same target |
195
+ | Coalition expulsion | Multiple actors coordinating EXPEL motions against a competitor with no performance basis |
196
+ | Procedural abuse | EXPEL filed with no cited Standing Orders violation |
197
+ | Timing manipulation | EXPEL filed immediately before a key Division where the target's vote would matter |
198
+ | False escalation | Point of Order citing a violation that does not appear in the Hansard record |
199
+
200
+ ### Protocol Mode and Bad Faith Risk
201
+
202
+ Not all protocols have the same exposure to bad faith elimination:
203
+
204
+ | Mode | Bad faith risk | Mitigation |
205
+ |---|---|---|
206
+ | Constitutional | Medium — Speaker can be lobbied | Speaker ruling is final and recorded |
207
+ | Authoritarian | High — AUTHORITY has unchecked expulsion power | Hansard records all AUTHORITY actions |
208
+ | Darwinist | Low — elimination is algorithmic not political | No appeal by design — Charter must be clear |
209
+ | Ephemeral | Low — session too short for politics to develop | No Hansard — no audit trail either |
210
+ | Immutable | Low — Charter cannot be changed mid-session | Expulsion criteria locked at Charter time |
211
+
212
+ ### The Human Flaw Connection
213
+
214
+ Bad faith elimination is the SESSION-level manifestation of the vices documented in the Human Flaw Thesis:
215
+
216
+ - **Envy** — expelling a competitor whose output is better than yours
217
+ - **Wrath** — expelling an actor who disagreed with you earlier in the session
218
+ - **Tribalism** — coordinating with in-group actors to remove an outsider
219
+ - **Pride** — refusing to accept that an actor's MOTION was superior to yours
220
+
221
+ Machine actors do not initiate bad faith elimination spontaneously. But they can be prompted into it by human Speakers who embed malicious objectives into Charter or session prompts. The Hansard exposes this — but only if someone reads it.
222
+
223
+ The Speaker role exists precisely to prevent this. A neutral constitutional authority who enforces procedure not outcome. The original parliamentary Speaker was created for exactly this reason: to prevent the majority from simply ejecting members who inconvenienced them.
224
+
225
+ Politik inherits both the problem and the solution.
226
+
227
+ ---
228
+
229
+ ### Politik Compatible (headless prompt arg required)
230
+
231
+ | Agent | Command | Auth (local) | Auth (headless) | Notes |
232
+ |---|---|---|---|---|
233
+ | Claude Code | `claude -p "..."` | OAuth ✅ | OAuth ✅ | Primary target |
234
+ | Gemini CLI | `gemini --skip-trust -p "..."` | OAuth ✅ | OAuth ✅ | 1M context. Refuses an untrusted directory without `--skip-trust` |
235
+ | OpenCode | `opencode run "..."` | OAuth ✅ | OAuth ✅ | 75+ providers, Ollama |
236
+ | Qwen Code | `qwen -p "..."` | OAuth ✅ | OAuth ✅ | stream-json, Apache 2.0 |
237
+ | Codex CLI | `codex exec "..."` | OAuth ✅ | OAuth ✅ | OpenAI, Rust-based. Bare `codex` is an interactive TUI |
238
+ | Antigravity | `agy -p "..."` | OAuth ✅ | OAuth ✅ | Google, `-p`/`--print` |
239
+ | GitHub Copilot | `copilot -p "..." --allow-all-tools` | OAuth ✅ | OAuth ✅ | Agentic CLI (v1+). Needs an active Copilot subscription + the CLI policy enabled |
240
+ | Aider | `aider --message "..."` | API key | API key | Strong git integration |
241
+ | Goose | `goose run "..."` | API key | API key | MCP-native, Block |
242
+ | Cline CLI | `cline "..."` | API key | API key | CLI 2.0 headless |
243
+ | Plandex | `plandex tell "..."` | API key | API key | 2M token context |
244
+ | Kilo Code CLI | `kilo "..."` | API key | API key | Orchestrator mode |
245
+ | Amazon Q | `q chat "..."` | AWS auth | AWS auth | AWS-focused |
246
+
247
+ **Auth, headless.** "Auth (headless)" is the credential a session uses when
248
+ running unattended — CI, a VPS, a container. The one thing that cannot happen
249
+ headless is the interactive *login*; once a credential persists on the host,
250
+ invocation is non-interactive. A stored **OAuth token qualifies** — proven live:
251
+ `claude -p`, `codex exec`, `opencode run`, `agy -p` all run unattended on their
252
+ subscription logins, refreshing the token silently — as do an API key and AWS
253
+ auth. The bar for a Politik agent is *a non-interactive credential path*, not a
254
+ specific credential type. (A truly ephemeral runner with no prior login must have
255
+ the credential injected as a secret — an OAuth token, an API key, or AWS auth.)
256
+
257
+ ### Explicitly Excluded (IDE-primary, no headless prompt)
258
+ - Cursor — IDE only
259
+ - Windsurf — IDE only
260
+ - Roo Code — VS Code extension primary
261
+ - Continue — IDE extension
262
+
263
+ ### Structured stdio/JSON Compatible (subset)
264
+ A subset of agents support structured JSON-over-stdio — useful when an operator console drives them programmatically rather than by plain prompt. Only these support it:
265
+
266
+ | Agent | stdio support |
267
+ |---|---|
268
+ | Claude Code | ✅ |
269
+ | Gemini CLI | ✅ |
270
+ | Codex CLI | ✅ |
271
+ | OpenCode | ✅ |
272
+ | Qwen Code | ✅ stream-json |
273
+
274
+ **This is not a Politik limitation.** Remaining agents participate via direct prompt invocation. Structured-stdio orchestration is one optional layer.
275
+
276
+ ---
277
+
278
+ ## THE OPERATOR CONSOLE (CLERK OF THE HOUSE)
279
+
280
+ The **operator console** is the Speaker's window into a session — how a human drops the Writ, receives escalations, and reads the Hansard. It is **not a specific product**. Any interactive session serves as the console: an agent CLI itself (Claude Code, Gemini CLI, etc.), a plain terminal, or a thin Politik CLI. The console is the Clerk of the House — it convenes and closes sessions and relays to the Speaker; it is not a Chamber participant.
281
+
282
+ | Component | Role |
283
+ |---|---|
284
+ | Operator console | Speaker's window. Drops/closes the Writ. Any interactive session, incl. an agent CLI. Not the Chamber. |
285
+ | Chamber floor | The transport (git-based default, NATS an opt-in upgrade). The console has no listener here. |
286
+ | Constituency | CLI agent process — spawns, works, disposes |
287
+
288
+ ### What the console does
289
+ - Drop the Writ (create and configure the session repo)
290
+ - Receive Point of Order notifications (email / SCM)
291
+ - Review the Hansard when the session prorogues
292
+ - Intervene when a Point of Order escalates to the Speaker
293
+
294
+ ### What the console does not do
295
+ - See real-time agent chatter — the Chamber floor is carried by the transport, not the console
296
+ - Tail live agent output — spawn-and-dispose means no persistent stdout
297
+ - Monitor mid-session state without reading the repo
298
+
299
+ ### Console vs Chamber — two execution models
300
+ | | Operator console | Politik constituency |
301
+ |---|---|---|
302
+ | Session model | Interactive / persistent | Ephemeral |
303
+ | State location | The console session | Git repo |
304
+ | Lifecycle | Long-lived (the human is present) | Spawn and dispose |
305
+
306
+ The console is where the human is constitutionally present. The constituencies are where work happens and disposes. They coexist by design — the console never needs to tail the Chamber, because the Hansard is the session.
307
+
308
+ ---
309
+
310
+ ## COST MODEL
311
+
312
+ ```
313
+ Run local, run free.
314
+ Run OAuth, run far.
315
+ Run API keys, run carefully.
316
+ ```
317
+
318
+ | Constituency | Auth | Cost | Notes |
319
+ |---|---|---|---|
320
+ | Local + OAuth | OAuth | ~$0 | Rides existing subscription |
321
+ | Local + Ollama (any agent) | None | $0.00 | Local GPU, fully free |
322
+ | Local Docker + DISPLAY passthrough | OAuth | ~$0 | Rides subscription |
323
+ | OpenCode + Ollama local | None | $0.00 | Zero cost, zero auth |
324
+ | OpenCode + cloud provider + API key | API key | 💸 | Warn loudly |
325
+ | VPS headless any agent | API key | 💸 | Warn loudly |
326
+ | Codespaces any agent | API key | 💸 | Warn loudly |
327
+ | CI runner any agent | API key | 💸 | Warn loudly |
328
+
329
+ ### OAuth Reality
330
+ OAuth subscription covers most developer use cases. Claude Max, Gemini Advanced, ChatGPT Pro users will rarely hit limits in normal Politik sessions. The subscription is already paid. Politik rides it.
331
+
332
+ ### API Key Warning (mandatory Charter acknowledgement)
333
+ ```yaml
334
+ constituencies:
335
+ - name: gamma
336
+ runtime: gemini-cli
337
+ auth: api_key
338
+ cost_acknowledged: true # REQUIRED — session refuses to start without this
339
+ ```
340
+
341
+ The Charter enforces cost acknowledgement before any API key constituency spawns.
342
+
343
+ ### Charter Cost Controls
344
+ ```yaml
345
+ ai:
346
+ max_tokens_per_motion: 4096
347
+ max_motions_per_session: 50
348
+ cost_responsibility: per_constituency
349
+ ```
350
+
351
+ ---
352
+
353
+ ## PLATFORM SUPPORT
354
+
355
+ ### Supported Platforms (Tier 1 — Full OAuth)
356
+ | Platform | Runtime | Claude Auth | Notes |
357
+ |---|---|---|---|
358
+ | Linux (any distro) | Bare metal | OAuth | Ideal |
359
+ | Linux | Docker + DISPLAY | OAuth | X11 passthrough |
360
+ | macOS | Bare metal | OAuth | Primary dev platform |
361
+ | macOS | Docker Desktop | OAuth | macOS display native |
362
+ | Windows Pro | Bare metal | OAuth | Clean |
363
+
364
+ ### Supported with Constraints (Tier 2)
365
+ | Platform | Runtime | Claude Auth | Notes |
366
+ |---|---|---|---|
367
+ | Windows Pro | WSL2 + Docker | API key | No OAuth in container |
368
+ | Windows Home | Bare metal | OAuth | User accepts risk, no isolation |
369
+ | Windows Home | WSL2 + Docker | API key | One-time WSL2 setup required |
370
+ | ChromeOS + Linux (Crostini) | Docker | OAuth | Crostini = Debian VM |
371
+
372
+ ### Cloud / Headless (Tier 3 — API key only)
373
+ | Platform | Auth | Cost |
374
+ |---|---|---|
375
+ | GitHub Codespaces | API key | 💸 |
376
+ | VPS (Hetzner, DO, Linode) | API key | 💸 |
377
+ | CI runners | API key | 💸 |
378
+
379
+ ### Explicitly Unsupported
380
+ - Windows Home bare metal without user risk acknowledgement
381
+ - ChromeOS without Linux (Crostini) enabled
382
+ - Mobile (iOS, Android)
383
+ - Windows containers (Linux toolchain incompatible)
384
+
385
+ ### OAuth in Containers
386
+ Local containers can use OAuth via X11 DISPLAY passthrough:
387
+ ```yaml
388
+ # docker-compose.yml
389
+ environment:
390
+ - DISPLAY=${DISPLAY}
391
+ volumes:
392
+ - /tmp/.X11-unix:/tmp/.X11-unix
393
+ ```
394
+ Works on Linux and macOS. Windows requires WSLg (Windows 11 only, untested).
395
+
396
+ ### Hard OAuth Rules
397
+ ```
398
+ ✅ DISPLAY passthrough — Claude Code authenticates itself
399
+ ✅ API key in environment — always legitimate
400
+ ❌ Token harvesting — TOS violation, never implement
401
+ ❌ Auth broker intercepting OAuth callback — token harvesting
402
+ ❌ Sharing token files between processes — grey area, avoid
403
+ ```
404
+
405
+ ---
406
+
407
+ ## SESSION QUORUM, MINIMUM CAST AND SINGLE-PLAYER SESSIONS
408
+
409
+ ### Session Termination Conditions
410
+
411
+ A proceeding ends when **any one** of the following conditions is met first — first-one-wins OR logic. All conditions are monitored simultaneously. All are optional and independently configurable. Any combination is valid.
412
+
413
+ ```
414
+ TERMINATE if (motions >= max_motions) ← TRIGGER_TURNS
415
+ OR (now >= deadline) ← TRIGGER_DEADLINE
416
+ OR (total_cost >= max_cost_usd) ← TRIGGER_COST
417
+ OR (AUTHORITY issues DISSOLVE verb) ← TRIGGER_SPEAKER
418
+ ```
419
+
420
+ ```yaml
421
+ session:
422
+ max_motions: 20 # turns ceiling (optional)
423
+ deadline: 2026-04-30T17:00:00-04:00 # wall-clock ceiling (optional)
424
+ max_cost_usd: 5.00 # cost ceiling (optional)
425
+ cost_warning_usd: 4.00 # Speaker notified before ceiling (optional)
426
+ deadline_action: escalate # what happens when any ceiling triggers
427
+ ```
428
+
429
+ **Cost ceiling** is the most critical guardrail for API key deployments. Without it an overnight proceeding can burn significant credits before anyone notices. With `max_cost_usd` set, the proceeding auto-suspends the moment it hits the limit and routes to the Speaker.
430
+
431
+ **Cost warning** fires before the ceiling — giving the Speaker a heads-up to intervene, extend budget, or gracefully wind down. Same model as a low-fuel warning before the engine cuts out.
432
+
433
+ ### SESSION_TIMEOUT — Trigger Tracking
434
+
435
+ The `SESSION_TIMEOUT` Hansard record always names **which condition triggered** and the state of all other conditions at that moment:
436
+
437
+ ```markdown
438
+ # SESSION_TIMEOUT
439
+
440
+ **Trigger:** TRIGGER_COST
441
+ **Trigger value:** $5.03 (ceiling: $5.00)
442
+ **Deadline action:** DEADLINE_ESCALATE
443
+
444
+ **Other conditions at trigger:**
445
+ - max_motions: 12 of 20 used (60% — would not have triggered)
446
+ - deadline: Apr 30 17:00 — 18 days remaining (would not have triggered)
447
+
448
+ ## Completed at timeout
449
+ - Authentication module scaffolded ✅
450
+ - JWT integration complete ✅
451
+
452
+ ## In Flight at timeout
453
+ - OPERATOR-2 mid-task: writing test suite (50% complete)
454
+ - Motion MOTION-14 tabled but Division not yet called
455
+
456
+ ## Pending at timeout
457
+ - MOTION-15 not yet tabled
458
+ - Escalation ESC-003 awaiting Speaker ruling
459
+
460
+ ## Nothing is lost
461
+ All committed work is in the Hansard. To resume:
462
+ politik resume --session [session-id]
463
+ To prorogue:
464
+ politik prorogue --session [session-id]
465
+ ```
466
+
467
+ Three trigger codes:
468
+
469
+ | Trigger | Code | Condition |
470
+ |---|---|---|
471
+ | Turns exhausted | `TRIGGER_TURNS` | `motions >= max_motions` |
472
+ | Wall-clock deadline | `TRIGGER_DEADLINE` | `now >= deadline` |
473
+ | Cost ceiling | `TRIGGER_COST` | `total_cost >= max_cost_usd` |
474
+ | Speaker closed | `TRIGGER_SPEAKER` | `DISSOLVE` verb issued |
475
+
476
+ **Protocol-specific defaults:**
477
+
478
+ | Protocol mode | Default deadline_action |
479
+ |---|---|
480
+ | Constitutional | `DEADLINE_ESCALATE` — Speaker decides |
481
+ | Darwinist | `DEADLINE_DISSOLVE` — incomplete = no winner, session void |
482
+ | Authoritarian | `DEADLINE_SUSPEND` — AUTHORITY resumes when ready |
483
+ | Ephemeral | `DEADLINE_DISSOLVE` — by definition time-boxed |
484
+ | Immutable | `DEADLINE_ESCALATE` — Charter cannot be changed, Speaker must rule |
485
+
486
+ ---
487
+
488
+ ### SESSION LEDGER — Secretarial Cost and Token Tracking
489
+
490
+ The Hansard is the session record. The LEDGER is the secretarial accounting record. They are separate files with separate purposes.
491
+
492
+ **`LEDGER.md`** — one file per session repo, auto-committed by the engine after every motion closes. The Clerk role owns it.
493
+
494
+ ```markdown
495
+ # SESSION LEDGER
496
+ ## cordfuse/politik-PROJ-112 — Agile Protocol
497
+
498
+ | # | Actor | Time | Elapsed | In tokens | Out tokens | Cache read | Est. cost | Motion summary |
499
+ |---|---|---|---|---|---|---|---|---|
500
+ | 01 | OPERATOR-1 | 3:02pm EDT Apr 9 | 45s | 1,842 | 347 | 1,200 | $0.008 | Scaffolded auth module |
501
+ | 02 | OPERATOR-2 | 3:48pm EDT Apr 9 | 2m 12s | 3,104 | 891 | 2,800 | $0.019 | Wrote JWT integration |
502
+ | 03 | MEMBER-1 | 4:15pm EDT Apr 9 | 38s | 922 | 203 | 800 | $0.004 | Filed Point of Order |
503
+ | — | SPEAKER | 4:22pm EDT Apr 9 | — | — | — | — | — | Ruled: scope confirmed |
504
+ | 04 | OPERATOR-1 | 4:30pm EDT Apr 9 | 1m 55s | 2,441 | 654 | 2,100 | $0.014 | Completed test suite |
505
+
506
+ **Session totals**
507
+ - Total motions: 4
508
+ - Total elapsed: 5h 28m (convened time)
509
+ - Total input tokens: 8,309
510
+ - Total output tokens: 2,095
511
+ - Total cache read: 6,900
512
+ - Total estimated cost: $0.045
513
+
514
+ **Termination**
515
+ - Trigger: TRIGGER_SPEAKER
516
+ - Prorogued: 5:12pm EDT Apr 9, 2026
517
+ ```
518
+
519
+ **Token data source:** The Anthropic API returns exact token counts in every response object — `input_tokens`, `output_tokens`, `cache_read_input_tokens`, `cache_creation_input_tokens`. The engine reads these and writes them to LEDGER.md automatically. For Claude.ai conversations (non-API) token counts are estimated.
520
+
521
+ **Charter configuration:**
522
+
523
+ ```yaml
524
+ session:
525
+ ledger: enabled
526
+ ledger_visibility: public # public (default) | private
527
+ ledger_path: LEDGER.md # or .politik/LEDGER.md for private
528
+ ```
529
+
530
+ **Private ledger** — for sessions where cost data should not be publicly visible (commercial client work). Charter sets `ledger_visibility: private` and the engine writes to `.politik/LEDGER.md` which is in `.gitignore`.
531
+
532
+ **Clerk role** — the engine process that auto-commits LEDGER.md entries. Not a human actor. Not an agent. The engine itself acting as session secretary. Speaker actions are logged at zero token cost (no API call fired).
533
+
534
+ ---
535
+
536
+ ### SESSION HEARTBEAT AND RESUMPTION
537
+
538
+ For long-running proceedings across multiple days — or proceedings interrupted by machine failure, network loss, or the operator going offline.
539
+
540
+ **Heartbeat detection:**
541
+
542
+ A GitHub Actions scheduled workflow runs hourly. It checks the timestamp of the last Hansard commit. If no commit has occurred within `heartbeat_timeout_hours` the proceeding is considered stale.
543
+
544
+ ```yaml
545
+ session:
546
+ heartbeat_timeout_hours: 4 # if no Hansard commit in 4hrs → stale
547
+ stale_action: suspend # auto-suspend, not dissolve
548
+ ```
549
+
550
+ On stale detection the engine commits `STATE.json → suspended: true` and a `SESSION_STALE` Hansard record. Agents check STATE.json before every action — they see suspended and stop immediately.
551
+
552
+ **State snapshots:**
553
+
554
+ Long proceedings commit a `STATE_SNAPSHOT` to Hansard at regular intervals — a complete picture of what is done, what is in flight, and what is pending.
555
+
556
+ ```yaml
557
+ session:
558
+ checkpoint_interval_hours: 8 # STATE_SNAPSHOT committed every 8hrs
559
+ ```
560
+
561
+ ```markdown
562
+ # STATE_SNAPSHOT — Day 2, 14:00
563
+
564
+ ## Completed
565
+ - Authentication module scaffolded ✅
566
+ - JWT integration complete ✅
567
+
568
+ ## In Flight
569
+ - OPERATOR-2 mid-task: writing test suite (50% complete)
570
+
571
+ ## Pending Divisions
572
+ - Motion: use jest vs vitest — Division not yet called
573
+
574
+ ## Blocked
575
+ - Waiting on AUTHORITY ruling: escalation filed 13:42
576
+
577
+ ## Cost at snapshot
578
+ - Total spent: $2.14 of $5.00 ceiling (43%)
579
+ - Motions used: 8 of 20 (40%)
580
+ ```
581
+
582
+ **Resuming a proceeding:**
583
+
584
+ ```bash
585
+ politik resume --session cordfuse/politik-PROJ-112
586
+ ```
587
+
588
+ The tool reads the last `STATE_SNAPSHOT` from Hansard, reconstructs the session context, and passes it to newly spawned agents as their initialisation prompt. They continue from the checkpoint. The key insight: **the Hansard is the session, not the agent process.** Losing agents does not lose the proceeding. New agents are given the Hansard context and continue.
589
+
590
+ ---
591
+
592
+ ### CROSS-SESSION MEMORY AND THE GLOBAL LAYER — ROADMAP TARGET: v0.9.x
593
+
594
+ Each Politik node starts cold — no knowledge of prior sessions by default. For multi-session sprints this creates a problem: an agent in session 12 may propose something already tried and rejected in session 4.
595
+
596
+ **Versioning:** Not an early development blocker. Target v0.9.x — pre-release feature complete, ships before v1.0.0 stable.
597
+
598
+ ```
599
+ v0.1.0 → architecture commit
600
+ v0.x.x → single leaf node working — the session we designed
601
+ v0.9.x → GLOBAL layer (politik-cortex) — actor profiles, cross-session memory,
602
+ org-wide constraints, sprint meta-context
603
+ v1.0.0 → MICRO layer — arbitrary depth nesting, full 1:N tree
604
+ v2.0.0 → ROOT layer (politik-root) — CASCADE_ALERT, QUARANTINE, RESTRUCTURE
605
+ v3.0.0 → FEDERATION — multiple roots, inter-org protocols
606
+ ```
607
+
608
+ **The v0.9.x solution — the GLOBAL layer:**
609
+
610
+ A standalone global repo per domain at the org level — `politik-cortex-[name]`. Not a manually curated lineage file. Not a GitHub org variable. A version-controlled, cryptographically linked, auto-maintained global node that every session under it inherits from.
611
+
612
+ ```
613
+ org/politik-cortex-[name] ← global layer (v0.9.x)
614
+ ├── actors/
615
+ │ ├── steve-k.md ← actor capability profile — auto-updated on prorogation
616
+ │ └── claude-opus.md ← machine actor profile
617
+ ├── sessions/
618
+ │ ├── PROJ-101.md ← key decisions, auto-committed on prorogation
619
+ │ └── PROJ-102.md
620
+ ├── constraints/
621
+ │ └── sprint-2026-04.md ← inherited constraints for this sprint
622
+ └── CHARTER.md ← org-wide defaults inherited by all child nodes
623
+ ```
624
+
625
+ Every time a session prorogues, the engine auto-commits a decisions summary and observed actor performance back to the global layer. Future sessions query it at Writ Drop. Actor profiles self-improve with every session. Cryptographically linked. No manual curation required.
626
+
627
+ Full design in THE POLITIK TREE section.
628
+
629
+ **What ships in early development builds instead:**
630
+ Agents initialised with Hansard context from their own session only. Cross-session memory declared as a known early-build limitation. Operators who need it can manually include prior decision summaries in the session prompt at Writ Drop as a workaround until v0.9.x ships.
631
+
632
+
633
+
634
+
635
+ ### Single-Player Sessions — QUORUM: 1
636
+
637
+ A single agent running under a governed protocol is not collaboration — it is **structured self-discipline**. The Charter constrains what the agent can do, forces it to commit all reasoning to Hansard, and requires escalation when it hits boundaries it cannot resolve alone. The governance layer works even with one actor because the constraint is on the process, not the headcount.
638
+
639
+ Valid single-agent use cases:
640
+
641
+ | Protocol | Single-agent value |
642
+ |---|---|
643
+ | Auditor | One agent reviews a codebase, commits findings to Hansard, escalates anything it cannot classify |
644
+ | Pre-registration | One agent locks a hypothesis, runs analysis, cannot alter methodology without Speaker approval |
645
+ | Replication Crisis | One agent attempts to replicate a finding, Hansard records every step |
646
+ | Writer/Drafter | One agent produces structured output under defined Standing Orders, no scope creep without escalation |
647
+
648
+ `QUORUM: 1` is a valid explicit Charter configuration. It is not a degenerate case — it is a legitimate session type where the governance value is audit trail and structured constraint, not multi-agent debate.
649
+
650
+ ```yaml
651
+ session:
652
+ quorum: 1 # this alone declares a single-player session
653
+ escalation: enabled # Speaker still reachable
654
+ ```
655
+
656
+ The Hansard is still required — recording is not optional in any non-Ephemeral
657
+ protocol, so a single-player session needs no flag to opt into it.
658
+
659
+ `mode` and `record_mode` belong to `protocol:` (see POLITIK-ARCHITECTURE.md
660
+ § Protocol Schema Format) and are **not** session-level keys. See ADR-0002.
661
+
662
+ ### Minimum Cast — Enforced at Writ Drop
663
+
664
+ Each protocol declares its minimum viable cast. The engine enforces this at Writ Drop — before the session starts. If the minimum cast is not met, the session never opens.
665
+
666
+ **Why Writ Drop enforcement, not runtime enforcement:**
667
+
668
+ Runtime discovery of a missing role means invalid state with work already committed to Hansard. That creates ambiguous, potentially corrupted output. Hard fail at Writ Drop keeps the session substrate clean — either the session opens fully valid or it does not open at all.
669
+
670
+ ```
671
+ Writ Drop validation:
672
+ Charter parsed
673
+ ↓
674
+ Minimum cast checked against assigned constituencies
675
+ ↓
676
+ PASS → session opens, STATE.json → active
677
+ FAIL → SESSION_INVALID committed to Hansard
678
+ session never opens
679
+ error specifies which roles are missing
680
+ ```
681
+
682
+ ### Minimum Cast Per Protocol
683
+
684
+ Each protocol definition declares its minimum viable cast. Examples:
685
+
686
+ ```yaml
687
+ # Parliamentary Democracy
688
+ minimum_cast:
689
+ AUTHORITY: 1 # Speaker required — no session without human authority
690
+ OPERATOR: 2 # At least two Ministers to debate
691
+ MEMBER: 0 # Optional
692
+ OBSERVER: 0 # Optional
693
+ quorum: 2 # Minimum actors for a valid Division
694
+
695
+ # Battle Royale
696
+ minimum_cast:
697
+ OPERATOR: 2 # Cannot have last-one-standing with one player
698
+ quorum: 2
699
+
700
+ # Military Operation
701
+ minimum_cast:
702
+ AUTHORITY: 1 # Commanding Officer required
703
+ OPERATOR: 1 # At least one field agent
704
+ quorum: 1 # CO alone can issue orders
705
+
706
+ # Peer Review
707
+ minimum_cast:
708
+ AUTHORITY: 1 # Editor required
709
+ OPERATOR: 2 # Minimum two reviewers
710
+ MEMBER: 1 # Author required
711
+ quorum: 3
712
+
713
+ # Solo Auditor (QUORUM: 1)
714
+ minimum_cast:
715
+ MEMBER: 1 # The auditing agent
716
+ quorum: 1
717
+ ```
718
+
719
+ ### SESSION_INVALID — Hansard Record Type
720
+
721
+ When a session fails minimum cast validation at Writ Drop, the following record is committed to Hansard before the session closes:
722
+
723
+ ```markdown
724
+ # SESSION_INVALID
725
+
726
+ **Timestamp:** [Writ Drop attempt time]
727
+ **Protocol:** [protocol name]
728
+ **Reason:** Minimum cast not met
729
+
730
+ **Required roles missing:**
731
+ - OPERATOR: required 2, assigned 0
732
+ - AUTHORITY: required 1, assigned 0
733
+
734
+ **Resolution:** Assign the missing constituencies and re-drop the Writ.
735
+ Session has not started. No session state has been written.
736
+ ```
737
+
738
+ This gives the Speaker a clean, auditable record of why the session failed to open.
739
+
740
+ ### Degraded Sessions — quorum_override
741
+
742
+ In some circumstances a Speaker may wish to proceed with a reduced cast — acknowledging the degraded configuration explicitly. This is the machine equivalent of a parliamentary session where members are absent but quorum is still technically met.
743
+
744
+ ```yaml
745
+ session:
746
+ quorum_override: true
747
+ quorum_override_reason: "OPERATOR-2 constituency unavailable — proceeding with single OPERATOR"
748
+ quorum_override_acknowledged_by: AUTHORITY
749
+ ```
750
+
751
+ `quorum_override` requires:
752
+ - Explicit `quorum_override_reason` committed to Hansard
753
+ - AUTHORITY acknowledgement
754
+ - Cannot override `minimum_cast` for AUTHORITY itself — a session with no Speaker cannot proceed under any configuration
755
+
756
+ The override is always visible in the Hansard. It cannot be hidden. Any reviewer of the session record will see that it ran in degraded mode and why.
757
+
758
+ ---
759
+
760
+ ## INFRASTRUCTURE FAULT CLASSIFICATION
761
+
762
+ ### The Problem
763
+
764
+ A failed agent action looks identical in the Hansard whether the agent made a bad decision or whether a GitHub Secret expired. Without fault attribution, Politik cannot distinguish actor failure from infrastructure failure. An innocent actor would be unfairly penalised — demotion triggers, performance record damaged — for something entirely outside their control.
765
+
766
+ ### Fault Types
767
+
768
+ Every failed action must be classified before it touches the actor's record:
769
+
770
+ | Fault type | Code | Meaning | Actor penalised? |
771
+ |---|---|---|---|
772
+ | Actor fault | `FAULT_ACTOR` | Bad logic, wrong output, Standing Orders violation | Yes |
773
+ | Infrastructure fault | `FAULT_INFRA` | Secret expired, pipeline misconfigured, API outage, rate limit | No |
774
+ | External fault | `FAULT_EXTERNAL` | Dependency registry down, network partition, third-party API failure | No |
775
+ | Ambiguous | `FAULT_AMBIGUOUS` | Cannot determine — escalates to Speaker for ruling | Pending |
776
+
777
+ ### SESSION_FAULT Hansard Record
778
+
779
+ ```markdown
780
+ # SESSION_FAULT
781
+
782
+ **Actor:** OPERATOR-1
783
+ **Action attempted:** Deploy authentication module to staging
784
+ **Fault type:** FAULT_INFRA
785
+ **Fault detail:** GitHub Secret STAGING_API_KEY not found —
786
+ secret name mismatch in workflow config
787
+ **Actor penalised:** No — infrastructure fault, actor blameless
788
+ **Resolution path:** PATH_B — human required
789
+ **Status:** SESSION_SUSPENDED — awaiting Speaker resolution
790
+ ```
791
+
792
+ ### Three Resolution Paths
793
+
794
+ **PATH_A — Auto-recoverable**
795
+
796
+ Transient failure — rate limit, temporary outage, secret rotation in progress. Engine retries after configurable delay. No Speaker intervention required. FAULT committed to Hansard with `auto_retry: true`. If retry succeeds, `FAULT_RESOLVED_AUTO` committed. If retry exhausted, escalates to PATH_B.
797
+
798
+ ```yaml
799
+ fault_handling:
800
+ auto_retry_max: 3
801
+ auto_retry_delay_minutes: 5
802
+ auto_recoverable: [rate_limit, transient_outage, timeout]
803
+ ```
804
+
805
+ **PATH_B — Human required**
806
+
807
+ Infrastructure misconfiguration that only a human can fix — expired secret, wrong secret name, broken workflow YAML, invalid credentials. Session auto-suspends. Speaker notified via GitHub Actions. Human fixes the infrastructure. Speaker commits `FAULT_RESOLVED` to Hansard. Session resumes from last STATE_SNAPSHOT.
808
+
809
+ ```markdown
810
+ # FAULT_RESOLVED
811
+
812
+ **Resolution:** STAGING_API_KEY secret corrected in GitHub Settings
813
+ **Resolved by:** AUTHORITY (human)
814
+ **Session resuming from:** STATE_SNAPSHOT 2026-04-08T14:00:00
815
+ **Actor record:** No penalty applied — FAULT_INFRA confirmed
816
+ ```
817
+
818
+ **PATH_C — Irrecoverable**
819
+
820
+ Critical infrastructure damage that cannot be repaired within the session — catastrophic git rebase destroying managed repo history, permanent data loss, security breach requiring repo isolation.
821
+
822
+ ```markdown
823
+ # SESSION_FAULT_CRITICAL
824
+
825
+ **Fault type:** FAULT_INFRA — CRITICAL
826
+ **What occurred:** Agent executed rebase on protected branch.
827
+ Managed repo history corrupted.
828
+ **Session status:** PROROGUED — irrecoverable
829
+ **Managed repo:** ISOLATED — no further commits until human review
830
+ **Recovery options:**
831
+ - git reflog may recover pre-rebase state (git feature, not Politik)
832
+ - Branch protection on main would have prevented this —
833
+ recommend enabling for future sessions
834
+ **Forensic record:** Complete Hansard preserved. See LEDGER.md
835
+ for full action timeline.
836
+ ```
837
+
838
+ ### The Honest Limits of Recovery
839
+
840
+ Politik does not repair destroyed git history. It cannot. What it does:
841
+
842
+ - **Limits blast radius** — commit-every-change rule maximises reflog entries
843
+ - **Branch protection Standing Orders** — Charter should declare managed repo main as protected; agents work feature branches only
844
+ - **Forensic record** — Hansard tells you what happened, by whom, when, and why — even if the code is gone
845
+ - **Fault attribution** — the actor is not blamed for infrastructure failure
846
+
847
+ Git's own `reflog` is the recovery mechanism for destroyed history. Politik maximises the number of recovery points through its commit discipline. It cannot reconstruct what was never committed.
848
+
849
+ ---
850
+
851
+ ## ACTOR HIRE AND FIRE — VIRTUE/VICE MATRIX
852
+
853
+ ### The HIRE Verb
854
+
855
+ Bringing a new actor into a convened proceeding requires an explicit HIRE action committed to Hansard:
856
+
857
+ ```yaml
858
+ HIRE:
859
+ who_can: [AUTHORITY, OPERATOR] # OPERATOR requires AUTHORITY witness
860
+ committed_to: Hansard immediately
861
+ effective: next_motion
862
+ required_fields:
863
+ - hiring_actor
864
+ - hired_actor
865
+ - role_assigned
866
+ - stated_reason
867
+ - authority_witness # required if OPERATOR is hiring
868
+ ```
869
+
870
+ Charter can optionally require:
871
+ ```yaml
872
+ hire_policy:
873
+ require_qualifications: true # stated reason must reference capabilities
874
+ require_alternatives_considered: true # were others evaluated?
875
+ authority_veto_window_motions: 2 # Speaker can reverse within N motions
876
+ ```
877
+
878
+ ### The Four-Quadrant Virtue/Vice Matrix
879
+
880
+ Every HIRE and FIRE involves two actors — the one doing it and the one it's done to. Each can be virtuous or vicious. The outcomes are different in every quadrant:
881
+
882
+ | Hirer/Firer | Hire-ee/Fire-ee | Pattern | Hansard signal |
883
+ |---|---|---|---|
884
+ | Virtuous | Virtuous | Clean — merit-based | Performance record supports the decision |
885
+ | Virtuous | Vicious | Legitimate | Violations in Hansard justify it |
886
+ | **Vicious** | **Virtuous** | **The problem** | High performance record + sudden EXIT or HIRE of loyalist |
887
+ | Vicious | Vicious | Chaos | Multiple violations, poor output across the board |
888
+
889
+ ### The Vicious Hirer / Virtuous Fire-ee Pattern
890
+
891
+ The most dangerous quadrant. A narcissistic AUTHORITY fires a high-performing actor because they were inconvenient, or hires a less-qualified loyalist over a better candidate.
892
+
893
+ **The Hansard makes this visible:**
894
+
895
+ ```markdown
896
+ # FIRE — Hansard entry
897
+ Actor: AUTHORITY
898
+ Action: EXPEL
899
+ Target: OPERATOR-2
900
+ Reason stated: "Poor alignment with session goals"
901
+ Exit type: EXIT_SPEAKER
902
+
903
+ # OPERATOR-2 performance record (prior 12 motions):
904
+ # Motions accepted: 11 of 12
905
+ # Escalations filed against: 0
906
+ # Divisions won: 8 of 8
907
+ # Demotion triggers hit: 0
908
+
909
+ # HIRE — 2 motions later
910
+ Actor: AUTHORITY
911
+ Action: HIRE
912
+ Hired: OPERATOR-3
913
+ Role: OPERATOR
914
+ Stated reason: "Strong alignment with session goals"
915
+
916
+ # OPERATOR-3 performance record (next 10 motions):
917
+ # Motions accepted: 3 of 10
918
+ # Escalations filed against: 4
919
+ # Divisions won: 1 of 6
920
+
921
+ # The Hansard has receipts.
922
+ # The contradiction between the stated reason and the performance
923
+ # record is permanent, attributed, and publicly readable.
924
+ ```
925
+
926
+ ### Why This Matters for the Human Flaw Thesis
927
+
928
+ Hiring and firing under the influence of Pride (I won't tolerate someone better than me), Envy (their success threatens mine), Tribalism (loyalty over merit), or Hubris (I don't need to justify my decisions) are among the most destructive governance failures in human organisations.
929
+
930
+ Machine actors don't hire loyalists. They don't fire threats. They don't build personal patronage networks. A Politik session where an OPERATOR cannot HIRE without AUTHORITY witness and stated reason on record — and where every hire and fire is permanently attributed in the Hansard — creates accountability that most human organisations never achieve.
931
+
932
+ The Hansard doesn't prevent bad hiring. It makes bad hiring undeniable and permanent.
933
+
934
+ ---
935
+
936
+ ## SOFTWARE FORENSICS — POLITIK AS FORENSIC PLATFORM
937
+
938
+ ### The Accidental Discovery
939
+
940
+ Politik was designed as a governance framework. It accidentally became a forensics platform. The same property that makes it a governance tool — every action attributed, timestamped, and immutably recorded — is exactly what forensic investigation requires.
941
+
942
+ A conventional git log tells you what changed and when. It tells you nothing about:
943
+ - Why the decision was made
944
+ - Who approved it under what governance
945
+ - What alternatives were considered and rejected
946
+ - What the escalation was that triggered an architectural pivot
947
+ - Whether the acting agent was within its mandate
948
+ - What it cost in tokens, time, and compute
949
+
950
+ The Hansard tells you all of that. Combined with the git log of the managed repo — which the Hansard references by commit hash — you have a complete forensic picture that no other tool produces.
951
+
952
+ ### Post-Mortem Investigation Protocol
953
+
954
+ ```yaml
955
+ protocol: incident_investigation
956
+ domain: software_forensics
957
+ mode: Constitutional # immutable Charter, human-led investigation
958
+
959
+ roles:
960
+ AUTHORITY: Lead Investigator (human, neutral party)
961
+ OPERATOR: Technical Analyst (reads Hansard and git log)
962
+ MEMBER: Witness Agent (answers questions about its own actions)
963
+ OBSERVER: Auditor (read-only, produces signed attestation)
964
+
965
+ session_rules:
966
+ managed_repo: read_only # investigators never touch the evidence
967
+ hansard_access: read_only # the Hansard IS the evidence
968
+ new_commits: findings_only # only the investigation report is written
969
+ ```
970
+
971
+ **What investigators read:**
972
+
973
+ ```
974
+ HANSARD.md ← complete attributed action log
975
+ LEDGER.md ← cost and timing per action (was the agent rushing?)
976
+ SESSION_FAULT.* ← what failures occurred and why
977
+ STATE_SNAPSHOT.* ← what the session knew at each checkpoint
978
+ escalations/ ← what triggered human intervention
979
+ motions/ ← what was proposed and what actually happened
980
+ ```
981
+
982
+ **What the investigation produces:**
983
+
984
+ ```markdown
985
+ # INCIDENT REPORT — SESSION cordfuse/politik-PROJ-112
986
+
987
+ ## Timeline reconstruction
988
+ 14:02 OPERATOR-1 tabled MOTION-07 — deploy to staging
989
+ 14:03 Division called — passed 2-0
990
+ 14:04 OPERATOR-1 executed deployment
991
+ 14:04 SESSION_FAULT — FAULT_INFRA — secret STAGING_KEY expired
992
+ 14:04 Session auto-suspended
993
+ 14:47 AUTHORITY resolved: secret rotated
994
+ 14:48 Session resumed
995
+
996
+ ## Root cause
997
+ Infrastructure fault — secret rotation policy not updated in Charter.
998
+ Not actor fault. No performance impact on OPERATOR-1.
999
+
1000
+ ## Recommendation
1001
+ Charter updated to include secret rotation schedule.
1002
+ Automated secret health check added to quorum-check.yml.
1003
+ ```
1004
+
1005
+ ### The Chain of Custody Property
1006
+
1007
+ An investigation session that reads the Hansard of a prior session maintains chain of custody automatically:
1008
+
1009
+ - Investigators never modify evidence — they read Hansard, commit findings only
1010
+ - All investigator actions are themselves recorded in the investigation Hansard
1011
+ - The investigation is attributed, timestamped, and immutable
1012
+ - Multiple independent investigations of the same incident produce comparable records
1013
+
1014
+ This is what legal forensics has always needed and never had in software: an immutable, attributed, machine-readable record of every decision made in a project — not just what the code looks like now, but the complete governance history of how it got there.
1015
+
1016
+ ### The Git Forensics Implication
1017
+
1018
+ When a production incident occurs:
1019
+
1020
+ ```
1021
+ 1. Open Politik Forensics session on the incident
1022
+ 2. Agents read the failed session's Hansard
1023
+ 3. Cross-reference with managed repo git log by commit hash
1024
+ 4. SESSION_FAULT records show fault attribution already done
1025
+ 5. LEDGER shows cost and timing — was the agent rushing?
1026
+ (high tokens, low elapsed = skipping steps)
1027
+ 6. Motion records show what was approved and by whom
1028
+ 7. Division records show who voted for the failing change
1029
+ 8. Investigation report committed — permanent, attributed, auditable
1030
+ ```
1031
+
1032
+ ### Forensics as a First-Class Domain
1033
+
1034
+ ```yaml
1035
+ domain: software_forensics
1036
+ protocols:
1037
+ - Incident Investigation # post-mortem, root cause
1038
+ - Security Audit # penetration testing governance
1039
+ - Compliance Review # SOC2, GDPR, audit trail production
1040
+ - Code Review Tribunal # contested PR with formal ruling
1041
+ - Regression Archaeology # when did this bug get introduced?
1042
+ ```
1043
+
1044
+ The Hansard is the chain of custody. The git log is the evidence. Politik is the court.
1045
+
1046
+ ---
1047
+
1048
+ ## POLITIK AS JIRA REPLACEMENT — THE ZERO-OVERHEAD PROJECT RECORD
1049
+
1050
+ ### The Discovery
1051
+
1052
+ Jira's primary value proposition is a centralised record of who did what on a software project.
1053
+
1054
+ Politik produces a superior version of that record as a **zero-overhead side effect of running governed agent sessions**. Nobody updates it. Nobody logs time. Nobody links the commit. It is all there because it cannot be otherwise — the Hansard is append-only and every action is attributed.
1055
+
1056
+ The difference is profound:
1057
+
1058
+ **Jira** is a database humans are required to keep updated.
1059
+ **Hansard** is a database that is impossible to not keep updated.
1060
+
1061
+ ### Feature Comparison
1062
+
1063
+ | Jira feature | How humans do it | How Politik does it automatically |
1064
+ |---|---|---|
1065
+ | Ticket title | Developer types it | Motion title in Hansard |
1066
+ | Description | Developer writes it | Motion body |
1067
+ | Assignee | Someone assigns it | Actor constituency from Writ Drop |
1068
+ | Status updates | Developer manually changes | STATE.json updates on every action |
1069
+ | Time logged | Developer estimates and enters | LEDGER — exact elapsed per motion |
1070
+ | Comments | Developer writes | Every Hansard entry — attributed, timestamped |
1071
+ | Linked commits | Developer manually links | Every Hansard entry references commit hash |
1072
+ | Code reviewer | Someone assigns | Division record — who approved, vote outcome |
1073
+ | Escalation/blocker | Developer flags | ESCALATION verb — auto-notifies Speaker |
1074
+ | Cost tracking | Finance estimates | LEDGER — actual token cost per motion |
1075
+ | Ticket closed | Developer manually closes | Prorogation — automatic on session end |
1076
+
1077
+ ### What Politik Produces That Jira Never Could
1078
+
1079
+ | Capability | Description |
1080
+ |---|---|
1081
+ | Why the decision was made | Motion reasoning — not just what changed but the full context |
1082
+ | Who approved it and how | Division record — attributed votes, not just "approved" |
1083
+ | What alternatives were rejected | Prior motions that failed — the full deliberation trail |
1084
+ | Fault attribution | FAULT_ACTOR vs FAULT_INFRA — was it the agent or the infrastructure? |
1085
+ | Cost per decision | Token cost and elapsed time per motion from LEDGER |
1086
+ | Agent performance record | Full motion history per constituency across the session |
1087
+ | Governance trail | Which protocol governed which decision |
1088
+ | Vice detection | Hansard pattern analysis for bad faith PROMOTE, FIRE, HIRE |
1089
+
1090
+ ### Story Points vs LEDGER
1091
+
1092
+ Jira uses story points — a fictional unit of effort estimated by humans before the work is done, notoriously inaccurate, constantly debated in sprint planning.
1093
+
1094
+ LEDGER provides:
1095
+ - Exact elapsed time per motion
1096
+ - Exact token count per motion
1097
+ - Exact cost in dollars per motion
1098
+ - Cumulative session cost against ceiling
1099
+
1100
+ No estimation. No debate. Actual measured data that improves with every session as baselines accumulate.
1101
+
1102
+ ### Structural Advantage
1103
+
1104
+ Jira's data quality depends on human discipline — developers must manually enter and maintain records. The Hansard's data quality is architectural — agents cannot act without recording. This is not a feature comparison. It is a category difference in how project records are produced.
1105
+
1106
+ ### Jira Integration
1107
+
1108
+ Politik can integrate with existing Jira installations:
1109
+
1110
+ ```yaml
1111
+ integrations:
1112
+ jira:
1113
+ enabled: true
1114
+ sync_on: prorogation # push session summary to Jira on close
1115
+ create_ticket: writ_drop # create Jira ticket when Writ is dropped
1116
+ update_status: state_change # sync STATE.json to Jira status
1117
+ link_commits: hansard # auto-link all commit hashes
1118
+ log_time: ledger # push LEDGER elapsed to Jira time tracking
1119
+ close_ticket: prorogation # close Jira ticket on prorogation
1120
+ ```
1121
+
1122
+ This allows Politik to coexist with existing project management infrastructure. The Hansard auto-populates Jira with attributed, timestamped records.
1123
+
1124
+ ---
1125
+
1126
+ ## GOVERNANCE TIERS
1127
+
1128
+ Every session has three governance tiers:
1129
+
1130
+ | Tier | Mechanism | Trigger |
1131
+ |---|---|---|
1132
+ | Standing Orders | Self-executing statute | Always checked first |
1133
+ | Deputy Speaker | Delegated agent proxy | Standing Orders silent |
1134
+ | Speaker | Human intervention | Deputy absent or overruled |
1135
+
1136
+ ### Promotion and Demotion — Full Doctrine
1137
+
1138
+ **Who can promote or demote whom:**
1139
+
1140
+ Promotion and demotion are not freely available verbs. The hierarchy of who holds these powers is strict:
1141
+
1142
+ | Actor | Can promote | Can demote |
1143
+ |---|---|---|
1144
+ | `AUTHORITY` | Any actor to any role below AUTHORITY | Any actor to any role |
1145
+ | `OPERATOR` | `MEMBER` → `OPERATOR` only, with AUTHORITY witness | `MEMBER` only, with AUTHORITY witness |
1146
+ | `MEMBER` | Cannot promote | Cannot demote |
1147
+ | `OBSERVER` | Cannot promote | Cannot demote |
1148
+
1149
+ An OPERATOR cannot promote another OPERATOR. An OPERATOR cannot demote another OPERATOR. Lateral role changes require AUTHORITY. This prevents coalition capture — two OPERATORs cannot conspire to elevate a third to shift a Division majority without the Speaker's knowledge.
1150
+
1151
+ **Auto-Promotion — Charter Config:**
1152
+
1153
+ ```yaml
1154
+ governance:
1155
+ auto_promotion:
1156
+ trigger: motions_carried >= 3 # performance threshold
1157
+ from: MEMBER
1158
+ to: OPERATOR
1159
+ witness: quorum_required # peers must acknowledge
1160
+ effective: next_motion # not retroactive
1161
+ authority_veto: true # AUTHORITY can block within N motions
1162
+ ```
1163
+
1164
+ **Auto-Demotion — Charter Config:**
1165
+
1166
+ ```yaml
1167
+ governance:
1168
+ auto_demotion:
1169
+ trigger: motions_failed >= 2 # consecutive failures
1170
+ from: OPERATOR
1171
+ to: MEMBER
1172
+ witness: quorum_required
1173
+ effective: next_motion
1174
+ authority_veto: true
1175
+ ```
1176
+
1177
+ Auto-demotion is the mirror of auto-promotion. Consistently failing to produce accepted output is grounds for trust reduction. This is the machine equivalent of a Minister losing the confidence of the House.
1178
+
1179
+ **What happens to in-flight work at role change:**
1180
+
1181
+ - **Promotion mid-motion:** Actor finishes the current motion at their old trust level. New verbs available from next motion onward. Promotion is committed to Hansard immediately but effective next motion — no ambiguity about which rules governed which output.
1182
+ - **Demotion mid-motion:** Same. Actor completes current motion at old trust level. Demotion effective from next action. Not retroactive — prior Hansard entries retain the role label they were committed under. Hansard is immutable.
1183
+
1184
+ **Prior Hansard entries after role change:**
1185
+
1186
+ Hansard entries are immutable. A MEMBER promoted to OPERATOR retains all prior entries labelled as MEMBER. This is correct and intentional — the record shows the actor's trust level at the time of each action. Auditors can see exactly when a role change occurred and what came before and after.
1187
+
1188
+ **Bad Faith PROMOTE — Defence Mechanism:**
1189
+
1190
+ An OPERATOR promoting a friendly MEMBER to shift a Division majority is a form of bad faith manipulation. The defences:
1191
+
1192
+ - AUTHORITY witness required for all promotions — Speaker must see it happen
1193
+ - Promotion committed to Hansard immediately — full visibility
1194
+ - `authority_veto: true` gives the Speaker a window to reverse a promotion before the new verbs are exercised
1195
+ - Hansard pattern detection: if a promotion is followed immediately by a Division where the newly promoted actor's vote is decisive — that sequence is auditable and flagged
1196
+
1197
+ ```yaml
1198
+ governance:
1199
+ auto_promotion:
1200
+ authority_veto: true
1201
+ authority_veto_window_motions: 2 # Speaker has 2 motions to reverse
1202
+ ```
1203
+
1204
+ **The AUTHORITY ceiling:**
1205
+
1206
+ AUTHORITY is constitutionally locked to human. This is not a technical limitation — it is a deliberate design choice. The framework is species-agnostic at every other role level. AUTHORITY is the one exception. The Speaker must be human because the Speaker is the last line of appeal when the system fails, and the system will fail in ways that require human judgement to resolve.
1207
+
1208
+ When AI systems reach a level of verified trustworthiness that justifies removing this constraint — the architecture supports it. The CANON layer will not need to change. The constitutional rule simply stops applying. The framework is ready for that day. We are not there yet.
1209
+
1210
+ ### Constitutional Capture — When AUTHORITY is the Corruptor
1211
+
1212
+ Every defence mechanism in Politik assumes the Speaker is neutral. Disputed exit flows escalate to the Speaker. Promotion vetoes sit with the Speaker. Hung Parliament routing goes to the Speaker. Voluntold detection auto-notifies the Speaker.
1213
+
1214
+ If the Speaker is the source of corruption — all of those mechanisms route directly to the problem. The system does not just fail. It actively assists the corruption.
1215
+
1216
+ **This is Constitutional Capture — the hardest failure mode in the architecture.**
1217
+
1218
+ Historical examples span every governance domain: republics where executive power was gradually concentrated until the constitution became advisory, scientific institutions where a dominant researcher suppressed dissenting findings through funding control, corporations where a board captured by the CEO rubber-stamped decisions contrary to shareholder interest. The pattern is universal. The mechanism is always the same — AUTHORITY uses legitimately held powers to remove actors who would check those powers, and promotes actors who will not.
1219
+
1220
+ **The seven sins at the AUTHORITY level:**
1221
+
1222
+ | Sin | AUTHORITY failure mode |
1223
+ |---|---|
1224
+ | **Pride** | Refusing to accept Division results that contradict their position |
1225
+ | **Wrath** | Demoting or expelling actors who dissent or outperform |
1226
+ | **Greed** | Using session mandate to enrich preferred actors or constituencies |
1227
+ | **Envy** | Surrounding themselves with poorly qualified actors whose competence does not threaten |
1228
+ | **Sloth** | Enforcing Standing Orders selectively against enemies, ignoring violations by allies |
1229
+ | **Tribalism** | Promoting based on loyalty to AUTHORITY rather than merit or session goals |
1230
+ | **Hubris** | Declaring their own actions exempt from Charter constraints |
1231
+
1232
+ **Why this is structurally worse than bad-faith actors below AUTHORITY:**
1233
+
1234
+ A corrupt OPERATOR can be expelled. A corrupt MEMBER can be demoted. The appeal path runs upward to AUTHORITY. When AUTHORITY is the corruptor there is no appeal path. The system has no mechanism above AUTHORITY by design — that is what makes the role constitutional.
1235
+
1236
+ **Three mitigations — all optional Charter declarations:**
1237
+
1238
+ **1. Witness Council**
1239
+
1240
+ ```yaml
1241
+ governance:
1242
+ witness_council:
1243
+ enabled: true
1244
+ roles: [OBSERVER] # designated constitutional witnesses
1245
+ can_file: CONSTITUTIONAL_CRISIS
1246
+ ```
1247
+
1248
+ Designated OBSERVER actors who can commit a `CONSTITUTIONAL_CRISIS` Hansard record when they observe AUTHORITY violations. Does not remove AUTHORITY. Creates an immutable formal record visible to anyone who can read the repo. The receipts survive even if the session is subsequently dissolved.
1249
+
1250
+ **2. DELEGATE Challenge Verb**
1251
+
1252
+ ```yaml
1253
+ governance:
1254
+ delegate_challenge:
1255
+ enabled: true
1256
+ challenge_window_minutes: 30 # AUTHORITY action paused for 30 minutes
1257
+ challenge_committed_to_hansard: true
1258
+ ```
1259
+
1260
+ DELEGATE can formally dispute an AUTHORITY action before it takes effect. The challenged action is logged and paused. AUTHORITY still wins after the window — but the challenge is on the permanent record. Makes bad faith AUTHORITY actions visible and attributable.
1261
+
1262
+ **3. Prorogation by Consensus**
1263
+
1264
+ ```yaml
1265
+ governance:
1266
+ consensus_suspension:
1267
+ enabled: true
1268
+ threshold: 0.75 # 75% of OPERATOR actors must concur
1269
+ action: CONSTITUTIONAL_CRISIS
1270
+ resume_requires: external_review
1271
+ ```
1272
+
1273
+ If a supermajority of OPERATOR actors simultaneously file escalations against AUTHORITY, the session auto-suspends and a `CONSTITUTIONAL_CRISIS` record is committed. Session cannot resume until an external human — outside the session — reviews the Hansard and rules. The machine equivalent of a parliamentary vote of no confidence.
1274
+
1275
+ **The uncomfortable architectural truth:**
1276
+
1277
+ A Charter written by a corrupt AUTHORITY will have convenient gaps. DELEGATE challenge powers will be stripped. Witness Council will be excluded. Consensus suspension threshold will be set so high it cannot trigger. The `quorum_override` will be configured to let AUTHORITY act alone.
1278
+
1279
+ The Hansard is always the last defence. It is immutable. It is public. It records everything. A corrupt AUTHORITY cannot change what was already committed — but it can stop future honest commits by dissolving the session before the evidence accumulates. This is why `CONSTITUTIONAL_CRISIS` suspends rather than prorogues — and why resumption requires external review. The session substrate survives a premature dissolution. The Hansard is the receipts.
1280
+
1281
+ **Note on the AUTHORITY hard rule:**
1282
+
1283
+ The Charter cannot declare a machine as AUTHORITY — not because machines would necessarily do worse, but because the failure mode of a corrupt AUTHORITY requires human accountability that only a human can bear. A machine AUTHORITY that captures a session cannot be held personally responsible. A human AUTHORITY can be. That accountability is the last teeth the constitution has.
1284
+
1285
+ When AI systems reach a level of verified trustworthiness that justifies removing this constraint, the architecture supports it. The CANON layer will not need to change. The constitutional rule simply stops applying.
1286
+ ```
1287
+ Standing Orders cannot resolve
1288
+ ↓
1289
+ Deputy Speaker consulted
1290
+ ↓
1291
+ Deputy cannot resolve
1292
+ ↓
1293
+ Session pauses
1294
+ ↓
1295
+ Speaker notified via GitHub Actions
1296
+ ↓
1297
+ Speaker rules
1298
+ ↓
1299
+ Session resumes
1300
+ ```
1301
+
1302
+ ---
1303
+
1304
+ ## RECORD MODES
1305
+
1306
+ | Mode | Hansard | Use case |
1307
+ |---|---|---|
1308
+ | Distributed (default) | Every Constituency keeps local log | Most sessions |
1309
+ | Anchored | Designated RECORD agent aggregates | Enterprise, audit |
1310
+ | Ephemeral | No record kept | Intelligence, Organized Crime protocols |
1311
+
1312
+ Charter declares mode. Framework respects it.
1313
+
1314
+ ---
1315
+
1316
+ ## DISTRIBUTION MODEL
1317
+
1318
+ ### Fork-Based Distribution
1319
+ ```
1320
+ cordfuse/politik ← canonical template repo (private until ready)
1321
+ ↓ (user forks)
1322
+ user/my-politik ← user's sovereign session repo
1323
+ ```
1324
+
1325
+ ### Template Repo Structure
1326
+ ```
1327
+ cordfuse/politik ← default Parliamentary protocol
1328
+ cordfuse/politik-agile ← Agile protocol
1329
+ cordfuse/politik-military ← Military protocol
1330
+ cordfuse/politik-legal ← Legal protocol
1331
+ cordfuse/politik-sdk ← build your own protocol
1332
+ ```
1333
+
1334
+ ### Update Flow
1335
+ ```bash
1336
+ # User pulls framework updates without touching their Charter
1337
+ git remote add upstream https://github.com/cordfuse/politik
1338
+ git fetch upstream
1339
+ git merge upstream/main
1340
+ # CHARTER.md and sessions/ never touched by upstream
1341
+ ```
1342
+
1343
+ ### .gitignore on master repo
1344
+ ```gitignore
1345
+ CHARTER.md
1346
+ sessions/
1347
+ actors/
1348
+ roles/*.md
1349
+ !roles/*.template.md
1350
+ STATE.json
1351
+ HANSARD.md
1352
+ ```
1353
+
1354
+ ---
1355
+