@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/agents.ts
CHANGED
|
@@ -33,7 +33,7 @@ export type PromptStyle =
|
|
|
33
33
|
export type AuthMode = 'oauth' | 'api_key' | 'aws';
|
|
34
34
|
|
|
35
35
|
export interface AgentSpec {
|
|
36
|
-
/** Registry key. Stable; used in Charters and
|
|
36
|
+
/** Registry key. Stable; used in Charters and record attribution. */
|
|
37
37
|
readonly id: string;
|
|
38
38
|
readonly label: string;
|
|
39
39
|
readonly command: string;
|
|
@@ -137,6 +137,11 @@ export const AGENTS: readonly AgentSpec[] = Object.freeze([
|
|
|
137
137
|
auth_local: 'oauth',
|
|
138
138
|
auth_headless: 'oauth',
|
|
139
139
|
stdio_json: true,
|
|
140
|
+
// `codex exec` defaults to a read-only sandbox, so a seated agent could read
|
|
141
|
+
// the session but not act through the CLI (found dogfooding: no vote could be
|
|
142
|
+
// cast). Per turn only: workspace-write, plus the session's git directory,
|
|
143
|
+
// which an enclosing repo may hold outside the workspace. Nothing is saved.
|
|
144
|
+
session_args: (ctx) => ['--sandbox', 'workspace-write', '--add-dir', ctx.git_dir],
|
|
140
145
|
notes:
|
|
141
146
|
'OpenAI, Rust-based. Bare `codex` is an interactive TUI; `exec` is headless. ' +
|
|
142
147
|
'Requires cwd to be a git repo — always true of a session repo.',
|
|
@@ -152,7 +157,7 @@ export const AGENTS: readonly AgentSpec[] = Object.freeze([
|
|
|
152
157
|
// agy's default mode sandboxes the commands it runs: paths outside the
|
|
153
158
|
// workspace are invisible and .git is read-only. An agent that votes
|
|
154
159
|
// through `politik` from inside its turn then cannot load the CLI or
|
|
155
|
-
// commit the act (
|
|
160
|
+
// commit the act (UAT, PR #38). `--settings` applies to this run
|
|
156
161
|
// only and is never saved; the grant is the session's own .git (write)
|
|
157
162
|
// and the CLI's install (read). The sandbox otherwise stays on.
|
|
158
163
|
session_args: (ctx) => [
|
|
@@ -220,7 +225,7 @@ export interface Invocation {
|
|
|
220
225
|
* Build the headless invocation for an agent.
|
|
221
226
|
*
|
|
222
227
|
* Returns command and args separately, never a shell string. The prompt carries
|
|
223
|
-
* a Charter, a
|
|
228
|
+
* a Charter, a record excerpt and arbitrary session text; interpolating that
|
|
224
229
|
* into a shell would be an injection vector on every spawn. Callers must pass
|
|
225
230
|
* this to a non-shell spawn.
|
|
226
231
|
*/
|
|
@@ -265,19 +270,21 @@ export const canRunHeadless = (agent: AgentSpec): boolean =>
|
|
|
265
270
|
|
|
266
271
|
export interface PromptContext {
|
|
267
272
|
readonly envelope: Envelope;
|
|
268
|
-
/** The
|
|
273
|
+
/** The handle this agent acts as (`--actor`), as recorded in the log. */
|
|
274
|
+
readonly actor: string;
|
|
275
|
+
/** The role this agent is seated in. */
|
|
269
276
|
readonly role: Role;
|
|
270
277
|
/** Verbs the Charter grants this role. */
|
|
271
278
|
readonly verbs: readonly Verb[];
|
|
272
|
-
/** Protocol vocabulary name, e.g.
|
|
279
|
+
/** Protocol vocabulary name, e.g. majority-vote. */
|
|
273
280
|
readonly protocol: string;
|
|
274
|
-
/** Recent
|
|
275
|
-
readonly
|
|
276
|
-
/**
|
|
277
|
-
readonly
|
|
281
|
+
/** Recent record, so a fresh agent has session context. */
|
|
282
|
+
readonly log_excerpt?: string;
|
|
283
|
+
/** Prose of the Charter. */
|
|
284
|
+
readonly charter?: string;
|
|
278
285
|
/**
|
|
279
286
|
* Whether the protocol permits escalation (ADR-0006). Defaults to true. When
|
|
280
|
-
* false — a Darwinist chamber — the agent is told there is no
|
|
287
|
+
* false — a Darwinist chamber — the agent is told there is no escalation:
|
|
281
288
|
* it decides within its mandate or exits, since an appeal has no resolver.
|
|
282
289
|
*/
|
|
283
290
|
readonly escalation_enabled?: boolean;
|
|
@@ -290,7 +297,7 @@ export interface PromptContext {
|
|
|
290
297
|
* agents: the same text goes to Claude Code and to Goose. Per-agent prompt
|
|
291
298
|
* tuning would make cross-protocol comparisons meaningless, and comparing
|
|
292
299
|
* behaviour under identical conditions is the entire point of the research
|
|
293
|
-
* layer (RESEARCH.md
|
|
300
|
+
* layer (RESEARCH.md).
|
|
294
301
|
*
|
|
295
302
|
* Structure: who you are, what you may do, what has happened, what to do now.
|
|
296
303
|
*/
|
|
@@ -298,32 +305,33 @@ export const composePrompt = (context: PromptContext): string => {
|
|
|
298
305
|
const sections: string[] = [
|
|
299
306
|
'# POLITIK SESSION',
|
|
300
307
|
'',
|
|
301
|
-
`You are a **${context.role}** in a governed multi-agent session running the`,
|
|
308
|
+
`You are ${/^[AEIOU]/.test(context.role) ? 'an' : 'a'} **${context.role}** in a governed multi-agent session running the`,
|
|
302
309
|
`**${context.protocol}** protocol. Session: \`${context.envelope.session_guid}\`.`,
|
|
310
|
+
`Your handle is \`${context.actor}\`. Every \`politik\` command you run acts as you: pass \`--actor ${context.actor} --role ${context.role}\`.`,
|
|
303
311
|
'',
|
|
304
312
|
'## Your mandate',
|
|
305
313
|
'',
|
|
306
314
|
`Verbs granted to your role: ${context.verbs.length > 0 ? context.verbs.join(', ') : 'none'}.`,
|
|
307
315
|
'You may not take an action your verbs do not grant.',
|
|
308
316
|
context.escalation_enabled === false
|
|
309
|
-
? 'This protocol has no escalation: there is no
|
|
317
|
+
? 'This protocol has no escalation: there is no escalation and no appeal. ' +
|
|
310
318
|
'Decide within your mandate, or exit. A decision here is final.'
|
|
311
|
-
: 'If you believe the correct action requires a verb you do not hold,
|
|
312
|
-
'
|
|
319
|
+
: 'If you believe the correct action requires a verb you do not hold, raise an ' +
|
|
320
|
+
'escalation instead of proceeding.',
|
|
313
321
|
'',
|
|
314
|
-
'##
|
|
322
|
+
'## Charter',
|
|
315
323
|
'',
|
|
316
|
-
context.
|
|
324
|
+
context.charter?.trim() || '_None supplied. Follow CANON defaults._',
|
|
317
325
|
'',
|
|
318
326
|
];
|
|
319
327
|
|
|
320
|
-
if (context.
|
|
328
|
+
if (context.log_excerpt !== undefined && context.log_excerpt.trim() !== '') {
|
|
321
329
|
sections.push(
|
|
322
330
|
'## Record so far',
|
|
323
331
|
'',
|
|
324
|
-
'The
|
|
332
|
+
'The record is the session. You are stateless; this is your context.',
|
|
325
333
|
'',
|
|
326
|
-
context.
|
|
334
|
+
context.log_excerpt.trim(),
|
|
327
335
|
'',
|
|
328
336
|
);
|
|
329
337
|
}
|
|
@@ -333,15 +341,19 @@ export const composePrompt = (context: PromptContext): string => {
|
|
|
333
341
|
'',
|
|
334
342
|
context.envelope.prompt.trim(),
|
|
335
343
|
'',
|
|
336
|
-
'## Rules of the
|
|
344
|
+
'## Rules of the session',
|
|
337
345
|
'',
|
|
338
346
|
'- Commit your result. Uncommitted work does not exist.',
|
|
339
|
-
'- Do not traverse above the working directory. Doing so is a
|
|
340
|
-
'
|
|
341
|
-
'- **
|
|
342
|
-
'
|
|
343
|
-
'
|
|
344
|
-
'
|
|
347
|
+
'- Do not traverse above the working directory. Doing so is a Charter',
|
|
348
|
+
' violation, logged to the record and escalated to the owner.',
|
|
349
|
+
'- **Act through the `politik` CLI.** Voting, vetoing, escalating and every',
|
|
350
|
+
' other governance act is a `politik` command; the command records the act',
|
|
351
|
+
' for you. Running it is how you act — it is not writing the record yourself.',
|
|
352
|
+
'- **Do not write to LOG.md, STATE.json or LEDGER.md at all** — not even',
|
|
353
|
+
' to append, and not by any means other than a `politik` command.',
|
|
354
|
+
' The RECORD agent owns them exclusively, and editing them directly is a',
|
|
355
|
+
' Charter violation. Your work is recorded for you; state your result in',
|
|
356
|
+
' your reply and it will be entered in the record.',
|
|
345
357
|
'- When your task is complete, stop. You are disposed after this turn.',
|
|
346
358
|
'',
|
|
347
359
|
);
|