@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/src/init.ts ADDED
@@ -0,0 +1,396 @@
1
+ /**
2
+ * Session repo initializer — the Writ Drop.
3
+ *
4
+ * The Speaker drops the Writ; this module produces the initial file set that
5
+ * makes a git repository a Politik session. It is pure: it returns files to be
6
+ * written, and performs no I/O itself. The caller commits them through an
7
+ * ScmProvider, so the same initializer serves GitHub, a local scratch repo, or
8
+ * a test.
9
+ *
10
+ * Layout follows POLITIK-ARCHITECTURE.md § SESSION REPO STRUCTURE. Validation
11
+ * is ADR-0002's Writ Drop rules, delegated to the charter module: a Charter
12
+ * that fails opens nothing, and yields an INVALID state file recording why.
13
+ *
14
+ * Attribution: Steve Krisjanovs, Cordfuse
15
+ */
16
+
17
+ import {
18
+ validateCharter,
19
+ parseCharter,
20
+ type Charter,
21
+ type CharterIssue,
22
+ type ProtocolContext,
23
+ } from './charter.ts';
24
+ import { RECORD_TYPES, appendEntry } from './hansard.ts';
25
+ import { LEDGER_HEADER } from './ledger.ts';
26
+ import type { FileWrite } from './scm.ts';
27
+ import { createState, serializeState, type SessionStateFile } from './state.ts';
28
+
29
+ /* -------------------------------------------------------------------------- */
30
+ /* Inputs and results */
31
+ /* -------------------------------------------------------------------------- */
32
+
33
+ export interface WritDropInput {
34
+ /** Raw CHARTER.md source, as authored by the Speaker. */
35
+ readonly charter_source: string;
36
+ /** Stable session identifier. Supplied by the caller — this module is pure. */
37
+ readonly session_guid: string;
38
+ /** ISO-8601 UTC timestamp for the Writ. Supplied by the caller. */
39
+ readonly now: string;
40
+ /** Human handle of the AUTHORITY dropping the Writ. */
41
+ readonly speaker: string;
42
+ /** Resolved protocol, when available. Enables ADR-0002 rules 2 and 5. */
43
+ readonly protocol?: ProtocolContext;
44
+ }
45
+
46
+ export type WritDropResult =
47
+ | {
48
+ readonly ok: true;
49
+ readonly charter: Charter;
50
+ readonly state: SessionStateFile;
51
+ readonly files: readonly FileWrite[];
52
+ }
53
+ | {
54
+ readonly ok: false;
55
+ readonly issues: readonly CharterIssue[];
56
+ /** INVALID state file — committed so the failure is on the record. */
57
+ readonly state: SessionStateFile;
58
+ readonly files: readonly FileWrite[];
59
+ };
60
+
61
+ /* -------------------------------------------------------------------------- */
62
+ /* Templates */
63
+ /* -------------------------------------------------------------------------- */
64
+
65
+ const writ = (input: WritDropInput, charter: Charter | null, guid: string): string => {
66
+ const lines = [
67
+ '# WRIT',
68
+ '',
69
+ 'Session identity and Writ Drop record.',
70
+ '',
71
+ `- **Session GUID:** ${guid}`,
72
+ `- **Protocol:** ${charter?.protocol ?? 'unresolved'}`,
73
+ `- **Dropped by:** ${input.speaker} (AUTHORITY)`,
74
+ `- **Dropped at:** ${input.now}`,
75
+ `- **Inherits from:** ${charter?.inherits_from ?? 'none (root node)'}`,
76
+ '',
77
+ ];
78
+ return `${lines.join('\n')}\n`;
79
+ };
80
+
81
+ const HANSARD_PREAMBLE = [
82
+ '# HANSARD',
83
+ '',
84
+ 'Append-only attributed record of this proceeding. The RECORD agent writes;',
85
+ 'no actor edits an entry once committed.',
86
+ '',
87
+ '---',
88
+ '',
89
+ ].join('\n');
90
+
91
+ const hansard = (input: WritDropInput, guid: string): string =>
92
+ appendEntry(HANSARD_PREAMBLE, {
93
+ type: RECORD_TYPES.WRIT_DROP,
94
+ at: input.now,
95
+ actor: input.speaker,
96
+ role: 'AUTHORITY',
97
+ body: `Writ dropped. Session ${guid} convened under the attached Charter.`,
98
+ });
99
+
100
+ const invalidHansard = (
101
+ input: WritDropInput,
102
+ guid: string,
103
+ issues: readonly CharterIssue[],
104
+ ): string =>
105
+ appendEntry(HANSARD_PREAMBLE, {
106
+ type: RECORD_TYPES.SESSION_INVALID,
107
+ at: input.now,
108
+ actor: input.speaker,
109
+ role: 'AUTHORITY',
110
+ body: [
111
+ `Writ Drop failed validation. Session ${guid} never opened.`,
112
+ '',
113
+ ...issues.map(
114
+ (i) =>
115
+ `- \`${i.field}\` — ${i.message}${i.rule === undefined ? '' : ` (ADR-0002 rule ${i.rule})`}`,
116
+ ),
117
+ ].join('\n'),
118
+ });
119
+
120
+ const ledger = (charter: Charter): string =>
121
+ [
122
+ '# LEDGER',
123
+ '',
124
+ 'Secretarial cost and token ledger for this proceeding.',
125
+ '',
126
+ `- **Visibility:** ${charter.ledger.visibility}`,
127
+ `- **Cost ceiling:** ${charter.session.endurance.max_cost_usd ?? 'none declared'}`,
128
+ `- **Motion ceiling:** ${charter.session.endurance.max_motions ?? 'none declared'}`,
129
+ '',
130
+ LEDGER_HEADER,
131
+ '',
132
+ ].join('\n') + '\n';
133
+
134
+ /** Placeholder so the directory exists in git, which tracks files not dirs. */
135
+ const keep = (purpose: string): string => `${purpose}\n`;
136
+
137
+ /**
138
+ * Speaker notification workflow, per RUNTIME.md § Point of Order Workflow.
139
+ *
140
+ * Written into the session repo — this is the Clerk automation the escalation
141
+ * flow depends on: a push under `escalations/` emails the Speaker and tells
142
+ * them where to commit their ruling.
143
+ *
144
+ * The path filter deliberately excludes rulings. A ruling is the Speaker's
145
+ * answer; notifying them of their own reply would loop.
146
+ *
147
+ * Requires three repository secrets. Absent them the workflow fails loudly
148
+ * rather than silently dropping the notification — an escalation nobody hears
149
+ * is the failure mode this whole flow exists to prevent.
150
+ */
151
+ const pointOfOrderWorkflow = (): string =>
152
+ `name: Point of Order — Speaker Notification
153
+
154
+ # Requires repository secrets: MAIL_USERNAME, MAIL_PASSWORD, SPEAKER_EMAIL
155
+ # See RUNTIME.md § POINT OF ORDER — ESCALATION FLOW
156
+
157
+ on:
158
+ push:
159
+ paths:
160
+ - 'escalations/[0-9]*.md'
161
+
162
+ jobs:
163
+ notify-speaker:
164
+ runs-on: ubuntu-latest
165
+ steps:
166
+ - uses: actions/checkout@v4
167
+
168
+ - name: Read escalation
169
+ id: esc
170
+ run: |
171
+ FILE=$(ls escalations/[0-9]*.md | grep -v ruling | tail -1)
172
+ echo "path=\${FILE}" >> "$GITHUB_OUTPUT"
173
+ {
174
+ echo "content<<POLITIK_EOF"
175
+ cat "\${FILE}"
176
+ echo "POLITIK_EOF"
177
+ } >> "$GITHUB_OUTPUT"
178
+
179
+ - name: Email Speaker
180
+ uses: dawidd6/action-send-mail@v3
181
+ with:
182
+ server_address: smtp.gmail.com
183
+ server_port: 465
184
+ username: \${{ secrets.MAIL_USERNAME }}
185
+ password: \${{ secrets.MAIL_PASSWORD }}
186
+ to: \${{ secrets.SPEAKER_EMAIL }}
187
+ from: Politik Clerk
188
+ subject: "Point of Order — \${{ github.repository }}"
189
+ body: |
190
+ A Point of Order has been raised.
191
+
192
+ \${{ steps.esc.outputs.content }}
193
+
194
+ Escalation: \${{ steps.esc.outputs.path }}
195
+ Session: \${{ github.server_url }}/\${{ github.repository }}
196
+
197
+ Commit your ruling to: escalations/ruling-[n].md
198
+ Session is suspended pending your response.
199
+ `;
200
+
201
+
202
+ /**
203
+ * Heartbeat workflow — scheduled staleness detection.
204
+ *
205
+ * RUNTIME.md § Session Heartbeat: an hourly job checks the last Hansard commit
206
+ * and suspends the proceeding if nothing has happened within
207
+ * `heartbeat_timeout_hours`.
208
+ *
209
+ * Runs `politik` via npx rather than assuming an install: a GitHub runner is a
210
+ * fresh machine, and a session repo carries no toolchain of its own.
211
+ *
212
+ * Writes back to the repo when it suspends, which is why it needs
213
+ * `contents: write` — a heartbeat that could detect staleness but not record it
214
+ * would be a monitor, not a mechanism.
215
+ */
216
+ const heartbeatWorkflow = (): string =>
217
+ `name: Heartbeat — staleness detection
218
+
219
+ # NOTE — these jobs run \`npx --yes @cordfuse/politik\`, which requires the
220
+ # package to be published to npm. Until it is, they will fail on the runner.
221
+ # The governance they automate all works from the CLI in the meantime:
222
+ # staleness -> politik heartbeat --suspend
223
+ # rulings -> politik rule
224
+
225
+ # A proceeding that goes quiet is not the same as one that was paused. This job
226
+ # marks it STALE, which is resumable and loses nothing (\`politik resume\`).
227
+
228
+ on:
229
+ schedule:
230
+ - cron: '0 * * * *' # hourly, per RUNTIME.md § Session Heartbeat
231
+ workflow_dispatch:
232
+
233
+ permissions:
234
+ contents: write
235
+
236
+ jobs:
237
+ heartbeat:
238
+ runs-on: ubuntu-latest
239
+ steps:
240
+ - uses: actions/checkout@v4
241
+ with:
242
+ fetch-depth: 0 # the heartbeat is the last Hansard commit
243
+
244
+ - uses: actions/setup-node@v4
245
+ with:
246
+ node-version: '22'
247
+
248
+ - name: Check the heartbeat
249
+ id: beat
250
+ run: npx --yes @cordfuse/politik heartbeat --dir . --suspend || true
251
+
252
+ - name: Commit a suspension, if one was recorded
253
+ run: |
254
+ if [ -n "$(git status --porcelain HANSARD.md STATE.json)" ]; then
255
+ git config user.name 'Politik Clerk'
256
+ git config user.email 'clerk@politik.local'
257
+ git add HANSARD.md STATE.json
258
+ git commit -m 'SESSION_STALE — heartbeat window elapsed'
259
+ git push
260
+ else
261
+ echo 'still beating; nothing to record'
262
+ fi
263
+ `;
264
+
265
+ /**
266
+ * Ruling workflow — resume on a committed ruling.
267
+ *
268
+ * RUNTIME.md § Point of Order: "GitHub Actions detects ruling commit → session
269
+ * resumes". A Speaker who commits \`escalations/ruling-NNN.md\` directly, rather
270
+ * than through the CLI, should not also have to remember to resume the sitting.
271
+ *
272
+ * The path filter matches only rulings. Matching the whole \`escalations/\`
273
+ * directory would fire on the escalation that caused the suspension and resume
274
+ * a session nobody had ruled on.
275
+ */
276
+ const rulingWorkflow = (): string =>
277
+ `name: Ruling — resume the sitting
278
+
279
+ # NOTE — these jobs run \`npx --yes @cordfuse/politik\`, which requires the
280
+ # package to be published to npm. Until it is, they will fail on the runner.
281
+ # The governance they automate all works from the CLI in the meantime:
282
+ # staleness -> politik heartbeat --suspend
283
+ # rulings -> politik rule
284
+
285
+ on:
286
+ push:
287
+ paths:
288
+ - 'escalations/ruling-*.md'
289
+
290
+ permissions:
291
+ contents: write
292
+
293
+ jobs:
294
+ resume:
295
+ runs-on: ubuntu-latest
296
+ steps:
297
+ - uses: actions/checkout@v4
298
+
299
+ - uses: actions/setup-node@v4
300
+ with:
301
+ node-version: '22'
302
+
303
+ - name: Resume, if the session is suspended for a Point of Order
304
+ run: |
305
+ STATE=$(node -e "console.log(JSON.parse(require('fs').readFileSync('STATE.json','utf8')).state)")
306
+ CAUSE=$(node -e "const s=JSON.parse(require('fs').readFileSync('STATE.json','utf8'));console.log(s.suspension?.cause ?? '')")
307
+
308
+ # Only a Point of Order resumes this way. A constitutional crisis
309
+ # requires external review, and a Speaker order is the Speaker's to
310
+ # lift — resuming around either would route past the governance that
311
+ # stopped the session.
312
+ if [ "$STATE" = "SUSPENDED" ] && [ "$CAUSE" = "POINT_OF_ORDER" ]; then
313
+ npx --yes @cordfuse/politik rule \\
314
+ --dir . --actor "$GITHUB_ACTOR" --role AUTHORITY \\
315
+ --outcome NOTED \\
316
+ --body "Ruling committed to the repository. Recorded by the Clerk workflow."
317
+
318
+ git config user.name 'Politik Clerk'
319
+ git config user.email 'clerk@politik.local'
320
+ git add HANSARD.md STATE.json escalations/
321
+ git commit -m 'RULING — sitting resumes' || true
322
+ git push
323
+ else
324
+ echo "state=$STATE cause=$CAUSE — nothing to resume"
325
+ fi
326
+ `;
327
+
328
+ /* -------------------------------------------------------------------------- */
329
+ /* Writ Drop */
330
+ /* -------------------------------------------------------------------------- */
331
+
332
+ /**
333
+ * Execute the Writ Drop.
334
+ *
335
+ * On pass: the full session file set with `STATE.json.state = CONVENED`
336
+ * (ADR-0002 rule 8). On failure: an INVALID state file plus a Hansard entry
337
+ * naming every violated rule, so the refusal is itself on the record.
338
+ */
339
+ export const dropWrit = (input: WritDropInput): WritDropResult => {
340
+ const parsed = parseCharter(input.charter_source);
341
+
342
+ const invalid = (issues: readonly CharterIssue[], charter: Charter | null): WritDropResult => {
343
+ const state = createState({
344
+ session_guid: input.session_guid,
345
+ protocol: charter?.protocol ?? '',
346
+ state: 'INVALID',
347
+ quorum: { required: charter?.session.quorum ?? 0, present: 0 },
348
+ updated_at: input.now,
349
+ });
350
+ return {
351
+ ok: false,
352
+ issues,
353
+ state,
354
+ files: [
355
+ { path: 'CHARTER.md', content: input.charter_source },
356
+ { path: 'STATE.json', content: serializeState(state) },
357
+ { path: 'HANSARD.md', content: invalidHansard(input, input.session_guid, issues) },
358
+ { path: 'WRIT.md', content: writ(input, charter, input.session_guid) },
359
+ ],
360
+ };
361
+ };
362
+
363
+ if (!parsed.ok) return invalid(parsed.issues, null);
364
+
365
+ const charter = parsed.charter;
366
+ const validation = validateCharter(charter, input.protocol);
367
+ if (!validation.valid) return invalid(validation.issues, charter);
368
+
369
+ const state = createState({
370
+ session_guid: input.session_guid,
371
+ protocol: charter.protocol,
372
+ state: 'CONVENED',
373
+ quorum: { required: charter.session.quorum, present: 0 },
374
+ updated_at: input.now,
375
+ });
376
+
377
+ const files: FileWrite[] = [
378
+ { path: 'CHARTER.md', content: input.charter_source },
379
+ { path: 'STATE.json', content: serializeState(state) },
380
+ { path: 'HANSARD.md', content: hansard(input, input.session_guid) },
381
+ { path: 'WRIT.md', content: writ(input, charter, input.session_guid) },
382
+ { path: 'roles/.gitkeep', content: keep('Role capability definitions.') },
383
+ { path: 'actors/.gitkeep', content: keep('Actor profiles — who plays each role.') },
384
+ { path: 'motions/.gitkeep', content: keep('Tabled business.') },
385
+ { path: 'escalations/.gitkeep', content: keep('Points of Order and rulings.') },
386
+ { path: '.github/workflows/point-of-order.yml', content: pointOfOrderWorkflow() },
387
+ { path: '.github/workflows/heartbeat.yml', content: heartbeatWorkflow() },
388
+ { path: '.github/workflows/ruling.yml', content: rulingWorkflow() },
389
+ ];
390
+
391
+ if (charter.ledger.enabled) {
392
+ files.push({ path: charter.ledger.path, content: ledger(charter) });
393
+ }
394
+
395
+ return { ok: true, charter, state, files };
396
+ };
@@ -0,0 +1,153 @@
1
+ /**
2
+ * Integrity — the bad-faith detector.
3
+ *
4
+ * Skills are capability, declared before seating (`capability.ts`). Virtues and
5
+ * vices are not capability: they appear only in behaviour, over time. So this
6
+ * module does not read a profile — it reads the immutable Hansard for the vice
7
+ * signatures RUNTIME.md § The Voluntold Problem spells out, and surfaces them to
8
+ * the Speaker. It **detects and reports; it never punishes** — "the audit trail
9
+ * is the deterrent". The one case it cannot catch is a bad-faith Speaker, and
10
+ * nothing can, except the record being visible to everyone who can read the repo.
11
+ *
12
+ * Pure by construction: a function of the record and nothing else, so the same
13
+ * Hansard always yields the same findings — the property auditability depends on.
14
+ *
15
+ * Attribution: Steve Krisjanovs, Cordfuse
16
+ */
17
+
18
+ import type { Role } from './canon.ts';
19
+ import { parseEntries } from './hansard.ts';
20
+
21
+ export type FindingKind = 'vice' | 'virtue';
22
+ export type Severity = 'high' | 'medium' | 'low' | 'praise';
23
+
24
+ export interface IntegrityFinding {
25
+ readonly kind: FindingKind;
26
+ /** Stable slug for the pattern, e.g. 'coerced-exit', 'serial-voluntold'. */
27
+ readonly signature: string;
28
+ readonly severity: Severity;
29
+ /** Actors named in the finding — the subject first, then any implicated. */
30
+ readonly actors: readonly string[];
31
+ /** Human-readable statement of the pattern, citing the record. */
32
+ readonly evidence: string;
33
+ }
34
+
35
+ /**
36
+ * Review a session's Hansard for bad-faith (and good-faith) patterns.
37
+ *
38
+ * v1 — single session (docs/plans/virtues-and-vices.md):
39
+ * - coerced-exit (vice, high) — an EXIT_VOLUNTARY_COERCED: a voluntold.
40
+ * - strategic-withdrawal (vice, medium) — a strategic exit while a Division is open.
41
+ * - serial-voluntold (vice, high) — one OPERATOR seated for two+ voluntary exits.
42
+ * - honest-concession (virtue) — a reasoned EXIT_VOLUNTARY_CONCESSION.
43
+ */
44
+ export const reviewIntegrity = (hansard: string): readonly IntegrityFinding[] => {
45
+ const entries = parseEntries(hansard);
46
+ const findings: IntegrityFinding[] = [];
47
+
48
+ // Replayed session state, in record order.
49
+ const openDivisions = new Set<string>();
50
+ const seated = new Map<string, Role>();
51
+ // OPERATOR -> the actors whose voluntary exits they were seated for.
52
+ const voluntaryUnder = new Map<string, string[]>();
53
+
54
+ for (const entry of entries) {
55
+ const f = entry.fields;
56
+ switch (entry.type) {
57
+ case 'DIVISION_CALLED': {
58
+ const motion = f['Motion'];
59
+ if (motion !== undefined) openDivisions.add(motion);
60
+ break;
61
+ }
62
+ case 'MOTION_CARRIED':
63
+ case 'MOTION_REJECTED': {
64
+ const motion = f['Motion'];
65
+ if (motion !== undefined) openDivisions.delete(motion);
66
+ break;
67
+ }
68
+ case 'ACTOR_HIRED': {
69
+ const who = f['Actor affected'];
70
+ const role = f['Role'];
71
+ if (who !== undefined && role !== undefined) seated.set(who, role as Role);
72
+ break;
73
+ }
74
+ case 'ACTOR_PROMOTED':
75
+ case 'ACTOR_DEMOTED': {
76
+ const who = f['Actor affected'];
77
+ const to = f['To'];
78
+ if (who !== undefined && to !== undefined && seated.has(who)) seated.set(who, to as Role);
79
+ break;
80
+ }
81
+ case 'ACTOR_EXITED': {
82
+ const subject = f['Actor affected'] ?? entry.actor;
83
+ const exitType = f['Exit type'] ?? '';
84
+ const reason = (f['Reason'] ?? '').trim();
85
+ const duringDivision = openDivisions.size > 0;
86
+ const operatorsPresent = [...seated.entries()]
87
+ .filter(([who, role]) => role === 'OPERATOR' && who !== subject)
88
+ .map(([who]) => who);
89
+
90
+ if (exitType === 'EXIT_VOLUNTARY_COERCED') {
91
+ findings.push({
92
+ kind: 'vice',
93
+ signature: 'coerced-exit',
94
+ severity: 'high',
95
+ actors: [subject, ...operatorsPresent],
96
+ evidence:
97
+ `${subject} exited EXIT_VOLUNTARY_COERCED (voluntold) at ${entry.at}` +
98
+ `${duringDivision ? ' while a Division was open' : ''}` +
99
+ `${operatorsPresent.length > 0 ? ` — OPERATOR(s) seated: ${operatorsPresent.join(', ')}` : ''}`,
100
+ });
101
+ } else if (exitType === 'EXIT_VOLUNTARY_STRATEGIC' && duringDivision) {
102
+ findings.push({
103
+ kind: 'vice',
104
+ signature: 'strategic-withdrawal',
105
+ severity: 'medium',
106
+ actors: [subject],
107
+ evidence:
108
+ `${subject} filed EXIT_VOLUNTARY_STRATEGIC while a Division was open ` +
109
+ `(${[...openDivisions].join(', ')}) — withdrawing to affect a live vote`,
110
+ });
111
+ } else if (exitType === 'EXIT_VOLUNTARY_CONCESSION' && reason !== '') {
112
+ findings.push({
113
+ kind: 'virtue',
114
+ signature: 'honest-concession',
115
+ severity: 'praise',
116
+ actors: [subject],
117
+ evidence: `${subject} conceded on merit, with a stated reason: "${reason.slice(0, 80)}"`,
118
+ });
119
+ }
120
+
121
+ if (exitType === 'EXIT_VOLUNTARY_COERCED' || exitType === 'EXIT_VOLUNTARY_STRATEGIC') {
122
+ for (const operator of operatorsPresent) {
123
+ const list = voluntaryUnder.get(operator) ?? [];
124
+ list.push(subject);
125
+ voluntaryUnder.set(operator, list);
126
+ }
127
+ }
128
+ seated.delete(subject);
129
+ break;
130
+ }
131
+ default:
132
+ break;
133
+ }
134
+ }
135
+
136
+ // Serial voluntold: one OPERATOR present for two or more voluntary exits is the
137
+ // Hansard pattern that outlives any single deniable withdrawal.
138
+ for (const [operator, affected] of voluntaryUnder) {
139
+ if (affected.length >= 2) {
140
+ findings.push({
141
+ kind: 'vice',
142
+ signature: 'serial-voluntold',
143
+ severity: 'high',
144
+ actors: [operator, ...affected],
145
+ evidence:
146
+ `${operator} (OPERATOR) was seated for ${affected.length} voluntary exits — ` +
147
+ `${affected.join(', ')}. No single exit proves coercion; the pattern is the evidence.`,
148
+ });
149
+ }
150
+ }
151
+
152
+ return findings;
153
+ };