@lmzhen/dsh-evolution-core 0.19.1 → 0.19.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/lib/index.js +21 -14
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -6049,6 +6049,15 @@ function newRunRegistry(options) {
|
|
|
6049
6049
|
const records = [];
|
|
6050
6050
|
const controllers = /* @__PURE__ */ new Map();
|
|
6051
6051
|
const ordered = () => [...records].sort((a, b) => b.startedAt - a.startedAt);
|
|
6052
|
+
/** The ONE wording of the orphan verdict — read-time convergence says it in two places. */
|
|
6053
|
+
const ORPHAN_FAILURE = "no live owner process — the run was interrupted before it settled (orphan)";
|
|
6054
|
+
/** A `running` record whose owner is gone, as the index must show it. */
|
|
6055
|
+
const orphanOf = (record) => ({
|
|
6056
|
+
...record,
|
|
6057
|
+
state: "failed",
|
|
6058
|
+
endedAt: now(),
|
|
6059
|
+
failure: ORPHAN_FAILURE
|
|
6060
|
+
});
|
|
6052
6061
|
/** Keep every RUNNING record plus the newest terminal ones: memory and the
|
|
6053
6062
|
* index share one cap, so the two can never disagree about the history. */
|
|
6054
6063
|
const trim = () => {
|
|
@@ -6065,7 +6074,12 @@ function newRunRegistry(options) {
|
|
|
6065
6074
|
const onDisk = parseIndex(current);
|
|
6066
6075
|
const merged = /* @__PURE__ */ new Map();
|
|
6067
6076
|
for (const record of onDisk.records) merged.set(record.id, record);
|
|
6068
|
-
for (const record of records)
|
|
6077
|
+
for (const record of records) {
|
|
6078
|
+
const onDiskRow = merged.get(record.id);
|
|
6079
|
+
const settledElsewhere = onDiskRow !== void 0 && TERMINAL.has(onDiskRow.state) && !TERMINAL.has(record.state);
|
|
6080
|
+
if (!controllers.has(record.id) && settledElsewhere) continue;
|
|
6081
|
+
merged.set(record.id, record);
|
|
6082
|
+
}
|
|
6069
6083
|
const view = [...merged.values()].sort((a, b) => b.startedAt - a.startedAt);
|
|
6070
6084
|
const live = view.filter((record) => record.state === "running");
|
|
6071
6085
|
const done = view.filter((record) => TERMINAL.has(record.state)).slice(0, maxRecords);
|
|
@@ -6107,15 +6121,13 @@ function newRunRegistry(options) {
|
|
|
6107
6121
|
const known = records[knownIndex];
|
|
6108
6122
|
if (!controllers.has(record.id) && !TERMINAL.has(known.state)) {
|
|
6109
6123
|
if (TERMINAL.has(record.state)) {
|
|
6110
|
-
|
|
6124
|
+
delete known.endedAt;
|
|
6125
|
+
delete known.resultRef;
|
|
6126
|
+
delete known.failure;
|
|
6127
|
+
Object.assign(known, record);
|
|
6111
6128
|
healed++;
|
|
6112
6129
|
} else if (record.pid === void 0 || !isProcessAlive(record.pid)) {
|
|
6113
|
-
records[knownIndex] =
|
|
6114
|
-
...record,
|
|
6115
|
-
state: "failed",
|
|
6116
|
-
endedAt: now(),
|
|
6117
|
-
failure: "no live owner process — the run was interrupted before it settled (orphan)"
|
|
6118
|
-
};
|
|
6130
|
+
records[knownIndex] = orphanOf(record);
|
|
6119
6131
|
converged++;
|
|
6120
6132
|
}
|
|
6121
6133
|
}
|
|
@@ -6131,12 +6143,7 @@ function newRunRegistry(options) {
|
|
|
6131
6143
|
continue;
|
|
6132
6144
|
}
|
|
6133
6145
|
converged++;
|
|
6134
|
-
records.push(
|
|
6135
|
-
...record,
|
|
6136
|
-
state: "failed",
|
|
6137
|
-
endedAt: now(),
|
|
6138
|
-
failure: "no live owner process — the run was interrupted before it settled (orphan)"
|
|
6139
|
-
});
|
|
6146
|
+
records.push(orphanOf(record));
|
|
6140
6147
|
}
|
|
6141
6148
|
if (converged > 0 || healed > 0) await persist();
|
|
6142
6149
|
const notes = [
|
package/package.json
CHANGED