@cordfuse/politik 0.3.1 → 0.5.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/src/charter.ts CHANGED
@@ -39,6 +39,22 @@ import { isTerminationPolicy, type TerminationPolicy } from './prorogation.ts';
39
39
  export const charterFingerprint = (source: string): string =>
40
40
  createHash('sha256').update(source, 'utf8').digest('hex');
41
41
 
42
+ /**
43
+ * Fingerprint of a session's instruction files (ADR-0010 §4) — AGENTS.md and the
44
+ * harness pointers — as one value. Order-independent, and adding or removing a
45
+ * file changes it, so planting a new instruction file is caught as surely as
46
+ * editing an existing one.
47
+ */
48
+ export const instructionsFingerprint = (
49
+ files: ReadonlyArray<{ readonly path: string; readonly content: string }>,
50
+ ): string => {
51
+ const hash = createHash('sha256');
52
+ for (const f of [...files].sort((a, b) => a.path.localeCompare(b.path))) {
53
+ hash.update(f.path, 'utf8').update('\0').update(f.content, 'utf8').update('\0');
54
+ }
55
+ return hash.digest('hex');
56
+ };
57
+
42
58
  /* -------------------------------------------------------------------------- */
43
59
  /* Schema */
44
60
  /* -------------------------------------------------------------------------- */
@@ -81,6 +97,17 @@ export interface SessionBlock {
81
97
  readonly deadline: string | null;
82
98
  readonly merge_strategy: MergeStrategy;
83
99
  readonly assent: Role;
100
+ /**
101
+ * ADR-0010: whether assent, rule and prorogue requested by an AI harness or a
102
+ * script are staged for the Speaker's confirmation. Absent means 'off', so every
103
+ * session convened before ADR-0010 behaves exactly as it did.
104
+ */
105
+ readonly speaker_confirmation: 'required' | 'off';
106
+ /**
107
+ * ADR-0011: whether a confirmed act's commit must be signed with the confirming
108
+ * person's git signing key. Absent means 'off'.
109
+ */
110
+ readonly signed_confirmations: 'required' | 'off';
84
111
  readonly endurance: Endurance;
85
112
  }
86
113
 
@@ -334,6 +361,8 @@ export const parseCharter = (source: string): ParseResult => {
334
361
  // rule and let a bad assent silently open a session (AUDIT #8).
335
362
  assent: session['assent'] === undefined ? 'AUTHORITY' : (session['assent'] as Role),
336
363
  stale_action: session['stale_action'] === 'dissolve' ? 'dissolve' : 'suspend',
364
+ speaker_confirmation: session['speaker_confirmation'] === 'required' ? 'required' : 'off',
365
+ signed_confirmations: session['signed_confirmations'] === 'required' ? 'required' : 'off',
337
366
  checkpoint_interval_hours: asNumberOrNull(session['checkpoint_interval_hours']),
338
367
  endurance: {
339
368
  max_motions: asNumberOrNull(endurance['max_motions']),