@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/tree.ts CHANGED
@@ -18,7 +18,7 @@
18
18
  */
19
19
 
20
20
  import type { Charter } from './charter.ts';
21
- import { appendEntry, parseEntries, type HansardEntry } from './hansard.ts';
21
+ import { appendEntry, parseEntries, type RecordEntry } from './log.ts';
22
22
  import type { Role } from './canon.ts';
23
23
 
24
24
  /* -------------------------------------------------------------------------- */
@@ -53,7 +53,7 @@ const tighterCeiling = (parent: number | null, child: number | null): number | n
53
53
  * constraint does not fail to load; it runs under the parent's value, and the
54
54
  * attempt is reported so it can be recorded rather than silently corrected.
55
55
  *
56
- * Silent correction would be the worse failure: a Speaker would believe their
56
+ * Silent correction would be the worse failure: an owner would believe their
57
57
  * Charter was in force when it was not.
58
58
  */
59
59
  export const resolveInheritance = (parent: Charter, child: Charter): ResolvedCharter => {
@@ -157,7 +157,7 @@ export const resolveInheritance = (parent: Charter, child: Charter): ResolvedCha
157
157
  /**
158
158
  * Record an inheritance resolution.
159
159
  *
160
- * Committed at the child's Writ Drop so the node's own Hansard states what it
160
+ * Committed at the child's session opening so the node's own record states what it
161
161
  * actually runs under — including any constraint it tried to loosen and did
162
162
  * not get.
163
163
  */
@@ -165,7 +165,7 @@ export const inheritanceEntry = (
165
165
  resolved: ResolvedCharter,
166
166
  parent: string,
167
167
  at: string,
168
- ): HansardEntry => ({
168
+ ): RecordEntry => ({
169
169
  type: 'CHARTER_INHERITED',
170
170
  at,
171
171
  actor: 'RECORD',
@@ -271,11 +271,11 @@ export const checkCascade = (
271
271
  * Record a CASCADE_ALERT on the parent node.
272
272
  *
273
273
  * Warns; does not block. Future sessions chartering the flagged configuration
274
- * receive the warning at Writ Drop and the Speaker may still proceed — but the
274
+ * receive the warning at session opening and the owner may still proceed — but the
275
275
  * risk is documented and attributed, which is the difference between an
276
276
  * informed decision and an unlucky one.
277
277
  */
278
- export const cascadeEntry = (alert: CascadeAlert, at: string): HansardEntry => {
278
+ export const cascadeEntry = (alert: CascadeAlert, at: string): RecordEntry => {
279
279
  if (!alert.triggered) {
280
280
  throw new Error(`no cascade to record — ${alert.reason}`);
281
281
  }
@@ -287,10 +287,10 @@ export const cascadeEntry = (alert: CascadeAlert, at: string): HansardEntry => {
287
287
  fields: {
288
288
  Signature: alert.signature ?? 'unknown',
289
289
  Nodes: alert.nodes.join(', '),
290
- Action: 'warn at Writ Drop for this configuration',
290
+ Action: 'warn at session opening for this configuration',
291
291
  Notify: 'AUTHORITY',
292
292
  },
293
- body: `${alert.reason}. Sessions chartering this configuration will carry this warning. The Speaker may proceed; the risk is on the record.`,
293
+ body: `${alert.reason}. Sessions chartering this configuration will carry this warning. The owner may proceed; the risk is on the record.`,
294
294
  };
295
295
  };
296
296
 
@@ -313,13 +313,13 @@ export interface ScopeMoveInput {
313
313
  *
314
314
  * Recorded at the node where the decision was made — the level that had the
315
315
  * authority to make it. A promotion decided at the sprint node belongs in the
316
- * sprint node's Hansard, not the leaf's, because that is where the
316
+ * sprint node's record, not the leaf's, because that is where the
317
317
  * accountability sits.
318
318
  */
319
319
  export const scopeMove = (
320
320
  input: ScopeMoveInput,
321
321
  direction: 'PROMOTE_SCOPE' | 'DEMOTE_SCOPE',
322
- ): HansardEntry => ({
322
+ ): RecordEntry => ({
323
323
  type: direction,
324
324
  at: input.at,
325
325
  actor: input.actor,
@@ -347,7 +347,7 @@ export const quarantineEntry = (
347
347
  at: string,
348
348
  actor: string,
349
349
  reason: string,
350
- ): HansardEntry => ({
350
+ ): RecordEntry => ({
351
351
  type: 'QUARANTINE',
352
352
  at,
353
353
  actor,
@@ -360,12 +360,12 @@ export const quarantineEntry = (
360
360
  });
361
361
 
362
362
  /** Every cascade alert already on a node's record. */
363
- export const cascadeAlerts = (hansard: string): readonly string[] =>
364
- parseEntries(hansard)
363
+ export const cascadeAlerts = (log: string): readonly string[] =>
364
+ parseEntries(log)
365
365
  .filter((e) => e.type === 'CASCADE_ALERT')
366
366
  .map((e) => e.fields['Signature'] ?? '')
367
367
  .filter((s) => s.length > 0);
368
368
 
369
- /** Append an entry to a node's Hansard. */
370
- export const recordOnNode = (hansard: string, entry: HansardEntry): string =>
371
- appendEntry(hansard, entry);
369
+ /** Append an entry to a node's record. */
370
+ export const recordOnNode = (log: string, entry: RecordEntry): string =>
371
+ appendEntry(log, entry);
@@ -1,28 +0,0 @@
1
- # Adversarial Collaboration — Constitutional + Immutable protocol. Two opposed
2
- # agents pre-commit to a shared design before data, then interpret the result
3
- # under an independent arbitrator. Attribution: Steve Krisjanovs, Cordfuse
4
- protocol:
5
- name: adversarial-collaboration
6
- version: 1.0.0
7
- mode: immutable
8
- record_mode: distributed
9
- roles:
10
- AUTHORITY: Independent Arbitrator
11
- DELEGATE: Opponent Agent
12
- OPERATOR: Proponent Agent
13
- MEMBER: Research Team
14
- OBSERVER: Scientific Community
15
- primitives:
16
- SESSION: Collaboration
17
- CHARTER: Pre-registered Agreement
18
- RECORD: Joint Report
19
- MOTION: Experimental Run
20
- DIVISION: Result Interpretation
21
- ESCALATION: Arbitrator Ruling
22
- SUSPENSION: Joint Publication
23
- EXIT: Protocol Violation
24
- DEADLOCK: Genuinely Ambiguous Result
25
- domain_veto: []
26
- no_escalation: false
27
- no_record: false
28
- immutable_charter: true
@@ -1,35 +0,0 @@
1
- # Corporate / Board — constitutional protocol with a shareholder veto.
2
- # Attribution: Steve Krisjanovs, Cordfuse
3
- protocol:
4
- name: corporate
5
- version: 1.0.0
6
- mode: constitutional
7
- record_mode: anchored
8
-
9
- roles:
10
- AUTHORITY: CEO / Chair
11
- DELEGATE: COO
12
- OPERATOR: VP / Director
13
- MEMBER: Manager
14
- OBSERVER: Shareholder
15
-
16
- primitives:
17
- SESSION: Board Meeting
18
- PROCEEDING: Quarter
19
- CHARTER: Corporate Policy
20
- RECORD: Minutes
21
- MOTION: Proposal
22
- DIVISION: Board Vote
23
- ESCALATION: Escalation to Legal
24
- SUSPENSION: End of Quarter
25
- QUORUM: Quorum
26
- DEADLOCK: Board Deadlock
27
- ASSENT: Resolution Adopted
28
- PROMOTE: Promoted to VP
29
- EXIT: Resigned / Terminated
30
-
31
- domain_veto:
32
- - OBSERVER
33
- no_escalation: false
34
- no_record: false
35
- immutable_charter: false
@@ -1,41 +0,0 @@
1
- # Elimination Tournament (Single) — Darwinist protocol.
2
- #
3
- # Losers exit permanently; there are no second chances. Appeals exist as a
4
- # protest to the Director, so escalation stays enabled.
5
- # Attribution: Steve Krisjanovs, Cordfuse
6
- protocol:
7
- name: elimination-tournament
8
- version: 1.0.0
9
- mode: darwinist
10
- record_mode: anchored
11
-
12
- roles:
13
- AUTHORITY: Tournament Director
14
- DELEGATE: Deputy Director
15
- OPERATOR: Team Captain
16
- MEMBER: Competitor
17
- OBSERVER: Spectator
18
-
19
- primitives:
20
- SESSION: Tournament
21
- PROCEEDING: Tournament
22
- CHARTER: Tournament Rules
23
- RECORD: Bracket
24
- MOTION: Match
25
- DIVISION: Match Result
26
- ESCALATION: Protest / Appeal
27
- SUSPENSION: Bye Round
28
- QUORUM: Minimum Entrants
29
- DEADLOCK: Tiebreaker Round
30
- ASSENT: Result Certified
31
- EXIT: Eliminated — bracket closes
32
-
33
- domain_veto: []
34
- no_escalation: false
35
- no_record: false
36
- immutable_charter: true
37
-
38
- mechanics:
39
- resolution: majority
40
- exit: elimination
41
- termination: last-standing
@@ -1,27 +0,0 @@
1
- # Emergency Response / ICS — Authoritarian protocol; the Safety Officer can
2
- # override the Incident Commander on safety (a domain veto carve-out).
3
- # Attribution: Steve Krisjanovs, Cordfuse
4
- protocol:
5
- name: emergency-response-ics
6
- version: 1.0.0
7
- mode: authoritarian
8
- record_mode: anchored
9
- roles:
10
- AUTHORITY: Incident Commander
11
- DELEGATE: Operations Section Chief
12
- OPERATOR: Division Supervisor
13
- MEMBER: Unit Leader
14
- OBSERVER: Safety Officer
15
- primitives:
16
- SESSION: Incident
17
- CHARTER: ICS Protocol
18
- RECORD: Incident Action Plan
19
- MOTION: Tactical Assignment
20
- ESCALATION: Safety Officer Override
21
- SUSPENSION: Demobilization
22
- EXIT: Relieved
23
- domain_veto:
24
- - OBSERVER
25
- no_escalation: false
26
- no_record: false
27
- immutable_charter: false
@@ -1,32 +0,0 @@
1
- # Jury Deliberation — Constitutional protocol. The canonical Jury: it deliberates
2
- # until unanimous, then delivers a verdict and rises (ADR-0007). Deliberations are
3
- # sealed in practice; the record toggle is not modelled here.
4
- # Attribution: Steve Krisjanovs, Cordfuse
5
- protocol:
6
- name: jury-deliberation
7
- version: 1.0.0
8
- mode: constitutional
9
- record_mode: distributed
10
- roles:
11
- AUTHORITY: Foreperson
12
- DELEGATE: Deputy Foreperson
13
- OPERATOR: Senior Juror
14
- MEMBER: Juror
15
- OBSERVER: Court Officer
16
- primitives:
17
- SESSION: Deliberation
18
- CHARTER: Jury Instructions
19
- MOTION: Argument
20
- DIVISION: Verdict Vote
21
- ESCALATION: Note to Judge
22
- SUSPENSION: Recess
23
- EXIT: Dismissed
24
- DEADLOCK: Hung Jury
25
- domain_veto: []
26
- no_escalation: false
27
- no_record: false
28
- immutable_charter: false
29
- mechanics:
30
- resolution: unanimity
31
- exit: none
32
- termination: verdict
@@ -1,31 +0,0 @@
1
- # Monarchy — Authoritarian protocol with constitutional elements.
2
- #
3
- # The Crown is AUTHORITY; a Petition may be raised and appealed to the Crown.
4
- #
5
- # Attribution: Steve Krisjanovs, Cordfuse
6
- protocol:
7
- name: monarchy
8
- version: 1.0.0
9
- mode: authoritarian
10
- record_mode: anchored
11
-
12
- roles:
13
- AUTHORITY: The Crown
14
- DELEGATE: Lord Chancellor
15
- OPERATOR: Lord
16
- MEMBER: Knight
17
- OBSERVER: Commoner
18
-
19
- primitives:
20
- SESSION: Royal Court
21
- CHARTER: Royal Decree
22
- RECORD: Royal Chronicle
23
- MOTION: Petition
24
- DIVISION: Royal Assent
25
- ESCALATION: Appeal to the Crown
26
- EXIT: Banished
27
-
28
- domain_veto: []
29
- no_escalation: false
30
- no_record: false
31
- immutable_charter: false
@@ -1,66 +0,0 @@
1
- # Parliamentary Democracy — protocol #1, the reference protocol.
2
- #
3
- # Parliamentary is not a privileged mode. It is the first protocol shipped, and
4
- # every other industry vocabulary is equally a protocol on top of the same CANON
5
- # engine. Nothing in this file changes engine behaviour except the four declared
6
- # flags at the bottom.
7
- #
8
- # Install as `.politik/protocol.yml` in a session repo.
9
- #
10
- # Attribution: Steve Krisjanovs, Cordfuse
11
-
12
- protocol:
13
- name: parliamentary
14
- version: 1.0.0
15
-
16
- # Constitutional: checks and balances, escalation paths, human override.
17
- mode: constitutional
18
-
19
- # Distributed: per-commit attribution is guaranteed, which is why a Charter
20
- # under this protocol may not use merge_strategy: squash (ADR-0002 rule 5).
21
- record_mode: distributed
22
-
23
- roles:
24
- AUTHORITY: Speaker
25
- DELEGATE: Deputy Speaker
26
- OPERATOR: Minister
27
- MEMBER: Backbencher
28
- OBSERVER: Gallery
29
-
30
- primitives:
31
- SESSION: Parliament
32
- PROCEEDING: Parliament
33
- CHARTER: Standing Orders
34
- RECORD: Hansard
35
- MOTION: Tabled Motion
36
- DIVISION: Division
37
- ESCALATION: Point of Order
38
- SUSPENSION: Adjournment
39
- QUORUM: Quorum
40
- CONFLICT: Competing Amendments
41
- DEADLOCK: Hung Parliament
42
-
43
- # Verbs
44
- ASSENT: Royal Assent
45
- VOTE: Cast a Vote
46
- ESCALATE: Raise a Point of Order
47
- PROMOTE: Appointed to Cabinet
48
- DEMOTE: Returned to Backbench
49
- SUSPEND: Suspend the Sitting
50
- EXPEL: Expel from the House
51
- VETO: Veto
52
- SPAWN: Refer to Committee
53
- DISSOLVE: Prorogation
54
- EXIT: Resigned from the House
55
-
56
- # No role holds a domain veto under the reference protocol.
57
- domain_veto: []
58
-
59
- # Constitutional protocols permit appeals.
60
- no_escalation: false
61
-
62
- # The Hansard is required.
63
- no_record: false
64
-
65
- # Standing Orders may be amended mid-session by the Speaker.
66
- immutable_charter: false
@@ -1,44 +0,0 @@
1
- # Peer Review — constitutional protocol for scientific research.
2
- #
3
- # The Statistical Reviewer holds a DOMAIN_VETO: methodology alone can reject a
4
- # submission, regardless of the Division. Reviewer identities are sealed by the
5
- # Charter (`operator_identity: anonymous`), which is what makes honest
6
- # assessment the equilibrium.
7
- # Attribution: Steve Krisjanovs, Cordfuse
8
- protocol:
9
- name: peer-review
10
- version: 1.0.0
11
- mode: constitutional
12
- record_mode: anchored
13
-
14
- roles:
15
- AUTHORITY: Editor / Programme Chair
16
- DELEGATE: Associate Editor
17
- OPERATOR: Reviewer
18
- MEMBER: Author
19
- OBSERVER: Scientific Community
20
-
21
- primitives:
22
- SESSION: Review Cycle
23
- PROCEEDING: Review Cycle
24
- CHARTER: Review Criteria
25
- RECORD: Decision Log
26
- MOTION: Submission
27
- DIVISION: Accept / Reject / Major Revision
28
- ESCALATION: Appeal to Editor-in-Chief
29
- SUSPENSION: Decision Issued
30
- QUORUM: Minimum Reviewers
31
- DEADLOCK: Split Decision — additional reviewer assigned
32
- ASSENT: Decision Issued
33
- EXIT: Withdrawn / Desk Rejected
34
-
35
- domain_veto:
36
- - OPERATOR
37
- no_escalation: false
38
- no_record: false
39
- immutable_charter: false
40
-
41
- mechanics:
42
- resolution: majority
43
- exit: division
44
- termination: verdict
@@ -1,36 +0,0 @@
1
- # Republic (US-style) — Constitutional protocol.
2
- #
3
- # Checks and balances with a strong executive veto. The Filibuster is the
4
- # escalation path; a Government Shutdown is the deadlock. AUTHORITY (President)
5
- # already holds VETO as a constitutional power, so no domain_veto is declared.
6
- #
7
- # Attribution: Steve Krisjanovs, Cordfuse
8
- protocol:
9
- name: republic
10
- version: 1.0.0
11
- mode: constitutional
12
- record_mode: distributed
13
-
14
- roles:
15
- AUTHORITY: President
16
- DELEGATE: Vice President
17
- OPERATOR: Senator
18
- MEMBER: Representative
19
- OBSERVER: Constituent
20
-
21
- primitives:
22
- SESSION: Congress
23
- CHARTER: Constitution
24
- RECORD: Congressional Record
25
- MOTION: Bill
26
- DIVISION: Vote
27
- ESCALATION: Filibuster
28
- SUSPENSION: Recess
29
- DEADLOCK: Government Shutdown
30
- VETO: Presidential Veto
31
- EXIT: Impeached or Resigned
32
-
33
- domain_veto: []
34
- no_escalation: false
35
- no_record: false
36
- immutable_charter: false
@@ -1,31 +0,0 @@
1
- # Socialism / Collective — Authoritarian protocol.
2
- #
3
- # Collective in theory, party in practice: the Party Chair is AUTHORITY and the
4
- # Party Record is anchored to it. A Party Challenge is the escalation path.
5
- #
6
- # Attribution: Steve Krisjanovs, Cordfuse
7
- protocol:
8
- name: socialism-collective
9
- version: 1.0.0
10
- mode: authoritarian
11
- record_mode: anchored
12
-
13
- roles:
14
- AUTHORITY: Party Chair
15
- DELEGATE: Deputy Chair
16
- OPERATOR: Comrade Commissar
17
- MEMBER: Worker Delegate
18
- OBSERVER: Civilian
19
-
20
- primitives:
21
- SESSION: Collective
22
- RECORD: Party Record
23
- MOTION: Party Directive
24
- ESCALATION: Party Challenge
25
- DEADLOCK: Party Purge
26
- EXIT: Purged
27
-
28
- domain_veto: []
29
- no_escalation: false
30
- no_record: false
31
- immutable_charter: false
@@ -1,32 +0,0 @@
1
- # Solo / Casual — the light entry point. Minimal ceremony for one person or a
2
- # small team: quorum 1, no elimination, escalation available but rarely needed.
3
- # You get the one thing nobody else gives you — a trustworthy, attributed,
4
- # cost-tracked record — with as little governance as the moment demands. Scale
5
- # up to a fuller protocol when the stakes or the numbers do.
6
- #
7
- # Attribution: Steve Krisjanovs, Cordfuse
8
- protocol:
9
- name: solo
10
- version: 1.0.0
11
- mode: constitutional
12
- record_mode: distributed
13
- roles:
14
- AUTHORITY: Lead
15
- DELEGATE: Co-lead
16
- OPERATOR: Maintainer
17
- MEMBER: Contributor
18
- OBSERVER: Watcher
19
- primitives:
20
- SESSION: Session
21
- CHARTER: Working Agreement
22
- RECORD: Log
23
- MOTION: Proposal
24
- DIVISION: Vote
25
- ESCALATION: Flag
26
- SUSPENSION: Paused
27
- EXIT: Left
28
- DEADLOCK: Stuck
29
- domain_veto: []
30
- no_escalation: false
31
- no_record: false
32
- immutable_charter: false