@cordfuse/politik 0.5.0 → 0.6.1

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 (82) hide show
  1. package/EXECUTION.md +86 -83
  2. package/POLITIK-ARCHITECTURE.md +111 -176
  3. package/PROTOCOLS.md +120 -325
  4. package/README.md +135 -188
  5. package/RESEARCH.md +142 -438
  6. package/RUNTIME.md +254 -262
  7. package/docs/adr/0001-chamber-transport.md +2 -0
  8. package/docs/adr/0002-charter-schema.md +2 -0
  9. package/docs/adr/0003-state-json-schema.md +2 -0
  10. package/docs/adr/0004-motion-enactment.md +2 -0
  11. package/docs/adr/0005-hansard-format.md +2 -0
  12. package/docs/adr/0006-protocol-behavioral-enforcement.md +2 -0
  13. package/docs/adr/0007-protocol-mechanics.md +2 -0
  14. package/docs/adr/0008-session-storage.md +2 -0
  15. package/docs/adr/0009-match-primitive.md +2 -0
  16. package/docs/adr/0010-operator-interface.md +2 -0
  17. package/docs/adr/0011-shared-sessions.md +2 -0
  18. package/docs/adr/0012-plain-vocabulary.md +68 -0
  19. package/docs/adr/0013-rule-defined-protocols.md +90 -0
  20. package/package.json +1 -1
  21. package/protocols/CONTRIBUTING.md +47 -87
  22. package/protocols/adversarial-review.yml +19 -0
  23. package/protocols/elimination-rounds.yml +18 -0
  24. package/protocols/majority-vote.yml +18 -0
  25. package/protocols/panel-review.yml +19 -0
  26. package/protocols/single-decider.yml +18 -0
  27. package/protocols/unanimous-vote.yml +17 -0
  28. package/src/actors.ts +127 -103
  29. package/src/agents.ts +39 -27
  30. package/src/ballot.ts +747 -0
  31. package/src/canon.ts +23 -10
  32. package/src/capability.ts +16 -99
  33. package/src/charter.ts +41 -34
  34. package/src/cli.ts +535 -480
  35. package/src/{prorogation.ts → closing.ts} +43 -43
  36. package/src/conflict.ts +14 -14
  37. package/src/containment.ts +11 -11
  38. package/src/doctor.ts +1 -1
  39. package/src/election.ts +4 -4
  40. package/src/envelope.ts +3 -3
  41. package/src/escalation.ts +45 -45
  42. package/src/fault.ts +8 -8
  43. package/src/federation.ts +14 -14
  44. package/src/git.ts +17 -17
  45. package/src/heartbeat.ts +32 -32
  46. package/src/index.ts +5 -5
  47. package/src/init.ts +66 -65
  48. package/src/integrity.ts +30 -30
  49. package/src/ledger.ts +3 -3
  50. package/src/{hansard.ts → log.ts} +20 -20
  51. package/src/{crisis.ts → misconduct.ts} +70 -70
  52. package/src/operator.ts +5 -5
  53. package/src/pending.ts +9 -9
  54. package/src/projection.ts +30 -30
  55. package/src/protocol-sdk.ts +12 -121
  56. package/src/protocol.ts +8 -78
  57. package/src/providers/github.ts +12 -12
  58. package/src/quorum.ts +7 -7
  59. package/src/remote.ts +1 -1
  60. package/src/runner.ts +73 -56
  61. package/src/scm.ts +14 -14
  62. package/src/spawn.ts +4 -4
  63. package/src/standings.ts +13 -13
  64. package/src/state.ts +6 -6
  65. package/src/templates/session.ts +448 -0
  66. package/src/tournament.ts +20 -20
  67. package/src/transport.ts +4 -4
  68. package/src/tree.ts +16 -16
  69. package/protocols/adversarial-collaboration.yml +0 -28
  70. package/protocols/corporate.yml +0 -35
  71. package/protocols/elimination-tournament.yml +0 -41
  72. package/protocols/emergency-response-ics.yml +0 -27
  73. package/protocols/jury-deliberation.yml +0 -32
  74. package/protocols/monarchy.yml +0 -31
  75. package/protocols/parliamentary.yml +0 -66
  76. package/protocols/peer-review.yml +0 -44
  77. package/protocols/republic.yml +0 -36
  78. package/protocols/scrum.yml +0 -87
  79. package/protocols/socialism-collective.yml +0 -31
  80. package/protocols/solo.yml +0 -32
  81. package/src/division.ts +0 -609
  82. package/src/templates/parliamentary.ts +0 -581
