@cordfuse/politik 0.4.0 → 0.6.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 (81) hide show
  1. package/EXECUTION.md +90 -85
  2. package/POLITIK-ARCHITECTURE.md +111 -176
  3. package/PROTOCOLS.md +120 -289
  4. package/README.md +130 -177
  5. package/RESEARCH.md +142 -436
  6. package/RUNTIME.md +253 -261
  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 +89 -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 +124 -100
  29. package/src/agents.ts +64 -23
  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 +541 -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 +44 -44
  42. package/src/fault.ts +8 -8
  43. package/src/federation.ts +14 -14
  44. package/src/git.ts +21 -18
  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 +134 -55
  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/socialism-collective.yml +0 -31
  79. package/protocols/solo.yml +0 -32
  80. package/src/division.ts +0 -609
  81. package/src/templates/parliamentary.ts +0 -580
package/src/escalation.ts CHANGED
@@ -1,15 +1,15 @@
1
1
  /**
2
- * Point of Order — escalation workflow.
2
+ * escalation — escalation workflow.
3
3
  *
4
- * The flow (RUNTIME.md § POINT OF ORDER — ESCALATION FLOW):
4
+ * The flow (RUNTIME.md — the escalation flow):
5
5
  *
6
6
  * Agent hits a decision requiring human judgement
7
7
  * -> commits escalation to escalations/[timestamp].md
8
- * -> Speaker notified
8
+ * -> Owner notified
9
9
  * -> session pauses
10
- * -> Speaker commits ruling
10
+ * -> Owner commits ruling
11
11
  * -> session resumes
12
- * -> ruling recorded permanently in Hansard
12
+ * -> ruling recorded permanently in record
13
13
  *
14
14
  * Pure, like the initializer: this module produces the files and the next state,
15
15
  * and the caller commits them. Notification is the caller's job too — it is an
@@ -18,14 +18,14 @@
18
18
  *
19
19
  * Note on vocabulary: RUNTIME.md predates ADR-0003 and describes the pause as
20
20
  * `STATE.json → paused: true`. ADR-0003 supersedes that mapping: the session
21
- * becomes SUSPENDED with `suspension.cause: POINT_OF_ORDER`. This module
21
+ * becomes SUSPENDED with `suspension.cause: ESCALATION`. This module
22
22
  * implements the ADR.
23
23
  *
24
24
  * Attribution: Steve Krisjanovs, Cordfuse
25
25
  */
26
26
 
27
27
  import type { Role } from './canon.ts';
28
- import { RECORD_TYPES, appendEntry, type HansardEntry } from './hansard.ts';
28
+ import { RECORD_TYPES, appendEntry, type RecordEntry } from './log.ts';
29
29
  import type { FileWrite } from './scm.ts';
30
30
  import { createState, type SessionStateFile } from './state.ts';
31
31
 
@@ -48,20 +48,20 @@ export interface EscalationInput {
48
48
  /**
49
49
  * True when the Charter's protocol declares `session.escalation: disabled`
50
50
  * (ADR-0006). A protocol with no appeals — a Darwinist chamber — has no
51
- * mechanism to resolve a Point of Order, so it refuses to raise one at all.
51
+ * mechanism to resolve an escalation, so it refuses to raise one at all.
52
52
  */
53
53
  readonly escalation_disabled?: boolean;
54
54
  }
55
55
 
56
56
  export interface EscalationResult {
57
57
  readonly escalation_path: string;
58
- /** Where the Speaker must commit their ruling. */
58
+ /** Where the owner must commit their ruling. */
59
59
  readonly ruling_path: string;
60
- /** SUSPENDED, cause POINT_OF_ORDER. */
60
+ /** SUSPENDED, cause ESCALATION. */
61
61
  readonly state: SessionStateFile;
62
62
  readonly files: readonly FileWrite[];
63
- readonly hansard_entry: HansardEntry;
64
- /** Message body for the Speaker notification. The caller delivers it. */
63
+ readonly log_entry: RecordEntry;
64
+ /** Message body for the owner notification. The caller delivers it. */
65
65
  readonly notification: string;
66
66
  }
