@cordfuse/politik 0.4.0 → 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.
@@ -136,7 +138,12 @@ politik run --dir ./session --agent claude-code --actor ada --role OPERATOR \
136
138
  ```
137
139
 
138
140
  The agent's turn is captured, its cost measured, and the result recorded — see
139
- `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.
140
147
 
141
148
  ---
142
149
 
@@ -171,7 +178,7 @@ and correct on git alone. *Run local, run free.*
171
178
  | PR Review | Division (vote) |
172
179
  | Issue | Escalation |
173
180
  | GitHub Actions | Clerk automation |
174
- | Repo access | Taking a Seat |
181
+ | Repo access | Taking a Seat (`politik join --as <handle>`) |
175
182
  | git history | Hansard (immutable record) |
176
183
 
177
184
  ### The Politik Tree
@@ -197,9 +204,11 @@ Broadcast received → Agent spawned → Prompt executed → Result committed to
197
204
 
198
205
  The Speaker (human) is constitutionally present, not operationally present. Drops the Writ, defines Standing Orders, rules on escalations. The session governs itself.
199
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
+
200
209
  ### Governance Protocols
201
210
 
202
- **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).
203
212
 
204
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.
205
214
 
@@ -229,7 +238,9 @@ Every protocol in Politik instantiates a formal game structure:
229
238
  | Emergency Response (ICS) | Stackelberg leader-follower | Full compliance, zero deviation |
230
239
  | Jury Deliberation | Unanimity / holdout game | Convergence to consensus, or a hung result |
231
240
  | Elimination Tournament | All-pay elimination | Aggressive early, conservative late |
241
+ | Peer Review | Multi-player review, information asymmetry | Honest assessment when anonymity is credible |
232
242
  | Adversarial Collaboration | Two-player, pre-committed | Maximum honest disclosure |
243
+ | Scrum / Agile | Cooperative, shared payoff, single acceptor | Consensus-seeking, slow convergence |
233
244
 
234
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.
235
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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cordfuse/politik",
3
- "version": "0.4.0",
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',
package/src/cli.ts CHANGED
@@ -1223,6 +1223,12 @@ const reportCommit = (result: CommitResult): void => {
1223
1223
  if (result.committed) out(` recorded ${result.sha?.slice(0, 8) ?? ''}`);
1224
1224
  else if (result.reason === 'not a git repository') {
1225
1225
  out(' [WARN] not a git repository — the record is not durable');
1226
+ } else if (result.reason === 'git add failed' || result.reason === 'commit failed') {
1227
+ // Loud, on stderr: the act was written to the working tree but git refused
1228
+ // the commit, so it is NOT on the record. Printing success here told an
1229
+ // agent in a sandbox (read-only .git) that its vote counted when it did not.
1230
+ err(` [ERROR] ${result.reason} — the act was written but NOT committed, so it is not on the record`);
1231
+ err(' Check that this process can write to .git, then repeat the act.');
1226
1232
  }
1227
1233
  };
1228
1234
 
package/src/git.ts CHANGED
@@ -80,7 +80,10 @@ export const commitRecord = async (
80
80
 
81
81
  const add = await git(dir, ['add', '--', ...present], spawnFn);
82
82
  if (add.code !== 0) {
83
- return { committed: false, sha: null, reason: 'nothing to stage' };
83
+ // Not "nothing to stage": an empty change is caught below. A failing
84
+ // `git add` means git could not write the index (a read-only .git in a
85
+ // sandboxed harness, a held index.lock) and the act is not on the record.
86
+ return { committed: false, sha: null, reason: 'git add failed' };
84
87
  }
85
88
 
86
89
  const staged = await git(dir, ['diff', '--cached', '--name-only'], spawnFn);
package/src/runner.ts CHANGED
@@ -17,8 +17,10 @@
17
17
  */
18
18
 
19
19
  import { spawn } from 'node:child_process';
20
+ import { existsSync } from 'node:fs';
20
21
  import { readFile, writeFile } from 'node:fs/promises';
21
- import { join } from 'node:path';
22
+ import { dirname, join, resolve } from 'node:path';
23
+ import { fileURLToPath } from 'node:url';
22
24
 
23
25
  import { findAgent, composePrompt, type AgentSpec } from './agents.ts';
24
26
  import type { Role, Verb } from './canon.ts';
@@ -26,7 +28,7 @@ import { parseCharter, type Charter } from './charter.ts';
26
28
  import { parseEnvelope, claimSlot, type Envelope } from './envelope.ts';
27
29
  import { standForElection, bowOut, type ElectionOptions } from './election.ts';
28
30
  import { nodeLockFs } from './lockfs.ts';
29
- import { appendEntry, type HansardEntry } from './hansard.ts';
31
+ import { appendEntry, parseEntries, type HansardEntry } from './hansard.ts';
30
32
  import { spawnAgent, type SpawnResult } from './spawn.ts';
31
33
  import {
32
34
  appendLedgerRow, parseResultText, parseUsage, type Usage,
@@ -122,7 +124,11 @@ const git = (dir: string, args: readonly string[], spawnFn: typeof spawn): Promi
122
124
  child.stdout?.on('data', (c: Buffer) => {
123
125
  output += c.toString();
124
126
  });
125
- child.on('close', () => resolve(output.trim()));
127
+ // trimEnd, not trim: `git status --porcelain` lines start with a status
128
+ // column that may be a space (" M file"). Trimming the front stripped it
129
+ // from the first line, so the first unstaged file lost its first letter
130
+ // ("ANSARD.md") and a hand edit of the record went unflagged.
131
+ child.on('close', () => resolve(output.trimEnd()));
126
132
  child.on('error', () => resolve(''));
127
133
  });
