nexus-agents 2.111.1 → 2.113.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/{chunk-GJ47JWNS.js → chunk-5KBR7SYI.js} +181 -335
- package/dist/chunk-5KBR7SYI.js.map +1 -0
- package/dist/{chunk-354QTTF2.js → chunk-5NE37CDW.js} +64 -10
- package/dist/{chunk-354QTTF2.js.map → chunk-5NE37CDW.js.map} +1 -1
- package/dist/{chunk-XOKGSQIB.js → chunk-5VGGVVPG.js} +48 -2
- package/dist/chunk-5VGGVVPG.js.map +1 -0
- package/dist/{chunk-5P5KCVTX.js → chunk-7E2ZCYKA.js} +162 -2
- package/dist/chunk-7E2ZCYKA.js.map +1 -0
- package/dist/{chunk-RA25HAZE.js → chunk-JPCEQZPE.js} +3 -3
- package/dist/{chunk-SQSBG6CW.js → chunk-OMZD4OZP.js} +2 -2
- package/dist/cli.js +7 -7
- package/dist/{consensus-vote-SB2G2W6G.js → consensus-vote-EW5HWO6Z.js} +3 -3
- package/dist/{improvement-review-GFCDFNYV.js → improvement-review-7R5Q4OD3.js} +5 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +18 -18
- package/dist/index.js.map +1 -1
- package/dist/{setup-command-QVVFQ2RD.js → setup-command-UZTCNASI.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-5P5KCVTX.js.map +0 -1
- package/dist/chunk-GJ47JWNS.js.map +0 -1
- package/dist/chunk-XOKGSQIB.js.map +0 -1
- /package/dist/{chunk-RA25HAZE.js.map → chunk-JPCEQZPE.js.map} +0 -0
- /package/dist/{chunk-SQSBG6CW.js.map → chunk-OMZD4OZP.js.map} +0 -0
- /package/dist/{consensus-vote-SB2G2W6G.js.map → consensus-vote-EW5HWO6Z.js.map} +0 -0
- /package/dist/{improvement-review-GFCDFNYV.js.map → improvement-review-7R5Q4OD3.js.map} +0 -0
- /package/dist/{setup-command-QVVFQ2RD.js.map → setup-command-UZTCNASI.js.map} +0 -0
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
+
DEFAULT_CONSENSUS_CONFIG,
|
|
3
|
+
DEFAULT_INCREMENTAL_QUORUM_CONFIG,
|
|
2
4
|
NOOP_NOTIFIER,
|
|
5
|
+
ProposalSchema,
|
|
6
|
+
VOTING_THRESHOLDS,
|
|
7
|
+
VoteSchema,
|
|
3
8
|
createMcpNotifier,
|
|
4
9
|
createSecureHandler,
|
|
5
10
|
getToolAnnotations,
|
|
@@ -9,7 +14,7 @@ import {
|
|
|
9
14
|
toolSuccess,
|
|
10
15
|
withProgressHeartbeat,
|
|
11
16
|
wrapToolWithTimeout
|
|
12
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-7E2ZCYKA.js";
|
|
13
18
|
import {
|
|
14
19
|
getToolMemory
|
|
15
20
|
} from "./chunk-P2K5GCLL.js";
|
|
@@ -66,7 +71,7 @@ import {
|
|
|
66
71
|
} from "./chunk-CH7QIDHQ.js";
|
|
67
72
|
|
|
68
73
|
// src/mcp/tools/consensus-vote.ts
|
|
69
|
-
import { z as
|
|
74
|
+
import { z as z9 } from "zod";
|
|
70
75
|
|
|
71
76
|
// src/cli/vote-types.ts
|
|
72
77
|
var VOTER_ROLES = {
|
|
@@ -1997,187 +2002,40 @@ async function collectRealVotes(options) {
|
|
|
1997
2002
|
});
|
|
1998
2003
|
}
|
|
1999
2004
|
|
|
2000
|
-
// src/consensus/types-core.ts
|
|
2001
|
-
import { z as z2 } from "zod";
|
|
2002
|
-
var ConsensusAlgorithmSchema = z2.enum([
|
|
2003
|
-
"simple_majority",
|
|
2004
|
-
"supermajority",
|
|
2005
|
-
"unanimous",
|
|
2006
|
-
"proof_of_learning",
|
|
2007
|
-
"opinion_wise",
|
|
2008
|
-
"higher_order"
|
|
2009
|
-
]);
|
|
2010
|
-
var VoteDecisionSchema = z2.enum(["approve", "reject", "abstain"]);
|
|
2011
|
-
var ProposalStatusSchema = z2.enum([
|
|
2012
|
-
"pending",
|
|
2013
|
-
"voting",
|
|
2014
|
-
"approved",
|
|
2015
|
-
"rejected",
|
|
2016
|
-
"timeout",
|
|
2017
|
-
"closed"
|
|
2018
|
-
]);
|
|
2019
|
-
var RejectionCategorySchema = z2.enum([
|
|
2020
|
-
"YAGNI",
|
|
2021
|
-
"DRY_VIOLATION",
|
|
2022
|
-
"OVER_ENGINEERING",
|
|
2023
|
-
"SCOPE_CREEP",
|
|
2024
|
-
"SECURITY_RISK",
|
|
2025
|
-
"MISALIGNED",
|
|
2026
|
-
"INSUFFICIENT_EVIDENCE"
|
|
2027
|
-
]);
|
|
2028
|
-
var REJECTION_CATEGORIES = RejectionCategorySchema.options;
|
|
2029
|
-
var FindingShapeSchema = z2.object({
|
|
2030
|
-
summary: z2.string().min(1).max(500),
|
|
2031
|
-
location: z2.string().min(1).max(200),
|
|
2032
|
-
severity: z2.enum(["critical", "high", "medium", "low"]).default("medium"),
|
|
2033
|
-
gate: z2.object({
|
|
2034
|
-
reread_cited_line: z2.enum(["passed", "failed", "skipped"]).default("skipped"),
|
|
2035
|
-
traced_call_path: z2.enum(["passed", "failed", "skipped"]).default("skipped"),
|
|
2036
|
-
named_assertion: z2.string().default(""),
|
|
2037
|
-
ruled_out_language_non_issue: z2.enum(["passed", "failed", "skipped"]).default("skipped")
|
|
2038
|
-
}),
|
|
2039
|
-
claim: z2.string().min(1).max(2e3)
|
|
2040
|
-
});
|
|
2041
|
-
var VoteSchema = z2.object({
|
|
2042
|
-
decision: VoteDecisionSchema,
|
|
2043
|
-
reasoning: z2.string().min(1).describe("Explanation for the vote"),
|
|
2044
|
-
confidence: z2.number().min(0).max(1).describe("Confidence level 0-1"),
|
|
2045
|
-
conditions: z2.array(z2.string()).optional().describe("Conditions for approval"),
|
|
2046
|
-
/** Structured rejection categories for reject→refine→re-vote loops (Issue #1213). */
|
|
2047
|
-
rejectionCategories: z2.array(RejectionCategorySchema).optional().describe("Rejection reason categories when decision is reject"),
|
|
2048
|
-
/** Pre-verified PR-review findings (#2245 v4 follow-up). Optional;
|
|
2049
|
-
* populated only when the voter emits the structured top-level array. */
|
|
2050
|
-
findings: z2.array(FindingShapeSchema).optional().describe("PR-review findings (pre-verified)"),
|
|
2051
|
-
timestamp: z2.iso.datetime().optional()
|
|
2052
|
-
});
|
|
2053
|
-
var ProposalSchema = z2.object({
|
|
2054
|
-
id: z2.string().optional().describe("Auto-generated if not provided"),
|
|
2055
|
-
title: z2.string().min(1).max(200).describe("Short proposal title"),
|
|
2056
|
-
description: z2.string().min(1).describe("Detailed proposal description"),
|
|
2057
|
-
algorithm: ConsensusAlgorithmSchema,
|
|
2058
|
-
timeout: z2.number().int().positive().optional().describe("Timeout in milliseconds"),
|
|
2059
|
-
requiredVoters: z2.array(z2.string()).optional().describe("Agent IDs that must vote"),
|
|
2060
|
-
metadata: z2.record(z2.string(), z2.unknown()).optional().describe("Additional context"),
|
|
2061
|
-
createdAt: z2.iso.datetime().optional()
|
|
2062
|
-
});
|
|
2063
|
-
var ConsensusResultSchema = z2.object({
|
|
2064
|
-
proposalId: z2.string(),
|
|
2065
|
-
proposal: ProposalSchema,
|
|
2066
|
-
outcome: ProposalStatusSchema,
|
|
2067
|
-
votes: z2.map(z2.string(), VoteSchema),
|
|
2068
|
-
voteCounts: z2.object({
|
|
2069
|
-
approve: z2.number().int().nonnegative(),
|
|
2070
|
-
reject: z2.number().int().nonnegative(),
|
|
2071
|
-
abstain: z2.number().int().nonnegative(),
|
|
2072
|
-
total: z2.number().int().nonnegative()
|
|
2073
|
-
}),
|
|
2074
|
-
weightedCounts: z2.object({
|
|
2075
|
-
approve: z2.number().nonnegative(),
|
|
2076
|
-
reject: z2.number().nonnegative(),
|
|
2077
|
-
abstain: z2.number().nonnegative(),
|
|
2078
|
-
totalWeight: z2.number().nonnegative()
|
|
2079
|
-
}).optional(),
|
|
2080
|
-
approvalPercentage: z2.number().min(0).max(100),
|
|
2081
|
-
quorumReached: z2.boolean(),
|
|
2082
|
-
startedAt: z2.iso.datetime(),
|
|
2083
|
-
closedAt: z2.iso.datetime(),
|
|
2084
|
-
durationMs: z2.number().int().nonnegative()
|
|
2085
|
-
});
|
|
2086
|
-
var AgentPerformanceSchema = z2.object({
|
|
2087
|
-
agentId: z2.string(),
|
|
2088
|
-
totalVotes: z2.number().int().nonnegative(),
|
|
2089
|
-
correctVotes: z2.number().int().nonnegative(),
|
|
2090
|
-
successRate: z2.number().min(0).max(1),
|
|
2091
|
-
lastUpdated: z2.iso.datetime()
|
|
2092
|
-
});
|
|
2093
|
-
var DEFAULT_INCREMENTAL_QUORUM_CONFIG = {
|
|
2094
|
-
enabled: false,
|
|
2095
|
-
maxExpansionRounds: 2,
|
|
2096
|
-
votersPerExpansion: 2,
|
|
2097
|
-
confidenceThreshold: 0.6,
|
|
2098
|
-
ambiguityBand: 0.15
|
|
2099
|
-
};
|
|
2100
|
-
var ProposalCacheConfigSchema = z2.object({
|
|
2101
|
-
enabled: z2.boolean().default(false),
|
|
2102
|
-
ttlMs: z2.number().int().positive().default(36e5),
|
|
2103
|
-
// 1 hour
|
|
2104
|
-
maxEntries: z2.number().int().positive().default(500)
|
|
2105
|
-
});
|
|
2106
|
-
var ConsensusEngineConfigSchema = z2.object({
|
|
2107
|
-
defaultTimeout: z2.number().int().positive().default(3e5),
|
|
2108
|
-
// 5 minutes
|
|
2109
|
-
minVotersForQuorum: z2.number().int().positive().default(2),
|
|
2110
|
-
maxActiveProposals: z2.number().int().positive().default(100),
|
|
2111
|
-
enablePerformanceTracking: z2.boolean().default(true),
|
|
2112
|
-
maxClosedProposals: z2.number().int().positive().default(1e3),
|
|
2113
|
-
// Issue #549
|
|
2114
|
-
proposalCache: ProposalCacheConfigSchema.optional()
|
|
2115
|
-
// Issue #589
|
|
2116
|
-
});
|
|
2117
|
-
var DEFAULT_CONSENSUS_CONFIG = {
|
|
2118
|
-
defaultTimeout: 3e5,
|
|
2119
|
-
// 5 minutes
|
|
2120
|
-
minVotersForQuorum: 2,
|
|
2121
|
-
maxActiveProposals: 100,
|
|
2122
|
-
enablePerformanceTracking: true,
|
|
2123
|
-
maxClosedProposals: 1e3
|
|
2124
|
-
// Issue #549: Prevent unbounded memory growth
|
|
2125
|
-
};
|
|
2126
|
-
var VOTING_THRESHOLDS = {
|
|
2127
|
-
simple_majority: 0.5,
|
|
2128
|
-
supermajority: 0.67,
|
|
2129
|
-
unanimous: 1,
|
|
2130
|
-
proof_of_learning: 0.5,
|
|
2131
|
-
// Uses weighted voting
|
|
2132
|
-
opinion_wise: 0.5,
|
|
2133
|
-
// Uses correlation-aware Bayesian aggregation (Issue #333)
|
|
2134
|
-
higher_order: 0.5
|
|
2135
|
-
// Alias for opinion_wise (Issue #514)
|
|
2136
|
-
};
|
|
2137
|
-
var ConsensusMetricsSchema = z2.object({
|
|
2138
|
-
totalProposals: z2.number().int().nonnegative(),
|
|
2139
|
-
approvedProposals: z2.number().int().nonnegative(),
|
|
2140
|
-
rejectedProposals: z2.number().int().nonnegative(),
|
|
2141
|
-
timedOutProposals: z2.number().int().nonnegative(),
|
|
2142
|
-
averageDurationMs: z2.number().nonnegative(),
|
|
2143
|
-
averageVotesPerProposal: z2.number().nonnegative(),
|
|
2144
|
-
algorithmUsage: z2.record(ConsensusAlgorithmSchema, z2.number().int().nonnegative())
|
|
2145
|
-
});
|
|
2146
|
-
|
|
2147
2005
|
// src/consensus/types-voting-protocol.ts
|
|
2148
|
-
import { z as
|
|
2149
|
-
var VotingRoundPhaseSchema =
|
|
2150
|
-
var VotingRoundStatusSchema =
|
|
2006
|
+
import { z as z2 } from "zod";
|
|
2007
|
+
var VotingRoundPhaseSchema = z2.enum(["analysis", "deliberation", "consensus"]);
|
|
2008
|
+
var VotingRoundStatusSchema = z2.enum([
|
|
2151
2009
|
"pending",
|
|
2152
2010
|
"in_progress",
|
|
2153
2011
|
"awaiting_votes",
|
|
2154
2012
|
"completed",
|
|
2155
2013
|
"aborted"
|
|
2156
2014
|
]);
|
|
2157
|
-
var AgentFindingSchema =
|
|
2158
|
-
agentId:
|
|
2159
|
-
category:
|
|
2160
|
-
severity:
|
|
2161
|
-
description:
|
|
2162
|
-
location:
|
|
2163
|
-
suggestion:
|
|
2164
|
-
confidence:
|
|
2165
|
-
timestamp:
|
|
2015
|
+
var AgentFindingSchema = z2.object({
|
|
2016
|
+
agentId: z2.string(),
|
|
2017
|
+
category: z2.enum(["bug", "security", "performance", "style", "design", "documentation", "other"]),
|
|
2018
|
+
severity: z2.enum(["critical", "major", "minor", "suggestion"]),
|
|
2019
|
+
description: z2.string().min(1),
|
|
2020
|
+
location: z2.string().optional().describe("File path and line range if applicable"),
|
|
2021
|
+
suggestion: z2.string().optional().describe("Recommended fix"),
|
|
2022
|
+
confidence: z2.number().min(0).max(1),
|
|
2023
|
+
timestamp: z2.iso.datetime().optional()
|
|
2166
2024
|
});
|
|
2167
|
-
var FindingVoteSchema =
|
|
2168
|
-
agentId:
|
|
2169
|
-
findingId:
|
|
2170
|
-
agree:
|
|
2171
|
-
reasoning:
|
|
2172
|
-
amendedSeverity:
|
|
2025
|
+
var FindingVoteSchema = z2.object({
|
|
2026
|
+
agentId: z2.string(),
|
|
2027
|
+
findingId: z2.string(),
|
|
2028
|
+
agree: z2.boolean(),
|
|
2029
|
+
reasoning: z2.string().optional(),
|
|
2030
|
+
amendedSeverity: z2.enum(["critical", "major", "minor", "suggestion"]).optional()
|
|
2173
2031
|
});
|
|
2174
|
-
var VotingProtocolConfigSchema =
|
|
2175
|
-
committeeSize:
|
|
2176
|
-
maxRounds:
|
|
2177
|
-
roundTimeoutMs:
|
|
2178
|
-
agreementThreshold:
|
|
2179
|
-
enableAntiSycophancy:
|
|
2180
|
-
sycophancyThreshold:
|
|
2032
|
+
var VotingProtocolConfigSchema = z2.object({
|
|
2033
|
+
committeeSize: z2.number().int().min(2).max(7).default(3),
|
|
2034
|
+
maxRounds: z2.number().int().min(1).max(5).default(3),
|
|
2035
|
+
roundTimeoutMs: z2.number().int().positive().default(6e4),
|
|
2036
|
+
agreementThreshold: z2.number().min(0.5).max(1).default(0.67),
|
|
2037
|
+
enableAntiSycophancy: z2.boolean().default(true),
|
|
2038
|
+
sycophancyThreshold: z2.number().min(0).max(1).default(0.8)
|
|
2181
2039
|
});
|
|
2182
2040
|
var DEFAULT_VOTING_PROTOCOL_CONFIG = {
|
|
2183
2041
|
committeeSize: 3,
|
|
@@ -2189,30 +2047,30 @@ var DEFAULT_VOTING_PROTOCOL_CONFIG = {
|
|
|
2189
2047
|
};
|
|
2190
2048
|
|
|
2191
2049
|
// src/consensus/types-weighted-voting.ts
|
|
2192
|
-
import { z as
|
|
2193
|
-
var TaskOutcomeStatusSchema =
|
|
2194
|
-
var WeightedAgentRecordSchema =
|
|
2195
|
-
agentId:
|
|
2196
|
-
totalTasks:
|
|
2197
|
-
successfulTasks:
|
|
2198
|
-
failedTasks:
|
|
2199
|
-
partialTasks:
|
|
2200
|
-
successRate:
|
|
2201
|
-
weight:
|
|
2202
|
-
trustScore:
|
|
2203
|
-
byzantineFlags:
|
|
2204
|
-
lastActive:
|
|
2205
|
-
createdAt:
|
|
2050
|
+
import { z as z3 } from "zod";
|
|
2051
|
+
var TaskOutcomeStatusSchema = z3.enum(["success", "failure", "partial", "unknown"]);
|
|
2052
|
+
var WeightedAgentRecordSchema = z3.object({
|
|
2053
|
+
agentId: z3.string().min(1),
|
|
2054
|
+
totalTasks: z3.number().int().nonnegative(),
|
|
2055
|
+
successfulTasks: z3.number().int().nonnegative(),
|
|
2056
|
+
failedTasks: z3.number().int().nonnegative(),
|
|
2057
|
+
partialTasks: z3.number().int().nonnegative(),
|
|
2058
|
+
successRate: z3.number().min(0).max(1),
|
|
2059
|
+
weight: z3.number().min(0).max(1),
|
|
2060
|
+
trustScore: z3.number().min(0).max(1),
|
|
2061
|
+
byzantineFlags: z3.number().int().nonnegative(),
|
|
2062
|
+
lastActive: z3.date(),
|
|
2063
|
+
createdAt: z3.date()
|
|
2206
2064
|
});
|
|
2207
|
-
var WeightedVotingConfigSchema =
|
|
2208
|
-
minWeight:
|
|
2209
|
-
maxByzantineFraction:
|
|
2210
|
-
weightDecayFactor:
|
|
2211
|
-
weightRecoveryFactor:
|
|
2212
|
-
minTrustScore:
|
|
2213
|
-
byzantineFlagThreshold:
|
|
2214
|
-
initialWeight:
|
|
2215
|
-
quorumThreshold:
|
|
2065
|
+
var WeightedVotingConfigSchema = z3.object({
|
|
2066
|
+
minWeight: z3.number().min(0).max(1).default(0.1),
|
|
2067
|
+
maxByzantineFraction: z3.number().min(0).max(0.5).default(0.33),
|
|
2068
|
+
weightDecayFactor: z3.number().min(0.5).max(1).default(0.9),
|
|
2069
|
+
weightRecoveryFactor: z3.number().min(1).max(2).default(1.05),
|
|
2070
|
+
minTrustScore: z3.number().min(0).max(1).default(0.3),
|
|
2071
|
+
byzantineFlagThreshold: z3.number().int().positive().default(3),
|
|
2072
|
+
initialWeight: z3.number().min(0).max(1).default(0.5),
|
|
2073
|
+
quorumThreshold: z3.number().min(0.5).max(1).default(0.67)
|
|
2216
2074
|
});
|
|
2217
2075
|
var DEFAULT_WEIGHTED_VOTING_CONFIG = {
|
|
2218
2076
|
minWeight: 0.1,
|
|
@@ -2226,7 +2084,7 @@ var DEFAULT_WEIGHTED_VOTING_CONFIG = {
|
|
|
2226
2084
|
};
|
|
2227
2085
|
|
|
2228
2086
|
// src/consensus/higher-order-types.ts
|
|
2229
|
-
import { z as
|
|
2087
|
+
import { z as z4 } from "zod";
|
|
2230
2088
|
function createAgentPairKey(agentA, agentB) {
|
|
2231
2089
|
return agentA < agentB ? `${agentA}:${agentB}` : `${agentB}:${agentA}`;
|
|
2232
2090
|
}
|
|
@@ -2237,40 +2095,40 @@ function parseAgentPairKey(key) {
|
|
|
2237
2095
|
}
|
|
2238
2096
|
return [parts[0], parts[1]];
|
|
2239
2097
|
}
|
|
2240
|
-
var CorrelationCoefficientSchema =
|
|
2241
|
-
var IndependentSubsetSchema =
|
|
2242
|
-
id:
|
|
2243
|
-
agentIds:
|
|
2244
|
-
independenceScore:
|
|
2245
|
-
observationCount:
|
|
2098
|
+
var CorrelationCoefficientSchema = z4.number().min(-1).max(1);
|
|
2099
|
+
var IndependentSubsetSchema = z4.object({
|
|
2100
|
+
id: z4.string(),
|
|
2101
|
+
agentIds: z4.array(z4.string()),
|
|
2102
|
+
independenceScore: z4.number().min(0).max(1),
|
|
2103
|
+
observationCount: z4.number().int().nonnegative()
|
|
2246
2104
|
});
|
|
2247
|
-
var VotingObservationSchema =
|
|
2248
|
-
proposalId:
|
|
2249
|
-
agentId:
|
|
2250
|
-
decision:
|
|
2251
|
-
confidence:
|
|
2252
|
-
alignedWithOutcome:
|
|
2253
|
-
timestamp:
|
|
2105
|
+
var VotingObservationSchema = z4.object({
|
|
2106
|
+
proposalId: z4.string(),
|
|
2107
|
+
agentId: z4.string(),
|
|
2108
|
+
decision: z4.enum(["approve", "reject", "abstain"]),
|
|
2109
|
+
confidence: z4.number().min(0).max(1),
|
|
2110
|
+
alignedWithOutcome: z4.boolean(),
|
|
2111
|
+
timestamp: z4.date()
|
|
2254
2112
|
});
|
|
2255
|
-
var PairwiseVotingHistorySchema =
|
|
2256
|
-
pairKey:
|
|
2257
|
-
jointObservations:
|
|
2258
|
-
agreements:
|
|
2259
|
-
disagreements:
|
|
2113
|
+
var PairwiseVotingHistorySchema = z4.object({
|
|
2114
|
+
pairKey: z4.string(),
|
|
2115
|
+
jointObservations: z4.number().int().nonnegative(),
|
|
2116
|
+
agreements: z4.number().int().nonnegative(),
|
|
2117
|
+
disagreements: z4.number().int().nonnegative(),
|
|
2260
2118
|
correlation: CorrelationCoefficientSchema,
|
|
2261
|
-
lastUpdated:
|
|
2119
|
+
lastUpdated: z4.date()
|
|
2262
2120
|
});
|
|
2263
|
-
var HigherOrderVotingConfigSchema =
|
|
2264
|
-
minObservationsForCorrelation:
|
|
2265
|
-
correlationThreshold:
|
|
2266
|
-
correlationMaxAgeMs:
|
|
2121
|
+
var HigherOrderVotingConfigSchema = z4.object({
|
|
2122
|
+
minObservationsForCorrelation: z4.number().int().positive().default(10),
|
|
2123
|
+
correlationThreshold: z4.number().min(0).max(1).default(0.3),
|
|
2124
|
+
correlationMaxAgeMs: z4.number().int().positive().default(864e5),
|
|
2267
2125
|
// 24 hours
|
|
2268
|
-
independenceThreshold:
|
|
2269
|
-
fallbackToSimpleVoting:
|
|
2270
|
-
observationDecayFactor:
|
|
2271
|
-
maxObservationsPerAgent:
|
|
2272
|
-
maxProposals:
|
|
2273
|
-
maxTrackedPairs:
|
|
2126
|
+
independenceThreshold: z4.number().min(0).max(1).default(0.2),
|
|
2127
|
+
fallbackToSimpleVoting: z4.boolean().default(true),
|
|
2128
|
+
observationDecayFactor: z4.number().min(0).max(1).default(0.95),
|
|
2129
|
+
maxObservationsPerAgent: z4.number().int().positive().default(1e3),
|
|
2130
|
+
maxProposals: z4.number().int().positive().default(5e3),
|
|
2131
|
+
maxTrackedPairs: z4.number().int().positive().default(100)
|
|
2274
2132
|
});
|
|
2275
2133
|
var DEFAULT_HIGHER_ORDER_CONFIG = {
|
|
2276
2134
|
minObservationsForCorrelation: 10,
|
|
@@ -2284,25 +2142,25 @@ var DEFAULT_HIGHER_ORDER_CONFIG = {
|
|
|
2284
2142
|
maxProposals: 5e3,
|
|
2285
2143
|
maxTrackedPairs: 100
|
|
2286
2144
|
};
|
|
2287
|
-
var HigherOrderVotingResultSchema =
|
|
2288
|
-
decision:
|
|
2289
|
-
posteriorApproval:
|
|
2290
|
-
posteriorRejection:
|
|
2291
|
-
effectiveVoteCount:
|
|
2292
|
-
usedCorrelationData:
|
|
2293
|
-
method:
|
|
2294
|
-
improvementOverBaseline:
|
|
2295
|
-
independentSubsets:
|
|
2296
|
-
downweightedAgents:
|
|
2297
|
-
reasoning:
|
|
2145
|
+
var HigherOrderVotingResultSchema = z4.object({
|
|
2146
|
+
decision: z4.enum(["approve", "reject", "no_consensus"]),
|
|
2147
|
+
posteriorApproval: z4.number().min(0).max(1),
|
|
2148
|
+
posteriorRejection: z4.number().min(0).max(1),
|
|
2149
|
+
effectiveVoteCount: z4.number().nonnegative(),
|
|
2150
|
+
usedCorrelationData: z4.boolean(),
|
|
2151
|
+
method: z4.enum(["ow", "isp", "simple"]),
|
|
2152
|
+
improvementOverBaseline: z4.number(),
|
|
2153
|
+
independentSubsets: z4.array(IndependentSubsetSchema).optional(),
|
|
2154
|
+
downweightedAgents: z4.array(z4.string()),
|
|
2155
|
+
reasoning: z4.string()
|
|
2298
2156
|
});
|
|
2299
|
-
var CorrelationTrackerStatsSchema =
|
|
2300
|
-
totalAgents:
|
|
2301
|
-
trackedPairs:
|
|
2302
|
-
totalObservations:
|
|
2303
|
-
averageCorrelation:
|
|
2304
|
-
independentSubsetCount:
|
|
2305
|
-
pairsWithSufficientData:
|
|
2157
|
+
var CorrelationTrackerStatsSchema = z4.object({
|
|
2158
|
+
totalAgents: z4.number().int().nonnegative(),
|
|
2159
|
+
trackedPairs: z4.number().int().nonnegative(),
|
|
2160
|
+
totalObservations: z4.number().int().nonnegative(),
|
|
2161
|
+
averageCorrelation: z4.number(),
|
|
2162
|
+
independentSubsetCount: z4.number().int().nonnegative(),
|
|
2163
|
+
pairsWithSufficientData: z4.number().int().nonnegative()
|
|
2306
2164
|
});
|
|
2307
2165
|
|
|
2308
2166
|
// src/consensus/higher-order-helpers.ts
|
|
@@ -4990,7 +4848,7 @@ function createCorrelationTracker(config) {
|
|
|
4990
4848
|
|
|
4991
4849
|
// src/consensus/correlation-persistence.ts
|
|
4992
4850
|
import * as fs from "fs";
|
|
4993
|
-
import { z as
|
|
4851
|
+
import { z as z5 } from "zod";
|
|
4994
4852
|
var logger6 = createLogger({ component: "correlation-persistence" });
|
|
4995
4853
|
var VOTING_SUBDIR = "voting";
|
|
4996
4854
|
var CORRELATIONS_FILE = "correlations.json";
|
|
@@ -4998,21 +4856,21 @@ var CORRELATIONS_JSONL_FILE = "correlations.jsonl";
|
|
|
4998
4856
|
var FILE_MODE = 384;
|
|
4999
4857
|
var DIR_MODE = 448;
|
|
5000
4858
|
var SCHEMA_VERSION = 2;
|
|
5001
|
-
var PersistedVoteSchema =
|
|
5002
|
-
agentId:
|
|
5003
|
-
decision:
|
|
5004
|
-
confidence:
|
|
4859
|
+
var PersistedVoteSchema = z5.object({
|
|
4860
|
+
agentId: z5.string(),
|
|
4861
|
+
decision: z5.enum(["approve", "reject", "abstain"]),
|
|
4862
|
+
confidence: z5.number().min(0).max(1)
|
|
5005
4863
|
});
|
|
5006
|
-
var PersistedProposalSchema =
|
|
5007
|
-
proposalId:
|
|
5008
|
-
votes:
|
|
5009
|
-
outcome:
|
|
5010
|
-
timestamp:
|
|
4864
|
+
var PersistedProposalSchema = z5.object({
|
|
4865
|
+
proposalId: z5.string(),
|
|
4866
|
+
votes: z5.array(PersistedVoteSchema),
|
|
4867
|
+
outcome: z5.enum(["approved", "rejected"]),
|
|
4868
|
+
timestamp: z5.iso.datetime()
|
|
5011
4869
|
});
|
|
5012
|
-
var PersistedCorrelationDataSchema =
|
|
5013
|
-
version:
|
|
5014
|
-
proposals:
|
|
5015
|
-
savedAt:
|
|
4870
|
+
var PersistedCorrelationDataSchema = z5.object({
|
|
4871
|
+
version: z5.number().int().positive(),
|
|
4872
|
+
proposals: z5.array(PersistedProposalSchema),
|
|
4873
|
+
savedAt: z5.iso.datetime()
|
|
5016
4874
|
});
|
|
5017
4875
|
function getCorrelationDataPath() {
|
|
5018
4876
|
return nexusDataPath(VOTING_SUBDIR, CORRELATIONS_FILE);
|
|
@@ -5213,9 +5071,9 @@ function createPersistedProposal(proposalId, votes, outcome) {
|
|
|
5213
5071
|
}
|
|
5214
5072
|
|
|
5215
5073
|
// src/mcp/tools/consensus-vote-types.ts
|
|
5216
|
-
import { z as
|
|
5074
|
+
import { z as z6 } from "zod";
|
|
5217
5075
|
var MAX_PROPOSAL_LENGTH = 4e3;
|
|
5218
|
-
var VotingStrategySchema =
|
|
5076
|
+
var VotingStrategySchema = z6.enum([
|
|
5219
5077
|
"simple_majority",
|
|
5220
5078
|
"supermajority",
|
|
5221
5079
|
"unanimous",
|
|
@@ -5226,8 +5084,8 @@ var VotingStrategySchema = z7.enum([
|
|
|
5226
5084
|
function isHigherOrderStrategy(strategy) {
|
|
5227
5085
|
return strategy === "higher_order" || strategy === "opinion_wise";
|
|
5228
5086
|
}
|
|
5229
|
-
var ErrorPolicySchema =
|
|
5230
|
-
var VoteThresholdSchema =
|
|
5087
|
+
var ErrorPolicySchema = z6.enum(["reduce_denominator", "count_as_abstain", "fail_closed"]);
|
|
5088
|
+
var VoteThresholdSchema = z6.enum(["majority", "supermajority", "unanimous"]);
|
|
5231
5089
|
var ERROR_FLOOR_FRACTION = 0.5;
|
|
5232
5090
|
function getDefaultErrorPolicy(strategy) {
|
|
5233
5091
|
if (strategy === "unanimous") {
|
|
@@ -5235,8 +5093,8 @@ function getDefaultErrorPolicy(strategy) {
|
|
|
5235
5093
|
}
|
|
5236
5094
|
return "reduce_denominator";
|
|
5237
5095
|
}
|
|
5238
|
-
var ConsensusVoteInputSchema =
|
|
5239
|
-
proposal:
|
|
5096
|
+
var ConsensusVoteInputSchema = z6.object({
|
|
5097
|
+
proposal: z6.string().min(1).max(MAX_PROPOSAL_LENGTH).describe("Proposal text to vote on"),
|
|
5240
5098
|
threshold: VoteThresholdSchema.optional().describe(
|
|
5241
5099
|
"Voting threshold (legacy): majority, supermajority, unanimous. Use strategy instead."
|
|
5242
5100
|
),
|
|
@@ -5246,8 +5104,8 @@ var ConsensusVoteInputSchema = z7.object({
|
|
|
5246
5104
|
errorPolicy: ErrorPolicySchema.optional().describe(
|
|
5247
5105
|
"How to treat voters that errored or timed out (#2630). Default: fail_closed for unanimous only; reduce_denominator for all other strategies incl. higher_order/opinion_wise (#3138 \u2014 a single infra timeout should not void an otherwise-unanimous vote). Regardless of policy, errors > 50% always fails."
|
|
5248
5106
|
),
|
|
5249
|
-
quickMode:
|
|
5250
|
-
simulateVotes:
|
|
5107
|
+
quickMode: z6.boolean().optional().default(false).describe("Use 3 agents instead of the full 7-role panel for faster execution"),
|
|
5108
|
+
simulateVotes: z6.boolean().optional().default(false).describe(
|
|
5251
5109
|
"TESTS ONLY \u2014 when true, voters return random decisions. Output must not be used for real decisions. (#2319)"
|
|
5252
5110
|
),
|
|
5253
5111
|
/**
|
|
@@ -5267,7 +5125,7 @@ var ConsensusVoteInputSchema = z7.object({
|
|
|
5267
5125
|
* Kept optional (no `.default()`) so the inferred type doesn't force
|
|
5268
5126
|
* `mode: 'sync'` on every existing call site / test fixture.
|
|
5269
5127
|
*/
|
|
5270
|
-
mode:
|
|
5128
|
+
mode: z6.enum(["sync", "async"]).optional().describe(
|
|
5271
5129
|
'Dispatch mode (default: sync). Use "async" for higher-order strategies with 7 voters.'
|
|
5272
5130
|
),
|
|
5273
5131
|
/**
|
|
@@ -5276,7 +5134,7 @@ var ConsensusVoteInputSchema = z7.object({
|
|
|
5276
5134
|
* same key with different inputs fails closed with
|
|
5277
5135
|
* `idempotency_key_collision`. Sync mode ignores this.
|
|
5278
5136
|
*/
|
|
5279
|
-
idempotencyKey:
|
|
5137
|
+
idempotencyKey: z6.string().min(1).max(256).optional().describe(
|
|
5280
5138
|
"Replay-safe key for async-mode dispatch (#3042 Stage 1c). Same (key, inputs) returns existing jobId."
|
|
5281
5139
|
)
|
|
5282
5140
|
});
|
|
@@ -5621,30 +5479,30 @@ function warnIfSimulatedOutsideTests(toolName, logger11) {
|
|
|
5621
5479
|
|
|
5622
5480
|
// src/mcp/jobs/job-result-store.ts
|
|
5623
5481
|
import { existsSync as existsSync3, readFileSync as readFileSync3, readdirSync, writeFileSync as writeFileSync3 } from "fs";
|
|
5624
|
-
import { z as
|
|
5482
|
+
import { z as z7 } from "zod";
|
|
5625
5483
|
var logger8 = createLogger({ component: "job-result-store" });
|
|
5626
|
-
var JobStatusSchema =
|
|
5627
|
-
var JobResultSchema =
|
|
5484
|
+
var JobStatusSchema = z7.enum(["pending", "complete", "failed", "cancelled"]);
|
|
5485
|
+
var JobResultSchema = z7.object({
|
|
5628
5486
|
/** Format version. Currently `1` — bump if the shape changes. */
|
|
5629
|
-
v:
|
|
5630
|
-
jobId:
|
|
5487
|
+
v: z7.literal(1),
|
|
5488
|
+
jobId: z7.string().min(1),
|
|
5631
5489
|
/** Tool that was invoked (e.g. `orchestrate`). */
|
|
5632
|
-
toolName:
|
|
5490
|
+
toolName: z7.string().min(1),
|
|
5633
5491
|
status: JobStatusSchema,
|
|
5634
|
-
createdAt:
|
|
5492
|
+
createdAt: z7.iso.datetime(),
|
|
5635
5493
|
/** Set when the job leaves `pending` — either via `complete` or `failed` or `cancelled`. */
|
|
5636
|
-
completedAt:
|
|
5494
|
+
completedAt: z7.iso.datetime().optional(),
|
|
5637
5495
|
/**
|
|
5638
5496
|
* Structured payload the synchronous mode would have returned. Present
|
|
5639
5497
|
* only when `status === 'complete'`. Shape is tool-specific — readers
|
|
5640
5498
|
* cast to the tool's known output type after status check.
|
|
5641
5499
|
*/
|
|
5642
|
-
result:
|
|
5500
|
+
result: z7.unknown().optional(),
|
|
5643
5501
|
/**
|
|
5644
5502
|
* Failure message when `status === 'failed'`. Cannot be paired with
|
|
5645
5503
|
* `result` — the discriminator is `status`.
|
|
5646
5504
|
*/
|
|
5647
|
-
error:
|
|
5505
|
+
error: z7.string().optional()
|
|
5648
5506
|
});
|
|
5649
5507
|
function jobResultPath(jobId) {
|
|
5650
5508
|
return nexusDataPathEnsure("jobs", `result-${jobId}.json`);
|
|
@@ -5761,20 +5619,20 @@ function listJobs() {
|
|
|
5761
5619
|
// src/mcp/jobs/job-idempotency.ts
|
|
5762
5620
|
import { createHash, randomUUID as randomUUID2 } from "crypto";
|
|
5763
5621
|
import { existsSync as existsSync4, readFileSync as readFileSync4, writeFileSync as writeFileSync4 } from "fs";
|
|
5764
|
-
import { z as
|
|
5622
|
+
import { z as z8 } from "zod";
|
|
5765
5623
|
var logger9 = createLogger({ component: "job-idempotency" });
|
|
5766
|
-
var IdempotencyIndexEntrySchema =
|
|
5767
|
-
v:
|
|
5624
|
+
var IdempotencyIndexEntrySchema = z8.object({
|
|
5625
|
+
v: z8.literal(1),
|
|
5768
5626
|
/** MCP tool name (e.g. `orchestrate`, `run_workflow`, `consensus_vote`). */
|
|
5769
|
-
tool:
|
|
5627
|
+
tool: z8.string().min(1),
|
|
5770
5628
|
/** Caller-supplied idempotency key. */
|
|
5771
|
-
key:
|
|
5629
|
+
key: z8.string().min(1),
|
|
5772
5630
|
/** sha256 of the canonical input JSON. */
|
|
5773
|
-
inputsHash:
|
|
5631
|
+
inputsHash: z8.string().length(64),
|
|
5774
5632
|
/** Existing jobId for this (tool, key, inputs) tuple. */
|
|
5775
|
-
jobId:
|
|
5633
|
+
jobId: z8.string().min(1),
|
|
5776
5634
|
/** ISO timestamp of first dispatch. */
|
|
5777
|
-
createdAt:
|
|
5635
|
+
createdAt: z8.iso.datetime()
|
|
5778
5636
|
});
|
|
5779
5637
|
function sha256Hex(input) {
|
|
5780
5638
|
return createHash("sha256").update(input).digest("hex");
|
|
@@ -6432,27 +6290,27 @@ function createConsensusVoteHandler(deps) {
|
|
|
6432
6290
|
};
|
|
6433
6291
|
}
|
|
6434
6292
|
var CONSENSUS_VOTE_OUTPUT_SCHEMA = {
|
|
6435
|
-
proposal:
|
|
6293
|
+
proposal: z9.string(),
|
|
6436
6294
|
strategy: VotingStrategySchema,
|
|
6437
|
-
decision:
|
|
6438
|
-
approvalPercentage:
|
|
6439
|
-
voteCounts:
|
|
6440
|
-
approve:
|
|
6441
|
-
reject:
|
|
6442
|
-
abstain:
|
|
6443
|
-
error:
|
|
6295
|
+
decision: z9.enum(["approved", "rejected", "no_quorum"]),
|
|
6296
|
+
approvalPercentage: z9.number(),
|
|
6297
|
+
voteCounts: z9.object({
|
|
6298
|
+
approve: z9.number(),
|
|
6299
|
+
reject: z9.number(),
|
|
6300
|
+
abstain: z9.number(),
|
|
6301
|
+
error: z9.number()
|
|
6444
6302
|
}),
|
|
6445
|
-
votes:
|
|
6446
|
-
|
|
6447
|
-
role:
|
|
6448
|
-
decision:
|
|
6449
|
-
confidence:
|
|
6450
|
-
reasoning:
|
|
6451
|
-
simulated:
|
|
6452
|
-
error:
|
|
6453
|
-
modelUsed:
|
|
6454
|
-
rejectionCategories:
|
|
6455
|
-
|
|
6303
|
+
votes: z9.array(
|
|
6304
|
+
z9.object({
|
|
6305
|
+
role: z9.string().max(100),
|
|
6306
|
+
decision: z9.enum(["approve", "reject", "abstain"]),
|
|
6307
|
+
confidence: z9.number(),
|
|
6308
|
+
reasoning: z9.string().max(4e3),
|
|
6309
|
+
simulated: z9.boolean(),
|
|
6310
|
+
error: z9.boolean(),
|
|
6311
|
+
modelUsed: z9.string().max(100).optional(),
|
|
6312
|
+
rejectionCategories: z9.array(
|
|
6313
|
+
z9.enum([
|
|
6456
6314
|
"YAGNI",
|
|
6457
6315
|
"DRY_VIOLATION",
|
|
6458
6316
|
"OVER_ENGINEERING",
|
|
@@ -6465,34 +6323,34 @@ var CONSENSUS_VOTE_OUTPUT_SCHEMA = {
|
|
|
6465
6323
|
})
|
|
6466
6324
|
),
|
|
6467
6325
|
threshold: VoteThresholdSchema.optional(),
|
|
6468
|
-
durationMs:
|
|
6469
|
-
simulateVotes:
|
|
6470
|
-
higherOrderMetadata:
|
|
6471
|
-
posteriorApproval:
|
|
6472
|
-
posteriorRejection:
|
|
6473
|
-
effectiveVoteCount:
|
|
6474
|
-
method:
|
|
6475
|
-
usedCorrelationData:
|
|
6476
|
-
improvementOverBaseline:
|
|
6477
|
-
downweightedAgents:
|
|
6478
|
-
reasoning:
|
|
6326
|
+
durationMs: z9.number(),
|
|
6327
|
+
simulateVotes: z9.boolean(),
|
|
6328
|
+
higherOrderMetadata: z9.object({
|
|
6329
|
+
posteriorApproval: z9.number(),
|
|
6330
|
+
posteriorRejection: z9.number(),
|
|
6331
|
+
effectiveVoteCount: z9.number(),
|
|
6332
|
+
method: z9.enum(["ow", "isp", "simple"]),
|
|
6333
|
+
usedCorrelationData: z9.boolean(),
|
|
6334
|
+
improvementOverBaseline: z9.number(),
|
|
6335
|
+
downweightedAgents: z9.array(z9.string().max(100)).max(10),
|
|
6336
|
+
reasoning: z9.string().max(2e3)
|
|
6479
6337
|
}).optional(),
|
|
6480
6338
|
// #3124: explains a `rejected` decision that coexists with a high
|
|
6481
6339
|
// approvalPercentage (an error-policy short-circuit, e.g. fail_closed).
|
|
6482
|
-
policyReason:
|
|
6340
|
+
policyReason: z9.string().max(200).optional()
|
|
6483
6341
|
};
|
|
6484
6342
|
function registerConsensusVoteTool(server, deps) {
|
|
6485
6343
|
const logger11 = deps.logger ?? createLogger({ tool: "consensus_vote" });
|
|
6486
6344
|
const notifier = deps.notifier ?? createMcpNotifier(server);
|
|
6487
6345
|
const depsWithNotifier = { ...deps, notifier };
|
|
6488
6346
|
const toolSchema = {
|
|
6489
|
-
proposal:
|
|
6490
|
-
threshold:
|
|
6347
|
+
proposal: z9.string().min(1).max(MAX_PROPOSAL_LENGTH).describe("Proposal text to vote on"),
|
|
6348
|
+
threshold: z9.enum(["majority", "supermajority", "unanimous"]).optional().describe("Voting threshold (legacy). Use strategy instead."),
|
|
6491
6349
|
strategy: VotingStrategySchema.optional().describe(
|
|
6492
6350
|
"Voting strategy: simple_majority (default), supermajority, unanimous, proof_of_learning, or higher_order"
|
|
6493
6351
|
),
|
|
6494
|
-
quickMode:
|
|
6495
|
-
simulateVotes:
|
|
6352
|
+
quickMode: z9.boolean().optional().default(false).describe("Use 3 agents instead of 7"),
|
|
6353
|
+
simulateVotes: z9.boolean().optional().default(false).describe("TESTS ONLY \u2014 random output, must not be used for real decisions (#2319)")
|
|
6496
6354
|
};
|
|
6497
6355
|
const description = "Execute multi-model consensus voting on a proposal. Uses 7 specialized agent roles (architect, security, devex, ai_ml, pm, catfish, scope_steward) to vote on proposals with configurable strategies. Supports higher_order strategy for Bayesian-optimal aggregation with correlation awareness (Issue #514).";
|
|
6498
6356
|
const secureHandler = createSecureHandler(createConsensusVoteHandler(depsWithNotifier), {
|
|
@@ -6546,18 +6404,6 @@ export {
|
|
|
6546
6404
|
VOTER_ROLES,
|
|
6547
6405
|
NoAdapterError,
|
|
6548
6406
|
collectRealVotes,
|
|
6549
|
-
ConsensusAlgorithmSchema,
|
|
6550
|
-
ProposalStatusSchema,
|
|
6551
|
-
RejectionCategorySchema,
|
|
6552
|
-
REJECTION_CATEGORIES,
|
|
6553
|
-
VoteSchema,
|
|
6554
|
-
ProposalSchema,
|
|
6555
|
-
ConsensusResultSchema,
|
|
6556
|
-
AgentPerformanceSchema,
|
|
6557
|
-
ConsensusEngineConfigSchema,
|
|
6558
|
-
DEFAULT_CONSENSUS_CONFIG,
|
|
6559
|
-
VOTING_THRESHOLDS,
|
|
6560
|
-
ConsensusMetricsSchema,
|
|
6561
6407
|
VotingRoundPhaseSchema,
|
|
6562
6408
|
VotingRoundStatusSchema,
|
|
6563
6409
|
AgentFindingSchema,
|
|
@@ -6611,4 +6457,4 @@ export {
|
|
|
6611
6457
|
CONSENSUS_VOTE_OUTPUT_SCHEMA,
|
|
6612
6458
|
registerConsensusVoteTool
|
|
6613
6459
|
};
|
|
6614
|
-
//# sourceMappingURL=chunk-
|
|
6460
|
+
//# sourceMappingURL=chunk-5KBR7SYI.js.map
|