67
67
 
@@ -73,7 +73,7 @@ export const rulingPath = (sequence: number): string =>
73
73
  `escalations/ruling-${String(sequence).padStart(3, '0')}.md`;
74
74
 
75
75
  /**
76
- * File a Point of Order.
76
+ * File an escalation.
77
77
  *
78
78
  * Suspends the session. Every actor reads STATE.json before acting, so agents
79
79
  * halt as soon as this state is committed — the pause is a consequence of the
@@ -88,22 +88,22 @@ export class EscalationError extends Error {
88
88
 
89
89
  export const fileEscalation = (
90
90
  input: EscalationInput,
91
- hansard: string,
92
- ): EscalationResult & { readonly hansard: string } => {
93
- // A protocol that declares no escalation has no mechanism to resolve a Point
94
- // of Order (ADR-0006). Refusing to raise one is what makes a Darwinist chamber
91
+ log: string,
92
+ ): EscalationResult & { readonly log: string } => {
93
+ // A protocol that declares no escalation has no mechanism to resolve an
94
+ // escalation (ADR-0006). Refusing to raise one is what makes a no-appeals session
95
95
  // behave like one: the decision stands, and a dissenting actor exits.
96
96
  if (input.escalation_disabled === true) {
97
- throw new EscalationError('this protocol declares no escalation — a Point of Order cannot be raised');
97
+ throw new EscalationError('this protocol declares no escalation — an escalation cannot be raised');
98
98
  }
99
99
 
100
- // A Point of Order suspends a live sitting, so it can only be raised from one.
101
- // Without this guard it would fire on any state — reopening a PROROGUED
100
+ // An escalation suspends a live session, so it can only be raised from one.
101
+ // Without this guard it would fire on any state — reopening a CLOSED
102
102
  // (sealed) session, or clobbering the pending ruling of a session already
103
- // SUSPENDED for an earlier Point of Order. Mirrors the Division/Assent guard.
103
+ // SUSPENDED for an earlier escalation. Mirrors the vote/Enactment guard.
104
104
  if (input.state.state !== 'CONVENED') {
105
105
  throw new EscalationError(
106
- `cannot raise a Point of Order while the session is ${input.state.state}`,
106
+ `cannot raise an escalation while the session is ${input.state.state}`,
107
107
  );
108
108
  }
109
109
 
@@ -111,7 +111,7 @@ export const fileEscalation = (
111
111
  const ruling_path = rulingPath(input.sequence);
112
112
 
113
113
  const document = [
114
- `# POINT OF ORDER — ${input.title}`,
114
+ `# ESCALATION — ${input.title}`,
115
115
  '',
116
116
  `**Filed by:** ${input.actor} (${input.role})`,
117
117
  `**Filed at:** ${input.at}`,
@@ -128,31 +128,31 @@ export const fileEscalation = (
128
128
  protocol: input.state.protocol,
129
129
  state: 'SUSPENDED',
130
130
  quorum: input.state.quorum,
131
- hansard_head: input.state.hansard_head,
131
+ log_head: input.state.log_head,
132
132
  updated_at: input.at,
133
133
  suspension: {
134
- cause: 'POINT_OF_ORDER',
134
+ cause: 'ESCALATION',
135
135
  since: input.at,
136
136
  record_ref: escalation_path,
137
137
  escalation_ref: escalation_path,
138
138
  },
139
139
  });
140
140
 
141
- const hansard_entry: HansardEntry = {
142
- type: 'POINT_OF_ORDER',
141
+ const log_entry: RecordEntry = {
142
+ type: 'ESCALATION',
143
143
  at: input.at,
144
144
  actor: input.actor,
145
145
  role: input.role,
146
146
  fields: {
147
147
  Escalation: escalation_path,
148
148
  'Ruling expected': ruling_path,
149
- 'Session status': 'SUSPENDED — awaiting Speaker ruling',
149
+ 'Session status': 'SUSPENDED — awaiting Owner ruling',
150
150
  },
151
151
  body: input.title,
152
152
  };
153
153
 
154
154
  const notification = [
155
- 'A Point of Order has been raised.',
155
+ 'An escalation has been raised.',
156
156
  '',
157
157
  `Filed by: ${input.actor} (${input.role})`,
158
158
  `Subject: ${input.title}`,
@@ -168,9 +168,9 @@ export const fileEscalation = (
168
168
  ruling_path,
169
169
  state,
170
170
  files: [{ path: escalation_path, content: document }],
171
- hansard_entry,
171
+ log_entry,
172
172
  notification,
173
- hansard: appendEntry(hansard, hansard_entry),
173
+ log: appendEntry(log, log_entry),
174
174
  };
175
175
  };
176
176
 
@@ -183,7 +183,7 @@ export type RulingOutcome = 'UPHELD' | 'REVERSED' | 'NOTED';
183
183
  export interface RulingInput {
184
184
  readonly sequence: number;
185
185
  readonly at: string;
186
- /** The Speaker. Only AUTHORITY may rule. */
186
+ /** The owner. Only AUTHORITY may rule. */
187
187
  readonly actor: string;
