@warpgogol/forge 9.4.0 → 9.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/README.md +4 -2
- package/README.uk.md +10 -8
- package/bin/cli.ts +152 -11
- package/dist/bin/cli.js +125 -5
- package/dist/bin/cli.js.map +1 -1
- package/dist/os/flow/dirty-classify.d.ts +11 -1
- package/dist/os/flow/dirty-classify.d.ts.map +1 -1
- package/dist/os/flow/dirty-classify.js +13 -0
- package/dist/os/flow/dirty-classify.js.map +1 -1
- package/dist/os/flow/flow.module.d.ts.map +1 -1
- package/dist/os/flow/flow.module.js +29 -3
- package/dist/os/flow/flow.module.js.map +1 -1
- package/dist/os/flow/handlers/flow-check.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-check.js +9 -9
- package/dist/os/flow/handlers/flow-check.js.map +1 -1
- package/dist/os/flow/handlers/flow-cut.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-cut.js +22 -8
- package/dist/os/flow/handlers/flow-cut.js.map +1 -1
- package/dist/os/flow/handlers/flow-integrate.d.ts +6 -0
- package/dist/os/flow/handlers/flow-integrate.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-integrate.js +155 -44
- package/dist/os/flow/handlers/flow-integrate.js.map +1 -1
- package/dist/os/flow/handlers/flow-open.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-open.js +14 -19
- package/dist/os/flow/handlers/flow-open.js.map +1 -1
- package/dist/os/flow/handlers/flow-peers.d.ts +24 -0
- package/dist/os/flow/handlers/flow-peers.d.ts.map +1 -0
- package/dist/os/flow/handlers/flow-peers.js +99 -0
- package/dist/os/flow/handlers/flow-peers.js.map +1 -0
- package/dist/os/flow/index.d.ts +3 -0
- package/dist/os/flow/index.d.ts.map +1 -1
- package/dist/os/flow/index.js +9 -4
- package/dist/os/flow/index.js.map +1 -1
- package/dist/os/flow/ops-registry.d.ts +33 -0
- package/dist/os/flow/ops-registry.d.ts.map +1 -0
- package/dist/os/flow/ops-registry.js +177 -0
- package/dist/os/flow/ops-registry.js.map +1 -0
- package/dist/os/flow/preflight.d.ts +70 -3
- package/dist/os/flow/preflight.d.ts.map +1 -1
- package/dist/os/flow/preflight.js +545 -49
- package/dist/os/flow/preflight.js.map +1 -1
- package/dist/os/flow/registry.d.ts +2 -2
- package/dist/os/flow/standalone-invoke.d.ts +11 -0
- package/dist/os/flow/standalone-invoke.d.ts.map +1 -0
- package/dist/os/flow/standalone-invoke.js +75 -0
- package/dist/os/flow/standalone-invoke.js.map +1 -0
- package/dist/os/gate-run/detach.d.ts +27 -0
- package/dist/os/gate-run/detach.d.ts.map +1 -0
- package/dist/os/gate-run/detach.js +85 -0
- package/dist/os/gate-run/detach.js.map +1 -0
- package/dist/os/gate-run/gate-run.module.d.ts +3 -0
- package/dist/os/gate-run/gate-run.module.d.ts.map +1 -0
- package/dist/os/gate-run/gate-run.module.js +23 -0
- package/dist/os/gate-run/gate-run.module.js.map +1 -0
- package/dist/os/gate-run/index.d.ts +7 -0
- package/dist/os/gate-run/index.d.ts.map +1 -0
- package/dist/os/gate-run/index.js +5 -0
- package/dist/os/gate-run/index.js.map +1 -0
- package/dist/os/gate-run/record.d.ts +47 -0
- package/dist/os/gate-run/record.d.ts.map +1 -0
- package/dist/os/gate-run/record.js +157 -0
- package/dist/os/gate-run/record.js.map +1 -0
- package/dist/os/gate-run/status.d.ts +41 -0
- package/dist/os/gate-run/status.d.ts.map +1 -0
- package/dist/os/gate-run/status.js +142 -0
- package/dist/os/gate-run/status.js.map +1 -0
- package/dist/os/gate-run/types.d.ts +47 -0
- package/dist/os/gate-run/types.d.ts.map +1 -0
- package/dist/os/gate-run/types.js +24 -0
- package/dist/os/gate-run/types.js.map +1 -0
- package/dist/os/mission/handlers/archive.d.ts.map +1 -1
- package/dist/os/mission/handlers/archive.js +12 -8
- package/dist/os/mission/handlers/archive.js.map +1 -1
- package/dist/os/mission/importer-block.d.ts +19 -0
- package/dist/os/mission/importer-block.d.ts.map +1 -0
- package/dist/os/mission/importer-block.js +124 -0
- package/dist/os/mission/importer-block.js.map +1 -0
- package/dist/os/mission/lockfile.d.ts +17 -0
- package/dist/os/mission/lockfile.d.ts.map +1 -1
- package/dist/os/mission/lockfile.js +38 -0
- package/dist/os/mission/lockfile.js.map +1 -1
- package/dist/os/rfc/evidence-annotation.d.ts +26 -0
- package/dist/os/rfc/evidence-annotation.d.ts.map +1 -0
- package/dist/os/rfc/evidence-annotation.js +52 -0
- package/dist/os/rfc/evidence-annotation.js.map +1 -0
- package/dist/os/rfc/handlers/fixed-inputs.d.ts.map +1 -1
- package/dist/os/rfc/handlers/fixed-inputs.js +7 -1
- package/dist/os/rfc/handlers/fixed-inputs.js.map +1 -1
- package/dist/os/rfc/handlers/implement-stamp.d.ts.map +1 -1
- package/dist/os/rfc/handlers/implement-stamp.js +21 -28
- package/dist/os/rfc/handlers/implement-stamp.js.map +1 -1
- package/dist/os/rfc/handlers/list-create.d.ts.map +1 -1
- package/dist/os/rfc/handlers/list-create.js +25 -3
- package/dist/os/rfc/handlers/list-create.js.map +1 -1
- package/dist/os/rfc/handlers/validate-rules.d.ts.map +1 -1
- package/dist/os/rfc/handlers/validate-rules.js +127 -7
- package/dist/os/rfc/handlers/validate-rules.js.map +1 -1
- package/dist/os/rfc/rfc.module.d.ts.map +1 -1
- package/dist/os/rfc/rfc.module.js +3 -2
- package/dist/os/rfc/rfc.module.js.map +1 -1
- package/dist/os/rfc/types.d.ts +9 -2
- package/dist/os/rfc/types.d.ts.map +1 -1
- package/dist/os/rfc/types.js +2 -2
- package/dist/os/rfc/types.js.map +1 -1
- package/dist/os/system/handlers/system-task-collect.d.ts.map +1 -1
- package/dist/os/system/handlers/system-task-collect.js +11 -5
- package/dist/os/system/handlers/system-task-collect.js.map +1 -1
- package/dist/src/cli-flags.d.ts.map +1 -1
- package/dist/src/cli-flags.js +6 -0
- package/dist/src/cli-flags.js.map +1 -1
- package/dist/src/onboarding/prettierignore.d.ts.map +1 -1
- package/dist/src/onboarding/prettierignore.js +2 -0
- package/dist/src/onboarding/prettierignore.js.map +1 -1
- package/dist/src/types.d.ts +7 -0
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +2 -8
- package/dist/src/types.js.map +1 -1
- package/os/flow/dirty-classify.ts +21 -0
- package/os/flow/flow.module.ts +31 -3
- package/os/flow/handlers/flow-check.ts +17 -18
- package/os/flow/handlers/flow-cut.ts +28 -11
- package/os/flow/handlers/flow-integrate.ts +229 -62
- package/os/flow/handlers/flow-open.ts +24 -31
- package/os/flow/handlers/flow-peers.ts +142 -0
- package/os/flow/index.ts +10 -8
- package/os/flow/ops-registry.ts +194 -0
- package/os/flow/preflight.ts +608 -55
- package/os/flow/standalone-invoke.ts +85 -0
- package/os/flow/tests/dirty-classify.test.ts +139 -4
- package/os/flow/tests/flow-cut.test.ts +21 -0
- package/os/flow/tests/flow-integrate.preflight.test.ts +34 -9
- package/os/flow/tests/flow-integrate.test.ts +433 -17
- package/os/flow/tests/lockfile-induced.test.ts +328 -0
- package/os/flow/tests/ops-registry.test.ts +136 -0
- package/os/gate-run/detach.ts +106 -0
- package/os/gate-run/gate-run.module.ts +25 -0
- package/os/gate-run/index.ts +16 -0
- package/os/gate-run/record.ts +194 -0
- package/os/gate-run/status.ts +168 -0
- package/os/gate-run/tests/gate-run-detach.test.ts +144 -0
- package/os/gate-run/tests/gate-run-record.test.ts +200 -0
- package/os/gate-run/types.ts +73 -0
- package/os/mission/handlers/archive.ts +22 -14
- package/os/mission/importer-block.ts +119 -0
- package/os/mission/lockfile.ts +41 -0
- package/os/rfc/evidence-annotation.ts +61 -0
- package/os/rfc/handlers/fixed-inputs.test.ts +70 -0
- package/os/rfc/handlers/fixed-inputs.ts +11 -1
- package/os/rfc/handlers/implement-stamp.ts +25 -28
- package/os/rfc/handlers/list-create.test.ts +58 -5
- package/os/rfc/handlers/list-create.ts +30 -3
- package/os/rfc/handlers/validate-evidence-shape.test.ts +218 -0
- package/os/rfc/handlers/validate-probe-meta.test.ts +71 -0
- package/os/rfc/handlers/validate-rules.ts +169 -17
- package/os/rfc/handlers/validate-transient-probes.test.ts +222 -0
- package/os/rfc/rfc-0000-template.md +10 -10
- package/os/rfc/rfc.module.ts +3 -2
- package/os/rfc/types.ts +5 -2
- package/os/system/handlers/system-task-collect.ts +11 -5
- package/os/system/tests/system-task-collect.test.ts +16 -0
- package/package.json +17 -1
- package/skills/fo/fo-session-retro/SKILL.md +12 -4
- package/src/cli-flags.ts +7 -0
- package/src/onboarding/prettierignore.ts +2 -0
- package/src/tests/prettierignore-manage.test.ts +11 -0
- package/src/types.ts +9 -8
|
@@ -20,12 +20,12 @@ at cleanup without moving develop again.</purpose>
|
|
|
20
20
|
<item>Task-file preservation runs inside the cleanup branch BEFORE the worktree-teardown hook and only for owner.kind task — a `git clean -fdx` teardown would destroy `.forge/task/` first, and a copy failure refuses cleanup (FLOW-INT-04) so the report is never lost with the worktree (RFC-1509 Q-16).</item>
|
|
21
21
|
</KEY_DECISIONS>
|
|
22
22
|
<CHANGE_SUMMARY>
|
|
23
|
-
<item>RFC-
|
|
24
|
-
<item>RFC-
|
|
25
|
-
<item>RFC-
|
|
26
|
-
<item>
|
|
27
|
-
<item>
|
|
28
|
-
<history>RFC-1487, RFC-1490, RFC-1491, RFC-1504, RFC-1509, RFC-1515, RFC-1528, RFC-1537</history>
|
|
23
|
+
<item>RFC-1545: standalone generated-conflict regeneration in flow.integrate</item>
|
|
24
|
+
<item>RFC-1543: attribute shared-checkout dirt to live ops and expose peers (RFC-1543)</item>
|
|
25
|
+
<item>RFC-1544: attribute mission lockfile churn to owning checkout and auto-resolve foreign importer diffs (RFC-1544)</item>
|
|
26
|
+
<item>ADR-0128: FLOW-INT-02 names rebase stderr tail + porcelain status when no unmerged paths; cap path list at 20 (+N more) (ADR-0128 F-0188)</item>
|
|
27
|
+
<item>ADR-0130: foreign-open-mission restore writes HEAD verbatim — whole diff classified as importer churn, a block splice would leave induced additions to be swept</item>
|
|
28
|
+
<history>RFC-1487, RFC-1490, RFC-1491, RFC-1504, RFC-1509, RFC-1515, RFC-1528, RFC-1531, RFC-1532, RFC-1536, RFC-1537, RFC-1538</history>
|
|
29
29
|
</CHANGE_SUMMARY>
|
|
30
30
|
*/
|
|
31
31
|
|
|
@@ -67,7 +67,7 @@ import {
|
|
|
67
67
|
} from "../locks.ts";
|
|
68
68
|
import {
|
|
69
69
|
appendJournal,
|
|
70
|
-
readJournal,
|
|
70
|
+
readJournal,
|
|
71
71
|
commonGitDir,
|
|
72
72
|
FlowRegistrySchemaError,
|
|
73
73
|
INTEGRATE_LOCK_RELATIVE_PATH,
|
|
@@ -77,6 +77,7 @@ readJournal,
|
|
|
77
77
|
type FlowRegistryEntry,
|
|
78
78
|
} from "../registry.ts";
|
|
79
79
|
import { runFlowScript, type FlowScriptResult } from "../scripts.ts";
|
|
80
|
+
import { standaloneInvoke } from "../standalone-invoke.ts";
|
|
80
81
|
import { preserveTaskFiles } from "../task-files.ts";
|
|
81
82
|
import { flowWorktreePath, primaryWorktree } from "../worktree-path.ts";
|
|
82
83
|
import { pruneReservationsForSession } from "../../rfc/next-id.ts";
|
|
@@ -124,6 +125,10 @@ export interface FlowIntegrateData {
|
|
|
124
125
|
autoCleaned?: string[];
|
|
125
126
|
/** RFC-1531: sha of the --autocommit sweep commit (SWEEP_COMMIT_SUBJECT). */
|
|
126
127
|
autocommitSha?: string;
|
|
128
|
+
/** RFC-1544: foreign-open-mission importer ids restored into the lockfile. */
|
|
129
|
+
restoredImporters?: string[];
|
|
130
|
+
/** RFC-1544: sha of the stale-importer prune commit, when one was written. */
|
|
131
|
+
staleImporterCommitSha?: string;
|
|
127
132
|
/** RFC-1515: holder payload when FLOW-INT-08 refused on a held lock. */
|
|
128
133
|
lock?: LockDiagnostic;
|
|
129
134
|
diagnostics: Diagnostic[];
|
|
@@ -149,6 +154,12 @@ function refuse(
|
|
|
149
154
|
...(partial?.reattachedTo !== undefined ? { reattachedTo: partial.reattachedTo } : {}),
|
|
150
155
|
...(partial?.autoCleaned !== undefined ? { autoCleaned: partial.autoCleaned } : {}),
|
|
151
156
|
...(partial?.autocommitSha !== undefined ? { autocommitSha: partial.autocommitSha } : {}),
|
|
157
|
+
...(partial?.restoredImporters !== undefined
|
|
158
|
+
? { restoredImporters: partial.restoredImporters }
|
|
159
|
+
: {}),
|
|
160
|
+
...(partial?.staleImporterCommitSha !== undefined
|
|
161
|
+
? { staleImporterCommitSha: partial.staleImporterCommitSha }
|
|
162
|
+
: {}),
|
|
152
163
|
...(partial?.lock !== undefined ? { lock: partial.lock } : {}),
|
|
153
164
|
diagnostics: [
|
|
154
165
|
{ ruleId, severity: "error", message, fixHint, ...(diagData ? { data: diagData } : {}) },
|
|
@@ -156,6 +167,58 @@ function refuse(
|
|
|
156
167
|
};
|
|
157
168
|
}
|
|
158
169
|
|
|
170
|
+
/**
|
|
171
|
+
* ADR-0128 (F-0188): FLOW-INT-02 always carries an actionable cause.
|
|
172
|
+
* Unmerged paths are capped at 20 with a (+N more) tail; when the rebase
|
|
173
|
+
* failed without unmerged paths the message names the cause instead —
|
|
174
|
+
* the rebase stderr tail plus the worktree's porcelain status.
|
|
175
|
+
*/
|
|
176
|
+
async function rebaseConflictRefusal(
|
|
177
|
+
branchWorktree: string,
|
|
178
|
+
io: WorkspaceIO,
|
|
179
|
+
rebase: { stderr?: string; stdout?: string },
|
|
180
|
+
paths: string[],
|
|
181
|
+
partial: Partial<FlowIntegrateData>,
|
|
182
|
+
messageSuffix = "",
|
|
183
|
+
): Promise<FlowIntegrateData> {
|
|
184
|
+
const porcelain = await git(branchWorktree, io, ["status", "--porcelain"]);
|
|
185
|
+
const statusPorcelain = porcelain.stdout
|
|
186
|
+
.split("\n")
|
|
187
|
+
.map((l) => l.trimEnd())
|
|
188
|
+
.filter((l) => l.length > 0)
|
|
189
|
+
.slice(0, 20);
|
|
190
|
+
const stderrLines = (rebase.stderr ?? rebase.stdout ?? "")
|
|
191
|
+
.split("\n")
|
|
192
|
+
.map((l) => l.trimEnd())
|
|
193
|
+
.filter((l) => l.length > 0);
|
|
194
|
+
const rebaseStderrTail = stderrLines.slice(-20);
|
|
195
|
+
let message: string;
|
|
196
|
+
let fixHint: string;
|
|
197
|
+
if (paths.length > 0) {
|
|
198
|
+
const shown = paths.slice(0, 20);
|
|
199
|
+
const more = paths.length - shown.length;
|
|
200
|
+
message = `rebase onto develop conflicts in: ${shown.join(", ")}${more > 0 ? ` (+${more} more)` : ""}${messageSuffix}`;
|
|
201
|
+
fixHint =
|
|
202
|
+
"resolve the listed conflicts in the session worktree, commit, and re-run flow.integrate";
|
|
203
|
+
} else {
|
|
204
|
+
const cause =
|
|
205
|
+
rebaseStderrTail.length > 0
|
|
206
|
+
? `rebase stderr tail: ${rebaseStderrTail.join(" | ")}`
|
|
207
|
+
: "no unmerged paths and empty rebase output";
|
|
208
|
+
const dirt =
|
|
209
|
+
statusPorcelain.length > 0
|
|
210
|
+
? `worktree status: ${statusPorcelain.join(" | ")}`
|
|
211
|
+
: "worktree status: clean";
|
|
212
|
+
message = `rebase onto develop failed without unmerged paths — ${cause} — ${dirt}${messageSuffix}`;
|
|
213
|
+
fixHint = "clean the listed worktree state, then re-run flow.integrate";
|
|
214
|
+
}
|
|
215
|
+
return refuse("FLOW-INT-02", message, fixHint, partial, {
|
|
216
|
+
conflictedPaths: paths,
|
|
217
|
+
rebaseStderrTail,
|
|
218
|
+
statusPorcelain,
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
|
|
159
222
|
async function resolveEntry(
|
|
160
223
|
repoRoot: string,
|
|
161
224
|
io: WorkspaceIO,
|
|
@@ -179,7 +242,13 @@ async function cleanupIntegrated(
|
|
|
179
242
|
journalBase?: string,
|
|
180
243
|
journalToleratedDirt?: Array<{ path: string; class: string }>,
|
|
181
244
|
journalAutoResolved?: string[],
|
|
182
|
-
journalRemediation?: {
|
|
245
|
+
journalRemediation?: {
|
|
246
|
+
reattachedTo?: string;
|
|
247
|
+
autoCleaned?: string[];
|
|
248
|
+
autocommitSha?: string;
|
|
249
|
+
restoredImporters?: string[];
|
|
250
|
+
staleImporterCommitSha?: string;
|
|
251
|
+
},
|
|
183
252
|
journalGateReport?: string,
|
|
184
253
|
): Promise<{ cleanedUp: boolean; diagnostics: Diagnostic[]; gate: FlowScriptResult | null }> {
|
|
185
254
|
const branchExistsNow = await branchExists(primary, io, entry.name);
|
|
@@ -301,13 +370,19 @@ async function cleanupIntegrated(
|
|
|
301
370
|
...(journalRemediation?.reattachedTo !== undefined
|
|
302
371
|
? { reattachedTo: journalRemediation.reattachedTo }
|
|
303
372
|
: {}),
|
|
304
|
-
...(journalRemediation?.autoCleaned !== undefined &&
|
|
305
|
-
journalRemediation.autoCleaned.length > 0
|
|
373
|
+
...(journalRemediation?.autoCleaned !== undefined && journalRemediation.autoCleaned.length > 0
|
|
306
374
|
? { autoCleaned: journalRemediation.autoCleaned }
|
|
307
375
|
: {}),
|
|
308
376
|
...(journalRemediation?.autocommitSha !== undefined
|
|
309
377
|
? { autocommitSha: journalRemediation.autocommitSha }
|
|
310
378
|
: {}),
|
|
379
|
+
...(journalRemediation?.restoredImporters !== undefined &&
|
|
380
|
+
journalRemediation.restoredImporters.length > 0
|
|
381
|
+
? { restoredImporters: journalRemediation.restoredImporters }
|
|
382
|
+
: {}),
|
|
383
|
+
...(journalRemediation?.staleImporterCommitSha !== undefined
|
|
384
|
+
? { staleImporterCommitSha: journalRemediation.staleImporterCommitSha }
|
|
385
|
+
: {}),
|
|
311
386
|
...(journalGateReport !== undefined ? { gateReport: journalGateReport } : {}),
|
|
312
387
|
});
|
|
313
388
|
} catch (error) {
|
|
@@ -348,8 +423,9 @@ export async function integrateFlowBranch(
|
|
|
348
423
|
try {
|
|
349
424
|
const common = await commonGitDir(io, repoRoot);
|
|
350
425
|
const sha =
|
|
351
|
-
(
|
|
352
|
-
|
|
426
|
+
(
|
|
427
|
+
await git(repoRoot, io, ["rev-parse", "--verify", "-q", `refs/heads/${data.branch}`])
|
|
428
|
+
).stdout.trim() || "unknown";
|
|
353
429
|
await appendJournal(io, common, {
|
|
354
430
|
event: "integrate-refusal",
|
|
355
431
|
branch: data.branch,
|
|
@@ -393,6 +469,8 @@ async function integrateFlowBranchAttempt(
|
|
|
393
469
|
autoClean?: boolean;
|
|
394
470
|
/** RFC-1531: sweep remaining dirty entries into a fixed-subject commit. */
|
|
395
471
|
autocommit?: boolean;
|
|
472
|
+
/** RFC-1543: seconds to wait for live foreign claim-holders on primary (default 600, 0 = fail-fast). */
|
|
473
|
+
waitForeignSeconds?: number;
|
|
396
474
|
},
|
|
397
475
|
): Promise<FlowIntegrateData> {
|
|
398
476
|
const now = opts.now ?? new Date();
|
|
@@ -502,8 +580,11 @@ async function integrateFlowBranchAttempt(
|
|
|
502
580
|
{
|
|
503
581
|
ruleId: "FLOW-07",
|
|
504
582
|
severity: "error",
|
|
505
|
-
message:
|
|
506
|
-
|
|
583
|
+
message:
|
|
584
|
+
`registry entry for ${branch} names worktree ${wtPath}, which does not exist (vanished)` +
|
|
585
|
+
(wouldReattach !== undefined
|
|
586
|
+
? ` — --reattach would recreate it at ${wouldReattach}`
|
|
587
|
+
: ""),
|
|
507
588
|
fixHint:
|
|
508
589
|
"re-run with --reattach to recreate the worktree at its recorded path, or run flow.discard to drop the registry entry and force-delete the branch",
|
|
509
590
|
data: { vanished: true, ...(wouldReattach !== undefined ? { wouldReattach } : {}) },
|
|
@@ -630,8 +711,7 @@ async function integrateFlowBranchAttempt(
|
|
|
630
711
|
// worktree with the branch — a foreign tree squats there.
|
|
631
712
|
const occupied =
|
|
632
713
|
live === null && liveEntry.worktree !== null && (await io.exists(liveEntry.worktree));
|
|
633
|
-
const vanished =
|
|
634
|
-
!occupied && (branchWorktree === null || !(await io.exists(branchWorktree)));
|
|
714
|
+
const vanished = !occupied && (branchWorktree === null || !(await io.exists(branchWorktree)));
|
|
635
715
|
if (opts.reattach === true && occupied) {
|
|
636
716
|
return refuse(
|
|
637
717
|
"FLOW-INT-17",
|
|
@@ -682,6 +762,68 @@ async function integrateFlowBranchAttempt(
|
|
|
682
762
|
opts.onProgress?.(`tolerated forge-local state: ${dirty.toleratedState.join(", ")}`);
|
|
683
763
|
}
|
|
684
764
|
|
|
765
|
+
// RFC-1544 AC-2: referent-aware importer-prune resolution — before any
|
|
766
|
+
// remediation, so --autocommit can never sweep a foreign mission's live
|
|
767
|
+
// importer into a commit. `foreign-open-mission` restores the committed
|
|
768
|
+
// importer subtree (never a whole-file checkout — sibling lockfile diffs
|
|
769
|
+
// keep their own classification); `importer-prune-stale` accepts the
|
|
770
|
+
// prune as cleanup and commits it so dead residue stops churning.
|
|
771
|
+
let restoredImporters: string[] | undefined;
|
|
772
|
+
let staleImporterCommitSha: string | undefined;
|
|
773
|
+
if (dirty.entries.some((line) => line.slice(3).trim() === "pnpm-lock.yaml")) {
|
|
774
|
+
const { classifyDirt, resolveImporterReferents } = await import("../preflight.ts");
|
|
775
|
+
const pruneVerdict = await classifyDirt(
|
|
776
|
+
branchWorktree,
|
|
777
|
+
io,
|
|
778
|
+
dirty.entries,
|
|
779
|
+
{ runGit: git },
|
|
780
|
+
[],
|
|
781
|
+
(ids) => resolveImporterReferents(branchWorktree, io, ids),
|
|
782
|
+
);
|
|
783
|
+
const lockTolerated = pruneVerdict.tolerated.find((t) => t.path === "pnpm-lock.yaml");
|
|
784
|
+
if (
|
|
785
|
+
lockTolerated?.class === "foreign-open-mission" &&
|
|
786
|
+
lockTolerated.missionIds !== undefined
|
|
787
|
+
) {
|
|
788
|
+
// ADR-0130: write HEAD verbatim — the diff already classified as
|
|
789
|
+
// importer churn end-to-end (strict prune, or prune + induced
|
|
790
|
+
// `optional: true`/`packages:`/`snapshots:` additions via the
|
|
791
|
+
// extended classifier), so the committed file is the canonical
|
|
792
|
+
// state and a whole-file restore reverts exactly that churn. A
|
|
793
|
+
// block splice would leave the induced additions behind, which
|
|
794
|
+
// is what used to land in the sweep commit.
|
|
795
|
+
const head = await git(branchWorktree, io, ["show", "HEAD:pnpm-lock.yaml"]);
|
|
796
|
+
if (head.exitCode === 0) {
|
|
797
|
+
await io.writeFile(join(branchWorktree, "pnpm-lock.yaml"), head.stdout);
|
|
798
|
+
restoredImporters = lockTolerated.missionIds;
|
|
799
|
+
opts.onProgress?.(
|
|
800
|
+
`restored foreign mission importer(s): ${lockTolerated.missionIds.map((id) => `missions/${id}/workpiece`).join(", ")}`,
|
|
801
|
+
);
|
|
802
|
+
dirty = await statusDirty(branchWorktree, io);
|
|
803
|
+
}
|
|
804
|
+
} else if (lockTolerated?.class === "importer-prune-stale") {
|
|
805
|
+
const add = await git(branchWorktree, io, ["add", "pnpm-lock.yaml"]);
|
|
806
|
+
const commit =
|
|
807
|
+
add.exitCode === 0
|
|
808
|
+
? await gitCommit(
|
|
809
|
+
branchWorktree,
|
|
810
|
+
io,
|
|
811
|
+
["commit", "-m", "chore(flow): prune stale mission importer"],
|
|
812
|
+
"integrate",
|
|
813
|
+
)
|
|
814
|
+
: add;
|
|
815
|
+
if (commit.exitCode === 0) {
|
|
816
|
+
staleImporterCommitSha = (
|
|
817
|
+
await git(branchWorktree, io, ["rev-parse", "HEAD"])
|
|
818
|
+
).stdout.trim();
|
|
819
|
+
opts.onProgress?.(
|
|
820
|
+
`committed stale importer prune ${staleImporterCommitSha.slice(0, 9)} (${(lockTolerated.missionIds ?? []).map((id) => `missions/${id}/workpiece`).join(", ")})`,
|
|
821
|
+
);
|
|
822
|
+
dirty = await statusDirty(branchWorktree, io);
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
|
|
685
827
|
// RFC-1531 remediation flags — before the dirty checks: --auto-clean
|
|
686
828
|
// deletes ONLY disposable-class paths (closed allowlist — a work-class
|
|
687
829
|
// member in the set deletes nothing and still refuses FLOW-INT-01, and
|
|
@@ -698,8 +840,7 @@ async function integrateFlowBranchAttempt(
|
|
|
698
840
|
// — AC-4 names importer-prune a refusal class: restoring/committing a
|
|
699
841
|
// lockfile is a content decision, never a cleanup step.
|
|
700
842
|
const blocker = classified.filter(
|
|
701
|
-
(c) =>
|
|
702
|
-
c.class !== "disposable" && !AUTO_CLEAN_PASS_CLASSES.includes(c.class),
|
|
843
|
+
(c) => c.class !== "disposable" && !AUTO_CLEAN_PASS_CLASSES.includes(c.class),
|
|
703
844
|
);
|
|
704
845
|
if (opts.autoClean === true) {
|
|
705
846
|
// A blocker refuses only when nothing downstream will commit it:
|
|
@@ -752,11 +893,12 @@ async function integrateFlowBranchAttempt(
|
|
|
752
893
|
{ branch, developBefore, autoCleaned },
|
|
753
894
|
);
|
|
754
895
|
}
|
|
755
|
-
const commit = await gitCommit(
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
SWEEP_COMMIT_SUBJECT,
|
|
759
|
-
|
|
896
|
+
const commit = await gitCommit(
|
|
897
|
+
branchWorktree,
|
|
898
|
+
io,
|
|
899
|
+
["commit", "-m", SWEEP_COMMIT_SUBJECT],
|
|
900
|
+
"integrate",
|
|
901
|
+
);
|
|
760
902
|
if (commit.exitCode !== 0) {
|
|
761
903
|
return refuse(
|
|
762
904
|
"FLOW-INT-17",
|
|
@@ -765,9 +907,7 @@ async function integrateFlowBranchAttempt(
|
|
|
765
907
|
{ branch, developBefore, autoCleaned },
|
|
766
908
|
);
|
|
767
909
|
}
|
|
768
|
-
autocommitSha = (
|
|
769
|
-
await git(branchWorktree, io, ["rev-parse", "HEAD"])
|
|
770
|
-
).stdout.trim();
|
|
910
|
+
autocommitSha = (await git(branchWorktree, io, ["rev-parse", "HEAD"])).stdout.trim();
|
|
771
911
|
opts.onProgress?.(
|
|
772
912
|
`autocommit: swept ${paths.length} path(s) into ${autocommitSha.slice(0, 9)} (${SWEEP_COMMIT_SUBJECT})`,
|
|
773
913
|
);
|
|
@@ -792,6 +932,8 @@ async function integrateFlowBranchAttempt(
|
|
|
792
932
|
worktreeDirty: dirty,
|
|
793
933
|
invoke: opts.invoke,
|
|
794
934
|
commandRegistry: opts.commandRegistry,
|
|
935
|
+
waitForeignSeconds: opts.waitForeignSeconds,
|
|
936
|
+
onProgress: opts.onProgress,
|
|
795
937
|
});
|
|
796
938
|
toleratedDirt = preflight.tolerated;
|
|
797
939
|
for (const skipped of preflight.skipped) {
|
|
@@ -817,6 +959,8 @@ async function integrateFlowBranchAttempt(
|
|
|
817
959
|
reattachedTo,
|
|
818
960
|
autoCleaned,
|
|
819
961
|
autocommitSha,
|
|
962
|
+
restoredImporters,
|
|
963
|
+
staleImporterCommitSha,
|
|
820
964
|
},
|
|
821
965
|
preflight.refuse.data,
|
|
822
966
|
);
|
|
@@ -854,6 +998,8 @@ async function integrateFlowBranchAttempt(
|
|
|
854
998
|
reattachedTo,
|
|
855
999
|
autoCleaned,
|
|
856
1000
|
autocommitSha,
|
|
1001
|
+
restoredImporters,
|
|
1002
|
+
staleImporterCommitSha,
|
|
857
1003
|
},
|
|
858
1004
|
{
|
|
859
1005
|
entries,
|
|
@@ -901,40 +1047,48 @@ async function integrateFlowBranchAttempt(
|
|
|
901
1047
|
let rebase = await git(branchWorktree, io, ["rebase", "develop"]);
|
|
902
1048
|
let guard = 0;
|
|
903
1049
|
while (rebase.exitCode !== 0 && guard++ < 8) {
|
|
904
|
-
const conflicts = await git(branchWorktree, io, [
|
|
905
|
-
"diff",
|
|
906
|
-
"--name-only",
|
|
907
|
-
"--diff-filter=U",
|
|
908
|
-
]);
|
|
1050
|
+
const conflicts = await git(branchWorktree, io, ["diff", "--name-only", "--diff-filter=U"]);
|
|
909
1051
|
const paths = conflicts.stdout
|
|
910
1052
|
.split("\n")
|
|
911
1053
|
.map((l) => l.trim())
|
|
912
1054
|
.filter((l) => l.length > 0);
|
|
913
1055
|
const { classifyRebaseConflicts } = await import("../preflight.ts");
|
|
914
1056
|
const verdict = await classifyRebaseConflicts(branchWorktree, io, paths);
|
|
1057
|
+
// RFC-1545 AC-2: without a kernel invoke port the standalone adapter
|
|
1058
|
+
// spawns the allowlisted owner commands in the worktree — the
|
|
1059
|
+
// resolution contract is identical either way.
|
|
1060
|
+
const invoker =
|
|
1061
|
+
opts.invoke ??
|
|
1062
|
+
standaloneInvoke(
|
|
1063
|
+
io,
|
|
1064
|
+
branchWorktree,
|
|
1065
|
+
verdict.owners.map((o) => o.command),
|
|
1066
|
+
);
|
|
915
1067
|
const resolvable =
|
|
916
1068
|
paths.length > 0 &&
|
|
917
1069
|
verdict.nonGenerated.length === 0 &&
|
|
918
|
-
verdict.owners.length === paths.length
|
|
919
|
-
opts.invoke !== undefined;
|
|
1070
|
+
verdict.owners.length === paths.length;
|
|
920
1071
|
if (!resolvable) {
|
|
921
1072
|
await git(branchWorktree, io, ["rebase", "--abort"]);
|
|
922
|
-
return
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
? " — generated conflicts present but no invoke port is available to regenerate them"
|
|
928
|
-
: " — mixed generated/non-generated conflict set"
|
|
929
|
-
: ""),
|
|
930
|
-
"resolve the rebase inside the session worktree, commit, and re-run flow.integrate",
|
|
1073
|
+
return rebaseConflictRefusal(
|
|
1074
|
+
branchWorktree,
|
|
1075
|
+
io,
|
|
1076
|
+
rebase,
|
|
1077
|
+
paths,
|
|
931
1078
|
{ branch, developBefore },
|
|
1079
|
+
verdict.owners.length > 0 ? " — mixed generated/non-generated conflict set" : "",
|
|
932
1080
|
);
|
|
933
1081
|
}
|
|
934
1082
|
let failed = false;
|
|
935
1083
|
for (const o of verdict.owners) {
|
|
936
|
-
|
|
937
|
-
|
|
1084
|
+
// `git checkout --theirs` is blocked by the agent-session git
|
|
1085
|
+
// wrapper — materialize the stage-3 (theirs) blob through the
|
|
1086
|
+
// read-only `git show` + io write instead (RFC-1545).
|
|
1087
|
+
const theirs = await git(branchWorktree, io, ["show", `:3:${o.path}`]);
|
|
1088
|
+
if (theirs.exitCode === 0) {
|
|
1089
|
+
await io.writeFile(join(branchWorktree, o.path), theirs.stdout);
|
|
1090
|
+
}
|
|
1091
|
+
const regen = await invoker(o.command, o.flags);
|
|
938
1092
|
if (regen.ok === false || (regen.exitCode !== undefined && regen.exitCode !== 0)) {
|
|
939
1093
|
await git(branchWorktree, io, ["rebase", "--abort"]);
|
|
940
1094
|
failed = true;
|
|
@@ -945,35 +1099,34 @@ async function integrateFlowBranchAttempt(
|
|
|
945
1099
|
{ branch, developBefore },
|
|
946
1100
|
);
|
|
947
1101
|
}
|
|
1102
|
+
// RFC-1545 AC-4: a successful generator that left conflict markers
|
|
1103
|
+
// behind must not be committed — escalate like a failure.
|
|
1104
|
+
const regenerated = await io.readFile(join(branchWorktree, o.path));
|
|
1105
|
+
if (/^(<{7}|={7}|>{7})/m.test(regenerated)) {
|
|
1106
|
+
await git(branchWorktree, io, ["rebase", "--abort"]);
|
|
1107
|
+
failed = true;
|
|
1108
|
+
return refuse(
|
|
1109
|
+
"FLOW-INT-02",
|
|
1110
|
+
`auto-resolve of generated conflict ${o.path} failed: ${o.command} left conflict markers in the regenerated output`,
|
|
1111
|
+
"resolve the rebase inside the session worktree manually, commit, and re-run flow.integrate",
|
|
1112
|
+
{ branch, developBefore },
|
|
1113
|
+
);
|
|
1114
|
+
}
|
|
948
1115
|
await git(branchWorktree, io, ["add", "--", o.path]);
|
|
949
1116
|
opts.onProgress?.(`conflict: ${o.path} — regenerated via ${o.command}`);
|
|
950
1117
|
autoResolved.push(o.path);
|
|
951
1118
|
}
|
|
952
1119
|
if (failed) break;
|
|
953
|
-
rebase = await git(branchWorktree, io, [
|
|
954
|
-
"-c",
|
|
955
|
-
"core.editor=true",
|
|
956
|
-
"rebase",
|
|
957
|
-
"--continue",
|
|
958
|
-
]);
|
|
1120
|
+
rebase = await git(branchWorktree, io, ["-c", "core.editor=true", "rebase", "--continue"]);
|
|
959
1121
|
}
|
|
960
1122
|
if (rebase.exitCode !== 0) {
|
|
961
|
-
const conflicts = await git(branchWorktree, io, [
|
|
962
|
-
"diff",
|
|
963
|
-
"--name-only",
|
|
964
|
-
"--diff-filter=U",
|
|
965
|
-
]);
|
|
1123
|
+
const conflicts = await git(branchWorktree, io, ["diff", "--name-only", "--diff-filter=U"]);
|
|
966
1124
|
const paths = conflicts.stdout
|
|
967
1125
|
.split("\n")
|
|
968
1126
|
.map((l) => l.trim())
|
|
969
1127
|
.filter((l) => l.length > 0);
|
|
970
1128
|
await git(branchWorktree, io, ["rebase", "--abort"]);
|
|
971
|
-
return
|
|
972
|
-
"FLOW-INT-02",
|
|
973
|
-
`rebase onto develop conflicts in: ${paths.join(", ") || "(unknown paths)"}`,
|
|
974
|
-
"resolve the rebase inside the session worktree, commit, and re-run flow.integrate",
|
|
975
|
-
{ branch, developBefore },
|
|
976
|
-
);
|
|
1129
|
+
return rebaseConflictRefusal(branchWorktree, io, rebase, paths, { branch, developBefore });
|
|
977
1130
|
}
|
|
978
1131
|
}
|
|
979
1132
|
|
|
@@ -983,7 +1136,10 @@ async function integrateFlowBranchAttempt(
|
|
|
983
1136
|
const { resolveGateEngine } = await import("../gate-engine.ts");
|
|
984
1137
|
const engine = await resolveGateEngine(branchWorktree, primary, io);
|
|
985
1138
|
const warnings: Diagnostic[] = [];
|
|
986
|
-
if (
|
|
1139
|
+
if (
|
|
1140
|
+
engine.source === "primary" &&
|
|
1141
|
+
(await io.exists(join(primary, "hooks", "integration-gate.sh")))
|
|
1142
|
+
) {
|
|
987
1143
|
warnings.push({
|
|
988
1144
|
ruleId: "FLOW-INT-16",
|
|
989
1145
|
severity: "warning",
|
|
@@ -1083,6 +1239,10 @@ async function integrateFlowBranchAttempt(
|
|
|
1083
1239
|
...(reattachedTo !== undefined ? { reattachedTo } : {}),
|
|
1084
1240
|
...(autoCleaned !== undefined && autoCleaned.length > 0 ? { autoCleaned } : {}),
|
|
1085
1241
|
...(autocommitSha !== undefined ? { autocommitSha } : {}),
|
|
1242
|
+
...(restoredImporters !== undefined && restoredImporters.length > 0
|
|
1243
|
+
? { restoredImporters }
|
|
1244
|
+
: {}),
|
|
1245
|
+
...(staleImporterCommitSha !== undefined ? { staleImporterCommitSha } : {}),
|
|
1086
1246
|
gateEngine: engine.source,
|
|
1087
1247
|
diagnostics: warnings,
|
|
1088
1248
|
};
|
|
@@ -1162,6 +1322,8 @@ async function integrateFlowBranchAttempt(
|
|
|
1162
1322
|
reattachedTo: inner.reattachedTo,
|
|
1163
1323
|
autoCleaned: inner.autoCleaned,
|
|
1164
1324
|
autocommitSha: inner.autocommitSha,
|
|
1325
|
+
restoredImporters: inner.restoredImporters,
|
|
1326
|
+
staleImporterCommitSha: inner.staleImporterCommitSha,
|
|
1165
1327
|
},
|
|
1166
1328
|
inner.gate?.reportPath ?? undefined,
|
|
1167
1329
|
);
|
|
@@ -1197,6 +1359,11 @@ export async function runFlowIntegrate(
|
|
|
1197
1359
|
reattach: input.flags["reattach"] === true,
|
|
1198
1360
|
autoClean: input.flags["auto-clean"] === true,
|
|
1199
1361
|
autocommit: input.flags["autocommit"] === true,
|
|
1362
|
+
waitForeignSeconds:
|
|
1363
|
+
typeof input.flags["wait-foreign"] === "string" ||
|
|
1364
|
+
typeof input.flags["wait-foreign"] === "number"
|
|
1365
|
+
? Number(input.flags["wait-foreign"])
|
|
1366
|
+
: undefined,
|
|
1200
1367
|
});
|
|
1201
1368
|
|
|
1202
1369
|
const refused = data.diagnostics.find((d) => d.severity === "error");
|
|
@@ -18,12 +18,11 @@ hooks/worktree-setup.sh.</purpose>
|
|
|
18
18
|
<item>A failed setup script is reported, never rolled back — the worktree and registry entry stay, and the command exits 1 (DNA-106).</item>
|
|
19
19
|
</KEY_DECISIONS>
|
|
20
20
|
<CHANGE_SUMMARY>
|
|
21
|
-
<item>RFC-1490: step 6 — flow.fix + fix-mode cut (patch-only, rebase on moved main, gate target main, trailing back-merge)</item>
|
|
22
|
-
<item>RFC-1490: independent-review pass — lock-held planning, fix-branch verification, spec-shaped data, coverage</item>
|
|
23
21
|
<item>ADR-0124: enable git rerere in flow-managed repositories</item>
|
|
24
22
|
<item>RFC-1536: owning-checkout routing, FLOW-OPEN-01 dirty-primary warning, shared governance-id allocation (RFC+ADR)</item>
|
|
25
23
|
<item>RFC-1536: evidence — routing/warning tests, FLOW-OPEN-10 validation renumber, owning-worktree doc rule, frictions F-0091/F-0096/F-0106/F-0119 addressed</item>
|
|
26
24
|
<item>RFC-1533: pending-branch summary + primaryMutations on the result; FLOW-OPEN-02 freed for the registry-unreadable warning (refusal renumbered to FLOW-OPEN-11)</item>
|
|
25
|
+
<item>ADR-0129: F-0186/F-0187 — FLOW-INT-03 names paths + three-way remedy, FLOW-OPEN-01 same hint, forge CLI kernel-command hint</item>
|
|
27
26
|
<history>RFC-1487, RFC-1490</history>
|
|
28
27
|
</CHANGE_SUMMARY>
|
|
29
28
|
*/
|
|
@@ -47,6 +46,7 @@ import {
|
|
|
47
46
|
topLevel,
|
|
48
47
|
} from "../git.ts";
|
|
49
48
|
import { formatFlowBranch, parseFlowBranch, type FlowBranchKind } from "../branch-name.ts";
|
|
49
|
+
import { FOREIGN_PRIMARY_DIRT_HINT } from "../dirty-classify.ts";
|
|
50
50
|
import { LockTimeoutError } from "../locks.ts";
|
|
51
51
|
import { detectRepoKind } from "../repo-kind.ts";
|
|
52
52
|
import {
|
|
@@ -134,10 +134,7 @@ function refuse(ruleId: string, message: string, fixHint: string): FlowOpenData
|
|
|
134
134
|
const SLUG_RE = /^[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
135
135
|
|
|
136
136
|
/** Highest NN for `date` among candidate auto branch names; returns max+1. */
|
|
137
|
-
export function nextFlowSeq(
|
|
138
|
-
names: string[],
|
|
139
|
-
yymmdd: string,
|
|
140
|
-
): number {
|
|
137
|
+
export function nextFlowSeq(names: string[], yymmdd: string): number {
|
|
141
138
|
let max = 0;
|
|
142
139
|
for (const raw of names) {
|
|
143
140
|
const parsed = parseFlowBranch(raw);
|
|
@@ -157,7 +154,11 @@ export async function openFlowBranch(
|
|
|
157
154
|
): Promise<FlowOpenData> {
|
|
158
155
|
// Flags — FLOW-OPEN-10/05 first, before any git fact is consulted.
|
|
159
156
|
if (opts.kind !== "session" && opts.kind !== "task") {
|
|
160
|
-
return refuse(
|
|
157
|
+
return refuse(
|
|
158
|
+
"FLOW-OPEN-10",
|
|
159
|
+
`invalid --kind '${opts.kind}'`,
|
|
160
|
+
"use --kind session or --kind task",
|
|
161
|
+
);
|
|
161
162
|
}
|
|
162
163
|
if (opts.kind === "task" && (opts.owner === null || opts.owner === "")) {
|
|
163
164
|
return refuse(
|
|
@@ -249,10 +250,11 @@ export async function openFlowBranchCore(
|
|
|
249
250
|
severity: "warning",
|
|
250
251
|
message:
|
|
251
252
|
`primary checkout carries ${primaryMutations.length} tracked mutation(s): ${shown.join(", ")}` +
|
|
252
|
-
(primaryMutations.length > shown.length
|
|
253
|
+
(primaryMutations.length > shown.length
|
|
254
|
+
? ` (+${primaryMutations.length - shown.length} more)`
|
|
255
|
+
: "") +
|
|
253
256
|
" — they are NOT swept into the worktree; commit or move them first",
|
|
254
|
-
fixHint:
|
|
255
|
-
"commit them in the primary checkout or move them into the session worktree before integrating",
|
|
257
|
+
fixHint: FOREIGN_PRIMARY_DIRT_HINT,
|
|
256
258
|
});
|
|
257
259
|
}
|
|
258
260
|
}
|
|
@@ -326,8 +328,7 @@ export async function openFlowBranchCore(
|
|
|
326
328
|
{
|
|
327
329
|
ruleId: "FLOW-OPEN-02" as const,
|
|
328
330
|
severity: "warning" as const,
|
|
329
|
-
message:
|
|
330
|
-
"flow registry absent or unreadable — pending-branch summary unavailable",
|
|
331
|
+
message: "flow registry absent or unreadable — pending-branch summary unavailable",
|
|
331
332
|
fixHint: `run flow.check for registry diagnostics; repair or remove ${registryPath(common)}`,
|
|
332
333
|
},
|
|
333
334
|
],
|
|
@@ -339,9 +340,7 @@ export async function openFlowBranchCore(
|
|
|
339
340
|
if (!(await io.exists(registryPath(common)))) return unreadable;
|
|
340
341
|
const status = await collectFlowStatus(repoRoot, io, { now });
|
|
341
342
|
if (status.registryError) throw status.registryError;
|
|
342
|
-
const siblings = status.data.branches.filter(
|
|
343
|
-
(b) => b.registered && b.name !== excludeName,
|
|
344
|
-
);
|
|
343
|
+
const siblings = status.data.branches.filter((b) => b.registered && b.name !== excludeName);
|
|
345
344
|
return {
|
|
346
345
|
pending: {
|
|
347
346
|
total: siblings.length,
|
|
@@ -360,7 +359,12 @@ export async function openFlowBranchCore(
|
|
|
360
359
|
};
|
|
361
360
|
|
|
362
361
|
for (let attempt = 1; attempt <= OPEN_MAX_ATTEMPTS; attempt++) {
|
|
363
|
-
const name = formatFlowBranch({
|
|
362
|
+
const name = formatFlowBranch({
|
|
363
|
+
kind: opts.kind as FlowBranchKind,
|
|
364
|
+
date: now,
|
|
365
|
+
seq,
|
|
366
|
+
slug: opts.slug,
|
|
367
|
+
});
|
|
364
368
|
// candidates gains each tried name so a collision retry picks the next NN.
|
|
365
369
|
const worktree = flowWorktreePath(primary, name);
|
|
366
370
|
|
|
@@ -388,16 +392,10 @@ export async function openFlowBranchCore(
|
|
|
388
392
|
};
|
|
389
393
|
}
|
|
390
394
|
|
|
391
|
-
const add = await git(primary, io, [
|
|
392
|
-
"worktree",
|
|
393
|
-
"add",
|
|
394
|
-
"-b",
|
|
395
|
-
name,
|
|
396
|
-
worktree,
|
|
397
|
-
baseRef,
|
|
398
|
-
]);
|
|
395
|
+
const add = await git(primary, io, ["worktree", "add", "-b", name, worktree, baseRef]);
|
|
399
396
|
if (add.exitCode !== 0) {
|
|
400
|
-
const collision =
|
|
397
|
+
const collision =
|
|
398
|
+
add.stderr.includes("already exists") || add.stderr.includes("is already used");
|
|
401
399
|
if (collision) {
|
|
402
400
|
if (attempt < OPEN_MAX_ATTEMPTS) {
|
|
403
401
|
seq = nextFlowSeq([...candidates, name], today);
|
|
@@ -490,12 +488,7 @@ export async function openFlowBranchCore(
|
|
|
490
488
|
setup,
|
|
491
489
|
primaryMutations,
|
|
492
490
|
pending: pending.pending,
|
|
493
|
-
diagnostics: [
|
|
494
|
-
...dirtyPrimaryDiags,
|
|
495
|
-
...pending.diags,
|
|
496
|
-
...rerereDiags,
|
|
497
|
-
...setupDiag,
|
|
498
|
-
],
|
|
491
|
+
diagnostics: [...dirtyPrimaryDiags, ...pending.diags, ...rerereDiags, ...setupDiag],
|
|
499
492
|
};
|
|
500
493
|
}
|
|
501
494
|
return refuse(
|