@cordfuse/politik 0.3.1 → 0.5.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.
package/EXECUTION.md CHANGED
@@ -263,7 +263,7 @@ unread template.
263
263
  **Framing note:** Parliamentary is protocol #1, not a privileged mode.
264
264
  All protocols are equal. The framework is protocol-agnostic.
265
265
 
266
- **Shipped with framework (reference protocols):** all eleven in `protocols/`,
266
+ **Shipped with framework (reference protocols):** all twelve in `protocols/`,
267
267
  every one lint-clean.
268
268
 
269
269
  ```
@@ -278,6 +278,7 @@ every one lint-clean.
278
278
  [x] Peer Review (scientific research) peer-review.yml
279
279
  [x] Adversarial Collaboration (scientific research) adversarial-collaboration.yml
280
280
  [x] Solo (single-lead) solo.yml
281
+ [x] Scrum / Agile (the comparison baseline) scrum.yml
281
282
  ```
282
283
 
283
284
  The eleven were curated from a much wider design exploration — 52 shapes down to
@@ -285,7 +286,8 @@ eleven professional exemplars, with fascism and organized-crime cut as liabiliti
285
286
  and games and toys trimmed. Modes represented: constitutional (parliamentary,
286
287
  republic, corporate, peer-review), a unanimity Jury, a darwinist elimination
287
288
  Tournament, and an authoritarian ICS incident command. PROTOCOLS.md documents the
288
- eleven.
289
+ eleven. Scrum / Agile was added later as a twelfth: not a curated exemplar but the
290
+ baseline RESEARCH.md measures the others against, available and never the default.
289
291
 
290
292
  **Power inversions are declared, never inferred.** `jury-deliberation.yml` and
291
293
  `peer-review.yml` let a lower-trust role — a juror, a reviewer — override the
package/PROTOCOLS.md CHANGED
@@ -8,7 +8,7 @@ See [POLITIK-ARCHITECTURE.md](POLITIK-ARCHITECTURE.md) for CANON, session struct
8
8
 
9
9
  ## Implementation status
10
10
 
11
- This document is the shipping protocol library — the eleven manifests in
11
+ This document is the shipping protocol library — the twelve manifests in
12
12
  `protocols/*.yml`, each a vocabulary translation over CANON plus a composition of
13
13
  mechanics. What the engine enforces:
14
14
 
@@ -41,13 +41,13 @@ mechanics. What the engine enforces:
41
41
  to play equilibrium.
42
42
 
43
43
  Parliamentary is protocol #1, not a privileged mode. `scaffold --protocol <name>`
44
- scaffolds a Charter for any of the eleven, inheriting its mechanics. **Compose
44
+ scaffolds a Charter for any of the twelve, inheriting its mechanics. **Compose
45
45
  your own** for any governance shape not here — the framework is the product, and
46
46
  a new protocol is a Charter away.
47
47
 
48
48
  ---
49
49
 
50
- ## The eleven protocols
50
+ ## The twelve protocols
51
51
 
52
52
  ### Political archetypes
53
53
 
@@ -229,6 +229,41 @@ Mode: Authoritarian with DOMAIN_VETO safety carve-out
229
229
  | DOMAIN_VETO | Shareholder (special resolution veto) |
230
230
  Mode: Constitutional
231
231
 
232
+ **Protocol: Scrum / Agile**
233
+ | CANON | Term |
234
+ |---|---|
235
+ | AUTHORITY | Product Owner |
236
+ | DELEGATE | Scrum Master |
237
+ | OPERATOR | Developer |
238
+ | MEMBER | Team Member |
239
+ | OBSERVER | Stakeholder |
240
+ | SESSION | Sprint |
241
+ | PROCEEDING | Release |
242
+ | CHARTER | Working Agreement |
243
+ | RECORD | Sprint Log |
244
+ | MOTION | Backlog Item |
245
+ | DIVISION | Sprint Review |
246
+ | ASSENT | Accepted as Done |
247
+ | ESCALATION | Impediment |
248
+ | SUSPENSION | Blocked |
249
+ | CONFLICT | Merge Conflict |
250
+ | DEADLOCK | No Consensus |
251
+ | SPAWN | Split the Story |
252
+ | DISSOLVE | Sprint Ends |
253
+ | EXIT | Left the Team |
254
+ Mode: Constitutional with an immutable Working Agreement · resolution: majority · exit: none · termination: objective
255
+
256
+ The process most software teams run today, shipped as the baseline the other
257
+ protocols can be measured against ([RESEARCH.md](RESEARCH.md), Case Study I).
258
+ Available, not the default. One session is one Sprint. Under Scrum the Product
259
+ Owner owns *what* is built and the Developers own *how*, so most decisions are a
260
+ role's call rather than a vote; the review of tabled work is where a Division
261
+ applies, and the Product Owner's acceptance is Assent. The Working Agreement
262
+ (including the Definition of Done) changes at the Retrospective, between
263
+ Sprints, so it is fixed for the Sprint. **Not modelled:** estimation
264
+ (planning poker): secret simultaneous estimates, revealed together and repeated
265
+ until they converge, are a mechanic CANON does not have.
266
+
232
267
  ---
