@rulvar/core 1.189.0 → 1.191.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/index.d.ts CHANGED
@@ -8103,6 +8103,13 @@ interface RunFactPairsFold {
8103
8103
  pairs: ClaimPair[];
8104
8104
  /** True when more sentences matched than `max` allowed to report. */
8105
8105
  truncated: boolean;
8106
+ /**
8107
+ * The UNCAPPED count of matched run-claim sentences (RV1809): with
8108
+ * only `truncated` a consumer knew the bound cut the fold but not by
8109
+ * how much, so no run-fact coverage ratio was computable from the
8110
+ * meta alone.
8111
+ */
8112
+ candidates: number;
8106
8113
  }
8107
8114
  /**
8108
8115
  * Pairs draft sentences that speak about the RUN with the run's own
@@ -9467,6 +9474,32 @@ interface OrchestrateClaimConsistency {
9467
9474
  * `runFacts: true`.
9468
9475
  */
9469
9476
  runFactTerms?: string[];
9477
+ /**
9478
+ * The declared coverage floor (RV1809): the minimum
9479
+ * coveredCitingSentences over draftCitingSentences ratio, in
9480
+ * (0, 1]. The nineteenth benchmark's pass covered 36 of 122 citing
9481
+ * sentences and graded itself 'partial' honestly, but nothing could
9482
+ * ENFORCE a floor: a consumer had to read the counts and decide
9483
+ * externally. Below the floor, `onLowCoverage` decides. A draft
9484
+ * with zero citing sentences is vacuously full and never trips it.
9485
+ */
9486
+ minimumCoverageRatio?: number;
9487
+ /**
9488
+ * The run-fact coverage floor (RV1809): the minimum judged run-fact
9489
+ * pairs over matched run-fact candidates ratio, in (0, 1]. Requires
9490
+ * `runFacts: true`; a draft with zero matched run claims never
9491
+ * trips it.
9492
+ */
9493
+ runFactCoverageRatio?: number;
9494
+ /**
9495
+ * What a below-floor ratio does (RV1809): 'report' (the default)
9496
+ * stamps the machine-readable `lowCoverage` block on the meta;
9497
+ * 'fail' fails the run typed BEFORE the judge dispatch, exactly
9498
+ * like `onUncoveredCritical`, so a run that cannot meet its
9499
+ * declared verification floor never pays for a partial verdict.
9500
+ * Requires at least one declared floor.
9501
+ */
9502
+ onLowCoverage?: "report" | "fail";
9470
9503
  }
9471
9504
  /** One judged contradiction: the pair plus the judge's one-sentence reason. */
