@cordfuse/politik 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/EXECUTION.md +766 -0
- package/LICENSE +21 -0
- package/POLITIK-ARCHITECTURE.md +676 -0
- package/PROTOCOLS.md +1106 -0
- package/README.md +193 -0
- package/RESEARCH.md +475 -0
- package/RUNTIME.md +1355 -0
- package/bin/politik.js +31 -0
- package/docs/adr/0001-chamber-transport.md +67 -0
- package/docs/adr/0002-charter-schema.md +142 -0
- package/docs/adr/0003-state-json-schema.md +134 -0
- package/docs/adr/0004-motion-enactment.md +215 -0
- package/docs/adr/0005-hansard-format.md +171 -0
- package/docs/adr/0006-protocol-behavioral-enforcement.md +89 -0
- package/docs/adr/0007-protocol-mechanics.md +100 -0
- package/docs/adr/0008-session-storage.md +108 -0
- package/docs/adr/0009-match-primitive.md +74 -0
- package/package.json +55 -0
- package/protocols/CONTRIBUTING.md +130 -0
- package/protocols/adversarial-collaboration.yml +28 -0
- package/protocols/corporate.yml +35 -0
- package/protocols/elimination-tournament.yml +41 -0
- package/protocols/emergency-response-ics.yml +27 -0
- package/protocols/jury-deliberation.yml +32 -0
- package/protocols/monarchy.yml +31 -0
- package/protocols/parliamentary.yml +66 -0
- package/protocols/peer-review.yml +44 -0
- package/protocols/republic.yml +36 -0
- package/protocols/socialism-collective.yml +31 -0
- package/protocols/solo.yml +32 -0
- package/src/actors.ts +742 -0
- package/src/agents.ts +318 -0
- package/src/canon.ts +173 -0
- package/src/capability.ts +336 -0
- package/src/charter.ts +545 -0
- package/src/cli.ts +2174 -0
- package/src/conflict.ts +211 -0
- package/src/containment.ts +155 -0
- package/src/crisis.ts +381 -0
- package/src/division.ts +609 -0
- package/src/doctor.ts +168 -0
- package/src/election.ts +233 -0
- package/src/envelope.ts +223 -0
- package/src/escalation.ts +320 -0
- package/src/fault.ts +241 -0
- package/src/federation.ts +299 -0
- package/src/git.ts +163 -0
- package/src/hansard.ts +201 -0
- package/src/heartbeat.ts +282 -0
- package/src/index.ts +43 -0
- package/src/init.ts +396 -0
- package/src/integrity.ts +153 -0
- package/src/ledger.ts +341 -0
- package/src/lockfs.ts +58 -0
- package/src/projection.ts +293 -0
- package/src/prorogation.ts +307 -0
- package/src/protocol-sdk.ts +248 -0
- package/src/protocol.ts +241 -0
- package/src/providers/github.ts +347 -0
- package/src/quorum.ts +137 -0
- package/src/runner.ts +534 -0
- package/src/scm.ts +142 -0
- package/src/spawn.ts +160 -0
- package/src/standings.ts +143 -0
- package/src/state.ts +179 -0
- package/src/templates/parliamentary.ts +359 -0
- package/src/tournament.ts +200 -0
- package/src/transport.ts +190 -0
- package/src/tree.ts +371 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# ADR-0005 — Hansard Format
|
|
2
|
+
|
|
3
|
+
**Attribution:** Steve Krisjanovs, Cordfuse
|
|
4
|
+
|
|
5
|
+
**Status:** Accepted
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Context
|
|
10
|
+
|
|
11
|
+
`HANSARD.md` is the append-only attributed record of a proceeding. It is the
|
|
12
|
+
durable truth of a Politik session: transport may drop a broadcast, an agent may
|
|
13
|
+
die mid-task, a lockfile may go stale — none of that loses anything, because the
|
|
14
|
+
Hansard is the session.
|
|
15
|
+
|
|
16
|
+
No document specified its format. What existed was a consistent *record shape*
|
|
17
|
+
shown by three worked examples in `RUNTIME.md` (`SESSION_FAULT`,
|
|
18
|
+
`FAULT_RESOLVED`, `SESSION_FAULT_CRITICAL`):
|
|
19
|
+
|
|
20
|
+
```markdown
|
|
21
|
+
# SESSION_FAULT
|
|
22
|
+
|
|
23
|
+
**Actor:** OPERATOR-1
|
|
24
|
+
**Fault type:** FAULT_INFRA
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
a record-type heading followed by bold-label fields. `EXECUTION.md` § Phase 4
|
|
28
|
+
listed "Hansard format spec" as an open deliverable.
|
|
29
|
+
|
|
30
|
+
The Phase 2 reference implementation (`src/hansard.ts`) had to write records
|
|
31
|
+
before this ADR existed. It followed the worked examples and marked two choices
|
|
32
|
+
as provisional, pending this decision. This ADR settles them.
|
|
33
|
+
|
|
34
|
+
## Decision
|
|
35
|
+
|
|
36
|
+
**A Hansard is one markdown document: a preamble, then append-only entries.**
|
|
37
|
+
|
|
38
|
+
```markdown
|
|
39
|
+
# HANSARD
|
|
40
|
+
|
|
41
|
+
Append-only attributed record of this proceeding. The RECORD agent writes;
|
|
42
|
+
no actor edits an entry once committed.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## 2026-04-08T14:02:11Z — WRIT_DROP
|
|
47
|
+
|
|
48
|
+
**Actor:** speaker-handle (AUTHORITY)
|
|
49
|
+
|
|
50
|
+
Writ dropped. Session 0f9c1b3e convened under the attached Charter.
|
|
51
|
+
|
|
52
|
+
## 2026-04-08T14:04:00Z — SESSION_FAULT
|
|
53
|
+
|
|
54
|
+
**Actor:** OPERATOR-1 (OPERATOR)
|
|
55
|
+
**Action attempted:** Deploy authentication module to staging
|
|
56
|
+
**Fault type:** FAULT_INFRA
|
|
57
|
+
**Actor penalised:** No — infrastructure fault, actor blameless
|
|
58
|
+
**Resolution path:** PATH_B
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Ruling 1 — entries are H2, not H1
|
|
62
|
+
|
|
63
|
+
The RUNTIME.md examples show `# SESSION_FAULT`. Those examples describe a
|
|
64
|
+
record's *shape* in isolation, not its position in a file.
|
|
65
|
+
|
|
66
|
+
`HANSARD.md` opens with a `# HANSARD` title. A document whose body is a run of
|
|
67
|
+
sibling H1s does not read as one record — it reads as many documents
|
|
68
|
+
concatenated, and every markdown renderer, table-of-contents generator and
|
|
69
|
+
GitHub anchor treats it that way.
|
|
70
|
+
|
|
71
|
+
**Ruling: the document title is H1; every entry is H2.** The RUNTIME.md examples
|
|
72
|
+
remain correct as descriptions of an entry's fields; they were never file
|
|
73
|
+
layouts.
|
|
74
|
+
|
|
75
|
+
### Ruling 2 — the entry heading carries timestamp and type
|
|
76
|
+
|
|
77
|
+
Format: `## <ISO-8601 UTC> — <RECORD_TYPE>`
|
|
78
|
+
|
|
79
|
+
Both facts are needed to locate an entry, and putting them in the heading makes
|
|
80
|
+
the record navigable by anchor and greppable by either axis without parsing
|
|
81
|
+
fields. Timestamp first, so that lexical order is chronological order.
|
|
82
|
+
|
|
83
|
+
### Ruling 3 — record types are an open set
|
|
84
|
+
|
|
85
|
+
The source documents name `WRIT_DROP`, `SESSION_INVALID`, `SESSION_FAULT`,
|
|
86
|
+
`SESSION_FAULT_CRITICAL`, `FAULT_RESOLVED`, `FAULT_RESOLVED_AUTO`,
|
|
87
|
+
`ACTOR_STATE`, `SESSION_TIMEOUT`, `POINT_OF_ORDER`, `RULING`, `CASCADE_ALERT`,
|
|
88
|
+
`QUARANTINE`, `RESTRUCTURE`, `PROMOTE_SCOPE`, `DEMOTE_SCOPE` and
|
|
89
|
+
`STATE_SNAPSHOT` — and never declare the set complete.
|
|
90
|
+
|
|
91
|
+
**Ruling: `type` is an open string, not a closed enum.** A protocol may record
|
|
92
|
+
events CANON never anticipated; that is the point of a protocol layer. Known
|
|
93
|
+
types are exported as constants for convenience, not as a constraint.
|
|
94
|
+
|
|
95
|
+
Record types are always written in CANON, never in protocol vocabulary. A
|
|
96
|
+
Parliamentary session records `POINT_OF_ORDER`, not "Point of Order". Vocabulary
|
|
97
|
+
translation is a presentation concern; the record must stay machine-comparable
|
|
98
|
+
across protocols, which is what makes the research layer possible at all.
|
|
99
|
+
|
|
100
|
+
### Ruling 4 — attribution is mandatory
|
|
101
|
+
|
|
102
|
+
Every entry carries `**Actor:** <handle> (<CANON ROLE>)` as its first field. An
|
|
103
|
+
unattributed record is not a Hansard record, and the writer must refuse to
|
|
104
|
+
produce one rather than emit an anonymous entry. Same for the record type and
|
|
105
|
+
the timestamp.
|
|
106
|
+
|
|
107
|
+
The role is recorded **as at the time of the act**, not as at read time. Actors
|
|
108
|
+
are promoted and demoted mid-session; a record that rendered a current role
|
|
109
|
+
would silently rewrite history.
|
|
110
|
+
|
|
111
|
+
### Ruling 5 — fields are single-line; prose goes in the body
|
|
112
|
+
|
|
113
|
+
Fields render as `**Key:** value` and are single-line. A field value that spanned
|
|
114
|
+
lines would be indistinguishable from the prose body on read-back, and the
|
|
115
|
+
Hansard's value depends on being unambiguously parseable years later.
|
|
116
|
+
|
|
117
|
+
Long-form content belongs in the entry body, which follows the fields after a
|
|
118
|
+
blank line. Field order is insertion order and is preserved.
|
|
119
|
+
|
|
120
|
+
### Ruling 6 — append-only is mechanical, not conventional
|
|
121
|
+
|
|
122
|
+
A Hansard writer must produce a new document that contains the previous document
|
|
123
|
+
**verbatim as a prefix**. This is stronger than "don't edit entries": it makes
|
|
124
|
+
tampering a diff that cannot hide.
|
|
125
|
+
|
|
126
|
+
Enforcement is the implementation's job, not a matter of discipline. The
|
|
127
|
+
reference implementation is tested by appending N entries and asserting every
|
|
128
|
+
intermediate revision remains a prefix of the final document.
|
|
129
|
+
|
|
130
|
+
Git is the second line of defence, not the first — `HANSARD.md → Append only,
|
|
131
|
+
never edited` (POLITIK-ARCHITECTURE.md § FILE OWNERSHIP) is a Standing Order,
|
|
132
|
+
and a force-push that rewrites it is itself visible in the reflog.
|
|
133
|
+
|
|
134
|
+
### Ruling 7 — the Hansard is authoritative; readers are best-effort
|
|
135
|
+
|
|
136
|
+
`parseEntries()` exists so a record can be audited and asserted against. It is
|
|
137
|
+
explicitly best-effort: a document written by an older implementation, or by a
|
|
138
|
+
future protocol extension, may parse partially.
|
|
139
|
+
|
|
140
|
+
**Reading is never authoritative. Git history is.** No engine decision may
|
|
141
|
+
depend on a parse succeeding — `STATE.json` carries `hansard_head` precisely so
|
|
142
|
+
a resumed agent can detect a state file that lags the record without having to
|
|
143
|
+
re-read the whole Hansard.
|
|
144
|
+
|
|
145
|
+
## Consequences
|
|
146
|
+
|
|
147
|
+
- `src/hansard.ts` needs no change. Both provisional Phase 2 choices — H2
|
|
148
|
+
entries and an open type set — are ratified as specified above.
|
|
149
|
+
- Phase 8.5's Obsidian layer can rely on a stable anchor per entry
|
|
150
|
+
(`#YYYY-MM-DDTHHMMSSZ--RECORD_TYPE`).
|
|
151
|
+
- The research layer can compare records across protocols, because record types
|
|
152
|
+
are CANON and never translated.
|
|
153
|
+
- A future format change requires a superseding ADR and a migration note; the
|
|
154
|
+
preamble is the natural place to carry a format version if one becomes
|
|
155
|
+
necessary. None is added now — a version field nobody reads is noise.
|
|
156
|
+
|
|
157
|
+
## Alternatives rejected
|
|
158
|
+
|
|
159
|
+
**YAML frontmatter per entry.** Machine-cleanest, but a Hansard is read by
|
|
160
|
+
humans during an escalation and by clinicians of the record after the fact.
|
|
161
|
+
Markdown that renders on GitHub without tooling is worth more than parse
|
|
162
|
+
convenience, and the field format is already unambiguous.
|
|
163
|
+
|
|
164
|
+
**One file per entry (`hansard/NNN.md`).** Trivially append-only and
|
|
165
|
+
merge-friendly. Rejected because the Hansard's readability as a single narrative
|
|
166
|
+
is its point — a reviewer reconstructing how a decision was made should scroll,
|
|
167
|
+
not `ls`. Cascade-level records across the Politik Tree already live in separate
|
|
168
|
+
per-node Hansards.
|
|
169
|
+
|
|
170
|
+
**JSON Lines.** Excellent for the LEDGER, wrong for the record. The Hansard
|
|
171
|
+
carries reasoning, not just events.
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# ADR-0006 — Protocol Behavioral Enforcement
|
|
2
|
+
|
|
3
|
+
**Attribution:** Steve Krisjanovs, Cordfuse
|
|
4
|
+
|
|
5
|
+
**Status:** Accepted
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Context
|
|
10
|
+
|
|
11
|
+
A protocol is a vocabulary-translation manifest over CANON, plus a small set of
|
|
12
|
+
behavioral flags: `mode` (`constitutional` | `authoritarian` | `darwinist` |
|
|
13
|
+
`ephemeral` | `immutable`), and `no_escalation`, `no_record`,
|
|
14
|
+
`immutable_charter`, `domain_veto`. Ten protocol manifests ship in
|
|
15
|
+
`protocols/*.yml`, five of them game-theory shapes (Battle Royale, Elimination
|
|
16
|
+
Tournament, League Season, Red/Blue Team, Peer Review).
|
|
17
|
+
|
|
18
|
+
The vocabulary half works: `roleTerm`/`term` translate CANON into a protocol's
|
|
19
|
+
words for the interface and the record. The behavioral half did not. The flags
|
|
20
|
+
were declared on the `Protocol` type, checked for internal coherence by the SDK
|
|
21
|
+
linter, and shipped in every manifest — but **no engine module ever read them**.
|
|
22
|
+
The predicates written for exactly this purpose (`allowsEscalation`,
|
|
23
|
+
`keepsRecord`, `allowsCharterAmendment`) were exported and never called.
|
|
24
|
+
|
|
25
|
+
The consequence: a `battle-royale` session and a `parliamentary` session ran
|
|
26
|
+
byte-for-byte identical mechanics, differing only in the words written to the
|
|
27
|
+
Hansard. A Darwinist protocol that declares "no appeals" still accepted them.
|
|
28
|
+
The thesis that different governance structures change how a chamber behaves was,
|
|
29
|
+
at the engine level, unimplemented — and a declared-but-inert flag is worse than
|
|
30
|
+
an absent one, because a reader trusts it.
|
|
31
|
+
|
|
32
|
+
`domain_veto` is the exception that shows the intended pattern: it is declared in
|
|
33
|
+
the Charter and enforced by the engine (`actors.ts` veto). The other behavioral
|
|
34
|
+
declarations should work the same way.
|
|
35
|
+
|
|
36
|
+
## Decision
|
|
37
|
+
|
|
38
|
+
**The Charter is the runtime authority for behavioral settings, and the engine
|
|
39
|
+
enforces them — matching `domain_veto`.** A protocol manifest still declares the
|
|
40
|
+
same flags for SDK coherence, but a running session enforces the Charter's copy,
|
|
41
|
+
because a session is one repository and must be self-contained.
|
|
42
|
+
|
|
43
|
+
**Scope is the flags that already exist and have a real enforcement point. It
|
|
44
|
+
explicitly excludes game-theory mechanics.** Elimination, tournament brackets,
|
|
45
|
+
scoring, and Nash-equilibrium behavior are not built here; they remain the
|
|
46
|
+
RESEARCH.md experimental agenda. `mode: darwinist` is a bundle of behavioral
|
|
47
|
+
flags, not a distinct engine.
|
|
48
|
+
|
|
49
|
+
### Wired now — `session.escalation`
|
|
50
|
+
|
|
51
|
+
The Charter already carries `session.escalation: 'enabled' | 'disabled'` (the
|
|
52
|
+
`no_escalation` flag by another name), previously enforced only in `tree.ts`
|
|
53
|
+
inheritance tightening. When a Charter declares it `disabled`, the engine now
|
|
54
|
+
refuses every escalation path:
|
|
55
|
+
|
|
56
|
+
- the CLI `escalate` command refuses;
|
|
57
|
+
- `fileEscalation` throws, so no caller can raise a Point of Order;
|
|
58
|
+
- during an agent turn, a file written under `escalations/` no longer suspends
|
|
59
|
+
the sitting — a protocol with no appeals has no mechanism to resolve one, so
|
|
60
|
+
the turn is recorded and the session stays live rather than deadlocking in a
|
|
61
|
+
suspension it cannot lift.
|
|
62
|
+
|
|
63
|
+
This is what makes a Darwinist chamber behave like one: a decision stands, and an
|
|
64
|
+
actor that dislikes it exits rather than appeals.
|
|
65
|
+
|
|
66
|
+
### Identified but not wired — and why
|
|
67
|
+
|
|
68
|
+
- **`no_record`** has no Charter field and contradicts the core invariant that
|
|
69
|
+
the Hansard *is* the session (POLITIK-ARCHITECTURE.md). An ephemeral chamber is
|
|
70
|
+
a real design question — what is a session with no record? — not a flag to flip.
|
|
71
|
+
- **`immutable_charter`** has no Charter field and no runtime charter-amendment
|
|
72
|
+
command to guard. There is nothing to refuse yet.
|
|
73
|
+
|
|
74
|
+
Both remain protocol-manifest metadata consumed only by the SDK's coherence
|
|
75
|
+
linter until a design exists. Recording them here keeps the gap explicit rather
|
|
76
|
+
than silent.
|
|
77
|
+
|
|
78
|
+
## Consequences
|
|
79
|
+
|
|
80
|
+
- Protocols that declare `session.escalation: disabled` — the Darwinist and
|
|
81
|
+
elimination shapes — now behave distinctly from Parliament, not just in
|
|
82
|
+
vocabulary.
|
|
83
|
+
- PROTOCOLS.md still describes elimination and Nash-equilibrium mechanics this
|
|
84
|
+
ADR does not build. A separate documentation pass must trim those claims to
|
|
85
|
+
what the engine enforces, or the credibility gap moves from the code to the
|
|
86
|
+
docs.
|
|
87
|
+
- The pattern is now uniform: a behavioral setting lives in the Charter, is
|
|
88
|
+
enforced by the engine, and is declared redundantly on the protocol manifest
|
|
89
|
+
for SDK coherence. Future flags follow this path.
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# ADR-0007 — Protocol Mechanics (Composable Behavioral Strategies)
|
|
2
|
+
|
|
3
|
+
**Attribution:** Steve Krisjanovs, Cordfuse
|
|
4
|
+
|
|
5
|
+
**Status:** Accepted
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Context
|
|
10
|
+
|
|
11
|
+
ADR-0006 wired the first protocol behavioral flag (`session.escalation`) into the
|
|
12
|
+
engine. It closed a credibility gap but not the central one: protocols still
|
|
13
|
+
share one set of *mechanics*. A Battle Royale and a Jury run the same Division
|
|
14
|
+
tally, the same exit rules, the same termination — they differ only in vocabulary
|
|
15
|
+
and whether appeals are allowed. The framework's thesis is that different
|
|
16
|
+
governance structures produce different behavior; a protocol layer that only
|
|
17
|
+
relabels words does not deliver it.
|
|
18
|
+
|
|
19
|
+
Two tempting answers are both wrong for Politik:
|
|
20
|
+
|
|
21
|
+
**An engine per protocol.** Subclass or fork the engine for each protocol. This
|
|
22
|
+
destroys the one thing Politik sells. The immutable Hansard, the audit trail, the
|
|
23
|
+
guarantees — all of it comes from a *single shared engine*. Forty-three engines is
|
|
24
|
+
forty-three codebases, forty-three sets of bugs, and no common trustworthy record.
|
|
25
|
+
The shared engine is not the enemy of unique protocols; it is what makes a unique
|
|
26
|
+
protocol trustable.
|
|
27
|
+
|
|
28
|
+
**Prose as the referee.** Describe each protocol's behavior in natural language
|
|
29
|
+
and have Politik interpret it at decision time. This trades away determinism —
|
|
30
|
+
and determinism *is* auditability. The moment "did the Motion carry?" depends on a
|
|
31
|
+
model's reading of a sentence, the Hansard can assert an outcome no one can
|
|
32
|
+
reproduce. A referee must be a rule, not a reading.
|
|
33
|
+
|
|
34
|
+
The correct model separates the **referee** (deterministic code) from the
|
|
35
|
+
**rulebook** (prose for humans and agents):
|
|
36
|
+
|
|
37
|
+
- The engine stays single and shared. It exposes a fixed set of decision points.
|
|
38
|
+
- Each point is filled by a named, deterministic **strategy** from a built-in
|
|
39
|
+
registry. A protocol is unique because it *composes* a unique set of strategies.
|
|
40
|
+
- Composition, not inheritance: protocols mix independent rules (a tribunal may
|
|
41
|
+
want a Jury's unanimity with a Battle Royale's no-appeals), which a class
|
|
42
|
+
hierarchy cannot express cleanly and composition can.
|
|
43
|
+
- Functional, not class trees: a strategy is a pure function selected by name,
|
|
44
|
+
matching this codebase's pure, table-driven core.
|
|
45
|
+
- Prose stays in the prompt as the rulebook agents read, and may serve as an
|
|
46
|
+
authoring source that *compiles* to a strategy selection — but never runs as
|
|
47
|
+
the referee.
|
|
48
|
+
|
|
49
|
+
## Decision
|
|
50
|
+
|
|
51
|
+
**The engine gains a fixed set of override points. A protocol declares which
|
|
52
|
+
built-in strategy fills each. The Charter is the runtime authority for the
|
|
53
|
+
selection, matching `domain_veto` (ADR-0006); the protocol manifest declares the
|
|
54
|
+
same for SDK coherence. An omitted selection falls back to the parliamentary
|
|
55
|
+
default, so every existing session is unchanged.**
|
|
56
|
+
|
|
57
|
+
The initial override points and their built-in strategies:
|
|
58
|
+
|
|
59
|
+
| Point | Question | Strategies (default first) |
|
|
60
|
+
|---|---|---|
|
|
61
|
+
| **resolution** | How does a Division resolve? | `majority` · `supermajority` (≥⅔ of cast) · `unanimity` (`plurality` deferred — needs multi-option Divisions) |
|
|
62
|
+
| **exit** | How does an actor leave? | `division` (voted out) · `elimination` (lose → out) · `none` (until terminal) |
|
|
63
|
+
| **pairing** | Who acts together? | `plenary` (all) · `bracket` · `swiss` |
|
|
64
|
+
| **termination** | When does the session end? | `objective` · `last-standing` · `rounds` · `verdict` |
|
|
65
|
+
|
|
66
|
+
Each strategy is a pure function with the same signature as its siblings, unit
|
|
67
|
+
tested in isolation. The engine dispatches by name; adding a strategy is a table
|
|
68
|
+
entry, not an engine change. Adding an override point is an ADR.
|
|
69
|
+
|
|
70
|
+
Battle Royale is then `{resolution: majority, exit: elimination, termination:
|
|
71
|
+
last-standing, escalation: disabled}`. A Jury is `{resolution: unanimity, exit:
|
|
72
|
+
none, termination: verdict}`. Parliament is the default of every slot. Same
|
|
73
|
+
engine, genuinely different behavior — every one still writing to the same Hansard.
|
|
74
|
+
|
|
75
|
+
### Phased implementation
|
|
76
|
+
|
|
77
|
+
The framework ships one slot at a time so each is proven before the next:
|
|
78
|
+
|
|
79
|
+
1. **`resolution`** — first, because Division already exists and resolution is the
|
|
80
|
+
most visible difference (a Jury that needs unanimity behaves unmistakably
|
|
81
|
+
unlike a Parliament that needs a majority). `tallyDivision` takes the strategy;
|
|
82
|
+
the Charter carries `mechanics.resolution`; the default `majority` reproduces
|
|
83
|
+
today's behavior exactly.
|
|
84
|
+
2. `exit`, `termination`, `pairing` follow, each its own change with its own
|
|
85
|
+
dogfood and tests.
|
|
86
|
+
|
|
87
|
+
## Consequences
|
|
88
|
+
|
|
89
|
+
- Protocols behave distinctly and *deterministically*. The Hansard stays
|
|
90
|
+
reproducible: an outcome is a function of recorded votes and a named strategy,
|
|
91
|
+
both auditable.
|
|
92
|
+
- The strategy registry is the new extension surface. New governance shapes are
|
|
93
|
+
new *combinations* of existing strategies, or a single new strategy function —
|
|
94
|
+
never a new engine.
|
|
95
|
+
- Prose is decoupled from enforcement. It informs agents and may author a
|
|
96
|
+
selection; it never decides an outcome.
|
|
97
|
+
- Backward compatible by construction: every default is the current parliamentary
|
|
98
|
+
behavior, so untouched sessions do not change.
|
|
99
|
+
- The game-theory analysis in PROTOCOLS.md becomes progressively real as slots
|
|
100
|
+
land, rather than remaining documentation.
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# ADR-0008 — Session Storage: Subtree vs. Standalone Repo
|
|
2
|
+
|
|
3
|
+
**Attribution:** Steve Krisjanovs, Cordfuse
|
|
4
|
+
|
|
5
|
+
**Status:** Accepted — **fully built.** Phase 1 (monorepo placement, auto-detected),
|
|
6
|
+
phase 2 (federation as local traversal — `politik registry`/`cascade`), and phase 3
|
|
7
|
+
(explicit mode: `init --standalone` overrides the default) all implemented.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Context
|
|
12
|
+
|
|
13
|
+
EXECUTION.md § The Politik Tree makes **every node its own git repository** —
|
|
14
|
+
"just a new repo with `inherits_from` pointing at it." A real organisational tree
|
|
15
|
+
(Org → Division → Team → Sprint → Ticket → Sub-ticket) is therefore a repo at
|
|
16
|
+
every level: a single Jira-style board becomes hundreds, a company thousands.
|
|
17
|
+
|
|
18
|
+
This is operationally heavy, and the evidence is in the codebase: the **federation
|
|
19
|
+
layer — whose entire job is to wrangle those repos** (the GLOBAL layer, the
|
|
20
|
+
session registry, cross-repo cascade propagation) — is the least-built part of
|
|
21
|
+
Politik, flagged as backlog in `docs/AUDIT.md`. When the hardest, unfinished part
|
|
22
|
+
of a design is the part that manages the design's own multiplicity, the design is
|
|
23
|
+
signalling a problem. Even at small scale (twenty tickets, twenty repos) the
|
|
24
|
+
sprawl is a real adoption blocker — nobody spins up twenty repos to try a tool.
|
|
25
|
+
|
|
26
|
+
The root cause is a conflation. **"A session is a git repo" was read as "a session
|
|
27
|
+
is its own *standalone* repo."** But the engine does not require that. The CLI
|
|
28
|
+
operates on `--dir` — a session is a *directory under git* holding CHARTER.md,
|
|
29
|
+
HANSARD.md, STATE.json and LEDGER.md. And `inherits_from` is a **Charter field**
|
|
30
|
+
(data), indifferent to whether the parent is a sibling directory or a separate
|
|
31
|
+
repository. `tree.ts` — the inheritance, cascade, and quarantine logic — operates
|
|
32
|
+
on Charters, not on repos. So *where* a session's directory lives is a deployment
|
|
33
|
+
concern, not an architectural one.
|
|
34
|
+
|
|
35
|
+
## Decision
|
|
36
|
+
|
|
37
|
+
**A session is a git-tracked directory containing its four records. Whether that
|
|
38
|
+
directory is a standalone repository or a subtree of a larger one is a deployment
|
|
39
|
+
choice; the session logic is identical.** Politik supports two modes, and the
|
|
40
|
+
default changes:
|
|
41
|
+
|
|
42
|
+
### Monorepo mode — the new default
|
|
43
|
+
|
|
44
|
+
The whole Politik tree lives in one repository; nodes are nested directories;
|
|
45
|
+
`inherits_from` points at a parent directory. One clone, one CI, trivial
|
|
46
|
+
discovery. Critically, **the unbuilt federation becomes tractable**: cascade,
|
|
47
|
+
actor mobility, the registry, and "state of everything" reduce to local file
|
|
48
|
+
operations over one working tree, instead of cross-repository orchestration git
|
|
49
|
+
was never built for. The hard part gets easy.
|
|
50
|
+
|
|
51
|
+
### Standalone-repo mode — a supported mode, not the default
|
|
52
|
+
|
|
53
|
+
One repository per node, retained for the two cases that justified it:
|
|
54
|
+
- **GitHub-native projection** — a standalone repo can carry per-session pull
|
|
55
|
+
requests, reviews and issues (Motion / Division / Escalation), which a
|
|
56
|
+
directory cannot.
|
|
57
|
+
- **Per-node access control** — a repository is a permission boundary; a
|
|
58
|
+
directory is not.
|
|
59
|
+
|
|
60
|
+
Both are real needs for large organisations. They are not needs for a solo dev or
|
|
61
|
+
a small team, who are the near-term adopters and for whom the default must be
|
|
62
|
+
manageable.
|
|
63
|
+
|
|
64
|
+
The engine stays **storage-agnostic** — it already does. Only `scaffold`/`init`
|
|
65
|
+
(where a session's directory is placed and what `inherits_from` points at) and the
|
|
66
|
+
federation orchestration differ by mode.
|
|
67
|
+
|
|
68
|
+
## Consequences
|
|
69
|
+
|
|
70
|
+
- **Manageable by default.** One repo, one clone, one CI, `grep`-able discovery.
|
|
71
|
+
The tree is legible instead of scattered across an org's repo list.
|
|
72
|
+
- **Federation becomes buildable.** The most ambitious, least-built piece —
|
|
73
|
+
cascade propagation, the session registry, actor mobility across the tree —
|
|
74
|
+
becomes ordinary file traversal in monorepo mode. This is the strongest reason
|
|
75
|
+
to flip the default: it doesn't just tidy the sprawl, it unblocks the roadmap.
|
|
76
|
+
- **Cost — per-session GitHub projection is monorepo's price.** A directory
|
|
77
|
+
cannot own a pull request, so monorepo mode drops per-session PR/review/issue
|
|
78
|
+
projection. Standalone mode keeps it. This is acceptable: projection is already
|
|
79
|
+
*optional* (ADR context; a session is complete on git alone), so the core is
|
|
80
|
+
untouched — only the GitHub-native *presentation* narrows.
|
|
81
|
+
- **Better onboarding and demo.** "Clone one repo — here is your whole governance
|
|
82
|
+
tree" beats "create a repo per ticket" decisively.
|
|
83
|
+
- **Access control is coarser** in monorepo mode (one boundary; path-based
|
|
84
|
+
CODEOWNERS partially mitigates). Reach for standalone mode when per-node ACL is
|
|
85
|
+
a hard requirement.
|
|
86
|
+
- **Scale trade is a wash.** A monorepo with many sessions and full Hansards
|
|
87
|
+
grows large; standard monorepo tooling handles that. Standalone spreads the load
|
|
88
|
+
but multiplies the repos. Neither is a blocker at realistic scale, and monorepo's
|
|
89
|
+
problems appear only at *high* scale, where standalone's appear immediately.
|
|
90
|
+
- **POLITIK-ARCHITECTURE.md and EXECUTION.md are not amended by this ADR.** The
|
|
91
|
+
tree model stands; this ADR reinterprets "node = repo" as "node = git-tracked
|
|
92
|
+
directory (standalone repo *or* subtree)." Those documents should be revised to
|
|
93
|
+
match when the architecture doc is next opened — with explicit human instruction,
|
|
94
|
+
as the locked invention disclosure requires.
|
|
95
|
+
|
|
96
|
+
## Implementation (phased, not yet built)
|
|
97
|
+
|
|
98
|
+
1. **`scaffold --tree <parent-dir>` / monorepo placement.** Init a session as a
|
|
99
|
+
subdirectory of a parent node, `inherits_from` resolved to the parent
|
|
100
|
+
directory rather than a repo. Standalone remains the current behavior.
|
|
101
|
+
2. **Federation as local traversal — built.** The registry ("all sessions and
|
|
102
|
+
their state"), cascade propagation, and roll-up implemented as reads over the
|
|
103
|
+
monorepo tree in `src/federation.ts`, surfaced as `politik registry` and
|
|
104
|
+
`politik cascade` — the GLOBAL layer the audit listed as backlog.
|
|
105
|
+
3. **Mode is a CLI setting — built.** The default is auto-detect (monorepo when
|
|
106
|
+
already inside a repo); `politik init --standalone` is the explicit opt-out,
|
|
107
|
+
nesting the session its own repo even inside an enclosing tree — for the
|
|
108
|
+
GitHub-native-projection and per-node-ACL cases standalone mode exists for.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# ADR-0009 — The MATCH Primitive and Pairing
|
|
2
|
+
|
|
3
|
+
**Attribution:** Steve Krisjanovs, Cordfuse
|
|
4
|
+
|
|
5
|
+
**Status:** Accepted — built (`src/tournament.ts`, `src/standings.ts`, `politik pair` / `politik match`).
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Context
|
|
10
|
+
|
|
11
|
+
Scoring a competitive protocol (`standings.ts`) reads results from the record and
|
|
12
|
+
works. **Pairing did not exist**, and could not be expressed on the primitives as
|
|
13
|
+
they stood. Swiss, round-robin and single-elimination are all **1v1-match**
|
|
14
|
+
formats: they generate matchups between two named contestants, each matchup
|
|
15
|
+
resolves to a winner, and the next round's matchups depend on the results.
|
|
16
|
+
|
|
17
|
+
A Politik **DIVISION** is an N-actor vote on a **MOTION**. It has no notion of a
|
|
18
|
+
contest between two parties, and no winner in the tournament sense — a Motion
|
|
19
|
+
carries or is rejected; it does not defeat another Motion. So there was nothing
|
|
20
|
+
for a pairing algorithm to pair. The audit recorded this honestly: pairing needs
|
|
21
|
+
"an additive *match primitive*, a design question rather than a scoring read."
|
|
22
|
+
This ADR adds it.
|
|
23
|
+
|
|
24
|
+
## Decision
|
|
25
|
+
|
|
26
|
+
**Add `MATCH` to CANON as a first-class primitive: a contest between two
|
|
27
|
+
contestants that resolves to a single winner.** It sits beside MOTION/DIVISION —
|
|
28
|
+
the deliberative pair decides *questions*; MATCH decides *contests* — and reuses
|
|
29
|
+
the rest of the engine unchanged (the Hansard records it, standings score it,
|
|
30
|
+
git commits it).
|
|
31
|
+
|
|
32
|
+
Lifecycle, all on the record:
|
|
33
|
+
|
|
34
|
+
- **`MATCH_CREATED`** — a pairing: round, contestant A, contestant B (or a bye).
|
|
35
|
+
Produced by `pairRound(contestants, standings, format, round, played)`, which
|
|
36
|
+
reads the current standings and the pairs already played:
|
|
37
|
+
- **single-elim** — pairs the still-undefeated (`losses === 0`); the bracket
|
|
38
|
+
narrows by loss, so no cull is required and one-undefeated is the champion.
|
|
39
|
+
- **swiss** — seeds by score and pairs adjacent, never rematching.
|
|
40
|
+
- **round-robin** — pairs each contestant with an opponent not yet played; a
|
|
41
|
+
bye when none remains.
|
|
42
|
+
- **`MATCH_DECIDED`** — the result: a referee (AUTHORITY) names the winner; the
|
|
43
|
+
loser is the other contestant. Refuses to crown a non-contestant, re-decide a
|
|
44
|
+
settled match, or resolve one that does not exist.
|
|
45
|
+
|
|
46
|
+
Scoring is unified: `standings.ts` reads `MATCH_DECIDED` exactly as it reads a
|
|
47
|
+
Division outcome — winner takes a win, loser a loss — so a tournament and a
|
|
48
|
+
deliberative body are scored on the same table.
|
|
49
|
+
|
|
50
|
+
CLI: `politik pair --format <f>` creates a round (byes auto-decided); `politik
|
|
51
|
+
match report --match <id> --winner <c>` settles one; `politik match list` shows
|
|
52
|
+
the bracket.
|
|
53
|
+
|
|
54
|
+
## Consequences
|
|
55
|
+
|
|
56
|
+
- **Pairing is now expressible** without distorting the deliberative model. MATCH
|
|
57
|
+
is a separate primitive, so a Division never has to pretend to be a duel.
|
|
58
|
+
- **The engine is unchanged.** MATCH reuses the Hansard, the commit path, the
|
|
59
|
+
scoring read. No new state machine, no change to SESSION/STATE.
|
|
60
|
+
- **No auto-elimination needed for single-elim** — a defeated contestant is
|
|
61
|
+
simply never paired again; the bracket is derived from the loss column. This
|
|
62
|
+
keeps MATCH orthogonal to the `exit: elimination` Division mechanic (ADR-0007),
|
|
63
|
+
which remains how a *Division* culls a losing side.
|
|
64
|
+
- **Adjudication is by AUTHORITY/referee**, not a Division. A match result is a
|
|
65
|
+
reported fact, not a vote; forcing it through a Division would reintroduce the
|
|
66
|
+
N-actor model MATCH exists to avoid. A protocol that wants matches decided by a
|
|
67
|
+
vote can still run a Division and report its outcome as the result.
|
|
68
|
+
- **POLITIK-ARCHITECTURE.md is not amended by this ADR.** As with ADR-0004 (which
|
|
69
|
+
added the CONFLICT primitive and ASSENT verb), the CANON constant in `canon.ts`
|
|
70
|
+
carries the addition; the locked invention-disclosure prose is revised only
|
|
71
|
+
under explicit human instruction when next opened.
|
|
72
|
+
- **Not built:** seeding beyond score order, tie-breaks (Buchholz/Sonneborn),
|
|
73
|
+
and best-of-N matches. All are additive over `MATCH_DECIDED` and out of scope
|
|
74
|
+
here.
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cordfuse/politik",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Politik — a governed multi-agent framework built on git. The SCM repository is the session: charter, record, state, and invite in one.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://github.com/cordfuse/politik",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/cordfuse/politik.git"
|
|
11
|
+
},
|
|
12
|
+
"bin": {
|
|
13
|
+
"politik": "./bin/politik.js"
|
|
14
|
+
},
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"bin/",
|
|
20
|
+
"src/",
|
|
21
|
+
"protocols/",
|
|
22
|
+
"docs/adr/",
|
|
23
|
+
"README.md",
|
|
24
|
+
"POLITIK-ARCHITECTURE.md",
|
|
25
|
+
"PROTOCOLS.md",
|
|
26
|
+
"RUNTIME.md",
|
|
27
|
+
"EXECUTION.md",
|
|
28
|
+
"RESEARCH.md"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "tsc --noEmit",
|
|
32
|
+
"lint": "tsc --noEmit",
|
|
33
|
+
"test": "node --import tsx --test tests/*.test.ts"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"tsx": "^4.20.0",
|
|
37
|
+
"yaml": "^2.8.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/node": "^22.10.0",
|
|
41
|
+
"typescript": "^5.7.0"
|
|
42
|
+
},
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": ">=20"
|
|
45
|
+
},
|
|
46
|
+
"keywords": [
|
|
47
|
+
"ai",
|
|
48
|
+
"agents",
|
|
49
|
+
"governance",
|
|
50
|
+
"multi-agent",
|
|
51
|
+
"git",
|
|
52
|
+
"politik",
|
|
53
|
+
"cordfuse"
|
|
54
|
+
]
|
|
55
|
+
}
|