@fro.bot/systematic 3.22.6 → 3.23.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/dist/cli.js CHANGED
@@ -34,7 +34,7 @@ import {
34
34
  findCommandsInDir,
35
35
  findSkillsInDir,
36
36
  discoverSkills
37
- } from "./index-aaygsm67.js";
37
+ } from "./index-pdbqekxp.js";
38
38
  var __defProp = Object.defineProperty;
39
39
  var __returnValue = (v) => v;
40
40
  function __exportSetter(name, newValue) {
@@ -7512,16 +7512,16 @@ var workflowGuardModeSchema = _enum([
7512
7512
  "disabled"
7513
7513
  ]);
7514
7514
  var WorkflowGuardSchema = object({
7515
- mode: workflowGuardModeSchema.default("observe").meta({
7516
- description: "Workflow guard mode",
7515
+ mode: workflowGuardModeSchema.default("disabled").meta({
7516
+ description: "Workflow guard mode. The guard is off by default (`disabled`); set `observe` or `protected` to turn it on.",
7517
7517
  examples: ["observe", "protected", "disabled"]
7518
7518
  }),
7519
7519
  debug: boolean().default(false).meta({
7520
7520
  description: "Enable workflow guard debugging",
7521
7521
  examples: [false, true]
7522
7522
  })
7523
- }).strict().default({ mode: "observe", debug: false }).meta({
7524
- description: "Workflow guard configuration",
7523
+ }).strict().default({ mode: "disabled", debug: false }).meta({
7524
+ description: "Workflow guard configuration. The guard is off by default; `mode: observe` or `mode: protected` turns it on.",
7525
7525
  examples: [{ mode: "observe", debug: false }]
7526
7526
  });
7527
7527
  var colorSchema = union([
@@ -8188,7 +8188,7 @@ var DEFAULT_CONFIG = {
8188
8188
  enabled: true
8189
8189
  },
8190
8190
  workflow_guard: {
8191
- mode: "observe",
8191
+ mode: "disabled",
8192
8192
  debug: false
8193
8193
  },
8194
8194
  agents: {},
package/dist/index.js CHANGED
@@ -19,7 +19,7 @@ import {
19
19
  extractCommandFrontmatter,
20
20
  findSkillsInDir,
21
21
  discoverSkills
22
- } from "./index-aaygsm67.js";
22
+ } from "./index-pdbqekxp.js";
23
23
 
24
24
  // src/index.ts
25
25
  import { createHash as createHash4 } from "crypto";
@@ -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:v3\x00";
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 readInitializedGitlink(readers, absolutePath, limits) {
1294
- const result = runCommand(readers.runner, ["rev-parse", "--show-toplevel", "--verify", "-q", "HEAD"], absolutePath, limits);
1295
- if (result.status === "error")
1296
- return result;
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
- const reported = canonicalPath(toplevel, readers.realPath);
1307
- return submodule !== undefined && submodule === reported ? { status: "initialized", id: id.toLowerCase() } : { status: "error", reasonCode: "file-read-failed" };
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 readInitializedGitlink(readers, absolutePath, limits);
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, id ?? "uninitialized");
1346
- return observed(absolutePath, { path: relativePath, kind: "gitlink", mode: "160000", id }, undefined);
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);
1352
+ }
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;
1347
1394
  }
1348
- function appendSymlinkFact(hash, readers, absolutePath, relativePath, stat, limits, budget, format, tracked) {
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 = budget.bytes + target.byteLength;
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
- budget.bytes = nextBytes;
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, budget, format, tracked) {
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 - budget.bytes;
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
- budget.bytes += content.byteLength;
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, budget, format, verifiedDirectories) {
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, budget, format, tracked) : appendRegularFact(hash, readers, absolutePath, relativePath, stat, limits, budget, format, tracked);
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
- function verifyGitlinkUnchanged(readers, limits, { absolutePath, record }) {
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 { status: "error", reasonCode: "target-unavailable" };
1612
+ return rootMoveIsFatal ? ROOT_MOVED : UNSTABLE;
1545
1613
  }
1546
1614
  return anchor.head === head ? { status: "ok" } : UNSTABLE;
1547
1615
  }
