@lmzhen/dsh-evolution-state-json 0.3.65 → 0.3.66
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 +19 -9
- package/package.json +7 -7
package/lib/index.js
CHANGED
|
@@ -239,14 +239,21 @@ function apply(ctx, rawConfig = {}) {
|
|
|
239
239
|
}
|
|
240
240
|
return retired;
|
|
241
241
|
}
|
|
242
|
-
async function retireLegacyOnce(legacy
|
|
242
|
+
async function retireLegacyOnce(legacy) {
|
|
243
243
|
if (legacyMigrated) return {};
|
|
244
244
|
try {
|
|
245
|
-
const retired =
|
|
246
|
-
await jsonTransact(ctx, io, root, PENDING_STATE_FILE, (fresh) =>
|
|
247
|
-
...
|
|
248
|
-
|
|
249
|
-
|
|
245
|
+
const retired = {};
|
|
246
|
+
await jsonTransact(ctx, io, root, PENDING_STATE_FILE, async (fresh) => {
|
|
247
|
+
const merged = { ...fresh ?? {} };
|
|
248
|
+
const archivedIds = await readArchivedIds();
|
|
249
|
+
for (const [id, record] of Object.entries(legacy)) {
|
|
250
|
+
if (id in merged) continue;
|
|
251
|
+
if (archivedIds.has(id)) continue;
|
|
252
|
+
merged[id] = record;
|
|
253
|
+
retired[id] = record;
|
|
254
|
+
}
|
|
255
|
+
return merged;
|
|
256
|
+
});
|
|
250
257
|
await io().rename(pathOf(PENDING_LEGACY_FILE), `${pathOf(PENDING_LEGACY_FILE)}.migrated`);
|
|
251
258
|
legacyMigrated = true;
|
|
252
259
|
return retired;
|
|
@@ -259,7 +266,7 @@ function apply(ctx, rawConfig = {}) {
|
|
|
259
266
|
async function loadPendingMap() {
|
|
260
267
|
const [current, legacy] = await Promise.all([readJson(PENDING_STATE_FILE), readJson(PENDING_LEGACY_FILE)]);
|
|
261
268
|
if (legacy !== null) return {
|
|
262
|
-
...await retireLegacyOnce(legacy
|
|
269
|
+
...await retireLegacyOnce(legacy),
|
|
263
270
|
...current ?? {}
|
|
264
271
|
};
|
|
265
272
|
return { ...current ?? {} };
|
|
@@ -282,7 +289,7 @@ function apply(ctx, rawConfig = {}) {
|
|
|
282
289
|
* live work and are never trimmed. Returns the pruned map (rather than
|
|
283
290
|
* mutating in place) plus the evicted records. */
|
|
284
291
|
function enforceResolvedCap(map) {
|
|
285
|
-
const resolved = Object.values(map).filter((record) => record.status === "approved" || record.status === "rejected");
|
|
292
|
+
const resolved = Object.values(map).filter((record) => (record.status === "approved" || record.status === "rejected") && record.kind !== "capability");
|
|
286
293
|
if (resolved.length <= PENDING_RESOLVED_CAP$1) return {
|
|
287
294
|
map,
|
|
288
295
|
evicted: []
|
|
@@ -321,7 +328,10 @@ function apply(ctx, rawConfig = {}) {
|
|
|
321
328
|
const parsed = JSON.parse(current);
|
|
322
329
|
if (Array.isArray(parsed)) archive = parsed;
|
|
323
330
|
} catch {
|
|
324
|
-
await io().writeText(`${pathOf(PENDING_ARCHIVE_FILE)}.corrupt`, current).
|
|
331
|
+
if (!await io().writeText(`${pathOf(PENDING_ARCHIVE_FILE)}.corrupt`, current).then(() => true, () => false)) {
|
|
332
|
+
ctx.logger.warn(`evolution-state-json: corrupt ${PENDING_ARCHIVE_FILE} could not be quarantined to .corrupt — skipping this audit append to preserve the recoverable bytes`);
|
|
333
|
+
return current;
|
|
334
|
+
}
|
|
325
335
|
}
|
|
326
336
|
const shaped = archive.filter((entry) => entry !== null && typeof entry === "object");
|
|
327
337
|
const archiveKeys = /* @__PURE__ */ new Set();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lmzhen/dsh-evolution-state-json",
|
|
3
3
|
"description": "JSON-file evolution state provider over the IO seam (community build)",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.66",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -31,18 +31,18 @@
|
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@deepseek-ai/schemastery": "^3.18.1",
|
|
34
|
-
"@lmzhen/dsh-evolution-core": "^0.3.
|
|
34
|
+
"@lmzhen/dsh-evolution-core": "^0.3.66"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
|
|
38
38
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
39
|
-
"@lmzhen/dsh-evolution-io": "^0.3.
|
|
40
|
-
"@lmzhen/dsh-evolution-state-storage": "^0.3.
|
|
39
|
+
"@lmzhen/dsh-evolution-io": "^0.3.66",
|
|
40
|
+
"@lmzhen/dsh-evolution-state-storage": "^0.3.66"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
|
|
44
|
-
"@lmzhen/dsh-evolution-io": "^0.3.
|
|
45
|
-
"@lmzhen/dsh-evolution-state-storage": "^0.3.
|
|
46
|
-
"@lmzhen/dsh-evolution-io-node": "^0.3.
|
|
44
|
+
"@lmzhen/dsh-evolution-io": "^0.3.66",
|
|
45
|
+
"@lmzhen/dsh-evolution-state-storage": "^0.3.66",
|
|
46
|
+
"@lmzhen/dsh-evolution-io-node": "^0.3.66"
|
|
47
47
|
}
|
|
48
48
|
}
|