nexus-agents 8.56.0 → 8.58.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-MO6FSEFJ.js → chunk-C4DQ6FON.js} +455 -375
- package/dist/chunk-C4DQ6FON.js.map +1 -0
- package/dist/{chunk-M2ZQXDSO.js → chunk-E5B3PEN2.js} +3 -3
- package/dist/{chunk-5W55WXLY.js → chunk-JEYC4YVR.js} +2 -2
- package/dist/{chunk-BWP3RTR2.js → chunk-KQNVDSMX.js} +2 -2
- package/dist/{chunk-UURJGJTW.js → chunk-PU2UWCEK.js} +2 -2
- package/dist/{chunk-HXITPFTR.js → chunk-WHA6AJVN.js} +89 -73
- package/dist/{chunk-HXITPFTR.js.map → chunk-WHA6AJVN.js.map} +1 -1
- package/dist/cli.d.ts +77 -2
- package/dist/cli.js +131 -36
- package/dist/cli.js.map +1 -1
- package/dist/{consensus-vote-JHCRRDH5.js → consensus-vote-2MWTFKEN.js} +4 -4
- package/dist/{consensus-vote-types-cDFfyFTQ.d.ts → consensus-vote-types-ClG_UKij.d.ts} +48 -18
- package/dist/{improvement-review-MTQWL4BT.js → improvement-review-GD3M7E24.js} +4 -4
- package/dist/index.d.ts +22 -76
- package/dist/index.js +6 -6
- package/dist/{setup-data-dir-RXY2PWDX.js → setup-data-dir-VGIART6F.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-MO6FSEFJ.js.map +0 -1
- /package/dist/{chunk-M2ZQXDSO.js.map → chunk-E5B3PEN2.js.map} +0 -0
- /package/dist/{chunk-5W55WXLY.js.map → chunk-JEYC4YVR.js.map} +0 -0
- /package/dist/{chunk-BWP3RTR2.js.map → chunk-KQNVDSMX.js.map} +0 -0
- /package/dist/{chunk-UURJGJTW.js.map → chunk-PU2UWCEK.js.map} +0 -0
- /package/dist/{consensus-vote-JHCRRDH5.js.map → consensus-vote-2MWTFKEN.js.map} +0 -0
- /package/dist/{improvement-review-MTQWL4BT.js.map → improvement-review-GD3M7E24.js.map} +0 -0
- /package/dist/{setup-data-dir-RXY2PWDX.js.map → setup-data-dir-VGIART6F.js.map} +0 -0
|
@@ -25,10 +25,10 @@ import {
|
|
|
25
25
|
toolSuccessStructured,
|
|
26
26
|
withProgressHeartbeat,
|
|
27
27
|
wrapToolWithTimeout
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-KQNVDSMX.js";
|
|
29
29
|
import {
|
|
30
30
|
VERSION
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-PU2UWCEK.js";
|
|
32
32
|
import {
|
|
33
33
|
UNRESOLVED_MODEL_ID,
|
|
34
34
|
assessPanelIndependence,
|
|
@@ -90,7 +90,71 @@ import {
|
|
|
90
90
|
} from "./chunk-BTYRPZON.js";
|
|
91
91
|
|
|
92
92
|
// src/mcp/tools/consensus-vote.ts
|
|
93
|
-
import { z as
|
|
93
|
+
import { z as z13 } from "zod";
|
|
94
|
+
|
|
95
|
+
// src/mcp/tools/async-dispatch-input.ts
|
|
96
|
+
import { z } from "zod";
|
|
97
|
+
var DISPATCH_MODES = ["sync", "async"];
|
|
98
|
+
var MODE_ALIAS_REMOVAL_ISSUE = "#6225";
|
|
99
|
+
var DISPATCH_DESCRIPTION = "Async dispatch (#4968). 'sync' (default): run inline and return the result. 'async': return { status: 'pending', jobId } immediately and run in the background; poll get_job_result({ jobId }).";
|
|
100
|
+
var WRONG_KEY_MODE_MESSAGE = '`mode` is not the async switch on this tool; send `dispatch: "async"` (or "sync") instead (#4968).';
|
|
101
|
+
function dispatchModeConflictMessage(dispatch, mode) {
|
|
102
|
+
return `\`dispatch: "${dispatch}"\` and \`mode: "${mode}"\` disagree; send only \`dispatch\` (\`mode\` is a deprecated alias, removed in ${MODE_ALIAS_REMOVAL_ISSUE}).`;
|
|
103
|
+
}
|
|
104
|
+
function describeDispatch(note) {
|
|
105
|
+
return note === void 0 ? DISPATCH_DESCRIPTION : `${DISPATCH_DESCRIPTION} ${note}`;
|
|
106
|
+
}
|
|
107
|
+
function dispatchField(note) {
|
|
108
|
+
return z.enum(DISPATCH_MODES).optional().describe(describeDispatch(note));
|
|
109
|
+
}
|
|
110
|
+
function dispatchFieldDefaultSync(note) {
|
|
111
|
+
return z.enum(DISPATCH_MODES).default("sync").describe(describeDispatch(note));
|
|
112
|
+
}
|
|
113
|
+
var REJECTED_MODE_KEY = z.never({ error: WRONG_KEY_MODE_MESSAGE }).optional().describe(
|
|
114
|
+
"Not an input of this tool. The async switch is `dispatch`; `mode: 'async'` is rejected (#4968)."
|
|
115
|
+
);
|
|
116
|
+
function asyncDispatchInput(note) {
|
|
117
|
+
return { dispatch: dispatchField(note), mode: REJECTED_MODE_KEY };
|
|
118
|
+
}
|
|
119
|
+
function asyncDispatchInputDefaultSync(note) {
|
|
120
|
+
return { dispatch: dispatchFieldDefaultSync(note), mode: REJECTED_MODE_KEY };
|
|
121
|
+
}
|
|
122
|
+
function modeEnumErrorNamingDispatch(issue) {
|
|
123
|
+
return isDispatchMode(issue.input) ? WRONG_KEY_MODE_MESSAGE : void 0;
|
|
124
|
+
}
|
|
125
|
+
function isDispatchMode(value) {
|
|
126
|
+
return value === "sync" || value === "async";
|
|
127
|
+
}
|
|
128
|
+
var DEPRECATED_MODE_ALIAS_INPUT = {
|
|
129
|
+
dispatch: dispatchField(),
|
|
130
|
+
mode: z.enum(DISPATCH_MODES).optional().describe(
|
|
131
|
+
`DEPRECATED alias of \`dispatch\` (removed in the next major, ${MODE_ALIAS_REMOVAL_ISSUE}). Send \`dispatch\` instead; a call that sends only \`mode\` still works and returns a deprecation warning.`
|
|
132
|
+
)
|
|
133
|
+
};
|
|
134
|
+
function refineDispatchModeAgreement(value, ctx) {
|
|
135
|
+
if (value.dispatch === void 0 || value.mode === void 0) return;
|
|
136
|
+
if (value.dispatch === value.mode) return;
|
|
137
|
+
ctx.addIssue({
|
|
138
|
+
code: "custom",
|
|
139
|
+
path: ["dispatch"],
|
|
140
|
+
message: dispatchModeConflictMessage(value.dispatch, value.mode)
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
function resolveDispatch(input) {
|
|
144
|
+
return input.dispatch ?? input.mode;
|
|
145
|
+
}
|
|
146
|
+
function deprecatedModeWarning(input) {
|
|
147
|
+
if (input.mode === void 0 || input.dispatch !== void 0) return void 0;
|
|
148
|
+
return `\`mode: "${input.mode}"\` is deprecated; send \`dispatch: "${input.mode}"\`. \`mode\` is removed in the next major (${MODE_ALIAS_REMOVAL_ISSUE}).`;
|
|
149
|
+
}
|
|
150
|
+
var WARNINGS_META_KEY = "nexus-agents/warnings";
|
|
151
|
+
function withWarnings(result, warnings) {
|
|
152
|
+
const present = warnings.filter((w) => w !== void 0);
|
|
153
|
+
if (present.length === 0) return result;
|
|
154
|
+
const existing = result._meta?.[WARNINGS_META_KEY];
|
|
155
|
+
const prior = Array.isArray(existing) ? existing.filter((w) => typeof w === "string") : [];
|
|
156
|
+
return { ...result, _meta: { ...result._meta, [WARNINGS_META_KEY]: [...prior, ...present] } };
|
|
157
|
+
}
|
|
94
158
|
|
|
95
159
|
// src/cli/voter-roles.ts
|
|
96
160
|
var VOTER_ROLES = {
|
|
@@ -602,7 +666,7 @@ var SIMULATED_VOTE_REASONING = {
|
|
|
602
666
|
};
|
|
603
667
|
|
|
604
668
|
// src/cli/voter-response.ts
|
|
605
|
-
import { z } from "zod";
|
|
669
|
+
import { z as z2 } from "zod";
|
|
606
670
|
|
|
607
671
|
// src/consensus/option-tally.ts
|
|
608
672
|
var SUPERMAJORITY_SHARE = 2 / 3;
|
|
@@ -662,26 +726,26 @@ var SyntheticVoteError = class extends Error {
|
|
|
662
726
|
}
|
|
663
727
|
rawOutput;
|
|
664
728
|
};
|
|
665
|
-
var RawFindingSchema =
|
|
666
|
-
summary:
|
|
667
|
-
location:
|
|
668
|
-
severity:
|
|
669
|
-
gate:
|
|
670
|
-
reread_cited_line:
|
|
671
|
-
traced_call_path:
|
|
672
|
-
named_assertion:
|
|
673
|
-
ruled_out_language_non_issue:
|
|
729
|
+
var RawFindingSchema = z2.object({
|
|
730
|
+
summary: z2.string().min(1).max(500).describe("One-line summary of the issue"),
|
|
731
|
+
location: z2.string().min(1).max(200).describe("path/file.ext:line"),
|
|
732
|
+
severity: z2.enum(["critical", "high", "medium", "low"]).default("medium"),
|
|
733
|
+
gate: z2.object({
|
|
734
|
+
reread_cited_line: z2.enum(["passed", "failed", "skipped"]).default("skipped"),
|
|
735
|
+
traced_call_path: z2.enum(["passed", "failed", "skipped"]).default("skipped"),
|
|
736
|
+
named_assertion: z2.string().default("").describe("Concrete failing assertion \u2014 substantive, not a rubber-stamp word"),
|
|
737
|
+
ruled_out_language_non_issue: z2.enum(["passed", "failed", "skipped"]).default("skipped")
|
|
674
738
|
}),
|
|
675
|
-
claim:
|
|
739
|
+
claim: z2.string().min(1).max(2e3).describe("What is wrong and why it justifies blocking")
|
|
676
740
|
});
|
|
677
|
-
var VoteResponseSchema =
|
|
678
|
-
decision:
|
|
679
|
-
reasoning:
|
|
680
|
-
confidence:
|
|
681
|
-
conditions:
|
|
741
|
+
var VoteResponseSchema = z2.object({
|
|
742
|
+
decision: z2.enum(["approve", "reject", "abstain"]).describe("Your vote decision"),
|
|
743
|
+
reasoning: z2.string().min(10).max(4e3).describe("Explanation for your vote (10-4000 chars)"),
|
|
744
|
+
confidence: z2.number().min(0).max(1).describe("Confidence level 0-1"),
|
|
745
|
+
conditions: z2.array(z2.string()).optional().describe("Optional conditions for approval"),
|
|
682
746
|
/** Structured rejection categories for reject→refine→re-vote loops (Issue #1213). */
|
|
683
|
-
rejectionCategories:
|
|
684
|
-
|
|
747
|
+
rejectionCategories: z2.array(
|
|
748
|
+
z2.enum([
|
|
685
749
|
"YAGNI",
|
|
686
750
|
"DRY_VIOLATION",
|
|
687
751
|
"OVER_ENGINEERING",
|
|
@@ -693,11 +757,11 @@ var VoteResponseSchema = z.object({
|
|
|
693
757
|
).optional().describe("Rejection reason categories when decision is reject"),
|
|
694
758
|
/** Top-level structured findings for PR-review mode (#2245 v4 follow-up).
|
|
695
759
|
* Replaces the YAML-in-reasoning encoding that proved lossy. */
|
|
696
|
-
findings:
|
|
760
|
+
findings: z2.array(RawFindingSchema).optional().describe("Structured findings (PR review only)"),
|
|
697
761
|
/** Chosen option when the proposal declared `options` (#4472). Validated
|
|
698
762
|
* against the declared list by the caller; an unmatched value is dropped
|
|
699
763
|
* rather than recorded, so a parse miss surfaces as absent. */
|
|
700
|
-
selectedOption:
|
|
764
|
+
selectedOption: z2.string().optional().describe("Which declared option you choose")
|
|
701
765
|
});
|
|
702
766
|
var VOTE_JSON_SCHEMA = {
|
|
703
767
|
type: "object",
|
|
@@ -1589,9 +1653,9 @@ async function collectRealVotes(options) {
|
|
|
1589
1653
|
// src/cli/voter-project.ts
|
|
1590
1654
|
import { readFileSync, statSync } from "node:fs";
|
|
1591
1655
|
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
1592
|
-
import { z as
|
|
1656
|
+
import { z as z3 } from "zod";
|
|
1593
1657
|
var VOTER_PROJECT_PATTERN = /^[A-Za-z0-9._/@-]{1,200}$/;
|
|
1594
|
-
var VoterProjectInputSchema =
|
|
1658
|
+
var VoterProjectInputSchema = z3.string().regex(VOTER_PROJECT_PATTERN).optional().describe(
|
|
1595
1659
|
"The project the panel is judging (#6110), e.g. `acme/widgets` \u2014 it replaces `nexus-agents` in every voter's system prompt, so a consuming repository is not judged against this one's mission and governance files. When omitted the name is DERIVED from the server's working directory (the `origin` remote as `owner/repo`, else the nearest `package.json` name) and falls back to `nexus-agents`; the response discloses which on `project.source`. Letters, digits and `._/@-` only, at most 200 characters."
|
|
1596
1660
|
);
|
|
1597
1661
|
var MAX_ANCESTOR_DEPTH = 64;
|
|
@@ -1757,40 +1821,40 @@ function describeVeto(verdict) {
|
|
|
1757
1821
|
}
|
|
1758
1822
|
|
|
1759
1823
|
// src/consensus/types-voting-protocol.ts
|
|
1760
|
-
import { z as
|
|
1824
|
+
import { z as z4 } from "zod";
|
|
1761
1825
|
var VOTING_ROUND_DEFAULT_TIMEOUT_MS = OPERATION_CLASSES["multi-llm-panel"].guardMs;
|
|
1762
|
-
var VotingRoundPhaseSchema =
|
|
1763
|
-
var VotingRoundStatusSchema =
|
|
1826
|
+
var VotingRoundPhaseSchema = z4.enum(["analysis", "deliberation", "consensus"]);
|
|
1827
|
+
var VotingRoundStatusSchema = z4.enum([
|
|
1764
1828
|
"pending",
|
|
1765
1829
|
"in_progress",
|
|
1766
1830
|
"awaiting_votes",
|
|
1767
1831
|
"completed",
|
|
1768
1832
|
"aborted"
|
|
1769
1833
|
]);
|
|
1770
|
-
var AgentFindingSchema =
|
|
1771
|
-
agentId:
|
|
1772
|
-
category:
|
|
1773
|
-
severity:
|
|
1774
|
-
description:
|
|
1775
|
-
location:
|
|
1776
|
-
suggestion:
|
|
1777
|
-
confidence:
|
|
1778
|
-
timestamp:
|
|
1834
|
+
var AgentFindingSchema = z4.object({
|
|
1835
|
+
agentId: z4.string(),
|
|
1836
|
+
category: z4.enum(["bug", "security", "performance", "style", "design", "documentation", "other"]),
|
|
1837
|
+
severity: z4.enum(["critical", "major", "minor", "suggestion"]),
|
|
1838
|
+
description: z4.string().min(1),
|
|
1839
|
+
location: z4.string().optional().describe("File path and line range if applicable"),
|
|
1840
|
+
suggestion: z4.string().optional().describe("Recommended fix"),
|
|
1841
|
+
confidence: z4.number().min(0).max(1),
|
|
1842
|
+
timestamp: z4.iso.datetime().optional()
|
|
1779
1843
|
});
|
|
1780
|
-
var FindingVoteSchema =
|
|
1781
|
-
agentId:
|
|
1782
|
-
findingId:
|
|
1783
|
-
agree:
|
|
1784
|
-
reasoning:
|
|
1785
|
-
amendedSeverity:
|
|
1844
|
+
var FindingVoteSchema = z4.object({
|
|
1845
|
+
agentId: z4.string(),
|
|
1846
|
+
findingId: z4.string(),
|
|
1847
|
+
agree: z4.boolean(),
|
|
1848
|
+
reasoning: z4.string().optional(),
|
|
1849
|
+
amendedSeverity: z4.enum(["critical", "major", "minor", "suggestion"]).optional()
|
|
1786
1850
|
});
|
|
1787
|
-
var VotingProtocolConfigSchema =
|
|
1788
|
-
committeeSize:
|
|
1789
|
-
maxRounds:
|
|
1790
|
-
roundTimeoutMs:
|
|
1791
|
-
agreementThreshold:
|
|
1792
|
-
enableAntiSycophancy:
|
|
1793
|
-
sycophancyThreshold:
|
|
1851
|
+
var VotingProtocolConfigSchema = z4.object({
|
|
1852
|
+
committeeSize: z4.number().int().min(2).max(7).default(3),
|
|
1853
|
+
maxRounds: z4.number().int().min(1).max(5).default(3),
|
|
1854
|
+
roundTimeoutMs: z4.number().int().positive().default(VOTING_ROUND_DEFAULT_TIMEOUT_MS),
|
|
1855
|
+
agreementThreshold: z4.number().min(0.5).max(1).default(SUPERMAJORITY_THRESHOLD),
|
|
1856
|
+
enableAntiSycophancy: z4.boolean().default(true),
|
|
1857
|
+
sycophancyThreshold: z4.number().min(0).max(1).default(0.8)
|
|
1794
1858
|
});
|
|
1795
1859
|
var DEFAULT_VOTING_PROTOCOL_CONFIG = {
|
|
1796
1860
|
committeeSize: 3,
|
|
@@ -1803,30 +1867,30 @@ var DEFAULT_VOTING_PROTOCOL_CONFIG = {
|
|
|
1803
1867
|
};
|
|
1804
1868
|
|
|
1805
1869
|
// src/consensus/types-weighted-voting.ts
|
|
1806
|
-
import { z as
|
|
1807
|
-
var TaskOutcomeStatusSchema =
|
|
1808
|
-
var WeightedAgentRecordSchema =
|
|
1809
|
-
agentId:
|
|
1810
|
-
totalTasks:
|
|
1811
|
-
successfulTasks:
|
|
1812
|
-
failedTasks:
|
|
1813
|
-
partialTasks:
|
|
1814
|
-
successRate:
|
|
1815
|
-
weight:
|
|
1816
|
-
trustScore:
|
|
1817
|
-
byzantineFlags:
|
|
1818
|
-
lastActive:
|
|
1819
|
-
createdAt:
|
|
1870
|
+
import { z as z5 } from "zod";
|
|
1871
|
+
var TaskOutcomeStatusSchema = z5.enum(["success", "failure", "partial", "unknown"]);
|
|
1872
|
+
var WeightedAgentRecordSchema = z5.object({
|
|
1873
|
+
agentId: z5.string().min(1),
|
|
1874
|
+
totalTasks: z5.number().int().nonnegative(),
|
|
1875
|
+
successfulTasks: z5.number().int().nonnegative(),
|
|
1876
|
+
failedTasks: z5.number().int().nonnegative(),
|
|
1877
|
+
partialTasks: z5.number().int().nonnegative(),
|
|
1878
|
+
successRate: z5.number().min(0).max(1),
|
|
1879
|
+
weight: z5.number().min(0).max(1),
|
|
1880
|
+
trustScore: z5.number().min(0).max(1),
|
|
1881
|
+
byzantineFlags: z5.number().int().nonnegative(),
|
|
1882
|
+
lastActive: z5.date(),
|
|
1883
|
+
createdAt: z5.date()
|
|
1820
1884
|
});
|
|
1821
|
-
var WeightedVotingConfigSchema =
|
|
1822
|
-
minWeight:
|
|
1823
|
-
maxByzantineFraction:
|
|
1824
|
-
weightDecayFactor:
|
|
1825
|
-
weightRecoveryFactor:
|
|
1826
|
-
minTrustScore:
|
|
1827
|
-
byzantineFlagThreshold:
|
|
1828
|
-
initialWeight:
|
|
1829
|
-
quorumThreshold:
|
|
1885
|
+
var WeightedVotingConfigSchema = z5.object({
|
|
1886
|
+
minWeight: z5.number().min(0).max(1).default(0.1),
|
|
1887
|
+
maxByzantineFraction: z5.number().min(0).max(0.5).default(0.33),
|
|
1888
|
+
weightDecayFactor: z5.number().min(0.5).max(1).default(0.9),
|
|
1889
|
+
weightRecoveryFactor: z5.number().min(1).max(2).default(1.05),
|
|
1890
|
+
minTrustScore: z5.number().min(0).max(1).default(0.3),
|
|
1891
|
+
byzantineFlagThreshold: z5.number().int().positive().default(3),
|
|
1892
|
+
initialWeight: z5.number().min(0).max(1).default(0.5),
|
|
1893
|
+
quorumThreshold: z5.number().min(0.5).max(1).default(SUPERMAJORITY_THRESHOLD)
|
|
1830
1894
|
});
|
|
1831
1895
|
var DEFAULT_WEIGHTED_VOTING_CONFIG = {
|
|
1832
1896
|
minWeight: 0.1,
|
|
@@ -1841,7 +1905,7 @@ var DEFAULT_WEIGHTED_VOTING_CONFIG = {
|
|
|
1841
1905
|
};
|
|
1842
1906
|
|
|
1843
1907
|
// src/consensus/higher-order-types.ts
|
|
1844
|
-
import { z as
|
|
1908
|
+
import { z as z6 } from "zod";
|
|
1845
1909
|
function createAgentPairKey(agentA, agentB) {
|
|
1846
1910
|
return agentA < agentB ? `${agentA}:${agentB}` : `${agentB}:${agentA}`;
|
|
1847
1911
|
}
|
|
@@ -1852,52 +1916,52 @@ function parseAgentPairKey(key) {
|
|
|
1852
1916
|
}
|
|
1853
1917
|
return [parts[0], parts[1]];
|
|
1854
1918
|
}
|
|
1855
|
-
var CorrelationCoefficientSchema =
|
|
1856
|
-
var IndependentSubsetSchema =
|
|
1857
|
-
id:
|
|
1858
|
-
agentIds:
|
|
1859
|
-
independenceScore:
|
|
1860
|
-
pairCoverage:
|
|
1861
|
-
observed:
|
|
1862
|
-
total:
|
|
1919
|
+
var CorrelationCoefficientSchema = z6.number().min(-1).max(1);
|
|
1920
|
+
var IndependentSubsetSchema = z6.object({
|
|
1921
|
+
id: z6.string(),
|
|
1922
|
+
agentIds: z6.array(z6.string()),
|
|
1923
|
+
independenceScore: z6.number().min(0).max(1),
|
|
1924
|
+
pairCoverage: z6.object({
|
|
1925
|
+
observed: z6.number().int().nonnegative(),
|
|
1926
|
+
total: z6.number().int().nonnegative()
|
|
1863
1927
|
}),
|
|
1864
|
-
observationCount:
|
|
1928
|
+
observationCount: z6.number().int().nonnegative()
|
|
1865
1929
|
});
|
|
1866
|
-
var VotingObservationSchema =
|
|
1867
|
-
proposalId:
|
|
1868
|
-
agentId:
|
|
1869
|
-
decision:
|
|
1870
|
-
confidence:
|
|
1871
|
-
alignedWithOutcome:
|
|
1872
|
-
timestamp:
|
|
1873
|
-
modelKey:
|
|
1874
|
-
observedModel:
|
|
1930
|
+
var VotingObservationSchema = z6.object({
|
|
1931
|
+
proposalId: z6.string(),
|
|
1932
|
+
agentId: z6.string(),
|
|
1933
|
+
decision: z6.enum(["approve", "reject", "abstain"]),
|
|
1934
|
+
confidence: z6.number().min(0).max(1),
|
|
1935
|
+
alignedWithOutcome: z6.boolean(),
|
|
1936
|
+
timestamp: z6.date(),
|
|
1937
|
+
modelKey: z6.string().optional(),
|
|
1938
|
+
observedModel: z6.string().optional()
|
|
1875
1939
|
});
|
|
1876
|
-
var PairwiseVotingHistorySchema =
|
|
1877
|
-
pairKey:
|
|
1878
|
-
jointObservations:
|
|
1879
|
-
agreements:
|
|
1880
|
-
disagreements:
|
|
1940
|
+
var PairwiseVotingHistorySchema = z6.object({
|
|
1941
|
+
pairKey: z6.string(),
|
|
1942
|
+
jointObservations: z6.number().int().nonnegative(),
|
|
1943
|
+
agreements: z6.number().int().nonnegative(),
|
|
1944
|
+
disagreements: z6.number().int().nonnegative(),
|
|
1881
1945
|
correlation: CorrelationCoefficientSchema,
|
|
1882
|
-
lastUpdated:
|
|
1946
|
+
lastUpdated: z6.date()
|
|
1883
1947
|
});
|
|
1884
|
-
var HigherOrderVotingConfigSchema =
|
|
1885
|
-
minObservationsForCorrelation:
|
|
1886
|
-
correlationThreshold:
|
|
1948
|
+
var HigherOrderVotingConfigSchema = z6.object({
|
|
1949
|
+
minObservationsForCorrelation: z6.number().int().positive().default(10),
|
|
1950
|
+
correlationThreshold: z6.number().min(0).max(1).default(0.3),
|
|
1887
1951
|
/**
|
|
1888
1952
|
* @deprecated Ignored since 8.x: correlation evidence is lifetime and partitioned by the role's pinned model (#5555); nothing reads this value. Removed in the next major (#5564).
|
|
1889
1953
|
*/
|
|
1890
|
-
correlationMaxAgeMs:
|
|
1954
|
+
correlationMaxAgeMs: z6.number().int().positive().default(864e5),
|
|
1891
1955
|
// 24 hours
|
|
1892
|
-
independenceThreshold:
|
|
1893
|
-
fallbackToSimpleVoting:
|
|
1956
|
+
independenceThreshold: z6.number().min(0).max(1).default(0.2),
|
|
1957
|
+
fallbackToSimpleVoting: z6.boolean().default(true),
|
|
1894
1958
|
/**
|
|
1895
1959
|
* @deprecated Ignored since 8.x: correlation evidence is lifetime and partitioned by the role's pinned model (#5555); nothing reads this value. Removed in the next major (#5564).
|
|
1896
1960
|
*/
|
|
1897
|
-
observationDecayFactor:
|
|
1898
|
-
maxObservationsPerAgent:
|
|
1899
|
-
maxProposals:
|
|
1900
|
-
maxTrackedPairs:
|
|
1961
|
+
observationDecayFactor: z6.number().min(0).max(1).default(0.95),
|
|
1962
|
+
maxObservationsPerAgent: z6.number().int().positive().default(1e3),
|
|
1963
|
+
maxProposals: z6.number().int().positive().default(5e3),
|
|
1964
|
+
maxTrackedPairs: z6.number().int().positive().default(100)
|
|
1901
1965
|
});
|
|
1902
1966
|
var DEFAULT_HIGHER_ORDER_CONFIG = {
|
|
1903
1967
|
minObservationsForCorrelation: 10,
|
|
@@ -1911,25 +1975,25 @@ var DEFAULT_HIGHER_ORDER_CONFIG = {
|
|
|
1911
1975
|
maxProposals: 5e3,
|
|
1912
1976
|
maxTrackedPairs: 100
|
|
1913
1977
|
};
|
|
1914
|
-
var HigherOrderVotingResultSchema =
|
|
1915
|
-
decision:
|
|
1916
|
-
posteriorApproval:
|
|
1917
|
-
posteriorRejection:
|
|
1918
|
-
effectiveVoteCount:
|
|
1919
|
-
usedCorrelationData:
|
|
1920
|
-
method:
|
|
1921
|
-
improvementOverBaseline:
|
|
1922
|
-
independentSubsets:
|
|
1923
|
-
downweightedAgents:
|
|
1924
|
-
reasoning:
|
|
1978
|
+
var HigherOrderVotingResultSchema = z6.object({
|
|
1979
|
+
decision: z6.enum(["approve", "reject", "no_consensus"]),
|
|
1980
|
+
posteriorApproval: z6.number().min(0).max(1),
|
|
1981
|
+
posteriorRejection: z6.number().min(0).max(1),
|
|
1982
|
+
effectiveVoteCount: z6.number().nonnegative(),
|
|
1983
|
+
usedCorrelationData: z6.boolean(),
|
|
1984
|
+
method: z6.enum(["ow", "isp", "simple"]),
|
|
1985
|
+
improvementOverBaseline: z6.number(),
|
|
1986
|
+
independentSubsets: z6.array(IndependentSubsetSchema).optional(),
|
|
1987
|
+
downweightedAgents: z6.array(z6.string()),
|
|
1988
|
+
reasoning: z6.string()
|
|
1925
1989
|
});
|
|
1926
|
-
var CorrelationTrackerStatsSchema =
|
|
1927
|
-
totalAgents:
|
|
1928
|
-
trackedPairs:
|
|
1929
|
-
totalObservations:
|
|
1930
|
-
averageCorrelation:
|
|
1931
|
-
independentSubsetCount:
|
|
1932
|
-
pairsWithSufficientData:
|
|
1990
|
+
var CorrelationTrackerStatsSchema = z6.object({
|
|
1991
|
+
totalAgents: z6.number().int().nonnegative(),
|
|
1992
|
+
trackedPairs: z6.number().int().nonnegative(),
|
|
1993
|
+
totalObservations: z6.number().int().nonnegative(),
|
|
1994
|
+
averageCorrelation: z6.number(),
|
|
1995
|
+
independentSubsetCount: z6.number().int().nonnegative(),
|
|
1996
|
+
pairsWithSufficientData: z6.number().int().nonnegative()
|
|
1933
1997
|
});
|
|
1934
1998
|
|
|
1935
1999
|
// src/consensus/higher-order-helpers.ts
|
|
@@ -4941,24 +5005,24 @@ function createCorrelationTracker(config) {
|
|
|
4941
5005
|
import * as fs from "node:fs";
|
|
4942
5006
|
|
|
4943
5007
|
// src/consensus/correlation-persistence-records.ts
|
|
4944
|
-
import { z as
|
|
4945
|
-
var PersistedVoteSchema =
|
|
4946
|
-
agentId:
|
|
4947
|
-
decision:
|
|
4948
|
-
confidence:
|
|
4949
|
-
modelKey:
|
|
4950
|
-
observedModel:
|
|
5008
|
+
import { z as z7 } from "zod";
|
|
5009
|
+
var PersistedVoteSchema = z7.object({
|
|
5010
|
+
agentId: z7.string(),
|
|
5011
|
+
decision: z7.enum(["approve", "reject", "abstain"]),
|
|
5012
|
+
confidence: z7.number().min(0).max(1),
|
|
5013
|
+
modelKey: z7.string().optional(),
|
|
5014
|
+
observedModel: z7.string().optional()
|
|
4951
5015
|
});
|
|
4952
|
-
var PersistedProposalSchema =
|
|
4953
|
-
proposalId:
|
|
4954
|
-
votes:
|
|
4955
|
-
outcome:
|
|
4956
|
-
timestamp:
|
|
5016
|
+
var PersistedProposalSchema = z7.object({
|
|
5017
|
+
proposalId: z7.string(),
|
|
5018
|
+
votes: z7.array(PersistedVoteSchema),
|
|
5019
|
+
outcome: z7.enum(["approved", "rejected"]),
|
|
5020
|
+
timestamp: z7.iso.datetime()
|
|
4957
5021
|
});
|
|
4958
|
-
var PersistedCorrelationDataSchema =
|
|
4959
|
-
version:
|
|
4960
|
-
proposals:
|
|
4961
|
-
savedAt:
|
|
5022
|
+
var PersistedCorrelationDataSchema = z7.object({
|
|
5023
|
+
version: z7.number().int().positive(),
|
|
5024
|
+
proposals: z7.array(PersistedProposalSchema),
|
|
5025
|
+
savedAt: z7.iso.datetime()
|
|
4962
5026
|
});
|
|
4963
5027
|
function createPersistedProposal(proposalId, votes, outcome, context) {
|
|
4964
5028
|
const persistedVotes = [];
|
|
@@ -5200,7 +5264,7 @@ function createPersistentCorrelationTracker(config) {
|
|
|
5200
5264
|
}
|
|
5201
5265
|
|
|
5202
5266
|
// src/mcp/tools/consensus-vote-types.ts
|
|
5203
|
-
import { z as
|
|
5267
|
+
import { z as z9 } from "zod";
|
|
5204
5268
|
|
|
5205
5269
|
// src/cli/vote-diversity.ts
|
|
5206
5270
|
function answeringSeats(votes) {
|
|
@@ -5244,39 +5308,39 @@ function singleModelPanelWarning(votes) {
|
|
|
5244
5308
|
|
|
5245
5309
|
// src/audit/vote-record.ts
|
|
5246
5310
|
import * as crypto from "node:crypto";
|
|
5247
|
-
import { z as
|
|
5248
|
-
var VoteRecordDecisionSchema =
|
|
5249
|
-
var VoteRecordOptionCoverageSchema =
|
|
5311
|
+
import { z as z8 } from "zod";
|
|
5312
|
+
var VoteRecordDecisionSchema = z8.enum(["approved", "rejected", "no_quorum"]);
|
|
5313
|
+
var VoteRecordOptionCoverageSchema = z8.object({
|
|
5250
5314
|
/** Every approving voter, selecting or not — the tally's denominator. */
|
|
5251
|
-
approverCount:
|
|
5315
|
+
approverCount: z8.number().int().nonnegative(),
|
|
5252
5316
|
/** Approvers whose selection matched a declared option. */
|
|
5253
|
-
selectedCount:
|
|
5317
|
+
selectedCount: z8.number().int().nonnegative(),
|
|
5254
5318
|
/** Approvers with no usable selection; their choice is unmeasured. */
|
|
5255
|
-
unattributedApprovals:
|
|
5319
|
+
unattributedApprovals: z8.number().int().nonnegative()
|
|
5256
5320
|
}).strict();
|
|
5257
|
-
var VoteRecordPanelCoverageSchema =
|
|
5321
|
+
var VoteRecordPanelCoverageSchema = z8.object({
|
|
5258
5322
|
/** Voters the panel asked for. */
|
|
5259
|
-
requested:
|
|
5323
|
+
requested: z8.number().int().nonnegative(),
|
|
5260
5324
|
/** Voters that returned a usable vote — the denominator of `voteCounts`. */
|
|
5261
|
-
responded:
|
|
5325
|
+
responded: z8.number().int().nonnegative(),
|
|
5262
5326
|
/** Voters that errored or timed out. */
|
|
5263
|
-
errored:
|
|
5327
|
+
errored: z8.number().int().nonnegative(),
|
|
5264
5328
|
/** The roles behind `errored`, in panel order. */
|
|
5265
|
-
erroredRoles:
|
|
5329
|
+
erroredRoles: z8.array(z8.string().min(1).max(100))
|
|
5266
5330
|
}).strict();
|
|
5267
5331
|
var MAX_VOTER_REASONING_CHARS = 2e4;
|
|
5268
|
-
var SeatFallbackRecordSchema =
|
|
5332
|
+
var SeatFallbackRecordSchema = z8.object({
|
|
5269
5333
|
/** The CLI the seat was assigned to, bare (`claude`, not `cli-claude`). */
|
|
5270
|
-
fromCli:
|
|
5334
|
+
fromCli: z8.string().min(1).max(100),
|
|
5271
5335
|
/** The model the assigned adapter had detected, when it had one. */
|
|
5272
|
-
fromModel:
|
|
5336
|
+
fromModel: z8.string().min(1).max(200).optional(),
|
|
5273
5337
|
/** The adapter-layer class of the error that moved the seat. */
|
|
5274
|
-
reason:
|
|
5338
|
+
reason: z8.enum(["rate-limit", "capacity", "auth", "timeout", "sandbox", "unknown"])
|
|
5275
5339
|
}).strict();
|
|
5276
|
-
var VoterSummarySchema =
|
|
5277
|
-
role:
|
|
5278
|
-
decision:
|
|
5279
|
-
confidence:
|
|
5340
|
+
var VoterSummarySchema = z8.object({
|
|
5341
|
+
role: z8.string().min(1).max(100),
|
|
5342
|
+
decision: z8.enum(["approve", "reject", "abstain"]),
|
|
5343
|
+
confidence: z8.number().min(0).max(1),
|
|
5280
5344
|
/**
|
|
5281
5345
|
* The voter's stated grounds (#5373, schema 1.6).
|
|
5282
5346
|
*
|
|
@@ -5296,9 +5360,9 @@ var VoterSummarySchema = z7.object({
|
|
|
5296
5360
|
* `voters` at all (see `panelCoverage`), so `reasoning: ''` means a live
|
|
5297
5361
|
* voter returned nothing, which is itself a signal.
|
|
5298
5362
|
*/
|
|
5299
|
-
reasoning:
|
|
5363
|
+
reasoning: z8.string().max(MAX_VOTER_REASONING_CHARS).optional(),
|
|
5300
5364
|
/** True when `reasoning` was clipped to {@link MAX_VOTER_REASONING_CHARS}. */
|
|
5301
|
-
reasoningTruncated:
|
|
5365
|
+
reasoningTruncated: z8.literal(true).optional(),
|
|
5302
5366
|
/**
|
|
5303
5367
|
* True when this seat was recovered by the per-role retry (#6050, schema 1.7).
|
|
5304
5368
|
*
|
|
@@ -5319,7 +5383,7 @@ var VoterSummarySchema = z7.object({
|
|
|
5319
5383
|
* seat carries no key, so its entry re-hashes byte-identical and every
|
|
5320
5384
|
* historical record still verifies.
|
|
5321
5385
|
*/
|
|
5322
|
-
retried:
|
|
5386
|
+
retried: z8.literal(true).optional(),
|
|
5323
5387
|
/**
|
|
5324
5388
|
* Registry model id the seat ran on (#6091, schema 1.8).
|
|
5325
5389
|
*
|
|
@@ -5332,7 +5396,7 @@ var VoterSummarySchema = z7.object({
|
|
|
5332
5396
|
* Present-only, on the `retried` rule; absent when the result carried no
|
|
5333
5397
|
* model or only the pending-detection placeholder.
|
|
5334
5398
|
*/
|
|
5335
|
-
model:
|
|
5399
|
+
model: z8.string().min(1).max(200).optional(),
|
|
5336
5400
|
/**
|
|
5337
5401
|
* True when the seat could not read the artifact (#6094, schema 1.8).
|
|
5338
5402
|
*
|
|
@@ -5342,7 +5406,7 @@ var VoterSummarySchema = z7.object({
|
|
|
5342
5406
|
* on the proposal text after failing to read. `literal(true)` and
|
|
5343
5407
|
* present-only, so every pre-1.8 entry re-hashes byte-identical.
|
|
5344
5408
|
*/
|
|
5345
|
-
unverifiable:
|
|
5409
|
+
unverifiable: z8.literal(true).optional(),
|
|
5346
5410
|
/**
|
|
5347
5411
|
* The CLI the round-robin or `NEXUS_VOTER_MODEL_<ROLE>` pin chose for the
|
|
5348
5412
|
* seat, as a bare name (#6115, schema 1.9). `model` says where a seat
|
|
@@ -5353,7 +5417,7 @@ var VoterSummarySchema = z7.object({
|
|
|
5353
5417
|
* that said five of them were substitutes. Present-only, on the `model`
|
|
5354
5418
|
* rule; absent on a result built outside the panel launcher.
|
|
5355
5419
|
*/
|
|
5356
|
-
assignedCli:
|
|
5420
|
+
assignedCli: z8.string().min(1).max(100).optional(),
|
|
5357
5421
|
/**
|
|
5358
5422
|
* Present only when the seat answered on a different CLI or model than
|
|
5359
5423
|
* assigned (#6115, schema 1.9): the exact `SeatFallback` shape the live
|
|
@@ -5407,33 +5471,33 @@ function projectVoterSummary(v) {
|
|
|
5407
5471
|
}
|
|
5408
5472
|
return out;
|
|
5409
5473
|
}
|
|
5410
|
-
var VoteRecordCountsSchema =
|
|
5411
|
-
approve:
|
|
5412
|
-
reject:
|
|
5413
|
-
abstain:
|
|
5414
|
-
total:
|
|
5474
|
+
var VoteRecordCountsSchema = z8.object({
|
|
5475
|
+
approve: z8.number().int().nonnegative(),
|
|
5476
|
+
reject: z8.number().int().nonnegative(),
|
|
5477
|
+
abstain: z8.number().int().nonnegative(),
|
|
5478
|
+
total: z8.number().int().nonnegative()
|
|
5415
5479
|
}).strict();
|
|
5416
|
-
var VoteRecordOptionCountSchema =
|
|
5480
|
+
var VoteRecordOptionCountSchema = z8.object({
|
|
5417
5481
|
/** The option label as declared in the proposal (e.g. 'A'). */
|
|
5418
|
-
option:
|
|
5482
|
+
option: z8.string().min(1),
|
|
5419
5483
|
/** How many voters selected it. */
|
|
5420
|
-
count:
|
|
5484
|
+
count: z8.number().int().nonnegative()
|
|
5421
5485
|
}).strict();
|
|
5422
5486
|
var GIT_SHA_PATTERN = /^[0-9a-f]{40}$/;
|
|
5423
|
-
var VoteRecordPrBindingSchema =
|
|
5424
|
-
pr:
|
|
5425
|
-
headSha:
|
|
5487
|
+
var VoteRecordPrBindingSchema = z8.object({
|
|
5488
|
+
pr: z8.number().int().positive(),
|
|
5489
|
+
headSha: z8.string().regex(GIT_SHA_PATTERN, "expected a full 40-hex lowercase commit sha")
|
|
5426
5490
|
}).strict();
|
|
5427
5491
|
function projectPrBinding(b) {
|
|
5428
5492
|
return { pr: b.pr, headSha: b.headSha };
|
|
5429
5493
|
}
|
|
5430
|
-
var VoteRecordErrorPolicySchema =
|
|
5494
|
+
var VoteRecordErrorPolicySchema = z8.enum([
|
|
5431
5495
|
"reduce_denominator",
|
|
5432
5496
|
"count_as_abstain",
|
|
5433
5497
|
"fail_closed",
|
|
5434
5498
|
"absolute_quorum"
|
|
5435
5499
|
]);
|
|
5436
|
-
var VoteRecordSchema =
|
|
5500
|
+
var VoteRecordSchema = z8.object({
|
|
5437
5501
|
/**
|
|
5438
5502
|
* Schema version. '1.1' marked the chain→record-set+sequence model (#3927);
|
|
5439
5503
|
* '1.2' adds the optional `ratifies` subject-binding field (#3927 item 1);
|
|
@@ -5444,7 +5508,7 @@ var VoteRecordSchema = z7.object({
|
|
|
5444
5508
|
* Tiers are labels, not ordered numbers: '1.10' follows '1.9' by
|
|
5445
5509
|
* convention only and nothing compares them.
|
|
5446
5510
|
*/
|
|
5447
|
-
version:
|
|
5511
|
+
version: z8.enum([
|
|
5448
5512
|
"1.1",
|
|
5449
5513
|
"1.2",
|
|
5450
5514
|
"1.3",
|
|
@@ -5458,27 +5522,27 @@ var VoteRecordSchema = z7.object({
|
|
|
5458
5522
|
"1.11"
|
|
5459
5523
|
]),
|
|
5460
5524
|
/** Unique record id (also usable as a `ratificationVoteRef`). */
|
|
5461
|
-
id:
|
|
5525
|
+
id: z8.string().min(1),
|
|
5462
5526
|
/**
|
|
5463
5527
|
* Monotonic sequence number (integer ≥ 0). Assigned as (max existing
|
|
5464
5528
|
* sequence)+1 at write time. Sorted, the set of sequences must cover
|
|
5465
5529
|
* 0..maxSeq with no gap (omission detection); DUPLICATE sequences are a
|
|
5466
5530
|
* benign concurrent-fork signal, not tampering.
|
|
5467
5531
|
*/
|
|
5468
|
-
sequence:
|
|
5532
|
+
sequence: z8.number().int().nonnegative(),
|
|
5469
5533
|
/** ISO-8601 timestamp the vote was recorded. */
|
|
5470
|
-
recordedAt:
|
|
5534
|
+
recordedAt: z8.string().min(1),
|
|
5471
5535
|
/**
|
|
5472
5536
|
* SHA-256 of the FULL proposal text. The proposal itself is truncated for
|
|
5473
5537
|
* the human record (`proposal`), but the hash binds the record to the exact
|
|
5474
5538
|
* proposal voted on — a later edit of `proposal` that changes meaning is
|
|
5475
5539
|
* detectable by recomputing this hash from the original.
|
|
5476
5540
|
*/
|
|
5477
|
-
proposalHash:
|
|
5541
|
+
proposalHash: z8.string().length(64),
|
|
5478
5542
|
/** Truncated proposal text for the human/reviewer record. */
|
|
5479
|
-
proposal:
|
|
5543
|
+
proposal: z8.string(),
|
|
5480
5544
|
/** The voting strategy used. */
|
|
5481
|
-
strategy:
|
|
5545
|
+
strategy: z8.enum([
|
|
5482
5546
|
"simple_majority",
|
|
5483
5547
|
"supermajority",
|
|
5484
5548
|
"unanimous",
|
|
@@ -5489,13 +5553,13 @@ var VoteRecordSchema = z7.object({
|
|
|
5489
5553
|
/** The resolved decision. */
|
|
5490
5554
|
decision: VoteRecordDecisionSchema,
|
|
5491
5555
|
/** Approval fraction as a percentage (0-100). */
|
|
5492
|
-
approvalPercentage:
|
|
5556
|
+
approvalPercentage: z8.number().min(0).max(100),
|
|
5493
5557
|
/** Vote-count breakdown. */
|
|
5494
5558
|
voteCounts: VoteRecordCountsSchema,
|
|
5495
5559
|
/** Per-voter {role, decision, confidence} summary. */
|
|
5496
|
-
voters:
|
|
5560
|
+
voters: z8.array(VoterSummarySchema),
|
|
5497
5561
|
/** Optional correlation/decision id linking to the cost rollup / trace. */
|
|
5498
|
-
correlationId:
|
|
5562
|
+
correlationId: z8.string().min(1).optional(),
|
|
5499
5563
|
/**
|
|
5500
5564
|
* Per-option distribution for a multi-option proposal (#4452, schema 1.3).
|
|
5501
5565
|
*
|
|
@@ -5520,7 +5584,7 @@ var VoteRecordSchema = z7.object({
|
|
|
5520
5584
|
//
|
|
5521
5585
|
// Relaxing is a pure widening: no previously-valid record changes meaning
|
|
5522
5586
|
// or hash, and no persisted record can currently hold an empty tally.
|
|
5523
|
-
optionTally:
|
|
5587
|
+
optionTally: z8.array(VoteRecordOptionCountSchema).optional(),
|
|
5524
5588
|
/**
|
|
5525
5589
|
* Selection coverage for a multi-option vote (#4472, schema 1.4).
|
|
5526
5590
|
*
|
|
@@ -5546,7 +5610,7 @@ var VoteRecordSchema = z7.object({
|
|
|
5546
5610
|
* (with `decision === 'approved'` and `strategy === 'higher_order'`). Absent on
|
|
5547
5611
|
* an ordinary (non-ratification) vote; a 1.1 record never carries it.
|
|
5548
5612
|
*/
|
|
5549
|
-
ratifies:
|
|
5613
|
+
ratifies: z8.string().min(1).optional(),
|
|
5550
5614
|
/**
|
|
5551
5615
|
* The PR this vote RATIFIES, bound to the head the panel saw (#5130 step 1,
|
|
5552
5616
|
* schema 1.10; panel decision Q1 option A, 5 of 6). Present only on a
|
|
@@ -5587,9 +5651,9 @@ var VoteRecordSchema = z7.object({
|
|
|
5587
5651
|
* Retained for audit texture but NOT covered by `hash` and NOT verified —
|
|
5588
5652
|
* the record-set model is position-independent (#3927).
|
|
5589
5653
|
*/
|
|
5590
|
-
previousHash:
|
|
5654
|
+
previousHash: z8.string().length(64).optional(),
|
|
5591
5655
|
/** SHA-256 over every field above EXCEPT `previousHash` (and except `hash`). */
|
|
5592
|
-
hash:
|
|
5656
|
+
hash: z8.string().length(64)
|
|
5593
5657
|
}).strict();
|
|
5594
5658
|
function foldOptionalFields(base, payload) {
|
|
5595
5659
|
const withTally = payload.optionTally !== void 0 ? {
|
|
@@ -5676,7 +5740,7 @@ function checkUndeclaredOptions(proposal, declaredOptions, allEngagedApproved) {
|
|
|
5676
5740
|
|
|
5677
5741
|
// src/mcp/tools/consensus-vote-types.ts
|
|
5678
5742
|
var MAX_PROPOSAL_LENGTH = 4e3;
|
|
5679
|
-
var VotingStrategySchema =
|
|
5743
|
+
var VotingStrategySchema = z9.enum([
|
|
5680
5744
|
"simple_majority",
|
|
5681
5745
|
"supermajority",
|
|
5682
5746
|
"unanimous",
|
|
@@ -5691,18 +5755,18 @@ var HIGHER_ORDER_ESCALATION_POSTERIOR_FLOOR = 0.65;
|
|
|
5691
5755
|
function shouldEscalateLowPosterior(strategy, outcome, quickMode, posteriorApproval) {
|
|
5692
5756
|
return quickMode && outcome === "approved" && isHigherOrderStrategy(strategy) && posteriorApproval !== void 0 && posteriorApproval < HIGHER_ORDER_ESCALATION_POSTERIOR_FLOOR;
|
|
5693
5757
|
}
|
|
5694
|
-
var ErrorPolicySchema =
|
|
5758
|
+
var ErrorPolicySchema = z9.enum([
|
|
5695
5759
|
"reduce_denominator",
|
|
5696
5760
|
"count_as_abstain",
|
|
5697
5761
|
"fail_closed",
|
|
5698
5762
|
"absolute_quorum"
|
|
5699
5763
|
]);
|
|
5700
|
-
var VoteThresholdSchema =
|
|
5701
|
-
var ConsensusVoteInputSchema =
|
|
5702
|
-
proposal:
|
|
5764
|
+
var VoteThresholdSchema = z9.enum(["majority", "supermajority", "unanimous"]);
|
|
5765
|
+
var ConsensusVoteInputSchema = z9.object({
|
|
5766
|
+
proposal: z9.string().min(1).max(MAX_PROPOSAL_LENGTH).describe(
|
|
5703
5767
|
'Proposal text to vote on. If the proposal asks voters to choose among named alternatives, declare them in `options` (#4472) \u2014 otherwise the tally records approve/reject/abstain only, so every voter who engages returns `approve` and a 6-1 split on WHICH option persists as 7-0, 100% (#4452). This is ENFORCED AS A WARNING, not a refusal: a heuristic over the proposal text flags an apparent multi-option proposal with no `options` and says so on `panelWarning` (#5360). The wording says "declare", not "MUST", because the warning is what the code actually holds \u2014 it is tightened back only in the same change that promotes the warning to a refusal.'
|
|
5704
5768
|
),
|
|
5705
|
-
options:
|
|
5769
|
+
options: z9.array(z9.string().min(1).max(200)).min(2).max(10).optional().describe(
|
|
5706
5770
|
"Named alternatives for a multi-option proposal (#4472). When present, the threshold must ALSO be cleared by the leading option, in addition to the ordinary approve/reject bar: `unanimous` requires every approver to have chosen the SAME option, and `supermajority`/`majority` measure the leading option's share of approvers. An approving voter whose selection is absent or matches no declared option stays in the denominator and credits no option, so a degraded response can only lower the leading share, never raise it. Omit for an ordinary yes/no vote \u2014 behaviour is then unchanged."
|
|
5707
5771
|
),
|
|
5708
5772
|
project: VoterProjectInputSchema,
|
|
@@ -5715,12 +5779,12 @@ var ConsensusVoteInputSchema = z8.object({
|
|
|
5715
5779
|
errorPolicy: ErrorPolicySchema.optional().describe(
|
|
5716
5780
|
"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). Opt-in absolute_quorum (#4132): an errored voter \u2014 especially the contrarian (catfish) \u2014 degrades the verdict to no_quorum (recoverable re-run) instead of being dropped from the denominator; never manufactures approved/rejected from an induced error. Regardless of policy, errors > 50% always fails."
|
|
5717
5781
|
),
|
|
5718
|
-
quickMode:
|
|
5719
|
-
simulateVotes:
|
|
5782
|
+
quickMode: z9.boolean().optional().default(false).describe("Use 3 agents instead of the full 7-role panel for faster execution"),
|
|
5783
|
+
simulateVotes: z9.boolean().optional().default(false).describe(
|
|
5720
5784
|
"TESTS ONLY \u2014 when true, voters return random decisions. Output must not be used for real decisions. (#2319)"
|
|
5721
5785
|
),
|
|
5722
5786
|
/**
|
|
5723
|
-
* Async
|
|
5787
|
+
* Async dispatch (#3045, Stage 4 of epic #2631). Default `sync` —
|
|
5724
5788
|
* backward-compat invariant. `async` returns `{ status: 'pending', jobId }`
|
|
5725
5789
|
* immediately; caller polls `get_job_result(jobId)`. Per-tool cap via
|
|
5726
5790
|
* `NEXUS_JOB_MAX_CONCURRENT_CONSENSUS_VOTE` (default 2 — voting is
|
|
@@ -5733,19 +5797,20 @@ var ConsensusVoteInputSchema = z8.object({
|
|
|
5733
5797
|
* with whatever voters completed before the abort signal — preserves
|
|
5734
5798
|
* audit visibility into who voted before the cancel landed.
|
|
5735
5799
|
*
|
|
5736
|
-
*
|
|
5737
|
-
*
|
|
5800
|
+
* The key is `dispatch` (#4968); `mode` is the deprecated alias this tool
|
|
5801
|
+
* used to spell it with, resolved as `dispatch ?? mode` by the handler and
|
|
5802
|
+
* rejected when the two disagree (the `superRefine` below). Both optional
|
|
5803
|
+
* (no `.default()`) so the inferred type doesn't force a value onto every
|
|
5804
|
+
* existing call site / test fixture.
|
|
5738
5805
|
*/
|
|
5739
|
-
|
|
5740
|
-
'Dispatch mode (default: sync). Use "async" for higher-order strategies with 7 voters.'
|
|
5741
|
-
),
|
|
5806
|
+
...DEPRECATED_MODE_ALIAS_INPUT,
|
|
5742
5807
|
/**
|
|
5743
5808
|
* Idempotency key for async-mode replay-safety (#3042 Stage 1c / epic
|
|
5744
5809
|
* #2631). When set: identical (key, inputs) returns the existing job;
|
|
5745
5810
|
* same key with different inputs fails closed with
|
|
5746
5811
|
* `idempotency_key_collision`. Sync mode ignores this.
|
|
5747
5812
|
*/
|
|
5748
|
-
idempotencyKey:
|
|
5813
|
+
idempotencyKey: z9.string().min(1).max(256).optional().describe(
|
|
5749
5814
|
"Replay-safe key for async-mode dispatch (#3042 Stage 1c). Same (key, inputs) returns existing jobId."
|
|
5750
5815
|
),
|
|
5751
5816
|
/**
|
|
@@ -5757,7 +5822,7 @@ var ConsensusVoteInputSchema = z8.object({
|
|
|
5757
5822
|
* record and require `ratifies === transition.subject` (with decision=approved,
|
|
5758
5823
|
* strategy=higher_order). Omit on an ordinary vote.
|
|
5759
5824
|
*/
|
|
5760
|
-
ratifies:
|
|
5825
|
+
ratifies: z9.string().min(1).max(256).optional().describe(
|
|
5761
5826
|
"Authority-tier ratification subject (#4004) \u2014 the loop/strategy id this vote ratifies for an authority-ladder promotion. Bound into the authentic vote record so the promotion gate can verify it. Omit for ordinary votes."
|
|
5762
5827
|
),
|
|
5763
5828
|
/**
|
|
@@ -5773,15 +5838,16 @@ var ConsensusVoteInputSchema = z8.object({
|
|
|
5773
5838
|
ratifiesPr: VoteRecordPrBindingSchema.optional().describe(
|
|
5774
5839
|
"Governor-path PR ratification binding (#5130): pr is the PR number and headSha the full 40-hex head sha the panel reviewed. Bound into the authentic vote record so the committed ledger and the governor gate can verify which PR, at which head, this panel ratified. Omit for ordinary votes."
|
|
5775
5840
|
)
|
|
5776
|
-
|
|
5777
|
-
|
|
5841
|
+
// #4968: `dispatch` and the deprecated `mode` alias must agree when both are sent.
|
|
5842
|
+
}).superRefine(refineDispatchModeAgreement);
|
|
5843
|
+
var VoteDecisionStatusSchema = z9.enum([
|
|
5778
5844
|
"approved",
|
|
5779
5845
|
"rejected",
|
|
5780
5846
|
"pending",
|
|
5781
5847
|
"timeout",
|
|
5782
5848
|
"no_quorum"
|
|
5783
5849
|
]);
|
|
5784
|
-
var ContrarianCheckStatusSchema =
|
|
5850
|
+
var ContrarianCheckStatusSchema = z9.enum(["ok", "errored", "skipped"]);
|
|
5785
5851
|
function toRecordDecision(status) {
|
|
5786
5852
|
switch (status) {
|
|
5787
5853
|
case "approved":
|
|
@@ -6773,25 +6839,25 @@ import {
|
|
|
6773
6839
|
writeFileSync as writeFileSync4,
|
|
6774
6840
|
chmodSync
|
|
6775
6841
|
} from "node:fs";
|
|
6776
|
-
import { z as
|
|
6842
|
+
import { z as z11 } from "zod";
|
|
6777
6843
|
|
|
6778
6844
|
// src/mcp/jobs/job-idempotency.ts
|
|
6779
6845
|
import { createHash as createHash2, randomUUID } from "node:crypto";
|
|
6780
6846
|
import { existsSync as existsSync4, readFileSync as readFileSync5, writeFileSync as writeFileSync3 } from "node:fs";
|
|
6781
|
-
import { z as
|
|
6847
|
+
import { z as z10 } from "zod";
|
|
6782
6848
|
var logger7 = createLogger({ component: "job-idempotency" });
|
|
6783
|
-
var IdempotencyIndexEntrySchema =
|
|
6784
|
-
v:
|
|
6849
|
+
var IdempotencyIndexEntrySchema = z10.object({
|
|
6850
|
+
v: z10.literal(1),
|
|
6785
6851
|
/** MCP tool name (e.g. `orchestrate`, `run_workflow`, `consensus_vote`). */
|
|
6786
|
-
tool:
|
|
6852
|
+
tool: z10.string().min(1),
|
|
6787
6853
|
/** Caller-supplied idempotency key. */
|
|
6788
|
-
key:
|
|
6854
|
+
key: z10.string().min(1),
|
|
6789
6855
|
/** sha256 of the canonical input JSON. */
|
|
6790
|
-
inputsHash:
|
|
6856
|
+
inputsHash: z10.string().length(64),
|
|
6791
6857
|
/** Existing jobId for this (tool, key, inputs) tuple. */
|
|
6792
|
-
jobId:
|
|
6858
|
+
jobId: z10.string().min(1),
|
|
6793
6859
|
/** ISO timestamp of first dispatch. */
|
|
6794
|
-
createdAt:
|
|
6860
|
+
createdAt: z10.iso.datetime()
|
|
6795
6861
|
});
|
|
6796
6862
|
function sha256Hex(input) {
|
|
6797
6863
|
return createHash2("sha256").update(input).digest("hex");
|
|
@@ -6892,28 +6958,28 @@ function readIndexEntry(path2) {
|
|
|
6892
6958
|
|
|
6893
6959
|
// src/mcp/jobs/job-result-store.ts
|
|
6894
6960
|
var logger8 = createLogger({ component: "job-result-store" });
|
|
6895
|
-
var JobStatusSchema =
|
|
6896
|
-
var JobResultSchema =
|
|
6961
|
+
var JobStatusSchema = z11.enum(["pending", "complete", "failed", "cancelled"]);
|
|
6962
|
+
var JobResultSchema = z11.object({
|
|
6897
6963
|
/** Format version. Currently `1` — bump if the shape changes. */
|
|
6898
|
-
v:
|
|
6899
|
-
jobId:
|
|
6964
|
+
v: z11.literal(1),
|
|
6965
|
+
jobId: z11.string().min(1),
|
|
6900
6966
|
/** Tool that was invoked (e.g. `orchestrate`). */
|
|
6901
|
-
toolName:
|
|
6967
|
+
toolName: z11.string().min(1),
|
|
6902
6968
|
status: JobStatusSchema,
|
|
6903
|
-
createdAt:
|
|
6969
|
+
createdAt: z11.iso.datetime(),
|
|
6904
6970
|
/** Set when the job leaves `pending` — either via `complete` or `failed` or `cancelled`. */
|
|
6905
|
-
completedAt:
|
|
6971
|
+
completedAt: z11.iso.datetime().optional(),
|
|
6906
6972
|
/**
|
|
6907
6973
|
* Structured payload the synchronous mode would have returned. Present
|
|
6908
6974
|
* only when `status === 'complete'`. Shape is tool-specific — readers
|
|
6909
6975
|
* cast to the tool's known output type after status check.
|
|
6910
6976
|
*/
|
|
6911
|
-
result:
|
|
6977
|
+
result: z11.unknown().optional(),
|
|
6912
6978
|
/**
|
|
6913
6979
|
* Failure message when `status === 'failed'`. Cannot be paired with
|
|
6914
6980
|
* `result` — the discriminator is `status`.
|
|
6915
6981
|
*/
|
|
6916
|
-
error:
|
|
6982
|
+
error: z11.string().optional(),
|
|
6917
6983
|
/**
|
|
6918
6984
|
* Machine-readable reason for a `failed` record that was NOT settled by the
|
|
6919
6985
|
* process that ran the job (#6224). `abandoned` is written only by
|
|
@@ -6922,7 +6988,7 @@ var JobResultSchema = z10.object({
|
|
|
6922
6988
|
* the sweep rewrote it rather than deleting it. Absent on every record the
|
|
6923
6989
|
* job's own process wrote — `error` alone carries those failures.
|
|
6924
6990
|
*/
|
|
6925
|
-
errorKind:
|
|
6991
|
+
errorKind: z11.literal("abandoned").optional(),
|
|
6926
6992
|
/**
|
|
6927
6993
|
* Whether the tool's `run` callback accepts `runAsJob`'s `AbortSignal`
|
|
6928
6994
|
* (#4972).
|
|
@@ -6938,7 +7004,7 @@ var JobResultSchema = z10.object({
|
|
|
6938
7004
|
* "cancellation can reach this tool", not "the work stopped". Absent means
|
|
6939
7005
|
* the writer did not report it, which is not the same as `false`.
|
|
6940
7006
|
*/
|
|
6941
|
-
signalAccepted:
|
|
7007
|
+
signalAccepted: z11.boolean().optional(),
|
|
6942
7008
|
/**
|
|
6943
7009
|
* `VERSION` of the nexus-agents process that WROTE this record (#5008) —
|
|
6944
7010
|
* i.e. the build that ran the job, not the build that reads it back.
|
|
@@ -6959,7 +7025,7 @@ var JobResultSchema = z10.object({
|
|
|
6959
7025
|
* `'dev'` — readers MUST run it through {@link isMeasuredBuildVersion}
|
|
6960
7026
|
* before treating two stamps as comparable.
|
|
6961
7027
|
*/
|
|
6962
|
-
producerVersion:
|
|
7028
|
+
producerVersion: z11.string().optional()
|
|
6963
7029
|
});
|
|
6964
7030
|
var UNMEASURED_BUILD_VERSION = "dev";
|
|
6965
7031
|
function isMeasuredBuildVersion(version) {
|
|
@@ -7332,8 +7398,8 @@ import * as path from "node:path";
|
|
|
7332
7398
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
7333
7399
|
|
|
7334
7400
|
// src/context/structured-task-state-types.ts
|
|
7335
|
-
import { z as
|
|
7336
|
-
var TaskStageSchema =
|
|
7401
|
+
import { z as z12 } from "zod";
|
|
7402
|
+
var TaskStageSchema = z12.enum([
|
|
7337
7403
|
"planning",
|
|
7338
7404
|
"executing",
|
|
7339
7405
|
"verifying",
|
|
@@ -7345,64 +7411,64 @@ var TaskStageSchema = z11.enum([
|
|
|
7345
7411
|
// failed run in StructuredTaskState instead of the Stage-1 sidecar.
|
|
7346
7412
|
"failed"
|
|
7347
7413
|
]);
|
|
7348
|
-
var TaskDecisionSchema =
|
|
7349
|
-
ts:
|
|
7350
|
-
decision:
|
|
7351
|
-
rationale:
|
|
7414
|
+
var TaskDecisionSchema = z12.object({
|
|
7415
|
+
ts: z12.iso.datetime(),
|
|
7416
|
+
decision: z12.string().min(1),
|
|
7417
|
+
rationale: z12.string().min(1)
|
|
7352
7418
|
});
|
|
7353
|
-
var TaskBlockerSchema =
|
|
7354
|
-
ts:
|
|
7355
|
-
blocker:
|
|
7356
|
-
resolved:
|
|
7419
|
+
var TaskBlockerSchema = z12.object({
|
|
7420
|
+
ts: z12.iso.datetime(),
|
|
7421
|
+
blocker: z12.string().min(1),
|
|
7422
|
+
resolved: z12.iso.datetime().optional()
|
|
7357
7423
|
});
|
|
7358
|
-
var TaskPositionSchema =
|
|
7359
|
-
currentStep:
|
|
7360
|
-
nextStep:
|
|
7424
|
+
var TaskPositionSchema = z12.object({
|
|
7425
|
+
currentStep: z12.string().min(1),
|
|
7426
|
+
nextStep: z12.string().optional()
|
|
7361
7427
|
});
|
|
7362
|
-
var TaskLedgerSchema =
|
|
7428
|
+
var TaskLedgerSchema = z12.object({
|
|
7363
7429
|
/** Verifiable observations: what we have observed/measured/confirmed. */
|
|
7364
|
-
facts:
|
|
7430
|
+
facts: z12.array(z12.string()),
|
|
7365
7431
|
/** Working assumptions: useful guesses we proceed under, marked separately. */
|
|
7366
|
-
guesses:
|
|
7432
|
+
guesses: z12.array(z12.string()),
|
|
7367
7433
|
/** Things we still need to figure out before the plan is sound. */
|
|
7368
|
-
openQuestions:
|
|
7369
|
-
updatedAt:
|
|
7434
|
+
openQuestions: z12.array(z12.string()),
|
|
7435
|
+
updatedAt: z12.iso.datetime()
|
|
7370
7436
|
});
|
|
7371
|
-
var ReflectActionSchema =
|
|
7437
|
+
var ReflectActionSchema = z12.enum([
|
|
7372
7438
|
"continue",
|
|
7373
7439
|
"revise_plan",
|
|
7374
7440
|
"escalate_to_human",
|
|
7375
7441
|
"abort"
|
|
7376
7442
|
]);
|
|
7377
|
-
var ProgressLedgerEntrySchema =
|
|
7378
|
-
ts:
|
|
7443
|
+
var ProgressLedgerEntrySchema = z12.object({
|
|
7444
|
+
ts: z12.iso.datetime(),
|
|
7379
7445
|
/** What just happened (the step we are reflecting on). */
|
|
7380
|
-
step:
|
|
7446
|
+
step: z12.string().min(1),
|
|
7381
7447
|
/** Is the outer Task Ledger plan still right after this step? */
|
|
7382
|
-
planStillValid:
|
|
7448
|
+
planStillValid: z12.boolean(),
|
|
7383
7449
|
/** Are we making progress, or have we stalled? */
|
|
7384
|
-
stuck:
|
|
7450
|
+
stuck: z12.boolean(),
|
|
7385
7451
|
/** What the orchestrator should do next based on this reflection. */
|
|
7386
7452
|
suggestedAction: ReflectActionSchema,
|
|
7387
7453
|
/** Why this action was chosen — required so future readers can audit the call. */
|
|
7388
|
-
rationale:
|
|
7454
|
+
rationale: z12.string().min(1)
|
|
7389
7455
|
});
|
|
7390
|
-
var TaskCancellationSchema =
|
|
7391
|
-
requestedAt:
|
|
7456
|
+
var TaskCancellationSchema = z12.object({
|
|
7457
|
+
requestedAt: z12.iso.datetime(),
|
|
7392
7458
|
/** Optional human-readable note carried back to the caller. */
|
|
7393
|
-
reason:
|
|
7459
|
+
reason: z12.string().max(1e3).optional()
|
|
7394
7460
|
});
|
|
7395
7461
|
var TASK_RESULT_MAX_BYTES = 1048576;
|
|
7396
|
-
var StructuredTaskStateSchema =
|
|
7397
|
-
taskId:
|
|
7462
|
+
var StructuredTaskStateSchema = z12.object({
|
|
7463
|
+
taskId: z12.string().min(1),
|
|
7398
7464
|
/**
|
|
7399
7465
|
* Marks state created by the shared async-job dispatcher (#5622).
|
|
7400
7466
|
* Optional for backward compatibility; absence does not prove async dispatch.
|
|
7401
7467
|
*/
|
|
7402
|
-
dispatch:
|
|
7468
|
+
dispatch: z12.literal("async").optional(),
|
|
7403
7469
|
stage: TaskStageSchema,
|
|
7404
|
-
decisions:
|
|
7405
|
-
blockers:
|
|
7470
|
+
decisions: z12.array(TaskDecisionSchema),
|
|
7471
|
+
blockers: z12.array(TaskBlockerSchema),
|
|
7406
7472
|
position: TaskPositionSchema,
|
|
7407
7473
|
/**
|
|
7408
7474
|
* Magentic-One Task Ledger (#2278). Mutable single-object outer-loop state:
|
|
@@ -7415,7 +7481,7 @@ var StructuredTaskStateSchema = z11.object({
|
|
|
7415
7481
|
* Most recent entry's `suggestedAction` is what `reflect()` returns. Optional
|
|
7416
7482
|
* for the same backward-compat reason as `taskLedger`.
|
|
7417
7483
|
*/
|
|
7418
|
-
progressLedger:
|
|
7484
|
+
progressLedger: z12.array(ProgressLedgerEntrySchema).optional(),
|
|
7419
7485
|
/**
|
|
7420
7486
|
* Monotonic version counter (#3043 / epic #2631 Stage 2). Increments by
|
|
7421
7487
|
* 1 on every write; polling clients use this to detect "I missed a
|
|
@@ -7425,7 +7491,7 @@ var StructuredTaskStateSchema = z11.object({
|
|
|
7425
7491
|
* state logs (pre-Stage-2) don't carry it; the reducer treats their
|
|
7426
7492
|
* baseline as v0 and starts counting from there.
|
|
7427
7493
|
*/
|
|
7428
|
-
version:
|
|
7494
|
+
version: z12.number().int().nonnegative().optional(),
|
|
7429
7495
|
/**
|
|
7430
7496
|
* Tool result payload (#3043 / epic #2631 Stage 2). Set atomically
|
|
7431
7497
|
* via the `result` log event when `stage === 'complete'`. Carries the
|
|
@@ -7441,7 +7507,7 @@ var StructuredTaskStateSchema = z11.object({
|
|
|
7441
7507
|
* field, then the sidecar files become legacy that the next cleanup
|
|
7442
7508
|
* sweep can remove.
|
|
7443
7509
|
*/
|
|
7444
|
-
result:
|
|
7510
|
+
result: z12.unknown().optional(),
|
|
7445
7511
|
/**
|
|
7446
7512
|
* Cancellation marker (#3043 / epic #2631 Stage 2). Set by `cancel_job`
|
|
7447
7513
|
* — the running tool checks for this at safe-point boundaries (between
|
|
@@ -7458,70 +7524,70 @@ var StructuredTaskStateSchema = z11.object({
|
|
|
7458
7524
|
* transition has been recorded. Optional for backward-compat with
|
|
7459
7525
|
* pre-#3090 logs (the reducer backfills it from the init entry).
|
|
7460
7526
|
*/
|
|
7461
|
-
createdAt:
|
|
7462
|
-
updatedAt:
|
|
7527
|
+
createdAt: z12.iso.datetime().optional(),
|
|
7528
|
+
updatedAt: z12.iso.datetime()
|
|
7463
7529
|
});
|
|
7464
|
-
var StructuredTaskLogEntrySchema =
|
|
7465
|
-
|
|
7466
|
-
event:
|
|
7467
|
-
ts:
|
|
7530
|
+
var StructuredTaskLogEntrySchema = z12.discriminatedUnion("event", [
|
|
7531
|
+
z12.object({
|
|
7532
|
+
event: z12.literal("init"),
|
|
7533
|
+
ts: z12.iso.datetime(),
|
|
7468
7534
|
state: StructuredTaskStateSchema
|
|
7469
7535
|
}),
|
|
7470
|
-
|
|
7471
|
-
event:
|
|
7472
|
-
ts:
|
|
7536
|
+
z12.object({
|
|
7537
|
+
event: z12.literal("decision"),
|
|
7538
|
+
ts: z12.iso.datetime(),
|
|
7473
7539
|
decision: TaskDecisionSchema
|
|
7474
7540
|
}),
|
|
7475
|
-
|
|
7476
|
-
event:
|
|
7477
|
-
ts:
|
|
7541
|
+
z12.object({
|
|
7542
|
+
event: z12.literal("blocker"),
|
|
7543
|
+
ts: z12.iso.datetime(),
|
|
7478
7544
|
blocker: TaskBlockerSchema
|
|
7479
7545
|
}),
|
|
7480
|
-
|
|
7481
|
-
event:
|
|
7482
|
-
ts:
|
|
7546
|
+
z12.object({
|
|
7547
|
+
event: z12.literal("blocker_resolved"),
|
|
7548
|
+
ts: z12.iso.datetime(),
|
|
7483
7549
|
/** Index of the blocker in the state's blockers[] array. */
|
|
7484
|
-
blockerIndex:
|
|
7485
|
-
resolvedAt:
|
|
7550
|
+
blockerIndex: z12.number().int().nonnegative(),
|
|
7551
|
+
resolvedAt: z12.iso.datetime()
|
|
7486
7552
|
}),
|
|
7487
|
-
|
|
7488
|
-
event:
|
|
7489
|
-
ts:
|
|
7553
|
+
z12.object({
|
|
7554
|
+
event: z12.literal("stage"),
|
|
7555
|
+
ts: z12.iso.datetime(),
|
|
7490
7556
|
stage: TaskStageSchema
|
|
7491
7557
|
}),
|
|
7492
|
-
|
|
7493
|
-
event:
|
|
7494
|
-
ts:
|
|
7558
|
+
z12.object({
|
|
7559
|
+
event: z12.literal("position"),
|
|
7560
|
+
ts: z12.iso.datetime(),
|
|
7495
7561
|
position: TaskPositionSchema
|
|
7496
7562
|
}),
|
|
7497
7563
|
// Magentic-One Task Ledger replacement event — the outer loop revises the
|
|
7498
7564
|
// entire ledger atomically when replanning. Always replaces, never partial.
|
|
7499
|
-
|
|
7500
|
-
event:
|
|
7501
|
-
ts:
|
|
7565
|
+
z12.object({
|
|
7566
|
+
event: z12.literal("task_ledger"),
|
|
7567
|
+
ts: z12.iso.datetime(),
|
|
7502
7568
|
ledger: TaskLedgerSchema
|
|
7503
7569
|
}),
|
|
7504
7570
|
// Magentic-One Progress Ledger append event — one self-reflection per step.
|
|
7505
|
-
|
|
7506
|
-
event:
|
|
7507
|
-
ts:
|
|
7571
|
+
z12.object({
|
|
7572
|
+
event: z12.literal("progress_ledger"),
|
|
7573
|
+
ts: z12.iso.datetime(),
|
|
7508
7574
|
entry: ProgressLedgerEntrySchema
|
|
7509
7575
|
}),
|
|
7510
7576
|
// #3043 / epic #2631 Stage 2 — tool result payload set when stage flips
|
|
7511
7577
|
// to 'complete'. Written by appendResult; replayed into state.result.
|
|
7512
7578
|
// The payload itself is `unknown` because each tool's result shape is
|
|
7513
7579
|
// its own; readers cast after a status check.
|
|
7514
|
-
|
|
7515
|
-
event:
|
|
7516
|
-
ts:
|
|
7517
|
-
result:
|
|
7580
|
+
z12.object({
|
|
7581
|
+
event: z12.literal("result"),
|
|
7582
|
+
ts: z12.iso.datetime(),
|
|
7583
|
+
result: z12.unknown()
|
|
7518
7584
|
}),
|
|
7519
7585
|
// #3043 / epic #2631 Stage 2 — cancellation marker. Append-only: the
|
|
7520
7586
|
// reducer ignores a second cancellation event so a malicious or buggy
|
|
7521
7587
|
// double-cancel can't rewrite the requestedAt timestamp.
|
|
7522
|
-
|
|
7523
|
-
event:
|
|
7524
|
-
ts:
|
|
7588
|
+
z12.object({
|
|
7589
|
+
event: z12.literal("cancellation"),
|
|
7590
|
+
ts: z12.iso.datetime(),
|
|
7525
7591
|
cancellation: TaskCancellationSchema
|
|
7526
7592
|
})
|
|
7527
7593
|
]);
|
|
@@ -7842,7 +7908,7 @@ function defaultBusyEnvelope(retryAfterMs, toolName) {
|
|
|
7842
7908
|
JSON.stringify({
|
|
7843
7909
|
status: "busy",
|
|
7844
7910
|
retryAfterMs,
|
|
7845
|
-
note: `Async-mode concurrency cap reached for ${toolName}. Retry later or use
|
|
7911
|
+
note: `Async-mode concurrency cap reached for ${toolName}. Retry later or use dispatch: "sync".`
|
|
7846
7912
|
})
|
|
7847
7913
|
);
|
|
7848
7914
|
}
|
|
@@ -8453,26 +8519,30 @@ function createConsensusVoteHandler(deps) {
|
|
|
8453
8519
|
if (!simCheck.allowed) return simulationDeniedResult(simCheck.reason);
|
|
8454
8520
|
}
|
|
8455
8521
|
const strategy = validationResult.data.strategy ?? "simple_majority";
|
|
8522
|
+
const dispatch = resolveDispatch(validationResult.data);
|
|
8523
|
+
const modeWarning = deprecatedModeWarning(validationResult.data);
|
|
8456
8524
|
ctx.logger.debug("Starting consensus vote", {
|
|
8457
8525
|
strategy,
|
|
8458
8526
|
quickMode: validationResult.data.quickMode,
|
|
8459
|
-
...
|
|
8527
|
+
...dispatch !== void 0 ? { dispatch } : {}
|
|
8460
8528
|
});
|
|
8461
8529
|
notifier.info("consensus_vote", {
|
|
8462
8530
|
event: "vote_start",
|
|
8463
8531
|
proposalLength: validationResult.data.proposal.length,
|
|
8464
8532
|
strategy
|
|
8465
8533
|
});
|
|
8466
|
-
if (
|
|
8534
|
+
if (dispatch === "async") {
|
|
8467
8535
|
const asyncResult = dispatchAsyncConsensusVote(deps, validationResult.data);
|
|
8468
8536
|
notifier.info("consensus_vote", {
|
|
8469
8537
|
event: "vote_dispatched_async",
|
|
8470
8538
|
proposalLength: validationResult.data.proposal.length,
|
|
8471
8539
|
strategy
|
|
8472
8540
|
});
|
|
8473
|
-
return asyncResult;
|
|
8541
|
+
return withWarnings(asyncResult, [modeWarning]);
|
|
8474
8542
|
}
|
|
8475
|
-
return runSyncConsensusVote(deps, notifier, validationResult.data)
|
|
8543
|
+
return withWarnings(await runSyncConsensusVote(deps, notifier, validationResult.data), [
|
|
8544
|
+
modeWarning
|
|
8545
|
+
]);
|
|
8476
8546
|
};
|
|
8477
8547
|
}
|
|
8478
8548
|
var ASYNC_ENVELOPES = {
|
|
@@ -8485,7 +8555,7 @@ var ASYNC_ENVELOPES = {
|
|
|
8485
8555
|
busy: (retryAfterMs, toolName) => toolSuccessStructured({
|
|
8486
8556
|
status: "busy",
|
|
8487
8557
|
retryAfterMs,
|
|
8488
|
-
note: `Async-mode concurrency cap reached for ${toolName}. Retry later or use
|
|
8558
|
+
note: `Async-mode concurrency cap reached for ${toolName}. Retry later or use dispatch: "sync".`
|
|
8489
8559
|
}),
|
|
8490
8560
|
replay: (jobId) => toolSuccessStructured({
|
|
8491
8561
|
status: "replay",
|
|
@@ -8497,49 +8567,49 @@ var ASYNC_ENVELOPES = {
|
|
|
8497
8567
|
};
|
|
8498
8568
|
var CONSENSUS_VOTE_OUTPUT_SCHEMA = {
|
|
8499
8569
|
/** Async-dispatch envelope discriminator — absent on a completed vote. */
|
|
8500
|
-
status:
|
|
8501
|
-
jobId:
|
|
8502
|
-
pollTool:
|
|
8503
|
-
note:
|
|
8504
|
-
retryAfterMs:
|
|
8505
|
-
proposal:
|
|
8570
|
+
status: z13.enum(["pending", "busy", "replay"]).optional(),
|
|
8571
|
+
jobId: z13.string().max(200).optional(),
|
|
8572
|
+
pollTool: z13.literal("get_job_result").optional(),
|
|
8573
|
+
note: z13.string().max(500).optional(),
|
|
8574
|
+
retryAfterMs: z13.number().optional(),
|
|
8575
|
+
proposal: z13.string().optional(),
|
|
8506
8576
|
strategy: VotingStrategySchema.optional(),
|
|
8507
8577
|
// Reuses the canonical VoteDecisionStatusSchema (single source) — a hand-listed
|
|
8508
8578
|
// subset here (was ['approved','rejected','no_quorum']) omitted the reachable
|
|
8509
8579
|
// 'timeout'/'pending' outcomes and made strict clients reject those votes (#4032).
|
|
8510
8580
|
decision: VoteDecisionStatusSchema.optional(),
|
|
8511
|
-
approvalPercentage:
|
|
8512
|
-
voteCounts:
|
|
8513
|
-
approve:
|
|
8514
|
-
reject:
|
|
8515
|
-
abstain:
|
|
8516
|
-
error:
|
|
8581
|
+
approvalPercentage: z13.number().optional(),
|
|
8582
|
+
voteCounts: z13.object({
|
|
8583
|
+
approve: z13.number(),
|
|
8584
|
+
reject: z13.number(),
|
|
8585
|
+
abstain: z13.number(),
|
|
8586
|
+
error: z13.number(),
|
|
8517
8587
|
/** #6094: seats that could not read the artifact; always present. */
|
|
8518
|
-
unverifiable:
|
|
8588
|
+
unverifiable: z13.number()
|
|
8519
8589
|
}).optional(),
|
|
8520
8590
|
// #6111: the quick-mode contrarian check is not a seat, so `voteCounts.error`
|
|
8521
8591
|
// cannot count it. Present on every completed vote (`skipped` when it did not
|
|
8522
8592
|
// run); optional here only because the async envelope shares this schema.
|
|
8523
8593
|
contrarianCheck: ContrarianCheckStatusSchema.optional(),
|
|
8524
|
-
votes:
|
|
8525
|
-
|
|
8526
|
-
role:
|
|
8527
|
-
decision:
|
|
8528
|
-
confidence:
|
|
8529
|
-
reasoning:
|
|
8530
|
-
simulated:
|
|
8531
|
-
error:
|
|
8594
|
+
votes: z13.array(
|
|
8595
|
+
z13.object({
|
|
8596
|
+
role: z13.string().max(100),
|
|
8597
|
+
decision: z13.enum(["approve", "reject", "abstain"]),
|
|
8598
|
+
confidence: z13.number(),
|
|
8599
|
+
reasoning: z13.string().max(4e3),
|
|
8600
|
+
simulated: z13.boolean(),
|
|
8601
|
+
error: z13.boolean(),
|
|
8532
8602
|
/** #6094: present only when the seat could not read the artifact. */
|
|
8533
|
-
unverifiable:
|
|
8603
|
+
unverifiable: z13.literal(true).optional(),
|
|
8534
8604
|
/** #6115: present only when the seat answered elsewhere than assigned. */
|
|
8535
|
-
fallback:
|
|
8536
|
-
fromCli:
|
|
8537
|
-
fromModel:
|
|
8538
|
-
reason:
|
|
8605
|
+
fallback: z13.object({
|
|
8606
|
+
fromCli: z13.string().max(100),
|
|
8607
|
+
fromModel: z13.string().max(100).optional(),
|
|
8608
|
+
reason: z13.enum(["rate-limit", "capacity", "auth", "timeout", "sandbox", "unknown"])
|
|
8539
8609
|
}).optional(),
|
|
8540
|
-
modelUsed:
|
|
8541
|
-
rejectionCategories:
|
|
8542
|
-
|
|
8610
|
+
modelUsed: z13.string().max(100).optional(),
|
|
8611
|
+
rejectionCategories: z13.array(
|
|
8612
|
+
z13.enum([
|
|
8543
8613
|
"YAGNI",
|
|
8544
8614
|
"DRY_VIOLATION",
|
|
8545
8615
|
"OVER_ENGINEERING",
|
|
@@ -8552,48 +8622,48 @@ var CONSENSUS_VOTE_OUTPUT_SCHEMA = {
|
|
|
8552
8622
|
})
|
|
8553
8623
|
).optional(),
|
|
8554
8624
|
threshold: VoteThresholdSchema.optional(),
|
|
8555
|
-
durationMs:
|
|
8556
|
-
simulateVotes:
|
|
8625
|
+
durationMs: z13.number().optional(),
|
|
8626
|
+
simulateVotes: z13.boolean().optional(),
|
|
8557
8627
|
// #6110: the project the panel judged and how the name was decided. Always
|
|
8558
8628
|
// on the response; optional here like every field, because the async
|
|
8559
8629
|
// `pending` envelope shares this schema.
|
|
8560
|
-
project:
|
|
8561
|
-
name:
|
|
8562
|
-
source:
|
|
8630
|
+
project: z13.object({
|
|
8631
|
+
name: z13.string().max(200),
|
|
8632
|
+
source: z13.enum(["input", "derived", "default"])
|
|
8563
8633
|
}).optional(),
|
|
8564
|
-
higherOrderMetadata:
|
|
8565
|
-
posteriorApproval:
|
|
8566
|
-
posteriorRejection:
|
|
8567
|
-
effectiveVoteCount:
|
|
8568
|
-
method:
|
|
8569
|
-
usedCorrelationData:
|
|
8570
|
-
improvementOverBaseline:
|
|
8571
|
-
downweightedAgents:
|
|
8572
|
-
reasoning:
|
|
8634
|
+
higherOrderMetadata: z13.object({
|
|
8635
|
+
posteriorApproval: z13.number(),
|
|
8636
|
+
posteriorRejection: z13.number(),
|
|
8637
|
+
effectiveVoteCount: z13.number(),
|
|
8638
|
+
method: z13.enum(["ow", "isp", "simple"]),
|
|
8639
|
+
usedCorrelationData: z13.boolean(),
|
|
8640
|
+
improvementOverBaseline: z13.number(),
|
|
8641
|
+
downweightedAgents: z13.array(z13.string().max(100)).max(10),
|
|
8642
|
+
reasoning: z13.string().max(2e3)
|
|
8573
8643
|
}).optional(),
|
|
8574
8644
|
// #3124: explains a `rejected` decision that coexists with a high
|
|
8575
8645
|
// approvalPercentage (an error-policy short-circuit, e.g. fail_closed).
|
|
8576
|
-
policyReason:
|
|
8646
|
+
policyReason: z13.string().max(200).optional(),
|
|
8577
8647
|
// #3991: whether the authentic vote record was persisted at vote time. Post-
|
|
8578
8648
|
// #3991 it routes through nexusDataPath under governance/, so true is the
|
|
8579
8649
|
// normal case; false means all-simulated (skipped by design) or write-failed
|
|
8580
8650
|
// (data dir unwritable) — voteRecordNote carries the actionable reason. Makes
|
|
8581
8651
|
// a previously WARN-only skip visible to MCP callers.
|
|
8582
|
-
voteRecordPersisted:
|
|
8583
|
-
voteRecordNote:
|
|
8652
|
+
voteRecordPersisted: z13.boolean().optional(),
|
|
8653
|
+
voteRecordNote: z13.string().max(500).optional(),
|
|
8584
8654
|
// #5130: the persisted record's id, so the caller-commits script can name it.
|
|
8585
|
-
voteRecordId:
|
|
8655
|
+
voteRecordId: z13.string().max(200).optional(),
|
|
8586
8656
|
// #3587: set when the panel DEGRADED (some voters errored), so the decision
|
|
8587
8657
|
// rests on fewer voters than requested. Part of the response since #3587 but
|
|
8588
8658
|
// omitted from this schema until #4032 — its absence made a strict MCP client
|
|
8589
8659
|
// reject any degraded-panel vote (`-32602 additional properties`).
|
|
8590
|
-
panelWarning:
|
|
8660
|
+
panelWarning: z13.string().optional(),
|
|
8591
8661
|
// #6115: distinct answering models and seats that answered elsewhere than
|
|
8592
8662
|
// assigned. Always on the response (explicit zeros); optional here only
|
|
8593
8663
|
// because the async `pending` envelope shares this schema.
|
|
8594
|
-
panelDiversity:
|
|
8595
|
-
distinctModels:
|
|
8596
|
-
fallbacks:
|
|
8664
|
+
panelDiversity: z13.object({
|
|
8665
|
+
distinctModels: z13.number().int().nonnegative(),
|
|
8666
|
+
fallbacks: z13.number().int().nonnegative()
|
|
8597
8667
|
}).optional(),
|
|
8598
8668
|
// #3855: per-decision cost rollup. Same omission as panelWarning (#4032) — it
|
|
8599
8669
|
// is present on the response whenever cost recording succeeds (common in `api`
|
|
@@ -8602,22 +8672,22 @@ var CONSENSUS_VOTE_OUTPUT_SCHEMA = {
|
|
|
8602
8672
|
// #4472: declared-option outcome. Present whenever the proposal declared
|
|
8603
8673
|
// `options`. `unattributedApprovals` is part of the contract, not telemetry:
|
|
8604
8674
|
// without it a caller cannot tell a real split from unreadable responses.
|
|
8605
|
-
optionOutcome:
|
|
8606
|
-
tally:
|
|
8607
|
-
leadingOption:
|
|
8608
|
-
leadingShare:
|
|
8609
|
-
approverCount:
|
|
8610
|
-
selectedCount:
|
|
8611
|
-
unattributedApprovals:
|
|
8612
|
-
thresholdMet:
|
|
8675
|
+
optionOutcome: z13.object({
|
|
8676
|
+
tally: z13.array(z13.object({ option: z13.string(), count: z13.number().int().nonnegative() })),
|
|
8677
|
+
leadingOption: z13.string().optional(),
|
|
8678
|
+
leadingShare: z13.number().min(0).max(1),
|
|
8679
|
+
approverCount: z13.number().int().nonnegative(),
|
|
8680
|
+
selectedCount: z13.number().int().nonnegative(),
|
|
8681
|
+
unattributedApprovals: z13.number().int().nonnegative(),
|
|
8682
|
+
thresholdMet: z13.boolean(),
|
|
8613
8683
|
// #4529: present only on a veto. Declared here because a strict MCP
|
|
8614
8684
|
// client rejects any property the advertised schema omits — the same
|
|
8615
8685
|
// drift that made degraded-panel votes unusable before #4032.
|
|
8616
|
-
vetoReason:
|
|
8686
|
+
vetoReason: z13.string().max(400).optional()
|
|
8617
8687
|
}).optional()
|
|
8618
8688
|
};
|
|
8619
8689
|
var CONSENSUS_VOTE_TOOL_SCHEMA = ConsensusVoteInputSchema.shape;
|
|
8620
|
-
var CONSENSUS_VOTE_DESCRIPTION = "Execute multi-model consensus voting on a proposal. Uses 7 roles by default (architect, security, devex, ai_ml, pm, catfish, scope_steward) or 3 with quickMode (architect, security, scope_steward), voting with configurable strategies. higher_order does NOT decide the verdict by correlation-aware aggregation (#4701): approve/reject is a simple tally of the panel, so correlated voters each carry full independent weight. The Bayesian correlation analysis is computed and feeds contrarian escalation only. Choose it for the escalation behaviour, not for a weighted verdict. Supports async
|
|
8690
|
+
var CONSENSUS_VOTE_DESCRIPTION = "Execute multi-model consensus voting on a proposal. Uses 7 roles by default (architect, security, devex, ai_ml, pm, catfish, scope_steward) or 3 with quickMode (architect, security, scope_steward), voting with configurable strategies. higher_order does NOT decide the verdict by correlation-aware aggregation (#4701): approve/reject is a simple tally of the panel, so correlated voters each carry full independent weight. The Bayesian correlation analysis is computed and feeds contrarian escalation only. Choose it for the escalation behaviour, not for a weighted verdict. Supports async dispatch (dispatch: 'async'; `mode` is a deprecated alias) \u2014 returns a jobId to poll via get_job_result. Pass ratifies=<subject> to bind an authority-ladder ratification vote into its authentic record, and ratifiesPr={pr, headSha} to bind a governor-path PR ratification to the head the panel saw (#5130); the result carries voteRecordId for the caller-commits append. If your proposal asks voters to choose among named alternatives, you MUST pass them in `options` (#4472) \u2014 the threshold is then measured over WHICH option won, and the record carries the per-option tally plus selection coverage. WITHOUT `options` the tally is approve/reject/abstain only, so every voter who engages returns `approve` and a 6-1 split on which option persists as 7-0, 100% (#4452).";
|
|
8621
8691
|
function registerConsensusVoteTool(server, deps) {
|
|
8622
8692
|
const logger11 = deps.logger ?? createLogger({ tool: "consensus_vote" });
|
|
8623
8693
|
const notifier = deps.notifier ?? createMcpNotifier(server);
|
|
@@ -8647,6 +8717,15 @@ function registerConsensusVoteTool(server, deps) {
|
|
|
8647
8717
|
|
|
8648
8718
|
export {
|
|
8649
8719
|
VOTER_ROLES,
|
|
8720
|
+
dispatchFieldDefaultSync,
|
|
8721
|
+
asyncDispatchInput,
|
|
8722
|
+
asyncDispatchInputDefaultSync,
|
|
8723
|
+
modeEnumErrorNamingDispatch,
|
|
8724
|
+
DEPRECATED_MODE_ALIAS_INPUT,
|
|
8725
|
+
refineDispatchModeAgreement,
|
|
8726
|
+
resolveDispatch,
|
|
8727
|
+
deprecatedModeWarning,
|
|
8728
|
+
withWarnings,
|
|
8650
8729
|
resolveIdempotency,
|
|
8651
8730
|
registerIdempotentJob,
|
|
8652
8731
|
JobStatusSchema,
|
|
@@ -8726,6 +8805,7 @@ export {
|
|
|
8726
8805
|
createCorrelationTracker,
|
|
8727
8806
|
seatFallbacks,
|
|
8728
8807
|
panelDiversityOf,
|
|
8808
|
+
VoteRecordPrBindingSchema,
|
|
8729
8809
|
VotingStrategySchema,
|
|
8730
8810
|
ErrorPolicySchema,
|
|
8731
8811
|
VoteThresholdSchema,
|
|
@@ -8747,4 +8827,4 @@ export {
|
|
|
8747
8827
|
CONSENSUS_VOTE_TOOL_SCHEMA,
|
|
8748
8828
|
registerConsensusVoteTool
|
|
8749
8829
|
};
|
|
8750
|
-
//# sourceMappingURL=chunk-
|
|
8830
|
+
//# sourceMappingURL=chunk-C4DQ6FON.js.map
|