1548
- function runFinalPass(readers, context, limits, head, first, observations, verifiedDirectories) {
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 readWorktreeSnapshot(readers, context, head, limits) {
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
- if (paths.filter((entry) => modeOf(entry) === "160000" && !displacedGitlinks.has(entry)).length > limits.maxGitlinks) {
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, budget, format, verifiedDirectories);
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 || !recordMatchesTreeEntry(record, entry)) {
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
- commandDirectory: targetDirectory,
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: deriveCommitClosure(worktree.records, worktree.headTree, anchor.head)
2140
+ commitClosure: worktree.commitClosure
2046
2141
  }
2047
2142
  };
2048
2143
  },
@@ -10992,6 +11087,7 @@ function isWorkflowGuardBlockedError(value) {
10992
11087
  return false;
10993
11088
  return typeof candidate.reasonCode === "string" && REASON_CODES.has(candidate.reasonCode);
10994
11089
  }
11090
+ var WORKFLOW_GUARD_GUIDANCE = `In this OpenCode session the workflow guard is on. 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. \`disabled\` means the user turned the guard off; do not call the workflow tools.`;
10995
11091
  function defaultTargetObserver(targetDirectory) {
10996
11092
  return createOpencodeOperationObserver({ targetDirectory });
10997
11093
  }
@@ -12926,9 +13022,21 @@ function createSessionRuntime(options, operationObservers, recoveredOperationCon
12926
13022
  terminalCompletes.set(callDigest, terminal);
12927
13023
  writeTerminalCompletionResult(output, terminal, target, terminal.title);
12928
13024
  }
13025
+ function writeDisabledBlockedResult(callDigest, output, target) {
13026
+ const terminal = {
13027
+ ...target ? { target } : {},
13028
+ status: "rejected",
13029
+ reasonCode: "disabled",
13030
+ title: "Workflow transition rejected"
13031
+ };
13032
+ terminalCompletes.set(callDigest, terminal);
13033
+ writeTerminalCompletionResult(output, terminal, target, terminal.title);
13034
+ }
12929
13035
  function writeBlockedCompleteResult(callDigest, output, blocked) {
12930
13036
  if (blocked?.reasonCode === "no-active-epoch") {
12931
13037
  writeNoEpochBlockedResult(callDigest, output, blocked.target);
13038
+ } else if (blocked?.reasonCode === "disabled") {
13039
+ writeDisabledBlockedResult(callDigest, output, blocked.target);
12932
13040
  }
12933
13041
  }