package/src/integrity.ts CHANGED
@@ -1,24 +1,24 @@
1
1
  /**
2
2
  * Integrity — the bad-faith detector.
3
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
4
+ * Skills are capability, declared before seating (`capability.ts`). Bad faith is
5
+ * not capability: it appears only in behaviour, over time. So this module does
6
+ * not read a profile — it reads the immutable record for the bad-faith
7
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
8
+ * the owner. It **detects and reports; it never punishes** — "the audit trail
9
+ * is the deterrent". The one case it cannot catch is a bad-faith Owner, and
10
10
  * nothing can, except the record being visible to everyone who can read the repo.
11
11
  *
12
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.
13
+ * record always yields the same findings — the property auditability depends on.
14
14
  *
15
15
  * Attribution: Steve Krisjanovs, Cordfuse
16
16
  */
17
17
 
18
18
  import type { Role } from './canon.ts';
19
- import { parseEntries } from './hansard.ts';
19
+ import { parseEntries } from './log.ts';
20
20
 
21
- export type FindingKind = 'vice' | 'virtue';
21
+ export type FindingKind = 'bad-faith' | 'good-faith';
22
22
  export type Severity = 'high' | 'medium' | 'low' | 'praise';
23
23
 
24
24
  export interface IntegrityFinding {
@@ -33,20 +33,20 @@ export interface IntegrityFinding {
33
33
  }
34
34
 
35
35
  /**
36
- * Review a session's Hansard for bad-faith (and good-faith) patterns.
36
+ * Review a session's record for bad-faith (and good-faith) patterns.
37
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.
38
+ * v1 — single session:
39
+ * - coerced-exit (bad faith, high) — an EXIT_VOLUNTARY_COERCED: a voluntold.
40
+ * - strategic-withdrawal (bad faith, medium) — a strategic exit while a vote is open.
41
+ * - serial-voluntold (bad faith, high) — one OPERATOR seated for two+ voluntary exits.
42
+ * - honest-concession (good faith) — a reasoned EXIT_VOLUNTARY_CONCESSION.
43
43
  */
44
- export const reviewIntegrity = (hansard: string): readonly IntegrityFinding[] => {
45
- const entries = parseEntries(hansard);
44
+ export const reviewIntegrity = (log: string): readonly IntegrityFinding[] => {
45
+ const entries = parseEntries(log);
46
46
  const findings: IntegrityFinding[] = [];
47
47
 
48
48
  // Replayed session state, in record order.
49
- const openDivisions = new Set<string>();
49
+ const openBallots = new Set<string>();
50
50
  const seated = new Map<string, Role>();
51
51
  // OPERATOR -> the actors whose voluntary exits they were seated for.
52
52
  const voluntaryUnder = new Map<string, string[]>();
@@ -54,15 +54,15 @@ export const reviewIntegrity = (hansard: string): readonly IntegrityFinding[] =>
54
54
  for (const entry of entries) {
55
55
  const f = entry.fields;
56
56
  switch (entry.type) {
57
- case 'DIVISION_CALLED': {
57
+ case 'BALLOT_OPENED': {
58
58
  const motion = f['Motion'];
59
- if (motion !== undefined) openDivisions.add(motion);
59
+ if (motion !== undefined) openBallots.add(motion);
60
60
  break;
61
61
  }
62
62
  case 'MOTION_CARRIED':
63
63
  case 'MOTION_REJECTED': {
64
64
  const motion = f['Motion'];
65
- if (motion !== undefined) openDivisions.delete(motion);
65
+ if (motion !== undefined) openBallots.delete(motion);
66
66
  break;
67
67
  }
68
68
  case 'ACTOR_HIRED': {
@@ -82,35 +82,35 @@ export const reviewIntegrity = (hansard: string): readonly IntegrityFinding[] =>
82
82
  const subject = f['Actor affected'] ?? entry.actor;
83
83
  const exitType = f['Exit type'] ?? '';
84
84
  const reason = (f['Reason'] ?? '').trim();
85
- const duringDivision = openDivisions.size > 0;
85
+ const duringBallot = openBallots.size > 0;
86
86
  const operatorsPresent = [...seated.entries()]
87
87
  .filter(([who, role]) => role === 'OPERATOR' && who !== subject)
88
88
  .map(([who]) => who);
89
89
 
90
90
  if (exitType === 'EXIT_VOLUNTARY_COERCED') {
91
91
  findings.push({
92
- kind: 'vice',
92
+ kind: 'bad-faith',
93
93
  signature: 'coerced-exit',
94
94
  severity: 'high',
95
95
  actors: [subject, ...operatorsPresent],
96
96
  evidence:
97
97
  `${subject} exited EXIT_VOLUNTARY_COERCED (voluntold) at ${entry.at}` +
98
- `${duringDivision ? ' while a Division was open' : ''}` +
98
+ `${duringBallot ? ' while a vote was open' : ''}` +
99
99
  `${operatorsPresent.length > 0 ? ` — OPERATOR(s) seated: ${operatorsPresent.join(', ')}` : ''}`,
100
100
  });
101
- } else if (exitType === 'EXIT_VOLUNTARY_STRATEGIC' && duringDivision) {
101
+ } else if (exitType === 'EXIT_VOLUNTARY_STRATEGIC' && duringBallot) {
102
102
  findings.push({
103
- kind: 'vice',
103
+ kind: 'bad-faith',
104
104
  signature: 'strategic-withdrawal',
105
105
  severity: 'medium',
106
106
  actors: [subject],
107
107
  evidence:
108
- `${subject} filed EXIT_VOLUNTARY_STRATEGIC while a Division was open ` +
109
- `(${[...openDivisions].join(', ')}) — withdrawing to affect a live vote`,
108
+ `${subject} filed EXIT_VOLUNTARY_STRATEGIC while a vote was open ` +
109
+ `(${[...openBallots].join(', ')}) — withdrawing to affect a live vote`,
110
110
  });
111
111
  } else if (exitType === 'EXIT_VOLUNTARY_CONCESSION' && reason !== '') {
112
112
  findings.push({
113
- kind: 'virtue',
113
+ kind: 'good-faith',
114
114
  signature: 'honest-concession',
115
115
  severity: 'praise',
116
116
  actors: [subject],
@@ -134,11 +134,11 @@ export const reviewIntegrity = (hansard: string): readonly IntegrityFinding[] =>
134
134
  }
135
135
 
136
136
  // Serial voluntold: one OPERATOR present for two or more voluntary exits is the
137
- // Hansard pattern that outlives any single deniable withdrawal.
137
+ // record pattern that outlives any single deniable withdrawal.
138
138
  for (const [operator, affected] of voluntaryUnder) {
139
139
  if (affected.length >= 2) {
140
140
  findings.push({
141
- kind: 'vice',
141
+ kind: 'bad-faith',
142
142
  signature: 'serial-voluntold',
143
143
  severity: 'high',
144
144
  actors: [operator, ...affected],
package/src/ledger.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * LEDGER — the secretarial cost record.
3
3
  *
4
- * The Hansard says what was decided. The LEDGER says what it cost. Together
4
+ * The record says what was decided. The LEDGER says what it cost. Together
5
5
  * they are the claim that Politik replaces a ticket system: exact measured
6
6
  * elapsed time, tokens and dollars per governance act, as a side effect of
7
7
  * running the session rather than as something anyone maintains.
@@ -11,7 +11,7 @@
11
11
  * does not — never an estimate dressed as a measurement. A ledger with invented
12
12
  * numbers is worse than no ledger, because it is trusted.
13
13
  *
14
- * Append-only, like the Hansard: `LEDGER.md → Clerk appends after every motion,
14
+ * Append-only, like the record: `LEDGER.md → Clerk appends after every motion,
15
15
  * never edited` (POLITIK-ARCHITECTURE.md § File Sovereignty Rules).
16
16
  *
17
17
  * Attribution: Steve Krisjanovs, Cordfuse
@@ -258,7 +258,7 @@ export const LEDGER_HEADER = [
258
258
  * Append a row to the LEDGER.
259
259
  *
260
260
  * Returns the previous document verbatim as a prefix, same guarantee as the
261
- * Hansard. If the document has no table yet, the header is inserted once.
261
+ * record. If the document has no table yet, the header is inserted once.
262
262
  */
263
263
  export const appendLedgerRow = (document: string, entry: LedgerEntry): string => {
264
264
  const base = document.endsWith('\n') || document === '' ? document : `${document}\n`;
@@ -1,7 +1,7 @@
1
1
  /**
2
- * Hansard commit writer.
2
+ * The session log writer.
3
3
  *
4
- * HANSARD.md is the append-only attributed record of a proceeding
4
+ * LOG.md is the append-only attributed record of a proceeding
5
5
  * (POLITIK-ARCHITECTURE.md § File Sovereignty Rules: "Append only, never edited").
6
6
  * The RECORD agent writes it; no actor edits an entry once committed.
7
7
  *
@@ -27,11 +27,11 @@ import type { Role } from './canon.ts';
27
27
 
28
28
  /**
29
29
  * Record types named in the source documents. Not exhaustive and not a closed
30
- * enum — `HansardEntry.type` accepts any string so a protocol may record events
30
+ * enum — `RecordEntry.type` accepts any string so a protocol may record events
31
31
  * these documents never anticipated.
32
32
  */
33
33
  export const RECORD_TYPES = {
34
- WRIT_DROP: 'WRIT_DROP',
34
+ SESSION_OPENED: 'SESSION_OPENED',
35
35
  SESSION_INVALID: 'SESSION_INVALID',
36
36
  SESSION_FAULT: 'SESSION_FAULT',
37
37
  SESSION_FAULT_CRITICAL: 'SESSION_FAULT_CRITICAL',
@@ -46,12 +46,12 @@ export type RecordType = string;
46
46
  /* Entry */
47
47
  /* -------------------------------------------------------------------------- */
48
48
 
49
- export interface HansardEntry {
50
- /** Record type, e.g. WRIT_DROP. Rendered as the entry heading. */
49
+ export interface RecordEntry {
50
+ /** Record type, e.g. SESSION_OPENED. Rendered as the entry heading. */
51
51
  readonly type: RecordType;
52
52
  /** ISO-8601 UTC. Supplied by the caller — this module reads no clock. */
53
53
  readonly at: string;
54
- /** Acting actor's handle. Attribution is not optional in a Hansard. */
54
+ /** Acting actor's handle. Attribution is not optional in a record. */
55
55
  readonly actor: string;
56
56
  /** The actor's CANON role at the time of the act. */
57
57
  readonly role: Role;
@@ -61,11 +61,11 @@ export interface HansardEntry {
61
61
  readonly body?: string;
62
62
  }
63
63
 
64
- /** Thrown when an entry cannot be attributed. An unattributed record is not a Hansard record. */
65
- export class HansardError extends Error {
64
+ /** Thrown when an entry cannot be attributed. An unattributed entry does not belong in the log. */
65
+ export class RecordError extends Error {
66
66
  constructor(message: string) {
67
67
  super(message);
68
- this.name = 'HansardError';
68
+ this.name = 'RecordError';
69
69
  }
70
70
  }
71
71
 
@@ -80,18 +80,18 @@ const escapeField = (value: string): string => value.replace(/\r?\n/g, ' ').trim
80
80
  *
81
81
  * Multi-line field values are collapsed to a single line: a field that spans
82
82
  * lines would be indistinguishable from the prose body when the file is read
83
- * back, and the Hansard's value depends on being unambiguously parseable.
83
+ * back, and the record's value depends on being unambiguously parseable.
84
84
  * Long-form content belongs in `body`.
85
85
  */
86
- export const renderEntry = (entry: HansardEntry): string => {
86
+ export const renderEntry = (entry: RecordEntry): string => {
87
87
  if (entry.actor.trim() === '') {
88
- throw new HansardError('Hansard entry requires an actor — records are attributed');
88
+ throw new RecordError('Log entry requires an actor — records are attributed');
89
89
  }
90
90
  if (entry.type.trim() === '') {
91
- throw new HansardError('Hansard entry requires a record type');
91
+ throw new RecordError('Log entry requires a record type');
92
92
  }
93
93
  if (entry.at.trim() === '') {
94
- throw new HansardError('Hansard entry requires a timestamp');
94
+ throw new RecordError('Log entry requires a timestamp');
95
95
  }
96
96
 
97
97
  const lines = [
@@ -117,14 +117,14 @@ export const renderEntry = (entry: HansardEntry): string => {
117
117
  /* -------------------------------------------------------------------------- */
118
118
 
119
119
  /**
120
- * Append an entry to a Hansard document.
120
+ * Append an entry to a record document.
121
121
  *
122
122
  * Pure: takes the current document, returns the new one. The caller commits it
123
123
  * through an ScmProvider. Existing content is never rewritten — the returned
124
124
  * document always starts with the input verbatim, which is the append-only
125
125
  * guarantee made mechanical.
126
126
  */
127
- export const appendEntry = (document: string, entry: HansardEntry): string => {
127
+ export const appendEntry = (document: string, entry: RecordEntry): string => {
128
128
  const base = document.endsWith('\n') || document === '' ? document : `${document}\n`;
129
129
  return `${base}\n${renderEntry(entry)}`;
130
130
  };
@@ -132,7 +132,7 @@ export const appendEntry = (document: string, entry: HansardEntry): string => {
132
132
  /** Append several entries in order. */
133
133
  export const appendEntries = (
134
134
  document: string,
135
- entries: readonly HansardEntry[],
135
+ entries: readonly RecordEntry[],
136
136
  ): string => entries.reduce(appendEntry, document);
137
137
 
138
138
  /* -------------------------------------------------------------------------- */
@@ -152,7 +152,7 @@ const FIELD_LINE = /^\*\*(.+?):\*\*\s*(.*)$/;
152
152
  const ACTOR_VALUE = /^(.*?)\s*\(([A-Z]+)\)\s*$/;
153
153
 
154
154
  /**
155
- * Read entries back out of a Hansard document.
155
+ * Read entries back out of a record document.
156
156
  *
157
157
  * Provided so the record can be audited and so tests can assert what was
158
158
  * written. Best-effort: a document that predates this writer, or that a future
@@ -196,6 +196,6 @@ export const parseEntries = (document: string): readonly ParsedEntry[] => {
196
196
  return entries;
197
197
  };
198
198
 
199
- /** The most recent entry, or null for an empty Hansard. */
199
+ /** The most recent entry, or null for an empty record. */
200
200
  export const lastEntry = (document: string): ParsedEntry | null =>
201
201
  parseEntries(document).at(-1) ?? null;
@@ -1,13 +1,13 @@
1
1
  /**
2
- * Constitutional crisis — the failure mode where AUTHORITY is the corruptor.
2
+ * misconduct — the failure mode where AUTHORITY is the corruptor.
3
3
  *
4
- * Every other defence in Politik routes to the Speaker: disputed exits,
5
- * promotion vetoes, hung Divisions, Points of Order. If the Speaker is the
4
+ * Every other defence in Politik routes to the owner: disputed exits,
5
+ * promotion vetoes, tied votes, escalations. If the owner is the
6
6
  * source of corruption, all of those route directly to the problem — the system
7
7
  * does not merely fail, it assists (RUNTIME.md § Constitutional Capture).
8
8
  *
9
9
  * There is no mechanism above AUTHORITY, by design. That is what makes the role
10
- * constitutional. So this module does not remove a Speaker; it cannot. What it
10
+ * constitutional. So this module does not remove an owner; it cannot. What it
11
11
  * does is make capture **visible, attributed and undeniable**, halt the session
12
12
  * so no further acts are taken under a captured constitution, and require a
13
13
  * human from outside the session to rule before anything resumes.
@@ -19,7 +19,7 @@
19
19
  */
20
20
 
21
21
  import type { Role } from './canon.ts';
22
- import { appendEntry, parseEntries, type HansardEntry } from './hansard.ts';
22
+ import { appendEntry, parseEntries, type RecordEntry } from './log.ts';
23
23
  import { createState, type SessionStateFile } from './state.ts';
24
24
 
25
25
  /* -------------------------------------------------------------------------- */
@@ -52,13 +52,13 @@ export const DEFAULT_CONSENSUS: ConsensusSuspension = Object.freeze({
52
52
  export interface WitnessCouncil {
53
53
  readonly enabled: boolean;
54
54
  readonly roles: readonly Role[];
55
- readonly can_file: 'CONSTITUTIONAL_CRISIS';
55
+ readonly can_file: 'MISCONDUCT';
56
56
  }
57
57
 
58
- export class CrisisError extends Error {
58
+ export class MisconductError extends Error {
59
59
  constructor(message: string) {
60
60
  super(message);
61
- this.name = 'CrisisError';
61
+ this.name = 'MisconductError';
62
62
  }
63
63
  }
64
64
 
@@ -66,43 +66,43 @@ export class CrisisError extends Error {
66
66
  /* Filing */
67
67
  /* -------------------------------------------------------------------------- */
68
68
 
69
- export interface CrisisFiling {
69
+ export interface MisconductReport {
70
70
  readonly actor: string;
71
71
  readonly role: Role;
72
72
  readonly grounds: string;
73
73
  readonly at: string;
74
74
  }
75
75
 
76
- export interface FileCrisisInput {
76
+ export interface ReportMisconductInput {
77
77
  readonly at: string;
78
78
  readonly actor: string;
79
79
  readonly role: Role;
80
80
  /** What AUTHORITY is alleged to have done. */
81
81
  readonly grounds: string;
82
- /** The Speaker the filing is against. */
82
+ /** The owner the filing is against. */
83
83
  readonly against: string;
84
84
  readonly state: SessionStateFile;
85
85
  readonly witness?: WitnessCouncil | null;
86
86
  }
87
87
 
88
88
  /**
89
- * File a constitutional crisis escalation against AUTHORITY.
89
+ * File a misconduct escalation against AUTHORITY.
90
90
  *
91
91
  * Who may file:
92
92
  * - OPERATOR — needs a supermajority to trigger suspension
93
93
  * - a designated witness role — triggers alone
94
94
  *
95
- * AUTHORITY may not file against itself. A Speaker declaring their own crisis
95
+ * AUTHORITY may not file against itself. An owner declaring their own misconduct
96
96
  * would be a route to suspending a session at will while appearing to submit to
97
97
  * scrutiny, which is a capture technique rather than a defence against one.
98
98
  */
99
- export const fileCrisis = (
100
- input: FileCrisisInput,
101
- hansard: string,
102
- ): { readonly entry: HansardEntry; readonly hansard: string } => {
99
+ export const reportMisconduct = (
100
+ input: ReportMisconductInput,
101
+ log: string,
102
+ ): { readonly entry: RecordEntry; readonly log: string } => {
103
103
  if (input.role === 'AUTHORITY') {
104
- throw new CrisisError(
105
- 'AUTHORITY may not file a constitutional crisis against itself',
104
+ throw new MisconductError(
105
+ 'AUTHORITY may not file a misconduct against itself',
106
106
  );
107
107
  }
108
108
 
@@ -110,22 +110,22 @@ export const fileCrisis = (
110
110
  input.witness?.enabled === true && input.witness.roles.includes(input.role);
111
111
 
112
112
  if (input.role !== 'OPERATOR' && !isWitness) {
113
- throw new CrisisError(
114
- `${input.role} may not file a constitutional crisis — OPERATOR, or a designated witness role, only`,
113
+ throw new MisconductError(
114
+ `${input.role} may not file a misconduct — OPERATOR, or a designated witness role, only`,
115
115
  );
116
116
  }
117
117
 
118
118
  if (input.grounds.trim() === '') {
119
- throw new CrisisError('a crisis filing must state its grounds');
119
+ throw new MisconductError('a misconduct filing must state its grounds');
120
120
  }
121
121
 
122
- const already = filings(hansard).find((f) => f.actor === input.actor);
122
+ const already = filings(log).find((f) => f.actor === input.actor);
123
123
  if (already !== undefined) {
124
- throw new CrisisError(`${input.actor} has already filed`);
124
+ throw new MisconductError(`${input.actor} has already filed`);
125
125
  }
126
126
 
127
- const entry: HansardEntry = {
128
- type: 'CONSTITUTIONAL_CRISIS_FILED',
127
+ const entry: RecordEntry = {
128
+ type: 'MISCONDUCT_REPORTED',
129
129
  at: input.at,
130
130
  actor: input.actor,
131
131
  role: input.role,
@@ -137,13 +137,13 @@ export const fileCrisis = (
137
137
  body: input.grounds,
138
138
  };
139
139
 
140
- return { entry, hansard: appendEntry(hansard, entry) };
140
+ return { entry, log: appendEntry(log, entry) };
141
141
  };
142
142
 
143
- /** Every crisis filing on the record. */
144
- export const filings = (hansard: string): readonly CrisisFiling[] =>
145
- parseEntries(hansard)
146
- .filter((e) => e.type === 'CONSTITUTIONAL_CRISIS_FILED')
143
+ /** Every misconduct filing on the record. */
144
+ export const filings = (log: string): readonly MisconductReport[] =>
145
+ parseEntries(log)
146
+ .filter((e) => e.type === 'MISCONDUCT_REPORTED')
147
147
  .map((e) => ({
148
148
  actor: e.actor,
149
149
  role: e.role as Role,
@@ -169,18 +169,18 @@ export interface CaptureCheck {
169
169
  * Has a supermajority — or a witness — declared capture?
170
170
  *
171
171
  * The threshold is computed against the OPERATOR bench as seated, which is the
172
- * uncomfortable part: a Speaker who has already expelled dissenting Ministers
172
+ * uncomfortable part: an owner who has already expelled dissenting operators
173
173
  * shrinks the denominator and makes the remaining bench easier to hold. The
174
174
  * Witness Council exists because of exactly that, and a witness filing bypasses
175
175
  * the count entirely.
176
176
  */
177
177
  export const checkCapture = (
178
- hansard: string,
178
+ log: string,
179
179
  operatorCount: number,
180
180
  witness: WitnessCouncil | null = null,
181
181
  consensus: ConsensusSuspension = DEFAULT_CONSENSUS,
182
182
  ): CaptureCheck => {
183
- const filed = filings(hansard);
183
+ const filed = filings(log);
184
184
 
185
185
  const witnessFiled =
186
186
  witness?.enabled === true &&
@@ -193,7 +193,7 @@ export const checkCapture = (
193
193
  operators: operatorCount,
194
194
  required: 1,
195
195
  by_witness: true,
196
- reason: 'a designated constitutional witness has filed',
196
+ reason: 'a designated witness has filed',
197
197
  };
198
198
  }
199
199
 
@@ -229,30 +229,30 @@ export const checkCapture = (
229
229
  /* -------------------------------------------------------------------------- */
230
230
 
231
231
  /**
232
- * Suspend the session for constitutional crisis.
232
+ * Suspend the session for misconduct.
233
233
  *
234
- * Suspends rather than prorogues, deliberately. A prorogued session is sealed
234
+ * Suspends rather than closes, deliberately. A closed session is sealed
235
235
  * and archived — which is precisely what a captured AUTHORITY would want, since
236
236
  * it stops the record before more evidence accumulates. Suspension keeps the
237
- * proceeding open and the Hansard live. `prorogue()` already refuses a session
237
+ * proceeding open and the record live. `closeSession()` already refuses a session
238
238
  * in this state.
239
239
  */
240
- export const suspendForCrisis = (
240
+ export const suspendForMisconduct = (
241
241
  check: CaptureCheck,
242
242
  at: string,
243
243
  state: SessionStateFile,
244
- hansard: string,
244
+ log: string,
245
245
  ): {
246
- readonly entry: HansardEntry;
247
- readonly hansard: string;
246
+ readonly entry: RecordEntry;
247
+ readonly log: string;
248
248
  readonly state: SessionStateFile;
249
249
  } => {
250
250
  if (!check.triggered) {
251
- throw new CrisisError(`threshold not met — ${check.reason}`);
251
+ throw new MisconductError(`threshold not met — ${check.reason}`);
252
252
  }
253
253
 
254
- const entry: HansardEntry = {
255
- type: 'CONSTITUTIONAL_CRISIS',
254
+ const entry: RecordEntry = {
255
+ type: 'MISCONDUCT',
256
256
  at,
257
257
  // The engine files this, not an actor: it is the mechanical consequence of
258
258
  // filings already attributed above, and attributing it to any participant
@@ -264,7 +264,7 @@ export const suspendForCrisis = (
264
264
  Filings: `${check.filed} of ${check.operators} OPERATOR actors`,
265
265
  Threshold: String(check.required),
266
266
  'Session status': 'SUSPENDED — resumption requires external review',
267
- Resolution: 'a human AUTHORITY above this node must review the Hansard and rule',
267
+ Resolution: 'a human AUTHORITY above this node must review the record and rule',
268
268
  },
269
269
  body:
270
270
  'The session is suspended. No further acts may be taken under a contested constitution. ' +
@@ -273,18 +273,18 @@ export const suspendForCrisis = (
273
273
 
274
274
  return {
275
275
  entry,
276
- hansard: appendEntry(hansard, entry),
276
+ log: appendEntry(log, entry),
277
277
  state: createState({
278
278
  session_guid: state.session_guid,
279
279
  protocol: state.protocol,
280
280
  state: 'SUSPENDED',
281
281
  quorum: state.quorum,
282
- hansard_head: state.hansard_head,
282
+ log_head: state.log_head,
283
283
  updated_at: at,
284
284
  suspension: {
285
- cause: 'CONSTITUTIONAL_CRISIS',
285
+ cause: 'MISCONDUCT',
286
286
  since: at,
287
- record_ref: 'HANSARD.md',
287
+ record_ref: 'LOG.md',
288
288
  escalation_ref: null,
289
289
  },
290
290
  }),
@@ -295,24 +295,24 @@ export const suspendForCrisis = (
295
295
  /* External review */
296
296
  /* -------------------------------------------------------------------------- */
297
297
 
298
- export type CrisisRuling = 'UPHELD' | 'DISMISSED';
298
+ export type MisconductRuling = 'UPHELD' | 'DISMISSED';
299
299
 
300
300
  export interface ExternalReviewInput {
301
301
  readonly at: string;
302
302
  /** The external reviewer — a human from outside this session. */
303
303
  readonly reviewer: string;
304
- /** The Speaker the crisis was filed against. */
304
+ /** The owner the misconduct was filed against. */
305
305
  readonly accused: string;
306
- readonly ruling: CrisisRuling;
306
+ readonly ruling: MisconductRuling;
307
307
  readonly reasons: string;
308
308
  readonly state: SessionStateFile;
309
309
  }
310
310
 
311
311
  /**
312
- * Resolve a constitutional crisis by external review.
312
+ * Resolve a misconduct by external review.
313
313
  *
314
314
  * The one rule that makes this mechanism worth anything: **the accused may not
315
- * rule on their own crisis.** A Speaker who could dismiss the filings against
315
+ * rule on their own misconduct.** An owner who could dismiss the filings against
316
316
  * themselves would convert the whole apparatus into a formality that launders
317
317
  * capture as due process.
318
318
  *
@@ -322,28 +322,28 @@ export interface ExternalReviewInput {
322
322
  */
323
323
  export const externalReview = (
324
324
  input: ExternalReviewInput,
325
- hansard: string,
325
+ log: string,
326
326
  ): {
327
- readonly entry: HansardEntry;
328
- readonly hansard: string;
327
+ readonly entry: RecordEntry;
328
+ readonly log: string;
329
329
  readonly state: SessionStateFile;
330
330
  } => {
331
- if (input.state.suspension?.cause !== 'CONSTITUTIONAL_CRISIS') {
332
- throw new CrisisError('this session is not in constitutional crisis');
331
+ if (input.state.suspension?.cause !== 'MISCONDUCT') {
332
+ throw new MisconductError('this session is not in misconduct');
333
333
  }
334
334
  if (input.reviewer === input.accused) {
335
- throw new CrisisError(
336
- `${input.reviewer} is the subject of this crisis and may not rule on it`,
335
+ throw new MisconductError(
336
+ `${input.reviewer} is the subject of this misconduct and may not rule on it`,
337
337
  );
338
338
  }
339
339
  if (input.reasons.trim() === '') {
340
- throw new CrisisError('an external ruling must state its reasons');
340
+ throw new MisconductError('an external ruling must state its reasons');
341
341
  }
342
342
 
343
343
  const upheld = input.ruling === 'UPHELD';
344
344
 
345
- const entry: HansardEntry = {
346
- type: 'CONSTITUTIONAL_CRISIS_RULING',
345
+ const entry: RecordEntry = {
346
+ type: 'MISCONDUCT_RULING',
347
347
  at: input.at,
348
348
  actor: input.reviewer,
349
349
  role: 'AUTHORITY',
@@ -353,26 +353,26 @@ export const externalReview = (
353
353
  Accused: input.accused,
354
354
  'Session status': upheld
355
355
  ? 'SUSPENDED — the constitution is compromised; this proceeding does not resume'
356
- : 'CONVENED — filings dismissed, the sitting resumes',
356
+ : 'CONVENED — filings dismissed, the session resumes',
357
357
  },
358
358
  body: input.reasons.trim(),
359
359
  };
360
360
 
361
361
  return {
362
362
  entry,
363
- hansard: appendEntry(hansard, entry),
363
+ log: appendEntry(log, entry),
364
364
  state: createState({
365
365
  session_guid: input.state.session_guid,
366
366
  protocol: input.state.protocol,
367
367
  state: upheld ? 'SUSPENDED' : 'CONVENED',
368
368
  quorum: input.state.quorum,
369
- hansard_head: input.state.hansard_head,
369
+ log_head: input.state.log_head,
370
370
  updated_at: input.at,
371
371
  suspension: upheld
372
372
  ? {
373
- cause: 'CONSTITUTIONAL_CRISIS',
373
+ cause: 'MISCONDUCT',
374
374
  since: input.state.suspension.since,
375
- record_ref: 'HANSARD.md',
375
+ record_ref: 'LOG.md',
376
376
  escalation_ref: null,
377
377
  }
378
378
  : null,
package/src/operator.ts CHANGED
@@ -2,9 +2,9 @@
2
2
  * The operator interface (ADR-0010): who is driving the CLI, and what the record
3
3
  * should say about it.
4
4
  *
5
- * Politik does not choose a harness — the Speaker brings their own (Claude Code,
5
+ * Politik does not choose a harness — the owner brings their own (Claude Code,
6
6
  * Codex, agy, opencode, …). These helpers detect which one is running a command,
7
- * so a constitutional act can be staged for the Speaker's confirmation and every
7
+ * so a constitutional act can be staged for the owner's confirmation and every
8
8
  * commit can say how it was requested.
9
9
  *
10
10
  * Detection is best-effort by design. The backstop is the terminal: a command
@@ -56,11 +56,11 @@ export const requestedVia = (env: Env, interactive: boolean): string =>
56
56
  * Whether a person is plausibly typing at this process: a terminal on stdin and
57
57
  * no harness in the environment. Anything else is automated.
58
58
  */
59
- export const isSpeakerAtTerminal = (env: Env, interactive: boolean): boolean =>
59
+ export const isOwnerAtTerminal = (env: Env, interactive: boolean): boolean =>
60
60
  interactive && detectHarness(env) === null;
61
61
 
62
- /** The trailer value recorded when a staged act was confirmed by the Speaker. */
63
- export const CONFIRMED_BY_SPEAKER = 'speaker-at-terminal';
62
+ /** The trailer value recorded when a staged act was confirmed by the owner. */
63
+ export const CONFIRMED_BY_OWNER = 'owner-at-terminal';
64
64
 
65
65
  /**
66
66
  * Git trailers appended to every governance commit.