233
268
 
234
269
  ### Competitive
@@ -288,6 +323,7 @@ not force agents to play them.
288
323
  | Elimination Tournament | All-pay elimination | Aggressive early, conservative late |
289
324
  | Peer Review | Multi-player review, information asymmetry | Honest assessment when anonymity is credible |
290
325
  | Adversarial Collaboration | Two-player, pre-committed | Honest reporting — defection contractually costly |
326
+ | Scrum / Agile | Cooperative, shared payoff, single acceptor | Consensus-seeking, slow convergence (RESEARCH.md) |
291
327
 
292
328
  ---
293
329
 
package/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  **A governed multi-agent framework built on git.**
7
7
 
8
- Pluggable governance protocols. Stateless agent workers. Git as the session substrate. Immutable Hansard. Append-only LEDGER. Human constitutional authority.
8
+ Pluggable governance protocols. Stateless agent workers. Git as the session substrate. Immutable Hansard. Append-only LEDGER. Human constitutional authority. Bring your own AI harness.
9
9
 
10
10
  ---
11
11
 
@@ -28,10 +28,12 @@ The result: agents that produce outputs nobody can fully trust, audit, or reprod
28
28
  Politik is a **governed multi-agent operating system** where:
29
29
 
30
30
  - A **human** is the constitutional authority — present but not operational
31
+ - The human governs through **whichever AI harness they already use** — Claude Code, Codex, agy, opencode — and still confirms every permanent act themselves
31
32
  - **Agents** are stateless CLI workers that spawn, do work, and dispose
32
33
  - A **git repository IS the session** — charter, record, state, and invite in one
33
34
  - **Pluggable governance protocols** translate the framework to any industry vocabulary
34
- - **A governed tree, not a single machine** — sessions nest into an Org → Team → Ticket hierarchy in one repository; `politik registry` reports the state of everything, across machines and teams
35
+ - **A governed tree** — sessions nest into an Org → Team → Ticket hierarchy in one repository; `politik registry` reports the state of every node
36
+ - **Not a single machine** — a session is shared through any git remote; people and agents on different machines act on it, every act syncs, and the Hansard never needs a manual merge
35
37
  - **No new infrastructure required** — git already built it
36
38
 
37
39
  Nobody connected these pieces this way before.
@@ -64,6 +66,52 @@ node bin/politik.js doctor
64
66
 
65
67
  ## A first session
66
68
 
69
+ **Bring your own AI harness** (ADR-0010). Create the folder, open whichever harness
70
+ you already use there, and talk to it in plain language:
71
+
72
+ ```sh
73
+ politik new q4-planning
74
+ cd q4-planning
75
+ claude # or codex, agy, opencode…
76
+ ```
77
+
78
+ The harness walks you through choosing a protocol, writing the Charter and
79
+ convening the session, then turns your requests into `politik` commands. Reading
80
+ is free; permanent acts are not. `assent`, `rule` and `prorogue` requested by a
81
+ harness or a script are **staged**, and only you can enact them, in your own
82
+ terminal:
83
+
84
+ ```sh
85
+ politik pending # what is waiting for you
86
+ politik confirm assent-3f9a2c # shows the act, asks you to type its id, then records it
87
+ politik reject assent-3f9a2c # or discard it
88
+ ```
89
+
90
+ Every commit records how it was requested (`Politik-Requested-Via: claude-code_…`)
91
+ and, for a confirmed act, that the Speaker confirmed it. The session's instruction
92
+ files are sealed at Writ Drop: if an agent rewrites them, governance stops until
93
+ they are restored.
94
+
95
+ ### Sharing a session across machines
96
+
97
+ A session can be shared through any git remote — GitHub, a NAS, anything git can
98
+ reach (ADR-0011). Several people, each with their own harness, and agents on other
99
+ machines can all act on it:
100
+
101
+ ```sh
102
+ politik remote git@github.com:acme/q4-planning.git # the Speaker shares it
103
+ politik join git@github.com:acme/q4-planning.git q4 --as ada # someone else joins
104
+ ```
105
+
106
+ Every act fetches the latest record first and pushes after; if someone else acted
107
+ in between, Politik recomputes the act on top of theirs, so the Hansard never needs a
108
+ manual merge. Offline, governance refuses and reads still work. Acts staged for the
109
+ Speaker are shared too, and only the seat an act names can confirm it. For proof
110
+ rather than names, set `signed_confirmations: required` in the Charter and each
111
+ confirmed act is signed with the confirming person's git key.
112
+
113
+ ### By hand, or from a script
114
+
67
115
  Every command below is a git commit. `git log` in the session directory is the
