opencode-azure-devops-pr-review 0.4.5 → 0.5.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/src/runtime.mjs CHANGED
@@ -15,15 +15,15 @@ import { dirname, join } from 'node:path';
15
15
  import { fileURLToPath } from 'node:url';
16
16
  import { randomUUID, X509Certificate } from 'node:crypto';
17
17
  import { createReviewSession, requestReview, interruptSession, appendReport, classifyFailure } from './session.mjs';
18
- import { COMMANDS, MODES, ROLES, PROMPTS, PLUGIN_ID, PACKAGE_NAME, REPOSITORY, roleFor, privateAgent, commentRole, allowedTools, buildAgents, validateSettings, withMissingSettings, settingsText, modelRef, modelSlots, configuredOptionalSlots, stageModel, commentSlot, patProblem } from './config.mjs';
18
+ import { COMMANDS, MODES, ROLES, PROMPTS, PLUGIN_ID, PACKAGE_NAME, REPOSITORY, roleFor, privateAgent, commentRole, allowedTools, buildAgents, validateSettings, withMissingSettings, settingsText, modelRef, stageModel, firstModel, modeReady, raterState, patProblem } from './config.mjs';
19
19
  import { parseUniqueJSON, parseReviewRequest, parseCommentRequest, visibleText } from './output.mjs';
20
20
  import { createDiagnostics, diagnosticResponse, diagnosticToolError, createStageTiming, collectToolObservations } from './diagnostics.mjs';
21
21
  import { createCommentData, captureObservation, PAGE_CHARACTERS, COMMENT_TURN_CHARACTERS } from './comment-data.mjs';
22
22
  import { prepareComments, publishPlan, discussionDigest, PLANNING_PARALLEL_PAGES } from './comment-work.mjs';