188
188
  readonly role: Role;
189
189
  readonly outcome: RulingOutcome;
@@ -206,23 +206,23 @@ export interface RulingResult {
206
206
  /** CONVENED — the suspension is lifted. */
207
207
  readonly state: SessionStateFile;
208
208
  readonly files: readonly FileWrite[];
209
- readonly hansard: string;
209
+ readonly log: string;
210
210
  }
211
211
 
212
212
  /**
213
- * Commit a Speaker's ruling and resume the session.
213
+ * Commit an owner's ruling and resume the session.
214
214
  *
215
215
  * Two constitutional constraints are enforced rather than assumed:
216
- * - Only AUTHORITY may rule. A Point of Order exists precisely because a
217
- * machine could not make the call; letting a non-Speaker resolve it would
216
+ * - Only AUTHORITY may rule. An escalation exists precisely because a
217
+ * machine could not make the call; letting a non-Owner resolve it would
218
218
  * defeat the mechanism.
219
- * - The session must actually be suspended for a Point of Order. Resuming a
219
+ * - The session must actually be suspended for an escalation. Resuming a
220
220
  * session suspended by a *different* cause would silently discard that cause.
221
221
  */
222
- export const commitRuling = (input: RulingInput, hansard: string): RulingResult => {
222
+ export const commitRuling = (input: RulingInput, log: string): RulingResult => {
223
223
  if (input.role !== 'AUTHORITY') {
224
224
  throw new RulingError(
225
- `only AUTHORITY may rule on a Point of Order — ${input.actor} is ${input.role}`,
225
+ `only AUTHORITY may rule on an escalation — ${input.actor} is ${input.role}`,
226
226
  );
227
227
  }
228
228
  if (input.state.state !== 'SUSPENDED') {
@@ -230,9 +230,9 @@ export const commitRuling = (input: RulingInput, hansard: string): RulingResult
230
230
  `cannot rule on a session in state ${input.state.state} — expected SUSPENDED`,
231
231
  );
232
232
  }
233
- if (input.state.suspension?.cause !== 'POINT_OF_ORDER') {
233
+ if (input.state.suspension?.cause !== 'ESCALATION') {
234
234
  throw new RulingError(
235
- `session is suspended for ${input.state.suspension?.cause ?? 'an unknown cause'}, not POINT_OF_ORDER`,
235
+ `session is suspended for ${input.state.suspension?.cause ?? 'an unknown cause'}, not ESCALATION`,
236
236
  );
237
237
  }
238
238
 
@@ -256,7 +256,7 @@ export const commitRuling = (input: RulingInput, hansard: string): RulingResult
256
256
  protocol: input.state.protocol,
257
257
  state: 'CONVENED',
258
258
  quorum: input.state.quorum,
259
- hansard_head: input.state.hansard_head,
259
+ log_head: input.state.log_head,
260
260
  updated_at: input.at,
261
261
  suspension: null,
262
262
  });