128
134
 
@@ -319,6 +325,27 @@ export const runTurn = async (options: RunOptions): Promise<RunOutcome> => {
319
325
  const beforeDirty = await dirtyFiles(options.dir, spawnFn);
320
326
 
321
327
  const measure = options.measure !== false && agent.json_args !== undefined;
328
+
329
+ // Per-turn grants for harnesses that sandbox their own shell (agents.ts
330
+ // session_args): the session's git directory, which an enclosing repo may
331
+ // own, and where this CLI runs from, so the agent can act through it.
332
+ const gitDir =
333
+ (await git(options.dir, ['rev-parse', '--absolute-git-dir'], spawnFn)) ||
334
+ join(resolve(options.dir), '.git');
335
+ const politikRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
336
+ // Where the agent will find `politik`: the directory it was invoked from and
337
+ // the one holding it on PATH (a global npm bin often lives under $HOME,
338
+ // which a sandbox hides). Read-only grants, deduplicated.
339
+ const invokedFrom = process.argv[1] === undefined ? null : dirname(resolve(process.argv[1]));
340
+ const onPath = (process.env['PATH'] ?? '')
341
+ .split(':')
342
+ .find((d) => d !== '' && existsSync(join(d, 'politik')));
343
+ const readPaths = [...new Set([politikRoot, invokedFrom, onPath === undefined ? null : resolve(onPath)])]
344
+ .filter((p): p is string => p !== null)
345
+ // A path inside the CLI's own install is already covered by politikRoot.
346
+ .filter((p) => p === politikRoot || !p.startsWith(`${politikRoot}/`));
347
+ const sessionArgs = agent.session_args?.({ git_dir: gitDir, read_paths: readPaths }) ?? [];
348
+ const turnArgs = [...(measure ? (agent.json_args ?? []) : []), ...sessionArgs];
322
349
  const sleepFn = options.sleepFn ?? ((ms: number) => new Promise((r) => setTimeout(r, ms)));
323
350
  const policy = {
324
351
  auto_retry_max: charter.fault_handling.auto_retry_max,
@@ -333,7 +360,7 @@ export const runTurn = async (options: RunOptions): Promise<RunOutcome> => {
333
360
  cwd: options.dir,
334
361
  timeout_ms: options.timeout_ms,
335
362
  spawnFn,
336
- extraArgs: measure ? agent.json_args : undefined,
363
+ extraArgs: turnArgs,
337
364
  });
338
365
 
339
366
  let attempts = 1;
@@ -363,7 +390,7 @@ export const runTurn = async (options: RunOptions): Promise<RunOutcome> => {
363
390
  cwd: options.dir,
364
391
  timeout_ms: options.timeout_ms,
365
392
  spawnFn,
366
- extraArgs: measure ? agent.json_args : undefined,
393
+ extraArgs: turnArgs,
367
394
  });
368
395
  }
369
396
 
