owenloop 0.5.9 → 0.5.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/README.md +77 -37
- package/bin/owenloop.mjs +16 -1
- package/dist/packages/work/src/agent/loop.js +7 -0
- package/dist/packages/work/src/bundle/pull.d.ts +21 -0
- package/dist/packages/work/src/bundle/pull.js +118 -0
- package/dist/packages/work/src/exec/instructions.d.ts +4 -1
- package/dist/packages/work/src/exec/instructions.js +3 -0
- package/dist/packages/work/src/exec/loop.d.ts +1 -1
- package/dist/packages/work/src/exec/loop.js +92 -14
- package/dist/packages/work/src/harness/claude.js +16 -0
- package/dist/packages/work/src/harness/codex.d.ts +8 -0
- package/dist/packages/work/src/harness/codex.js +27 -1
- package/dist/packages/work/src/harness/contract.d.ts +9 -0
- package/dist/packages/work/src/roles/agent-run.js +38 -10
- package/dist/packages/work/src/roles/exec.js +25 -8
- package/dist/packages/work/src/shift/loop.js +118 -4
- package/dist/packages/work/src/shift/runtime.d.ts +3 -0
- package/dist/packages/work/src/shift/runtime.js +10 -1
- package/dist/packages/work/src/submit-proof.d.ts +11 -8
- package/dist/packages/work/src/submit-proof.js +11 -8
- package/dist/src/capabilities.d.ts +70 -6
- package/dist/src/capabilities.js +49 -6
- package/dist/src/capability-mapping-client.d.ts +29 -0
- package/dist/src/capability-mapping-client.js +160 -0
- package/dist/src/cli.d.ts +2 -2
- package/dist/src/cli.js +1196 -164
- package/dist/src/defs.d.ts +32 -1
- package/dist/src/defs.js +391 -79
- package/dist/src/engine.d.ts +62 -19
- package/dist/src/engine.js +180 -70
- package/dist/src/hub.d.ts +77 -0
- package/dist/src/hub.js +162 -0
- package/dist/src/implements.d.ts +56 -0
- package/dist/src/implements.js +790 -0
- package/dist/src/index.d.ts +8 -6
- package/dist/src/index.js +4 -3
- package/dist/src/mcp/serve.js +254 -45
- package/dist/src/mcp/server.d.ts +10 -7
- package/dist/src/mcp/server.js +53 -8
- package/dist/src/model.d.ts +46 -10
- package/dist/src/model.js +220 -74
- package/dist/src/store/def-source.d.ts +19 -0
- package/dist/src/store/def-source.js +87 -17
- package/dist/src/store/gc-recovery.d.ts +46 -0
- package/dist/src/store/gc-recovery.js +258 -0
- package/dist/src/store/gc.d.ts +94 -0
- package/dist/src/store/gc.js +562 -0
- package/dist/src/store/index.d.ts +3 -1
- package/dist/src/store/index.js +2 -0
- package/dist/src/store/install.d.ts +34 -5
- package/dist/src/store/install.js +73 -11
- package/dist/src/store/pre-commit-verifier.js +42 -2
- package/dist/src/store/snapshot-guard.d.ts +18 -0
- package/dist/src/store/snapshot-guard.js +94 -0
- package/dist/src/store.d.ts +64 -4
- package/dist/src/store.js +211 -8
- package/dist/src/types.d.ts +61 -17
- package/dist/src/util.js +4 -1
- package/docs/authoring.md +145 -8
- package/docs/bundles.md +19 -0
- package/docs/cli.md +270 -30
- package/docs/crypto.md +13 -7
- package/docs/design.md +107 -46
- package/docs/evals/mcp-charter-baseline.json +428 -0
- package/docs/mcp-charter-eval.md +124 -0
- package/docs/shift-logs.md +18 -0
- package/docs/wire-contracts.md +28 -7
- package/examples/workflows/compile-dev-playbook.yaml +1 -1
- package/examples/workflows/ship.yaml +28 -2
- package/package.json +2 -1
- package/plugins/claude-code/plugin/.claude-plugin/plugin.json +1 -1
- package/plugins/claude-code/plugin/.mcp.json +1 -1
- package/plugins/claude-code/plugin/skills/author/SKILL.md +22 -0
- package/plugins/claude-code/plugin/skills/ephemeral/SKILL.md +95 -0
- package/plugins/claude-code/plugin/skills/graduate/SKILL.md +156 -0
- package/plugins/claude-code/plugin/skills/plan/SKILL.md +236 -0
- package/plugins/codex/plugins/owenloop/.codex-plugin/plugin.json +1 -1
- package/plugins/codex/plugins/owenloop/.mcp.json +1 -1
- package/plugins/codex/plugins/owenloop/skills/author/SKILL.md +22 -0
- package/plugins/codex/plugins/owenloop/skills/ephemeral/SKILL.md +95 -0
- package/plugins/codex/plugins/owenloop/skills/graduate/SKILL.md +156 -0
- package/plugins/codex/plugins/owenloop/skills/plan/SKILL.md +236 -0
package/dist/src/model.js
CHANGED
|
@@ -11,6 +11,17 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { bindProduce, elementPath, isMemberOf, parseElement, sealPath, sealStem, } from "./paths.js";
|
|
13
13
|
import { DEBT_STATES, OUTSTANDING_STATES, SETTLED_STATES } from "./types.js";
|
|
14
|
+
/**
|
|
15
|
+
* Time facts used only when classifying a model-checker no-moves state. This
|
|
16
|
+
* asks whether elapsed idle time could release a move; it deliberately does
|
|
17
|
+
* not make time an input to BFS expansion or canonical state identity.
|
|
18
|
+
*/
|
|
19
|
+
const EVENTUAL_TIME_FACTS = {
|
|
20
|
+
now: Number.POSITIVE_INFINITY,
|
|
21
|
+
lastProgressMs: 0,
|
|
22
|
+
inFlight: false,
|
|
23
|
+
alarms: new Map(),
|
|
24
|
+
};
|
|
14
25
|
// ---- step shape classification ----------------------------------------------
|
|
15
26
|
export function mapConsume(step) {
|
|
16
27
|
return step.consumes.find((c) => c.mode === 'map');
|
|
@@ -85,6 +96,24 @@ export function isDebt(a) {
|
|
|
85
96
|
export function isGreen(a) {
|
|
86
97
|
return !!a && a.acceptance === 'green';
|
|
87
98
|
}
|
|
99
|
+
/** The newest skip event wins: later structural routing can supersede an older exclusive skip. */
|
|
100
|
+
function latestSkipKind(art) {
|
|
101
|
+
for (let i = art.reasons.length - 1; i >= 0; i--) {
|
|
102
|
+
const reason = art.reasons[i];
|
|
103
|
+
if (reason.action === 'skip')
|
|
104
|
+
return reason.kind;
|
|
105
|
+
}
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
/** Only engine-authored structural skips are dead-branch cascades eligible for gate revival. */
|
|
109
|
+
function isEngineStructuralSkip(art) {
|
|
110
|
+
for (let i = art.reasons.length - 1; i >= 0; i--) {
|
|
111
|
+
const reason = art.reasons[i];
|
|
112
|
+
if (reason.action === 'skip')
|
|
113
|
+
return reason.kind === 'structural' && reason.by === 'engine';
|
|
114
|
+
}
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
88
117
|
/**
|
|
89
118
|
* §6 liveness: a judgment-rejected artifact that has been knocked back `cap`
|
|
90
119
|
* times has *stalled*. It stays a debt (so it surfaces as stuck), but the engine
|
|
@@ -394,6 +423,18 @@ export function requiredInputs(def, arts, art) {
|
|
|
394
423
|
}
|
|
395
424
|
return plain;
|
|
396
425
|
}
|
|
426
|
+
/**
|
|
427
|
+
* Dependencies used only by maintenance. A calls step's `callsInputs` are its
|
|
428
|
+
* scheduling gate and its dead-branch edge, but deliberately do not belong to
|
|
429
|
+
* `requiredInputs()`: that function defines build fingerprints, while live
|
|
430
|
+
* calls outputs also carry a child-outcome pin key.
|
|
431
|
+
*/
|
|
432
|
+
function maintenanceInputs(def, arts, art) {
|
|
433
|
+
const step = stepByName(def, art.producer);
|
|
434
|
+
if (step?.calls)
|
|
435
|
+
return Object.values(step.callsInputs ?? {});
|
|
436
|
+
return requiredInputs(def, arts, art);
|
|
437
|
+
}
|
|
397
438
|
/** The {path → version} snapshot over a set of input paths. */
|
|
398
439
|
export function computeFingerprint(arts, paths) {
|
|
399
440
|
const fp = {};
|
|
@@ -508,7 +549,10 @@ function idleEligible(step, arts, time) {
|
|
|
508
549
|
}
|
|
509
550
|
/**
|
|
510
551
|
* Is a `calls:` step's gate ready in this state — i.e. is every parent artifact
|
|
511
|
-
* wired into `callsInputs` green?
|
|
552
|
+
* wired into `callsInputs` green? Those stems are also the maintenance
|
|
553
|
+
* dead-input edges for the calls output. They intentionally remain absent from
|
|
554
|
+
* `StepDef.consumes` and `requiredInputs()`, which define build fingerprints:
|
|
555
|
+
* a live calls output additionally carries its child-outcome pin.
|
|
512
556
|
*
|
|
513
557
|
* This is the model-side mirror of `Engine.callsGateReady` (engine.ts) and MUST
|
|
514
558
|
* read the same field it does: `callsInputs`, the mapping {child input name →
|
|
@@ -539,9 +583,10 @@ function callsGateReady(step, arts) {
|
|
|
539
583
|
* deadlock/stall branch, which relabelled EVERY zero-firing state in the def —
|
|
540
584
|
* so one unrelated `calls:` step anywhere in a def suppressed every genuine
|
|
541
585
|
* deadlock in it. Modeling the discharge as a successor state instead keeps the
|
|
542
|
-
* classification strictly per-state: the
|
|
543
|
-
*
|
|
544
|
-
*
|
|
586
|
+
* classification strictly per-state: the synthetic green represents the
|
|
587
|
+
* opaque completion of the whole child plus exposure of its one declared
|
|
588
|
+
* output, and nothing else in the parent changes. A deadlock elsewhere in the
|
|
589
|
+
* same def is therefore still reached and still reported.
|
|
545
590
|
*
|
|
546
591
|
* Kept separate from `eligibleFirings` deliberately: that function is the LIVE
|
|
547
592
|
* engine scheduler and a `calls:` step must never become a worker order. These
|
|
@@ -566,6 +611,49 @@ function callsDischargeFirings(def, arts) {
|
|
|
566
611
|
}
|
|
567
612
|
return firings;
|
|
568
613
|
}
|
|
614
|
+
/**
|
|
615
|
+
* The model-only collection-member retractions available in THIS state.
|
|
616
|
+
*
|
|
617
|
+
* `Engine.retract()` is an authority action rather than a scheduler action:
|
|
618
|
+
* every existing bare member that is not already retracted remains available
|
|
619
|
+
* to each authorized non-judge consumer. In particular, the transition must
|
|
620
|
+
* remain available after rejection, when a member has no ordinary map firing;
|
|
621
|
+
* otherwise modelCheck would call that runtime-valid state a deadlock.
|
|
622
|
+
*
|
|
623
|
+
* Kept separate from `eligibleFirings` deliberately: that function is the
|
|
624
|
+
* live worker scheduler, while these synthetic firings are consumed only by
|
|
625
|
+
* modelCheck's successor expansion.
|
|
626
|
+
*/
|
|
627
|
+
export function memberRetractFirings(def, arts) {
|
|
628
|
+
const members = [...arts.values()]
|
|
629
|
+
.flatMap((art) => {
|
|
630
|
+
const el = parseElement(art.path);
|
|
631
|
+
return el && el.suffix === '' && art.acceptance !== 'retracted' ? [{ art, el }] : [];
|
|
632
|
+
})
|
|
633
|
+
.sort((a, b) => a.el.stem.localeCompare(b.el.stem) || a.el.index - b.el.index || a.art.path.localeCompare(b.art.path));
|
|
634
|
+
const firings = [];
|
|
635
|
+
for (const step of def.steps) {
|
|
636
|
+
// Synthesized judges may only invalidate the singleton in their `judges:`
|
|
637
|
+
// marker; their read-only context consumes grant no member-retract authority.
|
|
638
|
+
if (step.judges !== undefined)
|
|
639
|
+
continue;
|
|
640
|
+
for (const { art, el } of members) {
|
|
641
|
+
// Match Engine.assertAuthority's defensive exact-path comparison as well
|
|
642
|
+
// as its normal stem comparison. `some` also deduplicates repeated edges.
|
|
643
|
+
if (!step.consumes.some((consume) => consume.stem === el.stem || consume.stem === art.path))
|
|
644
|
+
continue;
|
|
645
|
+
firings.push({
|
|
646
|
+
modelTransition: 'member-retract',
|
|
647
|
+
step: step.name,
|
|
648
|
+
key: art.path,
|
|
649
|
+
index: el.index,
|
|
650
|
+
inputs: [],
|
|
651
|
+
outputs: [art.path],
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
return firings;
|
|
656
|
+
}
|
|
569
657
|
/**
|
|
570
658
|
* Every firing eligible *right now* — inputs satisfied AND an owed/rejected
|
|
571
659
|
* output to discharge. This is the scheduling gate (§11.4): necessary, not
|
|
@@ -828,9 +916,11 @@ export function canEverFire(step, def, reachable) {
|
|
|
828
916
|
* The standing guard: re-derive the invariant "an artifact is green only while
|
|
829
917
|
* every artifact it directly consumed is green and unmoved" and report the
|
|
830
918
|
* structural ops needed to restore it. Pure — the engine applies the ops and
|
|
831
|
-
* re-runs to a fixpoint. Covers
|
|
832
|
-
* tombstoning of map children, skip-propagation down dead branches,
|
|
833
|
-
*
|
|
919
|
+
* re-runs to a fixpoint. Covers ordinary build-fingerprint invalidation,
|
|
920
|
+
* retract/skip tombstoning of map children, skip-propagation down dead branches,
|
|
921
|
+
* and skipped-subtree revival. Calls gates are maintenance-local: they settle a
|
|
922
|
+
* dead calls branch and revive its engine cascade skip, but never validate a
|
|
923
|
+
* green calls fingerprint (which also includes a child-outcome pin).
|
|
834
924
|
*/
|
|
835
925
|
export function maintainDecisions(def, arts, time) {
|
|
836
926
|
const ops = [];
|
|
@@ -846,7 +936,9 @@ export function maintainDecisions(def, arts, time) {
|
|
|
846
936
|
// Re-arming on "inputs are green" alone would thrash, since the skip itself
|
|
847
937
|
// was made on green inputs (§16.1).
|
|
848
938
|
if (art.acceptance === 'skipped') {
|
|
849
|
-
const
|
|
939
|
+
const producerStep = stepByName(def, art.producer);
|
|
940
|
+
const isCallsCascade = producerStep?.calls && isEngineStructuralSkip(art);
|
|
941
|
+
const req = isCallsCascade ? maintenanceInputs(def, arts, art) : requiredInputs(def, arts, art);
|
|
850
942
|
const allGreen = req.length > 0 && req.every((p) => isGreen(arts.get(p)));
|
|
851
943
|
const moved = !fingerprintMatches(arts, req, art.fingerprint ?? {});
|
|
852
944
|
if (allGreen && moved) {
|
|
@@ -854,13 +946,11 @@ export function maintainDecisions(def, arts, time) {
|
|
|
854
946
|
}
|
|
855
947
|
continue;
|
|
856
948
|
}
|
|
857
|
-
const
|
|
858
|
-
if (req.length === 0)
|
|
859
|
-
continue; // a seeded input with no producer-inputs: nothing to rest on
|
|
949
|
+
const maintenanceReq = maintenanceInputs(def, arts, art);
|
|
860
950
|
// the first input that is not green (settled-dead or merely in-flight)
|
|
861
951
|
let offender;
|
|
862
952
|
let offenderPath;
|
|
863
|
-
for (const p of
|
|
953
|
+
for (const p of maintenanceReq) {
|
|
864
954
|
const dep = arts.get(p);
|
|
865
955
|
if (!isGreen(dep)) {
|
|
866
956
|
offender = dep;
|
|
@@ -874,15 +964,16 @@ export function maintainDecisions(def, arts, time) {
|
|
|
874
964
|
// (§11.8). `submitted` is never terminal (terminal applies at judge-approve
|
|
875
965
|
// time, §4.8, so a still-submitted artifact cannot have terminal:true yet).
|
|
876
966
|
if ((art.acceptance === 'green' && !art.terminal) || art.acceptance === 'submitted') {
|
|
877
|
-
const versionsOk = fingerprintMatches(arts, req, art.fingerprint ?? {});
|
|
878
|
-
if (!offender && versionsOk)
|
|
879
|
-
continue; // invariant holds
|
|
880
|
-
// Dead/settled input: structural cascade (retract or skip). NOT gated by effect:
|
|
881
|
-
// (§17.5 — dead-input cascade for non-idempotent steps is unconditionally structural).
|
|
882
967
|
if (offender && offenderPath) {
|
|
883
968
|
ops.push(cascadeFromDeadInput(art.path, offender, offenderPath, isMapChild));
|
|
884
969
|
continue;
|
|
885
970
|
}
|
|
971
|
+
const req = requiredInputs(def, arts, art);
|
|
972
|
+
if (req.length === 0)
|
|
973
|
+
continue; // a seeded input with no producer-inputs: nothing to rest on
|
|
974
|
+
const versionsOk = fingerprintMatches(arts, req, art.fingerprint ?? {});
|
|
975
|
+
if (versionsOk)
|
|
976
|
+
continue; // invariant holds
|
|
886
977
|
// All inputs are green but at least one moved (version changed). Route on effect:.
|
|
887
978
|
const moved = req.find((p) => (arts.get(p)?.version ?? -1) !== (art.fingerprint ?? {})[p]);
|
|
888
979
|
const producerStep = stepByName(def, art.producer);
|
|
@@ -917,19 +1008,12 @@ export function maintainDecisions(def, arts, time) {
|
|
|
917
1008
|
ops.push(cascadeFromDeadInput(art.path, offender, offenderPath, isMapChild));
|
|
918
1009
|
}
|
|
919
1010
|
}
|
|
920
|
-
// §26: declarative exclusive produce-groups
|
|
921
|
-
//
|
|
922
|
-
//
|
|
923
|
-
//
|
|
924
|
-
//
|
|
925
|
-
//
|
|
926
|
-
// is an OUTSTANDING state; left alone the instance can never reach
|
|
927
|
-
// done: true. Auto-skip settles them (clearing any partial approvals so a
|
|
928
|
-
// later resubmission never inherits a stale sign-off); the ordinary
|
|
929
|
-
// skipped-artifact rearm loop above (which runs on the artifact's own next
|
|
930
|
-
// maintenance pass) revives them if the winner is later un-greened
|
|
931
|
-
// (rejected/retracted) and the group's fingerprint-gated inputs move again
|
|
932
|
-
// — no separate rearm code is needed.
|
|
1011
|
+
// §26: declarative exclusive produce-groups. A green winner auto-skips
|
|
1012
|
+
// competing debt/submitted siblings. Once no winner remains, only siblings
|
|
1013
|
+
// whose latest skip reason is 'exclusive' re-arm: their routing decision was
|
|
1014
|
+
// the winner, not their producer inputs. The generic fingerprint gate above
|
|
1015
|
+
// intentionally cannot cover winner-only movement because those inputs did
|
|
1016
|
+
// not move. The two paths are mutually exclusive in one maintenance pass.
|
|
933
1017
|
for (const step of def.steps) {
|
|
934
1018
|
if (!step.groups || step.groups.length === 0)
|
|
935
1019
|
continue;
|
|
@@ -937,8 +1021,19 @@ export function maintainDecisions(def, arts, time) {
|
|
|
937
1021
|
if (g.mode === 'atLeastOne')
|
|
938
1022
|
continue;
|
|
939
1023
|
const winner = g.of.find((stem) => arts.get(stem)?.acceptance === 'green');
|
|
940
|
-
if (!winner)
|
|
1024
|
+
if (!winner) {
|
|
1025
|
+
for (const stem of g.of) {
|
|
1026
|
+
const sib = arts.get(stem);
|
|
1027
|
+
if (sib?.acceptance !== 'skipped' || latestSkipKind(sib) !== 'exclusive')
|
|
1028
|
+
continue;
|
|
1029
|
+
ops.push({
|
|
1030
|
+
kind: 'rearm',
|
|
1031
|
+
path: stem,
|
|
1032
|
+
reason: `group '${g.group}' (${g.mode}): winner is no longer green, re-arming exclusive sibling`,
|
|
1033
|
+
});
|
|
1034
|
+
}
|
|
941
1035
|
continue;
|
|
1036
|
+
}
|
|
942
1037
|
for (const stem of g.of) {
|
|
943
1038
|
if (stem === winner)
|
|
944
1039
|
continue;
|
|
@@ -1025,6 +1120,31 @@ function cascadeFromDeadInput(path, offender, offenderPath, isMapChild) {
|
|
|
1025
1120
|
}
|
|
1026
1121
|
return { kind: 'reject', path, reason: `auto-invalidated: ${offenderPath} changed` };
|
|
1027
1122
|
}
|
|
1123
|
+
/**
|
|
1124
|
+
* Whether one workflow instance has no outstanding artifact state (§17/§26).
|
|
1125
|
+
*
|
|
1126
|
+
* `atLeastOne` is the sole exception to a straight outstanding-state scan:
|
|
1127
|
+
* once any member is green, owed siblings may remain untouched forever without
|
|
1128
|
+
* keeping the workflow open. This predicate is intentionally cheaper than
|
|
1129
|
+
* `workflowStatus` so hot engine paths can share its exact completion rule
|
|
1130
|
+
* without building debts, eligibility, blockers, or pending-judge details.
|
|
1131
|
+
*/
|
|
1132
|
+
export function workflowDone(def, arts) {
|
|
1133
|
+
const satisfiedAtLeastOneMembers = new Set();
|
|
1134
|
+
for (const step of def.steps) {
|
|
1135
|
+
if (!step.groups)
|
|
1136
|
+
continue;
|
|
1137
|
+
for (const g of step.groups) {
|
|
1138
|
+
if (g.mode !== 'atLeastOne')
|
|
1139
|
+
continue;
|
|
1140
|
+
if (g.of.some((stem) => arts.get(stem)?.acceptance === 'green')) {
|
|
1141
|
+
for (const stem of g.of)
|
|
1142
|
+
satisfiedAtLeastOneMembers.add(stem);
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
return ![...arts.values()].some((a) => OUTSTANDING_STATES.has(a.acceptance) && !(a.acceptance === 'owed' && satisfiedAtLeastOneMembers.has(a.path)));
|
|
1147
|
+
}
|
|
1028
1148
|
/** Derive the operator view purely from artifact state (§17) — never stored. */
|
|
1029
1149
|
export function workflowStatus(def, arts) {
|
|
1030
1150
|
const debts = [];
|
|
@@ -1091,25 +1211,7 @@ export function workflowStatus(def, arts) {
|
|
|
1091
1211
|
pending.push({ path: a.path, version: a.version, pendingJudges });
|
|
1092
1212
|
}
|
|
1093
1213
|
pending.sort((x, y) => x.path.localeCompare(y.path));
|
|
1094
|
-
|
|
1095
|
-
// other members may legitimately sit `owed` forever (no auto-skip fires for
|
|
1096
|
-
// atLeastOne, unlike exactlyOne/atMostOne) without that being "not done".
|
|
1097
|
-
// Stored acceptance is untouched; this is a done-ness computation only.
|
|
1098
|
-
const satisfiedAtLeastOneMembers = new Set();
|
|
1099
|
-
for (const step of def.steps) {
|
|
1100
|
-
if (!step.groups)
|
|
1101
|
-
continue;
|
|
1102
|
-
for (const g of step.groups) {
|
|
1103
|
-
if (g.mode !== 'atLeastOne')
|
|
1104
|
-
continue;
|
|
1105
|
-
if (g.of.some((stem) => arts.get(stem)?.acceptance === 'green')) {
|
|
1106
|
-
for (const stem of g.of)
|
|
1107
|
-
satisfiedAtLeastOneMembers.add(stem);
|
|
1108
|
-
}
|
|
1109
|
-
}
|
|
1110
|
-
}
|
|
1111
|
-
const done = ![...arts.values()].some((a) => OUTSTANDING_STATES.has(a.acceptance) && !(a.acceptance === 'owed' && satisfiedAtLeastOneMembers.has(a.path)));
|
|
1112
|
-
return { done, debts, eligible, blocked, pending, inFlight: [] };
|
|
1214
|
+
return { done: workflowDone(def, arts), debts, eligible, blocked, pending, inFlight: [] };
|
|
1113
1215
|
}
|
|
1114
1216
|
/** The declared judge names for a produce stem (empty if the stem has no judges). */
|
|
1115
1217
|
function declaredJudgeNames(def, stem) {
|
|
@@ -1714,8 +1816,15 @@ function applyOpInMemory(arts, def, op) {
|
|
|
1714
1816
|
if (!art)
|
|
1715
1817
|
return;
|
|
1716
1818
|
if (op.kind === 'rearm') {
|
|
1717
|
-
// mirrors Engine.applyOp rearm branch: acceptance → 'owed'
|
|
1718
|
-
arts.set(op.path, {
|
|
1819
|
+
// mirrors Engine.applyOp rearm branch: acceptance → 'owed' + reopen reason.
|
|
1820
|
+
arts.set(op.path, {
|
|
1821
|
+
...art,
|
|
1822
|
+
acceptance: 'owed',
|
|
1823
|
+
reasons: [
|
|
1824
|
+
...art.reasons,
|
|
1825
|
+
{ at: 0, action: 'reopen', kind: 'structural', by: 'engine', text: op.reason, fromVersion: art.version },
|
|
1826
|
+
],
|
|
1827
|
+
});
|
|
1719
1828
|
return;
|
|
1720
1829
|
}
|
|
1721
1830
|
if (op.kind === 'skip') {
|
|
@@ -1729,6 +1838,17 @@ function applyOpInMemory(arts, def, op) {
|
|
|
1729
1838
|
acceptance: 'skipped',
|
|
1730
1839
|
...(clearApprovals ? { approvals: undefined } : {}),
|
|
1731
1840
|
fingerprint: computeFingerprint(arts, requiredInputs(def, arts, art)),
|
|
1841
|
+
reasons: [
|
|
1842
|
+
...art.reasons,
|
|
1843
|
+
{
|
|
1844
|
+
at: 0,
|
|
1845
|
+
action: 'skip',
|
|
1846
|
+
kind: op.rejectKind ?? 'structural',
|
|
1847
|
+
by: 'engine',
|
|
1848
|
+
text: op.reason,
|
|
1849
|
+
fromVersion: art.version,
|
|
1850
|
+
},
|
|
1851
|
+
],
|
|
1732
1852
|
});
|
|
1733
1853
|
return;
|
|
1734
1854
|
}
|
|
@@ -1831,6 +1951,9 @@ function seedArts(def, assumeProvided = false) {
|
|
|
1831
1951
|
}
|
|
1832
1952
|
/** Internal: the eligible outcomes for a given firing. */
|
|
1833
1953
|
function eligibleOutcomes(def, arts, firing) {
|
|
1954
|
+
if (firing.modelTransition === 'member-retract') {
|
|
1955
|
+
return ['retract'];
|
|
1956
|
+
}
|
|
1834
1957
|
const step = def.steps.find((l) => l.name === firing.step);
|
|
1835
1958
|
if (!step)
|
|
1836
1959
|
return ['green'];
|
|
@@ -1858,8 +1981,9 @@ function eligibleOutcomes(def, arts, firing) {
|
|
|
1858
1981
|
}
|
|
1859
1982
|
// M2: a `calls:` firing is the machine handing off to a child instance, not a
|
|
1860
1983
|
// worker order. The only outcome the PARENT def can observe is the child's
|
|
1861
|
-
// terminal
|
|
1862
|
-
//
|
|
1984
|
+
// terminal completion cascading up as a green on the calls artifact while
|
|
1985
|
+
// exposing the child's declared output. None of the worker-verb outcomes
|
|
1986
|
+
// apply: there is no worker to schema-reject a value, no
|
|
1863
1987
|
// consumer to judgment-reject (a calls: step declares `consumes: []`), and a
|
|
1864
1988
|
// calls: produce may carry neither `judges:` nor `group:` (rejected by
|
|
1865
1989
|
// `buildStep`). Modeling only the green keeps the successor set faithful to
|
|
@@ -1977,7 +2101,8 @@ function applyEmitSeal(def, arts, firing, maxCollectionSize) {
|
|
|
1977
2101
|
* bumping judgmentRejects+1
|
|
1978
2102
|
* 'schema-reject' — acceptance rejected, schemaRejects+1 on the output
|
|
1979
2103
|
* 'skip' — acceptance skipped + fingerprint of requiredInputs
|
|
1980
|
-
* 'retract' —
|
|
2104
|
+
* 'retract' — a non-judge consumer retracts an authorized bare
|
|
2105
|
+
* collection member; acceptance becomes retracted
|
|
1981
2106
|
* 'emit-seal' — collection producer: emit 1..maxCollectionSize green elements,
|
|
1982
2107
|
* then seal; forks into (maxCollectionSize+1) successor states
|
|
1983
2108
|
*
|
|
@@ -2087,6 +2212,10 @@ export function applyOutcome(def, arts, firing, outcome, opts) {
|
|
|
2087
2212
|
...art,
|
|
2088
2213
|
acceptance: 'skipped',
|
|
2089
2214
|
fingerprint: computeFingerprint(arts, requiredInputs(def, arts, art)),
|
|
2215
|
+
reasons: [
|
|
2216
|
+
...art.reasons,
|
|
2217
|
+
{ at: 0, action: 'skip', kind: 'structural', by: 'engine', text: 'producer skipped output', fromVersion: art.version },
|
|
2218
|
+
],
|
|
2090
2219
|
});
|
|
2091
2220
|
}
|
|
2092
2221
|
else if (outcome === 'retract') {
|
|
@@ -2107,8 +2236,8 @@ export function applyOutcome(def, arts, firing, outcome, opts) {
|
|
|
2107
2236
|
* are distinct but anything >= cap is the same (frozen state)
|
|
2108
2237
|
* schemaRejects: BUCKETED to min(count, maxSchemaFailures) similarly
|
|
2109
2238
|
*
|
|
2110
|
-
* For 'skipped' artifacts, the fingerprint
|
|
2111
|
-
*
|
|
2239
|
+
* For 'skipped' artifacts, the fingerprint and latest skip kind are encoded to
|
|
2240
|
+
* capture their distinct rearm eligibility correctly.
|
|
2112
2241
|
*/
|
|
2113
2242
|
function canonicalKey(def, arts) {
|
|
2114
2243
|
const parts = [];
|
|
@@ -2149,6 +2278,8 @@ function canonicalKey(def, arts) {
|
|
|
2149
2278
|
.join(',');
|
|
2150
2279
|
entry += `|fp:${fpParts}`;
|
|
2151
2280
|
}
|
|
2281
|
+
if (art.acceptance === 'skipped')
|
|
2282
|
+
entry += `|skip:${latestSkipKind(art) ?? 'none'}`;
|
|
2152
2283
|
parts.push(entry);
|
|
2153
2284
|
}
|
|
2154
2285
|
return parts.join(';');
|
|
@@ -2159,13 +2290,14 @@ function canonicalKey(def, arts) {
|
|
|
2159
2290
|
* Explores the full (or depth/state-bounded) state space via BFS to find:
|
|
2160
2291
|
* - a non-done, zero-eligible-firings state is split into exactly ONE of two
|
|
2161
2292
|
* mutually exclusive buckets by recomputing eligibility with every freeze
|
|
2162
|
-
* lifted (unlimited attempts — see
|
|
2163
|
-
*
|
|
2164
|
-
*
|
|
2165
|
-
*
|
|
2293
|
+
* lifted and eventual idle time (unlimited attempts — see
|
|
2294
|
+
* `eligibleFirings`'s `ignoreFreeze`):
|
|
2295
|
+
* - stall states: the recompute yields >= 1 firing — a retryable frozen debt
|
|
2296
|
+
* or future idle threshold is the only blocker. An expected brake/wait,
|
|
2297
|
+
* never a defect.
|
|
2166
2298
|
* - true deadlocks: the recompute STILL yields zero firings — a genuine
|
|
2167
|
-
* structural dead-end with no
|
|
2168
|
-
*
|
|
2299
|
+
* structural dead-end with no move even after retry or elapsed idle time.
|
|
2300
|
+
* A real defect.
|
|
2169
2301
|
* - stuck states: reachable states that have a stalled debt but STILL have
|
|
2170
2302
|
* >= 1 eligible firing elsewhere (a brake tripped on one branch while the
|
|
2171
2303
|
* line moves on another). Informational only; a no-moves state is never
|
|
@@ -2196,6 +2328,8 @@ export function modelCheck(def, opts = {}) {
|
|
|
2196
2328
|
def: def.name,
|
|
2197
2329
|
bounded: false,
|
|
2198
2330
|
boundsHit: [],
|
|
2331
|
+
collectionCapApplied: false,
|
|
2332
|
+
maxCollectionSize,
|
|
2199
2333
|
deadlocks: [],
|
|
2200
2334
|
stallStates: [],
|
|
2201
2335
|
stuck: [],
|
|
@@ -2257,8 +2391,9 @@ export function modelCheck(def, opts = {}) {
|
|
|
2257
2391
|
// which is false: the engine does spawn the child and the debt is
|
|
2258
2392
|
// discharged.
|
|
2259
2393
|
//
|
|
2260
|
-
// The child is modeled as a single opaque
|
|
2261
|
-
//
|
|
2394
|
+
// The child is modeled as a single opaque whole-child completion that greens
|
|
2395
|
+
// the calls artifact and exposes its declared output — the only thing the
|
|
2396
|
+
// parent def can observe about it. `callsDischargeFirings`
|
|
2262
2397
|
// gates per-step on `callsInputs` (the same field `Engine.callsGateReady`
|
|
2263
2398
|
// reads), so a `calls:` step whose gate is NOT green yields no firing and
|
|
2264
2399
|
// the state is classified on its own merits. Because the discharge greens
|
|
@@ -2268,15 +2403,20 @@ export function modelCheck(def, opts = {}) {
|
|
|
2268
2403
|
// `eligibleFirings` (the LIVE engine scheduler) and `hasDefiniteCheckDefect`
|
|
2269
2404
|
// (shared by check / add / push / install) are deliberately untouched.
|
|
2270
2405
|
const callsFirings = callsDischargeFirings(def, node.arts);
|
|
2271
|
-
|
|
2272
|
-
//
|
|
2273
|
-
//
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
//
|
|
2406
|
+
// Member retraction is likewise a runtime-valid authority transition, not
|
|
2407
|
+
// a worker firing. It is separate from eligibleFirings so a rejected map
|
|
2408
|
+
// input still has the later retract move the runtime permits.
|
|
2409
|
+
const retractFirings = memberRetractFirings(def, node.arts);
|
|
2410
|
+
const firings = [...status.eligible, ...callsFirings, ...retractFirings];
|
|
2411
|
+
// Non-done state with no eligible firings: classify by recomputing
|
|
2412
|
+
// eligibility as if every freeze/stall were lifted and idle time had
|
|
2413
|
+
// elapsed. If retry or time would make a producer eligible, this is an
|
|
2414
|
+
// expected stall/wait; otherwise it is a true structural deadlock.
|
|
2415
|
+
// EVENTUAL_TIME_FACTS is classification-only: the timeless BFS below does
|
|
2416
|
+
// not enqueue these future idle transitions or include time in its key.
|
|
2277
2417
|
if (firings.length === 0 && !status.done) {
|
|
2278
|
-
const
|
|
2279
|
-
if (
|
|
2418
|
+
const eventualFirings = eligibleFirings(def, node.arts, EVENTUAL_TIME_FACTS, { ignoreFreeze: true });
|
|
2419
|
+
if (eventualFirings.length > 0) {
|
|
2280
2420
|
report.stallStates.push({ path: node.path });
|
|
2281
2421
|
}
|
|
2282
2422
|
else {
|
|
@@ -2298,7 +2438,11 @@ export function modelCheck(def, opts = {}) {
|
|
|
2298
2438
|
}
|
|
2299
2439
|
// Expand successors
|
|
2300
2440
|
outer: for (const firing of firings) {
|
|
2301
|
-
|
|
2441
|
+
// An authority-only member retract does not prove its actor ever
|
|
2442
|
+
// produced an ordinary firing; preserve structural-dead-step accounting.
|
|
2443
|
+
if (firing.modelTransition !== 'member-retract') {
|
|
2444
|
+
firedSteps.add(firing.step);
|
|
2445
|
+
}
|
|
2302
2446
|
const outcomes = eligibleOutcomes(def, node.arts, firing);
|
|
2303
2447
|
for (const outcome of outcomes) {
|
|
2304
2448
|
// Check state count before expanding
|
|
@@ -2307,6 +2451,8 @@ export function modelCheck(def, opts = {}) {
|
|
|
2307
2451
|
break outer;
|
|
2308
2452
|
}
|
|
2309
2453
|
const step = { step: firing.step, key: firing.key, outcome };
|
|
2454
|
+
if (outcome === 'emit-seal')
|
|
2455
|
+
report.collectionCapApplied = true;
|
|
2310
2456
|
const successors = applyOutcome(def, node.arts, firing, outcome, { maxCollectionSize });
|
|
2311
2457
|
for (const suc of successors) {
|
|
2312
2458
|
const key = canonicalKey(def, suc);
|
|
@@ -39,6 +39,8 @@ export interface LoadCasDefsArgs {
|
|
|
39
39
|
globalRoot: string;
|
|
40
40
|
/** Warning sink used only by tolerant inspection and collision notices. */
|
|
41
41
|
warn: (line: string) => void;
|
|
42
|
+
/** Emit the full per-candidate superseded-version notices. */
|
|
43
|
+
verbose?: boolean;
|
|
42
44
|
}
|
|
43
45
|
/** Explicitly partial result for read-only inspection. */
|
|
44
46
|
export interface CasDefInspectionResult {
|
|
@@ -48,5 +50,22 @@ export interface CasDefInspectionResult {
|
|
|
48
50
|
}
|
|
49
51
|
/** Strict executable discovery. Any indexed integrity failure aborts. */
|
|
50
52
|
export declare function loadCasDefs(args: LoadCasDefsArgs): CasDefRegistration[];
|
|
53
|
+
/**
|
|
54
|
+
* Strict combined-store discovery for a same-digest repair transaction.
|
|
55
|
+
*
|
|
56
|
+
* The installer calls this only after independently verifying the staged
|
|
57
|
+
* replacement. Substituting those bytes for the repairing root/digest lets its
|
|
58
|
+
* exact reinstall reach the repair swap without removing the indexed digest
|
|
59
|
+
* that project fallback legitimately depends on. Every dependency, unrelated
|
|
60
|
+
* object, and same-digest copy at another root still goes through the ordinary
|
|
61
|
+
* strict execution-time discovery path.
|
|
62
|
+
* This transaction-only seam is deliberately not re-exported from the store
|
|
63
|
+
* barrel: executable discovery must never suppress a corrupt object.
|
|
64
|
+
*/
|
|
65
|
+
export declare function loadCasDefsWithRepairReplacement(args: LoadCasDefsArgs, replacement: {
|
|
66
|
+
root: string;
|
|
67
|
+
digest: DefDigest;
|
|
68
|
+
objectDir: string;
|
|
69
|
+
}): CasDefRegistration[];
|
|
51
70
|
/** Tolerant read-only inspection. Never use this result for execution. */
|
|
52
71
|
export declare function inspectCasDefs(args: LoadCasDefsArgs): CasDefInspectionResult;
|