@productbrain/mcp 0.0.1-beta.8947 → 0.0.1-beta.8962

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.
@@ -1163,16 +1163,33 @@ function buildCaptureForRealNextAction(payload) {
1163
1163
 
1164
1164
  // src/lib/checklist.ts
1165
1165
  var CHECKLIST_LINES = {
1166
- strategy: {
1167
- coherent_narrative: "Connect the diagnosis, the policy and the first actions (40+ words)",
1168
- decisiveness: "Say what you will not do",
1169
- time_bounded: "Name a horizon: a date, a duration or a milestone"
1166
+ purpose: {
1167
+ stranger_test: "Explain it so a stranger knows why this company exists",
1168
+ specificity: "Say what would be missing from the world without this company",
1169
+ not_a_platitude: "Say something a reasonable company would not also claim",
1170
+ beneficiary_named: "Name who the company exists for: a role, a persona or a segment",
1171
+ durable_not_dated: "Leave out dates and planning cycles; those belong on goals"
1170
1172
  },
1171
1173
  vision: {
1172
- specificity: "Say what will be different, in words only this product could use (15+ words)",
1174
+ specificity: "Say what will be different, in words only this product could use",
1173
1175
  beneficiary: "Name who benefits: a role, a persona or a segment",
1174
1176
  falsifiability: "Choose a direction a reasonable rival would reject",
1175
- stranger_test: "Explain it so a stranger knows what you build (20+ words)"
1177
+ stranger_test: "Explain it so a stranger knows what will be different, and for whom"
1178
+ },
1179
+ strategy: {
1180
+ coherent_narrative: "Connect the diagnosis, the policy and the first actions",
1181
+ decisiveness: "Say what you will not do",
1182
+ time_bounded: "Name a horizon: a date, a duration or a milestone"
1183
+ },
1184
+ objective: {
1185
+ outcome_not_activity: "State what will be true once it is met, not the work to do",
1186
+ serves_strategy: "Say what must be true for the strategy to succeed",
1187
+ observable: "Make it something a reader could see has happened"
1188
+ },
1189
+ key_result: {
1190
+ measurable: "Name a measure and the target value or state",
1191
+ bounded: "Say by when, or how often, the measure is read",
1192
+ moves_the_objective: "Pick a result that shows the objective is happening, not that work was done"
1176
1193
  },
1177
1194
  /** One line per spine rung, keyed by the rung it reaches (kernel/strategy/spineTrace.ts order). */
1178
1195
  strategy_link: {
@@ -2407,6 +2424,41 @@ async function runConflictPreflight(name, description, collectionHint) {
2407
2424
  }
2408
2425
  }
2409
2426
 
2427
+ // src/lib/judgeWait.ts
2428
+ var JUDGE_TIMEOUT_MS = 3e4;
2429
+ var JUDGE_CALLS_PER_RUN = 2;
2430
+ var JUDGE_WAIT_BOUND_MS = JUDGE_CALLS_PER_RUN * JUDGE_TIMEOUT_MS + 5e3;
2431
+ var POLL_MS = 1e3;
2432
+ async function settleVerdictBeforeAccept(evaluate, readLatest, opts = {}) {
2433
+ const now = opts.now ?? Date.now;
2434
+ const sleep = opts.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
2435
+ const bound = opts.boundMs ?? JUDGE_WAIT_BOUND_MS;
2436
+ let evaluation = null;
2437
+ try {
2438
+ evaluation = await evaluate();
2439
+ } catch {
2440
+ return { evaluation: null, latest: null, waitedMs: 0, judged: false };
2441
+ }
2442
+ if (!evaluation?.judgeInFlight && !evaluation?.reused) return { evaluation, latest: null, waitedMs: 0, judged: false };
2443
+ const inFlight = evaluation.judgeInFlight === true;
2444
+ const start = now();
2445
+ let latest = null;
2446
+ for (; ; ) {
2447
+ try {
2448
+ latest = await readLatest();
2449
+ } catch {
2450
+ return { evaluation, latest, waitedMs: now() - start, judged: false };
2451
+ }
2452
+ if (latest?.verdict?.llmStatus !== "pending") return { evaluation, latest, waitedMs: now() - start, judged: inFlight };
2453
+ if (now() - start >= bound) return { evaluation, latest, waitedMs: now() - start, judged: false };
2454
+ await sleep(POLL_MS);
2455
+ }
2456
+ }
2457
+ function judgedAcceptedLine(wait) {
2458
+ if (!wait?.judged) return null;
2459
+ return `Judged in ${Math.max(1, Math.round(wait.waitedMs / 1e3))} s, accepted.`;
2460
+ }
2461
+
2410
2462
  // src/tools/knowledge/updateEntryAppliedFields.ts
2411
2463
  function computeUpdateEntryAppliedFields(args, normalization, provenanceApplied = {}, revertedFields = []) {
2412
2464
  const rejectedDataFields = normalization?.rejected ?? [];
@@ -2654,16 +2706,12 @@ async function handleCommitEntry({ entryId, preview, steeringOverrideReason, coh
2654
2706
  confidence: c.confidence,
2655
2707
  explanation: c.explanation
2656
2708
  })) : [];
2657
- let coachingResult = null;
2658
- if (!preview) {
2659
- try {
2660
- coachingResult = await kernelMutation("quality.evaluateHeuristicAndSchedule", {
2661
- entryId,
2662
- context: "commit"
2663
- });
2664
- } catch {
2665
- }
2666
- }
2709
+ const judgeWait = preview ? null : await settleVerdictBeforeAccept(
2710
+ () => kernelMutation("quality.evaluateHeuristicAndSchedule", { entryId, context: "commit" }),
2711
+ () => kernelQuery("quality.getLatestVerdictForEntry", { entryId })
2712
+ );
2713
+ const stored = judgeWait?.latest?.verdict;
2714
+ const coachingResult = stored ? { verdict: stored, source: stored.source } : judgeWait?.evaluation ?? null;
2667
2715
  let result2;
2668
2716
  try {
2669
2717
  result2 = await kernelMutation("chain.commitEntry", {
@@ -2743,8 +2791,10 @@ No DB writes \u2014 call without \`preview:true\` to accept for real.` }],
2743
2791
  commit_method: "manual",
2744
2792
  surface: "mcp_commit_tool"
2745
2793
  });
2794
+ const judged = judgedAcceptedLine(judgeWait);
2746
2795
  const lines = [
2747
2796
  `# Accepted: ${entryId}`,
2797
+ ...judged ? [judged] : [],
2748
2798
  `**${entry.name}** promoted to SSOT on the Chain.`,
2749
2799
  `**Workspace:** ${wsCtx.workspaceSlug} (${wsCtx.workspaceId})`
2750
2800
  ];
@@ -2775,7 +2825,8 @@ No DB writes \u2014 call without \`preview:true\` to accept for real.` }],
2775
2825
  source: coachingResult.source ?? "heuristic",