@@ -384,8 +411,37 @@ export const runTurn = async (options: RunOptions): Promise<RunOutcome> => {
384
411
  // § File Sovereignty Rules). An actor writing to them is a Standing Orders
385
412
  // violation, and it must be recorded rather than silently tolerated —
386
413
  // a record an actor can write is not a record.
414
+ //
415
+ // An agent may also act *through the CLI* during its turn — cast a vote,
416
+ // call a Division — and those acts write and commit these same files. The
417
+ // record must keep them. So the files are read again after the turn, and a
418
+ // change to them is lawful only when it reached the record the way the CLI
419
+ // writes it: committed (nothing left dirty) and, for the Hansard, purely
420
+ // appended. Anything else is a hand edit: a violation, and the record is
421
+ // restored from the pre-turn copy rather than carrying the edit forward.
387
422
  const OWNED_BY_RECORD = ['HANSARD.md', 'STATE.json', 'LEDGER.md'];
388
- const violations = touched.filter((f) => OWNED_BY_RECORD.includes(f));
423
+ const dirtyAfter = await dirtyFiles(options.dir, spawnFn);
424
+ const hansardAfter = (await readIf(join(options.dir, 'HANSARD.md'))) ?? '';
425
+ const hansardAppended =
426
+ hansardAfter.startsWith(hansard) && !dirtyAfter.includes('HANSARD.md');
427
+ const violations = touched.filter(
428
+ (f) =>
429
+ OWNED_BY_RECORD.includes(f) &&
430
+ (dirtyAfter.includes(f) || (f === 'HANSARD.md' && !hansardAppended)),
431
+ );
432
+ // Entries the CLI appended during the turn — votes, Divisions — kept as
433
+ // the base the turn's own entry is appended to.
434
+ const recordBase = hansardAppended ? hansardAfter : hansard;
435
+ const actsDuringTurn = hansardAppended
436
+ ? parseEntries(hansardAfter).length - parseEntries(hansard).length
437
+ : 0;
438
+ // The same rule for STATE.json: a committed CLI act may have moved it (a
439
+ // tally that deadlocks suspends the sitting), and the turn must not undo it.
440
+ const stateAfterRaw = dirtyAfter.includes('STATE.json')
441
+ ? null
442
+ : await readIf(join(options.dir, 'STATE.json'));
443
+ const stateBase =
444
+ (stateAfterRaw === null ? null : parseState(stateAfterRaw)) ?? state;
389
445
 
390
446
  // An agent that hits a decision above its authority is told (composePrompt,
391
447
  // Rules of the Floor) to file a Point of Order instead of proceeding. On a
@@ -424,6 +480,9 @@ export const runTurn = async (options: RunOptions): Promise<RunOutcome> => {
424
480
  : `exit ${String(result.exit_code)}`,
425
481
  'Elapsed ms': String(result.elapsed_ms),
426
482
  'Files touched': touched.length > 0 ? touched.join(', ') : 'none',
483
+ ...(actsDuringTurn > 0
484
+ ? { 'Acts during turn': `${String(actsDuringTurn)} recorded through the CLI` }
485
+ : {}),
427
486
  ...(violations.length > 0
428
487
  ? {
429
488
  'Standing Orders violation': `actor wrote to ${violations.join(', ')} — owned by RECORD`,
@@ -447,7 +506,7 @@ export const runTurn = async (options: RunOptions): Promise<RunOutcome> => {
447
506
 
448
507
  // Faults are recorded before the turn's own entry: they happened first, and
449
508
  // a reader should see the retries that led to the outcome.
450
- let record = hansard;
509
+ let record = recordBase;
451
510
  for (const fault of faultEntries) record = appendEntry(record, fault);
452
511
  record = appendEntry(record, entry);
453
512
 
@@ -495,10 +554,12 @@ export const runTurn = async (options: RunOptions): Promise<RunOutcome> => {
495
554
  // POINT_OF_ORDER cause. A breach names no escalation file; an agent's Point
496
555
  // of Order does, so its path is recorded as the escalation reference.
497
556
  const suspend = !containment.contained || agentEscalated;
557
+ // Built on the post-turn state, so a suspension or quorum change an act
558
+ // made during the turn survives; the turn only adds its own suspension.
498
559
  const nextState = createState({
499
- session_guid: state.session_guid,
500
- protocol: state.protocol,
501
- state: suspend ? 'SUSPENDED' : 'CONVENED',
560
+ session_guid: stateBase.session_guid,
561
+ protocol: stateBase.protocol,
562
+ state: suspend ? 'SUSPENDED' : stateBase.state,
502
563
  ...(suspend
503
564
  ? {
504
565
  suspension: {
@@ -508,9 +569,11 @@ export const runTurn = async (options: RunOptions): Promise<RunOutcome> => {
508
569
  escalation_ref: agentEscalated ? (escalationFiles[0] ?? null) : null,
509
570
  },
510
571
  }
511
- : {}),
512
- quorum: state.quorum,
513
- hansard_head: state.hansard_head,
572
+ : stateBase.suspension !== null
573
+ ? { suspension: stateBase.suspension }
574
+ : {}),
575
+ quorum: stateBase.quorum,
576
+ hansard_head: stateBase.hansard_head,
514
577
  updated_at: options.now,
515
578
  });
516
579
  await writeFile(join(options.dir, 'STATE.json'), serializeState(nextState), 'utf8');
@@ -542,7 +542,8 @@ them through first-time setup as a conversation.
542
542
  install it (\`npm i -g @cordfuse/politik\`) and stop until they have.
543
543
  2. **Ask, in plain language:** what is this session for; which protocol fits
544
544
  (\`politik protocol list\` shows them; \`parliamentary\` is the default, \`solo\` suits one
545
- person); how many votes carry a decision (quorum); who is seated.
545
+ person, \`scrum\` mirrors how a software team already works); how many votes
546
+ carry a decision (quorum); who is seated.
546
547
  3. **Scaffold in place:** \`politik scaffold --dir . --protocol <p> --quorum <n>\`.
547
548
  This replaces this file with the protocol's own guide; it lists what it
548
549
  replaced.