@manifesto-ai/governance 3.13.1 → 5.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.
- package/README.md +24 -19
- package/dist/action-payload.d.ts +9 -0
- package/dist/chunk-HI32V6PR.js +1 -0
- package/dist/governance-runtime.d.ts +28 -0
- package/dist/governance-scope.d.ts +15 -0
- package/dist/index.d.ts +1 -3
- package/dist/index.js +1 -1
- package/dist/provider.js +1 -1
- package/dist/recovery.d.ts +14 -0
- package/dist/runtime-deps.d.ts +28 -0
- package/dist/runtime-types.d.ts +5 -5
- package/dist/service/governance-service.d.ts +2 -2
- package/dist/settlement-observation.d.ts +11 -0
- package/dist/settlement.d.ts +16 -0
- package/dist/snapshot-errors.d.ts +2 -0
- package/dist/submission.d.ts +16 -0
- package/dist/types.d.ts +8 -4
- package/dist/wait-for-proposal.d.ts +4 -4
- package/package.json +11 -11
- package/dist/chunk-2Q3OH2FH.js +0 -1
package/README.md
CHANGED
|
@@ -1,26 +1,31 @@
|
|
|
1
1
|
# @manifesto-ai/governance
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> Optional protocol extension for approval, policy, delegation, and proposal review.
|
|
4
4
|
|
|
5
|
-
`@manifesto-ai/governance`
|
|
5
|
+
`@manifesto-ai/governance` turns a composable Manifesto app into an
|
|
6
|
+
approval-gated runtime when the product needs that protocol. It is not part of
|
|
7
|
+
the base runtime ontology. Its public entry is `withGovernance(manifesto,
|
|
8
|
+
config)`.
|
|
6
9
|
|
|
7
|
-
> **Current Contract Note:** The current package contract is [docs/governance-SPEC.md](docs/governance-SPEC.md). The v2.0.0 governance spec remains as the historical service-first baseline. The current
|
|
10
|
+
> **Current Contract Note:** The current package contract is [docs/governance-SPEC.md](docs/governance-SPEC.md). The v2.0.0 governance spec remains as the historical service-first baseline. The current runtime surface uses governance-mode `action.<name>.submit(...)` plus `waitForSettlement(ref)`.
|
|
8
11
|
|
|
9
|
-
##
|
|
12
|
+
## Extension Runtime Path
|
|
10
13
|
|
|
11
14
|
```ts
|
|
12
15
|
import { createManifesto } from "@manifesto-ai/sdk";
|
|
13
16
|
import { createInMemoryLineageStore, withLineage } from "@manifesto-ai/lineage";
|
|
14
|
-
import {
|
|
17
|
+
import { withGovernance } from "@manifesto-ai/governance";
|
|
18
|
+
import TodoMel from "./domain/todo.mel";
|
|
19
|
+
import type { TodoDomain } from "./domain/todo.domain";
|
|
15
20
|
|
|
16
21
|
const governed = withGovernance(
|
|
17
|
-
withLineage(createManifesto<
|
|
22
|
+
withLineage(createManifesto<TodoDomain>(TodoMel, effects), {
|
|
18
23
|
store: createInMemoryLineageStore(),
|
|
19
24
|
}),
|
|
20
25
|
{
|
|
21
26
|
bindings,
|
|
22
27
|
execution: {
|
|
23
|
-
projectionId: "
|
|
28
|
+
projectionId: "todo",
|
|
24
29
|
deriveActor(intent) {
|
|
25
30
|
return { actorId: "agent:demo", kind: "agent" };
|
|
26
31
|
},
|
|
@@ -31,40 +36,40 @@ const governed = withGovernance(
|
|
|
31
36
|
},
|
|
32
37
|
).activate();
|
|
33
38
|
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
)
|
|
37
|
-
|
|
39
|
+
const pending = await governed.action.addTodo.submit("Review docs");
|
|
40
|
+
const settlement = pending.ok
|
|
41
|
+
? await pending.waitForSettlement()
|
|
42
|
+
: pending;
|
|
38
43
|
```
|
|
39
44
|
|
|
40
45
|
## What This Package Owns
|
|
41
46
|
|
|
42
47
|
- `withGovernance()` and the activated `GovernanceInstance`
|
|
43
|
-
- proposal lifecycle and
|
|
48
|
+
- proposal lifecycle and approval policy evaluation
|
|
44
49
|
- pending human/tribunal resolution through `approve()` / `reject()`
|
|
45
|
-
- additive proposal-settlement observation through `
|
|
50
|
+
- additive proposal-settlement observation through `waitForSettlement()`
|
|
46
51
|
- governance decision records and post-commit governance events
|
|
47
52
|
- lineage-preserving query access such as `getWorldSnapshot()`, `getLatestHead()`, and `getBranches()`
|
|
48
|
-
- low-level governance stores, services,
|
|
53
|
+
- low-level governance stores, services, approval handlers, and intent-instance helpers via `@manifesto-ai/governance/provider`
|
|
49
54
|
|
|
50
55
|
## What Changes After Governance Activation
|
|
51
56
|
|
|
52
|
-
- direct
|
|
53
|
-
- the
|
|
54
|
-
- `
|
|
57
|
+
- direct root write verbs from earlier runtimes no longer exist
|
|
58
|
+
- the extension state-change path becomes `action.x.submit() -> approve()/reject() -> waitForSettlement()`
|
|
59
|
+
- `waitForSettlement()` is an observation helper, not a state-change verb
|
|
55
60
|
- lineage must be composed before governance activation
|
|
56
61
|
- visible snapshots publish only after approved execution seals successfully
|
|
57
62
|
- `getWorldSnapshot(worldId)` remains the stored sealed canonical snapshot lookup; `restore(worldId)` remains the normalized resume path inherited from lineage
|
|
58
63
|
|
|
59
64
|
## Low-Level Surface Still Available
|
|
60
65
|
|
|
61
|
-
The provider entry point remains public for lower-level tooling and
|
|
66
|
+
The provider entry point remains public for lower-level tooling and integration tests:
|
|
62
67
|
|
|
63
68
|
- `@manifesto-ai/governance/provider`
|
|
64
69
|
- `createGovernanceService()`
|
|
65
70
|
- `createGovernanceEventDispatcher()`
|
|
66
71
|
- `createAuthorityEvaluator()`
|
|
67
|
-
-
|
|
72
|
+
- approval handlers and lifecycle types
|
|
68
73
|
|
|
69
74
|
`createInMemoryGovernanceStore()` also remains available from the root package as a consumer-safe bootstrap helper.
|
|
70
75
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ManifestoError } from "@manifesto-ai/sdk";
|
|
2
|
+
export declare function cloneAndFreezeActionPayload<T>(value: T): T;
|
|
3
|
+
export declare function tryCloneAndFreezeActionPayload<T>(value: T): {
|
|
4
|
+
readonly ok: true;
|
|
5
|
+
readonly value: T;
|
|
6
|
+
} | {
|
|
7
|
+
readonly ok: false;
|
|
8
|
+
readonly error: ManifestoError;
|
|
9
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function E(t){return t??`prop-${crypto.randomUUID()}`}function y(t){return t??`dec-${crypto.randomUUID()}`}function W(t,e=1){return`${t}:${e}`}var Q=({proposalId:t,attempt:e})=>W(t,e);function b(){return{emit(){}}}function X(t){return"body"in t?{type:t.body.type,input:t.body.input,intentId:t.intentId}:{type:t.type,input:t.input,intentId:t.intentId}}var j=["submitted","evaluating"],O=["approved","executing"],$=["rejected","completed","failed","superseded"],J=["approved","rejected"],A={submitted:["evaluating","rejected","superseded"],evaluating:["approved","rejected","superseded"],approved:["executing"],rejected:[],executing:["completed","failed"],completed:[],failed:[],superseded:[]};function x(t){return j.includes(t)}function c(t){return O.includes(t)}function Z(t){return $.includes(t)}function S(t,e){return A[t].includes(e)}function w(t){return[...A[t]]}function R(t,e){return t==="submitted"&&e==="rejected"||t==="evaluating"&&e==="approved"||t==="evaluating"&&e==="rejected"}function l(t){return structuredClone(t)}var m=class{proposals=new Map;decisions=new Map;actorBindings=new Map;async putProposal(e){this.proposals.set(e.proposalId,l(e))}async getProposal(e){return l(this.proposals.get(e)??null)}async getProposalsByBranch(e){return[...this.proposals.values()].filter(r=>r.branchId===e).sort((r,o)=>r.submittedAt!==o.submittedAt?r.submittedAt-o.submittedAt:r.proposalId.localeCompare(o.proposalId)).map(r=>l(r))}async getExecutionStageProposal(e){let r=(await this.getProposalsByBranch(e)).filter(o=>c(o.status));if(r.length>1)throw new Error(`GOV-STORE-4 violation: multiple execution-stage proposals found for branch ${e}`);return r[0]??null}async putDecisionRecord(e){this.decisions.set(e.decisionId,l(e))}async getDecisionRecord(e){return l(this.decisions.get(e)??null)}async putActorBinding(e){this.actorBindings.set(e.actorId,l(e))}async getActorBinding(e){return l(this.actorBindings.get(e)??null)}async getActorBindings(){return[...this.actorBindings.values()].sort((e,r)=>e.actorId.localeCompare(r.actorId)).map(e=>l(e))}snapshotState(){return{proposals:l(this.proposals),decisions:l(this.decisions),actorBindings:l(this.actorBindings)}}restoreState(e){this.proposals.clear();for(let[r,o]of e.proposals)this.proposals.set(r,l(o));this.decisions.clear();for(let[r,o]of e.decisions)this.decisions.set(r,l(o));this.actorBindings.clear();for(let[r,o]of e.actorBindings)this.actorBindings.set(r,l(o))}};function oe(){return new m}var h=class{async evaluate(e,r){if(r.policy.mode!=="auto_approve")throw new Error(`AutoApproveHandler received non-auto_approve policy: ${r.policy.mode}`);return{kind:"approved",approvedScope:e.intent.scopeProposal??null}}};function T(){return new h}var v=class{pendingDecisions=new Map;notificationCallbacks=new Set;onPendingDecision(e){return this.notificationCallbacks.add(e),()=>{this.notificationCallbacks.delete(e)}}async evaluate(e,r){if(r.policy.mode!=="hitl")throw new Error(`HITLHandler received non-hitl policy: ${r.policy.mode}`);let o=r.policy,n=e.proposalId;if(this.pendingDecisions.has(n))throw new Error(`Proposal ${n} already has a pending HITL decision`);return new Promise((i,a)=>{let s={proposalId:n,proposal:e,resolve:i,reject:a};o.timeout!=null&&(s.timeoutId=setTimeout(()=>{if(this.pendingDecisions.delete(n),o.onTimeout==="approve"){i({kind:"approved",approvedScope:e.intent.scopeProposal??null});return}a(new Error(`HITL decision timed out after ${o.timeout}ms for proposal '${n}'`))},o.timeout)),this.pendingDecisions.set(n,s);for(let p of this.notificationCallbacks)p(n,e,r)})}submitDecision(e,r,o,n){let i=this.pendingDecisions.get(e);if(!i)throw new Error(`No pending HITL decision for proposal ${e}`);if(i.timeoutId&&clearTimeout(i.timeoutId),this.pendingDecisions.delete(e),r==="approved"){i.resolve({kind:"approved",approvedScope:n!==void 0?n:i.proposal?.intent.scopeProposal??null});return}i.resolve({kind:"rejected",reason:o??"Human rejected"})}isPending(e){return this.pendingDecisions.has(e)}getPendingIds(){return[...this.pendingDecisions.keys()]}clearAllPending(){for(let[e,r]of this.pendingDecisions)r.timeoutId&&clearTimeout(r.timeoutId),r.reject(new Error(`HITL handler cleared pending proposal ${e}`));this.pendingDecisions.clear()}};function k(){return new v}var I=class{customEvaluators=new Map;registerCustomEvaluator(e,r){this.customEvaluators.set(e,r)}async evaluate(e,r){if(r.policy.mode!=="policy_rules")throw new Error(`PolicyRulesHandler received non-policy_rules policy: ${r.policy.mode}`);let o=e.intent.scopeProposal??null;for(let n of r.policy.rules)if(this.evaluateCondition(n.condition,e,r))return this.applyDecision(n,o);return this.applyDecision({decision:r.policy.defaultDecision,reason:"Default policy decision"},o)}evaluateCondition(e,r,o){switch(e.kind){case"intent_type":return e.types.includes(r.intent.type);case"scope_pattern":return this.matchPattern(r.intent.type,e.pattern);case"custom":{let n=this.customEvaluators.get(e.evaluator);return n?n(r,o):!1}}}matchPattern(e,r){return new RegExp(`^${r.replace(/\*/g,".*").replace(/\?/g,".")}$`).test(e)}applyDecision(e,r){switch(e.decision){case"approve":return{kind:"approved",approvedScope:r};case"reject":return{kind:"rejected",reason:e.reason??"Policy rejection"};case"escalate":return{kind:"rejected",reason:e.reason??"Policy requires escalation (not implemented)"}}}};function H(){return new I}var f=class{pendingTribunals=new Map;notificationCallback;onPendingTribunal(e){this.notificationCallback=e}async evaluate(e,r){if(r.policy.mode!=="tribunal")throw new Error(`TribunalHandler received non-tribunal policy: ${r.policy.mode}`);let o=r.policy,n=e.proposalId;if(this.pendingTribunals.has(n))throw new Error(`Proposal ${n} already has a pending tribunal`);return new Promise((i,a)=>{let s={proposalId:n,proposal:e,binding:r,votes:new Map,resolve:i,reject:a};o.timeout!=null&&(s.timeoutId=setTimeout(()=>{if(this.pendingTribunals.delete(n),o.onTimeout==="approve"){i({kind:"approved",approvedScope:e.intent.scopeProposal??null});return}a(new Error(`Tribunal decision timed out after ${o.timeout}ms for proposal '${n}'`))},o.timeout)),this.pendingTribunals.set(n,s),this.notificationCallback?.(n,e,o.members)})}submitVote(e,r,o,n){let i=this.pendingTribunals.get(e);if(!i)throw new Error(`No pending tribunal for proposal ${e}`);if(i.votes.has(r.actorId))throw new Error(`Actor ${r.actorId} already voted on proposal ${e}`);if(!(i.binding.policy.mode==="tribunal"?i.binding.policy.members.some(({actorId:s})=>s===r.actorId):!1))throw new Error(`Actor ${r.actorId} is not a tribunal member for proposal ${e}`);i.votes.set(r.actorId,{voter:r,decision:o,reasoning:n,votedAt:Date.now()}),this.checkQuorum(i)}isPending(e){return this.pendingTribunals.has(e)}getVotes(e){let r=this.pendingTribunals.get(e);return r?[...r.votes.values()]:[]}getPendingIds(){return[...this.pendingTribunals.keys()]}clearAllPending(){for(let[e,r]of this.pendingTribunals)r.timeoutId&&clearTimeout(r.timeoutId),r.reject(new Error(`Tribunal handler cleared pending proposal ${e}`));this.pendingTribunals.clear()}checkQuorum(e){let r=e.binding.policy;if(r.mode!=="tribunal")return;let o=r.members.length,n=0,i=0;for(let p of e.votes.values())p.decision==="approve"?n++:p.decision==="reject"&&i++;let a=!1,s=!1;switch(r.quorum.kind){case"unanimous":n===o?(a=!0,s=!0):(i>0||e.votes.size===o)&&(a=!0);break;case"majority":{let p=Math.floor(o/2)+1;n>=p?(a=!0,s=!0):i>=p?a=!0:e.votes.size===o&&(a=!0,s=n>i);break}case"threshold":n>=r.quorum.count?(a=!0,s=!0):i>o-r.quorum.count?a=!0:e.votes.size===o&&(a=!0,s=n>=r.quorum.count);break}if(a){if(e.timeoutId&&clearTimeout(e.timeoutId),this.pendingTribunals.delete(e.proposalId),s){e.resolve({kind:"approved",approvedScope:e.proposal.intent.scopeProposal??null});return}e.resolve({kind:"rejected",reason:`Tribunal rejected (${n}/${o} approved)`})}}};function B(){return new f}var V={auto_approve:"auto",hitl:"human",policy_rules:"policy",tribunal:"tribunal"},g=class{handlers=new Map;autoHandler;policyHandler;hitlHandler;tribunalHandler;constructor(){this.autoHandler=T(),this.policyHandler=H(),this.hitlHandler=k(),this.tribunalHandler=B(),this.handlers.set("auto_approve",this.autoHandler),this.handlers.set("hitl",this.hitlHandler),this.handlers.set("policy_rules",this.policyHandler),this.handlers.set("tribunal",this.tribunalHandler)}async evaluate(e,r){let o=this.handlers.get(r.policy.mode);if(!o)throw new Error(`Unknown policy mode: ${r.policy.mode}`);return o.evaluate(e,r)}registerHandler(e,r){this.handlers.set(e,r)}getAutoHandler(){return this.autoHandler}getPolicyHandler(){return this.policyHandler}getHITLHandler(){return this.hitlHandler}getTribunalHandler(){return this.tribunalHandler}getAuthorityKind(e){return V[e]??null}submitHITLDecision(e,r,o,n){this.hitlHandler.submitDecision(e,r,o,n)}submitTribunalVote(e,r,o,n){this.tribunalHandler.submitVote(e,r,o,n)}hasPendingHITL(){return this.hitlHandler.getPendingIds().length>0}hasPendingTribunal(){return this.tribunalHandler.getPendingIds().length>0}getPendingHITLIds(){return this.hitlHandler.getPendingIds()}getPendingTribunalIds(){return this.tribunalHandler.getPendingIds()}clearAllPending(){this.hitlHandler.clearAllPending(),this.tribunalHandler.clearAllPending()}};function ve(){return new g}function u(t){return t.system.lastError??K(t)}function K(t){let e=t.namespaces?.host;if(e&&typeof e=="object"&&!Array.isArray(e)){let r=e.lastError;if(L(r))return r}return null}function L(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.code=="string"&&typeof e.message=="string"&&typeof e.timestamp=="number"&&!!e.source&&typeof e.source=="object"&&typeof e.source.actionId=="string"&&typeof e.source.nodePath=="string"}function D(t){let e=u(t)??void 0,r=t.system.pendingRequirements.map(o=>o.id);return{summary:_(e?1:0,r.length),...e?{currentError:e}:{},...r.length>0?{pendingRequirements:r}:{}}}function _(t,e){return t>0&&e>0?`Execution failed with ${t} error(s) and ${e} pending requirement(s)`:t>0?`Execution failed with ${t} error(s)`:e>0?`Execution failed with ${e} pending requirement(s)`:"Execution failed"}function Ae(t){let e=t.sink??b(),r=t.now??Date.now;return{emitSealCompleted(o,n){let i=r(),a=o.proposal.status==="completed"?"completed":"failed";if(e.emit(t.service.createWorldCreatedEvent(n.world,o.proposal.proposalId,N(o,n),a,i)),q(n)&&e.emit(t.service.createWorldForkedEvent(o.proposal.branchId,n.edge.from,i)),a==="completed"){e.emit(t.service.createExecutionCompletedEvent(o.proposal,i));return}e.emit(t.service.createExecutionFailedEvent(o.proposal,F(n),i))}}}function N(t,e){return e.kind==="next"?e.edge.from:e.world.parentWorldId??t.proposal.baseWorld}function F(t){return D(t.terminalSnapshot)}function q(t){return t.kind==="next"&&"forkCreated"in t&&t.forkCreated===!0}function d(t){return Object.freeze(t)}var P=class{constructor(e,r={}){this.store=e;this.options=r}createProposal(e){if(e.computeEnvelope==null)throw new Error("GOV-REPLAY-1 violation: proposal requires a compute envelope");return d({proposalId:e.proposalId??E(),baseWorld:e.baseWorld,branchId:e.branchId,actorId:e.actorId,authorityId:e.authorityId,intent:d({...e.intent}),computeEnvelope:structuredClone(e.computeEnvelope),status:"submitted",executionKey:e.executionKey,submittedAt:e.submittedAt,epoch:e.epoch})}beginEvaluating(e){return this.transitionProposal(e,"evaluating")}beginExecution(e){if(!e.decisionId)throw new Error("GOV-EXEC-1 violation: approved proposal requires decisionId before execution can begin");return this.transitionProposal(e,"executing")}failExecution(e,r,o){return this.transitionProposal(e,"failed",{completedAt:r,...o!==void 0?{resultWorld:o}:{}})}async prepareAuthorityResult(e,r,o){if(e.status!=="submitted"&&e.status!=="evaluating")throw new Error(`GOV-TRANS-1 violation: authority result requires ingress proposal, received ${e.status}`);let n=await this.resolveBranchInfo(e.branchId),i=o.currentEpoch??n?.epoch??e.epoch,a=o.currentBranchHead??n?.head??e.baseWorld;if(this.shouldDiscardAuthorityResult(e,i)&&a!==e.baseWorld)return{proposal:this.prepareSupersede(e,"head_advance"),discarded:!0};if(r.kind==="approved"){if(await this.assertBranchGateAvailable(e),a!==e.baseWorld)return{proposal:this.prepareSupersede(e,"head_advance"),discarded:!0};let p=d({decisionId:o.decisionId??y(),proposalId:e.proposalId,authorityId:e.authorityId,decision:d({kind:"approved"}),decidedAt:o.decidedAt});return{proposal:this.transitionProposal(e,"approved",{decisionId:p.decisionId,decidedAt:p.decidedAt,approvedScope:r.approvedScope}),decisionRecord:p,discarded:!1}}let s=d({decisionId:o.decisionId??y(),proposalId:e.proposalId,authorityId:e.authorityId,decision:d({kind:"rejected",...r.reason?{reason:r.reason}:{}}),decidedAt:o.decidedAt});return{proposal:this.transitionProposal(e,"rejected",{decisionId:s.decisionId,decidedAt:s.decidedAt}),decisionRecord:s,discarded:!1}}prepareSupersede(e,r){return this.transitionProposal(e,"superseded",{supersededReason:r})}async invalidateStaleIngress(e,r){let o=await this.resolveBranchInfo(e),n=r??o?.epoch;if(n==null)throw new Error(`Cannot invalidate stale ingress without branch epoch for ${e}`);return(await this.store.getProposalsByBranch(e)).filter(i=>x(i.status)&&i.epoch<n).map(i=>this.prepareSupersede(i,"head_advance"))}shouldDiscardAuthorityResult(e,r){return e.epoch<r}deriveOutcome(e){return u(e)!=null||e.system.pendingRequirements.length>0?"failed":"completed"}async finalize(e,r,o){if(e.status!=="executing")throw new Error(`GOV-SEAL-6 violation: finalize() requires executing proposal, received ${e.status}`);if(!e.decisionId)throw new Error("GOV-SEAL-6 violation: executing proposal is missing decisionId");let n=await this.store.getDecisionRecord(e.decisionId);if(!n)throw new Error(`GOV-SEAL-6 violation: decision record ${e.decisionId} not found`);let i=this.deriveOutcome(r.terminalSnapshot);if(i!==r.terminalStatus)throw new Error(`GOV-SEAL-1 violation: deriveOutcome=${i} but lineageCommit.terminalStatus=${r.terminalStatus}`);let a=this.transitionProposal(e,i,{resultWorld:r.worldId,completedAt:o});return d({proposal:a,decisionRecord:n})}createProposalSubmittedEvent(e,r=Date.now()){return d({type:"proposal:submitted",timestamp:r,proposalId:e.proposalId,actorId:e.actorId,baseWorld:e.baseWorld,branchId:e.branchId,intent:d({type:e.intent.type,intentId:e.intent.intentId,...e.intent.input!==void 0?{input:e.intent.input}:{}}),executionKey:e.executionKey,epoch:e.epoch})}createProposalEvaluatingEvent(e,r=Date.now()){return d({type:"proposal:evaluating",timestamp:r,proposalId:e.proposalId})}createProposalDecidedEvent(e,r,o=Date.now()){return d({type:"proposal:decided",timestamp:o,proposalId:e.proposalId,decisionId:r.decisionId,decision:r.decision.kind,...r.decision.kind==="rejected"&&r.decision.reason?{reason:r.decision.reason}:{}})}createProposalSupersededEvent(e,r,o=Date.now()){if(e.status!=="superseded"||!e.supersededReason)throw new Error("GOV-EPOCH-5 violation: superseded event requires proposal.status='superseded' with supersededReason");return d({type:"proposal:superseded",timestamp:o,proposalId:e.proposalId,currentEpoch:r,proposalEpoch:e.epoch,reason:e.supersededReason})}createExecutionCompletedEvent(e,r=Date.now()){if(!e.resultWorld)throw new Error("GOV-EVT-6 violation: execution:completed requires proposal.resultWorld");return d({type:"execution:completed",timestamp:r,proposalId:e.proposalId,executionKey:e.executionKey,resultWorld:e.resultWorld})}createExecutionFailedEvent(e,r,o=Date.now()){if(!e.resultWorld)throw new Error("GOV-EVT-7 violation: execution:failed requires proposal.resultWorld");return d({type:"execution:failed",timestamp:o,proposalId:e.proposalId,executionKey:e.executionKey,resultWorld:e.resultWorld,error:d({summary:r.summary,...r.currentError!==void 0?{currentError:r.currentError}:{},...r.pendingRequirements!==void 0?{pendingRequirements:r.pendingRequirements}:{}})})}createWorldCreatedEvent(e,r,o,n,i=Date.now()){return d({type:"world:created",timestamp:i,world:e,from:o,proposalId:r,outcome:n})}createWorldForkedEvent(e,r,o=Date.now()){return d({type:"world:forked",timestamp:o,branchId:e,forkPoint:r})}async resolveBranchInfo(e){return this.options.lineageService?.getBranch(e)??null}async assertBranchGateAvailable(e){let r=await this.store.getExecutionStageProposal(e.branchId);if(r&&r.proposalId!==e.proposalId)throw new Error(`GOV-BRANCH-GATE-1 violation: branch ${e.branchId} already occupied by ${r.proposalId}`)}transitionProposal(e,r,o={}){if(!S(e.status,r))throw new Error(`GOV-TRANS-1 violation: invalid transition ${e.status} -> ${r}; valid targets are ${w(e.status).join(", ")}`);if(r==="superseded"){if(o.decisionId!=null)throw new Error("GOV-TRANS-3 violation: superseded transition must not create DecisionRecord");if(!o.supersededReason)throw new Error("GOV-STAGE-7 violation: superseded proposal must record supersededReason")}if(R(e.status,r)&&o.decisionId==null)throw new Error(`GOV-TRANS-2 violation: transition ${e.status} -> ${r} requires decisionId`);if(r!=="superseded"&&o.supersededReason!=null)throw new Error("GOV-TRANS-4 violation: supersededReason is only valid on superseded proposals");if(c(e.status)&&r==="superseded")throw new Error("GOV-STAGE-4 violation: execution-stage proposals must not be superseded");return d({...e,status:r,...o.decisionId!==void 0?{decisionId:o.decisionId}:{},...o.decidedAt!==void 0?{decidedAt:o.decidedAt}:{},...o.completedAt!==void 0?{completedAt:o.completedAt}:{},...o.resultWorld!==void 0?{resultWorld:o.resultWorld}:{},...o.approvedScope!==void 0?{approvedScope:o.approvedScope}:{},...o.supersededReason!==void 0?{supersededReason:o.supersededReason}:{},...r!=="superseded"?{supersededReason:void 0}:{}})}};function Te(t,e){return new P(t,e)}import{sha256 as M,toJcs as C}from"@manifesto-ai/core";async function z(t,e){let r=[t,e.type,C(e.input??null),C(e.scopeProposal??null)].join(":");return M(r)}async function Be(t){let e=t.intentId??`intent-${crypto.randomUUID()}`,r=await z(t.schemaHash,t.body);return U(t.body,e,r,{projectionId:t.projectionId,source:t.source,actor:t.actor,note:t.note})}function U(t,e,r,o){return G({body:t,intentId:e,intentKey:r,meta:{origin:o}})}function G(t){if(t===null||typeof t!="object")return t;for(let e of Object.getOwnPropertyNames(t)){let r=t[e];r!==null&&typeof r=="object"&&G(r)}return Object.freeze(t)}export{E as a,y as b,W as c,Q as d,b as e,X as f,j as g,O as h,$ as i,J as j,x as k,c as l,Z as m,S as n,w as o,R as p,m as q,oe as r,h as s,T as t,v as u,k as v,I as w,H as x,f as y,B as z,g as A,ve as B,u as C,Ae as D,P as E,Te as F,z as G,Be as H,U as I};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Context } from "@manifesto-ai/core";
|
|
2
|
+
import { type ActionName, type GovernanceSettlementResult, type ManifestoDomainShape, type PreviewDiagnosticsMode, type ProposalRef, type SubmitReportMode, type TypedIntent } from "@manifesto-ai/sdk";
|
|
3
|
+
import { type GovernanceRuntimeKernel } from "@manifesto-ai/sdk/provider";
|
|
4
|
+
import type { LineageRuntimeController } from "@manifesto-ai/lineage/provider";
|
|
5
|
+
import type { GovernanceInstance } from "./runtime-types.js";
|
|
6
|
+
import type { ActorAuthorityBinding, ActorId, BranchId, DecisionId, DecisionRecord, IntentScope, Proposal, ProposalId } from "./types.js";
|
|
7
|
+
type RuntimeExecutionView<T extends ManifestoDomainShape> = {
|
|
8
|
+
readonly context?: ReturnType<GovernanceRuntimeKernel<T>["getExternalContext"]>;
|
|
9
|
+
readonly diagnostics?: PreviewDiagnosticsMode;
|
|
10
|
+
readonly report?: SubmitReportMode;
|
|
11
|
+
};
|
|
12
|
+
export type GovernanceRuntimeServices<T extends ManifestoDomainShape> = {
|
|
13
|
+
readonly lineage: LineageRuntimeController<T>;
|
|
14
|
+
readonly ensureReady: () => Promise<void>;
|
|
15
|
+
readonly createSubmission: (intent: TypedIntent<T>, context: Context) => Promise<Proposal>;
|
|
16
|
+
readonly settleSubmission: (proposalId: ProposalId) => Promise<void>;
|
|
17
|
+
readonly resumePendingSettlements: () => Promise<void>;
|
|
18
|
+
readonly waitForSettlement: <Name extends ActionName<T>>(proposalId: ProposalRef, actionName?: Name, reportMode?: SubmitReportMode) => Promise<GovernanceSettlementResult<T, Name>>;
|
|
19
|
+
readonly approve: (proposalId: ProposalId, approvedScope?: IntentScope | null) => Promise<Proposal>;
|
|
20
|
+
readonly reject: (proposalId: ProposalId, reason?: string) => Promise<Proposal>;
|
|
21
|
+
readonly getProposal: (proposalId: ProposalId) => Promise<Proposal | null>;
|
|
22
|
+
readonly getProposals: (branchId?: BranchId) => Promise<readonly Proposal[]>;
|
|
23
|
+
readonly bindActor: (binding: ActorAuthorityBinding) => Promise<void>;
|
|
24
|
+
readonly getActorBinding: (actorId: ActorId) => Promise<ActorAuthorityBinding | null>;
|
|
25
|
+
readonly getDecisionRecord: (decisionId: DecisionId) => Promise<DecisionRecord | null>;
|
|
26
|
+
};
|
|
27
|
+
export declare function createGovernanceRuntimeInstance<T extends ManifestoDomainShape>(kernel: GovernanceRuntimeKernel<T>, services: GovernanceRuntimeServices<T>, view?: RuntimeExecutionView<T>, isView?: boolean): GovernanceInstance<T>;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { IntentScope } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Collect dot paths of leaf-level differences between two domain states.
|
|
4
|
+
*/
|
|
5
|
+
export declare function collectChangedStatePaths(before: unknown, after: unknown): readonly string[];
|
|
6
|
+
export declare function isPathAllowed(path: string, allowedPaths: readonly string[]): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Returns the changed paths that fall outside the approved scope. An empty
|
|
9
|
+
* result means the settlement stayed within what the authority approved.
|
|
10
|
+
*/
|
|
11
|
+
export declare function findScopeViolations(changedPaths: readonly string[], scope: IntentScope | null | undefined): readonly string[];
|
|
12
|
+
/**
|
|
13
|
+
* Narrow the persisted (unknown-typed) approvedScope back to IntentScope.
|
|
14
|
+
*/
|
|
15
|
+
export declare function toIntentScope(value: unknown): IntentScope | null;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
export type { ActorAuthorityBinding, ActorId, ActorKind, ActorRef, AuthorityId, AuthorityKind, AuthorityPolicy, AuthorityRef, DecisionId, DecisionRecord, ErrorInfo, FinalDecision, GovernanceEvent, GovernanceEventSink, GovernanceEventType, IntentScope, PolicyCondition, PolicyRule, Proposal, ProposalId, ProposalStatus, QuorumRule, SourceKind, SourceRef, SupersedeReason, Vote, WaitingFor, } from "./types.js";
|
|
2
|
-
export type { GovernanceComposableManifesto, GovernanceConfig, GovernanceExecutionConfig, GovernanceInstance, GovernanceProposalRuntime, } from "./runtime-types.js";
|
|
3
|
-
export type { ProposalSettlement, ProposalSettlementReport, WaitForProposalOptions, } from "./wait-for-proposal.js";
|
|
2
|
+
export type { GovernanceComposableManifesto, GovernanceConfig, GovernanceControlSurface, GovernanceExecutionConfig, GovernanceInstance, GovernanceProposalRuntime, } from "./runtime-types.js";
|
|
4
3
|
export { createNoopGovernanceEventSink, } from "./types.js";
|
|
5
4
|
export { createInMemoryGovernanceStore } from "./store/in-memory-governance-store.js";
|
|
6
5
|
export { withGovernance } from "./with-governance.js";
|
|
7
|
-
export { waitForProposal, waitForProposalWithReport, } from "./wait-for-proposal.js";
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as C,C as _,D as M,F,I as L,a as O,d as x,e as ie,r as G}from"./chunk-2Q3OH2FH.js";import{DisposedError as P,ManifestoError as R}from"@manifesto-ai/sdk";import{getExtensionKernel as me}from"@manifesto-ai/sdk/extensions";import{activateComposable as fe,assertComposableNotActivated as ye,attachExtensionKernel as he,attachRuntimeKernelFactory as Pe,getActivationState as Ie,getRuntimeKernelFactory as we}from"@manifesto-ai/sdk/provider";import{createLineageRuntimeController as ve,getLineageDecoration as ge}from"@manifesto-ai/lineage/provider";import{DisposedError as le,ManifestoError as v}from"@manifesto-ai/sdk";var U=Symbol("manifesto-governance.wait-for-proposal");function K(e,a){return Object.defineProperty(e,U,{enumerable:!1,configurable:!1,writable:!1,value:a}),e}async function V(e,a,s){let o=typeof a=="string"?a:a.proposalId,i=j(s?.timeoutMs,0),f=j(s?.pollIntervalMs,50),I=Date.now();for(;;){E(e);let p=await e.getProposal(o);if(!p)throw new v("GOVERNANCE_PROPOSAL_NOT_FOUND",`Proposal "${o}" was not found`);if(p.status==="completed"){let c=p,u=ce(c,"completed");return E(e),{kind:"completed",proposal:c,snapshot:e.getSnapshot(),resultWorld:u}}if(p.status==="failed"){let c=p,u=await pe(e,c);return{kind:"failed",proposal:c,...u.resultWorld!==void 0?{resultWorld:u.resultWorld}:{},error:u.error}}if(p.status==="rejected")return{kind:"rejected",proposal:p};if(p.status==="superseded")return{kind:"superseded",proposal:p};if(i===0)return{kind:"pending",proposal:p};let l=i-(Date.now()-I);if(l<=0)return{kind:"timed_out",proposal:p};await ue(Math.min(f,l))}}async function de(e,a,s){let o=await V(e,a,s);if(o.kind==="completed"){let i=await B(e,o.proposal.baseWorld,o.resultWorld);return{kind:"completed",proposal:o.proposal,baseWorld:o.proposal.baseWorld,resultWorld:o.resultWorld,outcome:i}}if(o.kind==="failed"){if(o.resultWorld){let i=await B(e,o.proposal.baseWorld,o.resultWorld);return{kind:"failed",proposal:o.proposal,baseWorld:o.proposal.baseWorld,published:!1,error:o.error,resultWorld:o.resultWorld,sealedOutcome:i}}return{kind:"failed",proposal:o.proposal,baseWorld:o.proposal.baseWorld,published:!1,error:o.error}}return o}async function pe(e,a){if(!a.resultWorld)return{error:{summary:"Execution failed before a result world was recorded"}};let s=a.resultWorld;E(e);let o=await e.getWorldSnapshot(s);if(!o)throw new v("GOVERNANCE_RESULT_WORLD_NOT_FOUND",`Failed proposal "${a.proposalId}" references missing world "${s}"`);return{resultWorld:s,error:_(o)}}async function B(e,a,s){let o=$(e);E(e);let i=await e.getWorldSnapshot(a);if(!i)throw new v("GOVERNANCE_BASE_WORLD_NOT_FOUND",`Proposal references missing base world "${a}"`);E(e);let f=await e.getWorldSnapshot(s);if(!f)throw new v("GOVERNANCE_RESULT_WORLD_NOT_FOUND",`Proposal references missing result world "${s}"`);return o.deriveExecutionOutcome(i,f)}function ce(e,a){if(!e.resultWorld)throw new v("GOVERNANCE_RESULT_WORLD_MISSING",`Proposal "${e.proposalId}" reached ${a} without a result world`);return e.resultWorld}function E(e){if($(e).isDisposed())throw new le}function $(e){let s=e[U];if(!s)throw new v("GOVERNANCE_RUNTIME_UNSUPPORTED","waitForProposal helpers require a runtime created by withGovernance().activate()");return s}function j(e,a){return e===void 0||!Number.isFinite(e)?a:Math.max(0,e)}function ue(e){return new Promise(a=>{globalThis.setTimeout(a,e)})}var Te=Object.freeze({__governanceLaws:!0});function Ee(e,a){ye(e);let s=we(e),o=s,i=ge(e);if(!i)throw new R("GOVERNANCE_LINEAGE_REQUIRED","withGovernance() requires a manifesto already composed with withLineage()");let f=Ie(e),I={_laws:Object.freeze({...e._laws,...Te}),schema:e.schema,activate(){return fe(I),Re(o(),i.config,a)}};return Pe(I,s,f),I}function Re(e,a,s){let o=s.governanceStore??G(),i=L(o,{lineageService:a.service}),f=s.evaluator??C(),I=M({service:i,sink:s.eventSink,now:s.now}),p=s.now??Date.now,l=ve(e,a.service,a),c,u=null;async function g(){return u||(u=Promise.all(s.bindings.map(async t=>{await o.putActorBinding(t)})).then(()=>{}).catch(t=>{throw u=null,t}),u)}async function A(){await l.ensureReady(),await g()}function T(){return p()}async function k(t,n){let r=await i.invalidateStaleIngress(t,n);await Promise.all(r.map(async m=>{await o.putProposal(m)}))}async function H(t){let n=await o.getActorBinding(t);if(n)return n;throw new R("GOVERNANCE_BINDING_NOT_FOUND",`No actor-authority binding exists for actor "${t}"`)}async function z(t,n,r){switch(n.policy.mode){case"hitl":return{kind:"pending",waitingFor:{kind:"human",delegate:n.policy.delegate}};case"tribunal":return{kind:"pending",waitingFor:{kind:"tribunal",members:n.policy.members}};default:return r.evaluate(t,n)}}async function Q(t,n){let r=null,m=null,w=!1;try{r=await l.sealIntent(n,{proposalRef:t.proposalId,decisionRef:t.decisionId,executionKey:t.executionKey,publishOnCompleted:!1,assumeEnqueued:!0});let d=await i.finalize(t,r.preparedCommit,T());if(m=d.proposal,await o.putProposal(d.proposal),w=!0,await o.putDecisionRecord(d.decisionRecord),I.emitSealCompleted(d,r.preparedCommit),r.preparedCommit.branchChange.headAdvanced){let h=e.setVisibleSnapshot(r.hostResult.snapshot);return e.emitEvent("dispatch:completed",{intentId:n.intentId??"",intent:n,snapshot:h}),d.proposal}let y=q(r.hostResult.error);return e.emitEvent("dispatch:failed",{intentId:n.intentId??"",intent:n,error:y}),d.proposal}catch(d){let y=q(d);if(!w)try{if(m)try{await o.putProposal(m)}catch{let h=i.failExecution(t,T(),r?.preparedCommit.worldId);await o.putProposal(h)}else{let h=i.failExecution(t,T(),r?.preparedCommit.worldId);await o.putProposal(h)}}catch{}throw be(y)||e.emitEvent("dispatch:failed",{intentId:n.intentId??"",intent:n,error:y}),y}}async function b(t,n){let r=await i.prepareAuthorityResult(t,n,{decidedAt:T()});if(await o.putProposal(r.proposal),r.decisionRecord&&await o.putDecisionRecord(r.decisionRecord),r.discarded||r.proposal.status==="rejected")return r.proposal;let m=i.beginExecution(r.proposal);return await o.putProposal(m),Q(m,Ae(r.proposal))}async function X(t){if(e.isDisposed())throw new P;return e.enqueue(async()=>{if(e.isDisposed())throw new P;await A();let n=e.ensureIntentId(t);if(!e.isActionAvailable(n.type))return e.rejectUnavailable(n);let r=await l.getActiveBranch();await k(r.id,r.epoch);let m=s.execution.deriveActor(n),w=await H(m.actorId),d=await F({body:{type:n.type,...n.input!==void 0?{input:n.input}:{},...Se(n)?{scopeProposal:n.scopeProposal}:{}},schemaHash:e.schema.hash,projectionId:s.execution.projectionId,source:s.execution.deriveSource(n),actor:m,intentId:n.intentId}),y=O(),h=i.createProposal({proposalId:y,baseWorld:r.head,branchId:r.id,actorId:w.actorId,authorityId:w.authorityId,intent:{type:d.body.type,intentId:d.intentId,...d.body.input!==void 0?{input:d.body.input}:{},...d.body.scopeProposal!==void 0?{scopeProposal:d.body.scopeProposal}:{}},executionKey:x({proposalId:y,actorId:w.actorId,baseWorld:r.head,branchId:r.id,attempt:1}),submittedAt:T(),epoch:r.epoch});await o.putProposal(h);let S=i.beginEvaluating(h);await o.putProposal(S);let N=await z(S,w,f);return N.kind==="pending"?S:b(S,N)})}async function D(t){let n=await o.getProposal(t);if(!n)throw new R("GOVERNANCE_PROPOSAL_NOT_FOUND",`Proposal "${t}" was not found`);if(n.status!=="evaluating")throw new R("GOVERNANCE_PENDING_REQUIRED",`Proposal "${t}" is not pending human resolution`);return n}async function J(t,n){if(e.isDisposed())throw new P;return e.enqueue(async()=>{if(e.isDisposed())throw new P;await A();let r=await D(t);return b(r,{kind:"approved",approvedScope:n!==void 0?n:r.intent.scopeProposal??null})})}async function Y(t,n){if(e.isDisposed())throw new P;return e.enqueue(async()=>{if(e.isDisposed())throw new P;await A();let r=await D(t);return b(r,{kind:"rejected",...n?{reason:n}:{}})})}async function Z(t){return await g(),o.getProposal(t)}async function ee(t){await A();let n=t??(await l.getActiveBranch()).id;return o.getProposalsByBranch(n)}async function oe(t){if(e.isDisposed())throw new P;return e.enqueue(async()=>{if(e.isDisposed())throw new P;await g(),await o.putActorBinding(t)})}async function te(t){return await g(),o.getActorBinding(t)}async function ne(t){return await g(),o.getDecisionRecord(t)}function W(t){return me(c).explainIntentFor(e.getCanonicalSnapshot(),t)}function re(t){return W(t)}function ae(t){let n=W(t);return n.kind==="blocked"?n.blockers:null}let se={createIntent:e.createIntent,subscribe:e.subscribe,on:e.on,getSnapshot:e.getSnapshot,getCanonicalSnapshot:e.getCanonicalSnapshot,getSchemaGraph:e.getSchemaGraph,getAvailableActions:e.getAvailableActions,isIntentDispatchable:e.isIntentDispatchable,getIntentBlockers:e.getIntentBlockers,getActionMetadata:e.getActionMetadata,isActionAvailable:e.isActionAvailable,simulate:e.simulate,simulateIntent:e.simulateIntent,explainIntent:W,why:re,whyNot:ae,MEL:e.MEL,schema:e.schema,dispose:e.dispose,restore:l.restore,getWorld:l.getWorld,getWorldSnapshot:l.getWorldSnapshot,getLineage:l.getLineage,getLatestHead:l.getLatestHead,getHeads:l.getHeads,getBranches:l.getBranches,getActiveBranch:l.getActiveBranch,switchActiveBranch:l.switchActiveBranch,createBranch:l.createBranch,proposeAsync:X,approve:J,reject:Y,getProposal:Z,getProposals:ee,bindActor:oe,getActorBinding:te,getDecisionRecord:ne};return c=K(he(se,e),{isDisposed:e.isDisposed,deriveExecutionOutcome:e.deriveExecutionOutcome}),c}function Ae(e){return{type:e.intent.type,intentId:e.intent.intentId,...e.intent.input!==void 0?{input:e.intent.input}:{}}}function Se(e){return"scopeProposal"in e&&e.scopeProposal!==void 0}function q(e){return e instanceof Error?e:new R("GOVERNANCE_EXECUTION_FAILED","Governed proposal execution did not produce a completed result")}function be(e){return"code"in e&&typeof e.code=="string"&&(e.code==="ACTION_UNAVAILABLE"||e.code==="INTENT_NOT_DISPATCHABLE"||e.code==="INVALID_INPUT")}export{G as createInMemoryGovernanceStore,ie as createNoopGovernanceEventSink,V as waitForProposal,de as waitForProposalWithReport,Ee as withGovernance};
|
|
1
|
+
import{B as me,C as q,D as fe,F as ye,H as he,a as ue,d as pe,e as Ge,r as ee}from"./chunk-HI32V6PR.js";import{DisposedError as De,ManifestoError as qe}from"@manifesto-ai/sdk";import{activateComposable as Qe,assertComposableNotActivated as Xe,attachRuntimeKernelFactory as Je,getActivationState as Ye,getRuntimeKernelFactory as Ze}from"@manifesto-ai/sdk/provider";import{createLineageRuntimeController as et,getLineageDecoration as tt}from"@manifesto-ai/lineage/provider";import{DisposedError as oe,ManifestoError as re,SubmissionFailedError as We}from"@manifesto-ai/sdk";import{attachExtensionKernel as Me,mapBlockedAdmission as Pe}from"@manifesto-ai/sdk/provider";import{ManifestoError as ge}from"@manifesto-ai/sdk";function te(e){let n;try{n=structuredClone(e)}catch(r){throw new ge("INVALID_INPUT",`Action input must be structured-cloneable: ${r instanceof Error?r.message:String(r)}`)}return Se(n)}function ne(e){try{return{ok:!0,value:te(e)}}catch(n){if(n instanceof ge)return{ok:!1,error:n};throw n}}function Se(e,n=new WeakSet){if(e==null||typeof e!="object")return e;let r=e;if(n.has(r)||Object.isFrozen(e))return e;n.add(r);for(let s of Reflect.ownKeys(r))Se(r[s],n);return Object.freeze(e)}function ae(e,n,r={},s=!1){let d=X(r),b=new Map;for(let t of e.getActionMetadata())b.set(t.name,_e(t));let f=Object.create(null),j=new Map;for(let t of b.keys()){let o=g(t);j.set(t,o),Object.defineProperty(f,t,{enumerable:!0,configurable:!1,writable:!1,value:o})}function A(t,o){if(e.isDisposed())return()=>{};let i;try{i=t(e.getSnapshot())}catch{i=void 0}return e.subscribe(t,c=>{let I=i;i=c,o(c,I)})}let v=Object.freeze({state:A,event(t,o){return e.isDisposed()?()=>{}:e.on(t,o)}}),u=(t=>j.get(t)),E={action:Object.freeze(f),state:w(),computed:W(),observe:v,inspect:Object.freeze({graph:e.getSchemaGraph,canonicalSnapshot:e.getCanonicalSnapshot,action(t){return F(t)},availableActions(){return Object.freeze(e.getAvailableActions().map(t=>F(t)))},schemaHash(){return e.getCanonicalSnapshot().meta.schemaHash}}),snapshot:e.getSnapshot,getAction:u,context:D,injectContext(t){if(s){d=X({...d,context:e.captureExternalContext(t)});return}e.replaceExternalContext(t)},updateContext(t){if(!s)return e.updateExternalContext(t);let o=t(D());return d=X({...d,context:e.captureExternalContext(o)}),d.context??e.getExternalContext()},with(t){return Object.freeze(ae(e,n,h(t),!0))},dispose:e.dispose,waitForSettlement(t){return n.waitForSettlement(t,void 0,d.report)},restore:n.lineage.restore,getWorld:n.lineage.getWorld,getWorldSnapshot:n.lineage.getWorldSnapshot,getLineage:n.lineage.getLineage,getLatestHead:n.lineage.getLatestHead,getHeads:n.lineage.getHeads,getBranches:n.lineage.getBranches,getActiveBranch:n.lineage.getActiveBranch,switchActiveBranch:n.lineage.switchActiveBranch,createBranch:n.lineage.createBranch,approve:m,reject:O,getProposal:n.getProposal,getProposals:n.getProposals,bindActor:n.bindActor,getActorBinding:n.getActorBinding,getDecisionRecord:n.getDecisionRecord};return Me(E,e);function P(t,o,i){return Object.freeze({name:t,ref:o,value:()=>i(e.getSnapshot()),observe:c=>A(i,c)})}function w(){let t=Object.create(null);for(let o of Object.keys(e.MEL.state)){let i=e.MEL.state[o];Object.defineProperty(t,o,{enumerable:!0,configurable:!1,writable:!1,value:P(o,i,c=>c.state[o])})}return Object.freeze(t)}function W(){let t=Object.create(null);for(let o of Object.keys(e.MEL.computed)){let i=e.MEL.computed[o];Object.defineProperty(t,o,{enumerable:!0,configurable:!1,writable:!1,value:P(o,i,c=>c.computed[o])})}return Object.freeze(t)}function g(t){return Object.freeze({info:()=>F(t),available:()=>e.isActionAvailable(t),check:(...o)=>{let i=l(t,o);return y(i)},preview:(...o)=>{let i=l(t,o);return S(i)},submit:(...o)=>{let i=l(t,o);return R(i)},bind:(...o)=>a(t,o)})}function a(t,o){let i=l(t,o),c=ne([...o]),I=()=>c.ok?l(t,c.value):i;return Object.freeze({action:t,input:i.input,check:()=>y(I()),preview:()=>S(I()),submit:()=>R(I()),intent:()=>{let N=I();return N.inputError?null:N.intent}})}function l(t,o){let i=e.MEL.actions[t],c=T(t,o),I=ne(c);if(!I.ok)return Object.freeze({actionName:t,input:void 0,intent:null,inputError:I.error});try{let N=te(e.createIntent(i,...o)),x=e.validateIntentInputFor(e.getCanonicalSnapshot(),N);return Object.freeze({actionName:t,input:I.value,intent:N,inputError:x})}catch(N){if(!(N instanceof re))throw N;return Object.freeze({actionName:t,input:I.value,intent:null,inputError:N})}}function T(t,o){return o.length===0?void 0:e.getActionMetadata(t).publicArity>1?Object.freeze([...o]):o.length===1?o[0]:Object.freeze([...o])}function y(t){return p(t,e.getCanonicalSnapshot()).admission}function S(t){let o=e.getCanonicalSnapshot(),i=p(t,o);if(!i.admission.ok||i.intent===null)return Object.freeze({admitted:!1,admission:i.admission});let c=i.intent,I=e.createComputeContext(c,M()),N=e.simulateSync(o,c,{context:I}),x=e.deriveExecutionOutcome(o,N.snapshot);return Object.freeze({admitted:!0,status:N.status,before:x.projected.beforeSnapshot,after:x.projected.afterSnapshot,changes:x.projected.changedPaths,requirements:N.requirements,newAvailableActions:e.getAvailableActionsFor(N.snapshot).map(G=>F(G)),...Fe(N.diagnostics,d.diagnostics),error:N.snapshot.system.lastError})}async function R(t){if(e.isDisposed())throw new oe;let o=t.intent?e.createComputeContext(t.intent,M()):null;return e.enqueue(async()=>{if(e.isDisposed())throw new oe;if(await n.ensureReady(),e.isDisposed())throw new oe;let i=e.getCanonicalSnapshot(),c=p(t,i);if(!c.admission.ok||c.intent===null){let G=c.admission;return $(t.actionName,t.intent,G,i),Object.freeze({ok:!1,mode:"governance",action:t.actionName,admission:G})}let I=c.intent;V(t.actionName,I,c.admission,i),C(t.actionName,I,i);let N;try{N=await n.createSubmission(I,o??e.createComputeContext(I,M()))}catch(G){let B=Ie(G),L=e.getCanonicalSnapshot(),_=Te(B,I,L);throw K(t.actionName,I,_,L,"runtime"),new We(B.message,"runtime",{cause:B})}let x=N.proposalId;return je(t.actionName,x,i),U(t.actionName,I,x,i),e.enqueue(async()=>{await n.settleSubmission(x);let G=await n.getProposal(x);if(!G||G.status==="evaluating"||G.status==="approved"||G.status==="executing")return;let B=e.getCanonicalSnapshot(),L=G?.decisionId?await n.getDecisionRecord(G.decisionId):null;L&&Z(t.actionName,x,L,B);let _=await n.waitForSettlement(x,t.actionName,"summary");_.status==="settled"?le(t.actionName,I,_.outcome,B,x,_.world.worldId):_.status==="settlement_failed"?K(t.actionName,I,_.error,B,"settlement",x):!L&&_.decision&&Z(t.actionName,x,_.decision,B)}).catch(G=>{let B=Ie(G),L=e.getCanonicalSnapshot(),_=Te(B,I,L);K(t.actionName,I,_,L,"settlement",x)}),Object.freeze({ok:!0,mode:"governance",status:"pending",action:t.actionName,proposal:x,waitForSettlement:()=>n.waitForSettlement(x,t.actionName,d.report)})})}function D(){return d.context??e.getExternalContext()}function M(){return d.context??e.captureExternalContext()}function h(t){return X({...d,...t.context!==void 0?{context:e.captureExternalContext(t.context)}:{},...t.diagnostics!==void 0?{diagnostics:t.diagnostics}:{},...t.report!==void 0?{report:t.report}:{}})}function p(t,o){if(!e.isActionAvailableFor(o,t.actionName))return{admission:Object.freeze({ok:!1,action:t.actionName,layer:"availability",code:"ACTION_UNAVAILABLE",message:`Action "${t.actionName}" is unavailable against the current visible snapshot`,blockers:k(t,o)}),intent:null};if(t.inputError||!t.intent)return{admission:Object.freeze({ok:!1,action:t.actionName,layer:"input",code:"INVALID_INPUT",message:t.inputError?.message??"Invalid action input",blockers:Object.freeze([])}),intent:null};let i=e.evaluateIntentLegalityFor(o,t.intent);if(i.kind==="admitted")return{admission:Object.freeze({ok:!0,action:t.actionName}),intent:i.intent};let c=e.deriveIntentAdmission(o,i);return{admission:Pe(t.actionName,c),intent:null}}async function m(t,o){let i=await n.approve(t,o);return await z(i),i}async function O(t,o){let i=await n.reject(t,o);return await z(i),i}async function z(t){let o=t.intent.type,i=e.getCanonicalSnapshot();if(t.decisionId){let c=await n.getDecisionRecord(t.decisionId);c&&Z(o,t.proposalId,c,i)}if(t.status==="completed"){let c=await n.waitForSettlement(t.proposalId,o);c.status==="settled"&&le(o,t.intent,c.outcome,i,t.proposalId,c.world.worldId);return}if(t.status==="failed"){let c=await n.waitForSettlement(t.proposalId,o);c.status==="settlement_failed"&&K(o,t.intent,c.error,i,"settlement",t.proposalId)}}function k(t,o){if(!t.intent)return Object.freeze([]);let i=e.evaluateIntentLegalityFor(o,t.intent),c=e.deriveIntentAdmission(o,i);return c.kind!=="blocked"||c.failure.kind!=="unavailable"?Object.freeze([]):Pe(t.actionName,c).blockers}function F(t){let o=b.get(t);if(!o)throw new re("UNKNOWN_ACTION",`Action "${String(t)}" is not declared by this Manifesto schema`);return o}function V(t,o,i,c){e.emitEvent("submission:admitted",{...H(t,o,c),admission:i})}function $(t,o,i,c){e.emitEvent("submission:rejected",{...H(t,o,c),admission:i})}function C(t,o,i){e.emitEvent("submission:submitted",H(t,o,i))}function U(t,o,i,c){e.emitEvent("submission:pending",{...H(t,o,c),proposal:i})}function K(t,o,i,c,I,N){e.emitEvent("submission:failed",{...H(t,o,c),stage:I,error:i,...N!==void 0?{proposal:N}:{}})}function le(t,o,i,c,I,N){e.emitEvent("submission:settled",{...H(t,o,c),outcome:i,proposal:I,worldId:N})}function je(t,o,i){e.emitEvent("proposal:created",{proposal:o,action:t,schemaHash:i.meta.schemaHash})}function Z(t,o,i,c){e.emitEvent("proposal:decided",{proposal:o,action:t,schemaHash:c.meta.schemaHash,decision:Object.freeze({...i})})}function H(t,o,i){return{action:t,mode:"governance",...o?.intentId?{intentId:o.intentId}:{},schemaHash:i.meta.schemaHash,snapshotVersion:i.meta.version}}}function Fe(e,n){return!e||n==="none"?{}:n==="summary"?{diagnostics:{}}:{diagnostics:{trace:e.trace}}}function X(e){return Object.freeze({...e})}function _e(e){let n=e.input?.type==="object"?e.input.fields??{}:{},r=e.params.length>0?e.params:Object.keys(n),s=e.annotations,d=typeof s?.title=="string"?s.title:void 0;return Object.freeze({name:e.name,...d!==void 0?{title:d}:{},...e.description!==void 0?{description:e.description}:{},parameters:Object.freeze(r.map(b=>{let f=n[b];return Object.freeze({name:b,required:f?.required??!0,...f?.type!==void 0?{type:ze(f.type)}:{},...f?.description!==void 0?{description:f.description}:{}})})),...s!==void 0?{annotations:s}:{}})}function ze(e){return typeof e=="string"?e:typeof e=="object"&&e!==null&&"enum"in e?"enum":"unknown"}function Te(e,n,r){return Object.freeze({code:e instanceof re?e.code:"SUBMISSION_FAILED",message:e.message,source:{actionId:n.intentId??"",nodePath:"governance.submit"},timestamp:r.meta.timestamp})}function Ie(e){return e instanceof Error?e:new Error(String(e))}import{ManifestoError as ce}from"@manifesto-ai/sdk";function ie(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ve(e,n){return e.length===0?n:`${e}.${n}`}function se(e,n,r,s){if(Object.is(e,n))return;let d=ie(e),b=ie(n);if(d&&b){let A=new Set([...Object.keys(e),...Object.keys(n)]);for(let v of A)se(e[v],n[v],ve(r,v),s);return}let f=Array.isArray(e),j=Array.isArray(n);if(f&&j){let A=Math.max(e.length,n.length);for(let v=0;v<A;v+=1)se(e[v],n[v],ve(r,String(v)),s);return}r.length>0&&JSON.stringify(e)!==JSON.stringify(n)&&s.add(r)}function we(e,n){let r=new Set;return se(e,n,"",r),Object.freeze([...r].sort())}function Be(e,n){for(let r of n){if(r==="*")return!0;let s=r.endsWith(".*")?r.slice(0,-2):r;if(e===s||e.startsWith(`${s}.`))return!0}return!1}function be(e,n){let r=n?.allowedPaths;return!r||r.length===0?Object.freeze([]):Object.freeze(e.filter(s=>!Be(s,r)))}function Ne(e){if(!ie(e))return null;let n=e.allowedPaths;return n===void 0||Array.isArray(n)&&n.every(r=>typeof r=="string")?e:null}function Ae(e){let{kernel:n,lineage:r,governanceService:s,governanceStore:d,eventDispatcher:b,getCurrentTimestamp:f}=e;async function j(u,E){let P=null,w=null,W=!1;try{if(P=await r.sealIntent(E,{branchId:u.branchId,baseWorldId:u.baseWorld,proposalRef:u.proposalId,decisionRef:u.decisionId,executionKey:u.executionKey,publishOnCompleted:!1,assumeEnqueued:!0,rejectPendingBeforeSeal:"unless-failed",context:u.computeEnvelope.context}),P.preparedCommit.branchId!==u.branchId||P.preparedCommit.attempt.baseWorldId!==u.baseWorld)throw new ce("GOVERNANCE_LINEAGE_TARGET_MISMATCH",`Governance proposal "${u.proposalId}" sealed on a different lineage target`);let g=Ne(u.approvedScope);if(g?.allowedPaths&&g.allowedPaths.length>0){let S=await r.getWorldSnapshot(u.baseWorld),R=we(S?.state??{},P.hostResult.snapshot.state),D=be(R,g);if(D.length>0)throw new ce("GOVERNANCE_SCOPE_VIOLATION",`Governance proposal "${u.proposalId}" settled outside its approved scope: ${D.join(", ")}`)}let a=await s.finalize(u,P.preparedCommit,f()),l=ke(P.hostResult.snapshot,Object.freeze({hostTraces:P.hostResult.traces}),E);w=Object.freeze({...a.proposal,terminalOutcome:l});let T=Object.freeze({...a,proposal:w});await d.putProposal(w),W=!0;let y=await r.getActiveBranch();return P.preparedCommit.branchChange.headAdvanced&&y.id===P.preparedCommit.branchId&&n.setVisibleSnapshot(P.hostResult.snapshot),b.emitSealCompleted(T,P.preparedCommit),w}catch(g){let a=Le(g);if(!W)try{if(w)try{await d.putProposal(w)}catch{let l=s.failExecution(u,f(),P?.preparedCommit.worldId);await d.putProposal(l)}else{let l=s.failExecution(u,f(),P?.preparedCommit.worldId);await d.putProposal(l)}}catch{}throw a}}async function A(u,E,P){let w=await d.getProposal(u)??E;w.status==="completed"||w.status==="failed"||w.status==="rejected"||w.status==="superseded"||await d.putProposal(await v(w,P))}async function v(u,E){if(u.status==="approved"){let P=s.beginExecution(u);return await d.putProposal(P),s.failExecution(P,f(),E)}return u.status==="executing"?s.failExecution(u,f(),E):s.prepareSupersede(u,"manual_cancel")}return{finalizeApprovedExecution:j,compensateSettlementFailure:A}}function J(e){return{type:e.computeEnvelope.intent.type,intentId:e.computeEnvelope.intent.intentId,...e.computeEnvelope.intent.input!==void 0?{input:e.computeEnvelope.intent.input}:{}}}function Le(e){return e instanceof Error?e:new ce("GOVERNANCE_EXECUTION_FAILED","Governed proposal execution did not produce a completed result")}function Ee(e,n){let r=e.canonical.afterCanonicalSnapshot,s=q(r);return s?Object.freeze({kind:"fail",error:s}):e.canonical.status==="error"?Object.freeze({kind:"fail",error:Object.freeze({code:"GOVERNANCE_EXECUTION_FAILED",message:"Governed proposal execution completed with error status",source:{actionId:n.intent.intentId,nodePath:"governance.waitForSettlement"},timestamp:r.meta.timestamp})}):Object.freeze({kind:"ok"})}function ke(e,n,r){let s=Ve(n);if(s!==null)return Object.freeze({kind:"stop",reason:s});let d=q(e);return d?Object.freeze({kind:"fail",error:d}):e.system.status==="error"?Object.freeze({kind:"fail",error:Object.freeze({code:"GOVERNANCE_EXECUTION_FAILED",message:"Governed proposal execution completed with error status",source:{actionId:r.intentId,nodePath:"governance.finalizeExecution"},timestamp:e.meta.timestamp})}):Object.freeze({kind:"ok"})}function Ve(e){let n=e.hostTraces?.slice().reverse().find(r=>r.terminatedBy==="halt");if(!n)return null;for(let r of Object.values(n.nodes))if(r.kind==="halt"){let s=r.inputs.reason;return typeof s=="string"?s:"halted"}return"halted"}function Re(e,n,r){let{kernel:s,lineage:d,lineageService:b,governanceService:f,governanceStore:j,ensureReady:A,activeSettlementTasks:v}=e,{finalizeApprovedExecution:u,compensateSettlementFailure:E}=n,{settleSubmission:P}=r;async function w(g){if(g.status==="submitted"){await P(g.proposalId);return}if(g.status==="evaluating"){await P(g.proposalId);return}if(!(g.status!=="approved"&&g.status!=="executing")&&!v.has(g.proposalId)){v.add(g.proposalId);try{if(g.status==="approved"){let T=f.beginExecution(g);await j.putProposal(T);try{await u(T,J(g))}catch{await E(g.proposalId,T)}return}let a=g,l;try{l=(await b.getAttemptsByBranch(a.branchId)).find(y=>y.proposalRef===a.proposalId)?.worldId}catch{}await E(a.proposalId,a,l)}finally{v.delete(g.proposalId)}}}async function W(){if(s.isDisposed())return;await A();let g=await d.getBranches(),a=new Set;for(let l of g){let T=await j.getProposalsByBranch(l.id);for(let y of T){if(s.isDisposed())return;a.has(y.proposalId)||(a.add(y.proposalId),(y.status==="submitted"||y.status==="evaluating"||y.status==="approved"||y.status==="executing")&&await w(y))}}}return{resumeStoredSettlement:w,resumePendingSettlements:W}}import{DisposedError as Ue,ManifestoError as Y}from"@manifesto-ai/sdk";function Oe(e,n){let{kernel:r,lineage:s,governanceStore:d}=e,{resumeStoredSettlement:b}=n;async function f(a,l,T){let y=new Set;for(;;){if(r.isDisposed())throw new Ue;let S=await d.getProposal(a);if(!S)throw new Y("GOVERNANCE_PROPOSAL_NOT_FOUND",`Proposal "${a}" was not found`);if(S.status==="completed"||u(S))return A(S,l,T);if(S.status==="failed")return P(S,l,T);if(E(S))return j(S,l,T);y.has(S.proposalId)||(y.add(S.proposalId),await r.enqueue(async()=>{let R=await d.getProposal(S.proposalId);R&&await b(R)})),await Ke(10)}}async function j(a,l,T){let y=g(a,l),S=null;if(a.decisionId&&(S=await d.getDecisionRecord(a.decisionId),!S)){let D=w(a);return Object.freeze({ok:!1,mode:"governance",status:"settlement_failed",action:y,proposal:a.proposalId,error:D,...T==="none"?{}:{report:Object.freeze({mode:"governance",status:"settlement_failed",action:y,proposal:a.proposalId,stage:"observation",error:D})}})}let R=S?Object.freeze({...S}):void 0;return Object.freeze({ok:!0,mode:"governance",status:a.status,action:y,proposal:a.proposalId,...R?{decision:R}:{},...T==="none"?{}:{report:Object.freeze({mode:"governance",status:a.status,action:y,proposal:a.proposalId,...R?{decision:R}:{}})}})}async function A(a,l,T){let y=g(a,l),S=await s.getWorldSnapshot(a.baseWorld);if(!S)throw new Y("GOVERNANCE_BASE_WORLD_NOT_FOUND",`Proposal references missing base world "${a.baseWorld}"`);let R=await s.getWorldSnapshot(a.resultWorld);if(!R)throw new Y("GOVERNANCE_RESULT_WORLD_NOT_FOUND",`Proposal references missing result world "${a.resultWorld}"`);let D=await s.getWorld(a.resultWorld);if(!D)throw new Y("GOVERNANCE_RESULT_WORLD_NOT_FOUND",`Proposal references missing result world "${a.resultWorld}"`);let M=r.deriveExecutionOutcome(S,R),h=a.terminalOutcome??Ee(M,a),p=await v(a);return Object.freeze({ok:!0,mode:"governance",status:"settled",action:y,proposal:a.proposalId,world:Object.freeze({...D}),before:M.projected.beforeSnapshot,after:M.projected.afterSnapshot,outcome:h,...T==="none"?{}:{report:Object.freeze({mode:"governance",status:"settled",action:y,proposal:a.proposalId,baseWorldId:a.baseWorld,worldId:a.resultWorld,sealedSnapshotHash:D.snapshotHash,published:p,outcome:h,changes:M.projected.changedPaths,requirements:M.canonical.pendingRequirements})}})}async function v(a){let l=await s.getActiveBranch();return l.id===a.branchId&&l.head===a.resultWorld}function u(a){return a.status==="failed"&&a.resultWorld!==void 0&&a.terminalOutcome!==void 0}function E(a){return a.status==="rejected"||a.status==="superseded"}async function P(a,l,T){let y=g(a,l),S=await W(a);return Object.freeze({ok:!1,mode:"governance",status:"settlement_failed",action:y,proposal:a.proposalId,error:S,...T==="none"?{}:{report:Object.freeze({mode:"governance",status:"settlement_failed",action:y,proposal:a.proposalId,stage:"settlement",error:S})}})}function w(a){let l=r.getCanonicalSnapshot();return Object.freeze({code:"GOVERNANCE_DECISION_RECORD_NOT_FOUND",message:`Proposal "${a.proposalId}" references missing decision record "${a.decisionId}"`,source:{actionId:a.intent.intentId,nodePath:"governance.waitForSettlement"},timestamp:l.meta.timestamp})}async function W(a){if(a.resultWorld){let T=await s.getWorldSnapshot(a.resultWorld);if(T){let y=q(T);if(y)return y}}let l=r.getCanonicalSnapshot();return Object.freeze({code:"GOVERNANCE_SETTLEMENT_FAILED",message:`Proposal "${a.proposalId}" failed before settlement completed`,source:{actionId:a.intent.intentId,nodePath:"governance.waitForSettlement"},timestamp:l.meta.timestamp})}function g(a,l){return l??a.intent.type}return{waitForSettlement:f}}function Ke(e){return new Promise(n=>{setTimeout(n,e)})}import{DisposedError as Q,ManifestoError as de}from"@manifesto-ai/sdk";function xe(e,n){let{kernel:r,lineage:s,config:d,governanceService:b,governanceStore:f,evaluator:j,getCurrentTimestamp:A,ensureReady:v,proposalSubmissionBindings:u,activeSettlementTasks:E}=e,{finalizeApprovedExecution:P,compensateSettlementFailure:w}=n;async function W(h,p){let m=await b.invalidateStaleIngress(h,p);await Promise.all(m.map(async O=>{await f.putProposal(O)}))}async function g(h){let p=await f.getActorBinding(h);if(p)return p;throw new de("GOVERNANCE_BINDING_NOT_FOUND",`No actor-authority binding exists for actor "${h}"`)}async function a(h,p,m){switch(p.policy.mode){case"hitl":return{kind:"pending",waitingFor:{kind:"human",delegate:p.policy.delegate}};case"tribunal":return{kind:"pending",waitingFor:{kind:"tribunal",members:p.policy.members}};default:return m.evaluate(h,p)}}async function l(h,p){let m=await b.prepareAuthorityResult(h,p,{decidedAt:A()});if(m.decisionRecord&&await f.putDecisionRecord(m.decisionRecord),await f.putProposal(m.proposal),m.discarded||m.proposal.status==="rejected")return m.proposal;let O=b.beginExecution(m.proposal);return await f.putProposal(O),P(O,J(m.proposal))}async function T(h,p){await v();let m=r.ensureIntentId(h),O=await s.getActiveBranch();await W(O.id,O.epoch);let z=d.execution.deriveActor(m),k=await g(z.actorId),F=await he({body:{type:m.type,...m.input!==void 0?{input:m.input}:{},...$e(m)?{scopeProposal:m.scopeProposal}:{}},schemaHash:r.schema.hash,projectionId:d.execution.projectionId,source:d.execution.deriveSource(m),actor:z,intentId:m.intentId}),V=ue(),$={type:F.body.type,intentId:F.intentId,...F.body.input!==void 0?{input:F.body.input}:{}},C={...$,...F.body.scopeProposal!==void 0?{scopeProposal:F.body.scopeProposal}:{}},U=b.createProposal({proposalId:V,baseWorld:O.head,branchId:O.id,actorId:k.actorId,authorityId:k.authorityId,intent:C,computeEnvelope:{intent:$,context:p},executionKey:pe({proposalId:V,actorId:k.actorId,baseWorld:O.head,branchId:O.id,attempt:1}),submittedAt:A(),epoch:O.epoch});await f.putProposal(U),u.set(V,k);let K=b.beginEvaluating(U);try{await f.putProposal(K)}catch{return U}return K}async function y(h){if(!E.has(h)){E.add(h);try{await S(h)}finally{E.delete(h)}}}async function S(h){if(r.isDisposed())throw new Q;await v();let p=await f.getProposal(h);if(!p)return;let m;if(p.status==="submitted")m=b.beginEvaluating(p),await f.putProposal(m);else if(p.status==="evaluating")m=p;else return;let O=u.get(h)??await g(m.actorId);u.delete(h);try{let z=await a(m,O,j);if(z.kind==="pending")return;await l(m,z)}catch{await w(h,m)}}async function R(h){let p=await f.getProposal(h);if(!p)throw new de("GOVERNANCE_PROPOSAL_NOT_FOUND",`Proposal "${h}" was not found`);if(p.status!=="evaluating")throw new de("GOVERNANCE_PENDING_REQUIRED",`Proposal "${h}" is not pending human resolution`);return p}async function D(h,p){if(r.isDisposed())throw new Q;return r.enqueue(async()=>{if(r.isDisposed())throw new Q;await v();let m=await R(h);return l(m,{kind:"approved",approvedScope:p!==void 0?p:m.intent.scopeProposal??null})})}async function M(h,p){if(r.isDisposed())throw new Q;return r.enqueue(async()=>{if(r.isDisposed())throw new Q;await v();let m=await R(h);return l(m,{kind:"rejected",...p?{reason:p}:{}})})}return{createSubmission:T,settleSubmission:y,approve:D,reject:M}}function $e(e){return"scopeProposal"in e&&e.scopeProposal!==void 0}import{DisposedError as Ot,ManifestoError as xt}from"@manifesto-ai/sdk";var He=Symbol("manifesto-governance.wait-for-proposal");function Ce(e,n){return Object.defineProperty(e,He,{enumerable:!1,configurable:!1,writable:!1,value:n}),e}var nt=Object.freeze({__governanceLaws:!0});function ot(e,n){Xe(e);let r=Ze(e),s=r,d=tt(e);if(!d)throw new qe("GOVERNANCE_LINEAGE_REQUIRED","withGovernance() requires a manifesto already composed with withLineage()");let b=Ye(e),f={_laws:Object.freeze({...e._laws,...nt}),schema:e.schema,activate(){return Qe(f),rt(s(),d.config,n)}};return Je(f,r,b),f}function rt(e,n,r){let s=r.governanceStore??ee(),d=ye(s,{lineageService:n.service}),b=r.evaluator??me(),f=fe({service:d,sink:r.eventSink,now:r.now}),j=r.now??Date.now,A=et(e,n.service,n),v,u=null,E=new Map,P=new Set;async function w(){return u||(u=Promise.all(r.bindings.map(async C=>{await s.putActorBinding(C)})).then(()=>{}).catch(C=>{throw u=null,C}),u)}async function W(){await A.ensureReady(),await w()}function g(){return j()}let a={kernel:e,lineage:A,lineageService:n.service,config:r,governanceService:d,governanceStore:s,evaluator:b,eventDispatcher:f,getCurrentTimestamp:g,ensureReady:W,proposalSubmissionBindings:E,activeSettlementTasks:P},l=Ae(a),T=xe(a,l),y=Re(a,l,T),S=Oe(a,y),{createSubmission:R,settleSubmission:D,approve:M,reject:h}=T,{resumePendingSettlements:p}=y,{waitForSettlement:m}=S;async function O(C){return await w(),s.getProposal(C)}async function z(C){await W();let U=C??(await A.getActiveBranch()).id;return s.getProposalsByBranch(U)}async function k(C){if(e.isDisposed())throw new De;return e.enqueue(async()=>{if(e.isDisposed())throw new De;await w(),await s.putActorBinding(C)})}async function F(C){return await w(),s.getActorBinding(C)}async function V(C){return await w(),s.getDecisionRecord(C)}let $=ae(e,{lineage:A,ensureReady:W,createSubmission:R,settleSubmission:D,resumePendingSettlements:p,waitForSettlement:m,approve:M,reject:h,getProposal:O,getProposals:z,bindActor:k,getActorBinding:F,getDecisionRecord:V});return v=Ce($,{isDisposed:e.isDisposed,deriveExecutionOutcome:e.deriveExecutionOutcome}),e.enqueue(p).catch(()=>{}),Object.freeze(v)}export{ee as createInMemoryGovernanceStore,Ge as createNoopGovernanceEventSink,ot as withGovernance};
|
package/dist/provider.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as h,B as C,D as P,E as D,F as K,G as N,H as g,I as b,a as e,b as t,c as o,d as n,e as r,f as a,g as i,h as c,i as s,j as p,k as l,l as u,m as y,n as I,o as S,p as d,q as v,r as E,s as T,t as f,u as m,v as A,w as x,x as G,y as H,z as R}from"./chunk-
|
|
1
|
+
import{A as h,B as C,D as P,E as D,F as K,G as N,H as g,I as b,a as e,b as t,c as o,d as n,e as r,f as a,g as i,h as c,i as s,j as p,k as l,l as u,m as y,n as I,o as S,p as d,q as v,r as E,s as T,t as f,u as m,v as A,w as x,x as G,y as H,z as R}from"./chunk-HI32V6PR.js";export{h as AuthorityEvaluator,T as AutoApproveHandler,p as DECISION_TRANSITION_TARGETS,D as DefaultGovernanceService,c as EXECUTION_STAGE_STATUSES,m as HITLHandler,i as INGRESS_STATUSES,v as InMemoryGovernanceStore,x as PolicyRulesHandler,s as TERMINAL_STATUSES,H as TribunalHandler,N as computeIntentKey,C as createAuthorityEvaluator,f as createAutoApproveHandler,t as createDecisionId,o as createExecutionKey,P as createGovernanceEventDispatcher,K as createGovernanceService,A as createHITLHandler,E as createInMemoryGovernanceStore,g as createIntentInstance,b as createIntentInstanceSync,r as createNoopGovernanceEventSink,G as createPolicyRulesHandler,e as createProposalId,R as createTribunalHandler,n as defaultExecutionKeyPolicy,S as getValidTransitions,u as isExecutionStageStatus,l as isIngressStatus,y as isTerminalStatus,I as isValidTransition,a as toHostIntent,d as transitionCreatesDecisionRecord};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ManifestoDomainShape } from "@manifesto-ai/sdk";
|
|
2
|
+
import type { GovernanceRuntimeDeps } from "./runtime-deps.js";
|
|
3
|
+
import { type SettlementEngine } from "./settlement.js";
|
|
4
|
+
import type { SubmissionFlow } from "./submission.js";
|
|
5
|
+
import type { Proposal } from "./types.js";
|
|
6
|
+
/**
|
|
7
|
+
* Recovery seam: resumes stored, unsettled proposals after activation or on
|
|
8
|
+
* demand from settlement observation, without re-executing host effects.
|
|
9
|
+
*/
|
|
10
|
+
export interface SettlementRecovery {
|
|
11
|
+
resumeStoredSettlement(proposal: Proposal): Promise<void>;
|
|
12
|
+
resumePendingSettlements(): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
export declare function createSettlementRecovery<T extends ManifestoDomainShape>(deps: GovernanceRuntimeDeps<T>, settlement: SettlementEngine<T>, submission: Pick<SubmissionFlow<T>, "settleSubmission">): SettlementRecovery;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ManifestoDomainShape } from "@manifesto-ai/sdk";
|
|
2
|
+
import type { GovernanceRuntimeKernel } from "@manifesto-ai/sdk/provider";
|
|
3
|
+
import type { LineageRuntimeController, LineageService } from "@manifesto-ai/lineage/provider";
|
|
4
|
+
import type { AuthorityEvaluator } from "./authority/evaluator.js";
|
|
5
|
+
import type { GovernanceConfig } from "./runtime-types.js";
|
|
6
|
+
import type { ActorAuthorityBinding, GovernanceEventDispatcher, GovernanceService, GovernanceStore, ProposalId } from "./types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Shared runtime collaborators for the governance activation modules.
|
|
9
|
+
*
|
|
10
|
+
* `activateGovernanceRuntime()` builds this once and hands it to the
|
|
11
|
+
* settlement, submission, recovery, and observation factories so the
|
|
12
|
+
* extracted closures keep operating on the exact same shared state
|
|
13
|
+
* (`proposalSubmissionBindings`, `activeSettlementTasks`) and services.
|
|
14
|
+
*/
|
|
15
|
+
export interface GovernanceRuntimeDeps<T extends ManifestoDomainShape> {
|
|
16
|
+
readonly kernel: GovernanceRuntimeKernel<T>;
|
|
17
|
+
readonly lineage: LineageRuntimeController<T>;
|
|
18
|
+
readonly lineageService: LineageService;
|
|
19
|
+
readonly config: GovernanceConfig<T>;
|
|
20
|
+
readonly governanceService: GovernanceService;
|
|
21
|
+
readonly governanceStore: GovernanceStore;
|
|
22
|
+
readonly evaluator: AuthorityEvaluator;
|
|
23
|
+
readonly eventDispatcher: GovernanceEventDispatcher;
|
|
24
|
+
readonly getCurrentTimestamp: () => number;
|
|
25
|
+
readonly ensureReady: () => Promise<void>;
|
|
26
|
+
readonly proposalSubmissionBindings: Map<ProposalId, ActorAuthorityBinding>;
|
|
27
|
+
readonly activeSettlementTasks: Set<ProposalId>;
|
|
28
|
+
}
|
package/dist/runtime-types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ComposableManifesto, BaseLaws, GovernanceLaws, LineageLaws, ManifestoDomainShape, TypedIntent } from "@manifesto-ai/sdk";
|
|
2
|
-
import type { BranchId,
|
|
1
|
+
import type { ComposableManifesto, BaseLaws, GovernanceLaws, LineageLaws, ManifestoApp, ManifestoDomainShape, TypedIntent } from "@manifesto-ai/sdk";
|
|
2
|
+
import type { BranchId, LineageContinuitySurface } from "@manifesto-ai/lineage";
|
|
3
3
|
import type { AuthorityEvaluator } from "./authority/evaluator.js";
|
|
4
4
|
import type { ActorAuthorityBinding, ActorId, ActorRef, DecisionId, DecisionRecord, GovernanceEventSink, GovernanceStore, IntentScope, Proposal, ProposalId, SourceRef } from "./types.js";
|
|
5
5
|
export type GovernanceExecutionConfig<T extends ManifestoDomainShape> = {
|
|
@@ -19,8 +19,7 @@ export type LineageComposableLaws = BaseLaws & LineageLaws & {
|
|
|
19
19
|
readonly __governanceLaws?: never;
|
|
20
20
|
};
|
|
21
21
|
export type GovernedComposableLaws = BaseLaws & LineageLaws & GovernanceLaws;
|
|
22
|
-
export type
|
|
23
|
-
readonly proposeAsync: (intent: TypedIntent<T>) => Promise<Proposal>;
|
|
22
|
+
export type GovernanceControlSurface = {
|
|
24
23
|
readonly approve: (proposalId: ProposalId, approvedScope?: IntentScope | null) => Promise<Proposal>;
|
|
25
24
|
readonly reject: (proposalId: ProposalId, reason?: string) => Promise<Proposal>;
|
|
26
25
|
readonly getProposal: (proposalId: ProposalId) => Promise<Proposal | null>;
|
|
@@ -29,7 +28,8 @@ export type GovernanceInstance<T extends ManifestoDomainShape> = Omit<LineageIns
|
|
|
29
28
|
readonly getActorBinding: (actorId: ActorId) => Promise<ActorAuthorityBinding | null>;
|
|
30
29
|
readonly getDecisionRecord: (decisionId: DecisionId) => Promise<DecisionRecord | null>;
|
|
31
30
|
};
|
|
32
|
-
export type
|
|
31
|
+
export type GovernanceInstance<T extends ManifestoDomainShape> = ManifestoApp<T, "governance"> & LineageContinuitySurface<T> & GovernanceControlSurface;
|
|
32
|
+
export type GovernanceProposalRuntime<_T extends ManifestoDomainShape> = Record<never, never>;
|
|
33
33
|
export type GovernanceComposableManifesto<T extends ManifestoDomainShape> = Omit<ComposableManifesto<T, GovernedComposableLaws>, "activate"> & {
|
|
34
34
|
activate(): GovernanceInstance<T>;
|
|
35
35
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { LineageService, PreparedLineageCommit,
|
|
1
|
+
import type { LineageService, PreparedLineageCommit, WorldId, WorldRecord } from "@manifesto-ai/lineage/provider";
|
|
2
2
|
import { type AuthorityResponse, type BranchId, type CreateProposalInput, type DecisionRecord, type GovernanceService, type GovernanceStore, type ExecutionCompletedEvent, type ExecutionFailedEvent, type PreparedAuthorityResult, type PrepareAuthorityResultOptions, type PreparedGovernanceCommit, type Proposal, type ProposalDecidedEvent, type ProposalEvaluatingEvent, type ProposalId, type ProposalSubmittedEvent, type ProposalSupersededEvent, type WorldCreatedEvent, type WorldForkedEvent, type Snapshot, type SupersedeReason, type ErrorInfo } from "../types.js";
|
|
3
3
|
export interface GovernanceServiceOptions {
|
|
4
4
|
readonly lineageService?: Pick<LineageService, "getBranch">;
|
|
@@ -31,7 +31,7 @@ export declare class DefaultGovernanceService implements GovernanceService {
|
|
|
31
31
|
createProposalSupersededEvent(proposal: Proposal, currentEpoch: number, timestamp?: number): ProposalSupersededEvent;
|
|
32
32
|
createExecutionCompletedEvent(proposal: Proposal, timestamp?: number): ExecutionCompletedEvent;
|
|
33
33
|
createExecutionFailedEvent(proposal: Proposal, error: ErrorInfo, timestamp?: number): ExecutionFailedEvent;
|
|
34
|
-
createWorldCreatedEvent(world:
|
|
34
|
+
createWorldCreatedEvent(world: WorldRecord, proposalId: ProposalId, from: WorldId, outcome: "completed" | "failed", timestamp?: number): WorldCreatedEvent;
|
|
35
35
|
createWorldForkedEvent(branchId: BranchId, forkPoint: WorldId, timestamp?: number): WorldForkedEvent;
|
|
36
36
|
private resolveBranchInfo;
|
|
37
37
|
private assertBranchGateAvailable;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ActionName, GovernanceSettlementResult, ManifestoDomainShape, ProposalRef, SubmitReportMode } from "@manifesto-ai/sdk";
|
|
2
|
+
import type { SettlementRecovery } from "./recovery.js";
|
|
3
|
+
import type { GovernanceRuntimeDeps } from "./runtime-deps.js";
|
|
4
|
+
/**
|
|
5
|
+
* Settlement observation seam: waits for a proposal to reach a terminal
|
|
6
|
+
* state and projects it into a `GovernanceSettlementResult`.
|
|
7
|
+
*/
|
|
8
|
+
export interface SettlementObservation<T extends ManifestoDomainShape> {
|
|
9
|
+
waitForSettlement<Name extends ActionName<T>>(proposalRef: ProposalRef, actionName?: Name, reportMode?: SubmitReportMode): Promise<GovernanceSettlementResult<T, Name>>;
|
|
10
|
+
}
|
|
11
|
+
export declare function createSettlementObservation<T extends ManifestoDomainShape>(deps: GovernanceRuntimeDeps<T>, recovery: Pick<SettlementRecovery, "resumeStoredSettlement">): SettlementObservation<T>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { DispatchExecutionOutcome, ExecutionOutcome, ManifestoDomainShape, TypedIntent } from "@manifesto-ai/sdk";
|
|
2
|
+
import type { GovernanceRuntimeDeps } from "./runtime-deps.js";
|
|
3
|
+
import type { Proposal, ProposalId } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Settlement/finalization seam: seals an approved execution into lineage and
|
|
6
|
+
* compensates settlement failures with a terminal proposal record.
|
|
7
|
+
*/
|
|
8
|
+
export interface SettlementEngine<T extends ManifestoDomainShape> {
|
|
9
|
+
finalizeApprovedExecution(executingProposal: Proposal & {
|
|
10
|
+
readonly status: "executing";
|
|
11
|
+
}, intent: TypedIntent<T>): Promise<Proposal>;
|
|
12
|
+
compensateSettlementFailure(proposalId: ProposalId, fallbackProposal: Proposal, resultWorld?: string): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
export declare function createSettlementEngine<T extends ManifestoDomainShape>(deps: GovernanceRuntimeDeps<T>): SettlementEngine<T>;
|
|
15
|
+
export declare function toTypedComputeIntent<T extends ManifestoDomainShape>(proposal: Proposal): TypedIntent<T>;
|
|
16
|
+
export declare function toSettlementOutcome<T extends ManifestoDomainShape>(dispatchOutcome: DispatchExecutionOutcome<T>, proposal: Proposal): ExecutionOutcome;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Context } from "@manifesto-ai/core";
|
|
2
|
+
import type { ManifestoDomainShape, TypedIntent } from "@manifesto-ai/sdk";
|
|
3
|
+
import type { GovernanceRuntimeDeps } from "./runtime-deps.js";
|
|
4
|
+
import { type SettlementEngine } from "./settlement.js";
|
|
5
|
+
import type { IntentScope, Proposal, ProposalId } from "./types.js";
|
|
6
|
+
/**
|
|
7
|
+
* Submission/authority decision seam: proposal ingress, authority
|
|
8
|
+
* evaluation, decision application, and the explicit approve/reject paths.
|
|
9
|
+
*/
|
|
10
|
+
export interface SubmissionFlow<T extends ManifestoDomainShape> {
|
|
11
|
+
createSubmission(intent: TypedIntent<T>, context: Context): Promise<Proposal>;
|
|
12
|
+
settleSubmission(proposalId: ProposalId): Promise<void>;
|
|
13
|
+
approve(proposalId: ProposalId, approvedScope?: IntentScope | null): Promise<Proposal>;
|
|
14
|
+
reject(proposalId: ProposalId, reason?: string): Promise<Proposal>;
|
|
15
|
+
}
|
|
16
|
+
export declare function createSubmissionFlow<T extends ManifestoDomainShape>(deps: GovernanceRuntimeDeps<T>, settlement: SettlementEngine<T>): SubmissionFlow<T>;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { ErrorValue, Intent as HostIntent, Snapshot } from "@manifesto-ai/core";
|
|
2
|
-
import type { BranchId,
|
|
2
|
+
import type { BranchId, ComputeEnvelope, WorldId, WorldRecord } from "@manifesto-ai/lineage";
|
|
3
3
|
import type { PreparedLineageCommit } from "@manifesto-ai/lineage/provider";
|
|
4
|
+
import type { ExecutionOutcome } from "@manifesto-ai/sdk";
|
|
4
5
|
export type { Snapshot } from "@manifesto-ai/core";
|
|
5
|
-
export type { ArtifactRef, BranchId,
|
|
6
|
+
export type { ArtifactRef, BranchId, ComputeEnvelope, WorldId, WorldRecord, } from "@manifesto-ai/lineage";
|
|
6
7
|
export type ProposalId = string;
|
|
7
8
|
export type DecisionId = string;
|
|
8
9
|
export type ActorId = string;
|
|
@@ -72,6 +73,7 @@ export interface Proposal {
|
|
|
72
73
|
readonly actorId: ActorId;
|
|
73
74
|
readonly authorityId: AuthorityId;
|
|
74
75
|
readonly intent: Intent;
|
|
76
|
+
readonly computeEnvelope: ComputeEnvelope;
|
|
75
77
|
readonly status: ProposalStatus;
|
|
76
78
|
readonly executionKey: ExecutionKey;
|
|
77
79
|
readonly submittedAt: number;
|
|
@@ -80,6 +82,7 @@ export interface Proposal {
|
|
|
80
82
|
readonly decisionId?: DecisionId;
|
|
81
83
|
readonly epoch: number;
|
|
82
84
|
readonly resultWorld?: WorldId;
|
|
85
|
+
readonly terminalOutcome?: ExecutionOutcome;
|
|
83
86
|
readonly supersededReason?: SupersedeReason;
|
|
84
87
|
readonly approvedScope?: unknown;
|
|
85
88
|
}
|
|
@@ -220,7 +223,7 @@ export interface ExecutionFailedEvent extends BaseGovernanceEvent<"execution:fai
|
|
|
220
223
|
readonly error: ErrorInfo;
|
|
221
224
|
}
|
|
222
225
|
export interface WorldCreatedEvent extends BaseGovernanceEvent<"world:created"> {
|
|
223
|
-
readonly world:
|
|
226
|
+
readonly world: WorldRecord;
|
|
224
227
|
readonly from: WorldId;
|
|
225
228
|
readonly proposalId: ProposalId;
|
|
226
229
|
readonly outcome: "completed" | "failed";
|
|
@@ -258,6 +261,7 @@ export interface CreateProposalInput {
|
|
|
258
261
|
readonly actorId: ActorId;
|
|
259
262
|
readonly authorityId: AuthorityId;
|
|
260
263
|
readonly intent: Intent;
|
|
264
|
+
readonly computeEnvelope: ComputeEnvelope;
|
|
261
265
|
readonly executionKey: ExecutionKey;
|
|
262
266
|
readonly submittedAt: number;
|
|
263
267
|
readonly epoch: number;
|
|
@@ -298,7 +302,7 @@ export interface GovernanceService {
|
|
|
298
302
|
createProposalSupersededEvent(proposal: Proposal, currentEpoch: number, timestamp?: number): ProposalSupersededEvent;
|
|
299
303
|
createExecutionCompletedEvent(proposal: Proposal, timestamp?: number): ExecutionCompletedEvent;
|
|
300
304
|
createExecutionFailedEvent(proposal: Proposal, error: ErrorInfo, timestamp?: number): ExecutionFailedEvent;
|
|
301
|
-
createWorldCreatedEvent(world:
|
|
305
|
+
createWorldCreatedEvent(world: WorldRecord, proposalId: ProposalId, from: WorldId, outcome: "completed" | "failed", timestamp?: number): WorldCreatedEvent;
|
|
302
306
|
createWorldForkedEvent(branchId: BranchId, forkPoint: WorldId, timestamp?: number): WorldForkedEvent;
|
|
303
307
|
}
|
|
304
308
|
export declare function createProposalId(value?: string): ProposalId;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type CanonicalSnapshot, type DispatchExecutionOutcome, type ManifestoDomainShape } from "@manifesto-ai/sdk";
|
|
2
2
|
import type { WaitForProposalRuntimeKernel } from "@manifesto-ai/sdk/provider";
|
|
3
3
|
import type { GovernanceInstance } from "./runtime-types.js";
|
|
4
4
|
import type { ErrorInfo, Proposal, ProposalId, WorldId } from "./types.js";
|
|
@@ -13,7 +13,7 @@ export type ProposalSettlement<T extends ManifestoDomainShape = ManifestoDomainS
|
|
|
13
13
|
readonly status: "completed";
|
|
14
14
|
readonly resultWorld: WorldId;
|
|
15
15
|
};
|
|
16
|
-
readonly snapshot:
|
|
16
|
+
readonly snapshot: CanonicalSnapshot<T["state"]>;
|
|
17
17
|
readonly resultWorld: WorldId;
|
|
18
18
|
} | {
|
|
19
19
|
readonly kind: "failed";
|
|
@@ -47,7 +47,7 @@ export type ProposalSettlementReport<T extends ManifestoDomainShape = ManifestoD
|
|
|
47
47
|
};
|
|
48
48
|
readonly baseWorld: WorldId;
|
|
49
49
|
readonly resultWorld: WorldId;
|
|
50
|
-
readonly outcome:
|
|
50
|
+
readonly outcome: DispatchExecutionOutcome<T>;
|
|
51
51
|
} | {
|
|
52
52
|
readonly kind: "failed";
|
|
53
53
|
readonly proposal: Proposal & {
|
|
@@ -57,7 +57,7 @@ export type ProposalSettlementReport<T extends ManifestoDomainShape = ManifestoD
|
|
|
57
57
|
readonly published: false;
|
|
58
58
|
readonly error: ErrorInfo;
|
|
59
59
|
readonly resultWorld?: WorldId;
|
|
60
|
-
readonly sealedOutcome?:
|
|
60
|
+
readonly sealedOutcome?: DispatchExecutionOutcome<T>;
|
|
61
61
|
} | {
|
|
62
62
|
readonly kind: "rejected";
|
|
63
63
|
readonly proposal: Proposal & {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manifesto-ai/governance",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"description": "Manifesto Governance - decorator runtime for legitimacy, approval, and governed execution",
|
|
5
5
|
"author": "eggplantiny <eggplantiny@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,18 +34,18 @@
|
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@manifesto-ai/core": "^
|
|
37
|
+
"@manifesto-ai/core": "^5.1.0"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@manifesto-ai/
|
|
41
|
-
"@manifesto-ai/
|
|
40
|
+
"@manifesto-ai/sdk": "5.1.0",
|
|
41
|
+
"@manifesto-ai/lineage": "5.1.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"typescript": "^5.9.3",
|
|
45
45
|
"vite": "^8.0.8",
|
|
46
46
|
"vitest": "^4.1.4",
|
|
47
|
-
"@manifesto-ai/core": "
|
|
48
|
-
"@manifesto-ai/cts-kit": "0.
|
|
47
|
+
"@manifesto-ai/core": "5.1.0",
|
|
48
|
+
"@manifesto-ai/cts-kit": "5.0.0"
|
|
49
49
|
},
|
|
50
50
|
"files": [
|
|
51
51
|
"dist"
|
|
@@ -53,11 +53,11 @@
|
|
|
53
53
|
"scripts": {
|
|
54
54
|
"build": "rm -rf dist && tsup && tsc -p tsconfig.build.json --emitDeclarationOnly --declarationMap false --outDir dist && node ../../scripts/check-public-surface.mjs packages/governance",
|
|
55
55
|
"clean": "rm -rf dist",
|
|
56
|
-
"lint": "
|
|
56
|
+
"lint": "node ../../node_modules/@biomejs/biome/bin/biome check src",
|
|
57
57
|
"test": "pnpm run test:runtime && pnpm run test:types",
|
|
58
|
-
"test:runtime": "node ../../
|
|
59
|
-
"test:types": "node ../../
|
|
60
|
-
"test:coverage": "node ../../
|
|
61
|
-
"test:watch": "node ../../
|
|
58
|
+
"test:runtime": "node ../../scripts/run-vitest.mjs run",
|
|
59
|
+
"test:types": "node ../../scripts/run-tsc.mjs -p tsconfig.types.json --noEmit",
|
|
60
|
+
"test:coverage": "node ../../scripts/run-vitest.mjs run --coverage",
|
|
61
|
+
"test:watch": "node ../../scripts/run-vitest.mjs"
|
|
62
62
|
}
|
|
63
63
|
}
|
package/dist/chunk-2Q3OH2FH.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function P(t){return t??`prop-${crypto.randomUUID()}`}function u(t){return t??`dec-${crypto.randomUUID()}`}function G(t,e=1){return`${t}:${e}`}var M=({proposalId:t,attempt:e})=>G(t,e);function E(){return{emit(){}}}function z(t){return"body"in t?{type:t.body.type,input:t.body.input,intentId:t.intentId}:{type:t.type,input:t.input,intentId:t.intentId}}var W=["submitted","evaluating"],j=["approved","executing"],O=["rejected","completed","failed","superseded"],Q=["approved","rejected"],b={submitted:["evaluating","rejected","superseded"],evaluating:["approved","rejected","superseded"],approved:["executing"],rejected:[],executing:["completed","failed"],completed:[],failed:[],superseded:[]};function A(t){return W.includes(t)}function c(t){return j.includes(t)}function X(t){return O.includes(t)}function x(t,e){return b[t].includes(e)}function S(t){return[...b[t]]}function w(t,e){return t==="submitted"&&e==="rejected"||t==="evaluating"&&e==="approved"||t==="evaluating"&&e==="rejected"}function l(t){return structuredClone(t)}var y=class{proposals=new Map;decisions=new Map;actorBindings=new Map;async putProposal(e){this.proposals.set(e.proposalId,l(e))}async getProposal(e){return l(this.proposals.get(e)??null)}async getProposalsByBranch(e){return[...this.proposals.values()].filter(r=>r.branchId===e).sort((r,o)=>r.submittedAt!==o.submittedAt?r.submittedAt-o.submittedAt:r.proposalId.localeCompare(o.proposalId)).map(r=>l(r))}async getExecutionStageProposal(e){let r=(await this.getProposalsByBranch(e)).filter(o=>c(o.status));if(r.length>1)throw new Error(`GOV-STORE-4 violation: multiple execution-stage proposals found for branch ${e}`);return r[0]??null}async putDecisionRecord(e){this.decisions.set(e.decisionId,l(e))}async getDecisionRecord(e){return l(this.decisions.get(e)??null)}async putActorBinding(e){this.actorBindings.set(e.actorId,l(e))}async getActorBinding(e){return l(this.actorBindings.get(e)??null)}async getActorBindings(){return[...this.actorBindings.values()].sort((e,r)=>e.actorId.localeCompare(r.actorId)).map(e=>l(e))}snapshotState(){return{proposals:l(this.proposals),decisions:l(this.decisions),actorBindings:l(this.actorBindings)}}restoreState(e){this.proposals.clear();for(let[r,o]of e.proposals)this.proposals.set(r,l(o));this.decisions.clear();for(let[r,o]of e.decisions)this.decisions.set(r,l(o));this.actorBindings.clear();for(let[r,o]of e.actorBindings)this.actorBindings.set(r,l(o))}};function Z(){return new y}var m=class{async evaluate(e,r){if(r.policy.mode!=="auto_approve")throw new Error(`AutoApproveHandler received non-auto_approve policy: ${r.policy.mode}`);return{kind:"approved",approvedScope:e.intent.scopeProposal??null}}};function R(){return new m}var h=class{pendingDecisions=new Map;notificationCallbacks=new Set;onPendingDecision(e){return this.notificationCallbacks.add(e),()=>{this.notificationCallbacks.delete(e)}}async evaluate(e,r){if(r.policy.mode!=="hitl")throw new Error(`HITLHandler received non-hitl policy: ${r.policy.mode}`);let o=r.policy,n=e.proposalId;if(this.pendingDecisions.has(n))throw new Error(`Proposal ${n} already has a pending HITL decision`);return new Promise((i,a)=>{let s={proposalId:n,proposal:e,resolve:i,reject:a};o.timeout!=null&&(s.timeoutId=setTimeout(()=>{if(this.pendingDecisions.delete(n),o.onTimeout==="approve"){i({kind:"approved",approvedScope:e.intent.scopeProposal??null});return}a(new Error(`HITL decision timed out after ${o.timeout}ms for proposal '${n}'`))},o.timeout)),this.pendingDecisions.set(n,s);for(let p of this.notificationCallbacks)p(n,e,r)})}submitDecision(e,r,o,n){let i=this.pendingDecisions.get(e);if(!i)throw new Error(`No pending HITL decision for proposal ${e}`);if(i.timeoutId&&clearTimeout(i.timeoutId),this.pendingDecisions.delete(e),r==="approved"){i.resolve({kind:"approved",approvedScope:n!==void 0?n:i.proposal?.intent.scopeProposal??null});return}i.resolve({kind:"rejected",reason:o??"Human rejected"})}isPending(e){return this.pendingDecisions.has(e)}getPendingIds(){return[...this.pendingDecisions.keys()]}clearAllPending(){for(let[e,r]of this.pendingDecisions)r.timeoutId&&clearTimeout(r.timeoutId),r.reject(new Error(`HITL handler cleared pending proposal ${e}`));this.pendingDecisions.clear()}};function T(){return new h}var v=class{customEvaluators=new Map;registerCustomEvaluator(e,r){this.customEvaluators.set(e,r)}async evaluate(e,r){if(r.policy.mode!=="policy_rules")throw new Error(`PolicyRulesHandler received non-policy_rules policy: ${r.policy.mode}`);let o=e.intent.scopeProposal??null;for(let n of r.policy.rules)if(this.evaluateCondition(n.condition,e,r))return this.applyDecision(n,o);return this.applyDecision({decision:r.policy.defaultDecision,reason:"Default policy decision"},o)}evaluateCondition(e,r,o){switch(e.kind){case"intent_type":return e.types.includes(r.intent.type);case"scope_pattern":return this.matchPattern(r.intent.type,e.pattern);case"custom":{let n=this.customEvaluators.get(e.evaluator);return n?n(r,o):!1}}}matchPattern(e,r){return new RegExp(`^${r.replace(/\*/g,".*").replace(/\?/g,".")}$`).test(e)}applyDecision(e,r){switch(e.decision){case"approve":return{kind:"approved",approvedScope:r};case"reject":return{kind:"rejected",reason:e.reason??"Policy rejection"};case"escalate":return{kind:"rejected",reason:e.reason??"Policy requires escalation (not implemented)"}}}};function k(){return new v}var I=class{pendingTribunals=new Map;notificationCallback;onPendingTribunal(e){this.notificationCallback=e}async evaluate(e,r){if(r.policy.mode!=="tribunal")throw new Error(`TribunalHandler received non-tribunal policy: ${r.policy.mode}`);let o=r.policy,n=e.proposalId;if(this.pendingTribunals.has(n))throw new Error(`Proposal ${n} already has a pending tribunal`);return new Promise((i,a)=>{let s={proposalId:n,proposal:e,binding:r,votes:new Map,resolve:i,reject:a};o.timeout!=null&&(s.timeoutId=setTimeout(()=>{if(this.pendingTribunals.delete(n),o.onTimeout==="approve"){i({kind:"approved",approvedScope:e.intent.scopeProposal??null});return}a(new Error(`Tribunal decision timed out after ${o.timeout}ms for proposal '${n}'`))},o.timeout)),this.pendingTribunals.set(n,s),this.notificationCallback?.(n,e,o.members)})}submitVote(e,r,o,n){let i=this.pendingTribunals.get(e);if(!i)throw new Error(`No pending tribunal for proposal ${e}`);if(i.votes.has(r.actorId))throw new Error(`Actor ${r.actorId} already voted on proposal ${e}`);if(!(i.binding.policy.mode==="tribunal"?i.binding.policy.members.some(({actorId:s})=>s===r.actorId):!1))throw new Error(`Actor ${r.actorId} is not a tribunal member for proposal ${e}`);i.votes.set(r.actorId,{voter:r,decision:o,reasoning:n,votedAt:Date.now()}),this.checkQuorum(i)}isPending(e){return this.pendingTribunals.has(e)}getVotes(e){let r=this.pendingTribunals.get(e);return r?[...r.votes.values()]:[]}getPendingIds(){return[...this.pendingTribunals.keys()]}clearAllPending(){for(let[e,r]of this.pendingTribunals)r.timeoutId&&clearTimeout(r.timeoutId),r.reject(new Error(`Tribunal handler cleared pending proposal ${e}`));this.pendingTribunals.clear()}checkQuorum(e){let r=e.binding.policy;if(r.mode!=="tribunal")return;let o=r.members.length,n=0,i=0;for(let p of e.votes.values())p.decision==="approve"?n++:p.decision==="reject"&&i++;let a=!1,s=!1;switch(r.quorum.kind){case"unanimous":n===o?(a=!0,s=!0):(i>0||e.votes.size===o)&&(a=!0);break;case"majority":{let p=Math.floor(o/2)+1;n>=p?(a=!0,s=!0):i>=p?a=!0:e.votes.size===o&&(a=!0,s=n>i);break}case"threshold":n>=r.quorum.count?(a=!0,s=!0):i>o-r.quorum.count?a=!0:e.votes.size===o&&(a=!0,s=n>=r.quorum.count);break}if(a){if(e.timeoutId&&clearTimeout(e.timeoutId),this.pendingTribunals.delete(e.proposalId),s){e.resolve({kind:"approved",approvedScope:e.proposal.intent.scopeProposal??null});return}e.resolve({kind:"rejected",reason:`Tribunal rejected (${n}/${o} approved)`})}}};function H(){return new I}var $={auto_approve:"auto",hitl:"human",policy_rules:"policy",tribunal:"tribunal"},f=class{handlers=new Map;autoHandler;policyHandler;hitlHandler;tribunalHandler;constructor(){this.autoHandler=R(),this.policyHandler=k(),this.hitlHandler=T(),this.tribunalHandler=H(),this.handlers.set("auto_approve",this.autoHandler),this.handlers.set("hitl",this.hitlHandler),this.handlers.set("policy_rules",this.policyHandler),this.handlers.set("tribunal",this.tribunalHandler)}async evaluate(e,r){let o=this.handlers.get(r.policy.mode);if(!o)throw new Error(`Unknown policy mode: ${r.policy.mode}`);return o.evaluate(e,r)}registerHandler(e,r){this.handlers.set(e,r)}getAutoHandler(){return this.autoHandler}getPolicyHandler(){return this.policyHandler}getHITLHandler(){return this.hitlHandler}getTribunalHandler(){return this.tribunalHandler}getAuthorityKind(e){return $[e]??null}submitHITLDecision(e,r,o,n){this.hitlHandler.submitDecision(e,r,o,n)}submitTribunalVote(e,r,o,n){this.tribunalHandler.submitVote(e,r,o,n)}hasPendingHITL(){return this.hitlHandler.getPendingIds().length>0}hasPendingTribunal(){return this.tribunalHandler.getPendingIds().length>0}getPendingHITLIds(){return this.hitlHandler.getPendingIds()}getPendingTribunalIds(){return this.tribunalHandler.getPendingIds()}clearAllPending(){this.hitlHandler.clearAllPending(),this.tribunalHandler.clearAllPending()}};function ye(){return new f}function B(t){let e=t.system.lastError??void 0,r=t.system.pendingRequirements.map(o=>o.id);return{summary:K(e?1:0,r.length),...e?{currentError:e}:{},...r.length>0?{pendingRequirements:r}:{}}}function K(t,e){return t>0&&e>0?`Execution failed with ${t} error(s) and ${e} pending requirement(s)`:t>0?`Execution failed with ${t} error(s)`:e>0?`Execution failed with ${e} pending requirement(s)`:"Execution failed"}function fe(t){let e=t.sink??E(),r=t.now??Date.now;return{emitSealCompleted(o,n){let i=r(),a=o.proposal.status==="completed"?"completed":"failed";if(e.emit(t.service.createWorldCreatedEvent(n.world,o.proposal.proposalId,L(o,n),a,i)),_(n)&&e.emit(t.service.createWorldForkedEvent(o.proposal.branchId,n.edge.from,i)),a==="completed"){e.emit(t.service.createExecutionCompletedEvent(o.proposal,i));return}e.emit(t.service.createExecutionFailedEvent(o.proposal,V(n),i))}}}function L(t,e){return e.kind==="next"?e.edge.from:e.world.parentWorldId??t.proposal.baseWorld}function V(t){return B(t.terminalSnapshot)}function _(t){return t.kind==="next"&&"forkCreated"in t&&t.forkCreated===!0}import{sha256 as F,toJcs as D}from"@manifesto-ai/core";async function N(t,e){let r=[t,e.type,D(e.input??null),D(e.scopeProposal??null)].join(":");return F(r)}async function Ee(t){let e=t.intentId??`intent-${crypto.randomUUID()}`,r=await N(t.schemaHash,t.body);return q(t.body,e,r,{projectionId:t.projectionId,source:t.source,actor:t.actor,note:t.note})}function q(t,e,r,o){return C({body:t,intentId:e,intentKey:r,meta:{origin:o}})}function C(t){if(t===null||typeof t!="object")return t;for(let e of Object.getOwnPropertyNames(t)){let r=t[e];r!==null&&typeof r=="object"&&C(r)}return Object.freeze(t)}function d(t){return Object.freeze(t)}var g=class{constructor(e,r={}){this.store=e;this.options=r}createProposal(e){return d({proposalId:e.proposalId??P(),baseWorld:e.baseWorld,branchId:e.branchId,actorId:e.actorId,authorityId:e.authorityId,intent:d({...e.intent}),status:"submitted",executionKey:e.executionKey,submittedAt:e.submittedAt,epoch:e.epoch})}beginEvaluating(e){return this.transitionProposal(e,"evaluating")}beginExecution(e){if(!e.decisionId)throw new Error("GOV-EXEC-1 violation: approved proposal requires decisionId before execution can begin");return this.transitionProposal(e,"executing")}failExecution(e,r,o){return this.transitionProposal(e,"failed",{completedAt:r,...o!==void 0?{resultWorld:o}:{}})}async prepareAuthorityResult(e,r,o){if(e.status!=="submitted"&&e.status!=="evaluating")throw new Error(`GOV-TRANS-1 violation: authority result requires ingress proposal, received ${e.status}`);let n=await this.resolveBranchInfo(e.branchId),i=o.currentEpoch??n?.epoch??e.epoch,a=o.currentBranchHead??n?.head??e.baseWorld;if(this.shouldDiscardAuthorityResult(e,i))return{proposal:this.prepareSupersede(e,"head_advance"),discarded:!0};if(r.kind==="approved"){if(await this.assertBranchGateAvailable(e),a!==e.baseWorld)return{proposal:this.prepareSupersede(e,"head_advance"),discarded:!0};let p=d({decisionId:o.decisionId??u(),proposalId:e.proposalId,authorityId:e.authorityId,decision:d({kind:"approved"}),decidedAt:o.decidedAt});return{proposal:this.transitionProposal(e,"approved",{decisionId:p.decisionId,decidedAt:p.decidedAt,approvedScope:r.approvedScope}),decisionRecord:p,discarded:!1}}let s=d({decisionId:o.decisionId??u(),proposalId:e.proposalId,authorityId:e.authorityId,decision:d({kind:"rejected",...r.reason?{reason:r.reason}:{}}),decidedAt:o.decidedAt});return{proposal:this.transitionProposal(e,"rejected",{decisionId:s.decisionId,decidedAt:s.decidedAt}),decisionRecord:s,discarded:!1}}prepareSupersede(e,r){return this.transitionProposal(e,"superseded",{supersededReason:r})}async invalidateStaleIngress(e,r){let o=await this.resolveBranchInfo(e),n=r??o?.epoch;if(n==null)throw new Error(`Cannot invalidate stale ingress without branch epoch for ${e}`);return(await this.store.getProposalsByBranch(e)).filter(i=>A(i.status)&&i.epoch<n).map(i=>this.prepareSupersede(i,"head_advance"))}shouldDiscardAuthorityResult(e,r){return e.epoch<r}deriveOutcome(e){return e.system.lastError!=null||e.system.pendingRequirements.length>0?"failed":"completed"}async finalize(e,r,o){if(e.status!=="executing")throw new Error(`GOV-SEAL-6 violation: finalize() requires executing proposal, received ${e.status}`);if(!e.decisionId)throw new Error("GOV-SEAL-6 violation: executing proposal is missing decisionId");let n=await this.store.getDecisionRecord(e.decisionId);if(!n)throw new Error(`GOV-SEAL-6 violation: decision record ${e.decisionId} not found`);let i=this.deriveOutcome(r.terminalSnapshot);if(i!==r.terminalStatus)throw new Error(`GOV-SEAL-1 violation: deriveOutcome=${i} but lineageCommit.terminalStatus=${r.terminalStatus}`);let a=this.transitionProposal(e,i,{resultWorld:r.worldId,completedAt:o});return d({proposal:a,decisionRecord:n})}createProposalSubmittedEvent(e,r=Date.now()){return d({type:"proposal:submitted",timestamp:r,proposalId:e.proposalId,actorId:e.actorId,baseWorld:e.baseWorld,branchId:e.branchId,intent:d({type:e.intent.type,intentId:e.intent.intentId,...e.intent.input!==void 0?{input:e.intent.input}:{}}),executionKey:e.executionKey,epoch:e.epoch})}createProposalEvaluatingEvent(e,r=Date.now()){return d({type:"proposal:evaluating",timestamp:r,proposalId:e.proposalId})}createProposalDecidedEvent(e,r,o=Date.now()){return d({type:"proposal:decided",timestamp:o,proposalId:e.proposalId,decisionId:r.decisionId,decision:r.decision.kind,...r.decision.kind==="rejected"&&r.decision.reason?{reason:r.decision.reason}:{}})}createProposalSupersededEvent(e,r,o=Date.now()){if(e.status!=="superseded"||!e.supersededReason)throw new Error("GOV-EPOCH-5 violation: superseded event requires proposal.status='superseded' with supersededReason");return d({type:"proposal:superseded",timestamp:o,proposalId:e.proposalId,currentEpoch:r,proposalEpoch:e.epoch,reason:e.supersededReason})}createExecutionCompletedEvent(e,r=Date.now()){if(!e.resultWorld)throw new Error("GOV-EVT-6 violation: execution:completed requires proposal.resultWorld");return d({type:"execution:completed",timestamp:r,proposalId:e.proposalId,executionKey:e.executionKey,resultWorld:e.resultWorld})}createExecutionFailedEvent(e,r,o=Date.now()){if(!e.resultWorld)throw new Error("GOV-EVT-7 violation: execution:failed requires proposal.resultWorld");return d({type:"execution:failed",timestamp:o,proposalId:e.proposalId,executionKey:e.executionKey,resultWorld:e.resultWorld,error:d({summary:r.summary,...r.currentError!==void 0?{currentError:r.currentError}:{},...r.pendingRequirements!==void 0?{pendingRequirements:r.pendingRequirements}:{}})})}createWorldCreatedEvent(e,r,o,n,i=Date.now()){return d({type:"world:created",timestamp:i,world:e,from:o,proposalId:r,outcome:n})}createWorldForkedEvent(e,r,o=Date.now()){return d({type:"world:forked",timestamp:o,branchId:e,forkPoint:r})}async resolveBranchInfo(e){return this.options.lineageService?.getBranch(e)??null}async assertBranchGateAvailable(e){let r=await this.store.getExecutionStageProposal(e.branchId);if(r&&r.proposalId!==e.proposalId)throw new Error(`GOV-BRANCH-GATE-1 violation: branch ${e.branchId} already occupied by ${r.proposalId}`)}transitionProposal(e,r,o={}){if(!x(e.status,r))throw new Error(`GOV-TRANS-1 violation: invalid transition ${e.status} -> ${r}; valid targets are ${S(e.status).join(", ")}`);if(r==="superseded"){if(o.decisionId!=null)throw new Error("GOV-TRANS-3 violation: superseded transition must not create DecisionRecord");if(!o.supersededReason)throw new Error("GOV-STAGE-7 violation: superseded proposal must record supersededReason")}if(w(e.status,r)&&o.decisionId==null)throw new Error(`GOV-TRANS-2 violation: transition ${e.status} -> ${r} requires decisionId`);if(r!=="superseded"&&o.supersededReason!=null)throw new Error("GOV-TRANS-4 violation: supersededReason is only valid on superseded proposals");if(c(e.status)&&r==="superseded")throw new Error("GOV-STAGE-4 violation: execution-stage proposals must not be superseded");return d({...e,status:r,...o.decisionId!==void 0?{decisionId:o.decisionId}:{},...o.decidedAt!==void 0?{decidedAt:o.decidedAt}:{},...o.completedAt!==void 0?{completedAt:o.completedAt}:{},...o.resultWorld!==void 0?{resultWorld:o.resultWorld}:{},...o.approvedScope!==void 0?{approvedScope:o.approvedScope}:{},...o.supersededReason!==void 0?{supersededReason:o.supersededReason}:{},...r!=="superseded"?{supersededReason:void 0}:{}})}};function Se(t,e){return new g(t,e)}export{P as a,u as b,G as c,M as d,E as e,z as f,W as g,j as h,O as i,Q as j,A as k,c as l,X as m,x as n,S as o,w as p,y as q,Z as r,m as s,R as t,h as u,T as v,v as w,k as x,I as y,H as z,f as A,ye as B,B as C,fe as D,N as E,Ee as F,q as G,g as H,Se as I};
|