2776
2826
  criteria_total: v.criteria?.length ?? 0,
2777
2827
  criteria_failed: failedCount,
2778
- llm_scheduled: v.tier !== "passive",
2828
+ llm_scheduled: judgeWait?.evaluation?.reused !== true && v.tier !== "passive",
2829
+ // TASK-612: a reused verdict schedules nothing
2779
2830
  methodology_version: v.methodologyVersion
2780
2831
  });
2781
2832
  } catch {
@@ -2845,6 +2896,8 @@ No DB writes \u2014 call without \`preview:true\` to accept for real.` }],
2845
2896
  outcome: "committed",
2846
2897
  qualityVerdict: coachingResult?.verdict ?? void 0,
2847
2898
  source: coachingResult?.source ?? void 0,
2899
+ ...judgeWait?.judged ? { judgedInMs: judgeWait.waitedMs } : {},
2900
+ // TASK-612
2848
2901
  contradictions: advisoryWarnings.length,
2849
2902
  ...epistemic ? { epistemicStatus: epistemic } : {},
2850
2903
  ...steeringAdvisory ? { steeringAdvisory } : {},
@@ -13595,4 +13648,4 @@ export {
13595
13648
  createProductBrainServer,
13596
13649
  initFeatureFlags
13597
13650
  };
13598
- //# sourceMappingURL=chunk-ISGBWBXR.js.map
13651
+ //# sourceMappingURL=chunk-FJ7SUWUN.js.map