@fro.bot/systematic 3.22.6 → 3.22.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -793,7 +793,7 @@ var STRICT_UTF8_DECODER = new TextDecoder("utf-8", {
|
|
|
793
793
|
fatal: true,
|
|
794
794
|
ignoreBOM: true
|
|
795
795
|
});
|
|
796
|
-
var WORKTREE_DIGEST_DOMAIN = "systematic:opencode-observer:worktree:
|
|
796
|
+
var WORKTREE_DIGEST_DOMAIN = "systematic:opencode-observer:worktree:v4\x00";
|
|
797
797
|
var IGNORED_GITIGNORE_ARGS = [
|
|
798
798
|
"ls-files",
|
|
799
799
|
"-o",
|
|
@@ -806,6 +806,9 @@ var IGNORED_GITIGNORE_ARGS = [
|
|
|
806
806
|
":(top,glob)**/.gitignore"
|
|
807
807
|
];
|
|
808
808
|
var MAX_IGNORE_SOURCE_BYTES = 1048576;
|
|
809
|
+
function createWalkState() {
|
|
810
|
+
return { bytes: 0, files: 0, gitlinks: 0 };
|
|
811
|
+
}
|
|
809
812
|
function unavailable(result) {
|
|
810
813
|
return { status: "unavailable", reasonCode: result.reasonCode };
|
|
811
814
|
}
|
|
@@ -1182,14 +1185,16 @@ function absoluteCanonicalPath(value, realPath) {
|
|
|
1182
1185
|
function isEnoent(error) {
|
|
1183
1186
|
return error !== null && typeof error === "object" && "code" in error && error.code === "ENOENT";
|
|
1184
1187
|
}
|
|
1185
|
-
function observed(absolutePath, record, stat, displacedByDirectory = false) {
|
|
1188
|
+
function observed(absolutePath, record, stat, displacedByDirectory = false, gitlinkState, walked) {
|
|
1186
1189
|
return {
|
|
1187
1190
|
status: "ok",
|
|
1188
1191
|
observation: {
|
|
1189
1192
|
absolutePath,
|
|
1190
1193
|
record,
|
|
1191
1194
|
stat,
|
|
1192
|
-
...displacedByDirectory ? { displacedByDirectory: true } : {}
|
|
1195
|
+
...displacedByDirectory ? { displacedByDirectory: true } : {},
|
|
1196
|
+
...gitlinkState ? { gitlinkState } : {},
|
|
1197
|
+
...walked ? { walked } : {}
|
|
1193
1198
|
}
|
|
1194
1199
|
};
|
|
1195
1200
|
}
|
|
@@ -1290,21 +1295,16 @@ function directoryEmptiness(absolutePath) {
|
|
|
1290
1295
|
} catch {}
|
|
1291
1296
|
}
|
|
1292
1297
|
}
|
|
1293
|
-
function
|
|
1294
|
-
const
|
|
1295
|
-
if (
|
|
1296
|
-
return
|
|
1297
|
-
const lines = result.output.stdout.split(`
|
|
1298
|
-
`);
|
|
1299
|
-
if (lines.at(-1) === "")
|
|
1300
|
-
lines.pop();
|
|
1301
|
-
const [toplevel, id] = lines;
|
|
1302
|
-
if (lines.length !== 2 || toplevel === undefined || id === undefined || !GIT_OBJECT_ID.test(id) || !path5.isAbsolute(toplevel)) {
|
|
1303
|
-
return { status: "error", reasonCode: "file-read-failed" };
|
|
1298
|
+
function readCheckedOutGitlink(readers, absolutePath, limits) {
|
|
1299
|
+
const anchor = readRepositoryAnchor(readers.runner, absolutePath, limits, readers.realPath);
|
|
1300
|
+
if (anchor.status === "error") {
|
|
1301
|
+
return anchor.reasonCode === "target-unavailable" ? { status: "error", reasonCode: "file-read-failed" } : anchor;
|
|
1304
1302
|
}
|
|
1305
1303
|
const submodule = canonicalPath(absolutePath, readers.realPath);
|
|
1306
|
-
|
|
1307
|
-
|
|
1304
|
+
if (submodule === undefined || submodule !== anchor.toplevel) {
|
|
1305
|
+
return { status: "error", reasonCode: "file-read-failed" };
|
|
1306
|
+
}
|
|
1307
|
+
return anchor.head === undefined ? { status: "unborn", anchor } : { status: "initialized", id: anchor.head, anchor };
|
|
1308
1308
|
}
|
|
1309
1309
|
function inspectGitlink(readers, absolutePath, limits) {
|
|
1310
1310
|
let directory;
|
|
@@ -1330,36 +1330,83 @@ function inspectGitlink(readers, absolutePath, limits) {
|
|
|
1330
1330
|
return { status: "error", reasonCode: "file-read-failed" };
|
|
1331
1331
|
}
|
|
1332
1332
|
}
|
|
1333
|
-
return
|
|
1333
|
+
return readCheckedOutGitlink(readers, absolutePath, limits);
|
|
1334
1334
|
}
|
|
1335
|
-
function appendSubmoduleFact(hash, readers, absolutePath, relativePath, limits) {
|
|
1335
|
+
function appendSubmoduleFact(hash, readers, absolutePath, relativePath, limits, walk) {
|
|
1336
1336
|
const inspected = inspectGitlink(readers, absolutePath, limits);
|
|
1337
1337
|
if (inspected.status === "error")
|
|
1338
1338
|
return inspected;
|
|
1339
1339
|
if (inspected.status === "absent") {
|
|
1340
1340
|
return missingObservation(absolutePath, relativePath);
|
|
1341
1341
|
}
|
|
1342
|
+
const walked = inspected.status === "uninitialized" ? undefined : readCheckoutFirstPass(readers, absolutePath, inspected, limits, walk);
|
|
1343
|
+
if (walked?.status === "error")
|
|
1344
|
+
return walked;
|
|
1342
1345
|
const id = inspected.status === "initialized" ? inspected.id : undefined;
|
|
1343
1346
|
hash.update("gitlink");
|
|
1344
1347
|
hashField(hash, relativePath);
|
|
1345
|
-
hashField(hash,
|
|
1346
|
-
|
|
1348
|
+
hashField(hash, gitlinkIdentity(inspected));
|
|
1349
|
+
if (walked)
|
|
1350
|
+
hashField(hash, walked.digest);
|
|
1351
|
+
return observed(absolutePath, { path: relativePath, kind: "gitlink", mode: "160000", id }, undefined, false, inspected.status, walked);
|
|
1347
1352
|
}
|
|
1348
|
-
function
|
|
1353
|
+
function appendNestedRepositoryFact(hash, readers, absolutePath, relativePath, limits, walk) {
|
|
1354
|
+
const inspected = inspectGitlink(readers, absolutePath, limits);
|
|
1355
|
+
if (inspected.status === "absent" || inspected.status === "uninitialized" || inspected.status === "error" && inspected.reasonCode === "file-read-failed") {
|
|
1356
|
+
return { status: "error", reasonCode: "worktree-unstable" };
|
|
1357
|
+
}
|
|
1358
|
+
if (inspected.status === "error")
|
|
1359
|
+
return inspected;
|
|
1360
|
+
const walked = readCheckoutFirstPass(readers, absolutePath, inspected, limits, walk);
|
|
1361
|
+
if (walked.status === "error")
|
|
1362
|
+
return walked;
|
|
1363
|
+
hash.update("nested");
|
|
1364
|
+
hashField(hash, relativePath);
|
|
1365
|
+
hashField(hash, gitlinkIdentity(inspected));
|
|
1366
|
+
hashField(hash, walked.digest);
|
|
1367
|
+
return observed(absolutePath, {
|
|
1368
|
+
path: relativePath,
|
|
1369
|
+
kind: "gitlink",
|
|
1370
|
+
mode: "160000",
|
|
1371
|
+
id: inspected.status === "initialized" ? inspected.id : undefined
|
|
1372
|
+
}, undefined, false, undefined, walked);
|
|
1373
|
+
}
|
|
1374
|
+
function isNestedRepositoryEntry(relativePath) {
|
|
1375
|
+
return relativePath.endsWith("/");
|
|
1376
|
+
}
|
|
1377
|
+
function readCheckoutFirstPass(readers, absolutePath, checkout, limits, walk) {
|
|
1378
|
+
return readRepositoryFirstPass(readers, contextFromAnchor(absolutePath, checkout.anchor), checkout.anchor.head, limits, walk);
|
|
1379
|
+
}
|
|
1380
|
+
function contextFromAnchor(commandDirectory, anchor) {
|
|
1381
|
+
return {
|
|
1382
|
+
commandDirectory,
|
|
1383
|
+
worktreeRoot: anchor.toplevel,
|
|
1384
|
+
infoExcludePath: anchor.infoExcludePath,
|
|
1385
|
+
pin: {
|
|
1386
|
+
targetRoot: anchor.toplevel,
|
|
1387
|
+
gitDir: anchor.gitDir,
|
|
1388
|
+
commonDir: anchor.commonDir
|
|
1389
|
+
}
|
|
1390
|
+
};
|
|
1391
|
+
}
|
|
1392
|
+
function gitlinkIdentity(inspected) {
|
|
1393
|
+
return inspected.status === "initialized" ? inspected.id : inspected.status;
|
|
1394
|
+
}
|
|
1395
|
+
function appendSymlinkFact(hash, readers, absolutePath, relativePath, stat, limits, walk, format, tracked) {
|
|
1349
1396
|
let target;
|
|
1350
1397
|
try {
|
|
1351
1398
|
target = readers.symlinkReader(absolutePath);
|
|
1352
1399
|
} catch (error) {
|
|
1353
1400
|
return isEnoent(error) ? vanishedPath(tracked, absolutePath, relativePath) : { status: "error", reasonCode: "file-read-failed" };
|
|
1354
1401
|
}
|
|
1355
|
-
const nextBytes =
|
|
1402
|
+
const nextBytes = walk.bytes + target.byteLength;
|
|
1356
1403
|
if (target.byteLength > limits.maxPathBytes || nextBytes > limits.maxTotalFileBytes) {
|
|
1357
1404
|
return { status: "error", reasonCode: "file-output-limit" };
|
|
1358
1405
|
}
|
|
1359
1406
|
hash.update("symlink");
|
|
1360
1407
|
hashField(hash, relativePath);
|
|
1361
1408
|
hashField(hash, target);
|
|
1362
|
-
|
|
1409
|
+
walk.bytes = nextBytes;
|
|
1363
1410
|
return observed(absolutePath, {
|
|
1364
1411
|
path: relativePath,
|
|
1365
1412
|
kind: "symlink",
|
|
@@ -1367,11 +1414,11 @@ function appendSymlinkFact(hash, readers, absolutePath, relativePath, stat, limi
|
|
|
1367
1414
|
id: gitBlobId(target, format)
|
|
1368
1415
|
}, stat);
|
|
1369
1416
|
}
|
|
1370
|
-
function appendRegularFact(hash, readers, absolutePath, relativePath, stat, limits,
|
|
1417
|
+
function appendRegularFact(hash, readers, absolutePath, relativePath, stat, limits, walk, format, tracked) {
|
|
1371
1418
|
if (!stat.isFile || !Number.isSafeInteger(stat.size) || stat.size < 0) {
|
|
1372
1419
|
return { status: "error", reasonCode: "file-read-failed" };
|
|
1373
1420
|
}
|
|
1374
|
-
const remaining = limits.maxTotalFileBytes -
|
|
1421
|
+
const remaining = limits.maxTotalFileBytes - walk.bytes;
|
|
1375
1422
|
if (stat.size > remaining) {
|
|
1376
1423
|
return { status: "error", reasonCode: "file-output-limit" };
|
|
1377
1424
|
}
|
|
@@ -1388,7 +1435,7 @@ function appendRegularFact(hash, readers, absolutePath, relativePath, stat, limi
|
|
|
1388
1435
|
hashField(hash, relativePath);
|
|
1389
1436
|
hashField(hash, (stat.mode & 73) !== 0 ? "executable" : "non-executable");
|
|
1390
1437
|
hashField(hash, content);
|
|
1391
|
-
|
|
1438
|
+
walk.bytes += content.byteLength;
|
|
1392
1439
|
return observed(absolutePath, {
|
|
1393
1440
|
path: relativePath,
|
|
1394
1441
|
kind: "regular",
|
|
@@ -1435,7 +1482,7 @@ function verifyAncestorsUnchanged(verified) {
|
|
|
1435
1482
|
}
|
|
1436
1483
|
return { status: "ok" };
|
|
1437
1484
|
}
|
|
1438
|
-
function appendPathFact(hash, readers, context, entry, limits,
|
|
1485
|
+
function appendPathFact(hash, readers, context, entry, limits, walk, format, verifiedDirectories) {
|
|
1439
1486
|
const { mode, relativePath } = entry;
|
|
1440
1487
|
const absolutePath = safePath(context.worktreeRoot, relativePath);
|
|
1441
1488
|
if (!absolutePath || outputBytes(relativePath) > limits.maxPathBytes) {
|
|
@@ -1448,8 +1495,11 @@ function appendPathFact(hash, readers, context, entry, limits, budget, format, v
|
|
|
1448
1495
|
if (entry.displacedGitlink) {
|
|
1449
1496
|
return missingObservation(absolutePath, relativePath, true);
|
|
1450
1497
|
}
|
|
1498
|
+
if (isNestedRepositoryEntry(relativePath)) {
|
|
1499
|
+
return appendNestedRepositoryFact(hash, readers, absolutePath, relativePath, limits, walk);
|
|
1500
|
+
}
|
|
1451
1501
|
if (mode === "160000") {
|
|
1452
|
-
return appendSubmoduleFact(hash, readers, absolutePath, relativePath, limits);
|
|
1502
|
+
return appendSubmoduleFact(hash, readers, absolutePath, relativePath, limits, walk);
|
|
1453
1503
|
}
|
|
1454
1504
|
let stat;
|
|
1455
1505
|
try {
|
|
@@ -1460,7 +1510,7 @@ function appendPathFact(hash, readers, context, entry, limits, budget, format, v
|
|
|
1460
1510
|
if (tracked && stat.isDirectory && !stat.isSymbolicLink) {
|
|
1461
1511
|
return missingObservation(absolutePath, relativePath, true);
|
|
1462
1512
|
}
|
|
1463
|
-
return stat.isSymbolicLink ? appendSymlinkFact(hash, readers, absolutePath, relativePath, stat, limits,
|
|
1513
|
+
return stat.isSymbolicLink ? appendSymlinkFact(hash, readers, absolutePath, relativePath, stat, limits, walk, format, tracked) : appendRegularFact(hash, readers, absolutePath, relativePath, stat, limits, walk, format, tracked);
|
|
1464
1514
|
}
|
|
1465
1515
|
function listWorktreePaths(runner, context, limits) {
|
|
1466
1516
|
const staged = runCommand(runner, STAGE_LIST_ARGS, context.commandDirectory, limits);
|
|
@@ -1483,16 +1533,34 @@ var UNSTABLE = {
|
|
|
1483
1533
|
status: "error",
|
|
1484
1534
|
reasonCode: "worktree-unstable"
|
|
1485
1535
|
};
|
|
1486
|
-
|
|
1536
|
+
var ROOT_MOVED = {
|
|
1537
|
+
status: "error",
|
|
1538
|
+
reasonCode: "target-unavailable"
|
|
1539
|
+
};
|
|
1540
|
+
function verifyGitlinkUnchanged(readers, limits, { absolutePath, record, gitlinkState, walked }) {
|
|
1541
|
+
if (walked)
|
|
1542
|
+
return verifyCheckoutUnchanged(readers, limits, absolutePath, walked);
|
|
1487
1543
|
const fresh = inspectGitlink(readers, absolutePath, limits);
|
|
1488
1544
|
if (fresh.status === "error") {
|
|
1489
1545
|
return fresh.reasonCode === "file-read-failed" ? UNSTABLE : fresh;
|
|
1490
1546
|
}
|
|
1491
|
-
if (fresh.status === "absent")
|
|
1547
|
+
if (fresh.status === "absent" || fresh.status !== gitlinkState) {
|
|
1492
1548
|
return UNSTABLE;
|
|
1549
|
+
}
|
|
1493
1550
|
const id = fresh.status === "initialized" ? fresh.id : undefined;
|
|
1494
1551
|
return id === record.id ? { status: "ok" } : UNSTABLE;
|
|
1495
1552
|
}
|
|
1553
|
+
function verifyCheckoutUnchanged(readers, limits, absolutePath, walked) {
|
|
1554
|
+
for (const target of [absolutePath, path5.join(absolutePath, ".git")]) {
|
|
1555
|
+
try {
|
|
1556
|
+
readers.statReader(target);
|
|
1557
|
+
} catch (error) {
|
|
1558
|
+
return hasErrorCode(error, "ENOENT", "ENOTDIR") ? UNSTABLE : { status: "error", reasonCode: "file-read-failed" };
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
const result = runFinalPass(readers, limits, walked.pass, false);
|
|
1562
|
+
return result.status === "error" && (result.reasonCode === "command-failed" || result.reasonCode === "file-read-failed") ? UNSTABLE : result;
|
|
1563
|
+
}
|
|
1496
1564
|
function verifyObservationUnchanged(readers, limits, observation) {
|
|
1497
1565
|
const { absolutePath, record, stat } = observation;
|
|
1498
1566
|
if (record.kind === "gitlink") {
|
|
@@ -1535,17 +1603,18 @@ function verifyIgnoreSourcesUnchanged(runner, context, limits, first) {
|
|
|
1535
1603
|
return fresh;
|
|
1536
1604
|
return sameIgnoreSources(first.ignoreSources, fresh.facts) ? { status: "ok" } : UNSTABLE;
|
|
1537
1605
|
}
|
|
1538
|
-
function verifyAnchorUnchanged(readers, context, limits, head) {
|
|
1606
|
+
function verifyAnchorUnchanged(readers, context, limits, head, rootMoveIsFatal) {
|
|
1539
1607
|
const anchor = readRepositoryAnchor(readers.runner, context.commandDirectory, limits, readers.realPath);
|
|
1540
1608
|
if (anchor.status === "error")
|
|
1541
1609
|
return anchor;
|
|
1542
1610
|
const { pin } = context;
|
|
1543
1611
|
if (anchor.toplevel !== pin.targetRoot || anchor.gitDir !== pin.gitDir || anchor.commonDir !== pin.commonDir) {
|
|
1544
|
-
return
|
|
1612
|
+
return rootMoveIsFatal ? ROOT_MOVED : UNSTABLE;
|
|
1545
1613
|
}
|
|
1546
1614
|
return anchor.head === head ? { status: "ok" } : UNSTABLE;
|
|
1547
1615
|
}
|
|
1548
|
-
function runFinalPass(readers,
|
|
1616
|
+
function runFinalPass(readers, limits, pass, rootMoveIsFatal) {
|
|
1617
|
+
const { context, head, first, observations, verifiedDirectories } = pass;
|
|
1549
1618
|
const sources = verifyIgnoreSourcesUnchanged(readers.runner, context, limits, first);
|
|
1550
1619
|
if (sources.status === "error")
|
|
1551
1620
|
return sources;
|
|
@@ -1558,7 +1627,7 @@ function runFinalPass(readers, context, limits, head, first, observations, verif
|
|
|
1558
1627
|
const listings = verifyListingsUnchanged(readers.runner, context, limits, first);
|
|
1559
1628
|
if (listings.status === "error")
|
|
1560
1629
|
return listings;
|
|
1561
|
-
return verifyAnchorUnchanged(readers, context, limits, head);
|
|
1630
|
+
return verifyAnchorUnchanged(readers, context, limits, head, rootMoveIsFatal);
|
|
1562
1631
|
}
|
|
1563
1632
|
function readIgnoreSourceFile(label, filePath) {
|
|
1564
1633
|
const absent = {
|
|
@@ -1714,7 +1783,7 @@ function findDisplacedGitlinks(sortedPaths, indexModes, headTree) {
|
|
|
1714
1783
|
const candidates = sortedPaths.filter((entry) => !indexModes.has(entry) && headTree.get(entry)?.mode === "160000");
|
|
1715
1784
|
return new Set(candidates.filter((entry) => hasPathBeneath(sortedPaths, entry)));
|
|
1716
1785
|
}
|
|
1717
|
-
function
|
|
1786
|
+
function readRepositoryFirstPass(readers, context, head, limits, walk) {
|
|
1718
1787
|
const { runner } = readers;
|
|
1719
1788
|
const sources = readIgnoreSources(runner, context, limits);
|
|
1720
1789
|
if (sources.status === "error")
|
|
@@ -1733,18 +1802,20 @@ function readWorktreeSnapshot(readers, context, head, limits) {
|
|
|
1733
1802
|
return { status: "error", reasonCode: "file-read-failed" };
|
|
1734
1803
|
}
|
|
1735
1804
|
const { paths } = listings;
|
|
1736
|
-
if (paths.length > limits.maxFiles) {
|
|
1805
|
+
if (walk.files + paths.length > limits.maxFiles) {
|
|
1737
1806
|
return { status: "error", reasonCode: "file-limit" };
|
|
1738
1807
|
}
|
|
1808
|
+
walk.files += paths.length;
|
|
1739
1809
|
const modes = new Map(listings.stageEntries.map((entry) => [entry.relativePath, entry.mode]));
|
|
1740
1810
|
const modeOf = (relativePath) => modes.get(relativePath) ?? tree.entries.get(relativePath)?.mode ?? "";
|
|
1741
1811
|
const displacedGitlinks = findDisplacedGitlinks(paths, modes, tree.entries);
|
|
1742
|
-
|
|
1812
|
+
const gitlinkCount = paths.filter((entry) => isNestedRepositoryEntry(entry) || modeOf(entry) === "160000" && !displacedGitlinks.has(entry)).length;
|
|
1813
|
+
if (walk.gitlinks + gitlinkCount > limits.maxGitlinks) {
|
|
1743
1814
|
return { status: "error", reasonCode: "file-limit" };
|
|
1744
1815
|
}
|
|
1816
|
+
walk.gitlinks += gitlinkCount;
|
|
1745
1817
|
const hash = createHash("sha256");
|
|
1746
1818
|
hash.update(WORKTREE_DIGEST_DOMAIN);
|
|
1747
|
-
const budget = { bytes: 0 };
|
|
1748
1819
|
const observations = [];
|
|
1749
1820
|
const verifiedDirectories = new Set;
|
|
1750
1821
|
for (const relativePath of paths) {
|
|
@@ -1752,21 +1823,44 @@ function readWorktreeSnapshot(readers, context, head, limits) {
|
|
|
1752
1823
|
relativePath,
|
|
1753
1824
|
mode: modeOf(relativePath),
|
|
1754
1825
|
...displacedGitlinks.has(relativePath) ? { displacedGitlink: true } : {}
|
|
1755
|
-
}, limits,
|
|
1826
|
+
}, limits, walk, format, verifiedDirectories);
|
|
1756
1827
|
if (result.status === "error")
|
|
1757
1828
|
return result;
|
|
1758
1829
|
observations.push(result.observation);
|
|
1759
1830
|
}
|
|
1760
1831
|
for (const fact of sources.facts)
|
|
1761
1832
|
hashIgnoreSource(hash, fact);
|
|
1762
|
-
const stable = runFinalPass(readers, context, limits, head, { ...listings.first, ignoreSources: sources.facts }, observations, verifiedDirectories);
|
|
1763
|
-
if (stable.status === "error")
|
|
1764
|
-
return stable;
|
|
1765
1833
|
return {
|
|
1766
1834
|
status: "ok",
|
|
1767
1835
|
digest: hash.digest("hex"),
|
|
1768
1836
|
records: observations.map((observation) => observation.record),
|
|
1769
|
-
headTree: tree.entries
|
|
1837
|
+
headTree: tree.entries,
|
|
1838
|
+
gitlinkStates: new Map(observations.flatMap(({ record, gitlinkState }) => gitlinkState ? [[record.path, gitlinkState]] : [])),
|
|
1839
|
+
pass: {
|
|
1840
|
+
context,
|
|
1841
|
+
head,
|
|
1842
|
+
first: { ...listings.first, ignoreSources: sources.facts },
|
|
1843
|
+
observations,
|
|
1844
|
+
verifiedDirectories
|
|
1845
|
+
}
|
|
1846
|
+
};
|
|
1847
|
+
}
|
|
1848
|
+
function isRepositoryClosed(snapshot) {
|
|
1849
|
+
return deriveCommitClosure(snapshot.records, snapshot.headTree, snapshot.pass.head, snapshot.gitlinkStates) && snapshot.pass.observations.every(({ walked }) => walked === undefined || isRepositoryClosed(walked));
|
|
1850
|
+
}
|
|
1851
|
+
function readWorktreeSnapshot(readers, context, head, limits, walk) {
|
|
1852
|
+
const snapshot = readRepositoryFirstPass(readers, context, head, limits, walk);
|
|
1853
|
+
if (snapshot.status === "error")
|
|
1854
|
+
return snapshot;
|
|
1855
|
+
const stable = runFinalPass(readers, limits, snapshot.pass, true);
|
|
1856
|
+
if (stable.status === "error")
|
|
1857
|
+
return stable;
|
|
1858
|
+
return {
|
|
1859
|
+
status: "ok",
|
|
1860
|
+
digest: snapshot.digest,
|
|
1861
|
+
records: snapshot.records,
|
|
1862
|
+
headTree: snapshot.headTree,
|
|
1863
|
+
commitClosure: isRepositoryClosed(snapshot)
|
|
1770
1864
|
};
|
|
1771
1865
|
}
|
|
1772
1866
|
function recordKindForTreeMode(mode) {
|
|
@@ -1779,15 +1873,18 @@ function recordKindForTreeMode(mode) {
|
|
|
1779
1873
|
function recordMatchesTreeEntry(record, entry) {
|
|
1780
1874
|
return record.id !== undefined && record.id === entry.id && record.mode === entry.mode && record.kind === recordKindForTreeMode(entry.mode);
|
|
1781
1875
|
}
|
|
1782
|
-
function deriveCommitClosure(records, headTree, head) {
|
|
1876
|
+
function deriveCommitClosure(records, headTree, head, gitlinkStates) {
|
|
1783
1877
|
if (head === undefined)
|
|
1784
1878
|
return false;
|
|
1785
1879
|
let matched = 0;
|
|
1786
1880
|
for (const record of records) {
|
|
1787
1881
|
const entry = headTree.get(record.path);
|
|
1788
|
-
if (entry === undefined
|
|
1882
|
+
if (entry === undefined)
|
|
1883
|
+
return false;
|
|
1884
|
+
const state = gitlinkStates.get(record.path);
|
|
1885
|
+
const matches = state === "uninitialized" ? entry.mode === "160000" : recordMatchesTreeEntry(record, entry);
|
|
1886
|
+
if (!matches)
|
|
1789
1887
|
return false;
|
|
1790
|
-
}
|
|
1791
1888
|
matched += 1;
|
|
1792
1889
|
}
|
|
1793
1890
|
return matched === headTree.size;
|
|
@@ -2025,15 +2122,13 @@ function createOpencodeOperationObserver(options) {
|
|
|
2025
2122
|
return { status: "unavailable", reasonCode: "target-unavailable" };
|
|
2026
2123
|
}
|
|
2027
2124
|
const context = {
|
|
2028
|
-
|
|
2029
|
-
worktreeRoot: anchor.toplevel,
|
|
2030
|
-
infoExcludePath: anchor.infoExcludePath,
|
|
2125
|
+
...contextFromAnchor(targetDirectory, anchor),
|
|
2031
2126
|
pin: rootPinResult.pin
|
|
2032
2127
|
};
|
|
2033
2128
|
const repository = readRevision(runner, context, anchor.head, anchor.insideWorkTree, limits);
|
|
2034
2129
|
if (repository.status === "error")
|
|
2035
2130
|
return unavailable(repository);
|
|
2036
|
-
const worktree = readWorktreeSnapshot(readers, context, anchor.head, limits);
|
|
2131
|
+
const worktree = readWorktreeSnapshot(readers, context, anchor.head, limits, createWalkState());
|
|
2037
2132
|
if (worktree.status === "error")
|
|
2038
2133
|
return unavailable(worktree);
|
|
2039
2134
|
return {
|
|
@@ -2042,7 +2137,7 @@ function createOpencodeOperationObserver(options) {
|
|
|
2042
2137
|
targetDigest,
|
|
2043
2138
|
repositoryRevisionDigest: repository.digest,
|
|
2044
2139
|
worktreeRevisionDigest: worktree.digest,
|
|
2045
|
-
commitClosure:
|
|
2140
|
+
commitClosure: worktree.commitClosure
|
|
2046
2141
|
}
|
|
2047
2142
|
};
|
|
2048
2143
|
},
|
|
@@ -132,6 +132,13 @@ export declare function validateRegisteredWorktree(candidateDirectory: string, p
|
|
|
132
132
|
* @internal Exported for the framing test only.
|
|
133
133
|
*/
|
|
134
134
|
export declare function hashField(hash: ReturnType<typeof createHash>, field: string | Uint8Array): void;
|
|
135
|
+
/**
|
|
136
|
+
* What a gitlink path holds on disk: nothing checked out (`uninitialized`), a
|
|
137
|
+
* checkout with no commit yet (`unborn`), or a checkout at a commit.
|
|
138
|
+
*
|
|
139
|
+
* @internal Exported for tests only.
|
|
140
|
+
*/
|
|
141
|
+
export type GitlinkState = 'uninitialized' | 'unborn' | 'initialized';
|
|
135
142
|
export interface HeadTreeEntry {
|
|
136
143
|
readonly mode: string;
|
|
137
144
|
readonly id: string;
|
|
@@ -155,6 +162,7 @@ export declare function readWorktreeRecords(targetDirectory: string, options?: O
|
|
|
155
162
|
digest: string;
|
|
156
163
|
records: readonly WorktreeRecord[];
|
|
157
164
|
headTree: ReadonlyMap<string, HeadTreeEntry>;
|
|
165
|
+
commitClosure: boolean;
|
|
158
166
|
} | {
|
|
159
167
|
status: 'error';
|
|
160
168
|
reasonCode: OperationObserverReasonCode;
|
package/package.json
CHANGED
|
@@ -114,4 +114,4 @@ The bootstrap inlines the active harness profile naming the exact mechanisms for
|
|
|
114
114
|
|
|
115
115
|
When a mechanism is unavailable, present numbered options in chat and wait for questions, maintain a visible list for task tracking, and dispatch delegation sequentially or do the work inline.
|
|
116
116
|
|
|
117
|
-
Check the workflow guard availability once per execution unit. Guard state is per session; a child session starts `inactive`. `inactive` (reason `no-active-epoch`) means no guarded workflow has started in this session. It is not unavailable and not terminal: load a guarded skill to begin, and do not call `systematic_workflow_start` or `systematic_workflow_complete` before one is active. A completion rejected with `readback-timeout` is retryable: call `systematic_workflow_complete` again at most twice, then report it to the user. Probes listed in `unconfirmedReadbacks` on status output (`local`, `pinned`, or an operation name) are unverified until a later status call confirms them. A completion rejected with `snapshot-blocked` or `stale-receipt` is not terminal. For `snapshot-blocked`, read `blockReason` from the rejection or `snapshotBlock.reasonCode` from status, fix that cause in the worktree without deleting or hiding user files unless the user agrees, and call status to confirm the block is gone (when the rejection names `blockTarget: parent-checkout`, fix the parent checkout and retry completion instead). Operations run while blocked leave no receipts: rerun stale or missing operations, checking remote state before redoing a push or PR, then complete. If the same reason remains after one fix, report it to the user, who can disable the guard through `systematic_workflow_control`. A call the guard skipped or sealed after a timeout has already run: for a local call check the worktree state, for a push or PR creation check remote state (the upstream ref or the open PR), and rerun only if its effect is missing. After a rejected push, check remote state, fix the cause and retry (a first push needs `git push -u`); never force-push or delete a remote ref without the user's approval. If a push may have landed but left no receipt and later pushes are rejected as `resource-mismatch`, report it to the user. A verification that overlapped another local call is not receipted; rerun it alone once every local call from that request has returned. If the guard reports `unavailable` or `guard-unavailable`, treat it as terminal for that unit: do not retry `systematic_workflow_start` or `systematic_workflow_complete`. Use the documented unguarded fallback only when authorized, and report the unavailable state once.
|
|
117
|
+
Check the workflow guard availability once per execution unit. Guard state is per session; a child session starts `inactive`. `inactive` (reason `no-active-epoch`) means no guarded workflow has started in this session. It is not unavailable and not terminal: load a guarded skill to begin, and do not call `systematic_workflow_start` or `systematic_workflow_complete` before one is active. A completion rejected with `readback-timeout` is retryable: call `systematic_workflow_complete` again at most twice, then report it to the user. Probes listed in `unconfirmedReadbacks` on status output (`local`, `pinned`, or an operation name) are unverified until a later status call confirms them. A completion rejected with `snapshot-blocked` or `stale-receipt` is not terminal. For `snapshot-blocked`, read `blockReason` from the rejection or `snapshotBlock.reasonCode` from status, fix that cause in the worktree without deleting or hiding user files unless the user agrees, and call status to confirm the block is gone (when the rejection names `blockTarget: parent-checkout`, fix the parent checkout and retry completion instead). Files inside submodules and nested repositories count toward the snapshot limits. Operations run while blocked leave no receipts: rerun stale or missing operations, checking remote state before redoing a push or PR, then complete. If the same reason remains after one fix, report it to the user, who can disable the guard through `systematic_workflow_control`. A call the guard skipped or sealed after a timeout has already run: for a local call check the worktree state, for a push or PR creation check remote state (the upstream ref or the open PR), and rerun only if its effect is missing. After a rejected push, check remote state, fix the cause and retry (a first push needs `git push -u`); never force-push or delete a remote ref without the user's approval. If a push may have landed but left no receipt and later pushes are rejected as `resource-mismatch`, report it to the user. A verification that overlapped another local call is not receipted; rerun it alone once every local call from that request has returned. If the guard reports `unavailable` or `guard-unavailable`, treat it as terminal for that unit: do not retry `systematic_workflow_start` or `systematic_workflow_complete`. Use the documented unguarded fallback only when authorized, and report the unavailable state once.
|