@fro.bot/systematic 3.21.5 → 3.21.6
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 +14 -12
- package/dist/{index-c17zm38x.js → index-99dtcz5j.js} +541 -539
- package/dist/index.js +196 -64
- package/dist/lib/opencode-workflow-guard.d.ts +16 -0
- package/dist/lib/workflow-guard.d.ts +1 -1
- package/package.json +7 -7
- package/skills/ce-review/scripts/validate-review.mjs +13 -11
- package/skills/using-systematic/SKILL.md +1 -1
package/dist/index.js
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
extractCommandFrontmatter,
|
|
20
20
|
findSkillsInDir,
|
|
21
21
|
discoverSkills
|
|
22
|
-
} from "./index-
|
|
22
|
+
} from "./index-99dtcz5j.js";
|
|
23
23
|
|
|
24
24
|
// src/index.ts
|
|
25
25
|
import { createHash as createHash4 } from "crypto";
|
|
@@ -9212,7 +9212,7 @@ function createWorkflowGuard(options) {
|
|
|
9212
9212
|
if (globalIssue)
|
|
9213
9213
|
return projectGlobalIssue(globalIssue, lists);
|
|
9214
9214
|
if (!epoch)
|
|
9215
|
-
return makeStatus("
|
|
9215
|
+
return makeStatus("inactive", "no-active-epoch");
|
|
9216
9216
|
if (epoch.status === "completed") {
|
|
9217
9217
|
return makeStatus("protected", "epoch-completed", undefined, lists.satisfied, lists.missing);
|
|
9218
9218
|
}
|
|
@@ -9253,7 +9253,7 @@ function createWorkflowGuard(options) {
|
|
|
9253
9253
|
if (!epoch) {
|
|
9254
9254
|
return {
|
|
9255
9255
|
ready: false,
|
|
9256
|
-
status: "
|
|
9256
|
+
status: "rejected",
|
|
9257
9257
|
reasonCode: "no-active-epoch"
|
|
9258
9258
|
};
|
|
9259
9259
|
}
|
|
@@ -10354,6 +10354,14 @@ function isWorkflowGuardBlockedError(value) {
|
|
|
10354
10354
|
return false;
|
|
10355
10355
|
return typeof candidate.reasonCode === "string" && REASON_CODES.has(candidate.reasonCode);
|
|
10356
10356
|
}
|
|
10357
|
+
function initializationCause(kind) {
|
|
10358
|
+
return { site: "initialize-session", kind, timedOut: false };
|
|
10359
|
+
}
|
|
10360
|
+
var OBSERVER_READBACK_FAILED_CAUSE = Object.freeze({
|
|
10361
|
+
site: "refresh-readback",
|
|
10362
|
+
kind: "observer-readback-failed",
|
|
10363
|
+
timedOut: false
|
|
10364
|
+
});
|
|
10357
10365
|
var startToolShape = {
|
|
10358
10366
|
expected_operations: array(_enum(OPERATIONS)).optional(),
|
|
10359
10367
|
resource_scopes: record(string(), string()).optional()
|
|
@@ -10849,16 +10857,18 @@ function statusForTool(status, unavailableCause) {
|
|
|
10849
10857
|
});
|
|
10850
10858
|
}
|
|
10851
10859
|
function markerStatusRank(state) {
|
|
10852
|
-
|
|
10860
|
+
const ranks = {
|
|
10853
10861
|
disabled: 0,
|
|
10854
|
-
|
|
10855
|
-
|
|
10856
|
-
|
|
10857
|
-
|
|
10858
|
-
|
|
10862
|
+
inactive: 1,
|
|
10863
|
+
protected: 2,
|
|
10864
|
+
waiting: 3,
|
|
10865
|
+
rejected: 4,
|
|
10866
|
+
unavailable: 5
|
|
10867
|
+
};
|
|
10868
|
+
return ranks[state];
|
|
10859
10869
|
}
|
|
10860
10870
|
function isWorkflowState(value) {
|
|
10861
|
-
return value === "protected" || value === "waiting" || value === "rejected" || value === "disabled" || value === "unavailable";
|
|
10871
|
+
return value === "protected" || value === "waiting" || value === "rejected" || value === "disabled" || value === "unavailable" || value === "inactive";
|
|
10862
10872
|
}
|
|
10863
10873
|
function parseMarkerDebug(value) {
|
|
10864
10874
|
if (value === undefined)
|
|
@@ -11005,7 +11015,7 @@ function buildMarker(sources, malformed, current) {
|
|
|
11005
11015
|
};
|
|
11006
11016
|
return `${MARKER_OPEN}${JSON.stringify(document)}${MARKER_CLOSE}`;
|
|
11007
11017
|
}
|
|
11008
|
-
function createSessionRuntime(options, operationObservers, recoveredOperationContexts) {
|
|
11018
|
+
function createSessionRuntime(options, operationObservers, recoveredOperationContexts, runtimeStartedAt) {
|
|
11009
11019
|
let ledger;
|
|
11010
11020
|
let guard;
|
|
11011
11021
|
let initialized = false;
|
|
@@ -11035,6 +11045,12 @@ function createSessionRuntime(options, operationObservers, recoveredOperationCon
|
|
|
11035
11045
|
firstUnavailableCause = undefined;
|
|
11036
11046
|
return result;
|
|
11037
11047
|
}
|
|
11048
|
+
function recordUnavailable(target, cause) {
|
|
11049
|
+
const result = target.setMode({ mode: "unavailable" });
|
|
11050
|
+
if (cause && result.status === "changed" && !firstUnavailableCause) {
|
|
11051
|
+
firstUnavailableCause = cause;
|
|
11052
|
+
}
|
|
11053
|
+
}
|
|
11038
11054
|
function effectiveTargetContext() {
|
|
11039
11055
|
const parentTargetRoot = options.targetDirectory ?? process.cwd();
|
|
11040
11056
|
return {
|
|
@@ -11253,13 +11269,75 @@ function createSessionRuntime(options, operationObservers, recoveredOperationCon
|
|
|
11253
11269
|
collectReceiptMarkers(part, markers);
|
|
11254
11270
|
}
|
|
11255
11271
|
}
|
|
11256
|
-
function
|
|
11272
|
+
function hasNoEpochRejection(part) {
|
|
11273
|
+
const carriers = [
|
|
11274
|
+
part.metadata,
|
|
11275
|
+
isRecord7(part.state) && part.state.metadata
|
|
11276
|
+
];
|
|
11277
|
+
return carriers.some((carrier) => isRecord7(carrier) && isRecord7(carrier.workflowGuard) && carrier.workflowGuard.status === "rejected" && carrier.workflowGuard.reasonCode === "no-active-epoch");
|
|
11278
|
+
}
|
|
11279
|
+
function newestMessage(history) {
|
|
11280
|
+
let newest;
|
|
11281
|
+
let newestCreated = Number.NEGATIVE_INFINITY;
|
|
11282
|
+
let tied = false;
|
|
11283
|
+
for (const entry of history) {
|
|
11284
|
+
const created = messageCreated(entry);
|
|
11285
|
+
if (!isRecord7(entry) || created === undefined)
|
|
11286
|
+
return;
|
|
11287
|
+
if (created > newestCreated) {
|
|
11288
|
+
newest = entry;
|
|
11289
|
+
newestCreated = created;
|
|
11290
|
+
tied = false;
|
|
11291
|
+
} else if (created === newestCreated) {
|
|
11292
|
+
tied = true;
|
|
11293
|
+
}
|
|
11294
|
+
}
|
|
11295
|
+
return tied ? undefined : newest;
|
|
11296
|
+
}
|
|
11297
|
+
function messageInfo(entry) {
|
|
11298
|
+
return isRecord7(entry) && isRecord7(entry.info) ? entry.info : undefined;
|
|
11299
|
+
}
|
|
11300
|
+
function messageCreated(entry) {
|
|
11301
|
+
const info2 = messageInfo(entry);
|
|
11302
|
+
const time = info2 && isRecord7(info2.time) ? info2.time : undefined;
|
|
11303
|
+
return typeof time?.created === "number" && Number.isFinite(time.created) ? time.created : undefined;
|
|
11304
|
+
}
|
|
11305
|
+
function isCurrentTurn(message) {
|
|
11306
|
+
const info2 = messageInfo(message);
|
|
11307
|
+
const time = info2 && isRecord7(info2.time) ? info2.time : undefined;
|
|
11308
|
+
const created = messageCreated(message);
|
|
11309
|
+
return info2?.role === "assistant" && (time?.completed === undefined || time.completed === null) && created !== undefined && created >= runtimeStartedAt;
|
|
11310
|
+
}
|
|
11311
|
+
function currentTurnExemptParts(history) {
|
|
11312
|
+
const exempt = new Set;
|
|
11313
|
+
const newest = newestMessage(history);
|
|
11314
|
+
if (!newest || !isCurrentTurn(newest) || !Array.isArray(newest.parts)) {
|
|
11315
|
+
return exempt;
|
|
11316
|
+
}
|
|
11317
|
+
for (const part of newest.parts) {
|
|
11318
|
+
if (isRecord7(part) && (part.tool === "systematic_workflow_start" || part.tool === "systematic_workflow_complete" || part.tool === "systematic_workflow_control") && isRecord7(part.state) && (part.state.status === "pending" || part.state.status === "running")) {
|
|
11319
|
+
exempt.add(part);
|
|
11320
|
+
}
|
|
11321
|
+
}
|
|
11322
|
+
return exempt;
|
|
11323
|
+
}
|
|
11324
|
+
function isExemptGuardPart(part, currentTurn) {
|
|
11325
|
+
if (part.tool === "systematic_workflow_status")
|
|
11326
|
+
return true;
|
|
11327
|
+
if (currentTurn.has(part))
|
|
11328
|
+
return true;
|
|
11329
|
+
if (part.tool !== "systematic_workflow_start" && part.tool !== "systematic_workflow_complete") {
|
|
11330
|
+
return false;
|
|
11331
|
+
}
|
|
11332
|
+
return isRecord7(part.state) && part.state.status === "completed" && hasNoEpochRejection(part);
|
|
11333
|
+
}
|
|
11334
|
+
function containsGuardHistory(value, currentTurn) {
|
|
11257
11335
|
if (!isRecord7(value))
|
|
11258
11336
|
return false;
|
|
11259
11337
|
if (value.tool === "systematic_workflow_start" || value.tool === "systematic_workflow_status" || value.tool === "systematic_workflow_complete" || value.tool === "systematic_workflow_control") {
|
|
11260
|
-
return
|
|
11338
|
+
return !isExemptGuardPart(value, currentTurn);
|
|
11261
11339
|
}
|
|
11262
|
-
return Array.isArray(value.parts) && value.parts.some((part) => containsGuardHistory(part));
|
|
11340
|
+
return Array.isArray(value.parts) && value.parts.some((part) => containsGuardHistory(part, currentTurn));
|
|
11263
11341
|
}
|
|
11264
11342
|
function createGuard(nextLedger) {
|
|
11265
11343
|
return createWorkflowGuard({
|
|
@@ -11298,16 +11376,18 @@ function createSessionRuntime(options, operationObservers, recoveredOperationCon
|
|
|
11298
11376
|
emptyHistoryLedger ??= mintLedger();
|
|
11299
11377
|
return emptyHistoryLedger;
|
|
11300
11378
|
}
|
|
11301
|
-
function publishUnavailable(reusableLedger) {
|
|
11379
|
+
function publishUnavailable(cause, reusableLedger) {
|
|
11302
11380
|
ledger = reusableLedger ?? mintLedger();
|
|
11303
11381
|
guard = createGuard(ledger);
|
|
11304
|
-
if (options.config.mode !== "disabled")
|
|
11305
|
-
guard
|
|
11382
|
+
if (options.config.mode !== "disabled") {
|
|
11383
|
+
recordUnavailable(guard, cause);
|
|
11384
|
+
}
|
|
11306
11385
|
initialized = true;
|
|
11307
11386
|
}
|
|
11308
11387
|
function publishFresh(reusableLedger) {
|
|
11309
11388
|
ledger = reusableLedger ?? mintLedger();
|
|
11310
11389
|
guard = createGuard(ledger);
|
|
11390
|
+
firstUnavailableCause = undefined;
|
|
11311
11391
|
initialized = true;
|
|
11312
11392
|
}
|
|
11313
11393
|
function ensureSynchronousRuntime() {
|
|
@@ -11359,8 +11439,9 @@ function createSessionRuntime(options, operationObservers, recoveredOperationCon
|
|
|
11359
11439
|
}
|
|
11360
11440
|
function recoverPersistedMarkers(markers) {
|
|
11361
11441
|
const seed = extractReceiptReadbackSeed(markers);
|
|
11362
|
-
if (seed.status !== "ready")
|
|
11363
|
-
return
|
|
11442
|
+
if (seed.status !== "ready") {
|
|
11443
|
+
return initializationCause("markers-malformed-or-incompatible");
|
|
11444
|
+
}
|
|
11364
11445
|
let recoveredLedger;
|
|
11365
11446
|
try {
|
|
11366
11447
|
recoveredLedger = createReceiptLedger({
|
|
@@ -11369,14 +11450,14 @@ function createSessionRuntime(options, operationObservers, recoveredOperationCon
|
|
|
11369
11450
|
sessionSalt: seed.sessionSalt
|
|
11370
11451
|
});
|
|
11371
11452
|
} catch {
|
|
11372
|
-
return
|
|
11453
|
+
return initializationCause("markers-malformed-or-incompatible");
|
|
11373
11454
|
}
|
|
11374
11455
|
if (!seedAgrees(recoveredLedger, seed)) {
|
|
11375
|
-
return
|
|
11456
|
+
return initializationCause("markers-malformed-or-incompatible");
|
|
11376
11457
|
}
|
|
11377
11458
|
const recovered = recoveredLedger.recoverReadback(markers);
|
|
11378
11459
|
if (recovered.status === "rejected") {
|
|
11379
|
-
return
|
|
11460
|
+
return initializationCause("recovery-rejected");
|
|
11380
11461
|
}
|
|
11381
11462
|
const recoveredGuard = createGuard(recoveredLedger);
|
|
11382
11463
|
const restored = recoveredGuard.restore({
|
|
@@ -11388,12 +11469,13 @@ function createSessionRuntime(options, operationObservers, recoveredOperationCon
|
|
|
11388
11469
|
}
|
|
11389
11470
|
});
|
|
11390
11471
|
if (restored.status === "rejected") {
|
|
11391
|
-
return
|
|
11472
|
+
return initializationCause("recovery-rejected");
|
|
11392
11473
|
}
|
|
11393
11474
|
ledger = recoveredLedger;
|
|
11394
11475
|
guard = recoveredGuard;
|
|
11476
|
+
firstUnavailableCause = undefined;
|
|
11395
11477
|
initialized = true;
|
|
11396
|
-
return
|
|
11478
|
+
return;
|
|
11397
11479
|
}
|
|
11398
11480
|
function classifyMarkersFromParts(parts2) {
|
|
11399
11481
|
const allMarkers = [];
|
|
@@ -11422,15 +11504,20 @@ function createSessionRuntime(options, operationObservers, recoveredOperationCon
|
|
|
11422
11504
|
}
|
|
11423
11505
|
function publishEmptyMarkers(parts2, allowFresh) {
|
|
11424
11506
|
const reusableLedger = emptyHistoryLedgerForRetry();
|
|
11425
|
-
|
|
11507
|
+
const currentTurn = currentTurnExemptParts(parts2);
|
|
11508
|
+
if (parts2.some((part) => containsGuardHistory(part, currentTurn))) {
|
|
11509
|
+
publishUnavailable(initializationCause("markerless-guard-history"), reusableLedger);
|
|
11510
|
+
return;
|
|
11511
|
+
}
|
|
11512
|
+
if (allowFresh) {
|
|
11426
11513
|
publishFresh(reusableLedger);
|
|
11427
|
-
|
|
11428
|
-
retryableEmptyHistory = true;
|
|
11429
|
-
publishUnavailable(reusableLedger);
|
|
11514
|
+
return;
|
|
11430
11515
|
}
|
|
11516
|
+
retryableEmptyHistory = true;
|
|
11517
|
+
publishFresh(reusableLedger);
|
|
11431
11518
|
}
|
|
11432
11519
|
async function initializeSession(sessionID, allowFresh) {
|
|
11433
|
-
const reader = options.hostReadback?.readSessionParts;
|
|
11520
|
+
const reader = options.hostReadback?.readSessionPartsStrict ?? options.hostReadback?.readSessionParts;
|
|
11434
11521
|
if (!reader) {
|
|
11435
11522
|
publishFresh();
|
|
11436
11523
|
return;
|
|
@@ -11439,32 +11526,40 @@ function createSessionRuntime(options, operationObservers, recoveredOperationCon
|
|
|
11439
11526
|
try {
|
|
11440
11527
|
parts2 = await reader(sessionID);
|
|
11441
11528
|
} catch {
|
|
11442
|
-
publishUnavailable();
|
|
11529
|
+
publishUnavailable(initializationCause("history-read-failed"));
|
|
11443
11530
|
return;
|
|
11444
11531
|
}
|
|
11445
11532
|
const classification = classifyMarkersFromParts(parts2);
|
|
11446
11533
|
if (classification.kind === "ambiguous") {
|
|
11447
|
-
publishUnavailable();
|
|
11534
|
+
publishUnavailable(initializationCause("markers-ambiguous"));
|
|
11448
11535
|
return;
|
|
11449
11536
|
}
|
|
11450
11537
|
if (classification.kind === "foreign-empty") {
|
|
11451
11538
|
publishEmptyMarkers(parts2, allowFresh);
|
|
11452
11539
|
return;
|
|
11453
11540
|
}
|
|
11454
|
-
|
|
11455
|
-
|
|
11541
|
+
const failure = recoverPersistedMarkers(classification.markers);
|
|
11542
|
+
if (failure)
|
|
11543
|
+
publishUnavailable(failure);
|
|
11456
11544
|
}
|
|
11457
11545
|
async function recoverFromHost(sessionID, allowFresh = true) {
|
|
11458
|
-
|
|
11459
|
-
|
|
11546
|
+
let reinitialize = false;
|
|
11547
|
+
while (initializationPromise) {
|
|
11548
|
+
const seen = initializationPromise;
|
|
11549
|
+
await seen;
|
|
11550
|
+
if (initializationPromise !== seen)
|
|
11551
|
+
continue;
|
|
11460
11552
|
if (!retryableEmptyHistory || !allowFresh)
|
|
11461
11553
|
return;
|
|
11462
|
-
|
|
11463
|
-
|
|
11554
|
+
reinitialize = true;
|
|
11555
|
+
break;
|
|
11464
11556
|
}
|
|
11557
|
+
if (reinitialize)
|
|
11558
|
+
initialized = false;
|
|
11465
11559
|
retryableEmptyHistory = false;
|
|
11466
|
-
|
|
11467
|
-
|
|
11560
|
+
const next = initializeSession(sessionID, allowFresh);
|
|
11561
|
+
initializationPromise = next;
|
|
11562
|
+
await next;
|
|
11468
11563
|
}
|
|
11469
11564
|
async function rollupForegroundTask(host, output) {
|
|
11470
11565
|
if (!options.hostReadback || !isRecord7(output))
|
|
@@ -11634,10 +11729,7 @@ function createSessionRuntime(options, operationObservers, recoveredOperationCon
|
|
|
11634
11729
|
function markUnavailable(cause) {
|
|
11635
11730
|
if (options.config.mode === "disabled")
|
|
11636
11731
|
return;
|
|
11637
|
-
|
|
11638
|
-
if (cause && result.status === "changed" && !firstUnavailableCause) {
|
|
11639
|
-
firstUnavailableCause = cause;
|
|
11640
|
-
}
|
|
11732
|
+
recordUnavailable(guard, cause);
|
|
11641
11733
|
}
|
|
11642
11734
|
function bindCall(callDigest, kind, fingerprint) {
|
|
11643
11735
|
const existing = callBindings.get(callDigest);
|
|
@@ -11671,7 +11763,6 @@ function createSessionRuntime(options, operationObservers, recoveredOperationCon
|
|
|
11671
11763
|
}
|
|
11672
11764
|
}
|
|
11673
11765
|
function readStatus() {
|
|
11674
|
-
abandonPending();
|
|
11675
11766
|
return guard.status();
|
|
11676
11767
|
}
|
|
11677
11768
|
function control(sessionID, input) {
|
|
@@ -11713,24 +11804,26 @@ function createSessionRuntime(options, operationObservers, recoveredOperationCon
|
|
|
11713
11804
|
})
|
|
11714
11805
|
};
|
|
11715
11806
|
}
|
|
11807
|
+
function observerReadbackApplies() {
|
|
11808
|
+
return options.observer !== undefined && guard.status().epoch !== null;
|
|
11809
|
+
}
|
|
11716
11810
|
async function refreshReadback() {
|
|
11717
|
-
|
|
11718
|
-
if (!options.observer)
|
|
11811
|
+
if (!observerReadbackApplies())
|
|
11719
11812
|
return;
|
|
11720
11813
|
const effective = effectiveOperationObserver();
|
|
11721
11814
|
if (!effective) {
|
|
11722
|
-
markUnavailable();
|
|
11815
|
+
markUnavailable(OBSERVER_READBACK_FAILED_CAUSE);
|
|
11723
11816
|
return;
|
|
11724
11817
|
}
|
|
11725
11818
|
let result;
|
|
11726
11819
|
try {
|
|
11727
11820
|
result = await effective.observer.snapshot();
|
|
11728
11821
|
} catch {
|
|
11729
|
-
markUnavailable();
|
|
11822
|
+
markUnavailable(OBSERVER_READBACK_FAILED_CAUSE);
|
|
11730
11823
|
return;
|
|
11731
11824
|
}
|
|
11732
11825
|
if (result.status === "unavailable" || result.snapshot.targetDigest !== effective.targetIdentity) {
|
|
11733
|
-
markUnavailable();
|
|
11826
|
+
markUnavailable(OBSERVER_READBACK_FAILED_CAUSE);
|
|
11734
11827
|
return;
|
|
11735
11828
|
}
|
|
11736
11829
|
const observed = guard.observeReadback({
|
|
@@ -11740,7 +11833,7 @@ function createSessionRuntime(options, operationObservers, recoveredOperationCon
|
|
|
11740
11833
|
...effective.pinned ? { operationTargetIdentity: effective.targetIdentity } : {}
|
|
11741
11834
|
});
|
|
11742
11835
|
if (observed.status === "rejected" && observed.reasonCode === "workspace-mismatch" || !await refreshRemoteReadbacks(effective.observer, result.snapshot)) {
|
|
11743
|
-
markUnavailable();
|
|
11836
|
+
markUnavailable(OBSERVER_READBACK_FAILED_CAUSE);
|
|
11744
11837
|
}
|
|
11745
11838
|
}
|
|
11746
11839
|
async function refreshRemoteReadbacks(observer, local) {
|
|
@@ -11878,11 +11971,11 @@ function createSessionRuntime(options, operationObservers, recoveredOperationCon
|
|
|
11878
11971
|
workflowGuard: { status: "completed", target }
|
|
11879
11972
|
};
|
|
11880
11973
|
}
|
|
11881
|
-
function writeTerminalCompletionResult(output, result, target) {
|
|
11974
|
+
function writeTerminalCompletionResult(output, result, target, title = "Workflow transition unavailable") {
|
|
11882
11975
|
if (!isRecord7(output))
|
|
11883
11976
|
return;
|
|
11884
11977
|
const existingMetadata = isRecord7(output.metadata) ? output.metadata : {};
|
|
11885
|
-
output.title =
|
|
11978
|
+
output.title = title;
|
|
11886
11979
|
output.output = JSON.stringify({
|
|
11887
11980
|
status: result.status,
|
|
11888
11981
|
reasonCode: result.reasonCode
|
|
@@ -11897,6 +11990,27 @@ function createSessionRuntime(options, operationObservers, recoveredOperationCon
|
|
|
11897
11990
|
}
|
|
11898
11991
|
};
|
|
11899
11992
|
}
|
|
11993
|
+
function writeNoEpochBlockedResult(callDigest, output, target) {
|
|
11994
|
+
const current = guard.status();
|
|
11995
|
+
const terminal = !current.epoch ? {
|
|
11996
|
+
target,
|
|
11997
|
+
status: "rejected",
|
|
11998
|
+
reasonCode: "no-active-epoch",
|
|
11999
|
+
title: "Workflow transition rejected"
|
|
12000
|
+
} : current.state === "unavailable" ? { target, status: "unavailable", reasonCode: current.reasonCode } : {
|
|
12001
|
+
target,
|
|
12002
|
+
status: "rejected",
|
|
12003
|
+
reasonCode: current.reasonCode,
|
|
12004
|
+
title: "Workflow transition rejected"
|
|
12005
|
+
};
|
|
12006
|
+
terminalCompletes.set(callDigest, terminal);
|
|
12007
|
+
writeTerminalCompletionResult(output, terminal, target, terminal.title);
|
|
12008
|
+
}
|
|
12009
|
+
function writeBlockedCompleteResult(callDigest, output, blocked) {
|
|
12010
|
+
if (blocked?.reasonCode === "no-active-epoch") {
|
|
12011
|
+
writeNoEpochBlockedResult(callDigest, output, blocked.target);
|
|
12012
|
+
}
|
|
12013
|
+
}
|
|
11900
12014
|
function writeAbandonedCompletionResult(output, target, reasonCode) {
|
|
11901
12015
|
writeTerminalCompletionResult(output, { target, status: "unavailable", reasonCode }, target);
|
|
11902
12016
|
}
|
|
@@ -11949,7 +12063,10 @@ function createSessionRuntime(options, operationObservers, recoveredOperationCon
|
|
|
11949
12063
|
if (options.config.mode === "protected") {
|
|
11950
12064
|
throw createWorkflowGuardBlockedError("guard-unavailable");
|
|
11951
12065
|
}
|
|
11952
|
-
blockedCompletes.set(callDigest,
|
|
12066
|
+
blockedCompletes.set(callDigest, {
|
|
12067
|
+
target,
|
|
12068
|
+
reasonCode: status.reasonCode
|
|
12069
|
+
});
|
|
11953
12070
|
blockedQuestionCalls.set(callDigest, challenge.challenge.challengeId);
|
|
11954
12071
|
return true;
|
|
11955
12072
|
}
|
|
@@ -11976,10 +12093,13 @@ function createSessionRuntime(options, operationObservers, recoveredOperationCon
|
|
|
11976
12093
|
});
|
|
11977
12094
|
return;
|
|
11978
12095
|
}
|
|
11979
|
-
if (options.config.mode === "protected") {
|
|
12096
|
+
if (options.config.mode === "protected" && prepared.reasonCode !== "no-active-epoch") {
|
|
11980
12097
|
throw createWorkflowGuardBlockedError(prepared.reasonCode);
|
|
11981
12098
|
}
|
|
11982
|
-
blockedCompletes.set(callDigest,
|
|
12099
|
+
blockedCompletes.set(callDigest, {
|
|
12100
|
+
target,
|
|
12101
|
+
reasonCode: prepared.reasonCode
|
|
12102
|
+
});
|
|
11983
12103
|
}
|
|
11984
12104
|
async function remoteIntentForOperation(host, args2, observer) {
|
|
11985
12105
|
if (host.tool !== "bash" || !isRecord7(args2))
|
|
@@ -12407,7 +12527,7 @@ function createSessionRuntime(options, operationObservers, recoveredOperationCon
|
|
|
12407
12527
|
writeAbandonedCompletionMetadata(output, target, terminal.reasonCode);
|
|
12408
12528
|
return;
|
|
12409
12529
|
}
|
|
12410
|
-
writeTerminalCompletionResult(output, terminal, target);
|
|
12530
|
+
writeTerminalCompletionResult(output, terminal, target, terminal.title);
|
|
12411
12531
|
}
|
|
12412
12532
|
function replayTerminalComplete(callDigest, finalTarget, output) {
|
|
12413
12533
|
const questionChallengeID = blockedQuestionCalls.get(callDigest);
|
|
@@ -12426,8 +12546,8 @@ function createSessionRuntime(options, operationObservers, recoveredOperationCon
|
|
|
12426
12546
|
}
|
|
12427
12547
|
const replay = finalizedCompletes.get(callDigest);
|
|
12428
12548
|
const abandonedTarget = abandonedCompletes.get(callDigest);
|
|
12429
|
-
const
|
|
12430
|
-
const expectedTarget = replay?.target ?? abandonedTarget ??
|
|
12549
|
+
const blocked = blockedCompletes.get(callDigest);
|
|
12550
|
+
const expectedTarget = replay?.target ?? abandonedTarget ?? blocked?.target;
|
|
12431
12551
|
if (!expectedTarget)
|
|
12432
12552
|
return false;
|
|
12433
12553
|
if (finalTarget !== expectedTarget) {
|
|
@@ -12437,6 +12557,7 @@ function createSessionRuntime(options, operationObservers, recoveredOperationCon
|
|
|
12437
12557
|
if (replay)
|
|
12438
12558
|
replayComplete(callDigest);
|
|
12439
12559
|
blockedCompletes.delete(callDigest);
|
|
12560
|
+
writeBlockedCompleteResult(callDigest, output, blocked);
|
|
12440
12561
|
return true;
|
|
12441
12562
|
}
|
|
12442
12563
|
function abandonComplete(callDigest, pending, remember) {
|
|
@@ -13018,6 +13139,7 @@ function createOpencodeWorkflowGuard(options) {
|
|
|
13018
13139
|
const sessions = new Map;
|
|
13019
13140
|
const operationObservers = new Map;
|
|
13020
13141
|
const recoveredOperationContexts = new Map;
|
|
13142
|
+
const runtimeStartedAt = (options.now ?? Date.now)();
|
|
13021
13143
|
function sessionRuntimeFor(sessionID) {
|
|
13022
13144
|
const existing = sessions.get(sessionID);
|
|
13023
13145
|
if (existing)
|
|
@@ -13026,7 +13148,7 @@ function createOpencodeWorkflowGuard(options) {
|
|
|
13026
13148
|
...options,
|
|
13027
13149
|
registrationIdentity: options.registrationIdentity,
|
|
13028
13150
|
sessionSalt: options.sessionSalt
|
|
13029
|
-
}, operationObservers, recoveredOperationContexts);
|
|
13151
|
+
}, operationObservers, recoveredOperationContexts, runtimeStartedAt);
|
|
13030
13152
|
sessions.set(sessionID, runtime);
|
|
13031
13153
|
return runtime;
|
|
13032
13154
|
}
|
|
@@ -13486,15 +13608,25 @@ var initializePlugin = async ({
|
|
|
13486
13608
|
observer,
|
|
13487
13609
|
classifier: createReceiptClassifier(),
|
|
13488
13610
|
hostReadback: (() => {
|
|
13611
|
+
const readMessages = async (sessionID) => {
|
|
13612
|
+
const messages = client.session.messages.bind(client.session);
|
|
13613
|
+
return messages({ path: { id: sessionID }, query: { directory } });
|
|
13614
|
+
};
|
|
13489
13615
|
return {
|
|
13490
13616
|
readSessionParts: async (sessionID) => {
|
|
13491
|
-
const
|
|
13492
|
-
const response = await messages({
|
|
13493
|
-
path: { id: sessionID },
|
|
13494
|
-
query: { directory }
|
|
13495
|
-
});
|
|
13617
|
+
const response = await readMessages(sessionID);
|
|
13496
13618
|
return Array.isArray(response.data) ? response.data : [];
|
|
13497
13619
|
},
|
|
13620
|
+
readSessionPartsStrict: async (sessionID) => {
|
|
13621
|
+
const response = await readMessages(sessionID);
|
|
13622
|
+
if (response.error !== undefined && response.error !== null) {
|
|
13623
|
+
throw new Error("session history read failed");
|
|
13624
|
+
}
|
|
13625
|
+
if (!Array.isArray(response.data)) {
|
|
13626
|
+
throw new Error("session history read returned malformed data");
|
|
13627
|
+
}
|
|
13628
|
+
return response.data;
|
|
13629
|
+
},
|
|
13498
13630
|
listChildren: async (sessionID) => {
|
|
13499
13631
|
const children = client.session.children.bind(client.session);
|
|
13500
13632
|
const response = await children({
|
|
@@ -28,13 +28,29 @@ export interface OpencodeWorkflowGuardOptions {
|
|
|
28
28
|
readonly sessionSalt?: Uint8Array;
|
|
29
29
|
readonly targetDirectory?: string;
|
|
30
30
|
readonly sessionLocation?: string;
|
|
31
|
+
/** Injectable clock (epoch milliseconds); defaults to `Date.now`. */
|
|
32
|
+
readonly now?: () => number;
|
|
31
33
|
}
|
|
32
34
|
export interface OpencodeWorkflowChildSession {
|
|
33
35
|
readonly sessionId: string;
|
|
34
36
|
readonly parentID?: string;
|
|
35
37
|
}
|
|
36
38
|
export interface OpencodeWorkflowHostReadback {
|
|
39
|
+
/**
|
|
40
|
+
* Lenient read, used for child-session rollup: a host error or malformed
|
|
41
|
+
* payload may be reported as `[]` (nothing to roll up), and only a thrown
|
|
42
|
+
* read marks the parent unavailable.
|
|
43
|
+
*/
|
|
37
44
|
readSessionParts(sessionID: string): Promise<ReadonlyArray<unknown>>;
|
|
45
|
+
/**
|
|
46
|
+
* Strict read of the session's OWN history, used for initialization and
|
|
47
|
+
* recovery. Must throw on a host error or malformed payload so a failed read
|
|
48
|
+
* can never be mistaken for empty history. Optional only so injected readers
|
|
49
|
+
* need no mass edits; when absent, initialization falls back to
|
|
50
|
+
* `readSessionParts`, which then carries the same obligation to throw on
|
|
51
|
+
* failure.
|
|
52
|
+
*/
|
|
53
|
+
readSessionPartsStrict?(sessionID: string): Promise<ReadonlyArray<unknown>>;
|
|
38
54
|
listChildren(sessionID: string): Promise<ReadonlyArray<OpencodeWorkflowChildSession>>;
|
|
39
55
|
}
|
|
40
56
|
export interface OpencodeWorkflowGuardHooks {
|
|
@@ -2,7 +2,7 @@ import { type ReceiptClassifier } from './receipt-classifier.js';
|
|
|
2
2
|
import type { ReceiptLedger, ReceiptOperation } from './receipt-ledger.js';
|
|
3
3
|
import type { ReceiptResourceScope } from './receipt-readback.js';
|
|
4
4
|
export type WorkflowMode = 'protected' | 'disabled' | 'unavailable';
|
|
5
|
-
export type WorkflowState = 'protected' | 'waiting' | 'rejected' | 'disabled' | 'unavailable';
|
|
5
|
+
export type WorkflowState = 'protected' | 'waiting' | 'rejected' | 'disabled' | 'unavailable' | 'inactive';
|
|
6
6
|
export type RepairKind = 'fresh-readback' | 'rerun-operation' | 'question-attestation';
|
|
7
7
|
export type TransitionTarget = 'unit' | 'epoch';
|
|
8
8
|
export type EpochFamily = 'work' | 'shipping';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fro.bot/systematic",
|
|
3
|
-
"version": "3.21.
|
|
3
|
+
"version": "3.21.6",
|
|
4
4
|
"description": "Compound-engineering loops for OpenCode, Pi, and Claude Code",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"homepage": "https://fro.bot/systematic",
|
|
@@ -99,22 +99,22 @@
|
|
|
99
99
|
"devDependencies": {
|
|
100
100
|
"@biomejs/biome": "2.5.15",
|
|
101
101
|
"@earendil-works/pi-coding-agent": "0.83.0",
|
|
102
|
-
"@opencode-ai/plugin": "1.18.
|
|
103
|
-
"@opencode-ai/sdk": "1.18.
|
|
102
|
+
"@opencode-ai/plugin": "1.18.35",
|
|
103
|
+
"@opencode-ai/sdk": "1.18.35",
|
|
104
104
|
"@semantic-release/exec": "7.1.0",
|
|
105
105
|
"@tintinweb/pi-subagents": "0.14.3",
|
|
106
106
|
"@types/bun": "latest",
|
|
107
107
|
"@types/js-yaml": "4.0.9",
|
|
108
|
-
"@types/node": "26.6.
|
|
108
|
+
"@types/node": "26.6.4",
|
|
109
109
|
"agent-browser": "0.34.0",
|
|
110
110
|
"ajv": "8.20.0",
|
|
111
111
|
"ajv-formats": "3.0.1",
|
|
112
|
-
"conventional-changelog-conventionalcommits": "10.4.
|
|
112
|
+
"conventional-changelog-conventionalcommits": "10.4.1",
|
|
113
113
|
"markdownlint-cli": "0.49.1",
|
|
114
114
|
"rimraf": "6.1.3",
|
|
115
115
|
"semantic-release": "25.0.9",
|
|
116
116
|
"semantic-release-export-data": "1.2.0",
|
|
117
|
-
"typebox": "1.3.
|
|
117
|
+
"typebox": "1.3.36",
|
|
118
118
|
"typescript": "7.0.2"
|
|
119
119
|
},
|
|
120
120
|
"dependencies": {
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
"brace-expansion": "^5.0.8",
|
|
130
130
|
"conventional-changelog-writer": ">=9",
|
|
131
131
|
"devalue": "^5.9.3",
|
|
132
|
-
"smol-toml": "~1.
|
|
132
|
+
"smol-toml": "~1.9.0"
|
|
133
133
|
},
|
|
134
134
|
"publishConfig": {
|
|
135
135
|
"access": "public",
|
|
@@ -18,6 +18,19 @@ var __export = (target, all) => {
|
|
|
18
18
|
})
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
// node_modules/.bun/zod@4.6.5/node_modules/zod/v4/classic/iso.js
|
|
22
|
+
var exports_iso = {}
|
|
23
|
+
__export(exports_iso, {
|
|
24
|
+
ZodISODate: () => ZodISODate,
|
|
25
|
+
ZodISODateTime: () => ZodISODateTime,
|
|
26
|
+
ZodISODuration: () => ZodISODuration,
|
|
27
|
+
ZodISOTime: () => ZodISOTime,
|
|
28
|
+
date: () => date2,
|
|
29
|
+
datetime: () => datetime2,
|
|
30
|
+
duration: () => duration2,
|
|
31
|
+
time: () => time2,
|
|
32
|
+
})
|
|
33
|
+
|
|
21
34
|
// src/ce-review-validator.ts
|
|
22
35
|
import fs3 from 'node:fs'
|
|
23
36
|
import { fileURLToPath } from 'node:url'
|
|
@@ -6286,17 +6299,6 @@ function superRefine(fn, params) {
|
|
|
6286
6299
|
return _superRefine(fn, params)
|
|
6287
6300
|
}
|
|
6288
6301
|
// node_modules/.bun/zod@4.6.5/node_modules/zod/v4/classic/iso.js
|
|
6289
|
-
var exports_iso = {}
|
|
6290
|
-
__export(exports_iso, {
|
|
6291
|
-
ZodISODate: () => ZodISODate,
|
|
6292
|
-
ZodISODateTime: () => ZodISODateTime,
|
|
6293
|
-
ZodISODuration: () => ZodISODuration,
|
|
6294
|
-
ZodISOTime: () => ZodISOTime,
|
|
6295
|
-
date: () => date2,
|
|
6296
|
-
datetime: () => datetime2,
|
|
6297
|
-
duration: () => duration2,
|
|
6298
|
-
time: () => time2,
|
|
6299
|
-
})
|
|
6300
6302
|
function datetime2(params) {
|
|
6301
6303
|
return _isoDateTime(ZodISODateTime, params)
|
|
6302
6304
|
}
|
|
@@ -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. 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. 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.
|