@cordfuse/politik 0.5.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/EXECUTION.md +86 -83
- package/POLITIK-ARCHITECTURE.md +111 -176
- package/PROTOCOLS.md +120 -325
- package/README.md +135 -188
- package/RESEARCH.md +142 -438
- package/RUNTIME.md +254 -262
- 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 +90 -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 +127 -103
- package/src/agents.ts +39 -27
- 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 +45 -45
- 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 +73 -56
- 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/canon.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* CANON — the canonical primitive layer.
|
|
3
3
|
*
|
|
4
4
|
* The engine speaks these terms. Protocols translate them to industry
|
|
5
|
-
* vocabulary; nothing below this layer knows what "
|
|
5
|
+
* vocabulary; nothing below this layer knows what "Owner" or "Sprint" means.
|
|
6
6
|
*
|
|
7
7
|
* This module is types and frozen constants only — no logic, no I/O. It is the
|
|
8
8
|
* single source of truth for CANON in code, so that any drift from
|
|
@@ -32,7 +32,7 @@ export type Role = (typeof ROLES)[number];
|
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* The one hard constitutional rule: AUTHORITY is always human. A Charter
|
|
35
|
-
* declaring a machine as AUTHORITY is invalid and fails
|
|
35
|
+
* declaring a machine as AUTHORITY is invalid and fails session opening validation.
|
|
36
36
|
*/
|
|
37
37
|
export const HUMAN_ONLY_ROLES: readonly Role[] = Object.freeze(['AUTHORITY']);
|
|
38
38
|
|
|
@@ -55,7 +55,7 @@ export const PRIMITIVES = [
|
|
|
55
55
|
'CHARTER',
|
|
56
56
|
'RECORD',
|
|
57
57
|
'MOTION',
|
|
58
|
-
'
|
|
58
|
+
'BALLOT',
|
|
59
59
|
'MATCH',
|
|
60
60
|
'ESCALATION',
|
|
61
61
|
'SUSPENSION',
|
|
@@ -74,7 +74,7 @@ export const VERBS = [
|
|
|
74
74
|
'READ',
|
|
75
75
|
'WRITE',
|
|
76
76
|
'VOTE',
|
|
77
|
-
'
|
|
77
|
+
'ENACT',
|
|
78
78
|
'ESCALATE',
|
|
79
79
|
'PROMOTE',
|
|
80
80
|
'DEMOTE',
|
|
@@ -90,18 +90,31 @@ export const VERBS = [
|
|
|
90
90
|
|
|
91
91
|
export type Verb = (typeof VERBS)[number];
|
|
92
92
|
|
|
93
|
+
/**
|
|
94
|
+
* The verbs each role holds by default — the same table the role files state.
|
|
95
|
+
* A Charter may grant more; an agent is told exactly these unless the caller
|
|
96
|
+
* passes its own list.
|
|
97
|
+
*/
|
|
98
|
+
export const ROLE_VERBS: Readonly<Record<Role, readonly Verb[]>> = Object.freeze({
|
|
99
|
+
AUTHORITY: VERBS,
|
|
100
|
+
DELEGATE: VERBS.filter((v) => v !== 'DISSOLVE'),
|
|
101
|
+
OPERATOR: ['READ', 'WRITE', 'VOTE', 'ESCALATE', 'SPAWN'],
|
|
102
|
+
MEMBER: ['READ', 'VOTE', 'ESCALATE'],
|
|
103
|
+
OBSERVER: ['READ'],
|
|
104
|
+
});
|
|
105
|
+
|
|
93
106
|
/* -------------------------------------------------------------------------- */
|
|
94
107
|
/* States */
|
|
95
108
|
/* -------------------------------------------------------------------------- */
|
|
96
109
|
|
|
97
110
|
/**
|
|
98
|
-
* The five valid states of a proceeding.
|
|
111
|
+
* The five valid states of a proceeding. MISCONDUCT is deliberately
|
|
99
112
|
* absent — it is a *cause of suspension*, not a state (ADR-0003).
|
|
100
113
|
*/
|
|
101
114
|
export const STATES = [
|
|
102
115
|
'STATE_CONVENED',
|
|
103
116
|
'STATE_SUSPENDED',
|
|
104
|
-
'
|
|
117
|
+
'STATE_CLOSED',
|
|
105
118
|
'STATE_STALE',
|
|
106
119
|
'STATE_INVALID',
|
|
107
120
|
] as const;
|
|
@@ -119,10 +132,10 @@ export type State = (typeof STATES)[number];
|
|
|
119
132
|
* quiet".
|
|
120
133
|
*/
|
|
121
134
|
export const SUSPENSION_CAUSES = [
|
|
122
|
-
'
|
|
123
|
-
'
|
|
135
|
+
'ESCALATION',
|
|
136
|
+
'OWNER_ORDER',
|
|
124
137
|
'DISPUTED_EXIT',
|
|
125
|
-
'
|
|
138
|
+
'MISCONDUCT',
|
|
126
139
|
'DEADLOCK',
|
|
127
140
|
] as const;
|
|
128
141
|
|
|
@@ -133,7 +146,7 @@ export type SuspensionCause = (typeof SUSPENSION_CAUSES)[number];
|
|
|
133
146
|
/* -------------------------------------------------------------------------- */
|
|
134
147
|
|
|
135
148
|
/**
|
|
136
|
-
* How a carried Motion is enacted on
|
|
149
|
+
* How a carried Motion is enacted on ENACT. Declared in the Charter; session opening
|
|
137
150
|
* enforces the squash/fast_forward constraints (ADR-0002).
|
|
138
151
|
*/
|
|
139
152
|
export const MERGE_STRATEGIES = [
|
package/src/capability.ts
CHANGED
|
@@ -1,65 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Actor capability profiles — the
|
|
2
|
+
* Actor capability profiles — the three dimensions.
|
|
3
3
|
*
|
|
4
4
|
* A Charter declares what a constituency *requires*; an actor declares what
|
|
5
|
-
* they *are*. This module decides whether the two match, at
|
|
5
|
+
* they *are*. This module decides whether the two match, at session opening and again
|
|
6
6
|
* before an agent is spawned.
|
|
7
7
|
*
|
|
8
8
|
* The dimensions (POLITIK-ARCHITECTURE.md § Actor Capability Profile):
|
|
9
9
|
*
|
|
10
10
|
* 1. Role tier — trust and verbs. Already enforced elsewhere.
|
|
11
|
-
* 2.
|
|
12
|
-
* 3.
|
|
13
|
-
*
|
|
14
|
-
*
|
|
11
|
+
* 2. Hard skills — domain competence, `required` and `excluded`.
|
|
12
|
+
* 3. Model / knowledge grade — the underlying intelligence, per seat.
|
|
13
|
+
*
|
|
14
|
+
* Plus the mandate a seat expects. Every dimension here gates seating; a
|
|
15
|
+
* profile field that gated nothing (personality archetypes, soft skills) was
|
|
16
|
+
* removed rather than kept as an unmeasured variable.
|
|
15
17
|
*
|
|
16
18
|
* `excluded` matters as much as `required`, and is the less obvious of the two:
|
|
17
19
|
* an actor working outside its domain does not fail loudly, it produces
|
|
18
20
|
* confident wrong output. Excluding a skill is how a Charter says "not this,
|
|
19
21
|
* even though you could".
|
|
20
22
|
*
|
|
21
|
-
* This module is also the instrument the research layer depends on. If profile
|
|
22
|
-
* composition has measurable effects, the profiles have to be real and recorded
|
|
23
|
-
* rather than declared and ignored.
|
|
24
|
-
*
|
|
25
23
|
* Attribution: Steve Krisjanovs, Cordfuse
|
|
26
24
|
*/
|
|
27
25
|
|
|
28
26
|
import { parse as parseYaml } from 'yaml';
|
|
29
27
|
|
|
30
28
|
import { splitFrontmatter, type Constituency } from './charter.ts';
|
|
31
|
-
import type {
|
|
29
|
+
import type { RecordEntry } from './log.ts';
|
|
32
30
|
import type { Role } from './canon.ts';
|
|
33
31
|
|
|
34
|
-
/* -------------------------------------------------------------------------- */
|
|
35
|
-
/* Dimensions 2 and 3 */
|
|
36
|
-
/* -------------------------------------------------------------------------- */
|
|
37
|
-
|
|
38
|
-
export const ARCHETYPES = [
|
|
39
|
-
'HARDLINER',
|
|
40
|
-
'DIPLOMAT',
|
|
41
|
-
'ANALYST',
|
|
42
|
-
'CREATIVE',
|
|
43
|
-
'LONE_WOLF',
|
|
44
|
-
'TEAM_PLAYER',
|
|
45
|
-
'JOKESTER',
|
|
46
|
-
] as const;
|
|
47
|
-
|
|
48
|
-
export type Archetype = (typeof ARCHETYPES)[number];
|
|
49
|
-
|
|
50
|
-
export const SOFT_SKILLS = [
|
|
51
|
-
'COMMUNICATION',
|
|
52
|
-
'CREATIVITY',
|
|
53
|
-
'ANALYTICAL_THINKING',
|
|
54
|
-
'PERSUASION',
|
|
55
|
-
'TECHNICAL_ACUMEN',
|
|
56
|
-
] as const;
|
|
57
|
-
|
|
58
|
-
export type SoftSkill = (typeof SOFT_SKILLS)[number];
|
|
59
|
-
|
|
60
|
-
export const isArchetype = (v: unknown): v is Archetype =>
|
|
61
|
-
typeof v === 'string' && (ARCHETYPES as readonly string[]).includes(v);
|
|
62
|
-
|
|
63
32
|
/* -------------------------------------------------------------------------- */
|
|
64
33
|
/* Profile */
|
|
65
34
|
/* -------------------------------------------------------------------------- */
|
|
@@ -67,8 +36,6 @@ export const isArchetype = (v: unknown): v is Archetype =>
|
|
|
67
36
|
export interface ActorProfile {
|
|
68
37
|
readonly actor: string;
|
|
69
38
|
readonly role: Role;
|
|
70
|
-
readonly archetype?: Archetype | null;
|
|
71
|
-
readonly soft_skills?: Readonly<Partial<Record<SoftSkill, number>>>;
|
|
72
39
|
readonly hard_skills?: readonly string[];
|
|
73
40
|
readonly model?: string | null;
|
|
74
41
|
/** ISO year-month, e.g. `2025-01`. */
|
|
@@ -77,7 +44,7 @@ export interface ActorProfile {
|
|
|
77
44
|
}
|
|
78
45
|
|
|
79
46
|
export interface CapabilityIssue {
|
|
80
|
-
readonly dimension: 'hard_skills' | 'model' | 'knowledge_cutoff' | '
|
|
47
|
+
readonly dimension: 'hard_skills' | 'model' | 'knowledge_cutoff' | 'mandate';
|
|
81
48
|
readonly severity: 'fail' | 'warn';
|
|
82
49
|
readonly message: string;
|
|
83
50
|
}
|
|
@@ -122,9 +89,9 @@ const cutoffSatisfies = (minimum: string | null, actual: string | null): boolean
|
|
|
122
89
|
* Check an actor against the constituency it would be seated in.
|
|
123
90
|
*
|
|
124
91
|
* Hard failures block the seating; warnings are recorded and proceed. The split
|
|
125
|
-
* follows the architecture: the engine "validates model compliance at
|
|
92
|
+
* follows the architecture: the engine "validates model compliance at session opening
|
|
126
93
|
* and refuses to spawn a mismatched model", while a preferred-but-absent model
|
|
127
|
-
*
|
|
94
|
+
* is a configuration gap, not a disqualification.
|
|
128
95
|
*/
|
|
129
96
|
export const checkCapability = (
|
|
130
97
|
profile: ActorProfile,
|
|
@@ -195,13 +162,6 @@ export const checkCapability = (
|
|
|
195
162
|
});
|
|
196
163
|
}
|
|
197
164
|
|
|
198
|
-
if (profile.archetype !== undefined && profile.archetype !== null && !isArchetype(profile.archetype)) {
|
|
199
|
-
issues.push({
|
|
200
|
-
dimension: 'archetype',
|
|
201
|
-
severity: 'warn',
|
|
202
|
-
message: `unknown archetype: ${String(profile.archetype)}`,
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
165
|
|
|
206
166
|
return { ok: !issues.some((i) => i.severity === 'fail'), issues };
|
|
207
167
|
};
|
|
@@ -224,15 +184,15 @@ export interface MismatchInput {
|
|
|
224
184
|
/**
|
|
225
185
|
* Record a SKILL_MISMATCH fault.
|
|
226
186
|
*
|
|
227
|
-
* Fires when
|
|
187
|
+
* Fires when record performance reveals a mismatch that session opening did not
|
|
228
188
|
* catch — output in an excluded domain, or repeated failure on required domain
|
|
229
189
|
* work. Consequence depends on the Charter: auto-demote where permitted,
|
|
230
|
-
* otherwise escalate to the
|
|
190
|
+
* otherwise escalate to the owner.
|
|
231
191
|
*
|
|
232
192
|
* The record is permanent either way. Future sessions plan against it, which is
|
|
233
193
|
* the point of keeping actor performance history at all.
|
|
234
194
|
*/
|
|
235
|
-
export const skillMismatch = (input: MismatchInput):
|
|
195
|
+
export const skillMismatch = (input: MismatchInput): RecordEntry => ({
|
|
236
196
|
type: 'FAULT_ACTOR',
|
|
237
197
|
at: input.at,
|
|
238
198
|
actor: 'RECORD',
|
|
@@ -245,43 +205,11 @@ export const skillMismatch = (input: MismatchInput): HansardEntry => ({
|
|
|
245
205
|
Observed: input.observed,
|
|
246
206
|
Consequence: input.auto_demotion
|
|
247
207
|
? 'auto-demotion (permitted by Charter)'
|
|
248
|
-
: 'escalated to the
|
|
208
|
+
: 'escalated to the owner — auto_demotion is false',
|
|
249
209
|
Record: 'permanent — future sessions plan against this',
|
|
250
210
|
},
|
|
251
211
|
});
|
|
252
212
|
|
|
253
|
-
/* -------------------------------------------------------------------------- */
|
|
254
|
-
/* Composition */
|
|
255
|
-
/* -------------------------------------------------------------------------- */
|
|
256
|
-
|
|
257
|
-
export interface Composition {
|
|
258
|
-
readonly archetypes: Readonly<Partial<Record<Archetype, number>>>;
|
|
259
|
-
readonly distinct: number;
|
|
260
|
-
readonly homogeneous: boolean;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* Describe the archetype composition of a seated bench.
|
|
265
|
-
*
|
|
266
|
-
* Measured, never judged. RESEARCH.md asks whether complementary composition
|
|
267
|
-
* outperforms homogeneous composition — that is an open empirical question, and
|
|
268
|
-
* a framework that warned about "bad" mixes would be answering it by assumption
|
|
269
|
-
* and contaminating its own instrument.
|
|
270
|
-
*/
|
|
271
|
-
export const composition = (profiles: readonly ActorProfile[]): Composition => {
|
|
272
|
-
const archetypes: Partial<Record<Archetype, number>> = {};
|
|
273
|
-
for (const p of profiles) {
|
|
274
|
-
if (p.archetype === undefined || p.archetype === null) continue;
|
|
275
|
-
archetypes[p.archetype] = (archetypes[p.archetype] ?? 0) + 1;
|
|
276
|
-
}
|
|
277
|
-
const distinct = Object.keys(archetypes).length;
|
|
278
|
-
return {
|
|
279
|
-
archetypes,
|
|
280
|
-
distinct,
|
|
281
|
-
homogeneous: distinct === 1 && profiles.length > 1,
|
|
282
|
-
};
|
|
283
|
-
};
|
|
284
|
-
|
|
285
213
|
/* -------------------------------------------------------------------------- */
|
|
286
214
|
/* Loading */
|
|
287
215
|
/* -------------------------------------------------------------------------- */
|
|
@@ -312,20 +240,9 @@ export const parseProfile = (source: string, fallbackActor: string): ActorProfil
|
|
|
312
240
|
if (!isObject(raw)) return null;
|
|
313
241
|
|
|
314
242
|
const model = isObject(raw['model']) ? raw['model'] : {};
|
|
315
|
-
const soft: Partial<Record<SoftSkill, number>> = {};
|
|
316
|
-
if (isObject(raw['soft_skills'])) {
|
|
317
|
-
for (const [key, value] of Object.entries(raw['soft_skills'])) {
|
|
318
|
-
if ((SOFT_SKILLS as readonly string[]).includes(key) && typeof value === 'number') {
|
|
319
|
-
soft[key as SoftSkill] = value;
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
|
|
324
243
|
return {
|
|
325
244
|
actor: typeof raw['actor'] === 'string' ? raw['actor'] : fallbackActor,
|
|
326
245
|
role: (typeof raw['role'] === 'string' ? raw['role'] : 'MEMBER') as Role,
|
|
327
|
-
archetype: isArchetype(raw['archetype']) ? raw['archetype'] : null,
|
|
328
|
-
soft_skills: soft,
|
|
329
246
|
hard_skills: strings(raw['hard_skills']),
|
|
330
247
|
model: typeof model['name'] === 'string' ? model['name'] : (typeof raw['model'] === 'string' ? raw['model'] : null),
|
|
331
248
|
knowledge_cutoff:
|
package/src/charter.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* CHARTER.md — parser and
|
|
2
|
+
* CHARTER.md — parser and session opening validator.
|
|
3
3
|
*
|
|
4
4
|
* The Charter is the sovereign law of a session: markdown with a single YAML
|
|
5
5
|
* frontmatter block. The frontmatter carries every machine-read field; the
|
|
6
|
-
* markdown body carries human-readable
|
|
6
|
+
* markdown body carries human-readable Charter which the engine never
|
|
7
7
|
* parses.
|
|
8
8
|
*
|
|
9
9
|
* Schema and the eight validation rules are fixed by ADR-0002 (with rules 5-7
|
|
@@ -23,13 +23,13 @@ import {
|
|
|
23
23
|
type Role,
|
|
24
24
|
} from './canon.ts';
|
|
25
25
|
import type { ProtocolRecordMode } from './protocol.ts';
|
|
26
|
-
import { isResolution, isExitPolicy, type Resolution, type ExitPolicy } from './
|
|
27
|
-
import { isTerminationPolicy, type TerminationPolicy } from './
|
|
26
|
+
import { isResolution, isExitPolicy, type Resolution, type ExitPolicy } from './ballot.ts';
|
|
27
|
+
import { isTerminationPolicy, type TerminationPolicy } from './closing.ts';
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* A content fingerprint of a Charter's source text.
|
|
31
31
|
*
|
|
32
|
-
* Recorded on the
|
|
32
|
+
* Recorded on the SESSION_OPENED entry at session open so an immutable-charter
|
|
33
33
|
* protocol (ADR-0007 `immutable_charter`) can prove its constitution has not
|
|
34
34
|
* been edited since. The raw CHARTER.md bytes are hashed — not the parsed
|
|
35
35
|
* object — so any change the operator makes to the file, meaningful or not, is
|
|
@@ -77,7 +77,7 @@ export interface Endurance {
|
|
|
77
77
|
readonly max_motions: number | null;
|
|
78
78
|
readonly max_cost_usd: number | null;
|
|
79
79
|
/**
|
|
80
|
-
* Spend at which the
|
|
80
|
+
* Spend at which the owner is warned, before the ceiling stops the session.
|
|
81
81
|
* The low-fuel light: a proceeding that dies at its ceiling with no warning
|
|
82
82
|
* gives nobody the chance to extend the budget or wind down gracefully.
|
|
83
83
|
*/
|
|
@@ -96,13 +96,19 @@ export interface SessionBlock {
|
|
|
96
96
|
readonly checkpoint_interval_hours: number | null;
|
|
97
97
|
readonly deadline: string | null;
|
|
98
98
|
readonly merge_strategy: MergeStrategy;
|
|
99
|
-
readonly
|
|
99
|
+
readonly enact: Role;
|
|
100
100
|
/**
|
|
101
|
-
*
|
|
102
|
-
*
|
|
101
|
+
* True when the Charter is locked once the session opens: any later edit to
|
|
102
|
+
* CHARTER.md refuses governance acts. Copied from the protocol at scaffold,
|
|
103
|
+
* and recorded on the SESSION_OPENED entry so editing this line cannot unlock it.
|
|
104
|
+
*/
|
|
105
|
+
readonly immutable_charter: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* ADR-0010: whether enact, rule and close requested by an AI harness or a
|
|
108
|
+
* script are staged for the owner's confirmation. Absent means 'off', so every
|
|
103
109
|
* session convened before ADR-0010 behaves exactly as it did.
|
|
104
110
|
*/
|
|
105
|
-
readonly
|
|
111
|
+
readonly owner_confirmation: 'required' | 'off';
|
|
106
112
|
/**
|
|
107
113
|
* ADR-0011: whether a confirmed act's commit must be signed with the confirming
|
|
108
114
|
* person's git signing key. Absent means 'off'.
|
|
@@ -149,8 +155,8 @@ export interface Constituency {
|
|
|
149
155
|
/**
|
|
150
156
|
* Constitutional-capture mitigations (RUNTIME.md § Constitutional Capture).
|
|
151
157
|
*
|
|
152
|
-
* These were implemented in `src/
|
|
153
|
-
* documentation shows was inert —
|
|
158
|
+
* These were implemented in `src/misconduct.ts` but never parsed, so the YAML the
|
|
159
|
+
* documentation shows was inert — an owner could declare a Witness Council and
|
|
154
160
|
* get nothing. Parsed here so the declaration has effect.
|
|
155
161
|
*/
|
|
156
162
|
export interface Governance {
|
|
@@ -173,7 +179,7 @@ export interface Charter {
|
|
|
173
179
|
readonly minimum_cast: Readonly<Partial<Record<Role, number>>>;
|
|
174
180
|
readonly domain_veto: readonly Role[];
|
|
175
181
|
/** Protocol override points (ADR-0007). Absent selections default to the
|
|
176
|
-
*
|
|
182
|
+
* default protocol (majority-vote) behavior. */
|
|
177
183
|
readonly mechanics: {
|
|
178
184
|
readonly resolution: Resolution;
|
|
179
185
|
readonly exit: ExitPolicy;
|
|
@@ -186,7 +192,7 @@ export interface Charter {
|
|
|
186
192
|
readonly auto_retry_delay_minutes: number;
|
|
187
193
|
};
|
|
188
194
|
readonly constituencies: readonly Constituency[];
|
|
189
|
-
/** Unparsed
|
|
195
|
+
/** Unparsed Charter prose. Carried, never interpreted. */
|
|
190
196
|
readonly body: string;
|
|
191
197
|
}
|
|
192
198
|
|
|
@@ -357,11 +363,12 @@ export const parseCharter = (source: string): ParseResult => {
|
|
|
357
363
|
? session['merge_strategy']
|
|
358
364
|
: 'merge_commit',
|
|
359
365
|
// Default only when absent. A present-but-invalid value is preserved so
|
|
360
|
-
//
|
|
361
|
-
// rule and let a bad
|
|
362
|
-
|
|
366
|
+
// session opening rule 7 can reject it — coercing it to AUTHORITY here masked the
|
|
367
|
+
// rule and let a bad enact silently open a session (AUDIT #8).
|
|
368
|
+
enact: session['enact'] === undefined ? 'AUTHORITY' : (session['enact'] as Role),
|
|
369
|
+
immutable_charter: session['immutable_charter'] === true,
|
|
363
370
|
stale_action: session['stale_action'] === 'dissolve' ? 'dissolve' : 'suspend',
|
|
364
|
-
|
|
371
|
+
owner_confirmation: session['owner_confirmation'] === 'required' ? 'required' : 'off',
|
|
365
372
|
signed_confirmations: session['signed_confirmations'] === 'required' ? 'required' : 'off',
|
|
366
373
|
checkpoint_interval_hours: asNumberOrNull(session['checkpoint_interval_hours']),
|
|
367
374
|
endurance: {
|
|
@@ -397,7 +404,7 @@ export const parseCharter = (source: string): ParseResult => {
|
|
|
397
404
|
const m = isObject(raw['mechanics']) ? raw['mechanics'] : {};
|
|
398
405
|
return {
|
|
399
406
|
resolution: isResolution(m['resolution']) ? m['resolution'] : 'majority',
|
|
400
|
-
exit: isExitPolicy(m['exit']) ? m['exit'] : '
|
|
407
|
+
exit: isExitPolicy(m['exit']) ? m['exit'] : 'vote',
|
|
401
408
|
termination: isTerminationPolicy(m['termination']) ? m['termination'] : 'objective',
|
|
402
409
|
};
|
|
403
410
|
})(),
|
|
@@ -408,7 +415,7 @@ export const parseCharter = (source: string): ParseResult => {
|
|
|
408
415
|
return {
|
|
409
416
|
// RUNTIME.md's documented defaults. A Charter that says nothing gets
|
|
410
417
|
// retry rather than an immediate escalation, because a rate limit is
|
|
411
|
-
// not something to wake
|
|
418
|
+
// not something to wake an owner for.
|
|
412
419
|
auto_retry_max: max !== null && max >= 0 ? max : 3,
|
|
413
420
|
auto_retry_delay_minutes: delay !== null && delay >= 0 ? delay : 5,
|
|
414
421
|
};
|
|
@@ -444,14 +451,14 @@ export const parseCharter = (source: string): ParseResult => {
|
|
|
444
451
|
};
|
|
445
452
|
|
|
446
453
|
/* -------------------------------------------------------------------------- */
|
|
447
|
-
/* Validate —
|
|
454
|
+
/* Validate — session opening */
|
|
448
455
|
/* -------------------------------------------------------------------------- */
|
|
449
456
|
|
|
450
457
|
/**
|
|
451
|
-
* Apply the
|
|
458
|
+
* Apply the session opening validation rules (ADR-0002 § Validation rules).
|
|
452
459
|
*
|
|
453
460
|
* A failing result means SESSION_INVALID: the session never opens and the
|
|
454
|
-
* issues are committed to the
|
|
461
|
+
* issues are committed to the record naming what failed.
|
|
455
462
|
*
|
|
456
463
|
* `protocol` is optional. Rule 2 (protocol resolution) and rule 5 (squash vs
|
|
457
464
|
* distributed record mode) are only enforced when the resolved protocol is
|
|
@@ -487,7 +494,7 @@ export const validateCharter = (
|
|
|
487
494
|
if (requiredAuthority !== undefined && requiredAuthority < 1) {
|
|
488
495
|
issues.push({
|
|
489
496
|
field: 'minimum_cast.AUTHORITY',
|
|
490
|
-
message: 'may never be overridden to 0 — a session with no
|
|
497
|
+
message: 'may never be overridden to 0 — a session with no Owner cannot proceed',
|
|
491
498
|
rule: 4,
|
|
492
499
|
});
|
|
493
500
|
}
|
|
@@ -503,7 +510,7 @@ export const validateCharter = (
|
|
|
503
510
|
if (c.role === 'AUTHORITY' && c.agent !== null) {
|
|
504
511
|
issues.push({
|
|
505
512
|
field: `constituencies[${i}].agent`,
|
|
506
|
-
message: `AUTHORITY is always human — this Charter seats the agent "${c.agent}" as
|
|
513
|
+
message: `AUTHORITY is always human — this Charter seats the agent "${c.agent}" as Owner`,
|
|
507
514
|
});
|
|
508
515
|
}
|
|
509
516
|
}
|
|
@@ -511,11 +518,11 @@ export const validateCharter = (
|
|
|
511
518
|
// Rule 3 — declared constituencies must satisfy minimum_cast.
|
|
512
519
|
//
|
|
513
520
|
// ADR-0002 says "assigned constituencies", which reads ambiguously. It means
|
|
514
|
-
// the seats this Charter assigns, not actors
|
|
521
|
+
// the seats this Charter assigns, not actors session in them: session opening runs
|
|
515
522
|
// *before* the session opens, so no actor has been seated yet and the other
|
|
516
523
|
// reading would make the rule uncheckable at the only moment it runs.
|
|
517
524
|
// Whether seats are actually filled is a runtime question, and quorum answers
|
|
518
|
-
// it at
|
|
525
|
+
// it at vote time.
|
|
519
526
|
const slotsByRole = new Map<Role, number>();
|
|
520
527
|
for (const c of charter.constituencies) {
|
|
521
528
|
slotsByRole.set(c.role, (slotsByRole.get(c.role) ?? 0) + c.slots);
|
|
@@ -543,20 +550,20 @@ export const validateCharter = (
|
|
|
543
550
|
});
|
|
544
551
|
}
|
|
545
552
|
|
|
546
|
-
// Rule 6 — fast_forward leaves no merge node, so no evidence of a
|
|
553
|
+
// Rule 6 — fast_forward leaves no merge node, so no evidence of a vote.
|
|
547
554
|
if (charter.session.merge_strategy === 'fast_forward' && charter.session.quorum !== 1) {
|
|
548
555
|
issues.push({
|
|
549
556
|
field: 'session.merge_strategy',
|
|
550
|
-
message: `fast_forward requires session.quorum: 1 (declared ${charter.session.quorum}) — it leaves no merge node to evidence a
|
|
557
|
+
message: `fast_forward requires session.quorum: 1 (declared ${charter.session.quorum}) — it leaves no merge node to evidence a vote`,
|
|
551
558
|
rule: 6,
|
|
552
559
|
});
|
|
553
560
|
}
|
|
554
561
|
|
|
555
|
-
// Rule 7 —
|
|
562
|
+
// Rule 7 — enact must name a CANON role. Parsing now defaults only when the
|
|
556
563
|
// key is absent, so a present-but-invalid value reaches here and is rejected.
|
|
557
|
-
if (!isRole(charter.session.
|
|
564
|
+
if (!isRole(charter.session.enact)) {
|
|
558
565
|
issues.push({
|
|
559
|
-
field: 'session.
|
|
566
|
+
field: 'session.enact',
|
|
560
567
|
message: 'must name a CANON role',
|
|
561
568
|
rule: 7,
|
|
562
569
|
});
|
|
@@ -575,10 +582,10 @@ export const validateCharter = (
|
|
|
575
582
|
};
|
|
576
583
|
|
|
577
584
|
/**
|
|
578
|
-
* Parse and validate in one step — the
|
|
585
|
+
* Parse and validate in one step — the session opening entry point.
|
|
579
586
|
* Rule 8: on pass, the caller sets `STATE.json.state = CONVENED`.
|
|
580
587
|
*/
|
|
581
|
-
export const
|
|
588
|
+
export const sessionOpening = (
|
|
582
589
|
source: string,
|
|
583
590
|
protocol?: ProtocolContext,
|
|
584
591
|
): ValidationResult & { readonly charter?: Charter } => {
|