9472
9505
  interface ClaimContradictionFinding extends ClaimPair {
@@ -9510,6 +9543,26 @@ interface OrchestrateClaimConsistencyMeta {
9510
9543
  runFactPairs?: number;
9511
9544
  /** Present under `runFacts` when more run claims matched than the bound. */
9512
9545
  runFactPairsTruncated?: true;
9546
+ /**
9547
+ * Present under `runFacts` (RV1809): the UNCAPPED count of matched
9548
+ * run-claim sentences, so the run-fact coverage ratio is computable
9549
+ * from the meta alone, live or from a persisted outcome.
9550
+ */
9551
+ runFactCandidates?: number;
9552
+ /**
9553
+ * Present when a declared coverage floor was not met under
9554
+ * `onLowCoverage: 'report'` (RV1809): each ratio beside its floor,
9555
+ * machine-readable, so "complete but under-verified by the declared
9556
+ * floor" is a field, not an external computation. Under 'fail' the
9557
+ * run fails typed instead and the meta stamps this block on the way
9558
+ * out.
9559
+ */
9560
+ lowCoverage?: {
9561
+ coverageRatio: number;
9562
+ coverageFloor?: number;
9563
+ runFactRatio?: number;
9564
+ runFactFloor?: number;
9565
+ };
9513
9566
  /** True when the judge invocation was dispatched. */
9514
9567
  judgeInvoked: boolean;
9515
9568
  /** Present when the judge invocation did not settle ok. */
@@ -11238,14 +11291,31 @@ interface McpConfig {
11238
11291
  * request timeout per tools/list page and per tools/call; without
11239
11292
  * them the SDK's own 60s default request timeout applies. A call
11240
11293
  * timeout surfaces as the tool's error result, never past policy.
11241
- * Each a positive finite number of milliseconds.
11294
+ * discoveryMs (RV1808) is the WALL-CLOCK cap over one whole
11295
+ * tools/list sweep, all pages included: per-page listMs cannot bound
11296
+ * a server that answers every page promptly and paginates forever
11297
+ * with unique cursors under maxPages' radar only when maxPages is
11298
+ * set, and cannot bound a slow-but-under-listMs page crawl at all.
11299
+ * On expiry the sweep refuses typed. Each a positive finite number
11300
+ * of milliseconds.
11242
11301
  */
11243
11302
  timeouts?: {
11244
11303
  connectMs?: number;
11245
11304
  listMs?: number;
11246
11305
  callMs?: number;
11306
+ discoveryMs?: number;
11247
11307
  };
11248
11308
  /**
11309
+ * Demand the discovery bounds (RV1808): with `requireBounds: true`
11310
+ * the source refuses at construction unless maxTools, maxPages,
11311
+ * maxSchemaBytes, and timeouts.discoveryMs are ALL declared. The
11312
+ * production posture: an unbounded discovery sweep against a remote
11313
+ * registry is an availability decision someone should have made on
11314
+ * purpose, so the flag turns the four absences into one typed error
11315
+ * naming what is missing instead of four silent unboundeds.
11316
+ */
11317
+ requireBounds?: boolean;
11318
+ /**
11249
11319
  * streamable-http only (RV1516): headers injected into EVERY wire
11250
11320
  * request through a wrapped fetch. The hook form is awaited before
11251
11321
  * each send, so it IS the refresh point: rotate a token in the hook
package/dist/index.js CHANGED
@@ -4055,11 +4055,21 @@ function validateBounds(cfg) {
4055
4055
  for (const key of [
4056
4056
  "connectMs",
4057
4057
  "listMs",
4058
- "callMs"
4058
+ "callMs",
4059
+ "discoveryMs"
4059
4060
  ]) {
4060
4061
  const value = cfg.timeouts?.[key];
4061
4062
  if (value !== void 0 && (!Number.isFinite(value) || value <= 0)) throw new ConfigError(`mcp: 'timeouts.${key}' must be a positive finite number of milliseconds, got ${String(value)}`);
4062
4063
  }
4064
+ if (cfg.requireBounds === true) {
4065
+ const missing = [
4066
+ ...cfg.maxTools === void 0 ? ["maxTools"] : [],
4067
+ ...cfg.maxPages === void 0 ? ["maxPages"] : [],
4068
+ ...cfg.maxSchemaBytes === void 0 ? ["maxSchemaBytes"] : [],
4069
+ ...cfg.timeouts?.discoveryMs === void 0 ? ["timeouts.discoveryMs"] : []
4070
+ ];
4071
+ if (missing.length > 0) throw new ConfigError(`mcp: requireBounds demands every discovery bound; missing ${missing.join(", ")}`);
4072
+ }
4063
4073
  if (cfg.drift !== void 0 && cfg.drift !== "rekey" && cfg.drift !== "refuse") throw new ConfigError(`mcp: 'drift' must be 'rekey' or 'refuse', got '${String(cfg.drift)}'`);
4064
4074
  const headers = cfg.http?.headers;
4065
4075
  if (headers !== void 0 && typeof headers !== "function" && typeof headers !== "object") throw new ConfigError("mcp: 'http.headers' must be a record of header values or a (possibly async) function returning one");
@@ -4201,13 +4211,19 @@ function mcp(cfg) {
4201
4211
  const tools = [];
4202
4212
  let cursor;
4203
4213
  let pages = 0;
4214
+ const visited = /* @__PURE__ */ new Set();
4215
+ const startedAt = Date.now();
4216
+ const discoveryMs = cfg.timeouts?.discoveryMs;
4204
4217
  const listOptions = cfg.timeouts?.listMs === void 0 ? void 0 : { timeout: cfg.timeouts.listMs };
4205
4218
  do {
4219
+ if (discoveryMs !== void 0 && Date.now() - startedAt > discoveryMs) throw new ConfigError(`mcp: tools/list of '${sourceIdOf(cfg)}' exceeded the discovery deadline (timeouts.discoveryMs ${discoveryMs}) after ${pages} page(s)`);
4220
+ if (cursor !== void 0) visited.add(cursor);
4206
4221
  const page = await client.listTools(cursor === void 0 ? {} : { cursor }, listOptions);
4207
4222
  pages += 1;
4208
4223
  tools.push(...page.tools);
4209
4224
  if (cfg.maxTools !== void 0 && tools.length > cfg.maxTools) throw new ConfigError(`mcp: tools/list of '${sourceIdOf(cfg)}' returned at least ${tools.length} wire tools, over the declared maxTools ${cfg.maxTools}; raise the cap or trim the server`);
4210
4225
  if (page.nextCursor !== void 0 && page.nextCursor !== "" && page.nextCursor === cursor) throw new ConfigError(`mcp: tools/list of '${sourceIdOf(cfg)}' returned the cursor it was queried with ('${page.nextCursor}') on page ${pages}: the pagination makes no progress`);
4226
+ if (page.nextCursor !== void 0 && page.nextCursor !== "" && visited.has(page.nextCursor)) throw new ConfigError(`mcp: tools/list of '${sourceIdOf(cfg)}' returned a cursor this sweep already visited ('${page.nextCursor}') on page ${pages}: the pagination cycles`);
4211
4227
  cursor = page.nextCursor;
4212
4228
  if (cfg.maxPages !== void 0 && pages >= cfg.maxPages && cursor !== void 0 && cursor !== "") throw new ConfigError(`mcp: tools/list of '${sourceIdOf(cfg)}' still reports another page after ${pages} page(s), over the declared maxPages ${cfg.maxPages}; raise the cap or trim the server`);
4213
4229
  } while (cursor !== void 0 && cursor !== "");
@@ -20163,7 +20179,8 @@ function pairRunFactClaims(draftText, sheet, options) {
20163
20179
  }
20164
20180
  return {
20165
20181
  pairs: matched,
20166
- truncated: total > matched.length
20182
+ truncated: total > matched.length,
20183
+ candidates: total
20167
20184
  };
20168
20185
  }
20169
20186
  /** Derives the {@link ClaimCoverageGrade} of a claim-consistency meta. */
@@ -20803,6 +20820,10 @@ function validateOrchestrateOptions(opts) {
20803
20820
  if (consistency.runFacts !== true) throw new ConfigError("orchestrate claimConsistency.runFactTerms rides the runFacts pass; set claimConsistency.runFacts true");
20804
20821
  if (!Array.isArray(consistency.runFactTerms) || consistency.runFactTerms.some((term) => typeof term !== "string" || term.length === 0)) throw new ConfigError("orchestrate claimConsistency.runFactTerms must be an array of nonempty strings; got " + JSON.stringify(consistency.runFactTerms));
20805
20822
  }
20823
+ for (const [label, ratio] of [["minimumCoverageRatio", consistency.minimumCoverageRatio], ["runFactCoverageRatio", consistency.runFactCoverageRatio]]) if (ratio !== void 0 && (typeof ratio !== "number" || !Number.isFinite(ratio) || ratio <= 0 || ratio > 1)) throw new ConfigError(`orchestrate claimConsistency.${label} must be a number in (0, 1]; got ` + JSON.stringify(ratio));
20824
+ if (consistency.runFactCoverageRatio !== void 0 && consistency.runFacts !== true) throw new ConfigError("orchestrate claimConsistency.runFactCoverageRatio rides the runFacts pass; set claimConsistency.runFacts true");
20825
+ if (consistency.onLowCoverage !== void 0 && consistency.onLowCoverage !== "report" && consistency.onLowCoverage !== "fail") throw new ConfigError("orchestrate claimConsistency.onLowCoverage must be 'report' or 'fail'; got " + JSON.stringify(consistency.onLowCoverage));
20826
+ if (consistency.onLowCoverage !== void 0 && consistency.minimumCoverageRatio === void 0 && consistency.runFactCoverageRatio === void 0) throw new ConfigError("orchestrate claimConsistency.onLowCoverage needs a declared floor; set minimumCoverageRatio or runFactCoverageRatio");
20806
20827
  if (consistency.judge !== void 0) {
20807
20828
  const judge = consistency.judge;
20808
20829
  if (typeof judge !== "object" || judge === null || Array.isArray(judge)) throw new ConfigError(`orchestrate claimConsistency.judge must be an object; got ${JSON.stringify(consistency.judge)}`);
@@ -22694,8 +22715,22 @@ function makeOrchestratorWorkflow(goal, opts) {
22694
22715
  },
22695
22716
  ...runFold === void 0 ? {} : {
22696
22717
  runFactPairs: runFold.pairs.length,
22697
- ...runFold.truncated ? { runFactPairsTruncated: true } : {}
22698
- }
22718
+ ...runFold.truncated ? { runFactPairsTruncated: true } : {},
22719
+ runFactCandidates: runFold.candidates
22720
+ },
22721
+ ...(() => {
22722
+ const coverageRatio = fold.draftCitingSentences === 0 ? 1 : fold.coveredCitingSentences / fold.draftCitingSentences;
22723
+ const runFactRatio = runFold === void 0 || runFold.candidates === 0 ? void 0 : runFold.pairs.length / runFold.candidates;
22724
+ const belowCoverage = spec.minimumCoverageRatio !== void 0 && fold.draftCitingSentences > 0 && coverageRatio < spec.minimumCoverageRatio;
22725
+ const belowRunFacts = spec.runFactCoverageRatio !== void 0 && runFactRatio !== void 0 && runFactRatio < spec.runFactCoverageRatio;
22726
+ if (!belowCoverage && !belowRunFacts) return {};
22727
+ return { lowCoverage: {
22728
+ coverageRatio,
22729
+ ...spec.minimumCoverageRatio === void 0 ? {} : { coverageFloor: spec.minimumCoverageRatio },
22730
+ ...runFactRatio === void 0 ? {} : { runFactRatio },
22731
+ ...spec.runFactCoverageRatio === void 0 ? {} : { runFactFloor: spec.runFactCoverageRatio }
22732
+ } };
22733
+ })()
22699
22734
  };
22700
22735
  const finishMeta = (flags) => {
22701
22736
  const bare = {
@@ -22707,6 +22742,16 @@ function makeOrchestratorWorkflow(goal, opts) {
22707
22742
  coverage: claimCoverageOf(bare)
22708
22743
  };
22709
22744
  };
22745
+ if (spec.onLowCoverage === "fail" && metaBase.lowCoverage !== void 0) {
22746
+ claimConsistencyMeta = finishMeta({ judgeInvoked: false });
22747
+ const low = metaBase.lowCoverage;
22748
+ throw new FailRunError(`the claim-consistency pass is below a declared coverage floor (coverage ${low.coverageRatio.toFixed(3)}` + (low.coverageFloor === void 0 ? "" : ` under floor ${String(low.coverageFloor)}`) + (low.runFactRatio === void 0 ? "" : `; run facts ${low.runFactRatio.toFixed(3)}` + (low.runFactFloor === void 0 ? "" : ` under floor ${String(low.runFactFloor)}`)) + "), and the armed onLowCoverage posture cannot pass the draft", { data: {
22749
+ source: "orchestrator_claim_consistency",
22750
+ lowCoverage: low,
22751
+ claimConsistencyMeta,
22752
+ ...snapshot ?? {}
22753
+ } });
22754
+ }
22710
22755
  if (spec.onUncoveredCritical === "fail" && fold.criticalUncovered !== void 0 && fold.criticalUncovered.length > 0) {
22711
22756
  claimConsistencyMeta = finishMeta({ judgeInvoked: false });
22712
22757
  throw new FailRunError(`the claim-consistency pass left ${String(fold.criticalUncoveredTotal ?? 0)} critical draft anchor(s) unjudged (${fold.criticalUncovered.join(", ")}), and the armed onUncoveredCritical posture cannot pass the draft`, { data: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rulvar/core",
3
- "version": "1.189.0",
3
+ "version": "1.191.0",
4
4
  "description": "Rulvar core: L0 contracts, journal kernel, ctx primitives, agent runtime, model router, tool system, dynamic orchestrator, InMemory and JSONL stores, event stream.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",