@@ -265,7 +265,7 @@ export const commitRuling = (input: RulingInput, hansard: string): RulingResult
265
265
  ruling_path,
266
266
  state,
267
267
  files: [{ path: ruling_path, content: document }],
268
- hansard: appendEntry(hansard, {
268
+ log: appendEntry(log, {
269
269
  type: 'RULING',
270
270
  at: input.at,
271
271
  actor: input.actor,
@@ -300,7 +300,7 @@ export interface FaultInput {
300
300
  * Render a SESSION_FAULT record in the shape RUNTIME.md specifies.
301
301
  * Critical faults (PATH_C) use the SESSION_FAULT_CRITICAL type.
302
302
  */
303
- export const faultEntry = (input: FaultInput): HansardEntry => ({
303
+ export const faultEntry = (input: FaultInput): RecordEntry => ({
304
304
  type:
305
305
  input.resolution_path === 'PATH_C'
306
306
  ? RECORD_TYPES.SESSION_FAULT_CRITICAL
package/src/fault.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * Fault classification and auto-recovery.
3
3
  *
4
4
  * RUNTIME.md § Infrastructure Fault Classification states the problem exactly:
5
- * a failed action looks identical in the Hansard whether the agent made a bad
5
+ * a failed action looks identical in the record whether the agent made a bad
6
6
  * decision or a secret expired. Without attribution an innocent actor is
7
7
  * penalised — demotion triggers, performance record damaged — for something
8
8
  * entirely outside their control.
@@ -12,14 +12,14 @@
12
12
  *
13
13
  * PATH_A — transient. Retry; no human needed.
14
14
  * PATH_B — a human must fix it. Suspend and escalate.
15
- * PATH_C — irrecoverable. Prorogue.
15
+ * PATH_C — irrecoverable. Close.
16
16
  *
17
17
  * ## On classifying from stderr
18
18
  *
19
19
  * The signals here are heuristics over vendor error text, and they will drift.
20
20
  * That is acceptable because of which way they fail: an unrecognised fault
21
21
  * classifies as `FAULT_AMBIGUOUS`, which does **not** penalise the actor and
22
- * routes to a human. The cost of being wrong is a Speaker reading an error
22
+ * routes to a human. The cost of being wrong is an owner reading an error
23
23
  * message; the cost of guessing confidently would be blaming an actor for an
24
24
  * outage.
25
25
  *
@@ -27,7 +27,7 @@
27
27
  */
28
28
 
29
29
  import type { Role } from './canon.ts';
30
- import { RECORD_TYPES, type HansardEntry } from './hansard.ts';
30
+ import { RECORD_TYPES, type RecordEntry } from './log.ts';
31
31
  import type { SpawnResult } from './spawn.ts';
32
32
 
33
33
  /* -------------------------------------------------------------------------- */
@@ -128,7 +128,7 @@ export const classify = (result: SpawnResult): Classification => {
128
128
  fault_type: 'FAULT_AMBIGUOUS',
129
129
  path: 'PATH_B',
130
130
  actor_penalised: false,
131
- detail: 'cannot determine — escalated to the Speaker for a ruling',
131
+ detail: 'cannot determine — escalated to the owner for a ruling',
132
132
  };
133
133
  };
134
134
 
@@ -200,7 +200,7 @@ export interface FaultRecordInput {
200
200
  }
201
201
 
202
202
  /** Record a fault, with its attribution and resolution path. */
203
- export const faultRecord = (input: FaultRecordInput): HansardEntry => ({
203
+ export const faultRecord = (input: FaultRecordInput): RecordEntry => ({
204
204
  type:
205
205
  input.classification.path === 'PATH_C'
206
206
  ? RECORD_TYPES.SESSION_FAULT_CRITICAL
@@ -228,7 +228,7 @@ export const autoResolvedRecord = (
228
228
  actor: string,
229
229
  role: Role,
230
230
  attempts: number,
231
- ): HansardEntry => ({
231
+ ): RecordEntry => ({
232
232
  type: RECORD_TYPES.FAULT_RESOLVED_AUTO,
233
233
  at,
234
234
  actor,
@@ -236,6 +236,6 @@ export const autoResolvedRecord = (
236
236
  fields: {
237
237
  Resolution: `succeeded on attempt ${attempts}`,
238
238
  'Actor record': 'no penalty — the fault was transient',
239
- 'Speaker intervention': 'none required',
239
+ 'Owner intervention': 'none required',
240
240
  },
241
241
  });
package/src/federation.ts CHANGED
@@ -10,7 +10,7 @@
10
10
  *
11
11
  * The engine stayed storage-agnostic; nothing here changes how a session runs.
12
12
  * Discovery walks directories; everything downstream (buildTree, rollUp,
13
- * detectCascades) is pure and reuses tree.ts, ledger.ts and hansard.ts, so a
13
+ * detectCascades) is pure and reuses tree.ts, ledger.ts and log.ts, so a
14
14
  * node in a federated tree obeys exactly the governance a standalone one does.
15
15
  *
16
16
  * Attribution: Steve Krisjanovs, Cordfuse
@@ -23,7 +23,7 @@ import { join, resolve, relative } from 'node:path';
23
23
  import { parseCharter } from './charter.ts';
24
24
  import { parseState } from './state.ts';
25
25
  import { totals } from './ledger.ts';
26
- import { parseEntries } from './hansard.ts';
26
+ import { parseEntries } from './log.ts';
27
27
  import {
28
28
  checkCascade, DEFAULT_CASCADE, type CascadeAlert, type CascadeConfig, type SiblingFault,
29
29
  } from './tree.ts';
@@ -51,7 +51,7 @@ export interface FederationNode {
51
51
  readonly children: readonly string[];
52
52
  readonly depth: number;
53
53
  /** Raw record, kept for fault and open-Motion scanning. */
54
- readonly hansard: string;
54
+ readonly log: string;
55
55
  }
56
56
 
57
57
  interface RawNode {
@@ -64,7 +64,7 @@ interface RawNode {
64
64
  readonly cost_usd: number;
65
65
  readonly tokens: number;
66
66
  readonly parentDir: string | null;
67
- readonly hansard: string;
67
+ readonly log: string;
68
68
  }
69
69
 
70
70
  /* -------------------------------------------------------------------------- */
@@ -113,7 +113,7 @@ export const readNode = async (dir: string): Promise<RawNode | null> => {
113
113
  const charter = parsed.charter;
114
114
 
115
115
  const ledgerDoc = await readFile(join(dir, charter.ledger.path), 'utf8').catch(() => '');
116
- const hansard = await readFile(join(dir, 'HANSARD.md'), 'utf8').catch(() => '');
116
+ const log = await readFile(join(dir, 'LOG.md'), 'utf8').catch(() => '');
117
117
  const cost = totals(ledgerDoc);
118
118
 
119
119
  // inherits_from is relative to the child; resolve it to the parent's directory.
@@ -129,7 +129,7 @@ export const readNode = async (dir: string): Promise<RawNode | null> => {
129
129
  cost_usd: cost.cost_usd,
130
130
  tokens: cost.tokens,
131
131
  parentDir,
132
- hansard,
132
+ log,
133
133
  };
134
134
  };
135
135
 
@@ -188,7 +188,7 @@ export const buildTree = (raws: readonly RawNode[], root: string): readonly Fede
188
188
  parent: inTree(r.parentDir) ? r.parentDir : null,
189
189
  children: (children.get(r.dir) ?? []).slice().sort(),
190
190
  depth: depthOf(r.dir),
191
- hansard: r.hansard,
191
+ log: r.log,
192
192
  }]),
193
193
  );
194
194
 
@@ -222,16 +222,16 @@ export interface RollUp {
222
222
  readonly by_state: Readonly<Record<string, number>>;
223
223
  readonly total_cost_usd: number;
224
224
  readonly total_tokens: number;
225
- readonly open_divisions: number;
225
+ readonly open_ballots: number;
226
226
  }
227
227
 
228
- /** Motions on the floor: a Division was called and no outcome has been recorded. */
229
- export const openDivisions = (hansard: string): number => {
228
+ /** Motions on the floor: a vote was opened and no outcome has been recorded. */
229
+ export const openBallots = (log: string): number => {
230
230
  const open = new Set<string>();
231
- for (const entry of parseEntries(hansard)) {
231
+ for (const entry of parseEntries(log)) {
232
232
  const motion = entry.fields['Motion'];
233
233
  if (motion === undefined) continue;
234
- if (entry.type === 'DIVISION_CALLED') open.add(motion);
234
+ if (entry.type === 'BALLOT_OPENED') open.add(motion);
235
235
  else if (entry.type === 'MOTION_CARRIED' || entry.type === 'MOTION_REJECTED') open.delete(motion);
236
236
  }
237
237
  return open.size;
@@ -246,14 +246,14 @@ export const rollUp = (nodes: readonly FederationNode[]): RollUp => {
246
246
  by_state[node.state] = (by_state[node.state] ?? 0) + 1;
247
247
  cost += node.cost_usd;
248
248
  tokens += node.tokens;
249
- open += openDivisions(node.hansard);
249
+ open += openBallots(node.log);
250
250
  }
251
251
  return {
252
252
  nodes: nodes.length,
253
253
  by_state,
254
254
  total_cost_usd: cost,
255
255
  total_tokens: tokens,
256
- open_divisions: open,
256
+ open_ballots: open,
257
257
  };
258
258
  };
259
259
 
package/src/git.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  * Committing the record.
3
3
  *
4
- * The Hansard is the session, and this framework's own Standing Orders tell
4
+ * The record is the session, and this framework's own Charter tell
5
5
  * every actor "commit your result; uncommitted work does not exist". That rule
6
6
  * binds the engine too: a governance act written to a file but never committed
7
7
  * has, by the framework's own definition, not happened.
8
8
  *
9
9
  * On a GitHub-backed session `ScmProvider.commit()` lands these writes. Local
10
- * sessions had no equivalent, so the Division and Assent cycle sat dirty in the
10
+ * sessions had no equivalent, so the vote and Enactment cycle sat dirty in the
11
11
  * working tree — a record that did not exist. This module closes that gap.
12
12
  *
13
13
  * Attribution: Steve Krisjanovs, Cordfuse
@@ -48,8 +48,8 @@ const git = (
48
48
  *
49
49
  * Deliberately narrow: only the files named are staged. A governance command
50
50
  * must never sweep up whatever else happens to be dirty in the working tree —
51
- * an actor's half-finished work is not part of the record of a Division, and
52
- * committing it under the Speaker's name would misattribute it.
51
+ * an actor's half-finished work is not part of the record of a vote, and
52
+ * committing it under the owner's name would misattribute it.
53
53
  *
54
54
  * Silent no-ops rather than failures when the directory is not a git
55
55
  * repository: a session can legitimately be exercised outside git (tests,
@@ -58,7 +58,7 @@ const git = (
58
58
  export const commitRecord = async (
59
59
  dir: string,
60
60
  message: string,
61
- paths: readonly string[] = ['HANSARD.md', 'STATE.json'],
61
+ paths: readonly string[] = ['LOG.md', 'STATE.json'],
62
62
  spawnFn: typeof spawn = spawn,
63
63
  opts: { readonly sign?: boolean } = {},
64
64
  ): Promise<CommitResult> => {
@@ -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);
@@ -101,15 +104,15 @@ export const commitRecord = async (
101
104
  };
102
105
 
103
106
  /**
104
- * Make a session's directory record-bearing. Writ Drop "creates the session
107
+ * Make a session's directory record-bearing. session opening "creates the session
105
108
  * repo"; without a repo, `commitRecord` silently no-ops and no act is recorded.
106
109
  *
107
110
  * Two shapes, auto-detected (ADR-0008 — a session is a git-tracked *directory*,
108
111
  * standalone repo or subtree of one):
109
112
  * - **Standalone**: the directory is not yet in a repo → `git init` it and land
110
- * the writ drop, attributed to the Speaker.
113
+ * the session opening, attributed to the owner.
111
114
  * - **Monorepo**: the directory already sits inside a repo (a parent tree, or a
112
- * clone) → commit the writ drop *to that repo* rather than nesting a new one.
115
+ * clone) → commit the session opening *to that repo* rather than nesting a new one.
113
116
  * Per-commit identity, so the enclosing repo's own config is untouched;
114
117
  * no-ops if there is nothing to commit (e.g. a re-run on a clone).
115
118
  *
@@ -117,7 +120,7 @@ export const commitRecord = async (
117
120
  */
118
121
  export const initSessionRepo = async (
119
122
  dir: string,
120
- speaker: string,
123
+ owner: string,
121
124
  guid: string,
122
125
  spawnFn: typeof spawn = spawn,
123
126
  opts: { readonly standalone?: boolean } = {},
@@ -128,23 +131,23 @@ export const initSessionRepo = async (
128
131
  // even inside an enclosing tree — for per-session GitHub projection or a
129
132
  // per-node permission boundary, the two cases standalone mode exists for.
130
133
  if (isRepo.code === 0 && opts.standalone !== true) {
131
- // Monorepo: land the writ drop in the enclosing repo. `add .` stages only
134
+ // Monorepo: land the session opening in the enclosing repo. `add .` stages only
132
135
  // this session's subtree; the per-commit identity attributes it to the
133
- // Speaker without rewriting the parent repo's config. Exclude `*.tmp` — an
136
+ // Owner without rewriting the parent repo's config. Exclude `*.tmp` — an
134
137
  // atomic write interrupted mid-flight can orphan one, and it must never enter
135
138
  // the record.
136
139
  await git(dir, ['add', '.', ':(exclude)*.tmp', ':(exclude).politik/pending'], spawnFn);
137
140
  const commit = await git(
138
141
  dir,
139
- ['-c', `user.name=${speaker}`, '-c', `user.email=${speaker}@politik.local`,
140
- 'commit', '-m', `writ drop: session ${guid}`],
142
+ ['-c', `user.name=${owner}`, '-c', `user.email=${owner}@politik.local`,
143
+ 'commit', '-m', `open: session ${guid}`],
141
144
  spawnFn,
142
145
  );
143
146
  if (commit.code !== 0) {
144
147
  return { committed: false, sha: null, reason: 'existing repository — nothing to commit' };
145
148
  }
146
149
  const sha = await git(dir, ['rev-parse', 'HEAD'], spawnFn);
147
- return { committed: true, sha: sha.out || null, reason: 'writ drop committed to the enclosing repo' };
150
+ return { committed: true, sha: sha.out || null, reason: 'session opening committed to the enclosing repo' };
148
151
  }
149
152
  // A forced standalone inside an enclosing repo nests a fresh repo here — a
150
153
  // deliberate isolation boundary, not the accidental nested `.git` the
@@ -153,10 +156,10 @@ export const initSessionRepo = async (
153
156
  if ((await git(dir, ['init', '-q'], spawnFn)).code !== 0) {
154
157
  return { committed: false, sha: null, reason: 'git unavailable — local directory only' };
155
158
  }
156
- await git(dir, ['config', 'user.name', speaker], spawnFn);
157
- await git(dir, ['config', 'user.email', `${speaker}@politik.local`], spawnFn);
159
+ await git(dir, ['config', 'user.name', owner], spawnFn);
160
+ await git(dir, ['config', 'user.email', `${owner}@politik.local`], spawnFn);
158
161
  await git(dir, ['add', '-A', '.', ':(exclude)*.tmp', ':(exclude).politik/pending'], spawnFn);
159
- const commit = await git(dir, ['commit', '-m', `writ drop: session ${guid}`], spawnFn);
162
+ const commit = await git(dir, ['commit', '-m', `open: session ${guid}`], spawnFn);
160
163
  if (commit.code !== 0) return { committed: false, sha: null, reason: 'repo initialized, nothing to commit' };
161
164
  const sha = await git(dir, ['rev-parse', 'HEAD'], spawnFn);
162
165
  return {