Open History to see the last commit
1import { resolveProjectSettings } from "@t3tools/shared/projectSettings";
2import { visibleThreadPullRequests } from "@t3tools/shared/threadPullRequests";
3import {
4 CommandId,
5 type ThreadId,
6 type OrchestrationV2DomainEvent,
7 type OrchestrationV2ThreadShell,
8} from "@t3tools/contracts";
9import { makeDrainableWorker } from "@t3tools/shared/DrainableWorker";
10import * as Cause from "effect/Cause";
11import * as Context from "effect/Context";
12import * as Crypto from "effect/Crypto";
13import * as DateTime from "effect/DateTime";
14import * as Effect from "effect/Effect";
15import * as FileSystem from "effect/FileSystem";
16import * as Layer from "effect/Layer";
17import * as Schedule from "effect/Schedule";
18import type * as Scope from "effect/Scope";
19import * as Stream from "effect/Stream";
20
21import * as GitManager from "../git/GitManager.ts";
22import * as PullRequestService from "../pullRequest/PullRequestService.ts";
23import * as ServerSettings from "../serverSettings.ts";
24import { forkParked } from "../serverActivation.ts";
25import * as TerminalManager from "../terminal/Manager.ts";
26import * as ProjectStore from "./ProjectStore.ts";
27import * as Orchestrator from "./Orchestrator.ts";
28import * as ProjectionStore from "./ProjectionStore.ts";
29
30export interface SettlementPullRequest {
31 readonly state: "open" | "closed" | "merged";
32 readonly closedAt?: string | null;
33 readonly mergedAt?: string | null;
34}
35
36const DAY_MS = 24 * 60 * 60 * 1_000;
37export const QUEUED_TURN_START_GRACE_MS = 2 * 60 * 1_000;
38
39function toMillis(value: DateTime.Utc | null | undefined): number | null {
40 return value == null ? null : DateTime.toEpochMillis(value);
41}
42
43function latestMillis(values: ReadonlyArray<number | null>): number | null {
44 let latest: number | null = null;
45 for (const value of values) {
46 if (value === null) continue;
47 if (latest === null || value > latest) latest = value;
48 }
49 return latest;
50}
51
52function canonicalRepositoryKey(key: string): string {
53 return key
54 .replace(
55 /^(?:ssh\.dev\.azure\.com|vs-ssh\.visualstudio\.com)\/v3\/([^/]+)\/([^/]+)\/([^/]+)$/u,
56 "dev.azure.com/$1/$2/_git/$3",
57 )
58 .replace(
59 /^([^.]+)\.visualstudio\.com\/(?:defaultcollection\/)?([^/]+)\/_git\/([^/]+)$/u,
60 "dev.azure.com/$1/$2/_git/$3",
61 );
62}
63
64function pullRequestMatchesProject(
65 pullRequest: GitManager.GitBranchPullRequest,
66 project: {
67 readonly repositoryIdentity?: { readonly canonicalKey: string } | null | undefined;
68 },
69): boolean {
70 return (
71 pullRequest.repositoryKey !== null &&
72 project.repositoryIdentity != null &&
73 canonicalRepositoryKey(pullRequest.repositoryKey) ===
74 canonicalRepositoryKey(project.repositoryIdentity.canonicalKey)
75 );
76}
77
78/**
79 * A recent user message stays queued until a run adopts its timestamp.
80 * Absolute age bounds client clock skew in both directions and stops stale
81 * pre-adoption data from blocking the thread forever. A failed run start
82 * clears the block immediately (mirrors the v1 session "error" rule).
83 */
84export function threadHasQueuedTurnStart(
85 thread: Pick<
86 OrchestrationV2ThreadShell,
87 | "latestUserMessageAt"
88 | "latestRunRequestedAt"
89 | "latestRunStartedAt"
90 | "latestRunCompletedAt"
91 | "latestRunId"
92 | "status"
93 >,
94 nowMs: number,
95): boolean {
96 const messageAtMs = toMillis(thread.latestUserMessageAt);
97 if (messageAtMs === null || thread.status === "failed") return false;
98 const age = nowMs - messageAtMs;
99 if (Number.isNaN(age) || Math.abs(age) > QUEUED_TURN_START_GRACE_MS) return false;
100 if (thread.latestRunId === null) return true;
101 return [
102 toMillis(thread.latestRunRequestedAt),
103 toMillis(thread.latestRunStartedAt),
104 toMillis(thread.latestRunCompletedAt),
105 ].every((value) => value === null || value < messageAtMs);
106}
107
108function pullRequestSettles(
109 thread: Pick<
110 OrchestrationV2ThreadShell,
111 "createdAt" | "latestUserMessageAt" | "latestRunRequestedAt"
112 >,
113 pullRequest: SettlementPullRequest,
114 autoSettleOnMerge: boolean,
115): boolean {
116 if (pullRequest.state !== "closed" && (pullRequest.state !== "merged" || !autoSettleOnMerge)) {
117 return false;
118 }
119 const terminalAt = pullRequest.state === "merged" ? pullRequest.mergedAt : pullRequest.closedAt;
120 if (terminalAt == null) return false;
121 const userAnchorMs = latestMillis([
122 toMillis(thread.createdAt),
123 toMillis(thread.latestUserMessageAt),
124 toMillis(thread.latestRunRequestedAt),
125 ]);
126 if (userAnchorMs === null) return false;
127 const pullRequestAtMs = Date.parse(terminalAt);
128 if (Number.isNaN(pullRequestAtMs)) return false;
129 return pullRequestAtMs >= userAnchorMs;
130}
131
132/** Cheap checks that run before any source control lookup. */
133export function isAutoSettlementCandidate(
134 thread: ProjectionStore.ProjectionSettlementCandidate,
135 nowMs: number,
136): boolean {
137 if (thread.archivedAt !== null || thread.settledOverride !== null) return false;
138 if (thread.pinnedAt != null || thread.autoSettleDisabledAt != null) return false;
139 // Blocked-on-you work must never park behind a settled override.
140 if (thread.pendingRuntimeRequest !== null) return false;
141 // A live run — or post-settlement background work — is not staleness.
142 if (thread.activityRunStatus != null) return false;
143 if ((thread.pendingBackgroundTasks?.length ?? 0) > 0) return false;
144 if (threadHasQueuedTurnStart(thread, nowMs)) return false;
145 const snoozedUntilMs = toMillis(thread.snoozedUntil);
146 if (snoozedUntilMs === null || snoozedUntilMs <= nowMs) return true;
147 // A snoozed thread that woke early (error or completed work) can settle;
148 // one still parked on its wake time keeps its stronger statement.
149 const snoozedAtMs = toMillis(thread.snoozedAt);
150 const completedAtMs = toMillis(thread.latestRunCompletedAt);
151 const wokeOnError =
152 thread.status === "failed" &&
153 (snoozedAtMs === null || (completedAtMs !== null && completedAtMs > snoozedAtMs));
154 const wokeOnCompletion =
155 snoozedAtMs !== null && completedAtMs !== null && completedAtMs > snoozedAtMs;
156 return wokeOnError || wokeOnCompletion;
157}
158
159export function resolveAutoSettlementAt(input: {
160 readonly thread: ProjectionStore.ProjectionSettlementCandidate;
161 readonly pullRequest: SettlementPullRequest | null;
162 readonly nowMs: number;
163 readonly autoSettleAfterDays: number | null;
164 readonly autoSettleOnMerge: boolean;
165}): DateTime.Utc | null {
166 const { thread } = input;
167 let pullRequest = input.pullRequest;
168 const links = visibleThreadPullRequests(thread.pullRequests ?? []);
169 if (links.some((link) => link.snapshot === null || link.snapshot.state === "open")) return null;
170 if (links.length > 0) {
171 const terminalAt = (link: (typeof links)[number]) => {
172 const snapshot = link.snapshot;
173 const value = snapshot?.state === "merged" ? snapshot.mergedAt : snapshot?.closedAt;
174 const timestamp = Date.parse(value ?? "");
175 return Number.isNaN(timestamp) ? Number.NEGATIVE_INFINITY : timestamp;
176 };
177 const latest = links.reduce((current, candidate) =>
178 terminalAt(candidate) > terminalAt(current) ? candidate : current,
179 );
180 pullRequest =
181 latest.snapshot === null
182 ? null
183 : {
184 state: latest.snapshot.state,
185 mergedAt: latest.snapshot.mergedAt ?? null,
186 closedAt: latest.snapshot.closedAt ?? null,
187 };
188 }
189 if (!isAutoSettlementCandidate(thread, input.nowMs)) return null;
190 const activityAtMs = latestMillis([
191 toMillis(thread.latestUserMessageAt),
192 toMillis(thread.latestRunRequestedAt),
193 toMillis(thread.latestRunStartedAt),
194 toMillis(thread.latestRunCompletedAt),
195 ]);
196 if (pullRequest !== null && pullRequestSettles(thread, pullRequest, input.autoSettleOnMerge)) {
197 return activityAtMs === null ? thread.createdAt : DateTime.makeUnsafe(activityAtMs);
198 }
199 if (input.autoSettleAfterDays === null || activityAtMs === null) return null;
200 return activityAtMs < input.nowMs - input.autoSettleAfterDays * DAY_MS
201 ? DateTime.makeUnsafe(activityAtMs)
202 : null;
203}
204
205export class ThreadSettlementServiceV2 extends Context.Service<
206 ThreadSettlementServiceV2,
207 {
208 readonly start: () => Effect.Effect<void, never, Scope.Scope>;
209 readonly drain: Effect.Effect<void>;
210 }
211>()("t3/orchestration-v2/ThreadSettlementService/ThreadSettlementServiceV2") {}
212
213function autoSettlementConfigured(settings: import("@t3tools/contracts").ServerSettings): boolean {
214 if (settings.sidebarAutoSettleOnMerge || settings.sidebarAutoSettleAfterDays !== null) {
215 return true;
216 }
217 return Object.values(settings.projectSettingsOverrides).some(
218 (entry) =>
219 entry.sidebarAutoSettleOnMerge === true ||
220 (entry.sidebarAutoSettleAfterDays !== undefined && entry.sidebarAutoSettleAfterDays !== null),
221 );
222}
223
224/** Identity of every settlement input, so unrelated settings edits do not trigger a sweep. */
225/** @internal Exported for tests. */
226export function autoSettlementSettingsKey(
227 settings: import("@t3tools/contracts").ServerSettings,
228): string {
229 return JSON.stringify([
230 settings.sidebarAutoSettleOnMerge,
231 settings.sidebarAutoSettleAfterDays,
232 // Only entries that touch settlement, in a stable order, so a project
233 // override on an unrelated key does not queue a sweep. JSON drops
234 // undefined, so inherit (absent) and never (null) need distinct marks.
235 Object.entries(settings.projectSettingsOverrides)
236 .filter(
237 ([, entry]) =>
238 entry.sidebarAutoSettleOnMerge !== undefined ||
239 entry.sidebarAutoSettleAfterDays !== undefined,
240 )
241 .sort(([left], [right]) => left.localeCompare(right))
242 .map(([projectId, entry]) => [
243 projectId,
244 entry.sidebarAutoSettleOnMerge ?? "inherit",
245 entry.sidebarAutoSettleAfterDays === undefined
246 ? "inherit"
247 : entry.sidebarAutoSettleAfterDays,
248 ]),
249 ]);
250}
251
252export const make = Effect.gen(function* () {
253 const orchestrator = yield* Orchestrator.OrchestratorV2;
254 const projections = yield* ProjectionStore.ProjectionStoreV2;
255 const projectStore = yield* ProjectStore.ProjectStoreV2;
256 const settingsService = yield* ServerSettings.ServerSettingsService;
257 const git = yield* GitManager.GitManager;
258 const pullRequests = yield* PullRequestService.PullRequestService;
259 const crypto = yield* Crypto.Crypto;
260 const fileSystem = yield* FileSystem.FileSystem;
261 const terminals = yield* TerminalManager.TerminalManager;
262
263 const sweep = Effect.fn("ThreadSettlementServiceV2.sweep")(function* (
264 mergedPullRequest: PullRequestService.PullRequestMergeEvent | null,
265 threadId?: ThreadId,
266 ) {
267 const settings = yield* settingsService.getSettings;
268 if (!autoSettlementConfigured(settings)) {
269 return;
270 }
271 // A sweep for one thread reads only that thread's candidate row.
272 const threads = yield* projections.getSettlementCandidates(threadId);
273 if (threads.length === 0) return;
274 const projectShells = yield* projectStore.listShells();
275 const nowMs = DateTime.toEpochMillis(yield* DateTime.now);
276 const projects = new Map(projectShells.map((project) => [project.id, project]));
277 // A merge event re-sweeps every candidate, not just the threads linked to
278 // the merged pull request: most threads carry no link and settle from
279 // their branch lookup, which would otherwise wait for the next minute's
280 // sweep on a possibly stale cached answer.
281 const candidates = threads.filter((thread) => isAutoSettlementCandidate(thread, nowMs));
282
283 const settleThread = Effect.fn("ThreadSettlementServiceV2.settleThread")(
284 function* (thread: (typeof candidates)[number], pullRequest: SettlementPullRequest | null) {
285 const currentSettings = resolveProjectSettings(
286 yield* settingsService.getSettings,
287 thread.projectId,
288 ).settings;
289 const decisionNow = yield* DateTime.now;
290 const settledAt = resolveAutoSettlementAt({
291 thread,
292 pullRequest,
293 nowMs: DateTime.toEpochMillis(decisionNow),
294 autoSettleAfterDays: currentSettings.sidebarAutoSettleAfterDays,
295 autoSettleOnMerge: currentSettings.sidebarAutoSettleOnMerge,
296 });
297 if (settledAt === null) return thread;
298 const uuid = yield* crypto.randomUUIDv4;
299 yield* orchestrator.dispatch({
300 type: "thread.auto-settle",
301 commandId: CommandId.make(`server:auto-settle:${thread.id}:${uuid}`),
302 threadId: thread.id,
303 snapshotAt: thread.updatedAt,
304 settledAt,
305 });
306 return null;
307 },
308 (effect, thread) =>
309 effect.pipe(
310 Effect.catchCause((cause) =>
311 Cause.hasInterruptsOnly(cause)
312 ? Effect.failCause(cause)
313 : Effect.logWarning("automatic thread settlement skipped", {
314 threadId: thread.id,
315 cause: Cause.pretty(cause),
316 }).pipe(Effect.as(null)),
317 ),
318 ),
319 );
320
321 // Inactivity is entirely projection-backed. Complete those decisions before
322 // a source-control lookup can delay or fail an otherwise eligible thread.
323 const lookupCandidates = (yield* Effect.forEach(
324 candidates,
325 (thread) => settleThread(thread, null),
326 { concurrency: 8 },
327 ))
328 .filter((thread) => thread !== null)
329 .filter((thread) => visibleThreadPullRequests(thread.pullRequests ?? []).length === 0);
330 // Use the same cwd as the sidebar so both paths share GitManager's PR cache.
331 const lookupCwdByThreadId = new Map<string, string>();
332 yield* Effect.forEach(
333 lookupCandidates,
334 (thread) =>
335 Effect.gen(function* () {
336 const project = projects.get(thread.projectId);
337 if (project === undefined || thread.branch === null) return;
338 const worktreeExists =
339 thread.worktreePath !== null &&
340 (yield* fileSystem.exists(thread.worktreePath).pipe(Effect.orElseSucceed(() => false)));
341 lookupCwdByThreadId.set(
342 thread.id,
343 worktreeExists && thread.worktreePath !== null
344 ? thread.worktreePath
345 : project.workspaceRoot,
346 );
347 }),
348 { concurrency: 8, discard: true },
349 );
350 if (mergedPullRequest !== null) {
351 // The merge just confirmed a terminal state the lookup caches can still
352 // call open (branch answers live two minutes, the sweep runs every
353 // minute). Drop the swept checkouts' cached answers so the merge settles
354 // its branch threads now instead of on a later sweep. Threads linked to
355 // the merged pull request settle from the event itself below and need no
356 // lookup, so they are absent from this map by construction.
357 const cwds = [...new Set(lookupCwdByThreadId.values())];
358 yield* Effect.forEach(cwds, (cwd) => git.invalidateStatus(cwd), {
359 concurrency: 8,
360 discard: true,
361 });
362 }
363 const lookupKey = (thread: (typeof lookupCandidates)[number]) => {
364 const reference = thread.linkedPullRequest ?? thread.branchPullRequest;
365 if (reference != null) {
366 return JSON.stringify([
367 "linked",
368 reference.projectId,
369 reference.repository,
370 reference.number,
371 lookupCwdByThreadId.get(thread.id),
372 thread.branch,
373 ]);
374 }
375 if (thread.branch === null) return JSON.stringify(["none", thread.id]);
376 const cwd = lookupCwdByThreadId.get(thread.id);
377 return JSON.stringify(
378 cwd === undefined ? ["missing-project", thread.id] : ["branch", cwd, thread.branch],
379 );
380 };
381 const groups = Map.groupBy(lookupCandidates, lookupKey);
382
383 const wouldSettle = Effect.fn("ThreadSettlementServiceV2.wouldSettle")(function* (
384 group: ReadonlyArray<(typeof lookupCandidates)[number]>,
385 pullRequest: SettlementPullRequest,
386 ) {
387 const currentSettings = yield* settingsService.getSettings;
388 const decisionNow = yield* DateTime.now;
389 return group.some((thread) => {
390 const { settings } = resolveProjectSettings(currentSettings, thread.projectId);
391 return (
392 resolveAutoSettlementAt({
393 thread,
394 pullRequest,
395 nowMs: DateTime.toEpochMillis(decisionNow),
396 autoSettleAfterDays: settings.sidebarAutoSettleAfterDays,
397 autoSettleOnMerge: settings.sidebarAutoSettleOnMerge,
398 }) !== null
399 );
400 });
401 });
402
403 const pullRequestFor = Effect.fn("ThreadSettlementServiceV2.pullRequestFor")(function* (
404 group: ReadonlyArray<(typeof lookupCandidates)[number]>,
405 ) {
406 const thread = group[0]!;
407 const reference = thread.linkedPullRequest ?? thread.branchPullRequest;
408 if (reference != null) {
409 // The event carries the merged state, so only the threads linked to
410 // that exact pull request settle from it. Every other linked thread
411 // falls through to a fresh summary lookup below: the merge sweep
412 // covers all candidates, and an unrelated merge must never settle
413 // them.
414 const matchesMerge =
415 mergedPullRequest !== null &&
416 reference.projectId === mergedPullRequest.projectId &&
417 reference.repository.toLowerCase() === mergedPullRequest.repository.toLowerCase() &&
418 reference.number === mergedPullRequest.number;
419 if (!matchesMerge && !projects.has(reference.projectId)) {
420 return yield* Effect.die(new Error("linked pull request project not found"));
421 }
422 const summary = matchesMerge
423 ? ({
424 state: "merged",
425 closedAt: null,
426 mergedAt: mergedPullRequest.mergedAt,
427 } satisfies SettlementPullRequest)
428 : yield* pullRequests.summary(
429 {
430 projectId: reference.projectId,
431 repository: reference.repository,
432 number: reference.number,
433 },
434 { recoverTransientFailure: false },
435 );
436 const terminal = {
437 state: summary.state,
438 closedAt: summary.closedAt ?? null,
439 mergedAt: summary.mergedAt ?? null,
440 } satisfies SettlementPullRequest;
441 const cwd = lookupCwdByThreadId.get(thread.id);
442 if (summary.state !== "open" && thread.branch !== null && cwd !== undefined) {
443 // Recheck reused branches only when this sweep would settle a thread.
444 // Eligibility that changes after this check waits for the next sweep.
445 if (!(yield* wouldSettle(group, terminal))) return undefined;
446 const current = yield* git.branchPullRequest(
447 { cwd, branch: thread.branch },
448 { refresh: true },
449 );
450 const project = projects.get(thread.projectId);
451 if (
452 current?.state === "open" &&
453 project !== undefined &&
454 pullRequestMatchesProject(current, project)
455 ) {
456 return current;
457 }
458 }
459 return terminal;
460 }
461 if (thread.branch === null) return null;
462 const cwd = lookupCwdByThreadId.get(thread.id);
463 if (cwd === undefined) {
464 return yield* Effect.die(new Error("thread project not found"));
465 }
466 return yield* git.branchPullRequest({ cwd, branch: thread.branch });
467 });
468
469 yield* Effect.forEach(
470 groups.values(),
471 (group) =>
472 Effect.gen(function* () {
473 const pullRequest = yield* pullRequestFor(group);
474 if (pullRequest === undefined) return;
475 yield* Effect.forEach(group, (thread) => settleThread(thread, pullRequest), {
476 discard: true,
477 });
478 }).pipe(
479 Effect.catchCause((cause) =>
480 Cause.hasInterruptsOnly(cause)
481 ? Effect.failCause(cause)
482 : Effect.logWarning("automatic thread settlement skipped", {
483 threadIds: group.map((thread) => thread.id),
484 cause: Cause.pretty(cause),
485 }),
486 ),
487 ),
488 { concurrency: 8, discard: true },
489 );
490 });
491
492 const runSweep = (
493 mergedPullRequest: PullRequestService.PullRequestMergeEvent | null,
494 threadId?: ThreadId,
495 ) =>
496 sweep(mergedPullRequest, threadId).pipe(
497 Effect.catchCause((cause) =>
498 Cause.hasInterruptsOnly(cause)
499 ? Effect.failCause(cause)
500 : Effect.logWarning("automatic thread settlement sweep failed", {
501 cause: Cause.pretty(cause),
502 }),
503 ),
504 );
505 const worker = yield* makeDrainableWorker((threadId: ThreadId | undefined) =>
506 runSweep(null, threadId),
507 );
508
509 // Settling closes the thread's shells that sit at an idle prompt, so they stop
510 // holding the worktree. A terminal running a command (a dev server, an
511 // editor) stays for the user to close.
512 const closeIdleTerminals = Effect.fn("ThreadSettlementServiceV2.closeIdleTerminals")(
513 function* (threadId: ThreadId) {
514 // A thread re-engaged before this event ran keeps its shells.
515 const thread = yield* projections.getThread(threadId);
516 if (thread.settledOverride !== "settled") return;
517 yield* terminals.closeIdle({ threadId });
518 },
519 (effect, threadId) =>
520 effect.pipe(
521 Effect.catchCause((cause) =>
522 Cause.hasInterruptsOnly(cause)
523 ? Effect.failCause(cause)
524 : Effect.logWarning("closing idle terminals after settlement failed", {
525 threadId,
526 cause: Cause.pretty(cause),
527 }),
528 ),
529 ),
530 );
531
532 const processEvent = (event: OrchestrationV2DomainEvent) => {
533 switch (event.type) {
534 case "thread.settled":
535 return closeIdleTerminals(event.threadId);
536 case "thread.pull-request-synced":
537 case "provider-session.detached":
538 return worker.enqueue(event.threadId);
539 case "provider-session.updated":
540 return event.payload.status !== "starting" && event.payload.status !== "running"
541 ? worker.enqueue(event.threadId)
542 : Effect.void;
543 case "run.updated":
544 return ["completed", "interrupted", "failed", "cancelled", "rolled_back"].includes(
545 event.payload.status,
546 )
547 ? worker.enqueue(event.threadId)
548 : Effect.void;
549 default:
550 return Effect.void;
551 }
552 };
553
554 const start: ThreadSettlementServiceV2["Service"]["start"] = Effect.fn(
555 "ThreadSettlementServiceV2.start",
556 )(function* () {
557 const settingsChanges = yield* settingsService.subscribeChanges;
558 const mergedPullRequests = yield* pullRequests.subscribeMerges;
559 const events = orchestrator.streamDomainEvents;
560 const initialSettings = yield* settingsService.getSettings.pipe(Effect.orDie);
561 let lastSettlementSettings = autoSettlementSettingsKey(initialSettings);
562 yield* forkParked(
563 Effect.gen(function* () {
564 yield* worker.enqueue(undefined);
565 yield* worker.drain;
566 }).pipe(Effect.repeat(Schedule.spaced("1 minute")), Effect.asVoid),
567 );
568 yield* forkParked(
569 Stream.runForEach(settingsChanges, (settings) => {
570 const key = autoSettlementSettingsKey(settings);
571 if (key === lastSettlementSettings) {
572 return Effect.void;
573 }
574 lastSettlementSettings = key;
575 return worker.enqueue(undefined);
576 }),
577 );
578 yield* forkParked(Stream.runForEach(mergedPullRequests, (event) => runSweep(event)));
579 yield* forkParked(
580 Stream.runForEach(events, processEvent).pipe(
581 Effect.catchCause((cause) =>
582 Effect.logWarning("Thread settlement event stream failed", { cause }),
583 ),
584 ),
585 );
586 });
587
588 return { start, drain: worker.drain } satisfies ThreadSettlementServiceV2["Service"];
589});
590
591export const layer = Layer.effect(ThreadSettlementServiceV2, make);