@manifesto-ai/governance 3.1.0 → 3.1.2

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/README.md CHANGED
@@ -10,12 +10,14 @@
10
10
 
11
11
  ```ts
12
12
  import { createManifesto } from "@manifesto-ai/sdk";
13
+ import { createInMemoryLineageStore, withLineage } from "@manifesto-ai/lineage";
13
14
  import { withGovernance } from "@manifesto-ai/governance";
14
15
 
15
16
  const governed = withGovernance(
16
- createManifesto<CounterDomain>(schema, effects),
17
+ withLineage(createManifesto<CounterDomain>(schema, effects), {
18
+ store: createInMemoryLineageStore(),
19
+ }),
17
20
  {
18
- lineage: { store },
19
21
  bindings,
20
22
  execution: {
21
23
  projectionId: "counter",
@@ -44,9 +46,9 @@ const proposal = await governed.proposeAsync(
44
46
 
45
47
  ## What Changes After Governance Activation
46
48
 
47
- - direct `dispatchAsync` no longer exists
49
+ - direct `dispatchAsync` and `commitAsync` no longer exist
48
50
  - the canonical state-change path becomes `proposeAsync() -> approve()/reject()`
49
- - lineage is guaranteed at runtime
51
+ - lineage must be composed before governance activation
50
52
  - visible snapshots publish only after approved execution seals successfully
51
53
 
52
54
  ## Low-Level Surface Still Available
@@ -0,0 +1,6 @@
1
+ import type { ActorAuthorityBinding, AuthorityResponse, Proposal } from "../types.js";
2
+ import type { AuthorityHandler } from "./types.js";
3
+ export declare class AutoApproveHandler implements AuthorityHandler {
4
+ evaluate(proposal: Proposal, binding: ActorAuthorityBinding): Promise<AuthorityResponse>;
5
+ }
6
+ export declare function createAutoApproveHandler(): AutoApproveHandler;
@@ -0,0 +1,33 @@
1
+ import type { ActorAuthorityBinding, AuthorityKind, AuthorityResponse, IntentScope, Proposal } from "../types.js";
2
+ import type { AuthorityHandler } from "./types.js";
3
+ import { AutoApproveHandler } from "./auto.js";
4
+ import { HITLHandler } from "./hitl.js";
5
+ import { PolicyRulesHandler } from "./policy.js";
6
+ import { TribunalHandler } from "./tribunal.js";
7
+ export declare class AuthorityEvaluator {
8
+ private readonly handlers;
9
+ private readonly autoHandler;
10
+ private readonly policyHandler;
11
+ private readonly hitlHandler;
12
+ private readonly tribunalHandler;
13
+ constructor();
14
+ evaluate(proposal: Proposal, binding: ActorAuthorityBinding): Promise<AuthorityResponse>;
15
+ registerHandler(policyMode: string, handler: AuthorityHandler): void;
16
+ getAutoHandler(): AutoApproveHandler;
17
+ getPolicyHandler(): PolicyRulesHandler;
18
+ getHITLHandler(): HITLHandler;
19
+ getTribunalHandler(): TribunalHandler;
20
+ getAuthorityKind(policyMode: string): AuthorityKind | null;
21
+ submitHITLDecision(proposalId: string, decision: "approved" | "rejected", reasoning?: string, approvedScope?: IntentScope | null): void;
22
+ submitTribunalVote(proposalId: string, voter: {
23
+ actorId: string;
24
+ kind: "human" | "agent" | "system";
25
+ name?: string;
26
+ }, decision: "approve" | "reject" | "abstain", reasoning?: string): void;
27
+ hasPendingHITL(): boolean;
28
+ hasPendingTribunal(): boolean;
29
+ getPendingHITLIds(): string[];
30
+ getPendingTribunalIds(): string[];
31
+ clearAllPending(): void;
32
+ }
33
+ export declare function createAuthorityEvaluator(): AuthorityEvaluator;
@@ -0,0 +1,14 @@
1
+ import type { ActorAuthorityBinding, AuthorityResponse, IntentScope, Proposal } from "../types.js";
2
+ import type { AuthorityHandler } from "./types.js";
3
+ export type HITLNotificationCallback = (proposalId: string, proposal: Proposal, binding: ActorAuthorityBinding) => void;
4
+ export declare class HITLHandler implements AuthorityHandler {
5
+ private readonly pendingDecisions;
6
+ private readonly notificationCallbacks;
7
+ onPendingDecision(callback: HITLNotificationCallback): () => void;
8
+ evaluate(proposal: Proposal, binding: ActorAuthorityBinding): Promise<AuthorityResponse>;
9
+ submitDecision(proposalId: string, decision: "approved" | "rejected", reasoning?: string, approvedScope?: IntentScope | null): void;
10
+ isPending(proposalId: string): boolean;
11
+ getPendingIds(): string[];
12
+ clearAllPending(): void;
13
+ }
14
+ export declare function createHITLHandler(): HITLHandler;
@@ -0,0 +1,12 @@
1
+ import type { ActorAuthorityBinding, AuthorityResponse, Proposal } from "../types.js";
2
+ import type { AuthorityHandler } from "./types.js";
3
+ export type CustomConditionEvaluator = (proposal: Proposal, binding: ActorAuthorityBinding) => boolean;
4
+ export declare class PolicyRulesHandler implements AuthorityHandler {
5
+ private readonly customEvaluators;
6
+ registerCustomEvaluator(name: string, evaluator: CustomConditionEvaluator): void;
7
+ evaluate(proposal: Proposal, binding: ActorAuthorityBinding): Promise<AuthorityResponse>;
8
+ private evaluateCondition;
9
+ private matchPattern;
10
+ private applyDecision;
11
+ }
12
+ export declare function createPolicyRulesHandler(): PolicyRulesHandler;
@@ -0,0 +1,16 @@
1
+ import type { ActorAuthorityBinding, ActorRef, AuthorityResponse, Proposal, Vote } from "../types.js";
2
+ import type { AuthorityHandler } from "./types.js";
3
+ export type TribunalNotificationCallback = (proposalId: string, proposal: Proposal, members: readonly ActorRef[]) => void;
4
+ export declare class TribunalHandler implements AuthorityHandler {
5
+ private readonly pendingTribunals;
6
+ private notificationCallback?;
7
+ onPendingTribunal(callback: TribunalNotificationCallback): void;
8
+ evaluate(proposal: Proposal, binding: ActorAuthorityBinding): Promise<AuthorityResponse>;
9
+ submitVote(proposalId: string, voter: ActorRef, decision: "approve" | "reject" | "abstain", reasoning?: string): void;
10
+ isPending(proposalId: string): boolean;
11
+ getVotes(proposalId: string): Vote[];
12
+ getPendingIds(): string[];
13
+ clearAllPending(): void;
14
+ private checkQuorum;
15
+ }
16
+ export declare function createTribunalHandler(): TribunalHandler;
@@ -0,0 +1,14 @@
1
+ import type { ActorAuthorityBinding, AuthorityResponse, Proposal } from "../types.js";
2
+ export interface AuthorityHandler {
3
+ evaluate(proposal: Proposal, binding: ActorAuthorityBinding): Promise<AuthorityResponse>;
4
+ }
5
+ export interface HITLDecisionCallback {
6
+ (proposalId: string, decision: "approved" | "rejected", reasoning?: string): void;
7
+ }
8
+ export interface HITLPendingState {
9
+ proposalId: string;
10
+ proposal?: Proposal;
11
+ resolve: (response: AuthorityResponse) => void;
12
+ reject: (error: Error) => void;
13
+ timeoutId?: ReturnType<typeof setTimeout>;
14
+ }
@@ -0,0 +1,7 @@
1
+ import { type GovernanceEventDispatcher, type GovernanceEventSink, type GovernanceService } from "./types.js";
2
+ export interface CreateGovernanceEventDispatcherOptions {
3
+ readonly service: Pick<GovernanceService, "createExecutionCompletedEvent" | "createExecutionFailedEvent" | "createWorldCreatedEvent" | "createWorldForkedEvent">;
4
+ readonly sink?: GovernanceEventSink;
5
+ readonly now?: () => number;
6
+ }
7
+ export declare function createGovernanceEventDispatcher(options: CreateGovernanceEventDispatcherOptions): GovernanceEventDispatcher;