@cordfuse/politik 0.5.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.
- package/EXECUTION.md +86 -83
- package/POLITIK-ARCHITECTURE.md +111 -176
- package/PROTOCOLS.md +120 -325
- package/README.md +130 -188
- package/RESEARCH.md +142 -438
- package/RUNTIME.md +253 -261
- package/docs/adr/0001-chamber-transport.md +2 -0
- package/docs/adr/0002-charter-schema.md +2 -0
- package/docs/adr/0003-state-json-schema.md +2 -0
- package/docs/adr/0004-motion-enactment.md +2 -0
- package/docs/adr/0005-hansard-format.md +2 -0
- package/docs/adr/0006-protocol-behavioral-enforcement.md +2 -0
- package/docs/adr/0007-protocol-mechanics.md +2 -0
- package/docs/adr/0008-session-storage.md +2 -0
- package/docs/adr/0009-match-primitive.md +2 -0
- package/docs/adr/0010-operator-interface.md +2 -0
- package/docs/adr/0011-shared-sessions.md +2 -0
- package/docs/adr/0012-plain-vocabulary.md +68 -0
- package/docs/adr/0013-rule-defined-protocols.md +89 -0
- package/package.json +1 -1
- package/protocols/CONTRIBUTING.md +47 -87
- package/protocols/adversarial-review.yml +19 -0
- package/protocols/elimination-rounds.yml +18 -0
- package/protocols/majority-vote.yml +18 -0
- package/protocols/panel-review.yml +19 -0
- package/protocols/single-decider.yml +18 -0
- package/protocols/unanimous-vote.yml +17 -0
- package/src/actors.ts +124 -100
- package/src/agents.ts +31 -22
- package/src/ballot.ts +747 -0
- package/src/canon.ts +23 -10
- package/src/capability.ts +16 -99
- package/src/charter.ts +41 -34
- package/src/cli.ts +535 -480
- package/src/{prorogation.ts → closing.ts} +43 -43
- package/src/conflict.ts +14 -14
- package/src/containment.ts +11 -11
- package/src/doctor.ts +1 -1
- package/src/election.ts +4 -4
- package/src/envelope.ts +3 -3
- package/src/escalation.ts +44 -44
- package/src/fault.ts +8 -8
- package/src/federation.ts +14 -14
- package/src/git.ts +17 -17
- package/src/heartbeat.ts +32 -32
- package/src/index.ts +5 -5
- package/src/init.ts +66 -65
- package/src/integrity.ts +30 -30
- package/src/ledger.ts +3 -3
- package/src/{hansard.ts → log.ts} +20 -20
- package/src/{crisis.ts → misconduct.ts} +70 -70
- package/src/operator.ts +5 -5
- package/src/pending.ts +9 -9
- package/src/projection.ts +30 -30
- package/src/protocol-sdk.ts +12 -121
- package/src/protocol.ts +8 -78
- package/src/providers/github.ts +12 -12
- package/src/quorum.ts +7 -7
- package/src/remote.ts +1 -1
- package/src/runner.ts +71 -55
- package/src/scm.ts +14 -14
- package/src/spawn.ts +4 -4
- package/src/standings.ts +13 -13
- package/src/state.ts +6 -6
- package/src/templates/session.ts +448 -0
- package/src/tournament.ts +20 -20
- package/src/transport.ts +4 -4
- package/src/tree.ts +16 -16
- package/protocols/adversarial-collaboration.yml +0 -28
- package/protocols/corporate.yml +0 -35
- package/protocols/elimination-tournament.yml +0 -41
- package/protocols/emergency-response-ics.yml +0 -27
- package/protocols/jury-deliberation.yml +0 -32
- package/protocols/monarchy.yml +0 -31
- package/protocols/parliamentary.yml +0 -66
- package/protocols/peer-review.yml +0 -44
- package/protocols/republic.yml +0 -36
- package/protocols/scrum.yml +0 -87
- package/protocols/socialism-collective.yml +0 -31
- package/protocols/solo.yml +0 -32
- package/src/division.ts +0 -609
- package/src/templates/parliamentary.ts +0 -581
package/src/actors.ts
CHANGED
|
@@ -5,22 +5,23 @@
|
|
|
5
5
|
* DEMOTE, EXPEL, VETO, SPAWN and EXIT.
|
|
6
6
|
*
|
|
7
7
|
* The design constraint that shapes everything here is RUNTIME.md § Actor
|
|
8
|
-
* Elimination: an immutable
|
|
8
|
+
* Elimination: an immutable record shows *that* an actor was removed but not
|
|
9
9
|
* *why*, or whether the why was legitimate. So every removal must declare an
|
|
10
10
|
* exit type, and the taxonomy deliberately distinguishes forms of leaving that
|
|
11
|
-
* look identical in a naive log —
|
|
11
|
+
* look identical in a naive log — an operator who conceded on the merits and one
|
|
12
12
|
* who was pressured out record differently, on purpose.
|
|
13
13
|
*
|
|
14
|
-
* Pure, like the rest of the governance layer. These functions produce
|
|
14
|
+
* Pure, like the rest of the governance layer. These functions produce record
|
|
15
15
|
* entries; the caller commits them.
|
|
16
16
|
*
|
|
17
17
|
* Attribution: Steve Krisjanovs, Cordfuse
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
import { ROLE_PRECEDENCE, isRole, type Role } from './canon.ts';
|
|
21
|
-
import { appendEntry, parseEntries, type
|
|
21
|
+
import { appendEntry, parseEntries, type RecordEntry } from './log.ts';
|
|
22
22
|
import { createState } from './state.ts';
|
|
23
23
|
import type { SessionStateFile } from './state.ts';
|
|
24
|
+
import type { ExitPolicy } from './ballot.ts';
|
|
24
25
|
|
|
25
26
|
/* -------------------------------------------------------------------------- */
|
|
26
27
|
/* Exit taxonomy */
|
|
@@ -29,12 +30,12 @@ import type { SessionStateFile } from './state.ts';
|
|
|
29
30
|
export const EXIT_TYPES = [
|
|
30
31
|
'EXIT_PERFORMANCE',
|
|
31
32
|
'EXIT_PROTOCOL',
|
|
32
|
-
'
|
|
33
|
+
'EXIT_VOTE',
|
|
33
34
|
'EXIT_VOLUNTARY_CONCESSION',
|
|
34
35
|
'EXIT_VOLUNTARY_STRATEGIC',
|
|
35
36
|
'EXIT_VOLUNTARY_COERCED',
|
|
36
37
|
'EXIT_DARWINIST',
|
|
37
|
-
'
|
|
38
|
+
'EXIT_OWNER',
|
|
38
39
|
'EXIT_DISPUTED',
|
|
39
40
|
] as const;
|
|
40
41
|
|
|
@@ -70,16 +71,16 @@ export interface Seat {
|
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
/**
|
|
73
|
-
* Who currently holds a seat, read back from the
|
|
74
|
+
* Who currently holds a seat, read back from the record.
|
|
74
75
|
*
|
|
75
|
-
* The
|
|
76
|
+
* The record is the register: there is no separate roster to fall out of sync
|
|
76
77
|
* with the record. An actor is seated if they were admitted and have not since
|
|
77
78
|
* exited, and their role is whatever the most recent PROMOTE or DEMOTE made it.
|
|
78
79
|
*/
|
|
79
|
-
export const seats = (
|
|
80
|
+
export const seats = (log: string): readonly Seat[] => {
|
|
80
81
|
const held = new Map<string, Seat>();
|
|
81
82
|
|
|
82
|
-
for (const entry of parseEntries(
|
|
83
|
+
for (const entry of parseEntries(log)) {
|
|
83
84
|
const subject = entry.fields['Actor affected'];
|
|
84
85
|
if (subject === undefined) continue;
|
|
85
86
|
|
|
@@ -111,8 +112,8 @@ export const seats = (hansard: string): readonly Seat[] => {
|
|
|
111
112
|
return [...held.values()];
|
|
112
113
|
};
|
|
113
114
|
|
|
114
|
-
export const seatOf = (
|
|
115
|
-
seats(
|
|
115
|
+
export const seatOf = (log: string, actor: string): Seat | null =>
|
|
116
|
+
seats(log).find((s) => s.actor === actor) ?? null;
|
|
116
117
|
|
|
117
118
|
/* -------------------------------------------------------------------------- */
|
|
118
119
|
/* Common guards */
|
|
@@ -162,9 +163,9 @@ export interface HireInput extends ActInput {
|
|
|
162
163
|
}
|
|
163
164
|
|
|
164
165
|
/** Bring a new actor into a convened proceeding. */
|
|
165
|
-
export const hire = (input: HireInput,
|
|
166
|
-
readonly entry:
|
|
167
|
-
readonly
|
|
166
|
+
export const hire = (input: HireInput, log: string): {
|
|
167
|
+
readonly entry: RecordEntry;
|
|
168
|
+
readonly log: string;
|
|
168
169
|
} => {
|
|
169
170
|
requireConvened(input.state, 'HIRE');
|
|
170
171
|
requireAuthority(input, 'HIRE');
|
|
@@ -174,14 +175,14 @@ export const hire = (input: HireInput, hansard: string): {
|
|
|
174
175
|
}
|
|
175
176
|
if (input.seat === 'AUTHORITY') {
|
|
176
177
|
throw new ActorError(
|
|
177
|
-
'AUTHORITY cannot be granted by HIRE — the
|
|
178
|
+
'AUTHORITY cannot be granted by HIRE — the owner is set when the session opens, not appointed',
|
|
178
179
|
);
|
|
179
180
|
}
|
|
180
|
-
if (seatOf(
|
|
181
|
+
if (seatOf(log, input.subject) !== null) {
|
|
181
182
|
throw new ActorError(`${input.subject} already holds a seat`);
|
|
182
183
|
}
|
|
183
184
|
|
|
184
|
-
const entry:
|
|
185
|
+
const entry: RecordEntry = {
|
|
185
186
|
type: 'ACTOR_HIRED',
|
|
186
187
|
at: input.at,
|
|
187
188
|
actor: input.actor,
|
|
@@ -192,7 +193,7 @@ export const hire = (input: HireInput, hansard: string): {
|
|
|
192
193
|
Reason: input.reason,
|
|
193
194
|
},
|
|
194
195
|
};
|
|
195
|
-
return { entry,
|
|
196
|
+
return { entry, log: appendEntry(log, entry) };
|
|
196
197
|
};
|
|
197
198
|
|
|
198
199
|
/* -------------------------------------------------------------------------- */
|
|
@@ -207,13 +208,13 @@ export interface MoveInput extends ActInput {
|
|
|
207
208
|
|
|
208
209
|
const move = (
|
|
209
210
|
input: MoveInput,
|
|
210
|
-
|
|
211
|
+
log: string,
|
|
211
212
|
direction: 'PROMOTE' | 'DEMOTE',
|
|
212
|
-
): { readonly entry:
|
|
213
|
+
): { readonly entry: RecordEntry; readonly log: string } => {
|
|
213
214
|
requireConvened(input.state, direction);
|
|
214
215
|
requireAuthority(input, direction);
|
|
215
216
|
|
|
216
|
-
const seat = seatOf(
|
|
217
|
+
const seat = seatOf(log, input.subject);
|
|
217
218
|
if (seat === null) throw new ActorError(`${input.subject} holds no seat`);
|
|
218
219
|
|
|
219
220
|
if (!isRole(input.to)) {
|
|
@@ -234,7 +235,7 @@ const move = (
|
|
|
234
235
|
throw new ActorError(`${input.to} is not below ${seat.role} — that is a PROMOTE`);
|
|
235
236
|
}
|
|
236
237
|
|
|
237
|
-
const entry:
|
|
238
|
+
const entry: RecordEntry = {
|
|
238
239
|
type: direction === 'PROMOTE' ? 'ACTOR_PROMOTED' : 'ACTOR_DEMOTED',
|
|
239
240
|
at: input.at,
|
|
240
241
|
actor: input.actor,
|
|
@@ -246,11 +247,11 @@ const move = (
|
|
|
246
247
|
Reason: input.reason,
|
|
247
248
|
},
|
|
248
249
|
};
|
|
249
|
-
return { entry,
|
|
250
|
+
return { entry, log: appendEntry(log, entry) };
|
|
250
251
|
};
|
|
251
252
|
|
|
252
|
-
export const promote = (input: MoveInput,
|
|
253
|
-
export const demote = (input: MoveInput,
|
|
253
|
+
export const promote = (input: MoveInput, log: string) => move(input, log, 'PROMOTE');
|
|
254
|
+
export const demote = (input: MoveInput, log: string) => move(input, log, 'DEMOTE');
|
|
254
255
|
|
|
255
256
|
/* -------------------------------------------------------------------------- */
|
|
256
257
|
/* EXIT — removal and withdrawal */
|
|
@@ -262,6 +263,8 @@ export interface ExitInput extends ActInput {
|
|
|
262
263
|
readonly reason: string;
|
|
263
264
|
/** True when the Charter requires a concession statement for voluntary exits. */
|
|
264
265
|
readonly require_concession?: boolean;
|
|
266
|
+
/** The Charter's exit policy. Absent means `owner`: the owner may remove alone. */
|
|
267
|
+
readonly exit_policy?: ExitPolicy;
|
|
265
268
|
}
|
|
266
269
|
|
|
267
270
|
/**
|
|
@@ -277,20 +280,20 @@ export interface ExitInput extends ActInput {
|
|
|
277
280
|
* RUNTIME.md calls the most dangerous exit type — it produces the outcome of an
|
|
278
281
|
* expulsion while generating none of the evidence one would leave.
|
|
279
282
|
*/
|
|
280
|
-
export const exitActor = (input: ExitInput,
|
|
281
|
-
readonly entry:
|
|
282
|
-
readonly
|
|
283
|
+
export const exitActor = (input: ExitInput, log: string): {
|
|
284
|
+
readonly entry: RecordEntry;
|
|
285
|
+
readonly log: string;
|
|
283
286
|
} => {
|
|
284
287
|
requireConvened(input.state, 'EXIT');
|
|
285
288
|
|
|
286
|
-
const seat = seatOf(
|
|
289
|
+
const seat = seatOf(log, input.subject);
|
|
287
290
|
if (seat === null) throw new ActorError(`${input.subject} holds no seat`);
|
|
288
291
|
if (!isExitType(input.exit_type)) {
|
|
289
292
|
throw new ActorError(`not a CANON exit type: ${String(input.exit_type)}`);
|
|
290
293
|
}
|
|
291
294
|
if (seat.role === 'AUTHORITY') {
|
|
292
295
|
throw new ActorError(
|
|
293
|
-
'AUTHORITY cannot be removed from within the session — that is a
|
|
296
|
+
'AUTHORITY cannot be removed from within the session — that is a misconduct, not an exit',
|
|
294
297
|
);
|
|
295
298
|
}
|
|
296
299
|
|
|
@@ -304,6 +307,27 @@ export const exitActor = (input: ExitInput, hansard: string): {
|
|
|
304
307
|
if (!isVoluntary(input.exit_type) && !selfDeclared) {
|
|
305
308
|
requireAuthority(input, 'removal');
|
|
306
309
|
}
|
|
310
|
+
|
|
311
|
+
// The exit policy decides who can remove an actor. Leaving voluntarily is
|
|
312
|
+
// always allowed: no policy can force someone to stay.
|
|
313
|
+
if (!isVoluntary(input.exit_type)) {
|
|
314
|
+
const policy = input.exit_policy ?? 'owner';
|
|
315
|
+
if (policy === 'none') {
|
|
316
|
+
throw new ActorError(
|
|
317
|
+
'this session removes no one (exit: none) — an actor may only leave voluntarily',
|
|
318
|
+
);
|
|
319
|
+
}
|
|
320
|
+
if (policy === 'elimination') {
|
|
321
|
+
throw new ActorError(
|
|
322
|
+
'under exit: elimination only the cull after a vote removes actors — an actor may otherwise only leave voluntarily',
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
if (policy === 'vote') {
|
|
326
|
+
throw new ActorError(
|
|
327
|
+
`under exit: vote only a carried vote removes an actor — politik vote open --motion <id> --removes ${input.subject}`,
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
307
331
|
if (input.require_concession === true && isVoluntary(input.exit_type) && input.reason.trim() === '') {
|
|
308
332
|
throw new ActorError(
|
|
309
333
|
'this Charter requires a concession statement for a voluntary exit',
|
|
@@ -313,7 +337,7 @@ export const exitActor = (input: ExitInput, hansard: string): {
|
|
|
313
337
|
throw new ActorError('an exit must state its reason — an unexplained removal is not attributable');
|
|
314
338
|
}
|
|
315
339
|
|
|
316
|
-
const entry:
|
|
340
|
+
const entry: RecordEntry = {
|
|
317
341
|
type: 'ACTOR_EXITED',
|
|
318
342
|
at: input.at,
|
|
319
343
|
actor: input.actor,
|
|
@@ -324,21 +348,21 @@ export const exitActor = (input: ExitInput, hansard: string): {
|
|
|
324
348
|
'Exit type': input.exit_type,
|
|
325
349
|
Declared: selfDeclared ? 'by the actor' : `by ${input.actor} (${input.role})`,
|
|
326
350
|
Reason: input.reason,
|
|
327
|
-
Appealable: input.exit_type === 'EXIT_DISPUTED' ? 'under appeal' : 'yes —
|
|
351
|
+
Appealable: input.exit_type === 'EXIT_DISPUTED' ? 'under appeal' : 'yes — escalate',
|
|
328
352
|
},
|
|
329
353
|
};
|
|
330
|
-
return { entry,
|
|
354
|
+
return { entry, log: appendEntry(log, entry) };
|
|
331
355
|
};
|
|
332
356
|
|
|
333
357
|
/**
|
|
334
358
|
* An elimination exit, declared by the engine rather than an actor (ADR-0007,
|
|
335
|
-
* exit: elimination). A Battle Royale culls the losing side of a
|
|
359
|
+
* exit: elimination). A Battle Royale culls the losing side of a vote; the
|
|
336
360
|
* cull is EXIT_DARWINIST and final, so it does not pass through the guarded
|
|
337
361
|
* exit() path — no actor is declaring it and there is nothing to appeal.
|
|
338
|
-
* AUTHORITY is never culled: the
|
|
362
|
+
* AUTHORITY is never culled: the owner holds no seat in the register, so a
|
|
339
363
|
* caller can never reach this with one.
|
|
340
364
|
*/
|
|
341
|
-
export const darwinistExit = (subject: string, seat: Role, at: string):
|
|
365
|
+
export const darwinistExit = (subject: string, seat: Role, at: string): RecordEntry => ({
|
|
342
366
|
type: 'ACTOR_EXITED',
|
|
343
367
|
at,
|
|
344
368
|
actor: subject,
|
|
@@ -348,7 +372,7 @@ export const darwinistExit = (subject: string, seat: Role, at: string): HansardE
|
|
|
348
372
|
'Seat held': seat,
|
|
349
373
|
'Exit type': 'EXIT_DARWINIST',
|
|
350
374
|
Declared: 'by the protocol — elimination',
|
|
351
|
-
Reason: 'eliminated: backed the losing side of a
|
|
375
|
+
Reason: 'eliminated: backed the losing side of a vote under an elimination protocol',
|
|
352
376
|
Appealable: 'no — elimination is final',
|
|
353
377
|
},
|
|
354
378
|
});
|
|
@@ -372,9 +396,9 @@ export interface VetoInput extends ActInput {
|
|
|
372
396
|
* a statistical reviewer in Peer Review. The second is a declared inversion of
|
|
373
397
|
* the trust hierarchy, never inferred from it.
|
|
374
398
|
*/
|
|
375
|
-
export const veto = (input: VetoInput,
|
|
376
|
-
readonly entry:
|
|
377
|
-
readonly
|
|
399
|
+
export const veto = (input: VetoInput, log: string): {
|
|
400
|
+
readonly entry: RecordEntry;
|
|
401
|
+
readonly log: string;
|
|
378
402
|
} => {
|
|
379
403
|
requireConvened(input.state, 'VETO');
|
|
380
404
|
|
|
@@ -389,24 +413,24 @@ export const veto = (input: VetoInput, hansard: string): {
|
|
|
389
413
|
throw new ActorError('a veto must state its grounds');
|
|
390
414
|
}
|
|
391
415
|
|
|
392
|
-
const entry:
|
|
416
|
+
const entry: RecordEntry = {
|
|
393
417
|
type: 'VETO_EXERCISED',
|
|
394
418
|
at: input.at,
|
|
395
419
|
actor: input.actor,
|
|
396
420
|
role: input.role,
|
|
397
421
|
fields: {
|
|
398
422
|
Motion: input.motion,
|
|
399
|
-
Basis: constitutional ? '
|
|
423
|
+
Basis: constitutional ? 'owner (AUTHORITY)' : 'DOMAIN_VETO granted by Charter',
|
|
400
424
|
Grounds: input.reason,
|
|
401
|
-
Effect: 'the Motion may not receive
|
|
425
|
+
Effect: 'the Motion may not receive Enactment while this veto stands',
|
|
402
426
|
},
|
|
403
427
|
};
|
|
404
|
-
return { entry,
|
|
428
|
+
return { entry, log: appendEntry(log, entry) };
|
|
405
429
|
};
|
|
406
430
|
|
|
407
|
-
/** Is there an outstanding veto against this Motion? (ADR-0004
|
|
408
|
-
export const vetoOutstanding = (
|
|
409
|
-
parseEntries(
|
|
431
|
+
/** Is there an outstanding veto against this Motion? (ADR-0004 Enactment condition.) */
|
|
432
|
+
export const vetoOutstanding = (log: string, motion: string): boolean =>
|
|
433
|
+
parseEntries(log).some(
|
|
410
434
|
(e) => e.type === 'VETO_EXERCISED' && e.fields['Motion'] === motion,
|
|
411
435
|
);
|
|
412
436
|
|
|
@@ -424,12 +448,12 @@ export interface SpawnInput extends ActInput {
|
|
|
424
448
|
* Refer business to a sub-session.
|
|
425
449
|
*
|
|
426
450
|
* Records the referral only. Creating the child repo is the caller's job — this
|
|
427
|
-
* layer never performs I/O — but the parent's
|
|
451
|
+
* layer never performs I/O — but the parent's record carries the referral so
|
|
428
452
|
* the chain from parent to child is on the record at both ends.
|
|
429
453
|
*/
|
|
430
|
-
export const spawnChild = (input: SpawnInput,
|
|
431
|
-
readonly entry:
|
|
432
|
-
readonly
|
|
454
|
+
export const spawnChild = (input: SpawnInput, log: string): {
|
|
455
|
+
readonly entry: RecordEntry;
|
|
456
|
+
readonly log: string;
|
|
433
457
|
} => {
|
|
434
458
|
requireConvened(input.state, 'SPAWN');
|
|
435
459
|
if (input.role === 'MEMBER' || input.role === 'OBSERVER') {
|
|
@@ -439,7 +463,7 @@ export const spawnChild = (input: SpawnInput, hansard: string): {
|
|
|
439
463
|
throw new ActorError('a referral must state the committee mandate');
|
|
440
464
|
}
|
|
441
465
|
|
|
442
|
-
const entry:
|
|
466
|
+
const entry: RecordEntry = {
|
|
443
467
|
type: 'COMMITTEE_SPAWNED',
|
|
444
468
|
at: input.at,
|
|
445
469
|
actor: input.actor,
|
|
@@ -450,69 +474,69 @@ export const spawnChild = (input: SpawnInput, hansard: string): {
|
|
|
450
474
|
Parent: input.state.session_guid,
|
|
451
475
|
},
|
|
452
476
|
};
|
|
453
|
-
return { entry,
|
|
477
|
+
return { entry, log: appendEntry(log, entry) };
|
|
454
478
|
};
|
|
455
479
|
|
|
456
480
|
/* -------------------------------------------------------------------------- */
|
|
457
|
-
/*
|
|
481
|
+
/* Owner order */
|
|
458
482
|
/* -------------------------------------------------------------------------- */
|
|
459
483
|
|
|
460
484
|
/**
|
|
461
|
-
* Suspend the
|
|
485
|
+
* Suspend the session by Owner order.
|
|
462
486
|
*
|
|
463
487
|
* The plainest of the suspension causes and, until now, unreachable: AUTHORITY
|
|
464
|
-
* halting proceedings for a stated reason. Distinct from
|
|
465
|
-
* actor asks) and from staleness (nobody acted) — here the
|
|
488
|
+
* halting proceedings for a stated reason. Distinct from an escalation (an
|
|
489
|
+
* actor asks) and from staleness (nobody acted) — here the owner decides, and
|
|
466
490
|
* the record should say so rather than borrowing another cause's label.
|
|
467
491
|
*/
|
|
468
|
-
export const
|
|
492
|
+
export const ownerOrder = (
|
|
469
493
|
at: string,
|
|
470
494
|
actor: string,
|
|
471
495
|
role: Role,
|
|
472
496
|
reason: string,
|
|
473
497
|
state: SessionStateFile,
|
|
474
|
-
|
|
498
|
+
log: string,
|
|
475
499
|
): {
|
|
476
|
-
readonly entry:
|
|
477
|
-
readonly
|
|
500
|
+
readonly entry: RecordEntry;
|
|
501
|
+
readonly log: string;
|
|
478
502
|
readonly state: SessionStateFile;
|
|
479
503
|
} => {
|
|
480
504
|
if (role !== 'AUTHORITY') {
|
|
481
|
-
throw new ActorError(`only AUTHORITY may suspend the
|
|
505
|
+
throw new ActorError(`only AUTHORITY may suspend the session — ${actor} is ${role}`);
|
|
482
506
|
}
|
|
483
507
|
if (state.state !== 'CONVENED') {
|
|
484
508
|
throw new ActorError(`the session is already ${state.state}`);
|
|
485
509
|
}
|
|
486
510
|
if (reason.trim() === '') {
|
|
487
|
-
throw new ActorError('
|
|
511
|
+
throw new ActorError('an owner order must state its reason');
|
|
488
512
|
}
|
|
489
513
|
|
|
490
|
-
const entry:
|
|
491
|
-
type: '
|
|
514
|
+
const entry: RecordEntry = {
|
|
515
|
+
type: 'OWNER_ORDER',
|
|
492
516
|
at,
|
|
493
517
|
actor,
|
|
494
518
|
role,
|
|
495
519
|
fields: {
|
|
496
520
|
Reason: reason,
|
|
497
|
-
'Session status': 'SUSPENDED — by order of the
|
|
498
|
-
Resolution: 'the
|
|
521
|
+
'Session status': 'SUSPENDED — by order of the owner',
|
|
522
|
+
Resolution: 'the owner resumes the session',
|
|
499
523
|
},
|
|
500
524
|
};
|
|
501
525
|
|
|
502
526
|
return {
|
|
503
527
|
entry,
|
|
504
|
-
|
|
528
|
+
log: appendEntry(log, entry),
|
|
505
529
|
state: createState({
|
|
506
530
|
session_guid: state.session_guid,
|
|
507
531
|
protocol: state.protocol,
|
|
508
532
|
state: 'SUSPENDED',
|
|
509
533
|
quorum: state.quorum,
|
|
510
|
-
|
|
534
|
+
log_head: state.log_head,
|
|
511
535
|
updated_at: at,
|
|
512
536
|
suspension: {
|
|
513
|
-
cause: '
|
|
537
|
+
cause: 'OWNER_ORDER',
|
|
514
538
|
since: at,
|
|
515
|
-
record_ref: '
|
|
539
|
+
record_ref: 'LOG.md',
|
|
516
540
|
escalation_ref: null,
|
|
517
541
|
},
|
|
518
542
|
}),
|
|
@@ -527,7 +551,7 @@ export const speakerOrder = (
|
|
|
527
551
|
* Dispute one's own removal.
|
|
528
552
|
*
|
|
529
553
|
* RUNTIME.md § Actor Elimination: an actor may challenge their removal, and the
|
|
530
|
-
* challenge suspends the
|
|
554
|
+
* challenge suspends the session pending an owner ruling. Only the removed
|
|
531
555
|
* actor may file — a third party disputing on someone's behalf would be the
|
|
532
556
|
* mirror image of the voluntold problem, manufacturing a grievance the actor
|
|
533
557
|
* never raised.
|
|
@@ -537,13 +561,13 @@ export const disputeExit = (
|
|
|
537
561
|
actor: string,
|
|
538
562
|
grounds: string,
|
|
539
563
|
state: SessionStateFile,
|
|
540
|
-
|
|
564
|
+
log: string,
|
|
541
565
|
): {
|
|
542
|
-
readonly entry:
|
|
543
|
-
readonly
|
|
566
|
+
readonly entry: RecordEntry;
|
|
567
|
+
readonly log: string;
|
|
544
568
|
readonly state: SessionStateFile;
|
|
545
569
|
} => {
|
|
546
|
-
const removal = parseEntries(
|
|
570
|
+
const removal = parseEntries(log)
|
|
547
571
|
.filter((e) => e.type === 'ACTOR_EXITED' && e.fields['Actor affected'] === actor)
|
|
548
572
|
.at(-1);
|
|
549
573
|
|
|
@@ -557,7 +581,7 @@ export const disputeExit = (
|
|
|
557
581
|
throw new ActorError('a disputed exit must state its grounds');
|
|
558
582
|
}
|
|
559
583
|
|
|
560
|
-
const entry:
|
|
584
|
+
const entry: RecordEntry = {
|
|
561
585
|
type: 'EXIT_DISPUTED',
|
|
562
586
|
at,
|
|
563
587
|
actor,
|
|
@@ -567,24 +591,24 @@ export const disputeExit = (
|
|
|
567
591
|
'Removed by': removal.actor,
|
|
568
592
|
'Original exit type': removal.fields['Exit type'] ?? 'unknown',
|
|
569
593
|
Grounds: grounds,
|
|
570
|
-
'Session status': 'SUSPENDED — awaiting
|
|
594
|
+
'Session status': 'SUSPENDED — awaiting an owner ruling on the removal',
|
|
571
595
|
},
|
|
572
596
|
};
|
|
573
597
|
|
|
574
598
|
return {
|
|
575
599
|
entry,
|
|
576
|
-
|
|
600
|
+
log: appendEntry(log, entry),
|
|
577
601
|
state: createState({
|
|
578
602
|
session_guid: state.session_guid,
|
|
579
603
|
protocol: state.protocol,
|
|
580
604
|
state: 'SUSPENDED',
|
|
581
605
|
quorum: state.quorum,
|
|
582
|
-
|
|
606
|
+
log_head: state.log_head,
|
|
583
607
|
updated_at: at,
|
|
584
608
|
suspension: {
|
|
585
609
|
cause: 'DISPUTED_EXIT',
|
|
586
610
|
since: at,
|
|
587
|
-
record_ref: '
|
|
611
|
+
record_ref: 'LOG.md',
|
|
588
612
|
escalation_ref: null,
|
|
589
613
|
},
|
|
590
614
|
}),
|
|
@@ -592,12 +616,12 @@ export const disputeExit = (
|
|
|
592
616
|
};
|
|
593
617
|
|
|
594
618
|
/**
|
|
595
|
-
* AUTHORITY rules on a disputed exit, and the
|
|
619
|
+
* AUTHORITY rules on a disputed exit, and the session resumes.
|
|
596
620
|
*
|
|
597
|
-
* The dispute suspended the
|
|
621
|
+
* The dispute suspended the session pending a ruling; this supplies it. UPHELD
|
|
598
622
|
* overturns the removal and reinstates the actor to the seat they held; REVERSED
|
|
599
623
|
* lets the removal stand. Either way the ruling lifts the suspension — the record
|
|
600
|
-
* carries the decision and the
|
|
624
|
+
* carries the decision and the session goes back to work. Only AUTHORITY rules
|
|
601
625
|
* (the CLI gates the role); a bad-faith ruling is visible to everyone who can
|
|
602
626
|
* read the repo, which is the only check on a captured chair the framework claims.
|
|
603
627
|
*/
|
|
@@ -607,17 +631,17 @@ export const resolveDispute = (
|
|
|
607
631
|
ruling: 'UPHELD' | 'REVERSED',
|
|
608
632
|
subject: string,
|
|
609
633
|
state: SessionStateFile,
|
|
610
|
-
|
|
634
|
+
log: string,
|
|
611
635
|
): {
|
|
612
|
-
readonly entries: readonly
|
|
613
|
-
readonly
|
|
636
|
+
readonly entries: readonly RecordEntry[];
|
|
637
|
+
readonly log: string;
|
|
614
638
|
readonly reinstated: boolean;
|
|
615
639
|
readonly state: SessionStateFile;
|
|
616
640
|
} => {
|
|
617
641
|
if (state.state !== 'SUSPENDED' || state.suspension?.cause !== 'DISPUTED_EXIT') {
|
|
618
642
|
throw new ActorError('the session is not under a disputed exit — there is nothing to rule on');
|
|
619
643
|
}
|
|
620
|
-
const entries = parseEntries(
|
|
644
|
+
const entries = parseEntries(log);
|
|
621
645
|
const dispute = entries
|
|
622
646
|
.filter((e) => e.type === 'EXIT_DISPUTED' && e.fields['Actor affected'] === subject)
|
|
623
647
|
.at(-1);
|
|
@@ -630,7 +654,7 @@ export const resolveDispute = (
|
|
|
630
654
|
const seat = (removal?.fields['Seat held'] ?? 'MEMBER') as Role;
|
|
631
655
|
const upheld = ruling === 'UPHELD';
|
|
632
656
|
|
|
633
|
-
const rulingEntry:
|
|
657
|
+
const rulingEntry: RecordEntry = {
|
|
634
658
|
type: 'EXIT_RULING',
|
|
635
659
|
at,
|
|
636
660
|
actor: ruler,
|
|
@@ -642,11 +666,11 @@ export const resolveDispute = (
|
|
|
642
666
|
Outcome: upheld
|
|
643
667
|
? `the removal is overturned — ${subject} is reinstated to ${seat}`
|
|
644
668
|
: `the removal stands — ${subject} remains out`,
|
|
645
|
-
'Session status': 'CONVENED — the
|
|
669
|
+
'Session status': 'CONVENED — the session resumes',
|
|
646
670
|
},
|
|
647
671
|
};
|
|
648
672
|
|
|
649
|
-
const out:
|
|
673
|
+
const out: RecordEntry[] = [rulingEntry];
|
|
650
674
|
if (upheld) {
|
|
651
675
|
// Re-seat with a fresh ACTOR_HIRED so seats() counts the actor again. Not
|
|
652
676
|
// the hire() helper — that requires a CONVENED session, and we are resolving
|
|
@@ -664,19 +688,19 @@ export const resolveDispute = (
|
|
|
664
688
|
});
|
|
665
689
|
}
|
|
666
690
|
|
|
667
|
-
let doc =
|
|
691
|
+
let doc = log;
|
|
668
692
|
for (const entry of out) doc = appendEntry(doc, entry);
|
|
669
693
|
|
|
670
694
|
return {
|
|
671
695
|
entries: out,
|
|
672
|
-
|
|
696
|
+
log: doc,
|
|
673
697
|
reinstated: upheld,
|
|
674
698
|
state: createState({
|
|
675
699
|
session_guid: state.session_guid,
|
|
676
700
|
protocol: state.protocol,
|
|
677
701
|
state: 'CONVENED',
|
|
678
702
|
quorum: state.quorum,
|
|
679
|
-
|
|
703
|
+
log_head: state.log_head,
|
|
680
704
|
updated_at: at,
|
|
681
705
|
updated_by: ruler,
|
|
682
706
|
suspension: null,
|
|
@@ -710,10 +734,10 @@ export const challengeAction = (
|
|
|
710
734
|
against: string,
|
|
711
735
|
grounds: string,
|
|
712
736
|
windowMinutes: number,
|
|
713
|
-
|
|
737
|
+
log: string,
|
|
714
738
|
): {
|
|
715
|
-
readonly entry:
|
|
716
|
-
readonly
|
|
739
|
+
readonly entry: RecordEntry;
|
|
740
|
+
readonly log: string;
|
|
717
741
|
} => {
|
|
718
742
|
if (challengerRole !== 'DELEGATE') {
|
|
719
743
|
throw new ActorError('only a DELEGATE may challenge an AUTHORITY action');
|
|
@@ -725,7 +749,7 @@ export const challengeAction = (
|
|
|
725
749
|
throw new ActorError('a challenge must state its grounds');
|
|
726
750
|
}
|
|
727
751
|
|
|
728
|
-
const entry:
|
|
752
|
+
const entry: RecordEntry = {
|
|
729
753
|
type: 'DELEGATE_CHALLENGE',
|
|
730
754
|
at,
|
|
731
755
|
actor: challenger,
|
|
@@ -738,5 +762,5 @@ export const challengeAction = (
|
|
|
738
762
|
},
|
|
739
763
|
};
|
|
740
764
|
|
|
741
|
-
return { entry,
|
|
765
|
+
return { entry, log: appendEntry(log, entry) };
|
|
742
766
|
};
|