nexus-agents 2.150.4 → 2.151.1

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.
@@ -8,7 +8,7 @@ import {
8
8
  checkSqlite,
9
9
  defaultConfig,
10
10
  initDataDirectories
11
- } from "./chunk-UIUTDHRX.js";
11
+ } from "./chunk-SJFARLAQ.js";
12
12
  import {
13
13
  BUILT_IN_EXPERTS
14
14
  } from "./chunk-ZM4O442V.js";
@@ -2000,4 +2000,4 @@ export {
2000
2000
  setupCommand,
2001
2001
  setupCommandAsync
2002
2002
  };
2003
- //# sourceMappingURL=chunk-4ELTYI33.js.map
2003
+ //# sourceMappingURL=chunk-QL4Q3HUO.js.map
@@ -42,7 +42,7 @@ import {
42
42
  } from "./chunk-DHVMSIT5.js";
43
43
 
44
44
  // src/version.ts
45
- var VERSION = true ? "2.150.4" : "dev";
45
+ var VERSION = true ? "2.151.1" : "dev";
46
46
 
47
47
  // src/config/schemas-core.ts
48
48
  import { z } from "zod";
@@ -2132,7 +2132,7 @@ async function runDoctorFix(result) {
2132
2132
  writeLine2("\u2500".repeat(40));
2133
2133
  let fixCount = 0;
2134
2134
  if (!result.dataDirectory.rootExists || result.dataDirectory.subdirectories.some((d) => !d.exists || !d.writable)) {
2135
- const { runSetup } = await import("./setup-command-OL2A2GCI.js");
2135
+ const { runSetup } = await import("./setup-command-IQ7WFZIM.js");
2136
2136
  const setupResult = runSetup({
2137
2137
  skipMcp: true,
2138
2138
  skipRules: true,
@@ -2245,4 +2245,4 @@ export {
2245
2245
  startStdioServer,
2246
2246
  closeServer
2247
2247
  };
2248
- //# sourceMappingURL=chunk-UIUTDHRX.js.map
2248
+ //# sourceMappingURL=chunk-SJFARLAQ.js.map
@@ -4305,7 +4305,12 @@ var HIGHER_ORDER_ESCALATION_POSTERIOR_FLOOR = 0.65;
4305
4305
  function shouldEscalateLowPosterior(strategy, outcome, quickMode, posteriorApproval) {
4306
4306
  return quickMode && outcome === "approved" && isHigherOrderStrategy(strategy) && posteriorApproval !== void 0 && posteriorApproval < HIGHER_ORDER_ESCALATION_POSTERIOR_FLOOR;
4307
4307
  }
4308
- var ErrorPolicySchema = z6.enum(["reduce_denominator", "count_as_abstain", "fail_closed"]);
4308
+ var ErrorPolicySchema = z6.enum([
4309
+ "reduce_denominator",
4310
+ "count_as_abstain",
4311
+ "fail_closed",
4312
+ "absolute_quorum"
4313
+ ]);
4309
4314
  var VoteThresholdSchema = z6.enum(["majority", "supermajority", "unanimous"]);
4310
4315
  var ERROR_FLOOR_FRACTION = 0.5;
4311
4316
  function getDefaultErrorPolicy(strategy) {
@@ -4323,7 +4328,7 @@ var ConsensusVoteInputSchema = z6.object({
4323
4328
  "Voting strategy: simple_majority (default), supermajority, unanimous, proof_of_learning, or higher_order (Bayesian-optimal)"
4324
4329
  ),
4325
4330
  errorPolicy: ErrorPolicySchema.optional().describe(
4326
- "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."
4331
+ "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."
4327
4332
  ),
4328
4333
  quickMode: z6.boolean().optional().default(false).describe("Use 3 agents instead of the full 7-role panel for faster execution"),
4329
4334
  simulateVotes: z6.boolean().optional().default(false).describe(
@@ -4406,12 +4411,69 @@ function panelDegradationWarning(errorCount, total) {
4406
4411
  if (errorCount <= 0 || errorCount >= total) return void 0;
4407
4412
  return `Panel degraded: ${String(errorCount)} of ${String(total)} voters errored; decision rests on ${String(total - errorCount)} voter(s).`;
4408
4413
  }
4414
+ var degradedPanelCount = 0;
4415
+ function absoluteQuorumFraction(strategy) {
4416
+ switch (strategy) {
4417
+ case "supermajority":
4418
+ return 2 / 3;
4419
+ case "unanimous":
4420
+ return 1;
4421
+ default:
4422
+ return 0.5;
4423
+ }
4424
+ }
4425
+ function absoluteQuorumDegradeReason(result, errorCount) {
4426
+ const contrarianVote = result.votes.find((v) => v.role === "catfish");
4427
+ const contrarianOk = contrarianVote !== void 0 && contrarianVote.source !== "error";
4428
+ const contrarianDegraded = result.contrarianRequested === true && !contrarianOk;
4429
+ if (errorCount === 0 && !contrarianDegraded) return void 0;
4430
+ const erroredRoles = result.votes.filter((v) => v.source === "error").map((v) => v.role);
4431
+ const named = contrarianDegraded && !erroredRoles.includes("catfish") ? [...erroredRoles, "catfish"] : erroredRoles;
4432
+ const list = named.length > 0 ? named.join(", ") : "contrarian";
4433
+ return `no_quorum: re-run \u2014 voter(s) [${list}] errored (absolute_quorum)`;
4434
+ }
4435
+ function computeAbsoluteQuorumDecision(result, errorCount, allErrors) {
4436
+ const degradeReason = absoluteQuorumDegradeReason(result, errorCount);
4437
+ if (degradeReason !== void 0) return { decision: "no_quorum", degradeReason };
4438
+ const panel = result.panelSize ?? result.votes.length;
4439
+ const needed = Math.ceil(absoluteQuorumFraction(result.strategy) * panel);
4440
+ const approveCount = result.votes.filter(
4441
+ (v) => v.source !== "error" && v.vote.decision === "approve"
4442
+ ).length;
4443
+ if (result.result.outcome === "approved" && approveCount >= needed) {
4444
+ return { decision: "approved" };
4445
+ }
4446
+ if (result.result.outcome === "rejected" && !allErrors) {
4447
+ return { decision: "rejected" };
4448
+ }
4449
+ return {
4450
+ decision: "no_quorum",
4451
+ degradeReason: `no_quorum: absolute quorum not met (${String(approveCount)}/${String(needed)} approvals over ${String(panel)}-voter panel, absolute_quorum)`
4452
+ };
4453
+ }
4454
+ function resolveVoteDecision(input, result, errorCount) {
4455
+ const allErrors = errorCount === result.votes.length && errorCount > 0;
4456
+ if (result.policyReason !== void 0 || !result.result.quorumReached && allErrors) {
4457
+ return { decision: "no_quorum" };
4458
+ }
4459
+ if (input.errorPolicy === "absolute_quorum") {
4460
+ return computeAbsoluteQuorumDecision(result, errorCount, allErrors);
4461
+ }
4462
+ return { decision: mapOutcomeToDecision(result.result.outcome) };
4463
+ }
4464
+ function applyAbsoluteQuorumTelemetry(response, input, decision, degradeReason) {
4465
+ if (input.errorPolicy === "absolute_quorum" && decision === "no_quorum") {
4466
+ degradedPanelCount++;
4467
+ }
4468
+ if (degradeReason !== void 0) {
4469
+ response.policyReason ??= degradeReason;
4470
+ response.panelWarning ??= degradeReason;
4471
+ }
4472
+ }
4409
4473
  function buildResponse(input, result, costSummary, voteRecord) {
4410
4474
  const proposalTruncated = input.proposal.length > 200 ? input.proposal.slice(0, 200) + "..." : input.proposal;
4411
4475
  const errorCount = result.votes.filter((v) => v.source === "error").length;
4412
- const allErrors = errorCount === result.votes.length && errorCount > 0;
4413
- const errorVoidedVote = result.policyReason !== void 0;
4414
- const decision = errorVoidedVote || !result.result.quorumReached && allErrors ? "no_quorum" : mapOutcomeToDecision(result.result.outcome);
4476
+ const { decision, degradeReason } = resolveVoteDecision(input, result, errorCount);
4415
4477
  const response = {
4416
4478
  proposal: proposalTruncated,
4417
4479
  strategy: result.strategy,
@@ -4434,6 +4496,7 @@ function buildResponse(input, result, costSummary, voteRecord) {
4434
4496
  response.voteRecordNote = voteRecord.detail;
4435
4497
  }
4436
4498
  applyOptionalResponseFields(response, input, result, errorCount, costSummary);
4499
+ applyAbsoluteQuorumTelemetry(response, input, decision, degradeReason);
4437
4500
  return response;
4438
4501
  }
4439
4502
  function applyOptionalResponseFields(response, input, result, errorCount, costSummary) {
@@ -4490,7 +4553,7 @@ function applyErrorPolicy(votes, policy) {
4490
4553
  engineVotes: []
4491
4554
  };
4492
4555
  }
4493
- if (policy === "count_as_abstain") {
4556
+ if (policy === "count_as_abstain" || policy === "absolute_quorum") {
4494
4557
  return {
4495
4558
  shortCircuit: false,
4496
4559
  engineVotes: votes.map(
@@ -5825,9 +5888,10 @@ async function runContrarianCheck(proposal, log) {
5825
5888
  '{"decision":"approve","confidence":0.0-1.0,"reasoning":"why it is acceptable"}'
5826
5889
  ].join("\n");
5827
5890
  const result = await executeExpert("architecture", prompt);
5828
- if (!result.success) return { shouldEscalate: false, reason: "", confidence: 0 };
5891
+ if (!result.success) return { shouldEscalate: false, reason: "", confidence: 0, errored: true };
5829
5892
  const jsonMatch = result.text.match(/\{[\s\S]*\}/);
5830
- if (jsonMatch === null) return { shouldEscalate: false, reason: "", confidence: 0 };
5893
+ if (jsonMatch === null)
5894
+ return { shouldEscalate: false, reason: "", confidence: 0, errored: false };
5831
5895
  const parsed = JSON.parse(jsonMatch[0]);
5832
5896
  const isRejection = parsed.decision === "reject";
5833
5897
  const confidence = typeof parsed.confidence === "number" ? parsed.confidence : 0;
@@ -5837,13 +5901,13 @@ async function runContrarianCheck(proposal, log) {
5837
5901
  confidence,
5838
5902
  reasoning: reasoning.slice(0, 200)
5839
5903
  });
5840
- return { shouldEscalate: true, reason: reasoning, confidence };
5904
+ return { shouldEscalate: true, reason: reasoning, confidence, errored: false };
5841
5905
  }
5842
- return { shouldEscalate: false, reason: "", confidence };
5906
+ return { shouldEscalate: false, reason: "", confidence, errored: false };
5843
5907
  } catch (error) {
5844
5908
  const message = error instanceof Error ? error.message : String(error);
5845
5909
  log.warn("Contrarian check failed; defaulting to no escalation", { error: message });
5846
- return { shouldEscalate: false, reason: "", confidence: 0 };
5910
+ return { shouldEscalate: false, reason: "", confidence: 0, errored: true };
5847
5911
  }
5848
5912
  }
5849
5913
  function buildPolicyShortCircuitResult(args) {
@@ -5860,27 +5924,37 @@ function buildPolicyShortCircuitResult(args) {
5860
5924
  totalTimeMs,
5861
5925
  simulateVotes: args.input.simulateVotes,
5862
5926
  strategy: args.strategy,
5927
+ // #4132: thread the requested panel shape so the absolute_quorum predicate
5928
+ // in buildResponse has PANEL_SIZE + contrarian-presence even on a short-circuit.
5929
+ panelSize: args.roles.length,
5930
+ contrarianRequested: args.roles.includes("catfish"),
5863
5931
  // #3124: surface WHY a high-approval result is still 'rejected' so callers
5864
5932
  // don't mistake a fail-closed policy short-circuit for a genuine rejection.
5865
5933
  policyReason: args.reason
5866
5934
  };
5867
5935
  }
5868
5936
  async function maybeEscalateContrarian(input, outcome, ctx, logger10, opts) {
5869
- if (!input.quickMode || outcome !== "approved" || input.simulateVotes) return void 0;
5937
+ if (!input.quickMode || outcome !== "approved" || input.simulateVotes) return {};
5870
5938
  if (shouldEscalateLowPosterior(ctx.strategy, outcome, input.quickMode, ctx.posteriorApproval)) {
5871
5939
  logger10.warn("Posterior-confidence escalation: re-running with full vote (#3174)", {
5872
5940
  strategy: ctx.strategy,
5873
5941
  posteriorApproval: ctx.posteriorApproval
5874
5942
  });
5875
- return executeVoting({ ...input, quickMode: false }, logger10, opts);
5943
+ return { escalated: await executeVoting({ ...input, quickMode: false }, logger10, opts) };
5876
5944
  }
5877
5945
  const escalation = await runContrarianCheck(input.proposal, logger10);
5878
- if (!escalation.shouldEscalate) return void 0;
5946
+ if (escalation.errored && input.errorPolicy === "absolute_quorum") {
5947
+ logger10.warn("Contrarian check errored under absolute_quorum \u2014 degrading to no_quorum (#4132)");
5948
+ return {
5949
+ degradeReason: "no_quorum: re-run \u2014 contrarian check errored (absolute_quorum quick-mode)"
5950
+ };
5951
+ }
5952
+ if (!escalation.shouldEscalate) return {};
5879
5953
  logger10.warn("Contrarian escalation: re-running with full vote", {
5880
5954
  reason: escalation.reason,
5881
5955
  confidence: escalation.confidence
5882
5956
  });
5883
- return executeVoting({ ...input, quickMode: false }, logger10, opts);
5957
+ return { escalated: await executeVoting({ ...input, quickMode: false }, logger10, opts) };
5884
5958
  }
5885
5959
  async function executeVoting(input, logger10, opts) {
5886
5960
  const strategy = resolveStrategy(input);
@@ -5907,6 +5981,7 @@ async function executeVoting(input, logger10, opts) {
5907
5981
  input,
5908
5982
  strategy,
5909
5983
  algorithm,
5984
+ roles,
5910
5985
  votes,
5911
5986
  errorPolicy,
5912
5987
  reason: policyDecision.reason ?? "error policy short-circuit",
@@ -5925,18 +6000,19 @@ async function executeVoting(input, logger10, opts) {
5925
6000
  }
5926
6001
  );
5927
6002
  recordVotesToTracker(votes, outcome, logger10);
5928
- const escalated = await maybeEscalateContrarian(
6003
+ const escalation = await maybeEscalateContrarian(
5929
6004
  input,
5930
6005
  outcome,
5931
6006
  { strategy, posteriorApproval: higherOrderResult?.posteriorApproval },
5932
6007
  logger10,
5933
6008
  opts
5934
6009
  );
5935
- if (escalated !== void 0) return escalated;
5936
- return finalizeVotingResult({
6010
+ if (escalation.escalated !== void 0) return escalation.escalated;
6011
+ const finalized = finalizeVotingResult({
5937
6012
  input,
5938
6013
  strategy,
5939
6014
  algorithm,
6015
+ roles,
5940
6016
  engineResult,
5941
6017
  higherOrderResult,
5942
6018
  votes,
@@ -5945,6 +6021,11 @@ async function executeVoting(input, logger10, opts) {
5945
6021
  startTime,
5946
6022
  logger: logger10
5947
6023
  });
6024
+ return applyContrarianDegrade(finalized, escalation.degradeReason);
6025
+ }
6026
+ function applyContrarianDegrade(result, degradeReason) {
6027
+ if (degradeReason === void 0 || result.policyReason !== void 0) return result;
6028
+ return { ...result, policyReason: degradeReason };
5948
6029
  }
5949
6030
  async function runConsensusForGoal(goal, logger10 = createLogger({ tool: "consensus_vote" }), gatewayAdapters) {
5950
6031
  return executeVoting(ConsensusVoteInputSchema.parse({ proposal: goal }), logger10, {
@@ -5966,7 +6047,10 @@ function finalizeVotingResult(args) {
5966
6047
  votes: args.votes,
5967
6048
  totalTimeMs,
5968
6049
  simulateVotes: args.input.simulateVotes,
5969
- strategy: args.strategy
6050
+ strategy: args.strategy,
6051
+ // #4132: PANEL_SIZE + contrarian-presence for the absolute_quorum predicate.
6052
+ panelSize: args.roles.length,
6053
+ contrarianRequested: args.roles.includes("catfish")
5970
6054
  };
5971
6055
  if (args.higherOrderResult !== void 0) result.higherOrderResult = args.higherOrderResult;
5972
6056
  return result;
@@ -6183,6 +6267,9 @@ var CONSENSUS_VOTE_TOOL_SCHEMA = {
6183
6267
  strategy: VotingStrategySchema.optional().describe(
6184
6268
  "Voting strategy: simple_majority (default), supermajority, unanimous, proof_of_learning, or higher_order"
6185
6269
  ),
6270
+ errorPolicy: ErrorPolicySchema.optional().describe(
6271
+ "How to treat errored/timed-out voters (#2630): reduce_denominator (default non-strict) | count_as_abstain | fail_closed (default unanimous) | absolute_quorum (#4132 opt-in \u2014 an errored voter, esp. the contrarian, degrades the verdict to no_quorum instead of being dropped; never manufactures approved/rejected from an induced error). Errors > 50% always fails."
6272
+ ),
6186
6273
  quickMode: z10.boolean().optional().default(false).describe("Use 3 agents instead of 7"),
6187
6274
  simulateVotes: z10.boolean().optional().default(false).describe("TESTS ONLY \u2014 random output, must not be used for real decisions (#2319)"),
6188
6275
  ratifies: z10.string().min(1).max(256).optional().describe(
@@ -6287,9 +6374,10 @@ export {
6287
6374
  warnIfSimulatedOutsideTests,
6288
6375
  resetCorrelationTracker,
6289
6376
  createPolicyFailedResult,
6377
+ maybeEscalateContrarian,
6290
6378
  executeVoting,
6291
6379
  runConsensusForGoal,
6292
6380
  CONSENSUS_VOTE_OUTPUT_SCHEMA,
6293
6381
  registerConsensusVoteTool
6294
6382
  };
6295
- //# sourceMappingURL=chunk-CB234Y3O.js.map
6383
+ //# sourceMappingURL=chunk-UIL37D2V.js.map