@sensigo/realm 0.32.0 → 0.33.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/engine/abandon-run.d.ts.map +1 -1
- package/dist/engine/abandon-run.js +17 -9
- package/dist/engine/abandon-run.js.map +1 -1
- package/dist/engine/apply-resume.d.ts +11 -2
- package/dist/engine/apply-resume.d.ts.map +1 -1
- package/dist/engine/apply-resume.js +15 -4
- package/dist/engine/apply-resume.js.map +1 -1
- package/dist/engine/eligibility.d.ts +20 -2
- package/dist/engine/eligibility.d.ts.map +1 -1
- package/dist/engine/eligibility.js +46 -24
- package/dist/engine/eligibility.js.map +1 -1
- package/dist/engine/execution-loop.d.ts +7 -4
- package/dist/engine/execution-loop.d.ts.map +1 -1
- package/dist/engine/execution-loop.js +810 -87
- package/dist/engine/execution-loop.js.map +1 -1
- package/dist/engine/run-health.d.ts +1 -1
- package/dist/engine/run-health.d.ts.map +1 -1
- package/dist/engine/run-health.js +62 -1
- package/dist/engine/run-health.js.map +1 -1
- package/dist/engine/settlement.d.ts +11 -0
- package/dist/engine/settlement.d.ts.map +1 -1
- package/dist/engine/settlement.js +441 -30
- package/dist/engine/settlement.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/store/json-file-store.d.ts +6 -4
- package/dist/store/json-file-store.d.ts.map +1 -1
- package/dist/store/json-file-store.js +26 -9
- package/dist/store/json-file-store.js.map +1 -1
- package/dist/store/store-interface.d.ts +11 -8
- package/dist/store/store-interface.d.ts.map +1 -1
- package/dist/types/run-record.d.ts +26 -3
- package/dist/types/run-record.d.ts.map +1 -1
- package/dist/types/settlement.d.ts +135 -11
- package/dist/types/settlement.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { classifyInProgressClaims } from './claim-liveness.js';
|
|
2
2
|
import { findCapabilityBlockedSteps } from './capability.js';
|
|
3
|
-
import { findEligibleSteps } from './eligibility.js';
|
|
3
|
+
import { findEligibleSteps, findEligibleGuardSteps } from './eligibility.js';
|
|
4
4
|
/**
|
|
5
5
|
* Default age threshold for the `never_claimed_idle` finding (issue #221) — 24 hours. Engine-
|
|
6
6
|
* minted so detection never REQUIRES an operator-supplied threshold; callers (surfaces) may
|
|
@@ -9,6 +9,34 @@ import { findEligibleSteps } from './eligibility.js';
|
|
|
9
9
|
* inspect take no override by design (agents don't tune detectors).
|
|
10
10
|
*/
|
|
11
11
|
export const DEFAULT_IDLE_THRESHOLD_MS = 24 * 60 * 60 * 1000;
|
|
12
|
+
/**
|
|
13
|
+
* G-2-corruption detector (issue #279, increment 2, PR-D, design record §9/N9): a `settled` entry
|
|
14
|
+
* recording a resolved gate (`outcome === 'gate'`) whose `token` equals the run's OWN live
|
|
15
|
+
* `pending_gate.gate_id` — the both-match corruption `settleGateArms`'s lookup-first ordering
|
|
16
|
+
* fail-safes against (NOOP, never RESOLVE — settlement.ts), but which then leaves `pending_gate`
|
|
17
|
+
* permanently unclearable by normal means (exits: `settle_step` abort, or `realm run purge`).
|
|
18
|
+
* Out-of-contract producer only (a real store honoring `settleStep`'s own atomicity can never
|
|
19
|
+
* produce this); a run-health finding is the detection surface. Checked from BOTH branches of
|
|
20
|
+
* {@link classifyRunHealth} (a live pending_gate can coexist with this corruption whether or not
|
|
21
|
+
* the run has separately gone terminal).
|
|
22
|
+
*/
|
|
23
|
+
function findGateCorruption(run) {
|
|
24
|
+
if (run.pending_gate === undefined)
|
|
25
|
+
return undefined;
|
|
26
|
+
const gateId = run.pending_gate.gate_id;
|
|
27
|
+
for (const [step, entry] of Object.entries(run.settled ?? {})) {
|
|
28
|
+
if (entry.outcome === 'gate' && entry.token === gateId) {
|
|
29
|
+
return {
|
|
30
|
+
kind: 'gate_corruption',
|
|
31
|
+
step,
|
|
32
|
+
reason: 'settled gate entry coexists with a live pending_gate bearing the same gate_id — ' +
|
|
33
|
+
'store history divergent',
|
|
34
|
+
evidence: { gate_id: gateId },
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
12
40
|
/**
|
|
13
41
|
* Classifies a run's health into zero or more typed findings. Pure, read-only, definition-
|
|
14
42
|
* optional, `now`-injectable. See the module doc above for the full branch-conditioning table
|
|
@@ -38,6 +66,22 @@ export function classifyRunHealth(run, opts) {
|
|
|
38
66
|
},
|
|
39
67
|
});
|
|
40
68
|
}
|
|
69
|
+
// issue #279 (increment 2, PR-D, design record §9): terminal-with-stale-gate — the #282
|
|
70
|
+
// class's own surface. A terminal record that STILL carries a pending_gate is a grandfathered
|
|
71
|
+
// (or mixed-fleet old-binary-written) record; purge is the disposal path.
|
|
72
|
+
if (run.pending_gate !== undefined) {
|
|
73
|
+
pendingFindings.push({
|
|
74
|
+
kind: 'terminal_with_stale_gate',
|
|
75
|
+
step: run.pending_gate.step_name,
|
|
76
|
+
reason: 'run is terminal but still carries a pending_gate (a grandfathered #282-class record)',
|
|
77
|
+
evidence: { gate_id: run.pending_gate.gate_id },
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
// G-2-corruption: checked here too — a terminal record can carry the same both-match
|
|
81
|
+
// corruption a live run can (N9).
|
|
82
|
+
const terminalGateCorruption = findGateCorruption(run);
|
|
83
|
+
if (terminalGateCorruption !== undefined)
|
|
84
|
+
pendingFindings.push(terminalGateCorruption);
|
|
41
85
|
if (pendingFindings.length > 0)
|
|
42
86
|
return pendingFindings;
|
|
43
87
|
return []; // terminal ∧ no pending ledger entries ⇒ [] (byte-identical to pre-#279 behavior)
|
|
@@ -68,6 +112,23 @@ export function classifyRunHealth(run, opts) {
|
|
|
68
112
|
evidence: { requirement: b.requirement, code: b.code },
|
|
69
113
|
});
|
|
70
114
|
}
|
|
115
|
+
// issue #279 (increment 2, PR-D, design record §9): G-2-corruption on the non-terminal path too
|
|
116
|
+
// — a live pending_gate can coexist with the same both-match corruption a terminal record can.
|
|
117
|
+
const gateCorruption = findGateCorruption(run);
|
|
118
|
+
if (gateCorruption !== undefined)
|
|
119
|
+
findings.push(gateCorruption);
|
|
120
|
+
// issue #279 (increment 2, PR-D, design record §9, N8's surface): resolved-gate-with-eligible-
|
|
121
|
+
// guard. findEligibleGuardSteps ALREADY self-filters both a terminal run and an open gate
|
|
122
|
+
// (eligibility.ts), so no extra gating is needed beyond requiring a definition.
|
|
123
|
+
if (opts?.definition !== undefined) {
|
|
124
|
+
for (const guardName of findEligibleGuardSteps(opts.definition, run)) {
|
|
125
|
+
findings.push({
|
|
126
|
+
kind: 'resolved_gate_with_eligible_guard',
|
|
127
|
+
step: guardName,
|
|
128
|
+
reason: `gate resolved; guard '${guardName}' awaits the next drive`,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
71
132
|
// Branch 4 — never_claimed_idle (the #221 class). since/idle_ms/evidence.idle_threshold_ms are
|
|
72
133
|
// REQUIRED on this finding.
|
|
73
134
|
if (run.run_phase === 'running' &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-health.js","sourceRoot":"","sources":["../../src/engine/run-health.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"run-health.js","sourceRoot":"","sources":["../../src/engine/run-health.ts"],"names":[],"mappings":"AA2EA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE7E;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAwC7D;;;;;;;;;;GAUG;AACH,SAAS,kBAAkB,CAAC,GAAc;IACxC,IAAI,GAAG,CAAC,YAAY,KAAK,SAAS;QAAE,OAAO,SAAS,CA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EAAE,CAAC;YACrE,QAAQ,CAAC,IAAI,CAAC;gBACZ,IAAI,EAAE,mCAAmC;gBACzC,IAAI,EAAE,SAAS;gBACf,MAAM,EAAE,yBAAyB,SAAS,yBAAyB;aACpE,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,+FAA+F;IAC/F,4BAA4B;IAC5B,IACE,GAAG,CAAC,SAAS,KAAK,SAAS;QAC3B,GAAG,CAAC,iBAAiB,CAAC,MAAM,KAAK,CAAC;QAClC,GAAG,CAAC,OAAO,EAAE,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE,IAAI,eAAe,EACrE,CAAC;QACD,QAAQ,CAAC,IAAI,CAAC;YACZ,IAAI,EAAE,oBAAoB;YAC1B,MAAM,EAAE,mCAAmC;YAC3C,KAAK,EAAE,GAAG,CAAC,UAAU;YACrB,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE;YAC3D,QAAQ,EAAE;gBACR,iBAAiB,EAAE,eAAe;gBAClC,GAAG,CAAC,IAAI,EAAE,UAAU,KAAK,SAAS;oBAChC,CAAC,CAAC,EAAE,cAAc,EAAE,iBAAiB,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,CAAC,EAAE;oBAC7D,CAAC,CAAC,EAAE,CAAC;aACR;SACF,CAAC,CAAC;IACL,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -24,4 +24,15 @@ export declare function selectFinalizers(definition: WorkflowDefinition, settled
|
|
|
24
24
|
export declare function applySettlement(fresh: RunRecord, delta: SettlementDelta, definition: WorkflowDefinition, options?: {
|
|
25
25
|
now?: Date;
|
|
26
26
|
}): SettlementResult;
|
|
27
|
+
/**
|
|
28
|
+
* Named constant (issue #279, increment 2, PR-C; design record §4.3) tying reclaim-step.ts's own
|
|
29
|
+
* open-gate refusal (`reclaimStep`, ~line 389: "the claim is legitimately pinned by a human gate")
|
|
30
|
+
* to this design's "unfenced-release soundness rests on reclaim" premise: `settle_step` abort's
|
|
31
|
+
* cancel-gate write (`applyAbortEdge`, above) is the ONLY path that may release an open gate's
|
|
32
|
+
* claim; `reclaimStep`/`isAutoReclaimable` must NEVER also release it, or the two paths could race
|
|
33
|
+
* and double-release the same claim. Referenced (not asserted via) by this invariant's two
|
|
34
|
+
* existing pinning tests (`reclaim-step.test.ts` + the CLI's `reclaim.test.ts`) so a future reader
|
|
35
|
+
* can grep this name to find both, and reclaim-step.ts's own SOURCE stays untouched by this PR.
|
|
36
|
+
*/
|
|
37
|
+
export declare const RECLAIM_REFUSES_GATE_STEP = "reclaim never releases the open-gate claim (design record design-d5-increment2.md \u00A74.3, unfenced-release soundness)";
|
|
27
38
|
//# sourceMappingURL=settlement.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settlement.d.ts","sourceRoot":"","sources":["../../src/engine/settlement.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAoB,MAAM,iCAAiC,CAAC;AAC5F,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAEhB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"settlement.d.ts","sourceRoot":"","sources":["../../src/engine/settlement.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAoB,MAAM,iCAAiC,CAAC;AAC5F,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAEhB,iBAAiB,EAOlB,MAAM,wBAAwB,CAAC;AA4GhC;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,kBAAkB,EAC9B,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAAC,EACrC,OAAO,EAAE,iBAAiB,GACzB,MAAM,EAAE,CAWV;AAuyBD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,eAAe,EACtB,UAAU,EAAE,kBAAkB,EAC9B,OAAO,CAAC,EAAE;IAAE,GAAG,CAAC,EAAE,IAAI,CAAA;CAAE,GACvB,gBAAgB,CAkBlB;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB,6HACiF,CAAC"}
|