23
- import { automaticPublicationProblems, automaticPublicationRepeats, publicationItems, publishableFindings, reviewVerification,
23
+ import { automaticPublicationProblems, automaticPublicationRepeats, publicationItems, publishableFindings, reviewMethod,
24
24
  everAdjusted, hasAdjustments, resolveAdjustments, everyFindingExcluded, publicationStarted, describeAdjustments, describeEarlierText, excludedReferences, previewNextSteps, previewActions, commentToken } from './comments.mjs';
25
25
  import { createToolQueue } from './tool-queue.mjs';
26
- import { API_VERSION, createAzureClient, fetchTransport, pemCertificates, proxyLabel, restBaseUrl, targetKey } from './azure.mjs';
26
+ import { API_VERSION, createAzureClient, fetchTransport, markersInThreads, pemCertificates, proxyLabel, restBaseUrl, targetKey } from './azure.mjs';
27
27
  import { REVIEW_TOOL_NAMES, reviewToolDefinitions, runReviewTool } from './review-tools.mjs';
28
28
  import { runReview } from './review-work.mjs';
29
29
  import { createReviewStore, createReviewWrites, stateRoot, REVIEW_LIMIT } from './store.mjs';
@@ -31,7 +31,6 @@ import { PROGRESS_EVENT_TYPES, TESTED_HOST_VERSION, USED_UP_LIMITS, fetchTranspo
31
31
  import { reviewProvenance, provenanceReport, commentAttribution, renderFinalReport, renderCommentActions, renderIncompleteDraft, renderReceipt, renderDiagnosticNotices, renderCheckReport, renderPublication, describeReview, conversationTitle, enclose } from './attribution.mjs';
32
32
 
33
33
  const DEFAULT_DIR = dirname(fileURLToPath(import.meta.url));
34
- const ownRole = name => typeof name === 'string' && Object.hasOwn(ROLES, name);
35
34
  const text = v => typeof v === 'string' && v.trim().length > 0;
36
35
  const clone = v => JSON.parse(JSON.stringify(v));
37
36
  const errorText = e => e instanceof Error ? e.message : typeof e?.message === 'string' ? e.message : 'OpenCode SDK operation failed.';
@@ -245,9 +244,9 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
245
244
  // is; the options are in --help.
246
245
  const COMMAND_DESCRIPTIONS = {
247
246
  'pr-check': 'Azure DevOps PR access check, no model; --help. READY means AZPR can read the PR (explicit invocation only)',
248
- 'pr-review': 'Verified Azure DevOps PR review; --help for options. Two reviewers, then separate verification; --preview/--publish/--no-comment after the URL (explicit invocation only)',
249
- 'pr-deep': 'Azure DevOps PR review, stronger models; --help. The verified review with the models of models.deep; --preview/--publish/--no-comment after the URL (explicit invocation only)',
250
- 'pr-quick': 'Quick Azure DevOps PR review, not verified; --help. One reviewer per shard, findings not independently verified; --preview/--publish/--no-comment after the URL (explicit invocation only)',
247
+ 'pr-review': 'Azure DevOps PR review; --help for options. One pass per model of models.review.reviewers, a duplicate check and a rating; --preview/--publish/--no-comment after the URL (explicit invocation only)',
248
+ 'pr-deep': 'Azure DevOps PR review, stronger models; --help. The same review with the models of models.deep.reviewers; --preview/--publish/--no-comment after the URL (explicit invocation only)',
249
+ 'pr-quick': 'Quick Azure DevOps PR review; --help. The same review with the models of models.quick.reviewers, usually one fast pass; --preview/--publish/--no-comment after the URL (explicit invocation only)',
251
250
  'pr-stop': "Cancel this conversation's AZPR command; --help (explicit invocation only)",
252
251
  'pr-comment': 'Preview, adjust or publish review comments; --help. Acts on the current review: --publish posts (safe to repeat), --show, --list, --exclude, --severity, --reset. Optional review ID.',
253
252
  };
@@ -261,16 +260,16 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
261
260
  'Then: /pr-comment --help. Stop a running command with /pr-stop.';
262
261
  const COMMAND_HELP = {
263
262
  'pr-check': () => '[AZPR] /pr-check <Azure DevOps PR URL>\n\nChecks that AZPR can read the PR with the configured PAT and that the review models exist. No model runs and nothing is posted; READY is not a review.',
264
- 'pr-review': () => reviewHelp('pr-review', 'Functional and risk reviewers read the changed files, then separate sessions verify every finding.'),
265
- 'pr-deep': () => reviewHelp('pr-deep', 'The same verified review as /pr-review, run with the stronger models of models.deep.'),
266
- 'pr-quick': () => reviewHelp('pr-quick', 'One reviewer per shard and no verifier: the findings are reported, not independently verified, and their comments say so.'),
263
+ 'pr-review': () => reviewHelp('pr-review', 'Each model of models.review.reviewers reviews the changed files on its own and checks its findings against the source. The runtime checks the form and source of every finding, a duplicate check merges repeated reports and a rating sets the severities. No separate verification runs, and the comments say so.'),
264
+ 'pr-deep': () => reviewHelp('pr-deep', 'The same review as /pr-review, run with the models of models.deep.reviewers: stronger models, or more passes.'),
265
+ 'pr-quick': () => reviewHelp('pr-quick', 'The same review as /pr-review, run with the models of models.quick.reviewers: usually one pass of a fast model.'),
267
266
  'pr-stop': () => '[AZPR] /pr-stop [run-id]\n\nCancels the AZPR command running in this conversation, or the run whose ID its STARTED notice gave. Requests already sent may still be billed.',
268
267
  'pr-comment': () => '[AZPR] /pr-comment [review-id] [--publish | --show | --exclude IDs | --severity ID=level,… | --reset], or /pr-comment --list\n\n' +
269
268
  "Without a review ID the command acts on this conversation's current review: the one most recently completed or used here. A review's own sessions always mean that review.\n\n" +
270
269
  ' /pr-comment plan a comment preview (a model runs; nothing is posted)\n' +
271
270
  ' /pr-comment --show show the saved preview again (no model)\n' +
272
- ' /pr-comment --exclude F-1,R-2 leave findings out, then read the new preview\n' +
273
- ' /pr-comment --severity F-3=low,R-4=medium change levels, then read the new preview\n' +
271
+ ' /pr-comment --exclude F-1,F-2 leave findings out, then read the new preview\n' +
272
+ ' /pr-comment --severity F-3=low,F-4=medium change levels, then read the new preview\n' +
274
273
  ' /pr-comment --exclude F-1 --severity F-3=low both in one command (one planning run)\n' +
275
274
  ' /pr-comment --exclude none put every finding back; --severity none and --reset work alike\n' +
276
275
  ' /pr-comment --publish post the saved preview as the PAT owner; safe to repeat\n' +
@@ -325,6 +324,12 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
325
324
  }
326
325
 
327
326
  /** Grant-only authorization; no file or catalog reads on the hot path. */
327
+ /**
328
+ * Whether a hook's event is about one of AZPR's private sessions: one of its roles, also one of 0.4.x that no
329
+ * longer exists, a session this process created, or one an earlier process created that a saved review or a
330
+ * session record names. Such a session runs nothing without a grant of a command that is under way.
331
+ */
332
+ const privateSession = event => privateAgent(event.agent) || seenSessions.has(event.sessionID) || createdEarlier.has(event.sessionID);
328
333
  function authorize(sessionID, agent, actualModel) {
329
334
  const g = grants.get(sessionID);
330
335
  if (!g || !g.run.active || g.role !== agent) throw new Error('[AZPR] No active command-scoped reviewer authorization.');
@@ -336,15 +341,24 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
336
341
  return g;
337
342
  }
338
343
 
339
- function modelProblems(modelRows, profile, slots, { tools = true } = {}) {
344
+ /**
345
+ * The models a mode's stages run with, as the settings name them: every reviewer (the first also checks
346
+ * duplicates and plans the comments), and the rater where one is named. A rater that is the first reviewer
347
+ * model is that entry; a rating session has no tools, so a named rater needs none.
348
+ */
349
+ const modelChecks = mode => [
350
+ ...settings.models[mode].reviewers.map((model, index) => ({ label: `reviewers[${index}]`, model, tools: true })),
351
+ ...(raterState(settings, mode) === 'named' ? [{ label: 'rater', model: settings.models[mode].rater, tools: false }] : [])];
352
+
353
+ function modelProblems(modelRows, profile, checks) {
340
354
  const problems = [];
341
- for (const slot of slots) {
342
- const selected = settings.models[profile][slot], { providerID, id, variant } = modelRef(selected);
355
+ for (const { label, model: selected, tools } of checks) {
356
+ const { providerID, id, variant } = modelRef(selected);
343
357
  const matches = modelRows.filter(model => model.providerID === providerID && model.id === id && model.enabled !== false);
344
358
  const variants = (Array.isArray(matches[0]?.variants) ? matches[0].variants : []).map(item => item?.id).filter(text);
345
- if (matches.length !== 1) problems.push(`The selected ${profile}.${slot} model (${selected}) is unavailable in the host catalog.`);
346
- else if (variant !== undefined && variant !== 'default' && !variants.includes(variant)) problems.push(`The selected ${profile}.${slot} model has no variant ${variant}${variants.length ? `; it offers ${variants.join(', ')}` : ''}.`);
347
- else if (tools && matches[0].capabilities?.tools !== true) problems.push(`The selected ${profile}.${slot} model does not advertise tool support.`);
359
+ if (matches.length !== 1) problems.push(`The selected ${profile}.${label} model (${selected}) is unavailable in the host catalog.`);
360
+ else if (variant !== undefined && variant !== 'default' && !variants.includes(variant)) problems.push(`The selected ${profile}.${label} model has no variant ${variant}${variants.length ? `; it offers ${variants.join(', ')}` : ''}.`);
361
+ else if (tools && matches[0].capabilities?.tools !== true) problems.push(`The selected ${profile}.${label} model does not advertise tool support.`);
348
362
  }
349
363
  return problems;
350
364
  }
@@ -352,26 +366,26 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
352
366
  /**
353
367
  * The model catalog only; no inference is submitted. A command checks only
354
368
  * the models it uses, so an unavailable optional model never blocks another
355
- * mode; /pr-check reports configured quick and deep models as warnings.
369
+ * mode; /pr-check reports configured quick and deep models as warnings. A
370
+ * comment command that only posts a saved preview uses no model at all.
356
371
  */
357
372
  async function readiness(run) {
373
+ const azureReadiness = { organization: settings.azure.organization, apiVersion: API_VERSION, ...network };
374
+ // Posting a saved preview runs no model: the catalog is not even read, so that an outage of it never stops it.
375
+ if (run.mode === 'comment' && run.planning === false) {
376
+ run.readiness = { profile: run.profile, checkedModelSlots: [], modelProblems: [], azure: azureReadiness };
377
+ return;
378
+ }
358
379
  requireMethods(context, ['model.list'], 'readiness checks');
359
380
  const modelRows = listOf(await bounded(() => context.model.list(), run.controller.signal));
360
381
  if (!modelRows) throw new Error('[AZPR] Invalid model catalog.');
361
- // An optional slot is checked only where it is set; the rater runs without tools.
362
- const checked = mode => {
363
- const extra = configuredOptionalSlots(settings, mode);
364
- return { checkedModelSlots: [...modelSlots(mode), ...extra],
365
- modelProblems: [...modelProblems(modelRows, mode, modelSlots(mode)), ...modelProblems(modelRows, mode, extra, { tools: false })] };
366
- };
367
- const own = run.mode === 'comment'
368
- ? { checkedModelSlots: [commentSlot(run.profile)], modelProblems: modelProblems(modelRows, run.profile, [commentSlot(run.profile)]) }
369
- : checked(run.profile);
382
+ const checked = (mode, list = modelChecks(mode)) => ({ checkedModelSlots: list.map(item => item.label), modelProblems: modelProblems(modelRows, mode, list) });
383
+ // Comment planning runs with the first reviewer model of the review's mode.
384
+ const own = run.mode !== 'comment' ? checked(run.profile) : checked(run.profile, modelChecks(run.profile).slice(0, 1));
370
385
  const problems = own.modelProblems;
371
- const optional = mode => run.mode === 'check' && settings[`${mode}Ready`] ? checked(mode) : undefined;
386
+ const optional = mode => run.mode === 'check' && modeReady(settings, mode) ? checked(mode) : undefined;
372
387
  const deep = optional('deep'), quick = optional('quick');
373
- run.readiness = { profile: run.profile, ...own, ...(deep ? { deep } : {}), ...(quick ? { quick } : {}),
374
- azure: { organization: settings.azure.organization, apiVersion: API_VERSION, ...network } };
388
+ run.readiness = { profile: run.profile, ...own, ...(deep ? { deep } : {}), ...(quick ? { quick } : {}), azure: azureReadiness };
375
389
  if (problems.length && run.mode !== 'check') throw new Error(`[AZPR] ${problems.join(' ')} No fallback was selected.`);
376
390
  }
377
391
 
@@ -402,7 +416,8 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
402
416
  if (drift === 'settings') throw new Error('[AZPR] settings.json changed since OpenCode loaded it. Restart the OpenCode service (opencode service restart) to use the new settings; running reviews are unaffected.');
403
417
  if (drift === 'pat') throw new Error('[AZPR] azure.patFile changed since OpenCode loaded it. Restart the OpenCode service (opencode service restart) to use the new PAT; running reviews are unaffected.');
404
418
  await checkCommands(signal);
405
- await pinAgents(run.profile, signal);
419
+ // Posting a saved preview starts no private session, so it needs no private agent either.
420
+ if (!(run.mode === 'comment' && run.planning === false)) await pinAgents(run.profile, signal);
406
421
  await readiness(run);
407
422
  await run.debug.write('readiness.json', { ...run.readiness, ...(baseUrl === 'https://dev.azure.com' ? {} : { azureBaseUrl: baseUrl }), host: capabilities,
408
423
  stateDirectory: store.root, ...(storeFallback ? { stateDirectoryFallback: storeFallback } : {}) });
@@ -832,6 +847,8 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
832
847
  visibleCharacters: input.length, checkpointRequested: false,
833
848
  // The planning page whose sessions this grant serves; its tool evidence is that page's.
834
849
  commentPage: payload.commentWork?.page ?? null,
850
+ // The grouping pass has an answer of its own: no page, no comments, no continuation.
851
+ grouping: payload.commentWork?.kind === 'group',
835
852
  // "commit\npath" of the file contents this session's own tool calls showed;
836
853
  // never the run's shared cache or another session's reads.
837
854
  reads: new Set(),
@@ -848,7 +865,7 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
848
865
  try {
849
866
  await run.debug.write(`${stem}.request.json`, { ...record, payload, instructions: state.agents[role].system });
850
867
  g.timing?.promptStarted();
851
- let prompt = input, evaluation, answerText = '', followUp;
868
+ let prompt = input, evaluation, answerText = '', followUp, lastUsable = null;
852
869
  const repairs = [];
853
870
  // What the handler may know about this session: the contents its own tools showed.
854
871
  const session = { reads: g.reads };
@@ -856,14 +873,20 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
856
873
  let answer;
857
874
  try { answer = await ask(g, made.id, prompt, signal); }
858
875
  catch (error) {
859
- // A follow-up is optional: when it or a later turn fails, the answer it
860
- // followed stands. Cancellation and context overflow keep their rules.
876
+ // A turn after the first that fails leaves the latest usable answer before it standing: a follow-up is
877
+ // optional, and a correction turn only repairs items, which stay degraded instead. A stopped run, and a
878
+ // context that overflowed where the handler can split its work (a reviewer shard of several files), keep
879
+ // their rules.
861
880
  const failureClass = runSignal.aborted ? 'cancelled' : watch.error ? 'idle' : classifyFailure(error);
862
- if (!followUp || ['cancelled', 'overflow'].includes(failureClass)) throw error;
863
- Object.assign(followUp, { outcome: 'failed', failureClass, error: errorText(watch.error ?? error).slice(0, 300) });
864
- if (error?.response && settings.debug.enabled) await run.debug.write(`${stem}.response-${followUp.turn === turn ? 'follow-up' : 'repair'}${turn}.json`, diagnosticResponse(error.response));
881
+ const kept = turn > 0 && failureClass !== 'cancelled' && !(failureClass === 'overflow' && handler.splittable === true);
882
+ if (!kept || !lastUsable) throw error;
883
+ const failure = { failureClass, error: errorText(watch.error ?? error).slice(0, 300) };
884
+ if (error?.response && settings.debug.enabled) await run.debug.write(`${stem}.response-${followUp?.turn === turn ? 'follow-up' : 'repair'}${turn}.json`, diagnosticResponse(error.response));
865
885
  await abortSession(run, made.id);
866
- ({ evaluation, answerText } = followUp.before);
886
+ // The turn that failed is named: the follow-up itself, or a correction turn (also one after a follow-up).
887
+ if (followUp?.turn === turn) Object.assign(followUp, { outcome: 'failed', ...failure });
888
+ else record.repairFailure = { turn, ...failure };
889
+ ({ evaluation, answerText } = lastUsable);
867
890
  break;
868
891
  }
869
892
  answerText = visibleText(answer);
@@ -874,6 +897,8 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
874
897
  }
875
898
  if (answer.retriedSteps) record.hostStepRetries = (record.hostStepRetries ?? 0) + answer.retriedSteps;
876
899
  evaluation = await handler.evaluate(answerText, evaluation?.result, session);
900
+ // What a handler can still use of an answer, whatever its items need: kept if a later turn fails or is unusable.
901
+ if (evaluation.usable === true) lastUsable = { evaluation, answerText, turn };
877
902
  const budget = turn < settings.workflow.repairAttempts;
878
903
  if (evaluation.issues?.length && evaluation.repairPrompt && budget) {
879
904
  repairs.push({ issues: evaluation.issues.slice(0, 25) });
@@ -883,17 +908,24 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
883
908
  // One follow-up per session, within the same turn budget, for a usable
884
909
  // answer with nothing to repair that names unfinished work.
885
910
  if (!evaluation.issues?.length && evaluation.followUp && !followUp && budget) {
886
- followUp = { turn: turn + 1, gaps: evaluation.followUp.gaps, uncovered: evaluation.followUp.uncovered, before: { evaluation, answerText } };
911
+ followUp = { turn: turn + 1, gaps: evaluation.followUp.gaps, uncovered: evaluation.followUp.uncovered };
887
912
  progress(run, `${spec.label}${label ? ` ${label}` : ''} reported unfinished work; asking the same session once to continue.`);
888
913
  prompt = evaluation.followUp.prompt;
889
914
  continue;
890
915
  }
891
916
  break;
892
917
  }
918
+ // An answer that is not usable never replaces a usable one before it: neither a follow-up's nor a correction's.
919
+ // The last turn is named where it was a correction turn; the follow-up's own outcome is said below.
920
+ if (evaluation.usable !== true && lastUsable && evaluation !== lastUsable.evaluation) {
921
+ const lastTurn = repairs.length + (followUp ? 1 : 0);
922
+ ({ evaluation, answerText } = lastUsable);
923
+ if (followUp?.turn !== lastTurn) record.repairFailure = { turn: lastTurn, failureClass: 'unusable', error: 'The corrected answer was not usable; the usable answer before it stands.' };
924
+ }
925
+ // What became of the follow-up itself, whatever its correction turns did: the answer that stands is its own
926
+ // (or a correction of it), or it gave none that was usable. A follow-up that failed says so already.
893
927
  if (followUp && !followUp.outcome) {
894
- // An answer that is not usable never replaces the usable one it followed.
895
- if (evaluation.usable === false) { ({ evaluation, answerText } = followUp.before); followUp.outcome = 'unusable'; }
896
- else followUp.outcome = evaluation.result?.status === 'COMPLETE' ? 'completed' : 'still-partial';
928
+ followUp.outcome = lastUsable.turn < followUp.turn ? 'unusable' : evaluation.result?.status === 'COMPLETE' ? 'completed' : 'still-partial';
897
929
  }
898
930
  if (followUp) {
899
931
  record.followUp = { turn: followUp.turn, gaps: followUp.gaps.slice(0, 10).map(gap => gap.slice(0, 300)), uncoveredFiles: followUp.uncovered.length,
@@ -901,7 +933,7 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
901
933
  }
902
934
  g.timing?.promptSettled('returned');
903
935
  // A watchdog stop of a failed follow-up is already settled: the earlier answer stands.
904
- if (!run.active || runSignal.aborted || (signal.aborted && followUp?.outcome !== 'failed')) throw abortError(signal);
936
+ if (!run.active || runSignal.aborted || (signal.aborted && followUp?.outcome !== 'failed' && !record.repairFailure)) throw abortError(signal);
905
937
  const result = evaluation.issues?.length && handler.finalize ? await handler.finalize(answerText, evaluation.result, session) : evaluation.result;
906
938
  if (!result) throw new Error('The stage produced no usable result.');
907
939
  if (repairs.length) record.repairs = repairs;
@@ -1025,7 +1057,7 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
1025
1057
  outcome.failure = run.controller.signal.aborted ? run.reason : errorText(error);
1026
1058
  outcome.status = run.controller.signal.aborted ? run.stopStatus : 'INCOMPLETE';
1027
1059
  if (outcome.status === 'INCOMPLETE' && ['review', 'deep', 'quick'].includes(run.mode)) {
1028
- outcome.report = renderIncompleteDraft(run.stages, outcome.failure, settings.outputLanguage, { quick: run.mode === 'quick' });
1060
+ outcome.report = renderIncompleteDraft(run.stages, outcome.failure, settings.outputLanguage);
1029
1061
  run.draft = Boolean(outcome.report);
1030
1062
  if (run.draft && run.active) await displayReport(run, outcome.report, outcome.status);
1031
1063
  }
@@ -1079,10 +1111,21 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
1079
1111
  for (const problem of run.readiness?.deep?.modelProblems ?? []) {
1080
1112
  checks.push({ name: 'Deep model', ok: true, warning: true, detail: `${problem} /pr-deep is unavailable until it is fixed; other commands are not affected.` });
1081
1113
  }
1082
- if (settings.deepPartial) checks.push({ name: 'Deep models', ok: true, warning: true, detail: 'Only some models.deep roles are set; /pr-deep needs all three.' });
1083
- else if (!settings.deepReady) checks.push({ name: 'Deep models', ok: true, detail: 'Not set: /pr-deep stays off until all three models.deep roles name models stronger than models.review: another model, or the same one with a higher variant.' });
1084
- else if (modelSlots('deep').every(slot => settings.models.deep[slot] === settings.models.review[slot])) {
1085
- checks.push({ name: 'Deep models', ok: true, warning: true, detail: 'models.deep repeats models.review, so /pr-deep would only repeat /pr-review; set stronger models there (another model, or a higher variant) for the PRs that need them.' });
1114
+ // What each mode runs with: its passes in order (a model without a variant runs at its provider's default),
1115
+ // and which model rates. /pr-deep and /pr-quick are the same review with other models; an empty list leaves one off.
1116
+ const passesOf = mode => { const list = settings.models[mode].reviewers; return `${list.length} pass${list.length === 1 ? '' : 'es'}: ${list.join(', ')}`; };
1117
+ const ratingOf = mode => raterState(settings, mode) === 'off' ? 'no severity rating (rater: false)' : `severity rating by ${stageModel(settings, roleFor(mode, 'rating'))}${raterState(settings, mode) === 'first' ? ' (the first reviewer model)' : ''}`;
1118
+ // What a mode runs, however its settings write it: a model at #default is that model, and a rater left empty is
1119
+ // the first reviewer model.
1120
+ const effective = model => String(model ?? '').replace(/#default$/, '');
1121
+ const effectiveModels = mode => ({ reviewers: settings.models[mode].reviewers.map(effective),
1122
+ rater: raterState(settings, mode) === 'off' ? false : effective(stageModel(settings, roleFor(mode, 'rating'))) });
1123
+ checks.push({ name: 'Review models', ok: true, detail: `${passesOf('review')}; ${ratingOf('review')}.` });
1124
+ for (const [mode, name, what] of [['deep', 'Deep models', 'stronger models than models.review.reviewers, or more passes'], ['quick', 'Quick models', 'usually one fast model']]) {
1125
+ if (!modeReady(settings, mode)) checks.push({ name, ok: true, detail: `Not set: /pr-${mode} stays off until models.${mode}.reviewers names at least one model (${what}).` });
1126
+ else if (mode === 'deep' && JSON.stringify(effectiveModels('deep')) === JSON.stringify(effectiveModels('review'))) {
1127
+ checks.push({ name, ok: true, warning: true, detail: `${passesOf(mode)}; ${ratingOf(mode)}. models.deep repeats models.review, so /pr-deep would only repeat /pr-review; set stronger models or more passes there for the PRs that need them.` });
1128
+ } else checks.push({ name, ok: true, detail: `${passesOf(mode)}; ${ratingOf(mode)}.` });
1086
1129
  }
1087
1130
  // One OpenCode release is validated; on others, reviews still run and what AZPR needs is detected at runtime.
1088
1131
  const host = capabilities.version === 'unknown' ? 'OpenCode did not report its version' : `OpenCode ${capabilities.version}`;
@@ -1334,8 +1377,7 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
1334
1377
  if (request.target.organization.toLowerCase() !== settings.azure.organization.toLowerCase()) {
1335
1378
  throw new Error(`[AZPR] The PR belongs to organization "${request.target.organization}", but azure.organization is "${settings.azure.organization}". Use a PAT and settings for that organization.`);
1336
1379
  }
1337
- if (mode === 'deep' && !settings.deepReady) throw new Error(`[AZPR] /pr-deep runs the review with the models of models.deep: set all three roles${settings.deepPartial ? ' (only some are set)' : ''}, preferably to models stronger than models.review, then restart the OpenCode service (opencode service restart). No fallback to review models.`);
1338
- if (mode === 'quick' && !settings.quickReady) throw new Error('[AZPR] Set models.quick.reviewer before /pr-quick. No fallback to other models.');
1380
+ if (mode !== 'check' && !modeReady(settings, mode)) throw new Error(`[AZPR] /pr-${mode} is off: models.${mode}.reviewers names no model. Name at least one with /pr-setup or in the settings file${mode === 'deep' ? ' (stronger than those of models.review, or more passes)' : ''}, then restart the OpenCode service (opencode service restart). No fallback to the models of another mode.`);
1339
1381
  // /pr-check checks the review profile's models.
1340
1382
  const profile = mode === 'check' ? 'review' : mode;
1341
1383
  // The comment step after a COMPLETE review: this command's flag, otherwise afterReview.
@@ -1344,25 +1386,30 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
1344
1386
  const shown = after && (after.mode !== 'none' || request.flag) ? after : undefined;
1345
1387
  const startNote = after?.mode === 'preview' ? ` After a COMPLETE review it previews the comments automatically (${after.source}); nothing is posted.`
1346
1388
  : after?.mode === 'publish' ? ` After a COMPLETE review it plans the comments and posts them automatically as the PAT owner (${after.source}); a comment that a safeguard holds back waits for a person.` : '';
1389
+ // What the run starts with, in its first notice: how many passes, with which models.
1390
+ const reviewers = mode === 'check' ? [] : settings.models[mode].reviewers;
1391
+ const startLabel = reviewers.length ? `(${reviewers.length} pass${reviewers.length === 1 ? '' : 'es'}: ${reviewers.join(', ')})` : '';
1347
1392
  const { run, status, report, failure, review, stopped } = await workflow({ origin: input.sessionID, notifySession: input.sessionID, mode, profile,
1348
- userContext: request.userContext, prUrl: request.prUrl, ...(shown ? { afterReview: shown } : {}), ...(startNote ? { startNote } : {}) }, async run => {
1393
+ userContext: request.userContext, prUrl: request.prUrl, ...(shown ? { afterReview: shown } : {}), ...(startNote ? { startNote } : {}), ...(startLabel ? { startLabel } : {}) }, async run => {
1349
1394
  nameConversation(run, request.target);
1350
1395
  if (mode === 'check') { run.phase = 'source check'; return runCheck(run, request); }
1351
1396
  run.phase = 'review';
1352
1397
  const final = await runReview({ azure, runStage, progress, settings, dataFor }, run, request);
1353
- if (final.verification === 'none') {
1354
- run.quickSummary = { coverage: final.coverageSummary,
1355
- high: final.dispositions.filter(d => d.status === 'REPORTED' && d.finding?.severity === 'high').length };
1356
- }
1398
+ // Every later reader of this review goes by what it says of itself: no separate verification, and the
1399
+ // method that produced it. A result that does not say both is not saved as a review.
1400
+ if (final.verification !== 'none' || final.method?.kind !== 'reviewers') throw new Error('[AZPR] The review did not state how its findings were produced; nothing was saved.');
1401
+ run.reviewSummary = { coverage: final.coverageSummary };
1357
1402
  const provenance = reviewProvenance(run);
1358
1403
  const rendered = `${renderFinalReport(final, settings.outputLanguage)}\n\n---\n\n${provenanceReport(provenance, final, settings.outputLanguage)}${final.status === 'COMPLETE' ? '\n\n' + renderCommentActions(run.id, settings.outputLanguage, shown) : ''}`;
1359
1404
  const completedReview = final.status !== 'COMPLETE' ? undefined : {
1360
1405
  id: run.id, origin: run.origin, status: final.status, completedAt: stamp(),
1361
1406
  reportSessions: new Set(run.stages.map(stage => stage.sessionID)), profile: run.profile,
1362
- verification: final.verification ?? 'independent',
1407
+ verification: final.verification, method: clone(final.method),
1363
1408
  request: input.arguments, prUrl: request.prUrl, target: request.target, snapshot: final.snapshot,
1364
1409
  outputLanguage: settings.outputLanguage, provenance, final: clone({ ...final, initialReports: undefined }),
1365
- toolText: [...run.toolText.values()], dataDirectory: undefined, plan: null, publication: new Map(), commentEvidence: [],
1410
+ // In the order of their content, not of the moment each read finished: what the planner is given of
1411
+ // them must not depend on which session was faster.
1412
+ toolText: [...run.toolText.values()].sort((a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : 0)), dataDirectory: undefined, plan: null, publication: new Map(), commentEvidence: [],
1366
1413
  };
1367
1414
  if (completedReview) {
1368
1415
  const data = await dataFor(run);
@@ -1442,9 +1489,13 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
1442
1489
 
1443
1490
  /** /pr-comment --show: the saved preview exactly as it would be posted, without a model or Azure DevOps request. */
1444
1491
  function renderSavedPreview(review) {
1445
- if (!review.plan) return `[AZPR] Review ${review.id} has no saved preview. /pr-comment ${review.id} plans one (a model runs; nothing is posted).`;
1492
+ if (!review.plan) return !reviewMethod(review) ? `[AZPR] Review ${review.id} has no saved preview, and it does not say how its findings were produced in a way this version knows, so it cannot be planned or posted; run a new review.`
1493
+ : !modeReady(settings, review.profile) ? `[AZPR] Review ${review.id} has no saved preview, and models.${review.profile}.reviewers names no model to plan its comments with. Name one there (its first entry plans the comments) and restart the OpenCode service; /pr-comment ${review.id} then plans one.`
1494
+ : `[AZPR] Review ${review.id} has no saved preview. /pr-comment ${review.id} plans one (a model runs; nothing is posted).`;
1446
1495
  const hold = holdNote(review);
1447
- const state = publicationStarted(review) ? `Publication of this preview has started; /pr-comment ${review.id} --publish retries what is not posted yet.`
1496
+ // A review whose method this version does not know is shown and never offered for posting: commentRun refuses it.
1497
+ const state = !reviewMethod(review) ? `This review does not say how its findings were produced in a way this version knows, so it cannot be posted; run a new review.`
1498
+ : publicationStarted(review) ? `Publication of this preview has started; /pr-comment ${review.id} --publish retries what is not posted yet.`
1448
1499
  : everyFindingExcluded(review) ? 'A person excluded every finding, so nothing will be posted.'
1449
1500
  : `Nothing was posted. ${hold || `To post this exact preview: /pr-comment ${review.id} --publish`}`;
1450
1501
  const safe = enclose('comment', renderPlan(review));
@@ -1529,7 +1580,7 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
1529
1580
  // The preview shown again offers what its own receipt offered, as the review is now: both are read here,
1530
1581
  // before anything is awaited, so that what is offered is what the text shows.
1531
1582
  const saved = renderSavedPreview(review);
1532
- const next = review.plan && previewActions(review, { held: Boolean(holdNote(review)) });
1583
+ const next = review.plan && reviewMethod(review) && previewActions(review, { held: Boolean(holdNote(review)), plannable: modeReady(settings, review.profile) });
1533
1584
  output.text = `${saved}${await kept ? '' : UNSAVED_CHOICE}`;
1534
1585
  if (next) output.extra = { next };
1535
1586
  return;
@@ -1576,13 +1627,15 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
1576
1627
  }
1577
1628
  }
1578
1629
  async function commentRun(review, { publish, notifySession, auto, adjust, seen }, output, dispatch) {
1579
- // A saved review whose verification cannot be established is never commented on.
1580
- const verification = reviewVerification(review);
1581
- if (!verification) throw new Error(`[AZPR] Review ${review.id} does not say whether its findings were verified; run a new review before commenting.`);
1582
- if (review.profile === 'quick' && !settings.quickReady) throw new Error(`[AZPR] Review ${review.id} is a quick review; set models.quick.reviewer, which plans its comments, before /pr-comment.`);
1583
- let planning = false, held = [], nothingNew = '', discussions = null, changed = [], earlier = '', hold = '', shown;
1630
+ // A saved review whose method cannot be established is never commented on.
1631
+ const method = reviewMethod(review);
1632
+ if (!method) throw new Error(`[AZPR] Review ${review.id} does not say how its findings were produced in a way this version knows; run a new review before commenting.`);
1633
+ // Planning needs the first reviewer model of the review's mode; posting a saved preview needs no model.
1634
+ const planning = !publish || !review.plan || Boolean(adjust);
1635
+ if (planning && !modeReady(settings, review.profile)) throw new Error(`[AZPR] Review ${review.id} is a /pr-${review.profile} review, and models.${review.profile}.reviewers names no model to plan its comments with. Name one there (its first entry plans the comments) and restart the OpenCode service${review.plan ? `, or post the saved preview with /pr-comment ${review.id} --publish` : ''}.`);
1636
+ let held = [], nothingNew = '', discussions = null, changed = [], earlier = '', hold = '', shown;
1584
1637
  const step = auto && `(automatic ${auto.mode === 'publish' ? 'publication' : 'preview'} after review ${review.id} completed; ${auto.source})`;
1585
- const { run, status, report, failure } = await workflow({ origin: review.origin, notifySession, mode: 'comment',
1638
+ const { run, status, report, failure } = await workflow({ origin: review.origin, notifySession, mode: 'comment', planning,
1586
1639
  profile: review.profile, review, lockKey: targetKey(review.target), startNote: ` It acts on ${describeReview(review)}.`,
1587
1640
  ...(auto ? { auto, startLabel: step } : adjust ? { startLabel: `(adjusting the findings of review ${review.id})` } : {}) }, async run => {
1588
1641
  run.snapshot = review.snapshot;
@@ -1608,30 +1661,38 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
1608
1661
  review.planCreatedAt = new Date().toISOString();
1609
1662
  await savePreview(review);
1610
1663
  } else if (!publish || !review.plan) {
1611
- planning = true;
1612
1664
  run.phase = 'comment planning';
1613
1665
  review.plan = null; // Never leave an obsolete preview after a failed refresh.
1614
1666
  review.commentEvidence = []; // Evidence belongs to the plan being made.
1615
- // The disclosure names the method (and, in the summary, incomplete coverage) of a quick review.
1616
- const commentModel = settings.models[review.profile][commentSlot(review.profile)];
1617
- review.attribution = commentAttribution(review.provenance, review.outputLanguage, commentModel, { verification });
1618
- review.summaryAttribution = commentAttribution(review.provenance, review.outputLanguage, commentModel, { verification, coverage: review.final.coverageSummary });
1667
+ // The disclosure names the review's method and, in the summary, incomplete coverage; a verified review
1668
+ // saved by 0.4.x keeps its own line, and is planned by the role whose wording describes it.
1669
+ const commentModel = firstModel(settings, review.profile);
1670
+ const planner = roleFor(run.profile, method === 'verified' ? 'comment-plan-verified' : 'comment-plan');
1671
+ review.attribution = commentAttribution(review.provenance, review.outputLanguage, commentModel, { method });
1672
+ review.summaryAttribution = commentAttribution(review.provenance, review.outputLanguage, commentModel, { method, coverage: review.final.coverageSummary });
1619
1673
  const data = await dataFor(run);
1620
1674
  // Read live discussions once for the planner's duplicate checks; the
1621
1675
  // planner can still read threads itself if this read fails.
1622
- try { discussions = discussionDigest(await azure.threads(run, review.snapshot)); }
1676
+ // The markers among them, each with its thread: a comment for several places does not stand on
1677
+ // lines that already carry a comment of AZPR's.
1678
+ let posted = null;
1679
+ try {
1680
+ const threads = await azure.threads(run, review.snapshot);
1681
+ discussions = discussionDigest(threads);
1682
+ posted = markersInThreads(threads);
1683
+ }
1623
1684
  catch (error) {
1624
1685
  if (!run.active) throw error;
1625
1686
  run.debug.warnings.push(`Existing discussions could not be read before planning: ${errorText(error)}`);
1626
1687
  }
1627
1688
  // Planning pages run side by side, never more than the configured sessions.
1628
1689
  const parallelPages = Math.min(PLANNING_PARALLEL_PAGES, settings.workflow.parallelSessions);
1629
- review.plan = await prepareComments(review, data, (payload, handler) => runStage(run, roleFor(run.profile, 'comment-plan'), payload, handler,
1630
- { label: `page ${payload.commentWork.page}/${payload.commentWork.pages}` }),
1631
- { progress: message => progress(run, message), discussions, parallel: parallelPages,
1690
+ // The grouping pass, which looks for one defect at several places before the pages are made, is a stage like a page.
1691
+ review.plan = await prepareComments(review, data, (payload, handler) => runStage(run, planner, payload, handler,
1692
+ { label: payload.commentWork.kind === 'group' ? 'grouping' : `page ${payload.commentWork.page}/${payload.commentWork.pages}` }),
1693
+ { progress: message => progress(run, message), discussions, posted, parallel: parallelPages, active: () => run.active,
1632
1694
  fetchSource: path => azure.fileContent(run, review.snapshot, path, review.snapshot.head) });
1633
1695
  review.planCreatedAt = new Date().toISOString();
1634
- planning = false;
1635
1696
  if (everAdjusted(review)) await savePreview(review);
1636
1697
  else await persistReview(review);
1637
1698
  await run.debug.write('comment-plan.json', { sourceReview: review.id, snapshot: review.snapshot, parallelPages, ...review.plan });
@@ -1670,10 +1731,10 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
1670
1731
  if (everAdjusted(review)) earlier = describeEarlierText(review, result.otherComments);
1671
1732
  return { status: result.status, report: `${preview}\n\n${renderPublication(review, result)}`, failure: result.reason ?? '' };
1672
1733
  }, dispatch);
1673
- // What this run decides about the review's preview and its own sessions is settled here, before anything is
1674
- // awaited: the command locks are released already, so a later command may be planning or saving while this
1675
- // run's sessions are deleted.
1676
- if (planning) review.plan = null;
1734
+ // What this run decides about its own sessions is settled here, before anything is awaited: the command locks
1735
+ // are released already, so a later command may be planning or saving while this run's sessions are deleted.
1736
+ // The preview is not touched here: a planning that failed left none (the run cleared it before planning, under
1737
+ // the lock), and one that a later command saved since is that command's.
1677
1738
  // A comment run keeps none of its sessions; the record names them before they are deleted.
1678
1739
  const obsolete = scheduleCleanup(run, review);
1679
1740
  await persistReview(review);
@@ -1848,7 +1909,7 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
1848
1909
  touch(g, `tool ${name} ended`);
1849
1910
  }
1850
1911
  let observation;
1851
- if (outcome.observation && ['initial', 'final'].includes(ROLES[g.role].format)) {
1912
+ if (outcome.observation && ROLES[g.role].format === 'initial') {
1852
1913
  // Keep observed source text with its request for anchor checks in comment planning. A stopped call does not
1853
1914
  // wait for that save, which finishes by itself.
1854
1915
  try {
@@ -1889,7 +1950,7 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
1889
1950
  if (event.prompt?.agents?.some(a => privateAgent(a.id) || privateAgent(a.name) || privateAgent(a.agent))) {
1890
1951
  throw new Error('[AZPR] Private reviewers cannot be mentioned or delegated.');
1891
1952
  }
1892
- if (!seenSessions.has(event.sessionID)) return;
1953
+ if (!seenSessions.has(event.sessionID) && !createdEarlier.has(event.sessionID)) return;
1893
1954
  const g = grants.get(event.sessionID);
1894
1955
  const pending = g?.pending;
1895
1956
  if (!g?.run.active || !pending || event.prompt.text !== pending.text || event.metadata?.azprGrant !== pending.nonce ||
@@ -1904,7 +1965,7 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
1904
1965
  }));
1905
1966
  registrations.push(await context.session.hook('context', async event => {
1906
1967
  const tools = event.tools && typeof event.tools === 'object' ? event.tools : null;
1907
- if (!ownRole(event.agent) && !seenSessions.has(event.sessionID)) {
1968
+ if (!privateSession(event)) {
1908
1969
  // AZPR's PAT-backed tools exist only for its private reviewers.
1909
1970
  if (tools) for (const name of REVIEW_TOOL_NAMES) delete tools[name];
1910
1971
  return;
@@ -1914,14 +1975,16 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
1914
1975
  // Show only the tools this role may run, so the model does not waste turns on others.
1915
1976
  const allowed = new Set(allowedTools(g.role, settings.shell));
1916
1977
  if (tools) for (const name of Object.keys(tools)) if (!allowed.has(name)) delete tools[name];
1917
- if (ROLES[g.role].stage === 'comment-plan' && (g.checkpointRequested || g.calls >= 12)) {
1978
+ if (commentRole(g.role) && (g.checkpointRequested || g.calls >= 12)) {
1918
1979
  event.tools = {};
1919
- event.system?.push?.({ type: 'text', text: 'Finish this work page now; tools are unavailable for this response. Return exactly one JSON object. If all assigned findings are handled, return READY. Otherwise return CONTINUE with completed comments/skips and a "continuation" note naming exact data references, completed checks and remaining work.' });
1980
+ event.system?.push?.({ type: 'text', text: g.grouping
1981
+ ? 'Finish the grouping now; tools are unavailable for this response. Return exactly one JSON object: {"status": "READY", "groups": [...]} with the groups you are sure of from the findings in your input, and [] when there is none. This pass has no continuation.'
1982
+ : 'Finish this work page now; tools are unavailable for this response. Return exactly one JSON object. If all assigned findings are handled, return READY. Otherwise return CONTINUE with completed comments/skips and a "continuation" note naming exact data references, completed checks and remaining work.' });
1920
1983
  }
1921
1984
  g.primaryPrepared = true;
1922
1985
  }));
1923
1986
  registrations.push(await context.session.hook('model.request', async event => {
1924
- if (!ownRole(event.agent) && !seenSessions.has(event.sessionID)) return;
1987
+ if (!privateSession(event)) return;
1925
1988
  const observed = grants.get(event.sessionID);
1926
1989
  const kind = Object.hasOwn(observed?.requestKinds ?? {}, event.kind) ? event.kind : 'unknown';
1927
1990
  if (observed) observed.requestKinds[kind]++;
@@ -1945,7 +2008,7 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
1945
2008
  }
1946
2009
  }));
1947
2010
  registrations.push(await context.session.hook('retry', async event => {
1948
- if (!ownRole(event.agent) && !seenSessions.has(event.sessionID)) return;
2011
+ if (!privateSession(event)) return;
1949
2012
  const g = grants.get(event.sessionID);
1950
2013
  const proposed = event.decision?.retry === true;
1951
2014
  // A used-up usage or spend limit fails every attempt the same way; the failed turn names it.
@@ -1990,7 +2053,8 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
1990
2053
  }
1991
2054
  registrations.push(await context.tool.hook('execute.before', async event => {
1992
2055
  if (event.tool === 'subagent' && privateAgent(event.input?.agent)) throw new Error('[AZPR] Private reviewers cannot be delegated.');
1993
- if (!seenSessions.has(event.sessionID) && !privateAgent(event.agent)) return;
2056
+ // A tool call in a private session, also one an earlier process created, needs the grant of a command under way.
2057
+ if (!privateSession(event)) return;
1994
2058
  const g = grants.get(event.sessionID);
1995
2059
  if (!g?.run.active || g.role !== event.agent) throw new Error('[AZPR] Review tool authorization expired.');
1996
2060
  touch(g, `tool ${event.tool} started`);
@@ -2032,7 +2096,7 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
2032
2096
  visible = notice;
2033
2097
  }
2034
2098
  g.visibleCharacters += visible.length + (g.toolArgumentCharacters.get(call) ?? 0);
2035
- if (ROLES[g.role].stage === 'comment-plan' && g.visibleCharacters >= COMMENT_TURN_CHARACTERS) g.checkpointRequested = true;
2099
+ if (commentRole(g.role) && g.visibleCharacters >= COMMENT_TURN_CHARACTERS) g.checkpointRequested = true;
2036
2100
  } catch {
2037
2101
  g.run.debug.warnings.push('A comment tool result could not be saved privately; it stays in the session.');
2038
2102
  }
package/src/session.mjs CHANGED
@@ -210,8 +210,9 @@ export function restartIndex(texts) {
210
210
  /**
211
211
  * Classify a failed stage for the runtime's retry policy.
212
212
  * - overflow: the host attempted compaction in the failed turn (context full) or
213
- * the provider rejected size. A refused background summary
214
- * (`experimental.background_compaction`) is not evidence: the turn went on, so
213
+ * the provider rejected size. A refused background summary (OpenCode's
214
+ * `compaction.background`, on by default in 2.3.2; before that
215
+ * `experimental.background_compaction`) is not evidence: the turn went on, so
215
216
  * its own failure decides.
216
217
  * - transient: interrupted streams, provider 408/409/425/429/5xx, missing idle,
217
218
  * unexpected host messages.