@guyghost/swarm-dao-core 0.3.0 → 0.4.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/dist/commands/index.d.ts +2 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +2 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/registry.d.ts +46 -0
- package/dist/commands/registry.d.ts.map +1 -0
- package/dist/commands/registry.js +352 -0
- package/dist/commands/registry.js.map +1 -0
- package/dist/control/gates.d.ts.map +1 -1
- package/dist/control/gates.js +17 -0
- package/dist/control/gates.js.map +1 -1
- package/dist/delivery/dependencies.d.ts.map +1 -1
- package/dist/delivery/dependencies.js +15 -7
- package/dist/delivery/dependencies.js.map +1 -1
- package/dist/delivery/execution.d.ts.map +1 -1
- package/dist/delivery/execution.js +7 -5
- package/dist/delivery/execution.js.map +1 -1
- package/dist/governance/agents.d.ts +2 -0
- package/dist/governance/agents.d.ts.map +1 -1
- package/dist/governance/agents.js +49 -12
- package/dist/governance/agents.js.map +1 -1
- package/dist/governance/delegation.machine.d.ts +316 -0
- package/dist/governance/delegation.machine.d.ts.map +1 -0
- package/dist/governance/delegation.machine.js +387 -0
- package/dist/governance/delegation.machine.js.map +1 -0
- package/dist/governance/delegation.utils.d.ts +55 -0
- package/dist/governance/delegation.utils.d.ts.map +1 -0
- package/dist/governance/delegation.utils.js +157 -0
- package/dist/governance/delegation.utils.js.map +1 -0
- package/dist/governance/index.d.ts +2 -0
- package/dist/governance/index.d.ts.map +1 -1
- package/dist/governance/index.js +2 -0
- package/dist/governance/index.js.map +1 -1
- package/dist/governance/lifecycle.d.ts +0 -6
- package/dist/governance/lifecycle.d.ts.map +1 -1
- package/dist/governance/lifecycle.js +7 -31
- package/dist/governance/lifecycle.js.map +1 -1
- package/dist/governance/proposal.machine.d.ts +65 -81
- package/dist/governance/proposal.machine.d.ts.map +1 -1
- package/dist/governance/proposal.machine.js +160 -357
- package/dist/governance/proposal.machine.js.map +1 -1
- package/dist/governance/proposal.utils.d.ts +19 -165
- package/dist/governance/proposal.utils.d.ts.map +1 -1
- package/dist/governance/proposal.utils.js +49 -119
- package/dist/governance/proposal.utils.js.map +1 -1
- package/dist/governance/scoring.d.ts.map +1 -1
- package/dist/governance/scoring.js +36 -16
- package/dist/governance/scoring.js.map +1 -1
- package/dist/host-tools/handlers.d.ts.map +1 -1
- package/dist/host-tools/handlers.js +24 -16
- package/dist/host-tools/handlers.js.map +1 -1
- package/dist/host-tools/messages.d.ts +10 -4
- package/dist/host-tools/messages.d.ts.map +1 -1
- package/dist/host-tools/messages.js +14 -17
- package/dist/host-tools/messages.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/integrations/http.d.ts +12 -1
- package/dist/integrations/http.d.ts.map +1 -1
- package/dist/integrations/http.js +114 -17
- package/dist/integrations/http.js.map +1 -1
- package/dist/intelligence/delegation.d.ts +40 -0
- package/dist/intelligence/delegation.d.ts.map +1 -0
- package/dist/intelligence/delegation.js +162 -0
- package/dist/intelligence/delegation.js.map +1 -0
- package/dist/intelligence/index.d.ts +1 -0
- package/dist/intelligence/index.d.ts.map +1 -1
- package/dist/intelligence/index.js +1 -0
- package/dist/intelligence/index.js.map +1 -1
- package/dist/intelligence/model.d.ts +28 -2
- package/dist/intelligence/model.d.ts.map +1 -1
- package/dist/intelligence/model.js +36 -3
- package/dist/intelligence/model.js.map +1 -1
- package/dist/intelligence/swarm.d.ts +13 -2
- package/dist/intelligence/swarm.d.ts.map +1 -1
- package/dist/intelligence/swarm.js +97 -50
- package/dist/intelligence/swarm.js.map +1 -1
- package/dist/persistence.d.ts +2 -6
- package/dist/persistence.d.ts.map +1 -1
- package/dist/persistence.js +109 -123
- package/dist/persistence.js.map +1 -1
- package/dist/types/index.d.ts +70 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +12 -0
- package/dist/types/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,166 +1,20 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
} | {
|
|
21
|
-
type: "APPROVE";
|
|
22
|
-
} | {
|
|
23
|
-
type: "REJECT";
|
|
24
|
-
} | {
|
|
25
|
-
type: "REQUEST_SPEC";
|
|
26
|
-
} | {
|
|
27
|
-
type: "REVIEW_SPEC";
|
|
28
|
-
} | {
|
|
29
|
-
type: "APPROVE_SPEC";
|
|
30
|
-
} | {
|
|
31
|
-
type: "EXECUTION_GATE_PASS";
|
|
32
|
-
} | {
|
|
33
|
-
type: "EXECUTION_GATE_FAIL";
|
|
34
|
-
} | {
|
|
35
|
-
type: "EXECUTE";
|
|
36
|
-
} | {
|
|
37
|
-
type: "EXECUTION_SUCCESS";
|
|
38
|
-
} | {
|
|
39
|
-
type: "EXECUTION_FAILED";
|
|
40
|
-
} | {
|
|
41
|
-
type: "POSTMORTEM";
|
|
42
|
-
} | {
|
|
43
|
-
type: "RETRY";
|
|
44
|
-
} | {
|
|
45
|
-
type: "DISCARD";
|
|
46
|
-
} | {
|
|
47
|
-
type: "ERROR";
|
|
48
|
-
message: string;
|
|
49
|
-
}, {}, never, never, never, never, "intake" | "qualification" | "analysis" | "critique" | "scoring" | "council" | "postmortem" | "rejected" | "draft" | "voting" | "specDraft" | "specReview" | "executionGate" | "executing" | "executionError" | "completed", string, ProposalMachineInput, import("xstate").NonReducibleUnknown, import("xstate").EventObject, import("xstate").MetaObject, {
|
|
50
|
-
id: "proposalLifecycle";
|
|
51
|
-
states: {
|
|
52
|
-
readonly draft: {};
|
|
53
|
-
readonly intake: {};
|
|
54
|
-
readonly qualification: {};
|
|
55
|
-
readonly analysis: {};
|
|
56
|
-
readonly critique: {};
|
|
57
|
-
readonly scoring: {};
|
|
58
|
-
readonly council: {};
|
|
59
|
-
readonly voting: {};
|
|
60
|
-
readonly specDraft: {};
|
|
61
|
-
readonly specReview: {};
|
|
62
|
-
readonly executionGate: {};
|
|
63
|
-
readonly executing: {};
|
|
64
|
-
readonly executionError: {};
|
|
65
|
-
readonly postmortem: {};
|
|
66
|
-
readonly rejected: {};
|
|
67
|
-
readonly completed: {};
|
|
68
|
-
};
|
|
69
|
-
}>>;
|
|
70
|
-
/**
|
|
71
|
-
* Moves a proposal through its states sequentially
|
|
72
|
-
*/
|
|
73
|
-
export declare function sendProposalEvent(actor: ReturnType<typeof createProposalActor>, event: ProposalEvent): import("xstate").MachineSnapshot<ProposalContext, {
|
|
74
|
-
type: "SUBMIT";
|
|
75
|
-
} | {
|
|
76
|
-
type: "QUALIFY";
|
|
77
|
-
} | {
|
|
78
|
-
type: "ANALYZE";
|
|
79
|
-
} | {
|
|
80
|
-
type: "CRITIQUE";
|
|
81
|
-
} | {
|
|
82
|
-
type: "SCORE";
|
|
83
|
-
} | {
|
|
84
|
-
type: "SEND_TO_COUNCIL";
|
|
85
|
-
} | {
|
|
86
|
-
type: "VOTE";
|
|
87
|
-
} | {
|
|
88
|
-
type: "APPROVE";
|
|
89
|
-
} | {
|
|
90
|
-
type: "REJECT";
|
|
91
|
-
} | {
|
|
92
|
-
type: "REQUEST_SPEC";
|
|
93
|
-
} | {
|
|
94
|
-
type: "REVIEW_SPEC";
|
|
95
|
-
} | {
|
|
96
|
-
type: "APPROVE_SPEC";
|
|
97
|
-
} | {
|
|
98
|
-
type: "EXECUTION_GATE_PASS";
|
|
99
|
-
} | {
|
|
100
|
-
type: "EXECUTION_GATE_FAIL";
|
|
101
|
-
} | {
|
|
102
|
-
type: "EXECUTE";
|
|
103
|
-
} | {
|
|
104
|
-
type: "EXECUTION_SUCCESS";
|
|
105
|
-
} | {
|
|
106
|
-
type: "EXECUTION_FAILED";
|
|
107
|
-
} | {
|
|
108
|
-
type: "POSTMORTEM";
|
|
109
|
-
} | {
|
|
110
|
-
type: "RETRY";
|
|
111
|
-
} | {
|
|
112
|
-
type: "DISCARD";
|
|
113
|
-
} | {
|
|
114
|
-
type: "ERROR";
|
|
115
|
-
message: string;
|
|
116
|
-
}, {}, "intake" | "qualification" | "analysis" | "critique" | "scoring" | "council" | "postmortem" | "rejected" | "draft" | "voting" | "specDraft" | "specReview" | "executionGate" | "executing" | "executionError" | "completed", string, import("xstate").NonReducibleUnknown, import("xstate").MetaObject, {
|
|
117
|
-
id: "proposalLifecycle";
|
|
118
|
-
states: {
|
|
119
|
-
readonly draft: {};
|
|
120
|
-
readonly intake: {};
|
|
121
|
-
readonly qualification: {};
|
|
122
|
-
readonly analysis: {};
|
|
123
|
-
readonly critique: {};
|
|
124
|
-
readonly scoring: {};
|
|
125
|
-
readonly council: {};
|
|
126
|
-
readonly voting: {};
|
|
127
|
-
readonly specDraft: {};
|
|
128
|
-
readonly specReview: {};
|
|
129
|
-
readonly executionGate: {};
|
|
130
|
-
readonly executing: {};
|
|
131
|
-
readonly executionError: {};
|
|
132
|
-
readonly postmortem: {};
|
|
133
|
-
readonly rejected: {};
|
|
134
|
-
readonly completed: {};
|
|
135
|
-
};
|
|
136
|
-
}>;
|
|
137
|
-
/**
|
|
138
|
-
* Returns the machine's current context
|
|
139
|
-
*/
|
|
140
|
-
export declare function getProposalContext(actor: ReturnType<typeof createProposalActor>): ProposalContext;
|
|
141
|
-
/**
|
|
142
|
-
* Returns the machine's current state
|
|
143
|
-
*/
|
|
144
|
-
export declare function getProposalState(actor: ReturnType<typeof createProposalActor>): "intake" | "qualification" | "analysis" | "critique" | "scoring" | "council" | "postmortem" | "rejected" | "draft" | "voting" | "specDraft" | "specReview" | "executionGate" | "executing" | "executionError" | "completed";
|
|
145
|
-
/**
|
|
146
|
-
* Checks whether the proposal can take a given transition
|
|
147
|
-
*/
|
|
148
|
-
export declare function canSendProposalEvent(actor: ReturnType<typeof createProposalActor>, eventType: string): boolean;
|
|
149
|
-
/**
|
|
150
|
-
* Returns all possible transitions from the current state
|
|
151
|
-
*/
|
|
152
|
-
export declare function getAvailableProposalEvents(actor: ReturnType<typeof createProposalActor>): string[];
|
|
153
|
-
/**
|
|
154
|
-
* Helper for auto-progressing a proposal through the pipeline
|
|
155
|
-
* Uses linear progression events
|
|
156
|
-
*/
|
|
157
|
-
export declare function progressProposal(actor: ReturnType<typeof createProposalActor>): string | null;
|
|
158
|
-
/**
|
|
159
|
-
* Creates a helper to trigger rejection events easily
|
|
160
|
-
*/
|
|
161
|
-
export declare function rejectProposal(actor: ReturnType<typeof createProposalActor>): "intake" | "qualification" | "analysis" | "critique" | "scoring" | "council" | "postmortem" | "rejected" | "draft" | "voting" | "specDraft" | "specReview" | "executionGate" | "executing" | "executionError" | "completed";
|
|
162
|
-
/**
|
|
163
|
-
* Listener for observing state changes
|
|
164
|
-
*/
|
|
165
|
-
export declare function onProposalStateChange(actor: ReturnType<typeof createProposalActor>, callback: (state: string, context: ProposalContext) => void): () => void;
|
|
1
|
+
import type { Proposal, ProposalStatus } from "../types/index.js";
|
|
2
|
+
import { type ProposalEvent } from "./proposal.machine.js";
|
|
3
|
+
export type DispatchResult = {
|
|
4
|
+
ok: true;
|
|
5
|
+
status: ProposalStatus;
|
|
6
|
+
} | {
|
|
7
|
+
ok: false;
|
|
8
|
+
error: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Apply a lifecycle event to a proposal. Enforces the machine's
|
|
12
|
+
* topology AND its guards. On success, `proposal.status` (and
|
|
13
|
+
* `proposal.resolvedAt` for terminal states) is updated in place.
|
|
14
|
+
*
|
|
15
|
+
* Returns `{ ok: false, error }` when the event is not permitted
|
|
16
|
+
* from the current status — the caller must surface that error and
|
|
17
|
+
* MUST NOT mutate the status itself.
|
|
18
|
+
*/
|
|
19
|
+
export declare function dispatchProposalEvent(proposal: Proposal, event: ProposalEvent): DispatchResult;
|
|
166
20
|
//# sourceMappingURL=proposal.utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proposal.utils.d.ts","sourceRoot":"","sources":["../../src/governance/proposal.utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"proposal.utils.d.ts","sourceRoot":"","sources":["../../src/governance/proposal.utils.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAGL,KAAK,aAAa,EAEnB,MAAM,uBAAuB,CAAC;AAE/B,MAAM,MAAM,cAAc,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,cAAc,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjG;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,aAAa,GAAG,cAAc,CAsC9F"}
|
|
@@ -1,126 +1,56 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// Swarm DAO Core — Proposal Dispatch Service
|
|
3
|
+
// ------------------------------------------------------------
|
|
4
|
+
// The only sanctioned way to mutate `proposal.status`. Every
|
|
5
|
+
// runtime path (host-tools, execution, pi/opencode adapters) goes
|
|
6
|
+
// through `dispatchProposalEvent`: it rehydrates an actor at the
|
|
7
|
+
// proposal's persisted status, asks the machine whether the event
|
|
8
|
+
// is permitted (guards included), and only then writes the new
|
|
9
|
+
// status back to the proposal. There is no other status writer.
|
|
10
|
+
// ============================================================
|
|
1
11
|
import { createActor } from "xstate";
|
|
2
|
-
import {
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
import { createProposalMachine, isProposalFinal, } from "./proposal.machine.js";
|
|
13
|
+
/**
|
|
14
|
+
* Apply a lifecycle event to a proposal. Enforces the machine's
|
|
15
|
+
* topology AND its guards. On success, `proposal.status` (and
|
|
16
|
+
* `proposal.resolvedAt` for terminal states) is updated in place.
|
|
17
|
+
*
|
|
18
|
+
* Returns `{ ok: false, error }` when the event is not permitted
|
|
19
|
+
* from the current status — the caller must surface that error and
|
|
20
|
+
* MUST NOT mutate the status itself.
|
|
21
|
+
*/
|
|
22
|
+
export function dispatchProposalEvent(proposal, event) {
|
|
23
|
+
// Terminal states are final: no event may leave them. This guard
|
|
24
|
+
// makes the invariant explicit rather than relying on the actor's
|
|
25
|
+
// "done" status, so the model stays correct regardless of how the
|
|
26
|
+
// XState runtime treats root-level global transitions once done.
|
|
27
|
+
if (isProposalFinal(proposal.status)) {
|
|
28
|
+
return {
|
|
29
|
+
ok: false,
|
|
30
|
+
error: `Proposal is in terminal status "${proposal.status}"; no transitions are permitted.`,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const machine = createProposalMachine(proposal.status);
|
|
34
|
+
const actor = createActor(machine, {
|
|
35
|
+
input: {
|
|
36
|
+
proposal,
|
|
37
|
+
lastTransitionTime: new Date().toISOString(),
|
|
38
|
+
},
|
|
17
39
|
});
|
|
18
40
|
actor.start();
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
actor.send(event);
|
|
26
|
-
return actor.getSnapshot();
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Returns the machine's current context
|
|
30
|
-
*/
|
|
31
|
-
export function getProposalContext(actor) {
|
|
32
|
-
return actor.getSnapshot().context;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Returns the machine's current state
|
|
36
|
-
*/
|
|
37
|
-
export function getProposalState(actor) {
|
|
38
|
-
return actor.getSnapshot().value;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Checks whether the proposal can take a given transition
|
|
42
|
-
*/
|
|
43
|
-
export function canSendProposalEvent(actor, eventType) {
|
|
44
|
-
try {
|
|
45
|
-
if (eventType === "ERROR") {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
const state = actor.getSnapshot();
|
|
49
|
-
return state.can({ type: eventType });
|
|
41
|
+
const before = actor.getSnapshot();
|
|
42
|
+
if (!before.can(event)) {
|
|
43
|
+
return {
|
|
44
|
+
ok: false,
|
|
45
|
+
error: `Event "${event.type}" is not permitted from status "${proposal.status}".`,
|
|
46
|
+
};
|
|
50
47
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
* Returns all possible transitions from the current state
|
|
57
|
-
*/
|
|
58
|
-
export function getAvailableProposalEvents(actor) {
|
|
59
|
-
const eventTypes = [
|
|
60
|
-
"SUBMIT",
|
|
61
|
-
"QUALIFY",
|
|
62
|
-
"ANALYZE",
|
|
63
|
-
"CRITIQUE",
|
|
64
|
-
"SCORE",
|
|
65
|
-
"SEND_TO_COUNCIL",
|
|
66
|
-
"VOTE",
|
|
67
|
-
"APPROVE",
|
|
68
|
-
"REJECT",
|
|
69
|
-
"REQUEST_SPEC",
|
|
70
|
-
"REVIEW_SPEC",
|
|
71
|
-
"APPROVE_SPEC",
|
|
72
|
-
"EXECUTION_GATE_PASS",
|
|
73
|
-
"EXECUTION_GATE_FAIL",
|
|
74
|
-
"EXECUTE",
|
|
75
|
-
"EXECUTION_SUCCESS",
|
|
76
|
-
"EXECUTION_FAILED",
|
|
77
|
-
"POSTMORTEM",
|
|
78
|
-
"RETRY",
|
|
79
|
-
"DISCARD",
|
|
80
|
-
];
|
|
81
|
-
return eventTypes.filter((eventType) => canSendProposalEvent(actor, eventType));
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Helper for auto-progressing a proposal through the pipeline
|
|
85
|
-
* Uses linear progression events
|
|
86
|
-
*/
|
|
87
|
-
export function progressProposal(actor) {
|
|
88
|
-
const current = actor.getSnapshot().value;
|
|
89
|
-
const progressMap = {
|
|
90
|
-
draft: "SUBMIT",
|
|
91
|
-
intake: "QUALIFY",
|
|
92
|
-
qualification: "ANALYZE",
|
|
93
|
-
analysis: "CRITIQUE",
|
|
94
|
-
critique: "SCORE",
|
|
95
|
-
scoring: "SEND_TO_COUNCIL",
|
|
96
|
-
council: "VOTE",
|
|
97
|
-
voting: "APPROVE",
|
|
98
|
-
specDraft: "REQUEST_SPEC",
|
|
99
|
-
specReview: "APPROVE_SPEC",
|
|
100
|
-
executionGate: "EXECUTION_GATE_PASS",
|
|
101
|
-
};
|
|
102
|
-
const nextEventType = progressMap[String(current)];
|
|
103
|
-
if (nextEventType && canSendProposalEvent(actor, nextEventType)) {
|
|
104
|
-
const event = { type: nextEventType };
|
|
105
|
-
sendProposalEvent(actor, event);
|
|
106
|
-
return nextEventType;
|
|
48
|
+
actor.send(event);
|
|
49
|
+
const status = actor.getSnapshot().value;
|
|
50
|
+
proposal.status = status;
|
|
51
|
+
if (isProposalFinal(status) && !proposal.resolvedAt) {
|
|
52
|
+
proposal.resolvedAt = new Date().toISOString();
|
|
107
53
|
}
|
|
108
|
-
return
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Creates a helper to trigger rejection events easily
|
|
112
|
-
*/
|
|
113
|
-
export function rejectProposal(actor) {
|
|
114
|
-
sendProposalEvent(actor, { type: "REJECT" });
|
|
115
|
-
return getProposalState(actor);
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Listener for observing state changes
|
|
119
|
-
*/
|
|
120
|
-
export function onProposalStateChange(actor, callback) {
|
|
121
|
-
const subscription = actor.subscribe((snapshot) => {
|
|
122
|
-
callback(String(snapshot.value), snapshot.context);
|
|
123
|
-
});
|
|
124
|
-
return () => subscription.unsubscribe();
|
|
54
|
+
return { ok: true, status };
|
|
125
55
|
}
|
|
126
56
|
//# sourceMappingURL=proposal.utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proposal.utils.js","sourceRoot":"","sources":["../../src/governance/proposal.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,
|
|
1
|
+
{"version":3,"file":"proposal.utils.js","sourceRoot":"","sources":["../../src/governance/proposal.utils.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,6CAA6C;AAC7C,+DAA+D;AAC/D,6DAA6D;AAC7D,kEAAkE;AAClE,iEAAiE;AACjE,kEAAkE;AAClE,+DAA+D;AAC/D,gEAAgE;AAChE,+DAA+D;AAE/D,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,EACL,qBAAqB,EACrB,eAAe,GAGhB,MAAM,uBAAuB,CAAC;AAI/B;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CAAC,QAAkB,EAAE,KAAoB;IAC5E,iEAAiE;IACjE,kEAAkE;IAClE,kEAAkE;IAClE,iEAAiE;IACjE,IAAI,eAAe,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACrC,OAAO;YACL,EAAE,EAAE,KAAK;YACT,KAAK,EAAE,mCAAmC,QAAQ,CAAC,MAAM,kCAAkC;SAC5F,CAAC;IACJ,CAAC;IAED,MAAM,OAAO,GAAG,qBAAqB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACvD,MAAM,KAAK,GAAG,WAAW,CAAC,OAAO,EAAE;QACjC,KAAK,EAAE;YACL,QAAQ;YACR,kBAAkB,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACd;KACjC,CAAC,CAAC;IACH,KAAK,CAAC,KAAK,EAAE,CAAC;IAEd,MAAM,MAAM,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;IACnC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO;YACL,EAAE,EAAE,KAAK;YACT,KAAK,EAAE,UAAU,KAAK,CAAC,IAAI,mCAAmC,QAAQ,CAAC,MAAM,IAAI;SAClF,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAClB,MAAM,MAAM,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC,KAAuB,CAAC;IAE3D,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,IAAI,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;QACpD,QAAQ,CAAC,UAAU,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACjD,CAAC;IAED,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC9B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scoring.d.ts","sourceRoot":"","sources":["../../src/governance/scoring.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,cAAc,EAAE,SAAS,EAAY,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"scoring.d.ts","sourceRoot":"","sources":["../../src/governance/scoring.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,cAAc,EAAE,SAAS,EAAY,MAAM,mBAAmB,CAAC;AAkBrG,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAYzE;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,cAAc,CAmE9E;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,CAgBlE;AAID,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,CAS/G;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAYvE;AAED,wBAAgB,UAAU,CACxB,SAAS,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,SAAS,CAAA;CAAE,EAAE,GACjD;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,CAWtD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAExD"}
|
|
@@ -4,19 +4,27 @@
|
|
|
4
4
|
import { RISK_ZONE_LABELS, SCORING_WEIGHTS } from "../types/index.js";
|
|
5
5
|
// ── Composite Score ──────────────────────────────────────────
|
|
6
6
|
const _SCORE_PATTERN = /##\s*Composite Score Inputs \(0-10\)\s*\n([\s\S]*?)(?=\n##|$)/i;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
// Single combined alternation scanned once via matchAll, replacing the former
|
|
8
|
+
// per-axis loop (5 full regex scans of the content). The separator `[:\s]+` is
|
|
9
|
+
// preserved verbatim so `key: n`, `key:n`, and `key n` keep matching exactly.
|
|
10
|
+
const SCORE_TOKEN_RE = /(userImpact|businessImpact|effort|securityRisk|confidence)[:\s]+(\d+(?:\.\d+)?)/gi;
|
|
11
|
+
const AXIS_KEY_BY_LOWER = {
|
|
12
|
+
userimpact: "userImpact",
|
|
13
|
+
businessimpact: "businessImpact",
|
|
14
|
+
effort: "effort",
|
|
15
|
+
securityrisk: "securityRisk",
|
|
16
|
+
confidence: "confidence",
|
|
13
17
|
};
|
|
14
18
|
export function parseScoresFromOutput(content) {
|
|
15
19
|
const scores = {};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
if (!content)
|
|
21
|
+
return scores;
|
|
22
|
+
for (const match of content.matchAll(SCORE_TOKEN_RE)) {
|
|
23
|
+
const axis = AXIS_KEY_BY_LOWER[(match[1] ?? "").toLowerCase()];
|
|
24
|
+
// First occurrence wins, mirroring the previous non-global per-axis `.match`,
|
|
25
|
+
// which returned only the first match per axis.
|
|
26
|
+
if (axis !== undefined && !(axis in scores)) {
|
|
27
|
+
scores[axis] = Math.min(10, Math.max(0, parseFloat(match[2] ?? "0")));
|
|
20
28
|
}
|
|
21
29
|
}
|
|
22
30
|
return scores;
|
|
@@ -38,13 +46,25 @@ export function calculateCompositeScore(outputs) {
|
|
|
38
46
|
breakdown: "No valid scores provided",
|
|
39
47
|
};
|
|
40
48
|
}
|
|
41
|
-
|
|
49
|
+
// Single reduce accumulating per-axis sums, then one division each —
|
|
50
|
+
// replaces the former five separate `reduce` passes over validScores.
|
|
51
|
+
// Addition order is identical, so floating-point results are bit-for-bit
|
|
52
|
+
// unchanged.
|
|
53
|
+
const sums = validScores.reduce((acc, s) => {
|
|
54
|
+
acc.userImpact += s.userImpact || 0;
|
|
55
|
+
acc.businessImpact += s.businessImpact || 0;
|
|
56
|
+
acc.effort += s.effort || 0;
|
|
57
|
+
acc.securityRisk += s.securityRisk || 0;
|
|
58
|
+
acc.confidence += s.confidence || 0;
|
|
59
|
+
return acc;
|
|
60
|
+
}, { userImpact: 0, businessImpact: 0, effort: 0, securityRisk: 0, confidence: 0 });
|
|
61
|
+
const n = validScores.length;
|
|
42
62
|
const axes = {
|
|
43
|
-
userImpact:
|
|
44
|
-
businessImpact:
|
|
45
|
-
effort:
|
|
46
|
-
securityRisk:
|
|
47
|
-
confidence:
|
|
63
|
+
userImpact: sums.userImpact / n,
|
|
64
|
+
businessImpact: sums.businessImpact / n,
|
|
65
|
+
effort: sums.effort / n,
|
|
66
|
+
securityRisk: sums.securityRisk / n,
|
|
67
|
+
confidence: sums.confidence / n,
|
|
48
68
|
};
|
|
49
69
|
// Invert effort and securityRisk (lower is better)
|
|
50
70
|
const normalizedEffort = 10 - axes.effort;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scoring.js","sourceRoot":"","sources":["../../src/governance/scoring.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,4CAA4C;AAC5C,+DAA+D;AAG/D,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEtE,gEAAgE;AAEhE,MAAM,cAAc,GAAG,gEAAgE,CAAC;AACxF,MAAM,
|
|
1
|
+
{"version":3,"file":"scoring.js","sourceRoot":"","sources":["../../src/governance/scoring.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,4CAA4C;AAC5C,+DAA+D;AAG/D,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEtE,gEAAgE;AAEhE,MAAM,cAAc,GAAG,gEAAgE,CAAC;AACxF,8EAA8E;AAC9E,+EAA+E;AAC/E,8EAA8E;AAC9E,MAAM,cAAc,GAAG,mFAAmF,CAAC;AAC3G,MAAM,iBAAiB,GAA8C;IACnE,UAAU,EAAE,YAAY;IACxB,cAAc,EAAE,gBAAgB;IAChC,MAAM,EAAE,QAAQ;IAChB,YAAY,EAAE,cAAc;IAC5B,UAAU,EAAE,YAAY;CACzB,CAAC;AAEF,MAAM,UAAU,qBAAqB,CAAC,OAAe;IACnD,MAAM,MAAM,GAAuB,EAAE,CAAC;IACtC,IAAI,CAAC,OAAO;QAAE,OAAO,MAAM,CAAC;IAC5B,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;QACrD,MAAM,IAAI,GAAG,iBAAiB,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;QAC/D,8EAA8E;QAC9E,gDAAgD;QAChD,IAAI,IAAI,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AAS,CAAC,OAAO,CAAC,CAAC,CAAC,YAAY,KAAK,CAAC,KAAK,cAAc,KAAK,CAAC,MAAM,kBAAkB,KAAK,CAAC,UAAU,eAAe,KAAK,CAAC,MAAM,GAAG,CAAC;AACxK,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../src/host-tools/handlers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../src/host-tools/handlers.ts"],"names":[],"mappings":"AAyCA,OAAO,KAAK,EAAe,gBAAgB,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAClG,OAAO,EAAwB,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAGvD,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,QAAQ,CAAC;AACjD,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,aAAa,CAAC;AAE1D,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,WAAW,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,eAAe,EAAE,eAAe,CAAC;IACjC,kEAAkE;IAClE,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,eAAe,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IAC3C,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,sBAAsB,CAAC,EAAE,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;CACjF;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,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AAM,CAAC;IACpB,aAAa,EAAE,gBAAgB,CAAC,MAAM,CAAC,SAAS,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACpE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,wBAAsB,yBAAyB,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CAuDvF;AAED,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,cAAc,EACpB,IAAI,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACnD,OAAO,CAAC,MAAM,CAAC,CAYjB;AAED,wBAAsB,2BAA2B,CAAC,IAAI,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAa3G;AAED,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,cAAc,EACpB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,CAAC,CAajB;AAED,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -8,7 +8,8 @@ import { executeProposal } from "../delivery/execution.js";
|
|
|
8
8
|
import { formatPlan, generateDeliveryPlan, getPlan } from "../delivery/plans.js";
|
|
9
9
|
import { formatAgentsTable, initializeAgents, loadAgentDefinitions } from "../governance/agents.js";
|
|
10
10
|
import { validateAmendmentPayload } from "../governance/amendments.js";
|
|
11
|
-
import { classifyRiskZone
|
|
11
|
+
import { classifyRiskZone } from "../governance/lifecycle.js";
|
|
12
|
+
import { dispatchProposalEvent } from "../governance/proposal.utils.js";
|
|
12
13
|
import { calculateCompositeScore, formatCompositeScore } from "../governance/scoring.js";
|
|
13
14
|
import { formatTallyResult, parseVoteFromOutput, tallyVotes } from "../governance/voting.js";
|
|
14
15
|
import { computeHealthScore, formatHealthScore, generateDashboard } from "../health-score.js";
|
|
@@ -57,7 +58,6 @@ export async function handleDaoPropose(args) {
|
|
|
57
58
|
proposal.riskZone = classifyRiskZone(proposal);
|
|
58
59
|
await saveState();
|
|
59
60
|
await recordAudit(proposal.id, "governance", "proposal_created", "user", `Proposal "${args.title}" created`);
|
|
60
|
-
await saveState();
|
|
61
61
|
const typeLabel = PROPOSAL_TYPE_LABELS[args.type] ?? args.type;
|
|
62
62
|
return `# 📋 Proposal Created — #${proposal.id}\n\n**Title:** ${args.title}\n**Type:** ${typeLabel}\n**Zone:** ${proposal.riskZone}\n\nRun \`dao_deliberate proposalId=${proposal.id}\``;
|
|
63
63
|
}
|
|
@@ -71,9 +71,9 @@ export async function handleDaoDeliberate(ctx, proposalId) {
|
|
|
71
71
|
return `Proposal #${proposalId} not found.`;
|
|
72
72
|
if (proposal.status !== "open")
|
|
73
73
|
return `Proposal #${proposal.id} is ${proposal.status}, must be open.`;
|
|
74
|
-
const
|
|
75
|
-
if (!
|
|
76
|
-
return `Cannot deliberate: ${
|
|
74
|
+
const deliberation = dispatchProposalEvent(proposal, { type: "DELIBERATE" });
|
|
75
|
+
if (!deliberation.ok)
|
|
76
|
+
return `Cannot deliberate: ${deliberation.error}`;
|
|
77
77
|
await recordAudit(proposal.id, "governance", "deliberation_started", "system", `Deliberation on #${proposal.id}`);
|
|
78
78
|
await saveState();
|
|
79
79
|
const projectConfig = await loadConfig(state.daoRoot);
|
|
@@ -93,11 +93,13 @@ export async function handleDaoDeliberate(ctx, proposalId) {
|
|
|
93
93
|
const outputs = await dispatchSwarm(proposal, agents, ctx.adapter, state.config.maxConcurrent, modelContext, (update) => ctx.onDeliberationProgress?.(update));
|
|
94
94
|
const votes = [];
|
|
95
95
|
const persistedOutputs = [];
|
|
96
|
+
const agentById = new Map(agents.map((a) => [a.id, a]));
|
|
96
97
|
for (const output of outputs) {
|
|
97
98
|
if (output.content) {
|
|
98
|
-
const
|
|
99
|
+
const weight = agentById.get(output.agentId)?.weight ?? 1;
|
|
100
|
+
const vote = parseVoteFromOutput(output.agentId, output.agentName, weight, output.content);
|
|
99
101
|
if (vote) {
|
|
100
|
-
vote.weight =
|
|
102
|
+
vote.weight = weight;
|
|
101
103
|
votes.push(vote);
|
|
102
104
|
}
|
|
103
105
|
}
|
|
@@ -115,11 +117,11 @@ export async function handleDaoDeliberate(ctx, proposalId) {
|
|
|
115
117
|
proposal.synthesis = synthesisText;
|
|
116
118
|
await storeSynthesis(proposal.id, synthesisText);
|
|
117
119
|
if (tally.approved) {
|
|
118
|
-
|
|
120
|
+
dispatchProposalEvent(proposal, { type: "APPROVE", tally });
|
|
119
121
|
await recordAudit(proposal.id, "intelligence", "deliberation_approved", "system", `Approved: ${tally.approvalScore}%`);
|
|
120
122
|
}
|
|
121
123
|
else {
|
|
122
|
-
|
|
124
|
+
dispatchProposalEvent(proposal, { type: "REJECT" });
|
|
123
125
|
await recordAudit(proposal.id, "intelligence", "deliberation_rejected", "system", `Rejected: ${tally.approvalScore}%`);
|
|
124
126
|
}
|
|
125
127
|
await saveState();
|
|
@@ -167,11 +169,11 @@ export async function handleDaoRecordOutputs(ctx, proposalId, outputs) {
|
|
|
167
169
|
await storeSynthesis(proposal.id, synthesisText);
|
|
168
170
|
const tally = tallyVotes(proposal, state.config);
|
|
169
171
|
if (tally.approved) {
|
|
170
|
-
|
|
172
|
+
dispatchProposalEvent(proposal, { type: "APPROVE", tally });
|
|
171
173
|
await recordAudit(proposal.id, "intelligence", "deliberation_approved", "system", `Approved: ${tally.approvalScore}%`);
|
|
172
174
|
}
|
|
173
175
|
else {
|
|
174
|
-
|
|
176
|
+
dispatchProposalEvent(proposal, { type: "REJECT" });
|
|
175
177
|
await recordAudit(proposal.id, "intelligence", "deliberation_rejected", "system", `Rejected: ${tally.approvalScore}%`);
|
|
176
178
|
}
|
|
177
179
|
await saveState();
|
|
@@ -189,7 +191,7 @@ export async function handleDaoControl(ctx, proposalId) {
|
|
|
189
191
|
return `Must be approved (current: ${proposal.status})`;
|
|
190
192
|
const result = runGates(proposal, state.config);
|
|
191
193
|
if (result.allGatesPassed) {
|
|
192
|
-
|
|
194
|
+
dispatchProposalEvent(proposal, { type: "CONTROL_PASS", result });
|
|
193
195
|
await recordAudit(proposal.id, "control", "gates_passed", "system", "All gates passed");
|
|
194
196
|
if (!state.deliveryPlans[proposal.id]) {
|
|
195
197
|
const plan = generateDeliveryPlan(proposal);
|
|
@@ -198,7 +200,7 @@ export async function handleDaoControl(ctx, proposalId) {
|
|
|
198
200
|
}
|
|
199
201
|
else {
|
|
200
202
|
if (ctx.failOnGateFailure) {
|
|
201
|
-
|
|
203
|
+
dispatchProposalEvent(proposal, { type: "CONTROL_FAIL" });
|
|
202
204
|
}
|
|
203
205
|
await recordAudit(proposal.id, "control", "gates_failed", "system", `${result.blockerCount} blockers`);
|
|
204
206
|
}
|
|
@@ -215,7 +217,6 @@ export async function handleDaoExecute(proposalId) {
|
|
|
215
217
|
const result = await executeProposal(proposal);
|
|
216
218
|
await saveState();
|
|
217
219
|
await recordAudit(proposal.id, "delivery", "proposal_executed", "user", `Executed #${proposal.id}`);
|
|
218
|
-
await saveState();
|
|
219
220
|
return result.result;
|
|
220
221
|
}
|
|
221
222
|
export async function handleDaoShip(ctx, proposalId, options) {
|
|
@@ -386,7 +387,15 @@ export async function handleDaoRoundtable(ctx) {
|
|
|
386
387
|
proposal.riskZone = classifyRiskZone(proposal);
|
|
387
388
|
suggestion.proposalId = proposal.id;
|
|
388
389
|
proposalIds.set(suggestion.agentId, proposal.id);
|
|
389
|
-
|
|
390
|
+
state.auditLog.push({
|
|
391
|
+
id: state.nextAuditId++,
|
|
392
|
+
timestamp: new Date().toISOString(),
|
|
393
|
+
proposalId: proposal.id,
|
|
394
|
+
layer: "intelligence",
|
|
395
|
+
action: "roundtable_proposal_created",
|
|
396
|
+
actor: suggestion.agentId,
|
|
397
|
+
details: "Auto-created from round table",
|
|
398
|
+
});
|
|
390
399
|
}
|
|
391
400
|
}
|
|
392
401
|
catch (error) {
|
|
@@ -493,7 +502,6 @@ export async function handleDaoProposeAmendment(args) {
|
|
|
493
502
|
proposal.riskZone = classifyRiskZone(proposal);
|
|
494
503
|
await saveState();
|
|
495
504
|
await recordAudit(proposal.id, "governance", "amendment_proposed", "user", `Amendment: ${payload.type}`);
|
|
496
|
-
await saveState();
|
|
497
505
|
return `# 📜 Amendment Proposed — #${proposal.id}\n\nType: ${payload.type}\n\nRun \`dao_deliberate proposalId=${proposal.id}\``;
|
|
498
506
|
}
|
|
499
507
|
export async function handleDaoConfigGithub(_ctx, args) {
|