@ddtcorex/dsh-maestro-review 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -0
- package/cordis.patch.yml +18 -0
- package/lib/ci-clone.d.ts +21 -0
- package/lib/ci-clone.d.ts.map +1 -0
- package/lib/ci-clone.js +35 -0
- package/lib/ci-clone.js.map +1 -0
- package/lib/ci-coexist.d.ts +11 -0
- package/lib/ci-coexist.d.ts.map +1 -0
- package/lib/ci-coexist.js +38 -0
- package/lib/ci-coexist.js.map +1 -0
- package/lib/config-store.d.ts +13 -6
- package/lib/config-store.d.ts.map +1 -1
- package/lib/config-store.js.map +1 -1
- package/lib/events.d.ts +27 -0
- package/lib/events.d.ts.map +1 -1
- package/lib/gitlab-auth.d.ts +11 -0
- package/lib/gitlab-auth.d.ts.map +1 -0
- package/lib/gitlab-auth.js +15 -0
- package/lib/gitlab-auth.js.map +1 -0
- package/lib/gitlab-client.d.ts +7 -0
- package/lib/gitlab-client.d.ts.map +1 -1
- package/lib/gitlab-client.js +23 -1
- package/lib/gitlab-client.js.map +1 -1
- package/lib/incremental.d.ts.map +1 -1
- package/lib/incremental.js +4 -2
- package/lib/incremental.js.map +1 -1
- package/lib/orchestrator.d.ts +56 -6
- package/lib/orchestrator.d.ts.map +1 -1
- package/lib/orchestrator.js +243 -68
- package/lib/orchestrator.js.map +1 -1
- package/lib/providers/ci-trigger.d.ts +44 -0
- package/lib/providers/ci-trigger.d.ts.map +1 -0
- package/lib/providers/ci-trigger.js +150 -0
- package/lib/providers/ci-trigger.js.map +1 -0
- package/lib/providers/gitlab.d.ts.map +1 -1
- package/lib/providers/gitlab.js +16 -3
- package/lib/providers/gitlab.js.map +1 -1
- package/lib/review-history.d.ts +2 -1
- package/lib/review-history.d.ts.map +1 -1
- package/lib/review-history.js +67 -40
- package/lib/review-history.js.map +1 -1
- package/lib/review-intake.d.ts +9 -0
- package/lib/review-intake.d.ts.map +1 -1
- package/lib/review-intake.js +34 -1
- package/lib/review-intake.js.map +1 -1
- package/lib/review-marker.d.ts +17 -0
- package/lib/review-marker.d.ts.map +1 -0
- package/lib/review-marker.js +23 -0
- package/lib/review-marker.js.map +1 -0
- package/lib/review-signals.d.ts.map +1 -1
- package/lib/review-signals.js +8 -6
- package/lib/review-signals.js.map +1 -1
- package/lib/settings-rpc.js +1 -1
- package/lib/settings-rpc.js.map +1 -1
- package/package.json +14 -9
- package/profiles/reviewer-ci/cordis.patch.yml +61 -0
- package/profiles/reviewer-ci/package.json +19 -0
- package/profiles/reviewer-ci/pnpm-lock.yaml +62 -0
- package/profiles/reviewer-ci/pnpm-workspace.yaml +12 -0
- package/src/host/ci-clone.ts +54 -0
- package/src/host/ci-coexist.ts +45 -0
- package/src/host/config-store.ts +14 -1
- package/src/host/events.ts +29 -0
- package/src/host/gitlab-auth.ts +13 -0
- package/src/host/gitlab-client.ts +23 -1
- package/src/host/incremental.ts +6 -4
- package/src/host/orchestrator.ts +247 -46
- package/src/host/providers/ci-trigger.ts +168 -0
- package/src/host/providers/gitlab.ts +19 -4
- package/src/host/review-history.ts +65 -35
- package/src/host/review-intake.ts +36 -1
- package/src/host/review-marker.ts +25 -0
- package/src/host/review-signals.ts +9 -6
- package/src/host/settings-rpc.ts +1 -1
- package/templates/reviewer-project.gitlab-ci.yml +90 -0
- package/templates/source-project.gitlab-ci.yml +41 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../src/host/orchestrator.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAIxC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAiB5D,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,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KG;AACH,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAMrE;AAED;;;;;;;;;GASG;AACH,wBAAsB,sBAAsB,CAAC,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAsC3G;AAKD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,uBAAuB,CAAC,cAAc,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,gBAAgB,GAAE,MAAiC,GAAG,MAAM,CAQjJ;AAED;;;;;;GAMG;AACH,wBAAsB,4BAA4B,CAAC,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAqB3H;AAkBD,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAodxD"}
|
package/lib/orchestrator.js
CHANGED
|
@@ -31,6 +31,9 @@ import { reviewDigestText } from './notify.js';
|
|
|
31
31
|
import { loadedReviewProfile } from './skills-tool.js';
|
|
32
32
|
import { gitlabProvider } from './providers/gitlab.js';
|
|
33
33
|
import './events.js';
|
|
34
|
+
import { gitlabAuthHeaders } from './gitlab-auth.js';
|
|
35
|
+
import { reviewMarker, resolveFlow } from './review-marker.js';
|
|
36
|
+
import { cloneSourceRepo, defaultRun } from './ci-clone.js';
|
|
34
37
|
// Provider-aware wrapper — orchestrator can run reviews via any ReviewProvider.
|
|
35
38
|
// This keeps the GitLab-specific flow intact while allowing Phase C to add GitHub/Jira without modifying core logic.
|
|
36
39
|
export async function runReviewWithProvider(provider, request) {
|
|
@@ -132,7 +135,8 @@ export function buildReviewComment(opts) {
|
|
|
132
135
|
? `\n\n<details>\n<summary>⚠️ Failed to post (${opts.failures.length})</summary>\n\n${opts.failures.map((f) => `- \`${f}\``).join('\n')}\n\n</details>`
|
|
133
136
|
: '';
|
|
134
137
|
const footer = `\n\n---\n\n<sub>Generated by Maestro · [View MR →](${mrUrl})</sub>`;
|
|
135
|
-
|
|
138
|
+
const markerLine = opts.marker === undefined ? '' : `\n\n${reviewMarker(opts.marker.sha, opts.marker.flow)}`;
|
|
139
|
+
return `${title}\n\n${metaLine}\n\n${scopeNote}${opts.summary}${findingsLine}${failuresBlock}${footer}${markerLine}`;
|
|
136
140
|
}
|
|
137
141
|
export function buildNotStartedComment(opts) {
|
|
138
142
|
const mrUrl = `${opts.gitlabBaseUrl.replace(/\/$/, '')}/${opts.projectPath}/-/merge_requests/${opts.mrIid}`;
|
|
@@ -147,6 +151,7 @@ export function buildNotStartedComment(opts) {
|
|
|
147
151
|
`---`,
|
|
148
152
|
'',
|
|
149
153
|
`<sub>Generated by Maestro · [View MR →](${mrUrl})</sub>`,
|
|
154
|
+
...(opts.marker === undefined ? [] : [``, `${reviewMarker(opts.marker.sha, opts.marker.flow)}`]),
|
|
150
155
|
].join('\n');
|
|
151
156
|
}
|
|
152
157
|
export const name = 'maestro-orchestrator';
|
|
@@ -199,10 +204,12 @@ export function getTurnErrorMessage(handle) {
|
|
|
199
204
|
}
|
|
200
205
|
/**
|
|
201
206
|
* Resolve the model to use for an automated review. Priority: per-project
|
|
202
|
-
* override > global reviewModel >
|
|
207
|
+
* override > global reviewModel (Maestro Settings) > row-config reviewModel
|
|
208
|
+
* (lets a headless profile such as reviewer-ci pin a model from env vars,
|
|
209
|
+
* where there is no Settings UI) > DSH default (`fallback`).
|
|
203
210
|
*/
|
|
204
|
-
export function resolveReviewModel(userConfig, mapping, fallback) {
|
|
205
|
-
const raw = mapping?.reviewModel ?? userConfig.reviewModel;
|
|
211
|
+
export function resolveReviewModel(userConfig, mapping, fallback, rowSelection) {
|
|
212
|
+
const raw = mapping?.reviewModel ?? userConfig.reviewModel ?? rowSelection;
|
|
206
213
|
if (raw === undefined || raw === null)
|
|
207
214
|
return fallback;
|
|
208
215
|
return {
|
|
@@ -211,6 +218,13 @@ export function resolveReviewModel(userConfig, mapping, fallback) {
|
|
|
211
218
|
...(raw.reasoningEffort === undefined ? {} : { reasoningEffort: ReasoningEffortId(raw.reasoningEffort) }),
|
|
212
219
|
};
|
|
213
220
|
}
|
|
221
|
+
/** Effective auto-trigger flags: per-project row overrides global, unset inherits (design §4). */
|
|
222
|
+
export function resolveReviewTriggers(userConfig, mapping) {
|
|
223
|
+
return {
|
|
224
|
+
onPush: mapping?.rereviewOnPush ?? userConfig.autoRereviewOnPush ?? false,
|
|
225
|
+
onAssign: mapping?.reviewOnAssign ?? userConfig.autoReviewOnAssign ?? true,
|
|
226
|
+
};
|
|
227
|
+
}
|
|
214
228
|
/** Compose a newly-created agent from the preset service owned by the root context. */
|
|
215
229
|
export async function mountAgentPreset(agentPresets, agentCtx, id) {
|
|
216
230
|
await agentPresets.mount(agentCtx, id);
|
|
@@ -321,7 +335,7 @@ function normalizedDiffPath(path) {
|
|
|
321
335
|
export async function postReviewFindings(findings, config) {
|
|
322
336
|
const fetcher = config.fetcher ?? fetch;
|
|
323
337
|
const apiBase = `${config.baseUrl}/api/v4/projects/${config.projectId}/merge_requests/${config.mrIid}`;
|
|
324
|
-
const headers = {
|
|
338
|
+
const headers = { ...gitlabAuthHeaders(config.token), 'Content-Type': 'application/json' };
|
|
325
339
|
for (const finding of findings) {
|
|
326
340
|
let response;
|
|
327
341
|
const label = severityPrefix(finding.severity);
|
|
@@ -382,7 +396,8 @@ export async function postReviewFindings(findings, config) {
|
|
|
382
396
|
const inFlightKeys = new Set();
|
|
383
397
|
function reviewKey(payload) {
|
|
384
398
|
const scope = payload.scope.kind === 'mr' ? 'mr' : `discussion:${payload.scope.discussionId}`;
|
|
385
|
-
|
|
399
|
+
const sha = typeof payload.pushSha === 'string' && payload.pushSha !== '' ? `:${payload.pushSha}` : '';
|
|
400
|
+
return `${payload.projectId}:${payload.mrIid}:${payload.mode}:${scope}:${payload.trigger}${sha}`;
|
|
386
401
|
}
|
|
387
402
|
/**
|
|
388
403
|
* Stable 8-char hex suffix of the review key, so distinct concurrent reviews
|
|
@@ -432,12 +447,66 @@ export function auditorOutputFromSession(session) {
|
|
|
432
447
|
return finalAssistantOutput(events) ?? [];
|
|
433
448
|
}
|
|
434
449
|
/** Full review + performance audit; resolves to the comment body that was posted. */
|
|
450
|
+
/** Marker for CI-posted comments; webhook payloads carry no headSha and stay marker-free. */
|
|
451
|
+
function commentMarker(payload) {
|
|
452
|
+
if (payload.headSha === undefined)
|
|
453
|
+
return undefined;
|
|
454
|
+
return { sha: payload.headSha, flow: resolveFlow(payload.mode) };
|
|
455
|
+
}
|
|
456
|
+
/** CI-deep decision: deep mode + CI env + head SHA (spec §3). Mapping is checked by the caller. */
|
|
457
|
+
export function shouldCiDeepReview(payload) {
|
|
458
|
+
return payload.mode === 'deep'
|
|
459
|
+
&& payload.headSha !== undefined
|
|
460
|
+
&& process.env.SOURCE_PROJECT_ID !== undefined
|
|
461
|
+
&& process.env.MR_IID !== undefined;
|
|
462
|
+
}
|
|
463
|
+
/** CI quick-with-profile decision: quick mode + non-generic profile + CI env
|
|
464
|
+
* + head SHA. Quick + generic/unset stays diff-only (no clone cost); a real
|
|
465
|
+
* profile opts into the clone branch reviewer-only (no auditor — quick never
|
|
466
|
+
* audits, see shouldAudit in runReviewAndAudit). Mapping is checked by the caller. */
|
|
467
|
+
export function shouldCiQuickProfileReview(payload) {
|
|
468
|
+
return payload.mode === 'quick'
|
|
469
|
+
&& payload.reviewProfile !== undefined
|
|
470
|
+
&& payload.reviewProfile !== 'generic'
|
|
471
|
+
&& payload.headSha !== undefined
|
|
472
|
+
&& process.env.SOURCE_PROJECT_ID !== undefined
|
|
473
|
+
&& process.env.MR_IID !== undefined;
|
|
474
|
+
}
|
|
475
|
+
/** Auditor degrade for CI (no runtime env): a govard throw becomes reviewer-only, never a failed review. */
|
|
476
|
+
export function withAuditorDegrade(runAuditor) {
|
|
477
|
+
return async (worktreePath, payload) => {
|
|
478
|
+
try {
|
|
479
|
+
return await runAuditor(worktreePath, payload);
|
|
480
|
+
}
|
|
481
|
+
catch {
|
|
482
|
+
return 'Auditor skipped — no runtime environment in CI (reviewer-only review).';
|
|
483
|
+
}
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Auditor instruction. The mapped flow keeps the full environment + test-suite
|
|
488
|
+
* workflow; the CI flow has no runtime, so the prompt countermands the
|
|
489
|
+
* auditor preset's environment steps and drops the Environment & Test Suite
|
|
490
|
+
* section entirely instead of reporting it "blocked".
|
|
491
|
+
*/
|
|
492
|
+
export function buildAuditorPrompt(opts) {
|
|
493
|
+
if (!opts.staticOnly) {
|
|
494
|
+
return 'Audit this merge request\'s performance: bring up the environment, run the test suite, look for regressions, then write a Markdown report and tear the environment down.';
|
|
495
|
+
}
|
|
496
|
+
return 'Audit this merge request\'s performance from the static diff and checked-out code only. '
|
|
497
|
+
+ 'No runtime environment exists in this container: ignore the auditor preset\'s environment steps '
|
|
498
|
+
+ '(do not bring anything up, do not run the test suite, do not tear anything down). '
|
|
499
|
+
+ 'Look for regressions by static analysis (diff, dependencies, query/shape risks), then write a Markdown report '
|
|
500
|
+
+ 'and OMIT the Environment & Test Suite section entirely — never report it as blocked.';
|
|
501
|
+
}
|
|
435
502
|
export async function runReviewAndAudit(payload, deps) {
|
|
436
503
|
assertSafeId(payload.projectId, 'projectId');
|
|
437
504
|
assertSafeId(payload.mrIid, 'mrIid');
|
|
438
505
|
const key = reviewKey(payload);
|
|
439
|
-
if (inFlightKeys.has(key))
|
|
506
|
+
if (inFlightKeys.has(key)) {
|
|
507
|
+
console.error(`maestro-orchestrator: deduped duplicate in-flight review key=${key} trigger=${payload.trigger}`);
|
|
440
508
|
return '';
|
|
509
|
+
}
|
|
441
510
|
inFlightKeys.add(key);
|
|
442
511
|
try {
|
|
443
512
|
const worktreePath = await deps.ensureWorktree(deps.localRepoPath, payload.sourceBranch, payload.projectId, payload.mrIid, reviewKeyHash(payload));
|
|
@@ -468,6 +537,7 @@ export async function runReviewAndAudit(payload, deps) {
|
|
|
468
537
|
summary: summaryText,
|
|
469
538
|
failures,
|
|
470
539
|
findings: { newCount, replyCount, severityCounts },
|
|
540
|
+
marker: commentMarker(payload),
|
|
471
541
|
})
|
|
472
542
|
: `## 🤖 Maestro Review\n\n**\`${payload.projectPath}\` !${payload.mrIid}** · ✅ Completed · \`${payload.mode}\`${deps.reviewProfile !== undefined ? ` · \`${deps.reviewProfile}\`` : ''}\n\n${summaryText}${failures.length > 0 ? `\n\n<details>\n<summary>⚠️ Failed to post (${failures.length})</summary>\n\n${failures.map((f) => `- \`${f}\``).join('\n')}\n\n</details>` : ''}`;
|
|
473
543
|
sections.push(richOpts);
|
|
@@ -489,7 +559,8 @@ export async function runReviewAndAudit(payload, deps) {
|
|
|
489
559
|
else
|
|
490
560
|
await deps.postComment(body);
|
|
491
561
|
}
|
|
492
|
-
catch {
|
|
562
|
+
catch (err) {
|
|
563
|
+
console.error(`maestro-orchestrator: posting review comment failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
493
564
|
await deps.writeFailedReport(payload.mrIid, body);
|
|
494
565
|
}
|
|
495
566
|
return body;
|
|
@@ -512,8 +583,10 @@ export async function runDiffOnlyReview(payload, deps) {
|
|
|
512
583
|
assertSafeId(payload.projectId, 'projectId');
|
|
513
584
|
assertSafeId(payload.mrIid, 'mrIid');
|
|
514
585
|
const key = reviewKey(payload);
|
|
515
|
-
if (inFlightKeys.has(key))
|
|
586
|
+
if (inFlightKeys.has(key)) {
|
|
587
|
+
console.error(`maestro-orchestrator: deduped duplicate in-flight review key=${key} trigger=${payload.trigger}`);
|
|
516
588
|
return '';
|
|
589
|
+
}
|
|
517
590
|
inFlightKeys.add(key);
|
|
518
591
|
try {
|
|
519
592
|
const { summary, failures } = await deps.runReviewer(payload);
|
|
@@ -526,6 +599,7 @@ export async function runDiffOnlyReview(payload, deps) {
|
|
|
526
599
|
summary: summary ?? '',
|
|
527
600
|
failures,
|
|
528
601
|
isDiffOnly: true,
|
|
602
|
+
marker: commentMarker(payload),
|
|
529
603
|
})
|
|
530
604
|
: `## 🤖 Maestro Review — Diff-only\n\n> **Scope:** Diff-only — reviewed the GitLab diff without a local checkout, Magento environment, static analysis, or tests. For a full review, add this project in Settings → Maestro and mention again.\n\n${summary}${failures.length > 0 ? `\n\n<details>\n<summary>⚠️ Failed to post (${failures.length})</summary>\n\n${failures.map((f) => `- \`${f}\``).join('\n')}\n\n</details>` : ''}`;
|
|
531
605
|
const body = diffBody;
|
|
@@ -535,7 +609,8 @@ export async function runDiffOnlyReview(payload, deps) {
|
|
|
535
609
|
else
|
|
536
610
|
await deps.postComment(body);
|
|
537
611
|
}
|
|
538
|
-
catch {
|
|
612
|
+
catch (err) {
|
|
613
|
+
console.error(`maestro-orchestrator: posting review comment failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
539
614
|
await deps.writeFailedReport(payload.mrIid, body);
|
|
540
615
|
}
|
|
541
616
|
return body;
|
|
@@ -544,18 +619,23 @@ export async function runDiffOnlyReview(payload, deps) {
|
|
|
544
619
|
inFlightKeys.delete(key);
|
|
545
620
|
}
|
|
546
621
|
}
|
|
547
|
-
/** Decline a Deep request that lacks the local mapping it requires.
|
|
622
|
+
/** Decline a Deep request that lacks the local mapping it requires.
|
|
623
|
+
* Resolves `true` when the decline was posted, `false` when a duplicate
|
|
624
|
+
* in-flight review is already handling this key (caller must not record a
|
|
625
|
+
* completion for work it did not do). */
|
|
548
626
|
export async function declineUnmappedDeepReview(payload, deps) {
|
|
549
627
|
assertSafeId(payload.projectId, 'projectId');
|
|
550
628
|
assertSafeId(payload.mrIid, 'mrIid');
|
|
551
629
|
const key = reviewKey(payload);
|
|
552
|
-
if (inFlightKeys.has(key))
|
|
553
|
-
|
|
630
|
+
if (inFlightKeys.has(key)) {
|
|
631
|
+
console.error(`maestro-orchestrator: deduped duplicate in-flight review key=${key} trigger=${payload.trigger}`);
|
|
632
|
+
return false;
|
|
633
|
+
}
|
|
554
634
|
inFlightKeys.add(key);
|
|
555
635
|
const depsWithUrl = deps;
|
|
556
636
|
const baseUrl = depsWithUrl.gitlabBaseUrl;
|
|
557
637
|
const body = baseUrl !== undefined
|
|
558
|
-
? buildNotStartedComment({ gitlabBaseUrl: baseUrl, projectPath: payload.projectPath, mrIid: payload.mrIid })
|
|
638
|
+
? buildNotStartedComment({ gitlabBaseUrl: baseUrl, projectPath: payload.projectPath, mrIid: payload.mrIid, marker: commentMarker(payload) })
|
|
559
639
|
: '## 🤖 Maestro Review — Not started\n\n**`' + payload.projectPath + '` !' + payload.mrIid + '** · ⏸️ Not started\n\n> Deep review requires a project mapping with a local checkout and Magento environment.\n> Add this project in **Settings → Maestro**, then mention the reviewer again.';
|
|
560
640
|
try {
|
|
561
641
|
try {
|
|
@@ -564,9 +644,11 @@ export async function declineUnmappedDeepReview(payload, deps) {
|
|
|
564
644
|
else
|
|
565
645
|
await deps.postComment(body);
|
|
566
646
|
}
|
|
567
|
-
catch {
|
|
647
|
+
catch (err) {
|
|
648
|
+
console.error(`maestro-orchestrator: posting review comment failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
568
649
|
await deps.writeFailedReport(payload.mrIid, body);
|
|
569
650
|
}
|
|
651
|
+
return true;
|
|
570
652
|
}
|
|
571
653
|
finally {
|
|
572
654
|
inFlightKeys.delete(key);
|
|
@@ -626,7 +708,7 @@ export function govardWorktreeOverride(projectId, mrIid, keySuffix) {
|
|
|
626
708
|
*/
|
|
627
709
|
export async function fetchMrBaseSha(baseUrl, token, projectId, mrIid, fetcher = fetch) {
|
|
628
710
|
try {
|
|
629
|
-
const response = await fetcher(`${baseUrl}/api/v4/projects/${projectId}/merge_requests/${mrIid}`, { headers:
|
|
711
|
+
const response = await fetcher(`${baseUrl}/api/v4/projects/${projectId}/merge_requests/${mrIid}`, { headers: gitlabAuthHeaders(token) });
|
|
630
712
|
if (!response.ok)
|
|
631
713
|
return undefined;
|
|
632
714
|
const mr = await response.json();
|
|
@@ -942,7 +1024,7 @@ export function apply(ctx, config) {
|
|
|
942
1024
|
throw err;
|
|
943
1025
|
}
|
|
944
1026
|
}
|
|
945
|
-
async function runAuditor(worktreePath, payload, effective, modelSelection) {
|
|
1027
|
+
async function runAuditor(worktreePath, payload, effective, modelSelection, opts) {
|
|
946
1028
|
let handle;
|
|
947
1029
|
const agentOptions = agentOptionsForModel(modelSelection ?? ctx.agentDefaultModel.currentSelection());
|
|
948
1030
|
try {
|
|
@@ -970,7 +1052,7 @@ export function apply(ctx, config) {
|
|
|
970
1052
|
}
|
|
971
1053
|
ctx.sessionTitle.rename(handle.agent.session, `Maestro Auditor — MR !${payload.mrIid} (${payload.projectPath})`);
|
|
972
1054
|
try {
|
|
973
|
-
const prompt =
|
|
1055
|
+
const prompt = buildAuditorPrompt({ staticOnly: opts?.staticOnly === true });
|
|
974
1056
|
handle.agent.followup(createUserMessage({ content: [{ type: 'text', text: prompt }], source: { kind: 'user' } }));
|
|
975
1057
|
await whenIdleWithTimeout(handle, effectiveAgentTimeoutMs);
|
|
976
1058
|
const output = auditorOutputFromSession(handle.agent.session);
|
|
@@ -981,8 +1063,9 @@ export function apply(ctx, config) {
|
|
|
981
1063
|
await handle.dispose();
|
|
982
1064
|
}
|
|
983
1065
|
}
|
|
984
|
-
|
|
985
|
-
|
|
1066
|
+
async function runReview(payload) {
|
|
1067
|
+
const t0 = Date.now();
|
|
1068
|
+
try {
|
|
986
1069
|
const userConfig = await loadUserConfig();
|
|
987
1070
|
const effective = {
|
|
988
1071
|
gitlabBaseUrl: userConfig.gitlabBaseUrl ?? config.gitlabBaseUrl,
|
|
@@ -1000,18 +1083,41 @@ export function apply(ctx, config) {
|
|
|
1000
1083
|
});
|
|
1001
1084
|
}
|
|
1002
1085
|
const mapping = effective.projectMappings.find(m => m.projectPath === payload.projectPath);
|
|
1086
|
+
// CI-deep (spec §3): unmapped deep review with CI env + head SHA skips
|
|
1087
|
+
// both the decline and the diff-only fallback and runs the clone branch
|
|
1088
|
+
// below, which shares the mapped path's completion tail.
|
|
1089
|
+
const ciDeep = mapping === undefined && payload.mode === 'deep' && shouldCiDeepReview(payload);
|
|
1090
|
+
// CI quick-with-profile: unmapped quick + non-generic profile + CI env
|
|
1091
|
+
// skips the diff-only fallback and joins the clone branch below, which
|
|
1092
|
+
// runs reviewer-only (quick never audits).
|
|
1093
|
+
const ciQuickProfile = mapping === undefined && shouldCiQuickProfileReview(payload);
|
|
1003
1094
|
// Unmapped reviewer assignments remain no-ops. Only an explicit mention
|
|
1004
1095
|
// may opt into the intentionally limited, diff-only fallback below.
|
|
1005
|
-
if (mapping === undefined && payload.trigger !== 'mention')
|
|
1006
|
-
|
|
1096
|
+
if (mapping === undefined && payload.trigger !== 'mention') {
|
|
1097
|
+
console.error(`maestro-orchestrator: drop unmapped project=${payload.projectPath} mr=!${payload.mrIid} trigger=${payload.trigger}`);
|
|
1098
|
+
return { ok: true, failures: [], durationMs: Date.now() - t0 };
|
|
1099
|
+
}
|
|
1100
|
+
const triggers = resolveReviewTriggers(userConfig, mapping);
|
|
1101
|
+
// Gated-off auto-triggers stay fully silent: no history, no signals, no comment (host log only).
|
|
1102
|
+
if (payload.trigger === 'reviewer-assignment' && !triggers.onAssign) {
|
|
1103
|
+
console.error(`maestro-orchestrator: drop assign-gate-off project=${payload.projectPath} mr=!${payload.mrIid} trigger=${payload.trigger}`);
|
|
1104
|
+
return { ok: true, failures: [], durationMs: Date.now() - t0 };
|
|
1105
|
+
}
|
|
1106
|
+
if (payload.trigger === 'push' && !triggers.onPush) {
|
|
1107
|
+
console.error(`maestro-orchestrator: drop push-gate-off project=${payload.projectPath} mr=!${payload.mrIid} trigger=${payload.trigger}`);
|
|
1108
|
+
return { ok: true, failures: [], durationMs: Date.now() - t0 };
|
|
1109
|
+
}
|
|
1007
1110
|
// A push only re-reviews an MR that already has a completed review;
|
|
1008
1111
|
// otherwise every newly opened MR would be reviewed twice.
|
|
1009
|
-
if (payload.trigger === 'push' && !(await hasCompletedReview(payload.projectId, payload.mrIid)))
|
|
1010
|
-
|
|
1112
|
+
if (payload.trigger === 'push' && !(await hasCompletedReview(payload.projectId, payload.mrIid))) {
|
|
1113
|
+
console.error(`maestro-orchestrator: drop push-no-completed-history project=${payload.projectPath} mr=!${payload.mrIid} trigger=${payload.trigger}`);
|
|
1114
|
+
return { ok: true, failures: [], durationMs: Date.now() - t0 };
|
|
1115
|
+
}
|
|
1011
1116
|
const { gitlabToken } = effective;
|
|
1012
1117
|
if (gitlabToken === undefined) {
|
|
1013
|
-
|
|
1014
|
-
|
|
1118
|
+
const message = `MR !${String(payload.mrIid)} for project ${payload.projectPath} has no GitLab token — set one in Maestro Settings or MAESTRO_GITLAB_TOKEN`;
|
|
1119
|
+
console.error(`maestro-orchestrator: drop missing-token project=${payload.projectPath} mr=!${String(payload.mrIid)} trigger=${payload.trigger} — ${message}`);
|
|
1120
|
+
return { ok: false, failures: [message], durationMs: Date.now() - t0 };
|
|
1015
1121
|
}
|
|
1016
1122
|
const resolved = { ...effective, gitlabToken };
|
|
1017
1123
|
const historyId = `${payload.projectId}-${payload.mrIid}-${Date.now()}`;
|
|
@@ -1043,7 +1149,7 @@ export function apply(ctx, config) {
|
|
|
1043
1149
|
const fallbackSelection = ctx.get?.('agentDefaultModel')?.currentSelection()
|
|
1044
1150
|
?? ctx.agentDefaultModel?.currentSelection()
|
|
1045
1151
|
?? { provider: 'fallback', model: 'fallback' };
|
|
1046
|
-
const reviewModelSelection = resolveReviewModel(userConfig, mapping, fallbackSelection);
|
|
1152
|
+
const reviewModelSelection = resolveReviewModel(userConfig, mapping, fallbackSelection, config.reviewModel);
|
|
1047
1153
|
// Opt-in Telegram digest; a delivery failure is logged and dropped.
|
|
1048
1154
|
const reviewStartMsOuter = Date.now();
|
|
1049
1155
|
const notifyTelegram = (status, summary, extra) => {
|
|
@@ -1093,34 +1199,42 @@ export function apply(ctx, config) {
|
|
|
1093
1199
|
: undefined;
|
|
1094
1200
|
await signals?.start();
|
|
1095
1201
|
const postComment = async (body) => {
|
|
1096
|
-
const response = await
|
|
1202
|
+
const response = await GitlabClient.fetchWithTimeout(`${resolved.gitlabBaseUrl}/api/v4/projects/${payload.projectId}/merge_requests/${payload.mrIid}/notes`, {
|
|
1097
1203
|
method: 'POST',
|
|
1098
|
-
headers: {
|
|
1204
|
+
headers: { ...gitlabAuthHeaders(resolved.gitlabToken), 'Content-Type': 'application/json' },
|
|
1099
1205
|
body: JSON.stringify({ body }),
|
|
1100
1206
|
});
|
|
1101
1207
|
if (!response.ok)
|
|
1102
1208
|
throw new Error(`GitLab API error ${response.status}: ${await response.text()}`);
|
|
1103
1209
|
};
|
|
1104
1210
|
const replyToDiscussion = async (discussionId, body) => {
|
|
1105
|
-
const response = await
|
|
1211
|
+
const response = await GitlabClient.fetchWithTimeout(`${resolved.gitlabBaseUrl}/api/v4/projects/${payload.projectId}/merge_requests/${payload.mrIid}/discussions/${encodeURIComponent(discussionId)}/notes`, {
|
|
1106
1212
|
method: 'POST',
|
|
1107
|
-
headers: {
|
|
1213
|
+
headers: { ...gitlabAuthHeaders(resolved.gitlabToken), 'Content-Type': 'application/json' },
|
|
1108
1214
|
body: JSON.stringify({ body }),
|
|
1109
1215
|
});
|
|
1110
1216
|
if (!response.ok)
|
|
1111
1217
|
throw new Error(`GitLab API error ${response.status}: ${await response.text()}`);
|
|
1112
1218
|
};
|
|
1113
1219
|
try {
|
|
1114
|
-
if (mapping === undefined) {
|
|
1115
|
-
|
|
1116
|
-
|
|
1220
|
+
if (mapping === undefined && !ciDeep && !ciQuickProfile) {
|
|
1221
|
+
// CI-deep (spec §3) skips the decline and falls through to the clone
|
|
1222
|
+
// branch below; every other unmapped deep review still declines here.
|
|
1223
|
+
if (payload.mode === 'deep' && !shouldCiDeepReview(payload)) {
|
|
1224
|
+
const declined = await declineUnmappedDeepReview(payload, { postComment, replyToDiscussion, writeFailedReport, gitlabBaseUrl: resolved.gitlabBaseUrl });
|
|
1225
|
+
if (!declined) {
|
|
1226
|
+
console.error(`maestro-orchestrator: deduped duplicate in-flight review project=${payload.projectPath} mr=!${payload.mrIid} trigger=${payload.trigger}`);
|
|
1227
|
+
await recordReviewFinish(historyId, { status: 'completed', summary: 'Duplicate in-flight review deduped — see the active run.' });
|
|
1228
|
+
await signals?.finish('completed');
|
|
1229
|
+
return { ok: true, summary: 'Duplicate in-flight review deduped — see the active run.', failures: [], durationMs: Date.now() - t0 };
|
|
1230
|
+
}
|
|
1117
1231
|
await recordReviewFinish(historyId, { status: 'completed', summary: 'Deep review declined (unmapped project)' });
|
|
1118
1232
|
notifyTelegram('completed', 'Deep review declined (unmapped project)');
|
|
1119
1233
|
await signals?.finish('completed');
|
|
1120
|
-
return;
|
|
1234
|
+
return { ok: true, summary: 'Deep review declined (unmapped project)', failures: [], durationMs: Date.now() - t0 };
|
|
1121
1235
|
}
|
|
1122
1236
|
const diffBody = await runDiffOnlyReview(payload, {
|
|
1123
|
-
runReviewer: (p) => runReviewer(undefined, p, resolved,
|
|
1237
|
+
runReviewer: (p) => runReviewer(undefined, p, resolved, payload.reviewProfile, reviewModelSelection, incrementalBlock),
|
|
1124
1238
|
postComment,
|
|
1125
1239
|
replyToDiscussion,
|
|
1126
1240
|
writeFailedReport,
|
|
@@ -1129,59 +1243,120 @@ export function apply(ctx, config) {
|
|
|
1129
1243
|
await recordReviewFinish(historyId, { status: 'completed', summary: summarize(diffBody) });
|
|
1130
1244
|
notifyTelegram('completed', summarize(diffBody));
|
|
1131
1245
|
await signals?.finish('completed');
|
|
1132
|
-
return;
|
|
1246
|
+
return { ok: true, summary: summarize(diffBody), failures: [], durationMs: Date.now() - t0 };
|
|
1133
1247
|
}
|
|
1134
1248
|
let fullBody;
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1249
|
+
if (ciDeep || ciQuickProfile) {
|
|
1250
|
+
// CI-deep (mapping is always undefined here — the unmapped block above
|
|
1251
|
+
// returned for every other case): clone the source at the head SHA,
|
|
1252
|
+
// map it in memory, and reuse the mapped machinery reviewer-only.
|
|
1253
|
+
// CI quick-with-profile joins the same branch; runReviewAndAudit skips
|
|
1254
|
+
// the auditor for quick (shouldAudit), so it stays reviewer-only.
|
|
1255
|
+
// No govard/vendor linking (ciEnsureWorktree is plain fetch + worktree).
|
|
1256
|
+
const ciHost = process.env.GITLAB_HOST?.trim() || new URL(resolved.gitlabBaseUrl).hostname;
|
|
1257
|
+
const cloneDir = join('/tmp', `maestro-ci-src-${payload.projectId}-${payload.mrIid}`);
|
|
1258
|
+
await cloneSourceRepo({ fetcher: fetch, run: defaultRun, host: ciHost, projectId: payload.projectId, sourceBranch: payload.sourceBranch, headSha: payload.headSha, token: resolved.gitlabToken, dir: cloneDir });
|
|
1259
|
+
try {
|
|
1260
|
+
const ciEnsureWorktree = async (repoPath, branch, pid, iid, suffix) => {
|
|
1261
|
+
assertSafeBranchName(branch);
|
|
1262
|
+
const wt = join('/tmp', `maestro-mr-${pid}-${iid}${suffix === undefined ? '' : `-${suffix}`}`);
|
|
1263
|
+
await defaultRun('git', ['fetch', '--depth', '50', 'origin', branch], repoPath);
|
|
1264
|
+
await defaultRun('git', ['worktree', 'remove', '--force', wt], repoPath).catch(() => { });
|
|
1265
|
+
await defaultRun('git', ['worktree', 'add', '--detach', '--', wt, payload.headSha], repoPath);
|
|
1266
|
+
return wt;
|
|
1267
|
+
};
|
|
1268
|
+
fullBody = await runReviewAndAudit(payload, {
|
|
1269
|
+
localRepoPath: cloneDir,
|
|
1270
|
+
ensureWorktree: ciEnsureWorktree,
|
|
1271
|
+
removeWorktree,
|
|
1272
|
+
runReviewer: (worktreePath, p) => runReviewer(worktreePath, p, resolved, payload.reviewProfile ?? 'generic', reviewModelSelection, incrementalBlock),
|
|
1273
|
+
runAuditor: withAuditorDegrade((worktreePath, p) => runAuditor(worktreePath, p, resolved, reviewModelSelection, { staticOnly: true })),
|
|
1274
|
+
postComment,
|
|
1275
|
+
replyToDiscussion,
|
|
1276
|
+
writeFailedReport,
|
|
1277
|
+
gitlabBaseUrl: resolved.gitlabBaseUrl,
|
|
1278
|
+
reviewProfile: payload.reviewProfile ?? 'generic',
|
|
1279
|
+
});
|
|
1280
|
+
}
|
|
1281
|
+
finally {
|
|
1282
|
+
await defaultRun('rm', ['-rf', cloneDir]).catch(() => { });
|
|
1283
|
+
}
|
|
1148
1284
|
}
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1285
|
+
else {
|
|
1286
|
+
// Unreachable when mapping is undefined: the unmapped block returned
|
|
1287
|
+
// for every non-CI-deep case, and ciDeep took the branch above.
|
|
1288
|
+
if (mapping === undefined)
|
|
1289
|
+
throw new Error('unreachable: unmapped review without CI-deep decision');
|
|
1290
|
+
try {
|
|
1291
|
+
fullBody = await runReviewAndAudit(payload, {
|
|
1292
|
+
localRepoPath: mapping.localRepoPath,
|
|
1293
|
+
ensureWorktree,
|
|
1294
|
+
removeWorktree,
|
|
1295
|
+
runReviewer: (worktreePath, p) => runReviewer(worktreePath, p, resolved, mapping.reviewProfile ?? 'magento2', reviewModelSelection, incrementalBlock),
|
|
1296
|
+
runAuditor: (worktreePath, p) => runAuditor(worktreePath, p, resolved, reviewModelSelection),
|
|
1154
1297
|
postComment,
|
|
1155
1298
|
replyToDiscussion,
|
|
1156
1299
|
writeFailedReport,
|
|
1157
1300
|
gitlabBaseUrl: resolved.gitlabBaseUrl,
|
|
1301
|
+
reviewProfile: mapping.reviewProfile ?? 'magento2',
|
|
1158
1302
|
});
|
|
1159
|
-
const summary = summarize(diffBody);
|
|
1160
|
-
const branchNote = `fallback diff-only: branch ${payload.sourceBranch} not found on origin — ${summary ?? ''}`.trim();
|
|
1161
|
-
await recordReviewFinish(historyId, { status: 'completed', summary: branchNote });
|
|
1162
|
-
notifyTelegram('completed', branchNote);
|
|
1163
|
-
await signals?.finish('completed');
|
|
1164
|
-
return;
|
|
1165
1303
|
}
|
|
1166
|
-
|
|
1304
|
+
catch (err) {
|
|
1305
|
+
const isBranchNotFound = err?.code === 'BRANCH_NOT_FOUND' || isBranchNotFoundError(err);
|
|
1306
|
+
if (isBranchNotFound) {
|
|
1307
|
+
const diffBody = await runDiffOnlyReview(payload, {
|
|
1308
|
+
runReviewer: (p) => runReviewer(undefined, p, resolved, payload.reviewProfile, reviewModelSelection, incrementalBlock),
|
|
1309
|
+
postComment,
|
|
1310
|
+
replyToDiscussion,
|
|
1311
|
+
writeFailedReport,
|
|
1312
|
+
gitlabBaseUrl: resolved.gitlabBaseUrl,
|
|
1313
|
+
});
|
|
1314
|
+
if (diffBody === '') {
|
|
1315
|
+
console.error(`maestro-orchestrator: deduped duplicate in-flight review project=${payload.projectPath} mr=!${payload.mrIid} trigger=${payload.trigger}`);
|
|
1316
|
+
await recordReviewFinish(historyId, { status: 'completed', summary: 'Duplicate in-flight review deduped — see the active run.' });
|
|
1317
|
+
await signals?.finish('completed');
|
|
1318
|
+
return { ok: true, summary: 'Duplicate in-flight review deduped — see the active run.', failures: [], durationMs: Date.now() - t0 };
|
|
1319
|
+
}
|
|
1320
|
+
const summary = summarize(diffBody);
|
|
1321
|
+
const branchNote = `fallback diff-only: branch ${payload.sourceBranch} not found on origin — ${summary ?? ''}`.trim();
|
|
1322
|
+
await recordReviewFinish(historyId, { status: 'completed', summary: branchNote });
|
|
1323
|
+
notifyTelegram('completed', branchNote);
|
|
1324
|
+
await signals?.finish('completed');
|
|
1325
|
+
return { ok: true, summary: branchNote, failures: [], durationMs: Date.now() - t0 };
|
|
1326
|
+
}
|
|
1327
|
+
throw err;
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
if (fullBody === '') {
|
|
1331
|
+
console.error(`maestro-orchestrator: deduped duplicate in-flight review project=${payload.projectPath} mr=!${payload.mrIid} trigger=${payload.trigger}`);
|
|
1332
|
+
await recordReviewFinish(historyId, { status: 'completed', summary: 'Duplicate in-flight review deduped — see the active run.' });
|
|
1333
|
+
await signals?.finish('completed');
|
|
1334
|
+
return { ok: true, summary: 'Duplicate in-flight review deduped — see the active run.', failures: [], durationMs: Date.now() - t0 };
|
|
1167
1335
|
}
|
|
1168
1336
|
await recordReviewFinish(historyId, { status: 'completed', summary: summarize(fullBody) });
|
|
1169
1337
|
notifyTelegram('completed', summarize(fullBody));
|
|
1170
1338
|
await signals?.finish('completed');
|
|
1339
|
+
return { ok: true, summary: summarize(fullBody), failures: [], durationMs: Date.now() - t0 };
|
|
1171
1340
|
}
|
|
1172
1341
|
catch (err) {
|
|
1173
1342
|
const message = err instanceof Error ? err.message : String(err);
|
|
1174
1343
|
await recordReviewFinish(historyId, { status: 'failed', error: message }).catch(() => { });
|
|
1175
1344
|
notifyTelegram('failed', message);
|
|
1176
1345
|
await signals?.finish('failed');
|
|
1177
|
-
|
|
1346
|
+
return { ok: false, summary: undefined, failures: [message], durationMs: Date.now() - t0 };
|
|
1178
1347
|
}
|
|
1179
|
-
}
|
|
1348
|
+
}
|
|
1349
|
+
catch (err) {
|
|
1180
1350
|
// Worktree creation, agent creation, and fallback delivery all run from
|
|
1181
|
-
//
|
|
1182
|
-
// fire-and-forget
|
|
1351
|
+
// this function — surface failures as a result instead of an unhandled
|
|
1352
|
+
// rejection, so both the fire-and-forget webhook path and an awaiting
|
|
1353
|
+
// CI caller observe the same outcome.
|
|
1354
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
1183
1355
|
console.error(`maestro-orchestrator: review run failed for MR !${String(payload.mrIid)}:`, err);
|
|
1184
|
-
|
|
1185
|
-
|
|
1356
|
+
return { ok: false, summary: undefined, failures: [message], durationMs: Date.now() - t0 };
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
ctx.on('maestro/review-request', (payload) => { void runReview(payload); });
|
|
1360
|
+
ctx.provide('reviewRunner', runReview);
|
|
1186
1361
|
}
|
|
1187
1362
|
//# sourceMappingURL=orchestrator.js.map
|