@warpgogol/forge 9.4.0 → 9.4.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/CHANGELOG.md +15 -0
- package/README.md +4 -2
- package/README.uk.md +10 -8
- package/dist/os/flow/dirty-classify.d.ts +4 -1
- package/dist/os/flow/dirty-classify.d.ts.map +1 -1
- package/dist/os/flow/dirty-classify.js +2 -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 +27 -2
- package/dist/os/flow/flow.module.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 +118 -40
- package/dist/os/flow/handlers/flow-integrate.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 +2 -0
- package/dist/os/flow/index.d.ts.map +1 -1
- package/dist/os/flow/index.js +4 -1
- 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 +46 -3
- package/dist/os/flow/preflight.d.ts.map +1 -1
- package/dist/os/flow/preflight.js +196 -44
- package/dist/os/flow/preflight.js.map +1 -1
- 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/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/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/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/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/os/flow/dirty-classify.ts +8 -0
- package/os/flow/flow.module.ts +29 -2
- package/os/flow/handlers/flow-cut.ts +28 -11
- package/os/flow/handlers/flow-integrate.ts +177 -50
- package/os/flow/handlers/flow-peers.ts +142 -0
- package/os/flow/index.ts +5 -1
- package/os/flow/ops-registry.ts +194 -0
- package/os/flow/preflight.ts +262 -51
- 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 +8 -4
- package/os/flow/tests/flow-integrate.test.ts +366 -16
- package/os/flow/tests/ops-registry.test.ts +136 -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/handlers/list-create.test.ts +44 -0
- package/os/rfc/handlers/list-create.ts +30 -3
- 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 +1 -1
- package/skills/fo/fo-session-retro/SKILL.md +9 -3
- package/src/onboarding/prettierignore.ts +2 -0
- package/src/tests/prettierignore-manage.test.ts +11 -0
|
@@ -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-1528: close review findings — manifest-union command inventory for regen/preflight</item>
|
|
24
|
-
<item>RFC-1536: owning-checkout routing, FLOW-OPEN-01 dirty-primary warning, shared governance-id allocation (RFC+ADR)</item>
|
|
25
|
-
<item>RFC-1538: revalidate integration preconditions post-lock and reuse the session engine</item>
|
|
26
23
|
<item>RFC-1531: remediation flags --reattach/--auto-clean/--autocommit on the classified dirty set, FLOW-INT-17 remediation-failure refusals, classified FLOW-INT-01 data</item>
|
|
27
24
|
<item>RFC-1532: persist integration-gate reports per attempt and link them from the flow journal</item>
|
|
28
|
-
<
|
|
25
|
+
<item>RFC-1545: standalone generated-conflict regeneration in flow.integrate</item>
|
|
26
|
+
<item>RFC-1543: attribute shared-checkout dirt to live ops and expose peers (RFC-1543)</item>
|
|
27
|
+
<item>RFC-1544: attribute mission lockfile churn to owning checkout and auto-resolve foreign importer diffs (RFC-1544)</item>
|
|
28
|
+
<history>RFC-1487, RFC-1490, RFC-1491, RFC-1504, RFC-1509, RFC-1515, RFC-1528, 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 } : {}) },
|
|
@@ -179,7 +190,13 @@ async function cleanupIntegrated(
|
|
|
179
190
|
journalBase?: string,
|
|
180
191
|
journalToleratedDirt?: Array<{ path: string; class: string }>,
|
|
181
192
|
journalAutoResolved?: string[],
|
|
182
|
-
journalRemediation?: {
|
|
193
|
+
journalRemediation?: {
|
|
194
|
+
reattachedTo?: string;
|
|
195
|
+
autoCleaned?: string[];
|
|
196
|
+
autocommitSha?: string;
|
|
197
|
+
restoredImporters?: string[];
|
|
198
|
+
staleImporterCommitSha?: string;
|
|
199
|
+
},
|
|
183
200
|
journalGateReport?: string,
|
|
184
201
|
): Promise<{ cleanedUp: boolean; diagnostics: Diagnostic[]; gate: FlowScriptResult | null }> {
|
|
185
202
|
const branchExistsNow = await branchExists(primary, io, entry.name);
|
|
@@ -301,13 +318,19 @@ async function cleanupIntegrated(
|
|
|
301
318
|
...(journalRemediation?.reattachedTo !== undefined
|
|
302
319
|
? { reattachedTo: journalRemediation.reattachedTo }
|
|
303
320
|
: {}),
|
|
304
|
-
...(journalRemediation?.autoCleaned !== undefined &&
|
|
305
|
-
journalRemediation.autoCleaned.length > 0
|
|
321
|
+
...(journalRemediation?.autoCleaned !== undefined && journalRemediation.autoCleaned.length > 0
|
|
306
322
|
? { autoCleaned: journalRemediation.autoCleaned }
|
|
307
323
|
: {}),
|
|
308
324
|
...(journalRemediation?.autocommitSha !== undefined
|
|
309
325
|
? { autocommitSha: journalRemediation.autocommitSha }
|
|
310
326
|
: {}),
|
|
327
|
+
...(journalRemediation?.restoredImporters !== undefined &&
|
|
328
|
+
journalRemediation.restoredImporters.length > 0
|
|
329
|
+
? { restoredImporters: journalRemediation.restoredImporters }
|
|
330
|
+
: {}),
|
|
331
|
+
...(journalRemediation?.staleImporterCommitSha !== undefined
|
|
332
|
+
? { staleImporterCommitSha: journalRemediation.staleImporterCommitSha }
|
|
333
|
+
: {}),
|
|
311
334
|
...(journalGateReport !== undefined ? { gateReport: journalGateReport } : {}),
|
|
312
335
|
});
|
|
313
336
|
} catch (error) {
|
|
@@ -348,8 +371,9 @@ export async function integrateFlowBranch(
|
|
|
348
371
|
try {
|
|
349
372
|
const common = await commonGitDir(io, repoRoot);
|
|
350
373
|
const sha =
|
|
351
|
-
(
|
|
352
|
-
|
|
374
|
+
(
|
|
375
|
+
await git(repoRoot, io, ["rev-parse", "--verify", "-q", `refs/heads/${data.branch}`])
|
|
376
|
+
).stdout.trim() || "unknown";
|
|
353
377
|
await appendJournal(io, common, {
|
|
354
378
|
event: "integrate-refusal",
|
|
355
379
|
branch: data.branch,
|
|
@@ -393,6 +417,8 @@ async function integrateFlowBranchAttempt(
|
|
|
393
417
|
autoClean?: boolean;
|
|
394
418
|
/** RFC-1531: sweep remaining dirty entries into a fixed-subject commit. */
|
|
395
419
|
autocommit?: boolean;
|
|
420
|
+
/** RFC-1543: seconds to wait for live foreign claim-holders on primary (default 600, 0 = fail-fast). */
|
|
421
|
+
waitForeignSeconds?: number;
|
|
396
422
|
},
|
|
397
423
|
): Promise<FlowIntegrateData> {
|
|
398
424
|
const now = opts.now ?? new Date();
|
|
@@ -502,8 +528,11 @@ async function integrateFlowBranchAttempt(
|
|
|
502
528
|
{
|
|
503
529
|
ruleId: "FLOW-07",
|
|
504
530
|
severity: "error",
|
|
505
|
-
message:
|
|
506
|
-
|
|
531
|
+
message:
|
|
532
|
+
`registry entry for ${branch} names worktree ${wtPath}, which does not exist (vanished)` +
|
|
533
|
+
(wouldReattach !== undefined
|
|
534
|
+
? ` — --reattach would recreate it at ${wouldReattach}`
|
|
535
|
+
: ""),
|
|
507
536
|
fixHint:
|
|
508
537
|
"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
538
|
data: { vanished: true, ...(wouldReattach !== undefined ? { wouldReattach } : {}) },
|
|
@@ -630,8 +659,7 @@ async function integrateFlowBranchAttempt(
|
|
|
630
659
|
// worktree with the branch — a foreign tree squats there.
|
|
631
660
|
const occupied =
|
|
632
661
|
live === null && liveEntry.worktree !== null && (await io.exists(liveEntry.worktree));
|
|
633
|
-
const vanished =
|
|
634
|
-
!occupied && (branchWorktree === null || !(await io.exists(branchWorktree)));
|
|
662
|
+
const vanished = !occupied && (branchWorktree === null || !(await io.exists(branchWorktree)));
|
|
635
663
|
if (opts.reattach === true && occupied) {
|
|
636
664
|
return refuse(
|
|
637
665
|
"FLOW-INT-17",
|
|
@@ -682,6 +710,76 @@ async function integrateFlowBranchAttempt(
|
|
|
682
710
|
opts.onProgress?.(`tolerated forge-local state: ${dirty.toleratedState.join(", ")}`);
|
|
683
711
|
}
|
|
684
712
|
|
|
713
|
+
// RFC-1544 AC-2: referent-aware importer-prune resolution — before any
|
|
714
|
+
// remediation, so --autocommit can never sweep a foreign mission's live
|
|
715
|
+
// importer into a commit. `foreign-open-mission` restores the committed
|
|
716
|
+
// importer subtree (never a whole-file checkout — sibling lockfile diffs
|
|
717
|
+
// keep their own classification); `importer-prune-stale` accepts the
|
|
718
|
+
// prune as cleanup and commits it so dead residue stops churning.
|
|
719
|
+
let restoredImporters: string[] | undefined;
|
|
720
|
+
let staleImporterCommitSha: string | undefined;
|
|
721
|
+
if (dirty.entries.some((line) => line.slice(3).trim() === "pnpm-lock.yaml")) {
|
|
722
|
+
const { classifyDirt, resolveImporterReferents } = await import("../preflight.ts");
|
|
723
|
+
const { extractImporterBlock, insertImporterBlock } =
|
|
724
|
+
await import("../../mission/importer-block.ts");
|
|
725
|
+
const pruneVerdict = await classifyDirt(
|
|
726
|
+
branchWorktree,
|
|
727
|
+
io,
|
|
728
|
+
dirty.entries,
|
|
729
|
+
{ runGit: git },
|
|
730
|
+
[],
|
|
731
|
+
(ids) => resolveImporterReferents(branchWorktree, io, ids),
|
|
732
|
+
);
|
|
733
|
+
const lockTolerated = pruneVerdict.tolerated.find((t) => t.path === "pnpm-lock.yaml");
|
|
734
|
+
if (
|
|
735
|
+
lockTolerated?.class === "foreign-open-mission" &&
|
|
736
|
+
lockTolerated.missionIds !== undefined
|
|
737
|
+
) {
|
|
738
|
+
const head = await git(branchWorktree, io, ["show", "HEAD:pnpm-lock.yaml"]);
|
|
739
|
+
if (head.exitCode === 0) {
|
|
740
|
+
let next = await io.readFile(join(branchWorktree, "pnpm-lock.yaml"));
|
|
741
|
+
const restored: string[] = [];
|
|
742
|
+
for (const id of lockTolerated.missionIds) {
|
|
743
|
+
const key = `missions/${id}/workpiece`;
|
|
744
|
+
const block = extractImporterBlock(head.stdout, key);
|
|
745
|
+
if (block === null) continue;
|
|
746
|
+
const spliced = insertImporterBlock(next, key, block);
|
|
747
|
+
if (spliced === null) continue;
|
|
748
|
+
next = spliced;
|
|
749
|
+
restored.push(id);
|
|
750
|
+
}
|
|
751
|
+
if (restored.length > 0) {
|
|
752
|
+
await io.writeFile(join(branchWorktree, "pnpm-lock.yaml"), next);
|
|
753
|
+
restoredImporters = restored;
|
|
754
|
+
opts.onProgress?.(
|
|
755
|
+
`restored foreign mission importer(s): ${restored.map((id) => `missions/${id}/workpiece`).join(", ")}`,
|
|
756
|
+
);
|
|
757
|
+
dirty = await statusDirty(branchWorktree, io);
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
} else if (lockTolerated?.class === "importer-prune-stale") {
|
|
761
|
+
const add = await git(branchWorktree, io, ["add", "pnpm-lock.yaml"]);
|
|
762
|
+
const commit =
|
|
763
|
+
add.exitCode === 0
|
|
764
|
+
? await gitCommit(
|
|
765
|
+
branchWorktree,
|
|
766
|
+
io,
|
|
767
|
+
["commit", "-m", "chore(flow): prune stale mission importer"],
|
|
768
|
+
"integrate",
|
|
769
|
+
)
|
|
770
|
+
: add;
|
|
771
|
+
if (commit.exitCode === 0) {
|
|
772
|
+
staleImporterCommitSha = (
|
|
773
|
+
await git(branchWorktree, io, ["rev-parse", "HEAD"])
|
|
774
|
+
).stdout.trim();
|
|
775
|
+
opts.onProgress?.(
|
|
776
|
+
`committed stale importer prune ${staleImporterCommitSha.slice(0, 9)} (${(lockTolerated.missionIds ?? []).map((id) => `missions/${id}/workpiece`).join(", ")})`,
|
|
777
|
+
);
|
|
778
|
+
dirty = await statusDirty(branchWorktree, io);
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
|
|
685
783
|
// RFC-1531 remediation flags — before the dirty checks: --auto-clean
|
|
686
784
|
// deletes ONLY disposable-class paths (closed allowlist — a work-class
|
|
687
785
|
// member in the set deletes nothing and still refuses FLOW-INT-01, and
|
|
@@ -698,8 +796,7 @@ async function integrateFlowBranchAttempt(
|
|
|
698
796
|
// — AC-4 names importer-prune a refusal class: restoring/committing a
|
|
699
797
|
// lockfile is a content decision, never a cleanup step.
|
|
700
798
|
const blocker = classified.filter(
|
|
701
|
-
(c) =>
|
|
702
|
-
c.class !== "disposable" && !AUTO_CLEAN_PASS_CLASSES.includes(c.class),
|
|
799
|
+
(c) => c.class !== "disposable" && !AUTO_CLEAN_PASS_CLASSES.includes(c.class),
|
|
703
800
|
);
|
|
704
801
|
if (opts.autoClean === true) {
|
|
705
802
|
// A blocker refuses only when nothing downstream will commit it:
|
|
@@ -752,11 +849,12 @@ async function integrateFlowBranchAttempt(
|
|
|
752
849
|
{ branch, developBefore, autoCleaned },
|
|
753
850
|
);
|
|
754
851
|
}
|
|
755
|
-
const commit = await gitCommit(
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
SWEEP_COMMIT_SUBJECT,
|
|
759
|
-
|
|
852
|
+
const commit = await gitCommit(
|
|
853
|
+
branchWorktree,
|
|
854
|
+
io,
|
|
855
|
+
["commit", "-m", SWEEP_COMMIT_SUBJECT],
|
|
856
|
+
"integrate",
|
|
857
|
+
);
|
|
760
858
|
if (commit.exitCode !== 0) {
|
|
761
859
|
return refuse(
|
|
762
860
|
"FLOW-INT-17",
|
|
@@ -765,9 +863,7 @@ async function integrateFlowBranchAttempt(
|
|
|
765
863
|
{ branch, developBefore, autoCleaned },
|
|
766
864
|
);
|
|
767
865
|
}
|
|
768
|
-
autocommitSha = (
|
|
769
|
-
await git(branchWorktree, io, ["rev-parse", "HEAD"])
|
|
770
|
-
).stdout.trim();
|
|
866
|
+
autocommitSha = (await git(branchWorktree, io, ["rev-parse", "HEAD"])).stdout.trim();
|
|
771
867
|
opts.onProgress?.(
|
|
772
868
|
`autocommit: swept ${paths.length} path(s) into ${autocommitSha.slice(0, 9)} (${SWEEP_COMMIT_SUBJECT})`,
|
|
773
869
|
);
|
|
@@ -792,6 +888,8 @@ async function integrateFlowBranchAttempt(
|
|
|
792
888
|
worktreeDirty: dirty,
|
|
793
889
|
invoke: opts.invoke,
|
|
794
890
|
commandRegistry: opts.commandRegistry,
|
|
891
|
+
waitForeignSeconds: opts.waitForeignSeconds,
|
|
892
|
+
onProgress: opts.onProgress,
|
|
795
893
|
});
|
|
796
894
|
toleratedDirt = preflight.tolerated;
|
|
797
895
|
for (const skipped of preflight.skipped) {
|
|
@@ -817,6 +915,8 @@ async function integrateFlowBranchAttempt(
|
|
|
817
915
|
reattachedTo,
|
|
818
916
|
autoCleaned,
|
|
819
917
|
autocommitSha,
|
|
918
|
+
restoredImporters,
|
|
919
|
+
staleImporterCommitSha,
|
|
820
920
|
},
|
|
821
921
|
preflight.refuse.data,
|
|
822
922
|
);
|
|
@@ -854,6 +954,8 @@ async function integrateFlowBranchAttempt(
|
|
|
854
954
|
reattachedTo,
|
|
855
955
|
autoCleaned,
|
|
856
956
|
autocommitSha,
|
|
957
|
+
restoredImporters,
|
|
958
|
+
staleImporterCommitSha,
|
|
857
959
|
},
|
|
858
960
|
{
|
|
859
961
|
entries,
|
|
@@ -901,40 +1003,47 @@ async function integrateFlowBranchAttempt(
|
|
|
901
1003
|
let rebase = await git(branchWorktree, io, ["rebase", "develop"]);
|
|
902
1004
|
let guard = 0;
|
|
903
1005
|
while (rebase.exitCode !== 0 && guard++ < 8) {
|
|
904
|
-
const conflicts = await git(branchWorktree, io, [
|
|
905
|
-
"diff",
|
|
906
|
-
"--name-only",
|
|
907
|
-
"--diff-filter=U",
|
|
908
|
-
]);
|
|
1006
|
+
const conflicts = await git(branchWorktree, io, ["diff", "--name-only", "--diff-filter=U"]);
|
|
909
1007
|
const paths = conflicts.stdout
|
|
910
1008
|
.split("\n")
|
|
911
1009
|
.map((l) => l.trim())
|
|
912
1010
|
.filter((l) => l.length > 0);
|
|
913
1011
|
const { classifyRebaseConflicts } = await import("../preflight.ts");
|
|
914
1012
|
const verdict = await classifyRebaseConflicts(branchWorktree, io, paths);
|
|
1013
|
+
// RFC-1545 AC-2: without a kernel invoke port the standalone adapter
|
|
1014
|
+
// spawns the allowlisted owner commands in the worktree — the
|
|
1015
|
+
// resolution contract is identical either way.
|
|
1016
|
+
const invoker =
|
|
1017
|
+
opts.invoke ??
|
|
1018
|
+
standaloneInvoke(
|
|
1019
|
+
io,
|
|
1020
|
+
branchWorktree,
|
|
1021
|
+
verdict.owners.map((o) => o.command),
|
|
1022
|
+
);
|
|
915
1023
|
const resolvable =
|
|
916
1024
|
paths.length > 0 &&
|
|
917
1025
|
verdict.nonGenerated.length === 0 &&
|
|
918
|
-
verdict.owners.length === paths.length
|
|
919
|
-
opts.invoke !== undefined;
|
|
1026
|
+
verdict.owners.length === paths.length;
|
|
920
1027
|
if (!resolvable) {
|
|
921
1028
|
await git(branchWorktree, io, ["rebase", "--abort"]);
|
|
922
1029
|
return refuse(
|
|
923
1030
|
"FLOW-INT-02",
|
|
924
1031
|
`rebase onto develop conflicts in: ${paths.join(", ") || "(unknown paths)"}` +
|
|
925
|
-
(verdict.owners.length > 0
|
|
926
|
-
? opts.invoke === undefined
|
|
927
|
-
? " — generated conflicts present but no invoke port is available to regenerate them"
|
|
928
|
-
: " — mixed generated/non-generated conflict set"
|
|
929
|
-
: ""),
|
|
1032
|
+
(verdict.owners.length > 0 ? " — mixed generated/non-generated conflict set" : ""),
|
|
930
1033
|
"resolve the rebase inside the session worktree, commit, and re-run flow.integrate",
|
|
931
1034
|
{ branch, developBefore },
|
|
932
1035
|
);
|
|
933
1036
|
}
|
|
934
1037
|
let failed = false;
|
|
935
1038
|
for (const o of verdict.owners) {
|
|
936
|
-
|
|
937
|
-
|
|
1039
|
+
// `git checkout --theirs` is blocked by the agent-session git
|
|
1040
|
+
// wrapper — materialize the stage-3 (theirs) blob through the
|
|
1041
|
+
// read-only `git show` + io write instead (RFC-1545).
|
|
1042
|
+
const theirs = await git(branchWorktree, io, ["show", `:3:${o.path}`]);
|
|
1043
|
+
if (theirs.exitCode === 0) {
|
|
1044
|
+
await io.writeFile(join(branchWorktree, o.path), theirs.stdout);
|
|
1045
|
+
}
|
|
1046
|
+
const regen = await invoker(o.command, o.flags);
|
|
938
1047
|
if (regen.ok === false || (regen.exitCode !== undefined && regen.exitCode !== 0)) {
|
|
939
1048
|
await git(branchWorktree, io, ["rebase", "--abort"]);
|
|
940
1049
|
failed = true;
|
|
@@ -945,24 +1054,28 @@ async function integrateFlowBranchAttempt(
|
|
|
945
1054
|
{ branch, developBefore },
|
|
946
1055
|
);
|
|
947
1056
|
}
|
|
1057
|
+
// RFC-1545 AC-4: a successful generator that left conflict markers
|
|
1058
|
+
// behind must not be committed — escalate like a failure.
|
|
1059
|
+
const regenerated = await io.readFile(join(branchWorktree, o.path));
|
|
1060
|
+
if (/^(<{7}|={7}|>{7})/m.test(regenerated)) {
|
|
1061
|
+
await git(branchWorktree, io, ["rebase", "--abort"]);
|
|
1062
|
+
failed = true;
|
|
1063
|
+
return refuse(
|
|
1064
|
+
"FLOW-INT-02",
|
|
1065
|
+
`auto-resolve of generated conflict ${o.path} failed: ${o.command} left conflict markers in the regenerated output`,
|
|
1066
|
+
"resolve the rebase inside the session worktree manually, commit, and re-run flow.integrate",
|
|
1067
|
+
{ branch, developBefore },
|
|
1068
|
+
);
|
|
1069
|
+
}
|
|
948
1070
|
await git(branchWorktree, io, ["add", "--", o.path]);
|
|
949
1071
|
opts.onProgress?.(`conflict: ${o.path} — regenerated via ${o.command}`);
|
|
950
1072
|
autoResolved.push(o.path);
|
|
951
1073
|
}
|
|
952
1074
|
if (failed) break;
|
|
953
|
-
rebase = await git(branchWorktree, io, [
|
|
954
|
-
"-c",
|
|
955
|
-
"core.editor=true",
|
|
956
|
-
"rebase",
|
|
957
|
-
"--continue",
|
|
958
|
-
]);
|
|
1075
|
+
rebase = await git(branchWorktree, io, ["-c", "core.editor=true", "rebase", "--continue"]);
|
|
959
1076
|
}
|
|
960
1077
|
if (rebase.exitCode !== 0) {
|
|
961
|
-
const conflicts = await git(branchWorktree, io, [
|
|
962
|
-
"diff",
|
|
963
|
-
"--name-only",
|
|
964
|
-
"--diff-filter=U",
|
|
965
|
-
]);
|
|
1078
|
+
const conflicts = await git(branchWorktree, io, ["diff", "--name-only", "--diff-filter=U"]);
|
|
966
1079
|
const paths = conflicts.stdout
|
|
967
1080
|
.split("\n")
|
|
968
1081
|
.map((l) => l.trim())
|
|
@@ -983,7 +1096,10 @@ async function integrateFlowBranchAttempt(
|
|
|
983
1096
|
const { resolveGateEngine } = await import("../gate-engine.ts");
|
|
984
1097
|
const engine = await resolveGateEngine(branchWorktree, primary, io);
|
|
985
1098
|
const warnings: Diagnostic[] = [];
|
|
986
|
-
if (
|
|
1099
|
+
if (
|
|
1100
|
+
engine.source === "primary" &&
|
|
1101
|
+
(await io.exists(join(primary, "hooks", "integration-gate.sh")))
|
|
1102
|
+
) {
|
|
987
1103
|
warnings.push({
|
|
988
1104
|
ruleId: "FLOW-INT-16",
|
|
989
1105
|
severity: "warning",
|
|
@@ -1083,6 +1199,10 @@ async function integrateFlowBranchAttempt(
|
|
|
1083
1199
|
...(reattachedTo !== undefined ? { reattachedTo } : {}),
|
|
1084
1200
|
...(autoCleaned !== undefined && autoCleaned.length > 0 ? { autoCleaned } : {}),
|
|
1085
1201
|
...(autocommitSha !== undefined ? { autocommitSha } : {}),
|
|
1202
|
+
...(restoredImporters !== undefined && restoredImporters.length > 0
|
|
1203
|
+
? { restoredImporters }
|
|
1204
|
+
: {}),
|
|
1205
|
+
...(staleImporterCommitSha !== undefined ? { staleImporterCommitSha } : {}),
|
|
1086
1206
|
gateEngine: engine.source,
|
|
1087
1207
|
diagnostics: warnings,
|
|
1088
1208
|
};
|
|
@@ -1162,6 +1282,8 @@ async function integrateFlowBranchAttempt(
|
|
|
1162
1282
|
reattachedTo: inner.reattachedTo,
|
|
1163
1283
|
autoCleaned: inner.autoCleaned,
|
|
1164
1284
|
autocommitSha: inner.autocommitSha,
|
|
1285
|
+
restoredImporters: inner.restoredImporters,
|
|
1286
|
+
staleImporterCommitSha: inner.staleImporterCommitSha,
|
|
1165
1287
|
},
|
|
1166
1288
|
inner.gate?.reportPath ?? undefined,
|
|
1167
1289
|
);
|
|
@@ -1197,6 +1319,11 @@ export async function runFlowIntegrate(
|
|
|
1197
1319
|
reattach: input.flags["reattach"] === true,
|
|
1198
1320
|
autoClean: input.flags["auto-clean"] === true,
|
|
1199
1321
|
autocommit: input.flags["autocommit"] === true,
|
|
1322
|
+
waitForeignSeconds:
|
|
1323
|
+
typeof input.flags["wait-foreign"] === "string" ||
|
|
1324
|
+
typeof input.flags["wait-foreign"] === "number"
|
|
1325
|
+
? Number(input.flags["wait-foreign"])
|
|
1326
|
+
: undefined,
|
|
1200
1327
|
});
|
|
1201
1328
|
|
|
1202
1329
|
const refused = data.diagnostics.find((d) => d.severity === "error");
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>flow.peers — the read-only live resource map (RFC-1543). Reports the
|
|
4
|
+
integrate.lock holder, live op-claims grouped by checkout, open missions per
|
|
5
|
+
worktree, and registered in-flight branches so an operator (or a second
|
|
6
|
+
agent session) can see who owns a shared checkout before flow.integrate
|
|
7
|
+
waits or refuses on it.</purpose>
|
|
8
|
+
<non-goals>
|
|
9
|
+
<item>No mutation authority — peers observes; it never breaks locks, releases claims, or closes missions.</item>
|
|
10
|
+
</non-goals>
|
|
11
|
+
</MODULE_CONTRACT>
|
|
12
|
+
<CHANGE_SUMMARY>
|
|
13
|
+
<item>RFC-1543: flow.peers — forge/peers@1 report over lock holder, live claims, open missions, in-flight branches</item>
|
|
14
|
+
<item>RFC-1543: attribute shared-checkout dirt to live ops and expose peers (RFC-1543)</item>
|
|
15
|
+
</CHANGE_SUMMARY>
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { join } from "node:path";
|
|
19
|
+
import type {
|
|
20
|
+
ForgeCommandInput,
|
|
21
|
+
ForgeCommandResult,
|
|
22
|
+
ForgeRuntimeContext,
|
|
23
|
+
} from "../../../src/types.ts";
|
|
24
|
+
import { resolveIo } from "../../../src/utils/io.ts";
|
|
25
|
+
import { openMissionsIn } from "../../mission/open-missions.ts";
|
|
26
|
+
import { commonGitDir, INTEGRATE_LOCK_RELATIVE_PATH, readRegistry } from "../registry.ts";
|
|
27
|
+
import { requireGit, topLevel } from "../git.ts";
|
|
28
|
+
import { describeHeldLock } from "../locks.ts";
|
|
29
|
+
import { isClaimLive, liveClaimsReadOnly, type OpClaim } from "../ops-registry.ts";
|
|
30
|
+
|
|
31
|
+
export const PEERS_SCHEMA = "forge/peers@1";
|
|
32
|
+
|
|
33
|
+
interface LockHolder {
|
|
34
|
+
pid: number;
|
|
35
|
+
host?: string;
|
|
36
|
+
at?: string;
|
|
37
|
+
bootId?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface PeersReport {
|
|
41
|
+
schema: typeof PEERS_SCHEMA;
|
|
42
|
+
integrateLock: (LockHolder & { disposition: "live" | "dead-holder" | "stale" }) | null;
|
|
43
|
+
claimsByCheckout: { workspaceRoot: string; claims: OpClaim[] }[];
|
|
44
|
+
openMissions: string[];
|
|
45
|
+
branchesInFlight: string[];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Read + liveness-check the integrate.lock holder — shared with ops sweeps. */
|
|
49
|
+
async function integrateLockHolder(
|
|
50
|
+
io: ReturnType<typeof resolveIo>,
|
|
51
|
+
common: string,
|
|
52
|
+
): Promise<PeersReport["integrateLock"]> {
|
|
53
|
+
let parsed: LockHolder | null = null;
|
|
54
|
+
try {
|
|
55
|
+
const raw = JSON.parse(await io.readFile(join(common, INTEGRATE_LOCK_RELATIVE_PATH))) as Record<
|
|
56
|
+
string,
|
|
57
|
+
unknown
|
|
58
|
+
>;
|
|
59
|
+
if (typeof raw["pid"] === "number") {
|
|
60
|
+
parsed = {
|
|
61
|
+
pid: raw["pid"],
|
|
62
|
+
host: typeof raw["host"] === "string" ? raw["host"] : undefined,
|
|
63
|
+
at: typeof raw["at"] === "string" ? raw["at"] : undefined,
|
|
64
|
+
bootId: typeof raw["bootId"] === "string" ? raw["bootId"] : undefined,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
} catch {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
if (parsed === null) return null;
|
|
71
|
+
const d = describeHeldLock(
|
|
72
|
+
{ pid: parsed.pid, host: parsed.host, at: parsed.at ?? "", bootId: parsed.bootId },
|
|
73
|
+
10 * 60_000,
|
|
74
|
+
);
|
|
75
|
+
return { ...parsed, disposition: d.disposition };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export async function runFlowPeers(
|
|
79
|
+
_input: ForgeCommandInput,
|
|
80
|
+
context: ForgeRuntimeContext,
|
|
81
|
+
): Promise<ForgeCommandResult<PeersReport>> {
|
|
82
|
+
const { workspaceRoot, logger, outputFormat } = context;
|
|
83
|
+
const io = resolveIo(context.io);
|
|
84
|
+
await requireGit(io);
|
|
85
|
+
|
|
86
|
+
const repoRoot = await topLevel(workspaceRoot, io);
|
|
87
|
+
if (repoRoot === null) {
|
|
88
|
+
throw new Error("flow.peers must run inside a git repository");
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const common = await commonGitDir(io, repoRoot);
|
|
92
|
+
const [lock, claims, openMissions, registry] = await Promise.all([
|
|
93
|
+
integrateLockHolder(io, common),
|
|
94
|
+
liveClaimsReadOnly(repoRoot, io),
|
|
95
|
+
openMissionsIn(repoRoot, io),
|
|
96
|
+
readRegistry(io, repoRoot).catch(() => null),
|
|
97
|
+
]);
|
|
98
|
+
|
|
99
|
+
const byRoot = new Map<string, OpClaim[]>();
|
|
100
|
+
for (const c of claims.filter((c) => isClaimLive(c))) {
|
|
101
|
+
byRoot.set(c.workspaceRoot, [...(byRoot.get(c.workspaceRoot) ?? []), c]);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const report: PeersReport = {
|
|
105
|
+
schema: PEERS_SCHEMA,
|
|
106
|
+
integrateLock: lock,
|
|
107
|
+
claimsByCheckout: [...byRoot.entries()].map(([root, list]) => ({
|
|
108
|
+
workspaceRoot: root,
|
|
109
|
+
claims: list,
|
|
110
|
+
})),
|
|
111
|
+
openMissions,
|
|
112
|
+
branchesInFlight: (registry?.branches ?? []).map((b) => b.name),
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
if (outputFormat === "pretty") {
|
|
116
|
+
logger.section("flow.peers");
|
|
117
|
+
logger.info(
|
|
118
|
+
lock === null
|
|
119
|
+
? " integrate.lock: free"
|
|
120
|
+
: ` integrate.lock: pid ${lock.pid} on ${lock.host ?? "?"} since ${lock.at ?? "?"} (${lock.disposition})`,
|
|
121
|
+
);
|
|
122
|
+
for (const g of report.claimsByCheckout) {
|
|
123
|
+
for (const c of g.claims) {
|
|
124
|
+
logger.info(
|
|
125
|
+
` claim ${c.opId}: ${c.command} (pid ${c.pid}, started ${c.startedAt}) on ${g.workspaceRoot} — ${c.paths.length} path(s)`,
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (report.openMissions.length > 0) {
|
|
130
|
+
logger.info(` open missions: ${report.openMissions.join(", ")}`);
|
|
131
|
+
}
|
|
132
|
+
if (report.branchesInFlight.length > 0) {
|
|
133
|
+
logger.info(` branches in flight: ${report.branchesInFlight.join(", ")}`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return {
|
|
138
|
+
data: report,
|
|
139
|
+
exitCode: 0,
|
|
140
|
+
summary: `[flow.peers] ${lock === null ? "lock free" : `lock ${lock.disposition}`}, ${claims.length} live claim(s), ${report.openMissions.length} open mission(s)`,
|
|
141
|
+
};
|
|
142
|
+
}
|
package/os/flow/index.ts
CHANGED
|
@@ -15,11 +15,13 @@ reachable, else the version-file value.</purpose>
|
|
|
15
15
|
<item>Untagged is not an error — it resolves to the version-file value; only a missing or unparsable version file throws.</item>
|
|
16
16
|
</KEY_DECISIONS>
|
|
17
17
|
<CHANGE_SUMMARY>
|
|
18
|
-
<item>RFC-1493: step 1 — forge public release-line version reader</item>
|
|
19
18
|
<item>RFC-1494: step 1 — isFlowAdopted public export</item>
|
|
20
19
|
<item>RFC-1495: step 1 - forge state roots</item>
|
|
21
20
|
<item>RFC-1495: steps 2-3 - workshop paths resolver and call-site migration</item>
|
|
22
21
|
<item>RFC-1519: add advisory gate-verdict store for scoped pass reuse across reruns and the commit-integrate boundary</item>
|
|
22
|
+
<item>RFC-1549: route generated onboarding-status commits through session flow on fixed branches
|
|
23
|
+
|
|
24
|
+
commitWerkstattSideEffects skips git add+commit when classifyBranch() yields non-flow (protected/nonconforming), reports written outputPaths; status-hook and deploy/leitstand results propagate onboardingStatus metadata; leitstand.promote surfaces an optional session-worktree integration nextStep. Flow-branch commit behavior unchanged; mission-open fixture rebased to conforming auto/task-YYMMDD-NN branch. AC-1..AC-3 checked.</item>
|
|
23
25
|
<history>RFC-1493</history>
|
|
24
26
|
</CHANGE_SUMMARY>
|
|
25
27
|
*/
|
|
@@ -43,6 +45,8 @@ export { primaryWorktree, resolveStateRoots, worktreeList };
|
|
|
43
45
|
export { FORGE_STATE_FILES } from "./git.ts";
|
|
44
46
|
export type { StateRoots };
|
|
45
47
|
export type { FlowWorktree } from "./git.ts";
|
|
48
|
+
export { classifyBranch } from "./branch-name.ts";
|
|
49
|
+
export type { BranchClass } from "./branch-name.ts";
|
|
46
50
|
|
|
47
51
|
export interface RepositoryLineVersion {
|
|
48
52
|
/** "6.451.0+12.ab12cd34e" for a tagged line, "6.451.0" from the version file otherwise. */
|