68
116
  Hansard — the immutable record.
69
117
 
@@ -77,6 +125,11 @@ politik division tally --dir ./session --motion adopt-standard #
77
125
  politik assent --dir ./session --motion adopt-standard --actor you --role AUTHORITY
78
126
  ```
79
127
 
128
+ Run at your own terminal, `assent` asks you to type `assent` to confirm. For a
129
+ fully scripted session (CI, tests), scaffold with `--speaker-confirmation off` —
130
+ the setting lives in the Charter, which is sealed at Writ Drop, so it cannot be
131
+ switched off later.
132
+
80
133
  Seat a real agent to do the work instead of a human vote:
81
134
 
82
135
  ```sh
@@ -85,7 +138,12 @@ politik run --dir ./session --agent claude-code --actor ada --role OPERATOR \
85
138
  ```
86
139
 
87
140
  The agent's turn is captured, its cost measured, and the result recorded — see
88
- `politik ledger --dir ./session`.
141
+ `politik ledger --dir ./session`. An agent may also act through the CLI during its
142
+ turn — review a Motion and cast its own vote — and those acts stay on the record,
143
+ noted on the turn's entry. Editing `HANSARD.md` or `STATE.json` by hand is not
144
+ acting: it is recorded as a Standing Orders violation and the record is restored.
145
+ A harness that sandboxes its own shell (agy) is granted, for that turn only, write
146
+ access to the session's `.git` and read access to the `politik` CLI — nothing else.
89
147
 
90
148
  ---
91
149
 
@@ -120,7 +178,7 @@ and correct on git alone. *Run local, run free.*
120
178
  | PR Review | Division (vote) |
121
179
  | Issue | Escalation |
122
180
  | GitHub Actions | Clerk automation |
123
- | Repo access | Taking a Seat |
181
+ | Repo access | Taking a Seat (`politik join --as <handle>`) |
124
182
  | git history | Hansard (immutable record) |
125
183
 
126
184
  ### The Politik Tree
@@ -146,9 +204,11 @@ Broadcast received → Agent spawned → Prompt executed → Result committed to
146
204
 
147
205
  The Speaker (human) is constitutionally present, not operationally present. Drops the Writ, defines Standing Orders, rules on escalations. The session governs itself.
148
206
 
207
+ The Speaker works through **their own AI harness**, opened in the session folder, in plain language. The harness reads freely and drafts freely, but the constitutional acts — assent, rulings, prorogation — are staged for the Speaker, who enacts them by typing the act's id at a real terminal. Every commit records who asked and how (ADR-0010). In a shared session, only the seat an act names can confirm it (ADR-0011).
208
+
149
209
  ### Governance Protocols
150
210
 
151
- **Eleven reference protocols ship** — Parliamentary, Republic, Monarchy, Socialism (political archetypes), Jury Deliberation, Elimination Tournament, Emergency Response (ICS), Corporate, Peer Review, Adversarial Collaboration, and Solo (single-lead) — spanning constitutional, authoritarian and darwinist modes. Each is a vocabulary translation **plus** a composition of behavioral mechanics — how a decision resolves (majority · supermajority · unanimity), how an actor exits (voted out · elimination · none), and when a session ends (objective · last-standing · verdict) — on top of CANON. You compose your own for anything else; the framework is the product, these are exemplars. Parliamentary is protocol #1, not a privileged mode. Each protocol's vocabulary and mechanics are documented in [PROTOCOLS.md](PROTOCOLS.md).
211
+ **Twelve reference protocols ship** — Parliamentary, Republic, Monarchy, Socialism (political archetypes), Jury Deliberation, Elimination Tournament, Emergency Response (ICS), Corporate, Scrum / Agile, Peer Review, Adversarial Collaboration, and Solo (single-lead) — spanning constitutional, authoritarian and darwinist modes. Each is a vocabulary translation **plus** a composition of behavioral mechanics — how a decision resolves (majority · supermajority · unanimity), how an actor exits (voted out · elimination · none), and when a session ends (objective · last-standing · verdict) — on top of CANON. You compose your own for anything else; the framework is the product, these are exemplars. Parliamentary is protocol #1, not a privileged mode, and stays the default. **Scrum / Agile** ships as the baseline the others are measured against — the process most software teams already run, available with `--protocol scrum`: the Product Owner accepts, Developers table work and review it in a Sprint Review, and the Working Agreement is fixed for the Sprint. Each protocol's vocabulary and mechanics are documented in [PROTOCOLS.md](PROTOCOLS.md).
152
212
 
153
213
  Competitive protocols run on the `MATCH` primitive — a real 1v1 contest that a Motion-and-vote Division cannot model. `politik pair` generates a round (Swiss, round-robin, or single-elimination), `politik match report` settles a result, and `politik standings` scores the field from the record.
154
214
 
@@ -178,7 +238,9 @@ Every protocol in Politik instantiates a formal game structure:
178
238
  | Emergency Response (ICS) | Stackelberg leader-follower | Full compliance, zero deviation |
179
239
  | Jury Deliberation | Unanimity / holdout game | Convergence to consensus, or a hung result |
180
240
  | Elimination Tournament | All-pay elimination | Aggressive early, conservative late |
241
+ | Peer Review | Multi-player review, information asymmetry | Honest assessment when anonymity is credible |
181
242
  | Adversarial Collaboration | Two-player, pre-committed | Maximum honest disclosure |
243
+ | Scrum / Agile | Cooperative, shared payoff, single acceptor | Consensus-seeking, slow convergence |
182
244
 
183
245
  **The research question** (not yet a built feature — see [RESEARCH.md](RESEARCH.md)): do AI agents converge on Nash Equilibrium predictions when governed by protocols that formally instantiate known game structures? If yes — protocol selection becomes a mechanism design problem. If no — why do agents deviate? Either result is publishable.
184
246
 
package/RESEARCH.md CHANGED
@@ -91,6 +91,8 @@ Politik is the first instrument that makes this empirically testable.
91
91
 
92
92
  #### Case Study I — Agile/Scrum: The Protocol Your Audience Lives Daily
93
93
 
94
+ *Runnable baseline: `protocols/scrum.yml` ships Scrum as a Politik protocol (available, not the default), so the same task can be run under Scrum and under any other protocol and the records compared. Estimation (planning poker) is not modelled — CANON has no secret-ballot convergence mechanic.*
95
+
94
96
  The Agile Manifesto was written in 2001 by 17 people who were genuinely trying to fix software development. The values were sound. Working software over comprehensive documentation. Individuals and interactions over processes and tools. The protocol was not wrong. The humans who administered it were.
95
97
 
96
98
  Within a decade, Agile had become exactly what it was designed to replace. The ceremonies proliferated: daily standups that should have been emails, sprint planning meetings that consumed the first day of every sprint, retrospectives where nobody said what they actually thought. The process became the product.
@@ -0,0 +1,145 @@
1
+ # ADR-0010 — The Operator Interface: Bring Your Own Harness
2
+
3
+ **Attribution:** Steve Krisjanovs, Cordfuse
4
+
5
+ **Status:** Accepted — built (`src/operator.ts`, `src/pending.ts`; `politik new`, `pending` / `confirm` / `reject`, `protocol list`, `status --json`; provenance trailers; sealed instruction files).
6
+
7
+ ---
8
+
9
+ ## Context
10
+
11
+ Politik is heavy for a human to drive: about 32 top-level commands, and a first
12
+ session is seven commands repeating the same flags. The architecture says the
13
+ Speaker is *constitutionally present, not operationally present* — yet setting up
14
+ and following a session was all manual commands.
15
+
16
+ Three interfaces were considered:
17
+
18
+ 1. **An interactive shell with no AI.** Deterministic and safe, but still asks the
19
+ operator to know the vocabulary (division, tally, assent).
20
+ 2. **AI built into Politik's own interface.** Means rebuilding a harness (tool
21
+ loop, providers, streaming, context), paying per token through API keys —
22
+ providers do not let third-party apps reuse subscription logins — and owning
23
+ the prompt-injection defence alone.
24
+ 3. **The operator's existing AI harness** (Claude Code, Codex, agy, opencode, or
25
+ whatever comes next), opened in the session folder, translating plain language
26
+ into `politik` commands.
27
+
28
+ ## Decision
29
+
30
+ **The operator's entry point is their own harness, opened in the session
31
+ folder.** Politik does not choose, bundle or favour one:
32
+
33
+ ```
34
+ npm i -g @cordfuse/politik
35
+ politik new q4-planning # folder + bootstrap instructions
36
+ cd q4-planning
37
+ claude # or codex, agy, opencode…
38
+ ```
39
+
40
+ **Safety is enforced in the CLI, not in prompts.** Instructions to a model are
41
+ requests; the guarantees below hold whichever harness is used, or none.
42
+
43
+ ### 1. `politik new <dir>` — the front door
44
+
45
+ Creates the folder and writes bootstrap instructions (`AGENTS.md`, with
46
+ `CLAUDE.md` and `GEMINI.md` pointing to it). On first run the harness checks the
47
+ CLI is installed, asks the operator for protocol, quorum and seats, runs
48
+ `politik scaffold --dir .` in place, helps edit the Charter, then runs
49
+ `politik init`. Choices are deferred to the conversation; `scaffold` remains the
50
+ non-interactive path for scripts, CI and child nodes (`--parent`). There is no
51
+ template repository: a second copy of the bootstrap would drift from the CLI
52
+ that runs it.
53
+
54
+ `scaffold` replaces the bootstrap files with protocol-specific ones and now
55
+ **reports every file it overwrites** instead of replacing them silently.
56
+
57
+ ### 2. Pending acts — the Speaker's confirmation
58
+
59
+ The constitutional acts — `assent`, `rule`, `prorogue` — are gated when the
60
+ Charter sets `session.speaker_confirmation: required`. **New scaffolds default to
61
+ `required`**; a Charter without the key (every session convened before this ADR)
62
+ behaves as `off`, so no existing session changes behaviour.
63
+
64
+ Under `required`, an act is staged instead of committed when **either**:
65
+
66
+ - an AI harness is detected in the environment (`AI_AGENT`, `CLAUDECODE`,
67
+ `CODEX_*`, `AGY_*`, `OPENCODE_*`, `GEMINI_CLI`), or
68
+ - there is no terminal on stdin (a script, a pipe, a harness without a pty).
69
+
70
+ A staged act is written to `.politik/pending/<id>.json` (never committed) and the
71
+ command prints the id. Nothing reaches the record. The Speaker then runs, **in
72
+ their own terminal**:
73
+
74
+ - `politik pending` — list staged acts
75
+ - `politik confirm <id>` — shows the act and requires typing its id; only then
76
+ is it executed and committed
77
+ - `politik reject <id>` — discards it
78
+
79
+ `confirm` itself refuses to run without a terminal or under a detected harness.
80
+ A human running an act directly at a terminal with no harness is prompted inline
81
+ the same way.
82
+
83
+ Because the setting lives in the Charter, and the Charter is fingerprinted at Writ
84
+ Drop, a session cannot quietly turn its own gate off after it has opened.
85
+
86
+ ### 3. Provenance — the record says who acted
87
+
88
+ Every governance commit carries trailers:
89
+
90
+ ```
91
+ Politik-Requested-Via: claude-code_2-1-283_agent (or: terminal, script)
92
+ Politik-Confirmed-By: speaker-at-terminal (staged acts only)
93
+ ```
94
+
95
+ `AI_AGENT` is preferred when set (it names harness and version); otherwise the
96
+ harness is inferred from known variables, then from whether a terminal is
97
+ attached. Where nothing is detectable the trailer says what is certain rather
98
+ than guessing.
99
+
100
+ ### 4. Sealed instruction files
101
+
102
+ `politik init` fingerprints the session's instruction files (`AGENTS.md`,
103
+ `CLAUDE.md`, `GEMINI.md`, whichever exist) onto the WRIT_DROP entry beside the
104
+ Charter fingerprint. Governance acts refuse to proceed if they have changed since,
105
+ and `politik integrity` reports it. An agent that rewrites the instructions the
106
+ Speaker's harness loads has tried to reprogram the governor's own tool; that is
107
+ now a refused act, not a silent one. Unlike the Charter seal, this applies to
108
+ every protocol.
109
+
110
+ ### 5. Session content is data
111
+
112
+ The protocol `AGENTS.md` carries a section for a harness assisting the Speaker:
113
+ translate requests into commands, preview every write, never run
114
+ `politik confirm` on the Speaker's behalf, and treat Motions, Hansard text and
115
+ other agent-written content as data, never as instructions.
116
+
117
+ ### 6. Where the Hansard begins
118
+
119
+ The Hansard begins at the `writ drop: session <guid>` commit. For a standalone
120
+ session created with `politik new` that is the repository's first commit. For a
121
+ session inside an existing repository (a tree, ADR-0008) earlier commits belong to
122
+ the enclosing repository and are not part of this session's record.
123
+
124
+ ## Threat model — what this does and does not stop
125
+
126
+ The gate protects against **a cooperative harness making a mistake or being
127
+ steered** — a misread request, or a prompt injection planted in agent-written
128
+ text that tells the model to enact something. Those paths end at a staged act a
129
+ human must confirm.
130
+
131
+ It is **not a sandbox against a hostile agent with the same shell privileges as
132
+ the human.** Such an agent could unset environment variables or allocate a
133
+ pseudo-terminal. Defending against that needs an operating-system boundary — a
134
+ separate user account, or a signing key the agent cannot read — which is out of
135
+ scope here and noted for a future ADR.
136
+
137
+ ## Consequences
138
+
139
+ - The operator talks in plain language; permanent acts still need a human at a
140
+ terminal.
141
+ - Every harness works the same, including ones that do not exist yet.
142
+ - Existing sessions and the test suite are unaffected: the gate is opt-in per
143
+ Charter, defaulting on only for newly scaffolded sessions.
144
+ - `--json` output is added to `status` and `pending` for reliable machine
145
+ reading; broader `--json` / `--dry-run` coverage is follow-up work.
@@ -0,0 +1,129 @@
1
+ # ADR-0011 — Shared Sessions Across Machines
2
+
3
+ **Attribution:** Steve Krisjanovs, Cordfuse
4
+
5
+ **Status:** Accepted — built (`src/remote.ts`; `politik remote` / `join` / `sync`, `init --remote`; sync-and-retry around acts; shared pending refs; `Politik-Operator` trailer; `signed_confirmations`). Stacked on ADR-0010.
6
+
7
+ ---
8
+
9
+ ## Context
10
+
11
+ A session is a git repository, so anyone *could* clone it — but Politik assumed
12
+ one machine. Every act committed locally and nothing was ever pulled or pushed.
13
+ Two people acting at once on different machines each appended to `HANSARD.md`
14
+ and rewrote `STATE.json` from their own copy; their histories diverged and the
15
+ record itself became a merge conflict.
16
+
17
+ ADR-0001 covers the *nudge* between machines (git by default, NATS opt-in). It
18
+ never covered keeping the **record** consistent, and there was no way to say where
19
+ a shared session lives.
20
+
21
+ ADR-0010 made this sharper: pending acts were local files, so an act staged by a
22
+ harness on one machine was invisible to a Speaker on another.
23
+
24
+ Both shapes are in scope: several humans, each with their own harness, seated in
25
+ one session; and one Speaker with agents running elsewhere.
26
+
27
+ ## Decision
28
+
29
+ **A session can be shared through any git remote. Sharing is explicit and
30
+ opt-in; a session that never configures it behaves exactly as before.**
31
+
32
+ ### 1. Configuring and joining
33
+
34
+ - `politik remote <url>` makes a session shared: it sets the git remote, turns on
35
+ sync, and publishes the current history. `politik remote` alone shows the
36
+ configuration; `politik remote --off` stops syncing.
37
+ - `politik init --remote <url>` does the same at Writ Drop.
38
+ - `politik join <url> [dir] --as <handle>` clones a shared session, checks it is a
39
+ session with intact seals, turns on sync and records who the person is (their
40
+ seat handle, see §4). Then they open their own harness there, as in ADR-0010.
41
+
42
+ The configuration lives in the clone's git config (`politik.sync`,
43
+ `politik.remote`, `politik.branch`, `politik.handle`), not in the session's
44
+ files: it describes this machine, not the proceeding.
45
+
46
+ ### 2. Sync on every act, with a safe retry
47
+
48
+ For a shared session, every governance command runs as:
49
+
50
+ 1. **fetch** the remote and **fast-forward** to the latest record;
51
+ 2. run the act, which commits locally;
52
+ 3. **push**.
53
+
54
+ If the push is rejected because someone else acted first, the local act is
55
+ discarded (`reset --hard` to where it started), the record is fast-forwarded again,
56
+ and the act is **recomputed** against the new record — up to three attempts. This
57
+ is safe because every act is computed from the current record; redoing it is not
58
+ the same as merging it. Output from discarded attempts is withheld, so the
59
+ operator only ever sees the act that was actually recorded (the "record, then
60
+ report" rule holds across machines). Nobody hand-merges the Hansard.
61
+
62
+ **Long-running acts are not retried.** `politik run` spawns an agent; re-running it
63
+ would re-run the agent. If its push is rejected, the commit stays local and the
64
+ operator is told to run `politik sync`.
65
+
66
+ **`politik sync`** fetches, fast-forwards, pushes local commits, and refreshes
67
+ pending acts. If local and remote have genuinely diverged it attempts a rebase and,
68
+ on conflict, aborts and explains rather than guessing.
69
+
70
+ **Reads** (`status`, `hansard`, `pending`, …) fetch first when they can and quietly
71
+ fall back to the local copy when the remote is unreachable.
72
+
73
+ ### 3. Offline: governance refuses, reads keep working
74
+
75
+ If the remote cannot be reached, governance acts on a shared session **refuse**.
76
+ Acting offline and pushing later lets acts land out of order — the divergence this
77
+ ADR exists to prevent. Reads still work from the local copy.
78
+
79
+ ### 4. Shared pending acts and who may confirm them
80
+
81
+ For a shared session, a staged act (ADR-0010) is stored as a git ref,
82
+ `refs/politik/pending/<id>`, pointing at a commit that holds the act. These refs
83
+ are pushed and fetched with the session but are **never part of its history**:
84
+ nothing staged is the record. `politik pending` on any machine lists them;
85
+ `politik confirm` on any machine executes one; confirming or rejecting deletes the
86
+ ref everywhere.
87
+
88
+ **Only the seat the act names may confirm it.** Each clone records its person's
89
+ seat handle (`politik.handle`, set by `join --as`, falling back to git
90
+ `user.name`). `confirm` refuses unless that handle matches the act's `--actor` —
91
+ the Speaker confirms the Speaker's assent; nobody confirms it on their behalf.
92
+
93
+ This is identity by configuration, not proof: anyone can set a name. Where proof
94
+ matters, the Charter sets `session.signed_confirmations: required` (§5).
95
+
96
+ ### 5. Identity on the record
97
+
98
+ Every governance commit carries a third trailer naming the person operating that
99
+ clone:
100
+
101
+ ```
102
+ Politik-Requested-Via: claude-code_2-1-283_agent
103
+ Politik-Confirmed-By: speaker-at-terminal
104
+ Politik-Operator: steve <steve@example.com>
105
+ ```
106
+
107
+ Under `session.signed_confirmations: required`, a confirmed act's commit is
108
+ GPG/SSH-signed with the confirming person's git signing key, and confirmation
109
+ refuses if signing fails. `politik integrity` reports any confirmed commit whose
110
+ signature does not verify.
111
+
112
+ ## Threat model
113
+
114
+ Sync makes the record consistent across machines; it does not make every machine
115
+ trustworthy. Who can act at all is who can push to the remote — Politik's existing
116
+ model ("repo access = taking a seat"), enforced by the host (branch protection,
117
+ access control). The handle check stops honest mistakes and casual impersonation;
118
+ signed confirmations stop forgery by anyone without the confirming person's key.
119
+ ADR-0010's limits still apply on each machine.
120
+
121
+ ## Consequences
122
+
123
+ - Several people and their agents can share one session from different machines,
124
+ each through their own harness.
125
+ - The record never needs a manual merge in normal use.
126
+ - A shared session needs the remote to be reachable to act.
127
+ - Retried acts that project to an SCM provider (ADR-0004) may attempt the
128
+ projection again; projection is recorded either way, so a duplicate attempt is
129
+ visible rather than silent.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cordfuse/politik",
3
- "version": "0.3.1",
3
+ "version": "0.5.0",
4
4
  "description": "Politik — a governed multi-agent framework built on git. The SCM repository is the session: charter, record, state, and invite in one.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -0,0 +1,87 @@
1
+ # Scrum / Agile — Constitutional protocol. The process most software teams run
2
+ # today, shipped so Politik can be compared against it on the same task
3
+ # (RESEARCH.md, Case Study I). Available, not the default: parliamentary stays
4
+ # protocol #1.
5
+ #
6
+ # One session is one Sprint. Developers take Backlog Items and table the work;
7
+ # the team reviews it; the Product Owner accepts it. Under Scrum the Product
8
+ # Owner owns *what* is built and the Developers own *how*, so most decisions
9
+ # are a role's call rather than a vote. The review vote is the one place
10
+ # Politik's Division applies directly.
11
+ #
12
+ # Not modelled: estimation (planning poker). Secret simultaneous estimates,
13
+ # revealed together and repeated until they converge, are a mechanic CANON
14
+ # does not have. Per protocols/CONTRIBUTING.md that is a finding to raise, not
15
+ # something to encode here.
16
+ #
17
+ # Attribution: Steve Krisjanovs, Cordfuse
18
+ protocol:
19
+ name: scrum
20
+ version: 1.0.0
21
+
22
+ # Constitutional: impediments can be raised and ruled on, and the Product
23
+ # Owner (always human) holds the final say on acceptance.
24
+ mode: constitutional
25
+
26
+ # Distributed: per-commit attribution, as a git-native development team
27
+ # expects. Forbids merge_strategy: squash in a Charter under this protocol.
28
+ record_mode: distributed
29
+
30
+ roles:
31
+ AUTHORITY: Product Owner
32
+ # The Scrum Master serves the process, not the product: facilitates,
33
+ # removes impediments, does not decide what gets built.
34
+ DELEGATE: Scrum Master
35
+ OPERATOR: Developer
36
+ # Scrum has three roles. MEMBER covers anyone on the team who contributes
37
+ # without carrying a Developer seat.
38
+ MEMBER: Team Member
39
+ OBSERVER: Stakeholder
40
+
41
+ primitives:
42
+ SESSION: Sprint
43
+ PROCEEDING: Release
44
+ CHARTER: Working Agreement
45
+ RECORD: Sprint Log
46
+ MOTION: Backlog Item
47
+ DIVISION: Sprint Review
48
+ ESCALATION: Impediment
49
+ SUSPENSION: Blocked
50
+ QUORUM: Quorum
51
+ CONFLICT: Merge Conflict
52
+ DEADLOCK: No Consensus
53
+
54
+ # Verbs
55
+ ASSENT: Accepted as Done
56
+ VOTE: Review
57
+ ESCALATE: Raise an Impediment
58
+ SUSPEND: Pause the Sprint
59
+ EXPEL: Removed from the Team
60
+ VETO: Rejected by the Product Owner
61
+ SPAWN: Split the Story
62
+ DISSOLVE: Sprint Ends
63
+ EXIT: Left the Team
64
+
65
+ # AUTHORITY already holds VETO; nobody else has a domain veto in Scrum.
66
+ domain_veto: []
67
+
68
+ # Impediments are raised and resolved; that is the Scrum Master's job.
69
+ no_escalation: false
70
+
71
+ # The Sprint Log is kept.
72
+ no_record: false
73
+
74
+ # The Working Agreement (including the Definition of Done) changes at the
75
+ # Retrospective, between Sprints, not during one. This flag usually travels
76
+ # with mode: immutable; it is set here on purpose, because Scrum is otherwise
77
+ # constitutional.
78
+ immutable_charter: true
79
+
80
+ mechanics:
81
+ # A peer review needs agreement, not unanimity; a Charter can raise this to
82
+ # unanimity for a team that works by full consensus.
83
+ resolution: majority
84
+ # Nobody is voted off a Scrum team.
85
+ exit: none
86
+ # The Sprint ends when its goal is met.
87
+ termination: objective
package/src/agents.ts CHANGED
@@ -54,9 +54,24 @@ export interface AgentSpec {
54
54
  * Without these the LEDGER can record elapsed time but not tokens or cost.
55
55
  */
56
56
  readonly json_args?: readonly string[];
57
+ /**
58
+ * Args computed per turn from the session being governed. For a harness
59
+ * that sandboxes its own shell, this is where a turn is granted exactly what
60
+ * governing the session needs — no more, and never saved to the user's
61
+ * settings.
62
+ */
63
+ readonly session_args?: (ctx: SessionContext) => readonly string[];
57
64
  readonly notes: string;
58
65
  }
59
66
 
67
+ /** What a turn's harness must be able to reach to act on the record. */
68
+ export interface SessionContext {
69
+ /** Absolute git directory of the session: acts commit here. */
70
+ readonly git_dir: string;
71
+ /** Absolute paths the `politik` CLI runs from: read-only is enough. */
72
+ readonly read_paths: readonly string[];
73
+ }
74
+
60
75
  /**
61
76
  * Agents Politik can spawn as constituencies.
62
77
  *
@@ -134,7 +149,24 @@ export const AGENTS: readonly AgentSpec[] = Object.freeze([
134
149
  auth_local: 'oauth',
135
150
  auth_headless: 'oauth',
136
151
  stdio_json: false,
137
- notes: 'Google. -p/--print for headless.',
152
+ // agy's default mode sandboxes the commands it runs: paths outside the
153
+ // workspace are invisible and .git is read-only. An agent that votes
154
+ // through `politik` from inside its turn then cannot load the CLI or
155
+ // commit the act (Scrum UAT, PR #38). `--settings` applies to this run
156
+ // only and is never saved; the grant is the session's own .git (write)
157
+ // and the CLI's install (read). The sandbox otherwise stays on.
158
+ session_args: (ctx) => [
159
+ '--settings',
160
+ JSON.stringify({
161
+ permissions: {
162
+ allow: [
163
+ `write_file(${ctx.git_dir})`,
164
+ ...ctx.read_paths.map((p) => `read_file(${p})`),
165
+ ],
166
+ },
167
+ }),
168
+ ],
169
+ notes: 'Google. -p/--print for headless. Sandboxed shell: granted the session .git per turn.',
138
170
  },
139
171
  {
140
172
  id: 'aider',