@rulvar/cli 1.81.0 → 1.81.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +58 -44
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -690,58 +690,70 @@ function createWorker(engine, options) {
|
|
|
690
690
|
await releaseQuietly(lease);
|
|
691
691
|
}
|
|
692
692
|
}
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
if (!
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
693
|
+
/** The sweep in flight, so stop() can wait it out before snapshotting. */
|
|
694
|
+
let sweepInFlight;
|
|
695
|
+
async function sweepBody() {
|
|
696
|
+
let picked = 0;
|
|
697
|
+
const metas = options.retention === void 0 ? await store.listRuns({ statuses: [...CANDIDATE_STATUSES] }) : await store.listRuns();
|
|
698
|
+
const candidateIds = new Set(metas.filter((meta) => CANDIDATE_STATUSES.has(meta.status)).map((meta) => meta.runId));
|
|
699
|
+
for (const runId of [...suspendedAt.keys()]) if (!candidateIds.has(runId)) suspendedAt.delete(runId);
|
|
700
|
+
for (const runId of [...poisoned.keys()]) if (!candidateIds.has(runId)) poisoned.delete(runId);
|
|
701
|
+
for (const meta of metas) {
|
|
702
|
+
if (stopping || active.size >= concurrency) break;
|
|
703
|
+
if (!CANDIDATE_STATUSES.has(meta.status)) {
|
|
704
|
+
if (options.retention !== void 0 && !active.has(meta.runId)) await applyRetention(meta).catch((thrown) => {
|
|
705
|
+
reportError(meta.runId, thrown);
|
|
706
|
+
});
|
|
707
|
+
continue;
|
|
708
|
+
}
|
|
709
|
+
if (active.has(meta.runId)) continue;
|
|
710
|
+
if (poisoned.has(meta.runId)) {
|
|
711
|
+
if (poisoned.get(meta.runId) === meta.genesis) continue;
|
|
712
|
+
poisoned.delete(meta.runId);
|
|
713
|
+
}
|
|
714
|
+
let lease;
|
|
715
|
+
try {
|
|
716
|
+
lease = await store.acquire(meta.runId, owner);
|
|
717
|
+
} catch (thrown) {
|
|
718
|
+
if (thrown instanceof LeaseHeldError) continue;
|
|
719
|
+
throw thrown;
|
|
720
|
+
}
|
|
721
|
+
try {
|
|
722
|
+
const entries = (await store.load(meta.runId)).map((raw) => normalizeEntry(raw));
|
|
723
|
+
scanJournalCompatibility(meta.runId, entries, registry);
|
|
724
|
+
const cached = suspendedAt.get(meta.runId);
|
|
725
|
+
if (meta.status === "suspended" && cached !== void 0 && cached.length === entries.length && cached.genesis === meta.genesis) {
|
|
726
|
+
await releaseQuietly(lease);
|
|
708
727
|
continue;
|
|
709
728
|
}
|
|
710
|
-
if (
|
|
711
|
-
if (poisoned.has(meta.runId)) {
|
|
712
|
-
if (poisoned.get(meta.runId) === meta.genesis) continue;
|
|
713
|
-
poisoned.delete(meta.runId);
|
|
714
|
-
}
|
|
715
|
-
let lease;
|
|
716
|
-
try {
|
|
717
|
-
lease = await store.acquire(meta.runId, owner);
|
|
718
|
-
} catch (thrown) {
|
|
719
|
-
if (thrown instanceof LeaseHeldError) continue;
|
|
720
|
-
throw thrown;
|
|
721
|
-
}
|
|
722
|
-
try {
|
|
723
|
-
const entries = (await store.load(meta.runId)).map((raw) => normalizeEntry(raw));
|
|
724
|
-
scanJournalCompatibility(meta.runId, entries, registry);
|
|
725
|
-
const cached = suspendedAt.get(meta.runId);
|
|
726
|
-
if (meta.status === "suspended" && cached !== void 0 && cached.length === entries.length && cached.genesis === meta.genesis) {
|
|
727
|
-
await releaseQuietly(lease);
|
|
728
|
-
continue;
|
|
729
|
-
}
|
|
730
|
-
picked += 1;
|
|
731
|
-
drive(meta.runId, meta, lease);
|
|
732
|
-
} catch (thrown) {
|
|
729
|
+
if (stopping) {
|
|
733
730
|
await releaseQuietly(lease);
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
731
|
+
break;
|
|
732
|
+
}
|
|
733
|
+
picked += 1;
|
|
734
|
+
drive(meta.runId, meta, lease);
|
|
735
|
+
} catch (thrown) {
|
|
736
|
+
await releaseQuietly(lease);
|
|
737
|
+
if (thrown instanceof JournalCompatibilityError || thrown instanceof ConfigError) {
|
|
738
|
+
poisoned.set(meta.runId, meta.genesis);
|
|
739
739
|
reportError(meta.runId, thrown);
|
|
740
|
+
continue;
|
|
740
741
|
}
|
|
742
|
+
reportError(meta.runId, thrown);
|
|
741
743
|
}
|
|
742
|
-
|
|
744
|
+
}
|
|
745
|
+
return picked;
|
|
746
|
+
}
|
|
747
|
+
async function sweep() {
|
|
748
|
+
if (stopping || sweeping) return 0;
|
|
749
|
+
sweeping = true;
|
|
750
|
+
const work = sweepBody();
|
|
751
|
+
sweepInFlight = work.then(() => void 0, () => void 0);
|
|
752
|
+
try {
|
|
753
|
+
return await work;
|
|
743
754
|
} finally {
|
|
744
755
|
sweeping = false;
|
|
756
|
+
sweepInFlight = void 0;
|
|
745
757
|
}
|
|
746
758
|
}
|
|
747
759
|
return {
|
|
@@ -759,6 +771,8 @@ function createWorker(engine, options) {
|
|
|
759
771
|
clearInterval(pollTimer);
|
|
760
772
|
pollTimer = void 0;
|
|
761
773
|
}
|
|
774
|
+
const inFlight = sweepInFlight;
|
|
775
|
+
if (inFlight !== void 0) await inFlight;
|
|
762
776
|
const held = [...active.values()];
|
|
763
777
|
await Promise.all(held.map(async (run) => {
|
|
764
778
|
await run.cancel("worker stopping");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rulvar/cli",
|
|
3
|
-
"version": "1.81.
|
|
3
|
+
"version": "1.81.2",
|
|
4
4
|
"description": "Rulvar shell: run/resume/runs/inspect/plan/kb commands, TUI progress, createServer, createWorker, OTel exporter.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -22,17 +22,17 @@
|
|
|
22
22
|
"access": "public"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@rulvar/core": "1.81.
|
|
25
|
+
"@rulvar/core": "1.81.2"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/node": "^22.20.0",
|
|
29
29
|
"tsdown": "^0.22.3",
|
|
30
30
|
"typescript": "~6.0.3",
|
|
31
|
-
"@rulvar/
|
|
32
|
-
"@rulvar/
|
|
33
|
-
"@rulvar/planner": "1.81.
|
|
34
|
-
"@rulvar/plan": "1.81.
|
|
35
|
-
"@rulvar/evals": "1.81.
|
|
31
|
+
"@rulvar/testing": "1.81.2",
|
|
32
|
+
"@rulvar/store-sqlite": "1.81.2",
|
|
33
|
+
"@rulvar/planner": "1.81.2",
|
|
34
|
+
"@rulvar/plan": "1.81.2",
|
|
35
|
+
"@rulvar/evals": "1.81.2"
|
|
36
36
|
},
|
|
37
37
|
"bin": {
|
|
38
38
|
"rulvar": "./dist/cli.js"
|