@arcanea/council 0.1.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.
@@ -0,0 +1,182 @@
1
+ /**
2
+ * @arcanea/council — Type Definitions
3
+ *
4
+ * Rebranded from claude-flow swarm types to Arcanea Council terminology.
5
+ * Consensus algorithms become Council protocols. Swarm topology becomes
6
+ * Guardian Council formation. Queen becomes Shinkami.
7
+ *
8
+ * Backward-compatible interfaces (ConsensusProposal, ConsensusVote,
9
+ * ConsensusResult) preserve the original claude-flow field names so
10
+ * ported consensus implementations work without modification.
11
+ */
12
+ import { EventEmitter } from 'node:events';
13
+ import type { GuardianName, Element } from './external-types.js';
14
+ /**
15
+ * Available consensus protocols.
16
+ * - council-vote (Raft) — Leader-based, one Guardian leads
17
+ * - shinkamis-decree (Byzantine) — Fault-tolerant under hostile agents
18
+ * - whisper (Gossip) — Eventual consistency via propagation
19
+ * - gate-quorum (NEW) — Frequency-weighted voting across Guardians
20
+ * - ancient-accord (Paxos) — Falls back to Raft
21
+ */
22
+ export type CouncilProtocol = 'council-vote' | 'shinkamis-decree' | 'whisper' | 'gate-quorum' | 'ancient-accord';
23
+ /** Backward-compatible alias for claude-flow code */
24
+ export type ConsensusAlgorithm = CouncilProtocol;
25
+ export interface CouncilConfig {
26
+ protocol: CouncilProtocol;
27
+ threshold: number;
28
+ timeoutMs: number;
29
+ maxRounds: number;
30
+ requireQuorum: boolean;
31
+ }
32
+ /** Backward-compatible alias — ported code uses Partial<ConsensusConfig> */
33
+ export type ConsensusConfig = CouncilConfig;
34
+ /** A proposal submitted to the Council (Arcanea naming) */
35
+ export interface Petition {
36
+ id: string;
37
+ petitionerId: string;
38
+ value: unknown;
39
+ term: number;
40
+ timestamp: Date;
41
+ seals: Map<string, Seal>;
42
+ status: 'pending' | 'accepted' | 'rejected' | 'expired';
43
+ }
44
+ /**
45
+ * Backward-compatible proposal type for ported consensus code.
46
+ * Uses the original claude-flow field names (proposerId, votes).
47
+ */
48
+ export interface ConsensusProposal {
49
+ id: string;
50
+ proposerId: string;
51
+ value: unknown;
52
+ term: number;
53
+ timestamp: Date;
54
+ votes: Map<string, ConsensusVote>;
55
+ status: 'pending' | 'accepted' | 'rejected' | 'expired';
56
+ }
57
+ /** A Guardian's vote on a petition (Arcanea naming) */
58
+ export interface Seal {
59
+ guardianId: string;
60
+ approve: boolean;
61
+ confidence: number;
62
+ timestamp: Date;
63
+ reason?: string;
64
+ }
65
+ /**
66
+ * Backward-compatible vote type for ported consensus code.
67
+ * Uses the original claude-flow field name (voterId).
68
+ */
69
+ export interface ConsensusVote {
70
+ voterId: string;
71
+ approve: boolean;
72
+ confidence: number;
73
+ timestamp: Date;
74
+ reason?: string;
75
+ }
76
+ /** Result of a Council deliberation (Arcanea naming) */
77
+ export interface CouncilResult {
78
+ petitionId: string;
79
+ approved: boolean;
80
+ approvalRate: number;
81
+ participationRate: number;
82
+ finalValue: unknown;
83
+ rounds: number;
84
+ durationMs: number;
85
+ }
86
+ /**
87
+ * Backward-compatible result type for ported consensus code.
88
+ * Uses the original claude-flow field name (proposalId).
89
+ */
90
+ export interface ConsensusResult {
91
+ proposalId: string;
92
+ approved: boolean;
93
+ approvalRate: number;
94
+ participationRate: number;
95
+ finalValue: unknown;
96
+ rounds: number;
97
+ durationMs: number;
98
+ }
99
+ export interface ICouncilEngine extends EventEmitter {
100
+ initialize(config?: CouncilConfig): Promise<void>;
101
+ shutdown(): Promise<void>;
102
+ addNode(nodeId: string, options?: {
103
+ isPrimary?: boolean;
104
+ }): void;
105
+ removeNode(nodeId: string): void;
106
+ propose(value: unknown): Promise<Petition>;
107
+ vote(petitionId: string, seal: Seal): Promise<void>;
108
+ awaitConsensus(petitionId: string): Promise<CouncilResult>;
109
+ }
110
+ /** Backward-compatible alias */
111
+ export type IConsensusEngine = ICouncilEngine;
112
+ export type TopologyType = 'mesh' | 'hierarchical' | 'centralized' | 'hybrid';
113
+ export interface TopologyNode {
114
+ id: string;
115
+ agentId: string;
116
+ role: 'shinkami' | 'guardian' | 'servant' | 'equal';
117
+ status: 'active' | 'inactive' | 'syncing' | 'failed';
118
+ guardian?: GuardianName;
119
+ connections: string[];
120
+ metadata: Record<string, unknown>;
121
+ }
122
+ export interface GateQuorumConfig {
123
+ /** How many Guardians must participate (1-10) */
124
+ quorumSize: number;
125
+ /** Weight votes by Gate frequency (higher Hz = more weight) */
126
+ weightByFrequency: boolean;
127
+ /** Approval threshold as fraction of total weight (0-1) */
128
+ approvalThreshold: number;
129
+ /** How to break ties */
130
+ tieBreaker: 'highest-frequency' | 'element-affinity' | 'random';
131
+ /** Prefer Guardians of this element */
132
+ elementAffinity?: Element;
133
+ /** Timeout per vote in ms */
134
+ voteTimeoutMs: number;
135
+ /** Allow Shinkami override */
136
+ shinkamOverride: boolean;
137
+ }
138
+ export interface GateQuorumVote {
139
+ guardian: GuardianName;
140
+ frequency: number;
141
+ element: Element;
142
+ vote: 'approve' | 'reject' | 'abstain';
143
+ weight: number;
144
+ reason?: string;
145
+ timestamp: number;
146
+ }
147
+ export interface GateQuorumResult {
148
+ approved: boolean;
149
+ totalWeight: number;
150
+ approvalWeight: number;
151
+ rejectionWeight: number;
152
+ abstainWeight: number;
153
+ votes: GateQuorumVote[];
154
+ shinkamOverrideUsed: boolean;
155
+ durationMs: number;
156
+ }
157
+ export declare const COUNCIL_CONSTANTS: {
158
+ readonly DEFAULT_HEARTBEAT_INTERVAL_MS: 5000;
159
+ readonly DEFAULT_HEALTH_CHECK_INTERVAL_MS: 10000;
160
+ readonly DEFAULT_TASK_TIMEOUT_MS: 300000;
161
+ readonly DEFAULT_CONSENSUS_TIMEOUT_MS: 30000;
162
+ readonly DEFAULT_MESSAGE_TTL_MS: 60000;
163
+ readonly DEFAULT_MAX_AGENTS: 100;
164
+ readonly DEFAULT_MAX_TASKS: 1000;
165
+ readonly DEFAULT_CONSENSUS_THRESHOLD: 0.66;
166
+ readonly MAX_QUEUE_SIZE: 10000;
167
+ readonly MAX_RETRIES: 3;
168
+ };
169
+ /** Backward-compatible alias */
170
+ export declare const SWARM_CONSTANTS: {
171
+ readonly DEFAULT_HEARTBEAT_INTERVAL_MS: 5000;
172
+ readonly DEFAULT_HEALTH_CHECK_INTERVAL_MS: 10000;
173
+ readonly DEFAULT_TASK_TIMEOUT_MS: 300000;
174
+ readonly DEFAULT_CONSENSUS_TIMEOUT_MS: 30000;
175
+ readonly DEFAULT_MESSAGE_TTL_MS: 60000;
176
+ readonly DEFAULT_MAX_AGENTS: 100;
177
+ readonly DEFAULT_MAX_TASKS: 1000;
178
+ readonly DEFAULT_CONSENSUS_THRESHOLD: 0.66;
179
+ readonly MAX_QUEUE_SIZE: 10000;
180
+ readonly MAX_RETRIES: 3;
181
+ };
182
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAIjE;;;;;;;GAOG;AACH,MAAM,MAAM,eAAe,GACvB,cAAc,GACd,kBAAkB,GAClB,SAAS,GACT,aAAa,GACb,gBAAgB,CAAC;AAErB,qDAAqD;AACrD,MAAM,MAAM,kBAAkB,GAAG,eAAe,CAAC;AAEjD,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,eAAe,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,4EAA4E;AAC5E,MAAM,MAAM,eAAe,GAAG,aAAa,CAAC;AAI5C,2DAA2D;AAC3D,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,CAAC;IACrB,KAA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ow swarm types to Arcanea Council terminology.
5
+ * Consensus algorithms become Council protocols. Swarm topology becomes
6
+ * Guardian Council formation. Queen becomes Shinkami.
7
+ *
8
+ * Backward-compatible interfaces (ConsensusProposal, ConsensusVote,
9
+ * ConsensusResult) preserve the original claude-flow field names so
10
+ * ported consensus implementations work without modification.
11
+ */
12
+ // ── Constants ────────────────────────────────────────────────
13
+ export const COUNCIL_CONSTANTS = {
14
+ DEFAULT_HEARTBEAT_INTERVAL_MS: 5000,
15
+ DEFAULT_HEALTH_CHECK_INTERVAL_MS: 10000,
16
+ DEFAULT_TASK_TIMEOUT_MS: 300000,
17
+ DEFAULT_CONSENSUS_TIMEOUT_MS: 30000,
18
+ DEFAULT_MESSAGE_TTL_MS: 60000,
19
+ DEFAULT_MAX_AGENTS: 100,
20
+ DEFAULT_MAX_TASKS: 1000,
21
+ DEFAULT_CONSENSUS_THRESHOLD: 0.66,
22
+ MAX_QUEUE_SIZE: 10000,
23
+ MAX_RETRIES: 3,
24
+ };
25
+ /** Backward-compatible alias */
26
+ export const SWARM_CONSTANTS = COUNCIL_CONSTANTS;
27
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAwLH,gEAAgE;AAEhE,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,6BAA6B,EAAE,IAAI;IACnC,gCAAgC,EAAE,KAAK;IACvC,uBAAuB,EAAE,MAAM;IAC/B,4BAA4B,EAAE,KAAK;IACnC,sBAAsB,EAAE,KAAK;IAC7B,kBAAkB,EAAE,GAAG;IACvB,iBAAiB,EAAE,IAAI;IACvB,2BAA2B,EAAE,IAAI;IACjC,cAAc,EAAE,KAAK;IACrB,WAAW,EAAE,CAAC;CACN,CAAC;AAEX,gCAAgC;AAChC,MAAM,CAAC,MAAM,eAAe,GAAG,iBAAiB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@arcanea/council",
3
+ "version": "0.1.0",
4
+ "description": "Guardian Council consensus mechanics — Byzantine, Raft, Gossip, and Gate Quorum protocols for the Ten Guardians",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "./consensus": {
14
+ "types": "./dist/consensus/index.d.ts",
15
+ "import": "./dist/consensus/index.js"
16
+ }
17
+ },
18
+ "scripts": {
19
+ "build": "tsc",
20
+ "dev": "tsc --watch",
21
+ "clean": "rm -rf dist",
22
+ "typecheck": "tsc --noEmit",
23
+ "test": "node --test tests/council.test.mjs"
24
+ },
25
+ "keywords": [
26
+ "arcanea",
27
+ "council",
28
+ "consensus",
29
+ "guardian",
30
+ "byzantine",
31
+ "raft",
32
+ "gossip"
33
+ ],
34
+ "license": "MIT",
35
+ "files": [
36
+ "dist",
37
+ "README.md"
38
+ ],
39
+ "publishConfig": {
40
+ "access": "public"
41
+ },
42
+ "dependencies": {
43
+ "@arcanea/guardian-memory": "workspace:*"
44
+ },
45
+ "devDependencies": {
46
+ "@types/node": "^25.3.0",
47
+ "typescript": "^5.5.0"
48
+ }
49
+ }