12934
13042
  function writeAbandonedCompletionResult(output, target, reasonCode) {
@@ -13701,6 +13809,10 @@ function createSessionRuntime(options, operationObservers, recoveredOperationCon
13701
13809
  const callDigest = digestCall(ledger, host.callID);
13702
13810
  const pending = pendingStarts.get(callDigest);
13703
13811
  pendingStarts.delete(callDigest);
13812
+ if (options.config.mode === "disabled") {
13813
+ writeStartResult(output, { status: "rejected", reasonCode: "disabled" });
13814
+ return;
13815
+ }
13704
13816
  if (!pending) {
13705
13817
  markUnavailable(afterCause("call-lifecycle-mismatch"));
13706
13818
  return;
@@ -13970,7 +14082,11 @@ function createSessionRuntime(options, operationObservers, recoveredOperationCon
13970
14082
  markUnavailable(afterCause("call-lifecycle-mismatch"));
13971
14083
  writeAbandonedCompletionResult(output, pending.target, "invalid-transition");
13972
14084
  }
13973
- function finishUnreplayableComplete(finalTarget, output) {
14085
+ function finishUnreplayableComplete(callDigest, finalTarget, output) {
14086
+ if (options.config.mode === "disabled") {
14087
+ writeDisabledBlockedResult(callDigest, output, finalTarget);
14088
+ return;
14089
+ }
13974
14090
  markUnavailable(afterCause("call-lifecycle-mismatch"));
13975
14091
  writeAbandonedCompletionResult(output, finalTarget, "guard-unavailable");
13976
14092
  }
@@ -14030,10 +14146,19 @@ function createSessionRuntime(options, operationObservers, recoveredOperationCon
14030
14146
  return currentSnapshotBlock()?.reasonCode;
14031
14147
  }
14032
14148
  const completionFailureCause = (reasonCode) => observerReadbackFailedCause(reasonCode, "complete-readback");
14149
+ function finishDisabledComplete(callDigest, finalTarget, output) {
14150
+ const target = terminalCompletes.get(callDigest)?.target ?? blockedCompletes.get(callDigest)?.target ?? finalTarget;
14151
+ blockedCompletes.delete(callDigest);
14152
+ writeDisabledBlockedResult(callDigest, output, target);
14153
+ }
14033
14154
  async function finishComplete(host, output) {
14034
14155
  const callDigest = digestCall(ledger, host.callID);
14035
14156
  const pending = pendingCompletes.get(callDigest);
14036
14157
  const finalTarget = normalizeTarget(host.args);
14158
+ if (options.config.mode === "disabled") {
14159
+ finishDisabledComplete(callDigest, finalTarget, output);
14160
+ return;
14161
+ }
14037
14162
  if (pending && (!finalTarget || finalTarget !== pending.target)) {
14038
14163
  finishMismatchedTarget(callDigest, pending, output);
14039
14164
  return;
@@ -14041,7 +14166,7 @@ function createSessionRuntime(options, operationObservers, recoveredOperationCon
14041
14166
  if (!pending) {
14042
14167
  if (replayTerminalComplete(callDigest, finalTarget, output))
14043
14168
  return;
14044
- finishUnreplayableComplete(finalTarget, output);
14169
+ finishUnreplayableComplete(callDigest, finalTarget, output);
14045
14170
  return;
14046
14171
  }
14047
14172
  const generation = unitStartGeneration;
@@ -14547,6 +14672,12 @@ function unavailableToolResult() {
14547
14672
  reasonCode: "guard-unavailable"
14548
14673
  });
14549
14674
  }
14675
+ function disabledRejectionResult(title) {
14676
+ return {
14677
+ title,
14678
+ output: JSON.stringify({ status: "rejected", reasonCode: "disabled" })
14679
+ };
14680
+ }
14550
14681
  function makeWorkflowTool(description, args2, getRuntime, execute) {
14551
14682
  return {
14552
14683
  description,
@@ -14596,7 +14727,16 @@ function makeWorkflowTool(description, args2, getRuntime, execute) {
14596
14727
  }
14597
14728
  };
14598
14729
  }
14730
+ function assertDisabledGuardHasNoDependencies(options) {
14731
+ if (options.config.mode !== "disabled")
14732
+ return;
14733
+ const supplied = ["observer", "hostReadback", "classifier"].filter((name2) => options[name2] !== undefined);
14734
+ if (supplied.length === 0)
14735
+ return;
14736
+ throw new TypeError(`A disabled workflow guard must be built without ${supplied.join(", ")}`);
14737
+ }
14599
14738
  function createOpencodeWorkflowGuard(options) {
14739
+ assertDisabledGuardHasNoDependencies(options);
14600
14740
  const sessions = new Map;
14601
14741
  const operationObservers = new Map;
14602
14742
  const recoveredOperationContexts = new Map;
@@ -14617,7 +14757,7 @@ function createOpencodeWorkflowGuard(options) {
14617
14757
  systematic_workflow_start: makeWorkflowTool("Request the start of a guarded workflow unit.", startToolShape, sessionRuntimeFor, (_runtime, input) => startToolSchema.safeParse(input).success ? {
14618
14758
  title: "Workflow guard start pending",
14619
14759
  output: JSON.stringify({ status: "pending", operation: "start" })
14620
- } : {
14760
+ } : options.config.mode === "disabled" ? disabledRejectionResult("Workflow unit rejected") : {
14621
14761
  title: "Workflow guard unavailable",
14622
14762
  output: unavailableToolResult()
14623
14763
  }),
@@ -14634,7 +14774,7 @@ function createOpencodeWorkflowGuard(options) {
14634
14774
  status: "pending",
14635
14775
  operation: "complete"
14636
14776
  })
14637
- } : {
14777
+ } : options.config.mode === "disabled" ? disabledRejectionResult("Workflow transition rejected") : {
14638
14778
  title: "Workflow guard unavailable",
14639
14779
  output: unavailableToolResult()
14640
14780
  }),
@@ -15021,28 +15161,64 @@ var getPackageVersion = () => {
15021
15161
  return "unknown";
15022
15162
  }
15023
15163
  };
15024
- var initializePlugin = async ({
15164
+ var DISABLED_GUARD_IDENTITY = "0".repeat(64);
15165
+ var createHostReadback = ({
15025
15166
  client,
15026
- directory,
15027
- worktree
15167
+ directory
15028
15168
  }) => {
15029
- let hasLoggedInit = false;
15030
- let userOutputLimitSet = false;
15031
- const skillOutputStore = createSkillOutputStore();
15032
- const config = loadConfig(directory);
15033
- const bootstrapContent = getBootstrapContent(config, {
15034
- bundledSkillsDir,
15035
- profileBlock: readHarnessProfile(bundledSkillsDir, "opencode") ?? undefined
15036
- });
15037
- const configHandler = createConfigHandler({
15038
- directory,
15039
- bundledSkillsDir,
15040
- bundledAgentsDir,
15041
- bundledCommandsDir
15042
- });
15043
- const observer = createOpencodeOperationObserver({
15044
- targetDirectory: typeof worktree === "string" ? worktree : directory
15045
- });
15169
+ const readMessages = async (sessionID) => {
15170
+ const messages = client.session.messages.bind(client.session);
15171
+ return messages({ path: { id: sessionID }, query: { directory } });
15172
+ };
15173
+ return {
15174
+ readSessionParts: async (sessionID) => {
15175
+ const response = await readMessages(sessionID);
15176
+ return Array.isArray(response.data) ? response.data : [];
15177
+ },
15178
+ readSessionPartsStrict: async (sessionID) => {
15179
+ const response = await readMessages(sessionID);
15180
+ if (response.error !== undefined && response.error !== null) {
15181
+ throw new Error("session history read failed");
15182
+ }
15183
+ if (!Array.isArray(response.data)) {
15184
+ throw new Error("session history read returned malformed data");
15185
+ }
15186
+ return response.data;
15187
+ },
15188
+ listChildren: async (sessionID) => {
15189
+ const children = client.session.children.bind(client.session);
15190
+ const response = await children({
15191
+ path: { id: sessionID },
15192
+ query: { directory }
15193
+ });
15194
+ if (!Array.isArray(response.data))
15195
+ return [];
15196
+ return response.data.flatMap((entry) => {
15197
+ if (typeof entry !== "object" || entry === null || typeof entry.id !== "string") {
15198
+ return [];
15199
+ }
15200
+ return [{ sessionId: entry.id, parentID: entry.parentID }];
15201
+ });
15202
+ }
15203
+ };
15204
+ };
15205
+ var workflowGuardOptions = async ({ client, directory, worktree }, config, guardEnabled) => {
15206
+ const targetDirectory = typeof worktree === "string" ? worktree : directory;
15207
+ const base = {
15208
+ config: config.workflow_guard,
15209
+ registrationIdentity: registrationSourceIdentity,
15210
+ targetDirectory,
15211
+ sessionLocation: directory
15212
+ };
15213
+ if (!guardEnabled) {
15214
+ return {
15215
+ ...base,
15216
+ workspaceIdentity: DISABLED_GUARD_IDENTITY,
15217
+ repositoryIdentity: DISABLED_GUARD_IDENTITY,
15218
+ worktreeIdentity: DISABLED_GUARD_IDENTITY
15219
+ };
15220
+ }
15221
+ const observer = createOpencodeOperationObserver({ targetDirectory });
15046
15222
  let initialSnapshot;
15047
15223
  try {
15048
15224
  initialSnapshot = await observer.snapshot();
@@ -15057,54 +15233,44 @@ var initializePlugin = async ({
15057
15233
  repositoryRevisionDigest: observer.targetDigest,
15058
15234
  worktreeRevisionDigest: observer.targetDigest
15059
15235
  };
15060
- const workflowGuard = createOpencodeWorkflowGuard({
15061
- config: config.workflow_guard,
15236
+ return {
15237
+ ...base,
15062
15238
  workspaceIdentity: initialIdentities.targetDigest,
15063
15239
  repositoryIdentity: initialIdentities.repositoryRevisionDigest,
15064
15240
  worktreeIdentity: initialIdentities.worktreeRevisionDigest,
15065
- registrationIdentity: registrationSourceIdentity,
15066
- targetDirectory: typeof worktree === "string" ? worktree : directory,
15067
- sessionLocation: directory,
15068
15241
  observer,
15069
15242
  classifier: createReceiptClassifier(),
15070
- hostReadback: (() => {
15071
- const readMessages = async (sessionID) => {
15072
- const messages = client.session.messages.bind(client.session);
15073
- return messages({ path: { id: sessionID }, query: { directory } });
15074
- };
15075
- return {
15076
- readSessionParts: async (sessionID) => {
15077
- const response = await readMessages(sessionID);
15078
- return Array.isArray(response.data) ? response.data : [];
15079
- },
15080
- readSessionPartsStrict: async (sessionID) => {
15081
- const response = await readMessages(sessionID);
15082
- if (response.error !== undefined && response.error !== null) {
15083
- throw new Error("session history read failed");
15084
- }
15085
- if (!Array.isArray(response.data)) {
15086
- throw new Error("session history read returned malformed data");
15087
- }
15088
- return response.data;
15089
- },
15090
- listChildren: async (sessionID) => {
15091
- const children = client.session.children.bind(client.session);
15092
- const response = await children({
15093
- path: { id: sessionID },
15094
- query: { directory }
15095
- });
15096
- if (!Array.isArray(response.data))
15097
- return [];
15098
- return response.data.flatMap((entry) => {
15099
- if (typeof entry !== "object" || entry === null || typeof entry.id !== "string") {
15100
- return [];
15101
- }
15102
- return [{ sessionId: entry.id, parentID: entry.parentID }];
15103
- });
15104
- }
15105
- };
15106
- })()
15243
+ hostReadback: createHostReadback({ client, directory })
15244
+ };
15245
+ };
15246
+ var composeProfileBlock = (harnessProfile, guardEnabled) => {
15247
+ const parts2 = [harnessProfile, guardEnabled ? WORKFLOW_GUARD_GUIDANCE : null];
15248
+ const present = parts2.filter((part) => part !== null);
15249
+ return present.length > 0 ? present.join(`
15250
+
15251
+ `) : undefined;
15252
+ };
15253
+ var initializePlugin = async ({
15254
+ client,
15255
+ directory,
15256
+ worktree
15257
+ }) => {
15258
+ let hasLoggedInit = false;
15259
+ let userOutputLimitSet = false;
15260
+ const skillOutputStore = createSkillOutputStore();
15261
+ const config = loadConfig(directory);
15262
+ const guardEnabled = config.workflow_guard.mode !== "disabled";
15263
+ const bootstrapContent = getBootstrapContent(config, {
15264
+ bundledSkillsDir,
15265
+ profileBlock: composeProfileBlock(readHarnessProfile(bundledSkillsDir, "opencode"), guardEnabled)
15266
+ });
15267
+ const configHandler = createConfigHandler({
15268
+ directory,
15269
+ bundledSkillsDir,
15270
+ bundledAgentsDir,
15271
+ bundledCommandsDir
15107
15272
  });
15273
+ const workflowGuard = createOpencodeWorkflowGuard(await workflowGuardOptions({ client, directory, worktree }, config, guardEnabled));
15108
15274
  const hooks = {
15109
15275
  config: async (incomingConfig) => {
15110
15276
  const configUnknown = incomingConfig;
@@ -15155,6 +15321,7 @@ var initializePlugin = async ({
15155
15321
  extra: {
15156
15322
  version: packageVersion,
15157
15323
  bootstrapEnabled: config.bootstrap.enabled,
15324
+ workflowGuardMode: config.workflow_guard.mode,
15158
15325
  disabledSkillsCount: config.disabled_skills.length,
15159
15326
  disabledAgentsCount: config.disabled_agents.length,
15160
15327
  disabledCommandsCount: config.disabled_commands.length
@@ -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;
@@ -15,6 +15,7 @@ export type WorkflowGuardBlockedError = Error & {
15
15
  };
16
16
  export declare function createWorkflowGuardBlockedError(reasonCode: WorkflowReasonCode): WorkflowGuardBlockedError;
17
17
  export declare function isWorkflowGuardBlockedError(value: unknown): value is WorkflowGuardBlockedError;
18
+ export declare const WORKFLOW_GUARD_GUIDANCE = "In this OpenCode session the workflow guard is on. 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. `disabled` means the user turned the guard off; do not call the workflow tools.";
18
19
  export interface OpencodeWorkflowGuardOptions {
19
20
  config: OpencodeWorkflowGuardConfig;
20
21
  workspaceIdentity: string;
package/dist/pi.js CHANGED
@@ -9453,16 +9453,16 @@ var workflowGuardModeSchema = _enum([
9453
9453
  "disabled"
9454
9454
  ]);
9455
9455
  var WorkflowGuardSchema = object({
9456
- mode: workflowGuardModeSchema.default("observe").meta({
9457
- description: "Workflow guard mode",
9456
+ mode: workflowGuardModeSchema.default("disabled").meta({
9457
+ description: "Workflow guard mode. The guard is off by default (`disabled`); set `observe` or `protected` to turn it on.",
9458
9458
  examples: ["observe", "protected", "disabled"]
9459
9459
  }),
9460
9460
  debug: boolean2().default(false).meta({
9461
9461
  description: "Enable workflow guard debugging",
9462
9462
  examples: [false, true]
9463
9463
  })
9464
- }).strict().default({ mode: "observe", debug: false }).meta({
9465
- description: "Workflow guard configuration",
9464
+ }).strict().default({ mode: "disabled", debug: false }).meta({
9465
+ description: "Workflow guard configuration. The guard is off by default; `mode: observe` or `mode: protected` turns it on.",
9466
9466
  examples: [{ mode: "observe", debug: false }]
9467
9467
  });
9468
9468
  var colorSchema = union([
@@ -10021,7 +10021,7 @@ var DEFAULT_CONFIG = {
10021
10021
  enabled: true
10022
10022
  },
10023
10023
  workflow_guard: {
10024
- mode: "observe",
10024
+ mode: "disabled",
10025
10025
  debug: false
10026
10026
  },
10027
10027
  agents: {},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fro.bot/systematic",
3
- "version": "3.22.6",
3
+ "version": "3.23.0",
4
4
  "description": "Compound-engineering loops for OpenCode, Pi, and Claude Code",
5
5
  "type": "module",
6
6
  "homepage": "https://fro.bot/systematic",
@@ -113,5 +113,3 @@ The four capabilities are subagent delegation, blocking user interaction, task t
113
113
  The bootstrap inlines the active harness profile naming the exact mechanisms for this session—consult it.
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
-
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.