@adhdev/mesh-shared 1.0.82-rc.45 → 1.0.82-rc.47
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 +2 -0
- package/dist/index.js +452 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +402 -1
- package/dist/index.mjs.map +1 -1
- package/dist/light-task.d.ts +89 -0
- package/dist/mesh-tool-names.d.ts +2 -2
- package/dist/task-source-phase.d.ts +9 -1
- package/dist/task-stages.d.ts +206 -0
- package/dist/turn-evidence.d.ts +16 -2
- package/dist/turn-ipc-mission.d.ts +2 -0
- package/dist/worker-protocol.d.ts +25 -0
- package/package.json +1 -1
- package/src/index.ts +2 -0
- package/src/light-task.ts +103 -0
- package/src/mesh-tool-names.ts +3 -0
- package/src/task-source-phase.ts +10 -1
- package/src/task-stages.ts +455 -0
- package/src/turn-evidence.ts +29 -0
- package/src/turn-ipc-mission.ts +4 -1
- package/src/worker-protocol.ts +48 -0
package/dist/index.mjs
CHANGED
|
@@ -755,9 +755,12 @@ var CANONICAL_MESH_TOOL_NAMES = [
|
|
|
755
755
|
"mesh_enqueue_task",
|
|
756
756
|
"mesh_view_queue",
|
|
757
757
|
"mesh_queue_cancel",
|
|
758
|
+
"mesh_task_stage_decide",
|
|
758
759
|
"mesh_direct_cancel",
|
|
759
760
|
"mesh_queue_requeue",
|
|
760
761
|
"mesh_queue_revise",
|
|
762
|
+
"mesh_light_land",
|
|
763
|
+
"mesh_light_discard",
|
|
761
764
|
"mesh_send_task",
|
|
762
765
|
"mesh_read_chat",
|
|
763
766
|
"mesh_read_debug",
|
|
@@ -1717,6 +1720,15 @@ function isWorkerTool(value) {
|
|
|
1717
1720
|
return typeof value === "string" && WORKER_TOOL_SET.has(value);
|
|
1718
1721
|
}
|
|
1719
1722
|
var WORKER_PROTOCOL_FOOTER_MARKER = "--- adhdev worker protocol ---";
|
|
1723
|
+
function renderLightWorkspaceRules(light) {
|
|
1724
|
+
const base = light.ossBaseSha ? `${light.baseSha} (oss ${light.ossBaseSha})` : light.baseSha;
|
|
1725
|
+
return [
|
|
1726
|
+
`You are working in a temporary light workspace at \`${light.workspace}\` based on \`${base}\`. Work only inside it. Commit your change there (the branch is already set up); do not push.`,
|
|
1727
|
+
"Do not run `npm install`/`npm ci`/`npm rebuild`/`node-gyp`, do not change package.json or lockfiles \u2014 if the fix needs a dependency change, stop and report `blocked`.",
|
|
1728
|
+
"Do not start long-running servers on fixed ports. Run the narrowest tests that cover your change and list them in `report_completion.testsRun`.",
|
|
1729
|
+
light.ownedPaths.length ? `Stay inside \`owned_paths\` (${light.ownedPaths.join(", ")}); if you must touch more, say why in the summary.` : "Stay inside the paths the task names; if you must touch more, say why in the summary."
|
|
1730
|
+
];
|
|
1731
|
+
}
|
|
1720
1732
|
function hasWorkerProtocolFooter(body) {
|
|
1721
1733
|
return typeof body === "string" && body.includes(WORKER_PROTOCOL_FOOTER_MARKER);
|
|
1722
1734
|
}
|
|
@@ -1738,6 +1750,7 @@ function renderWorkerProtocolFooter(input = {}) {
|
|
|
1738
1750
|
if (input.readonly) scope.push("read-only");
|
|
1739
1751
|
if (scope.length) lines.push(`You are a delegated worker (${scope.join(", ")}).`);
|
|
1740
1752
|
else lines.push("You are a delegated worker.");
|
|
1753
|
+
if (input.light) lines.push(...renderLightWorkspaceRules(input.light));
|
|
1741
1754
|
if (input.workerMcp === false) {
|
|
1742
1755
|
lines.push(
|
|
1743
1756
|
"This session has NO adhdev worker tools (`report_completion`, `progress_update`, `peer_context_pull`, `git_*`) \u2014 do not look for them. When your work is finished, blocked, or has failed, end your turn with a plain final summary: what you did, what you found, which files you changed, and where you left the branch. That final message is what the coordinator receives.",
|
|
@@ -1765,8 +1778,21 @@ function renderWorkerProtocolFooter(input = {}) {
|
|
|
1765
1778
|
`The ${input.enclosedHandoffNotes} handoff note(s) above were written by agents who touched this code before you; honour their conflict guidance and add your own in \`handoff_notes\` when you report.`
|
|
1766
1779
|
);
|
|
1767
1780
|
}
|
|
1781
|
+
if (input.stage) lines.push(...renderStageProtocolLines(input.stage));
|
|
1768
1782
|
return lines.join("\n");
|
|
1769
1783
|
}
|
|
1784
|
+
function renderStageProtocolLines(stage) {
|
|
1785
|
+
if (stage.role === "review") {
|
|
1786
|
+
return [
|
|
1787
|
+
`STAGE: you are the independent reviewer (round ${stage.round} of at most ${stage.maxRevisions + 1}). Read the input artifacts first (diff, self-check log, previous verdict).` + (stage.workspace ? ` Your workspace ${stage.workspace} is pinned to the round head \u2014 you may run tests, but nothing you change lands; do not fix, record findings instead.` : " Do not modify the workspace: read it, and record findings instead of fixing."),
|
|
1788
|
+
"Your `report_completion` MUST carry `review`: {verdict: approve | approve_with_nits | changes_requested | reject_approach, findings[{id, severity, category, claim, evidence, suggested_fix?}], checked[], not_checked[], tests_run?[]}. `changes_requested` needs at least one blocking/major finding; `approve` allows none. From round 2 also give `prior_findings[{id, status}]` for every earlier blocking/major finding. `reject_approach` is only for a wrong approach, not for fixable defects."
|
|
1789
|
+
];
|
|
1790
|
+
}
|
|
1791
|
+
return [
|
|
1792
|
+
`STAGE: your \`report_completion\` is a stage report (${stage.role}, round ${stage.round}). An independent reviewer reads your diff next, so commit your work and leave the workspace clean before you report. You may receive review findings as a follow-up memo in this same session.`,
|
|
1793
|
+
...stage.role === "revise" ? ["For every open blocking/major finding in the memo, fill `finding_responses[{id, response: fixed | disputed, note}]` \u2014 `disputed` needs your reasoning; the reviewer judges it next round."] : []
|
|
1794
|
+
];
|
|
1795
|
+
}
|
|
1770
1796
|
function stripWorkerProtocolFooter(body) {
|
|
1771
1797
|
if (typeof body !== "string") return body;
|
|
1772
1798
|
const at = body.indexOf(WORKER_PROTOCOL_FOOTER_MARKER);
|
|
@@ -2029,6 +2055,17 @@ function sanitizeRefusalCode(value) {
|
|
|
2029
2055
|
if (!normalized) return void 0;
|
|
2030
2056
|
return normalized.slice(0, 64);
|
|
2031
2057
|
}
|
|
2058
|
+
var DISPATCH_REFUSAL_DETAIL_MAX = 200;
|
|
2059
|
+
function sanitizeDispatchRefusalDetail(code, message) {
|
|
2060
|
+
const cleanCode = sanitizeRefusalCode(code);
|
|
2061
|
+
let cleanMessage;
|
|
2062
|
+
if (typeof message === "string") {
|
|
2063
|
+
const line = message.replace(/(?:[A-Za-z]:)?[\\/](?:Users|home)[\\/][^\s\\/]+/g, "~").replace(/[\u0000-\u001f\u007f]+/g, " ").replace(/\s+/g, " ").trim();
|
|
2064
|
+
if (line) cleanMessage = line.length > DISPATCH_REFUSAL_DETAIL_MAX ? `${line.slice(0, DISPATCH_REFUSAL_DETAIL_MAX - 1)}\u2026` : line;
|
|
2065
|
+
}
|
|
2066
|
+
if (!cleanCode && !cleanMessage) return void 0;
|
|
2067
|
+
return { ...cleanCode ? { code: cleanCode } : {}, ...cleanMessage ? { message: cleanMessage } : {} };
|
|
2068
|
+
}
|
|
2032
2069
|
var CONSUME_PROFILES = ["default", "native_source"];
|
|
2033
2070
|
var SESSION_REBOUND_REASONS = ["restart", "live_holder"];
|
|
2034
2071
|
var SUSPENSION_MODALS = ["approval", "choice"];
|
|
@@ -2103,6 +2140,8 @@ var TURN_REASONS = [
|
|
|
2103
2140
|
"reclaim_budget_exhausted",
|
|
2104
2141
|
"hollow_max_retries",
|
|
2105
2142
|
"migration_orphan",
|
|
2143
|
+
// a stopping attempt whose writer node stayed unreachable (or was removed) past the bound
|
|
2144
|
+
"writer_unreachable",
|
|
2106
2145
|
// reclaims (generation + 1)
|
|
2107
2146
|
"dispatch_refused_session_exited",
|
|
2108
2147
|
"dispatch_refused_no_target",
|
|
@@ -3076,13 +3115,14 @@ function isLedgerQueryEntryWire(value) {
|
|
|
3076
3115
|
return true;
|
|
3077
3116
|
}
|
|
3078
3117
|
function isLedgerQuerySummaryWire(value) {
|
|
3079
|
-
const keys = ["meshId", "totalEntries", "taskDispatched", "taskCompleted", "taskFailed", "taskBlocked", "taskStalled", "sessionLaunched", "checkpointCreated", "lastActivityAt", "recentFailures"];
|
|
3118
|
+
const keys = ["meshId", "totalEntries", "taskDispatched", "taskCompleted", "taskFailed", "taskBlocked", "taskStalled", "sessionLaunched", "checkpointCreated", "lastActivityAt", "recentFailures", "taskBlocked", "refineFailed"];
|
|
3080
3119
|
if (!isRecord(value) || !hasOnlyKeys2(value, keys)) return false;
|
|
3081
3120
|
if (!isEvidenceIdentifier(value.meshId)) return false;
|
|
3082
3121
|
for (const k of ["totalEntries", "taskDispatched", "taskCompleted", "taskFailed", "taskStalled", "sessionLaunched", "checkpointCreated", "recentFailures"]) {
|
|
3083
3122
|
if (!isNonNegativeInt(value[k])) return false;
|
|
3084
3123
|
}
|
|
3085
3124
|
if (value.taskBlocked !== void 0 && !isNonNegativeInt(value.taskBlocked)) return false;
|
|
3125
|
+
if (value.refineFailed !== void 0 && !isNonNegativeInt(value.refineFailed)) return false;
|
|
3086
3126
|
if (value.lastActivityAt !== null && typeof value.lastActivityAt !== "string") return false;
|
|
3087
3127
|
return true;
|
|
3088
3128
|
}
|
|
@@ -4214,6 +4254,34 @@ function isProviderQuestionBinding(value) {
|
|
|
4214
4254
|
return b.transport === "codex_async" ? b.requestId === void 0 : typeof b.requestId === "string" && !!b.requestId.trim() || typeof b.requestId === "number" && Number.isFinite(b.requestId);
|
|
4215
4255
|
}
|
|
4216
4256
|
|
|
4257
|
+
// src/task-source-phase.ts
|
|
4258
|
+
function reviewIndependenceOf(review) {
|
|
4259
|
+
return review.independence ?? "different_provider";
|
|
4260
|
+
}
|
|
4261
|
+
|
|
4262
|
+
// src/light-task.ts
|
|
4263
|
+
var LIGHT_REJECT = {
|
|
4264
|
+
REQUIRES_LOCAL_BASE: "light_requires_local_base",
|
|
4265
|
+
NOT_CONFIGURED: "light_workspace_not_configured",
|
|
4266
|
+
REQUIRES_OWNED_PATHS: "light_requires_owned_paths",
|
|
4267
|
+
MODE_CONFLICT: "light_mode_conflict"
|
|
4268
|
+
};
|
|
4269
|
+
var LIGHT_HOLD = {
|
|
4270
|
+
PREPARE_FAILED: "light_workspace_prepare_failed",
|
|
4271
|
+
LIMIT: "light_workspace_limit",
|
|
4272
|
+
DISK_LOW: "light_workspace_disk_low",
|
|
4273
|
+
CAP: "max_light_parallel_tasks_reached"
|
|
4274
|
+
};
|
|
4275
|
+
var LIGHT_BLOCK_REASONS = [
|
|
4276
|
+
"light_uncommitted_changes",
|
|
4277
|
+
"light_dependency_change",
|
|
4278
|
+
"light_lineage_unproven",
|
|
4279
|
+
"shared_checkout_mutated"
|
|
4280
|
+
];
|
|
4281
|
+
var LIGHT_WARNINGS = ["shared_checkout_changed_during_task", "light_base_dirty_overlap"];
|
|
4282
|
+
var LIGHT_LAND_MODES = ["refine", "apply_to_checkout"];
|
|
4283
|
+
var LIGHT_TESTS_RUN_MAX = 20;
|
|
4284
|
+
|
|
4217
4285
|
// src/relay-reprobe.ts
|
|
4218
4286
|
var RELAY_REPROBE_BASE_DELAY_MS = 6e4;
|
|
4219
4287
|
var RELAY_REPROBE_MAX_DELAY_MS = 5 * 6e4;
|
|
@@ -4293,6 +4361,289 @@ var RelayReprobeScheduler = class {
|
|
|
4293
4361
|
this.schedule();
|
|
4294
4362
|
}
|
|
4295
4363
|
};
|
|
4364
|
+
|
|
4365
|
+
// src/task-stages.ts
|
|
4366
|
+
var REVIEW_VERDICTS = ["approve", "approve_with_nits", "changes_requested", "reject_approach"];
|
|
4367
|
+
var FINDING_SEVERITIES = ["blocking", "major", "minor", "nit"];
|
|
4368
|
+
var FINDING_CATEGORIES = ["correctness", "regression", "test_gap", "scope", "security", "performance", "maintainability"];
|
|
4369
|
+
var PRIOR_FINDING_STATUSES = ["resolved", "unresolved", "dispute_accepted", "dispute_rejected"];
|
|
4370
|
+
var FINDING_RESPONSE_KINDS = ["fixed", "disputed"];
|
|
4371
|
+
var STAGE_PHASES = ["implementing", "self_checking", "awaiting_review", "reviewing", "revising", "done"];
|
|
4372
|
+
var STAGE_PARKED_PHASES = ["self_checking", "awaiting_review", "reviewing"];
|
|
4373
|
+
var STAGE_INDEPENDENCE_MODES = ["different_provider", "fresh_session_ok"];
|
|
4374
|
+
var STAGE_ROLES = ["implement", "revise", "review"];
|
|
4375
|
+
var STAGE_BLOCKED_REASONS = [
|
|
4376
|
+
"review_unresolved",
|
|
4377
|
+
"review_rejected_approach",
|
|
4378
|
+
"review_unavailable",
|
|
4379
|
+
"self_check_failed",
|
|
4380
|
+
"stage_pipeline_ceiling",
|
|
4381
|
+
"reviewer_mutated_source",
|
|
4382
|
+
// The read-lease checkout could not be fingerprinted (start or end): the review's integrity cannot be verified.
|
|
4383
|
+
"reviewer_integrity_unverifiable"
|
|
4384
|
+
];
|
|
4385
|
+
var STAGE_DECIDE_ACTIONS = ["accept", "revise_once", "rereview", "abandon"];
|
|
4386
|
+
var STAGE_MAX_REVISIONS_LIMIT = 3;
|
|
4387
|
+
var STAGE_DEFAULT_MAX_REVISIONS = 2;
|
|
4388
|
+
var STAGE_SELF_CHECK_MAX_BOUNCES = 2;
|
|
4389
|
+
var STAGE_INDEPENDENCE_FALLBACK_MS = 10 * 60 * 1e3;
|
|
4390
|
+
var STAGE_PIPELINE_CEILING_DEFAULT_MS = 4 * 60 * 60 * 1e3;
|
|
4391
|
+
var REVIEW_FINDINGS_MAX = 30;
|
|
4392
|
+
var REVIEW_CLAIM_MAX_CHARS = 500;
|
|
4393
|
+
var REVIEW_EVIDENCE_MAX_CHARS = 1e3;
|
|
4394
|
+
var REVIEW_FIX_MAX_CHARS = 500;
|
|
4395
|
+
var REVIEW_FINDING_ID_MAX_CHARS = 40;
|
|
4396
|
+
var REVIEW_CHECKED_MAX = 20;
|
|
4397
|
+
var REVIEW_NOTE_MAX_CHARS = 500;
|
|
4398
|
+
var REVIEW_TESTS_RUN_MAX = 20;
|
|
4399
|
+
var FINDING_RESPONSES_MAX = 30;
|
|
4400
|
+
function makeGuard4(values) {
|
|
4401
|
+
const set = new Set(values);
|
|
4402
|
+
return (value) => typeof value === "string" && set.has(value);
|
|
4403
|
+
}
|
|
4404
|
+
var isReviewVerdict = makeGuard4(REVIEW_VERDICTS);
|
|
4405
|
+
var isFindingSeverity = makeGuard4(FINDING_SEVERITIES);
|
|
4406
|
+
var isFindingCategory = makeGuard4(FINDING_CATEGORIES);
|
|
4407
|
+
var isPriorFindingStatus = makeGuard4(PRIOR_FINDING_STATUSES);
|
|
4408
|
+
var isFindingResponseKind = makeGuard4(FINDING_RESPONSE_KINDS);
|
|
4409
|
+
var isStageBlockedReason = makeGuard4(STAGE_BLOCKED_REASONS);
|
|
4410
|
+
var isRecord4 = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
4411
|
+
function isBlockingSeverity(severity) {
|
|
4412
|
+
return severity === "blocking" || severity === "major";
|
|
4413
|
+
}
|
|
4414
|
+
function resolveStagePlan(raw, task, opts = {}) {
|
|
4415
|
+
const eligible = isStageEligibleTask(task);
|
|
4416
|
+
if (raw === void 0 || raw === null) return (opts.defaultOn ?? true) && defaultsOnFor(task) ? defaultStagePlan() : null;
|
|
4417
|
+
if (raw === false) return null;
|
|
4418
|
+
if (raw === true) {
|
|
4419
|
+
if (!eligible) throw new Error(`invalid_review_option: review requires a non-readonly code_change task (got taskMode=${task.taskMode ?? "unset"}${task.readonly ? ", readonly" : ""})`);
|
|
4420
|
+
return defaultStagePlan();
|
|
4421
|
+
}
|
|
4422
|
+
if (!isRecord4(raw)) throw new Error("invalid_review_option: review must be true, false or {max_revisions?, independence?}");
|
|
4423
|
+
const allowed = /* @__PURE__ */ new Set(["max_revisions", "maxRevisions", "independence"]);
|
|
4424
|
+
for (const key of Object.keys(raw)) {
|
|
4425
|
+
if (!allowed.has(key)) throw new Error(`invalid_review_option: unknown review key '${key}' (expected max_revisions, independence)`);
|
|
4426
|
+
}
|
|
4427
|
+
if (!eligible) throw new Error(`invalid_review_option: review requires a non-readonly code_change task (got taskMode=${task.taskMode ?? "unset"}${task.readonly ? ", readonly" : ""})`);
|
|
4428
|
+
const rawMax = raw.max_revisions ?? raw.maxRevisions;
|
|
4429
|
+
let maxRevisions = STAGE_DEFAULT_MAX_REVISIONS;
|
|
4430
|
+
if (rawMax !== void 0) {
|
|
4431
|
+
if (typeof rawMax !== "number" || !Number.isInteger(rawMax) || rawMax < 0 || rawMax > STAGE_MAX_REVISIONS_LIMIT) {
|
|
4432
|
+
throw new Error(`invalid_review_option: max_revisions must be an integer 0..${STAGE_MAX_REVISIONS_LIMIT}`);
|
|
4433
|
+
}
|
|
4434
|
+
maxRevisions = rawMax;
|
|
4435
|
+
}
|
|
4436
|
+
let independence = "fresh_session_ok";
|
|
4437
|
+
if (raw.independence !== void 0) {
|
|
4438
|
+
if (!STAGE_INDEPENDENCE_MODES.includes(raw.independence)) {
|
|
4439
|
+
throw new Error(`invalid_review_option: independence must be one of ${STAGE_INDEPENDENCE_MODES.join(" | ")}`);
|
|
4440
|
+
}
|
|
4441
|
+
independence = raw.independence;
|
|
4442
|
+
}
|
|
4443
|
+
return { review: true, maxRevisions, independence };
|
|
4444
|
+
}
|
|
4445
|
+
function defaultStagePlan() {
|
|
4446
|
+
return { review: true, maxRevisions: STAGE_DEFAULT_MAX_REVISIONS, independence: "fresh_session_ok" };
|
|
4447
|
+
}
|
|
4448
|
+
function isStageEligibleTask(task) {
|
|
4449
|
+
if (task.readonly) return false;
|
|
4450
|
+
return (task.taskMode ?? "code_change") === "code_change";
|
|
4451
|
+
}
|
|
4452
|
+
function defaultsOnFor(task) {
|
|
4453
|
+
return isStageEligibleTask(task) && (task.difficulty === "medium" || task.difficulty === "difficult");
|
|
4454
|
+
}
|
|
4455
|
+
function str2(value) {
|
|
4456
|
+
return typeof value === "string" ? value.trim() : "";
|
|
4457
|
+
}
|
|
4458
|
+
function validateStringList(value, field, max, maxChars, errors, minItems = 0) {
|
|
4459
|
+
if (!Array.isArray(value)) {
|
|
4460
|
+
errors.push({ field, message: `${field} must be an array of strings` });
|
|
4461
|
+
return [];
|
|
4462
|
+
}
|
|
4463
|
+
if (value.length > max) errors.push({ field, message: `${field} has ${value.length} entries, over the ${max} limit` });
|
|
4464
|
+
const out = [];
|
|
4465
|
+
for (const item of value) {
|
|
4466
|
+
const text = str2(item);
|
|
4467
|
+
if (!text) continue;
|
|
4468
|
+
if (text.length > maxChars) {
|
|
4469
|
+
errors.push({ field, message: `${field} contains an entry over ${maxChars} chars` });
|
|
4470
|
+
continue;
|
|
4471
|
+
}
|
|
4472
|
+
out.push(text);
|
|
4473
|
+
}
|
|
4474
|
+
if (out.length < minItems) errors.push({ field, message: `${field} needs at least ${minItems} entry \u2014 an empty ${field} list is a review with no recorded scope` });
|
|
4475
|
+
return out;
|
|
4476
|
+
}
|
|
4477
|
+
function validateReviewReport(raw, ctx) {
|
|
4478
|
+
const errors = [];
|
|
4479
|
+
if (!isRecord4(raw)) return { errors: [{ field: "review", message: "review must be an object {verdict, findings, checked, notChecked, ...}" }] };
|
|
4480
|
+
const KNOWN = /* @__PURE__ */ new Set(["verdict", "findings", "priorFindings", "checked", "notChecked", "testsRun"]);
|
|
4481
|
+
for (const key of Object.keys(raw)) if (!KNOWN.has(key)) errors.push({ field: `review.${key}`, message: `unknown field '${key}' (expected one of: ${[...KNOWN].join(", ")})` });
|
|
4482
|
+
const verdict = raw.verdict;
|
|
4483
|
+
if (!isReviewVerdict(verdict)) errors.push({ field: "review.verdict", message: `verdict must be one of ${REVIEW_VERDICTS.join(" | ")}` });
|
|
4484
|
+
const findings = [];
|
|
4485
|
+
if (!Array.isArray(raw.findings)) errors.push({ field: "review.findings", message: "findings must be an array (use [] when there are none)" });
|
|
4486
|
+
else {
|
|
4487
|
+
if (raw.findings.length > REVIEW_FINDINGS_MAX) errors.push({ field: "review.findings", message: `findings has ${raw.findings.length} entries, over the ${REVIEW_FINDINGS_MAX} limit \u2014 keep the most important` });
|
|
4488
|
+
const seen = /* @__PURE__ */ new Set();
|
|
4489
|
+
raw.findings.forEach((f, i) => {
|
|
4490
|
+
const at = `review.findings[${i}]`;
|
|
4491
|
+
if (!isRecord4(f)) {
|
|
4492
|
+
errors.push({ field: at, message: "each finding must be an object" });
|
|
4493
|
+
return;
|
|
4494
|
+
}
|
|
4495
|
+
const FK = /* @__PURE__ */ new Set(["id", "severity", "category", "file", "line", "claim", "evidence", "suggestedFix"]);
|
|
4496
|
+
for (const key of Object.keys(f)) if (!FK.has(key)) errors.push({ field: `${at}.${key}`, message: `unknown field '${key}'` });
|
|
4497
|
+
const id2 = str2(f.id);
|
|
4498
|
+
if (!id2 || id2.length > REVIEW_FINDING_ID_MAX_CHARS) errors.push({ field: `${at}.id`, message: `id is required (\u2264 ${REVIEW_FINDING_ID_MAX_CHARS} chars)` });
|
|
4499
|
+
else if (seen.has(id2)) errors.push({ field: `${at}.id`, message: `duplicate finding id '${id2}'` });
|
|
4500
|
+
else seen.add(id2);
|
|
4501
|
+
if (!isFindingSeverity(f.severity)) errors.push({ field: `${at}.severity`, message: `severity must be one of ${FINDING_SEVERITIES.join(" | ")}` });
|
|
4502
|
+
if (!isFindingCategory(f.category)) errors.push({ field: `${at}.category`, message: `category must be one of ${FINDING_CATEGORIES.join(" | ")}` });
|
|
4503
|
+
const claim = str2(f.claim);
|
|
4504
|
+
if (!claim) errors.push({ field: `${at}.claim`, message: "claim is required" });
|
|
4505
|
+
else if (claim.length > REVIEW_CLAIM_MAX_CHARS) errors.push({ field: `${at}.claim`, message: `claim is over ${REVIEW_CLAIM_MAX_CHARS} chars` });
|
|
4506
|
+
const evidence = str2(f.evidence);
|
|
4507
|
+
if (!evidence) errors.push({ field: `${at}.evidence`, message: "evidence is required \u2014 what did you read or run to know this" });
|
|
4508
|
+
else if (evidence.length > REVIEW_EVIDENCE_MAX_CHARS) errors.push({ field: `${at}.evidence`, message: `evidence is over ${REVIEW_EVIDENCE_MAX_CHARS} chars` });
|
|
4509
|
+
const fix = f.suggestedFix === void 0 ? void 0 : str2(f.suggestedFix);
|
|
4510
|
+
if (fix !== void 0 && fix.length > REVIEW_FIX_MAX_CHARS) errors.push({ field: `${at}.suggestedFix`, message: `suggestedFix is over ${REVIEW_FIX_MAX_CHARS} chars` });
|
|
4511
|
+
if (f.file !== void 0 && typeof f.file !== "string") errors.push({ field: `${at}.file`, message: "file must be a string" });
|
|
4512
|
+
if (f.line !== void 0 && (typeof f.line !== "number" || !Number.isInteger(f.line) || f.line < 1)) errors.push({ field: `${at}.line`, message: "line must be a positive integer" });
|
|
4513
|
+
if (id2 && isFindingSeverity(f.severity) && isFindingCategory(f.category) && claim && evidence) {
|
|
4514
|
+
findings.push({
|
|
4515
|
+
id: id2,
|
|
4516
|
+
severity: f.severity,
|
|
4517
|
+
category: f.category,
|
|
4518
|
+
...typeof f.file === "string" && f.file.trim() ? { file: f.file.trim() } : {},
|
|
4519
|
+
...typeof f.line === "number" ? { line: f.line } : {},
|
|
4520
|
+
claim,
|
|
4521
|
+
evidence,
|
|
4522
|
+
...fix ? { suggestedFix: fix } : {}
|
|
4523
|
+
});
|
|
4524
|
+
}
|
|
4525
|
+
});
|
|
4526
|
+
}
|
|
4527
|
+
const checked = validateStringList(raw.checked, "review.checked", REVIEW_CHECKED_MAX, REVIEW_CLAIM_MAX_CHARS, errors, 1);
|
|
4528
|
+
const notChecked = validateStringList(raw.notChecked, "review.notChecked", REVIEW_CHECKED_MAX, REVIEW_CLAIM_MAX_CHARS, errors, 1);
|
|
4529
|
+
let priorFindings;
|
|
4530
|
+
if (raw.priorFindings !== void 0) {
|
|
4531
|
+
if (!Array.isArray(raw.priorFindings)) errors.push({ field: "review.priorFindings", message: "priorFindings must be an array" });
|
|
4532
|
+
else {
|
|
4533
|
+
priorFindings = [];
|
|
4534
|
+
raw.priorFindings.forEach((p, i) => {
|
|
4535
|
+
const at = `review.priorFindings[${i}]`;
|
|
4536
|
+
if (!isRecord4(p)) {
|
|
4537
|
+
errors.push({ field: at, message: "each entry must be an object {id, status, note?}" });
|
|
4538
|
+
return;
|
|
4539
|
+
}
|
|
4540
|
+
for (const key of Object.keys(p)) if (!["id", "status", "note"].includes(key)) errors.push({ field: `${at}.${key}`, message: `unknown field '${key}'` });
|
|
4541
|
+
const id2 = str2(p.id);
|
|
4542
|
+
if (!id2) errors.push({ field: `${at}.id`, message: "id is required" });
|
|
4543
|
+
if (!isPriorFindingStatus(p.status)) errors.push({ field: `${at}.status`, message: `status must be one of ${PRIOR_FINDING_STATUSES.join(" | ")}` });
|
|
4544
|
+
const note = p.note === void 0 ? void 0 : str2(p.note);
|
|
4545
|
+
if (note !== void 0 && note.length > REVIEW_NOTE_MAX_CHARS) errors.push({ field: `${at}.note`, message: `note is over ${REVIEW_NOTE_MAX_CHARS} chars` });
|
|
4546
|
+
if (id2 && isPriorFindingStatus(p.status)) priorFindings.push({ id: id2, status: p.status, ...note ? { note } : {} });
|
|
4547
|
+
});
|
|
4548
|
+
}
|
|
4549
|
+
}
|
|
4550
|
+
const testsRun = raw.testsRun === void 0 ? void 0 : validateTestsRun(raw.testsRun, "review.testsRun", errors);
|
|
4551
|
+
if (isReviewVerdict(verdict)) {
|
|
4552
|
+
const blocking = findings.filter((f) => isBlockingSeverity(f.severity));
|
|
4553
|
+
if (verdict === "changes_requested" && blocking.length === 0 && Array.isArray(raw.findings) && errors.length === 0) {
|
|
4554
|
+
errors.push({ field: "review.verdict", message: "changes_requested needs at least one blocking or major finding \u2014 nits alone are approve_with_nits" });
|
|
4555
|
+
}
|
|
4556
|
+
if (verdict === "approve" && blocking.length > 0) {
|
|
4557
|
+
errors.push({ field: "review.verdict", message: "approve cannot carry blocking or major findings" });
|
|
4558
|
+
}
|
|
4559
|
+
if (verdict === "approve_with_nits" && blocking.length > 0) {
|
|
4560
|
+
errors.push({ field: "review.verdict", message: "approve_with_nits cannot carry blocking or major findings \u2014 use changes_requested" });
|
|
4561
|
+
}
|
|
4562
|
+
}
|
|
4563
|
+
if (ctx.round >= 2 && ctx.priorOpenBlockingIds?.length) {
|
|
4564
|
+
const answered = new Set((priorFindings ?? []).map((p) => p.id));
|
|
4565
|
+
const missing = ctx.priorOpenBlockingIds.filter((id2) => !answered.has(id2));
|
|
4566
|
+
if (missing.length) errors.push({ field: "review.priorFindings", message: `round ${ctx.round} must give a status for every prior blocking/major finding; missing: ${missing.join(", ")}` });
|
|
4567
|
+
}
|
|
4568
|
+
if (errors.length) return { errors };
|
|
4569
|
+
return {
|
|
4570
|
+
report: {
|
|
4571
|
+
verdict,
|
|
4572
|
+
findings,
|
|
4573
|
+
...priorFindings?.length ? { priorFindings } : {},
|
|
4574
|
+
checked,
|
|
4575
|
+
notChecked,
|
|
4576
|
+
...testsRun?.length ? { testsRun } : {}
|
|
4577
|
+
},
|
|
4578
|
+
errors: []
|
|
4579
|
+
};
|
|
4580
|
+
}
|
|
4581
|
+
function validateTestsRun(raw, field, errors) {
|
|
4582
|
+
if (!Array.isArray(raw)) {
|
|
4583
|
+
errors.push({ field, message: `${field} must be an array of {command, exit, passed?, failed?, note?}` });
|
|
4584
|
+
return [];
|
|
4585
|
+
}
|
|
4586
|
+
if (raw.length > REVIEW_TESTS_RUN_MAX) errors.push({ field, message: `${field} has ${raw.length} entries, over the ${REVIEW_TESTS_RUN_MAX} limit` });
|
|
4587
|
+
const out = [];
|
|
4588
|
+
raw.forEach((t, i) => {
|
|
4589
|
+
const at = `${field}[${i}]`;
|
|
4590
|
+
if (!isRecord4(t)) {
|
|
4591
|
+
errors.push({ field: at, message: "each entry must be an object" });
|
|
4592
|
+
return;
|
|
4593
|
+
}
|
|
4594
|
+
for (const key of Object.keys(t)) if (!["command", "exit", "passed", "failed", "note"].includes(key)) errors.push({ field: `${at}.${key}`, message: `unknown field '${key}'` });
|
|
4595
|
+
const command = str2(t.command);
|
|
4596
|
+
if (!command || command.length > REVIEW_CLAIM_MAX_CHARS) errors.push({ field: `${at}.command`, message: `command is required (\u2264 ${REVIEW_CLAIM_MAX_CHARS} chars)` });
|
|
4597
|
+
if (typeof t.exit !== "number" || !Number.isInteger(t.exit)) errors.push({ field: `${at}.exit`, message: "exit must be an integer" });
|
|
4598
|
+
for (const k of ["passed", "failed"]) {
|
|
4599
|
+
if (t[k] !== void 0 && (typeof t[k] !== "number" || !Number.isInteger(t[k]) || t[k] < 0)) errors.push({ field: `${at}.${k}`, message: `${k} must be a non-negative integer` });
|
|
4600
|
+
}
|
|
4601
|
+
const note = t.note === void 0 ? void 0 : str2(t.note);
|
|
4602
|
+
if (note !== void 0 && note.length > REVIEW_NOTE_MAX_CHARS) errors.push({ field: `${at}.note`, message: `note is over ${REVIEW_NOTE_MAX_CHARS} chars` });
|
|
4603
|
+
if (command && typeof t.exit === "number") {
|
|
4604
|
+
out.push({
|
|
4605
|
+
command,
|
|
4606
|
+
exit: t.exit,
|
|
4607
|
+
...typeof t.passed === "number" ? { passed: t.passed } : {},
|
|
4608
|
+
...typeof t.failed === "number" ? { failed: t.failed } : {},
|
|
4609
|
+
...note ? { note } : {}
|
|
4610
|
+
});
|
|
4611
|
+
}
|
|
4612
|
+
});
|
|
4613
|
+
return out;
|
|
4614
|
+
}
|
|
4615
|
+
function validateFindingResponses(raw, field = "findingResponses") {
|
|
4616
|
+
const errors = [];
|
|
4617
|
+
if (!Array.isArray(raw)) return { errors: [{ field, message: `${field} must be an array of {id, response, note}` }] };
|
|
4618
|
+
if (raw.length > FINDING_RESPONSES_MAX) errors.push({ field, message: `${field} has ${raw.length} entries, over the ${FINDING_RESPONSES_MAX} limit` });
|
|
4619
|
+
const out = [];
|
|
4620
|
+
raw.forEach((r, i) => {
|
|
4621
|
+
const at = `${field}[${i}]`;
|
|
4622
|
+
if (!isRecord4(r)) {
|
|
4623
|
+
errors.push({ field: at, message: "each entry must be an object {id, response, note}" });
|
|
4624
|
+
return;
|
|
4625
|
+
}
|
|
4626
|
+
for (const key of Object.keys(r)) if (!["id", "response", "note"].includes(key)) errors.push({ field: `${at}.${key}`, message: `unknown field '${key}'` });
|
|
4627
|
+
const id2 = str2(r.id);
|
|
4628
|
+
if (!id2) errors.push({ field: `${at}.id`, message: "id is required" });
|
|
4629
|
+
if (!isFindingResponseKind(r.response)) errors.push({ field: `${at}.response`, message: `response must be one of ${FINDING_RESPONSE_KINDS.join(" | ")}` });
|
|
4630
|
+
const note = str2(r.note);
|
|
4631
|
+
if (!note) errors.push({ field: `${at}.note`, message: "note is required \u2014 say what changed, or why you dispute it" });
|
|
4632
|
+
else if (note.length > REVIEW_NOTE_MAX_CHARS) errors.push({ field: `${at}.note`, message: `note is over ${REVIEW_NOTE_MAX_CHARS} chars` });
|
|
4633
|
+
if (id2 && isFindingResponseKind(r.response) && note && note.length <= REVIEW_NOTE_MAX_CHARS) out.push({ id: id2, response: r.response, note });
|
|
4634
|
+
});
|
|
4635
|
+
return errors.length ? { errors } : { responses: out, errors: [] };
|
|
4636
|
+
}
|
|
4637
|
+
function formatStageVerdictLine(input) {
|
|
4638
|
+
const parts = [`review: ${input.verdict}`];
|
|
4639
|
+
if (input.verdict === "skipped_no_diff") return parts[0];
|
|
4640
|
+
parts.push(`${input.rounds} round${input.rounds === 1 ? "" : "s"}`);
|
|
4641
|
+
if (input.reviewerProvider) parts.push(`reviewer ${input.reviewerProvider} (${input.independenceUsed ?? "different_provider"})`);
|
|
4642
|
+
const tail = [];
|
|
4643
|
+
if (input.fixed) tail.push(`${input.fixed} finding${input.fixed === 1 ? "" : "s"} fixed`);
|
|
4644
|
+
if (input.openNits) tail.push(`${input.openNits} nit${input.openNits === 1 ? "" : "s"} open`);
|
|
4645
|
+
return tail.length ? `${parts.join(" \xB7 ")} \xB7 ${tail.join(", ")}` : parts.join(" \xB7 ");
|
|
4646
|
+
}
|
|
4296
4647
|
export {
|
|
4297
4648
|
ASSISTANT_ACCOUNT_SLOT,
|
|
4298
4649
|
ASSISTANT_FOLLOWER_ALLOWED_OPS,
|
|
@@ -4343,14 +4694,25 @@ export {
|
|
|
4343
4694
|
DELIVERY_OUTCOMES,
|
|
4344
4695
|
DELIVERY_VIAS,
|
|
4345
4696
|
DISPATCH_FAILURE_REASONS,
|
|
4697
|
+
DISPATCH_REFUSAL_DETAIL_MAX,
|
|
4346
4698
|
EVIDENCE_ENVELOPE_FIELD_SPECS,
|
|
4347
4699
|
EVIDENCE_SOURCE_IDS,
|
|
4700
|
+
FINDING_CATEGORIES,
|
|
4701
|
+
FINDING_RESPONSES_MAX,
|
|
4702
|
+
FINDING_RESPONSE_KINDS,
|
|
4703
|
+
FINDING_SEVERITIES,
|
|
4348
4704
|
HOLD_REASONS,
|
|
4349
4705
|
LAUNCH_DEFAULTS_NEXT_LAUNCH_NOTE,
|
|
4350
4706
|
LAUNCH_DEFAULT_ERROR_CODES,
|
|
4351
4707
|
LAUNCH_DEFAULT_ROLES,
|
|
4352
4708
|
LAUNCH_DEFAULT_SOURCES,
|
|
4353
4709
|
LEGACY_CARRY_OVER_MISSION_TITLE,
|
|
4710
|
+
LIGHT_BLOCK_REASONS,
|
|
4711
|
+
LIGHT_HOLD,
|
|
4712
|
+
LIGHT_LAND_MODES,
|
|
4713
|
+
LIGHT_REJECT,
|
|
4714
|
+
LIGHT_TESTS_RUN_MAX,
|
|
4715
|
+
LIGHT_WARNINGS,
|
|
4354
4716
|
LIVENESS_RESULTS,
|
|
4355
4717
|
MAX_MESH_RECORD_STRING,
|
|
4356
4718
|
MAX_OWNED_PATHS,
|
|
@@ -4408,6 +4770,7 @@ export {
|
|
|
4408
4770
|
OWNER_ABANDON_CONFIRM_OPTIONS,
|
|
4409
4771
|
OWNER_ABANDON_CONFIRM_QUESTION,
|
|
4410
4772
|
P2P_SIGNAL_TYPES,
|
|
4773
|
+
PRIOR_FINDING_STATUSES,
|
|
4411
4774
|
PROVIDER_FAILURES,
|
|
4412
4775
|
QUOTA_BACKFILL_HORIZON_MS,
|
|
4413
4776
|
QUOTA_RETRY_INFLIGHT_GRACE_MS,
|
|
@@ -4424,6 +4787,15 @@ export {
|
|
|
4424
4787
|
RELEASE_MEMBER_STATES,
|
|
4425
4788
|
REMOVED_MESH_TOOLS,
|
|
4426
4789
|
RETIRED_MESH_TOOLS,
|
|
4790
|
+
REVIEW_CHECKED_MAX,
|
|
4791
|
+
REVIEW_CLAIM_MAX_CHARS,
|
|
4792
|
+
REVIEW_EVIDENCE_MAX_CHARS,
|
|
4793
|
+
REVIEW_FINDINGS_MAX,
|
|
4794
|
+
REVIEW_FINDING_ID_MAX_CHARS,
|
|
4795
|
+
REVIEW_FIX_MAX_CHARS,
|
|
4796
|
+
REVIEW_NOTE_MAX_CHARS,
|
|
4797
|
+
REVIEW_TESTS_RUN_MAX,
|
|
4798
|
+
REVIEW_VERDICTS,
|
|
4427
4799
|
RelayReprobeScheduler,
|
|
4428
4800
|
SEND_POLICY_MODES,
|
|
4429
4801
|
SEND_REFUSAL_REASONS,
|
|
@@ -4437,6 +4809,17 @@ export {
|
|
|
4437
4809
|
SESSION_STATUS_ALIASES,
|
|
4438
4810
|
SESSION_STATUS_CLASS,
|
|
4439
4811
|
SHARED_SESSION_TO_VIEWER_TYPES,
|
|
4812
|
+
STAGE_BLOCKED_REASONS,
|
|
4813
|
+
STAGE_DECIDE_ACTIONS,
|
|
4814
|
+
STAGE_DEFAULT_MAX_REVISIONS,
|
|
4815
|
+
STAGE_INDEPENDENCE_FALLBACK_MS,
|
|
4816
|
+
STAGE_INDEPENDENCE_MODES,
|
|
4817
|
+
STAGE_MAX_REVISIONS_LIMIT,
|
|
4818
|
+
STAGE_PARKED_PHASES,
|
|
4819
|
+
STAGE_PHASES,
|
|
4820
|
+
STAGE_PIPELINE_CEILING_DEFAULT_MS,
|
|
4821
|
+
STAGE_ROLES,
|
|
4822
|
+
STAGE_SELF_CHECK_MAX_BOUNCES,
|
|
4440
4823
|
STATUS_PROBE_ARG_KEY,
|
|
4441
4824
|
SUSPENSION_MODALS,
|
|
4442
4825
|
SUSPENSION_RESOLUTIONS,
|
|
@@ -4544,6 +4927,7 @@ export {
|
|
|
4544
4927
|
decodeUserSessionToDashboard,
|
|
4545
4928
|
decodeViewerToSharedSession,
|
|
4546
4929
|
defaultProviderPriorityFromNodeFacts,
|
|
4930
|
+
defaultStagePlan,
|
|
4547
4931
|
deriveItemDedupeKey,
|
|
4548
4932
|
deriveProviderPriorityFromSlots,
|
|
4549
4933
|
deriveSlotsFromLegacy,
|
|
@@ -4558,6 +4942,7 @@ export {
|
|
|
4558
4942
|
followedRemoteProjectKey,
|
|
4559
4943
|
followerOpPermitted,
|
|
4560
4944
|
formatQuotaAccount,
|
|
4945
|
+
formatStageVerdictLine,
|
|
4561
4946
|
hasGitStatusEvidence,
|
|
4562
4947
|
hasWorkerProtocolFooter,
|
|
4563
4948
|
interpolateString,
|
|
@@ -4565,6 +4950,7 @@ export {
|
|
|
4565
4950
|
isAssistantFollowerAllowedOp,
|
|
4566
4951
|
isAssistantTool,
|
|
4567
4952
|
isBlockedStatus,
|
|
4953
|
+
isBlockingSeverity,
|
|
4568
4954
|
isBusyStatus,
|
|
4569
4955
|
isCarryOverMissionRecord,
|
|
4570
4956
|
isCarryOverMissionTitle,
|
|
@@ -4583,6 +4969,9 @@ export {
|
|
|
4583
4969
|
isDeadStatus,
|
|
4584
4970
|
isDowngrade,
|
|
4585
4971
|
isEvidenceIdentifier,
|
|
4972
|
+
isFindingCategory,
|
|
4973
|
+
isFindingResponseKind,
|
|
4974
|
+
isFindingSeverity,
|
|
4586
4975
|
isFiniteNumber,
|
|
4587
4976
|
isIdleSessionState,
|
|
4588
4977
|
isInputEnvelopeWire,
|
|
@@ -4612,11 +5001,13 @@ export {
|
|
|
4612
5001
|
isOutboundMessageOrigin,
|
|
4613
5002
|
isP2PSignalType,
|
|
4614
5003
|
isPhantomDaemonEntry,
|
|
5004
|
+
isPriorFindingStatus,
|
|
4615
5005
|
isProviderQuestionBinding,
|
|
4616
5006
|
isRawDaemonDoId,
|
|
4617
5007
|
isReadyStatus,
|
|
4618
5008
|
isRecord,
|
|
4619
5009
|
isReleaseStatus,
|
|
5010
|
+
isReviewVerdict,
|
|
4620
5011
|
isSendPolicy,
|
|
4621
5012
|
isSendPolicyMode,
|
|
4622
5013
|
isSendRefusal,
|
|
@@ -4625,6 +5016,8 @@ export {
|
|
|
4625
5016
|
isSessionLaunchedBy,
|
|
4626
5017
|
isSessionStatus,
|
|
4627
5018
|
isSharedSessionToViewerType,
|
|
5019
|
+
isStageBlockedReason,
|
|
5020
|
+
isStageEligibleTask,
|
|
4628
5021
|
isSubmitOutcome,
|
|
4629
5022
|
isSummaryRef,
|
|
4630
5023
|
isTerminalSessionRecordStatus,
|
|
@@ -4696,9 +5089,14 @@ export {
|
|
|
4696
5089
|
readStringArray,
|
|
4697
5090
|
readText,
|
|
4698
5091
|
renderCoordinatorWorkerSection,
|
|
5092
|
+
renderLightWorkspaceRules,
|
|
4699
5093
|
renderMissionBriefBlock,
|
|
5094
|
+
renderStageProtocolLines,
|
|
4700
5095
|
renderWorkerProtocolFooter,
|
|
5096
|
+
resolveStagePlan,
|
|
4701
5097
|
retiredMeshToolError,
|
|
5098
|
+
reviewIndependenceOf,
|
|
5099
|
+
sanitizeDispatchRefusalDetail,
|
|
4702
5100
|
sanitizeModelIdentifier,
|
|
4703
5101
|
sanitizeRefusalCode,
|
|
4704
5102
|
sanitizeRemoteRepoIdentity,
|
|
@@ -4714,6 +5112,9 @@ export {
|
|
|
4714
5112
|
touchedFilesOutsideOwnership,
|
|
4715
5113
|
truncateMissionText,
|
|
4716
5114
|
unwrapPastedContent,
|
|
5115
|
+
validateFindingResponses,
|
|
5116
|
+
validateReviewReport,
|
|
5117
|
+
validateTestsRun,
|
|
4717
5118
|
withStatusProbeMarker
|
|
4718
5119
|
};
|
|
4719
5120
|
//# sourceMappingURL=index.mjs.map
|