@remnic/core 10.0.126 → 10.0.127
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/access-admin-ops-surface.js +38 -38
- package/dist/access-cli.js +38 -38
- package/dist/access-extraction-force-flush.js +38 -38
- package/dist/access-http-briefing.js +38 -38
- package/dist/access-http-query.js +38 -38
- package/dist/access-http.js +38 -38
- package/dist/access-identity-continuity-surface.js +38 -38
- package/dist/access-lcm-surface.js +38 -38
- package/dist/access-mcp.js +38 -38
- package/dist/access-observe-write-surface.js +38 -38
- package/dist/access-operations-batch.js +38 -38
- package/dist/access-operations.js +38 -38
- package/dist/access-recall-concurrency.js +38 -38
- package/dist/access-recall-response.js +38 -38
- package/dist/access-recall-surface.js +38 -38
- package/dist/access-service.d.ts.map +1 -1
- package/dist/access-service.js +38 -38
- package/dist/active-recall.js +6 -6
- package/dist/briefing.js +4 -4
- package/dist/buffer-turn-helpers.d.ts +7 -0
- package/dist/buffer-turn-helpers.d.ts.map +1 -1
- package/dist/buffer-turn-helpers.js +3 -1
- package/dist/buffer-turn.d.ts +10 -0
- package/dist/buffer-turn.d.ts.map +1 -1
- package/dist/buffer.js +3 -3
- package/dist/causal-consolidation.js +5 -5
- package/dist/{chunk-BNRKSJMO.js → chunk-2BBCM2PX.js} +2 -2
- package/dist/{chunk-2GSPNTOU.js → chunk-2G72JBQB.js} +2 -2
- package/dist/{chunk-IDCZEKK6.js → chunk-34YQ7CVE.js} +3 -3
- package/dist/{chunk-AYWW6JEH.js → chunk-3OLHDECL.js} +115 -41
- package/dist/chunk-3OLHDECL.js.map +1 -0
- package/dist/{chunk-4VWZ4HPL.js → chunk-4DJSDH2M.js} +6 -6
- package/dist/{chunk-YJEOQ72B.js → chunk-6FPJPSQK.js} +2 -2
- package/dist/{chunk-YKUW2EZF.js → chunk-7T7I5D3F.js} +2 -2
- package/dist/{chunk-ERR7ZFPJ.js → chunk-7TC2PWKH.js} +2 -2
- package/dist/{chunk-DH2CDGAE.js → chunk-ALLI23GW.js} +2 -2
- package/dist/{chunk-RTIHO7AJ.js → chunk-AYBRQJXP.js} +2 -2
- package/dist/{chunk-UXXK523X.js → chunk-BR7CZVMO.js} +20 -16
- package/dist/chunk-BR7CZVMO.js.map +1 -0
- package/dist/{chunk-AWD36R4D.js → chunk-DURQZFVJ.js} +36 -6
- package/dist/chunk-DURQZFVJ.js.map +1 -0
- package/dist/{chunk-C7BTGSCY.js → chunk-FPBFDQZZ.js} +9 -9
- package/dist/{chunk-5DCCVEKT.js → chunk-GWFL6LUU.js} +2 -2
- package/dist/{chunk-JTY3NA3I.js → chunk-HJ7M322C.js} +2 -2
- package/dist/{chunk-HURBXNNB.js → chunk-JCPEXUNP.js} +2 -2
- package/dist/{chunk-LKGTTX74.js → chunk-JK2IVISS.js} +2 -2
- package/dist/{chunk-7XG7KMIW.js → chunk-LNQQEFKH.js} +2 -2
- package/dist/{chunk-IB4TDPCC.js → chunk-LR2X3FJM.js} +2 -2
- package/dist/{chunk-6IRJWKR5.js → chunk-LU2GQ4Q4.js} +2 -2
- package/dist/{chunk-4VCASS3Q.js → chunk-MCTGYIYN.js} +2 -2
- package/dist/{chunk-XN43HAIV.js → chunk-MGCV3VGC.js} +2 -2
- package/dist/{chunk-KWVGRNKL.js → chunk-NYZ6ZNFO.js} +2 -2
- package/dist/{chunk-6VAN7VZR.js → chunk-ORMJT23N.js} +7 -7
- package/dist/{chunk-DL7K5PMQ.js → chunk-PPPY2PCU.js} +2 -2
- package/dist/{chunk-5DP4GVKR.js → chunk-PXZLVFNC.js} +2 -2
- package/dist/{chunk-GSCIRMPR.js → chunk-QKYOMKRG.js} +2 -2
- package/dist/{chunk-QF64W4YM.js → chunk-QRZNVNNS.js} +2 -2
- package/dist/{chunk-CQMH65IP.js → chunk-TJJPT2OV.js} +2 -2
- package/dist/{chunk-2AVPRUML.js → chunk-TJY6AKWV.js} +2 -2
- package/dist/{chunk-RRHLI6VU.js → chunk-TQ5NOVMT.js} +2 -2
- package/dist/{chunk-KNT3BZZH.js → chunk-UWU6KEZU.js} +185 -59
- package/dist/chunk-UWU6KEZU.js.map +1 -0
- package/dist/{chunk-PUKLCFCU.js → chunk-VY3DHUL7.js} +2 -2
- package/dist/chunk-VY3DHUL7.js.map +1 -0
- package/dist/{chunk-47W3ALIS.js → chunk-XMKUABIG.js} +3 -3
- package/dist/{chunk-UGCLNASV.js → chunk-XUWDB53W.js} +3 -3
- package/dist/{chunk-XLHLZALR.js → chunk-YCJRYM3Q.js} +3 -3
- package/dist/{chunk-DB4THCGN.js → chunk-YFUHFPV6.js} +2 -2
- package/dist/{chunk-42JE2CF4.js → chunk-YPE3O5VH.js} +2 -2
- package/dist/{chunk-7TJMXZPO.js → chunk-ZO377APE.js} +2 -2
- package/dist/cli.js +38 -38
- package/dist/coding/export-okf-codegraph.js +3 -3
- package/dist/compounding/engine.js +5 -5
- package/dist/config.js +6 -6
- package/dist/connectors/codex-materialize-runner.js +4 -4
- package/dist/connectors/index.js +4 -4
- package/dist/convergence-refresh.js +6 -6
- package/dist/corpus-watermark.js +6 -6
- package/dist/entity-retrieval.js +4 -4
- package/dist/explicit-capture.js +38 -38
- package/dist/extraction-liveness.d.ts +54 -5
- package/dist/extraction-liveness.d.ts.map +1 -1
- package/dist/extraction-liveness.js +1 -1
- package/dist/extraction-span-config.js +2 -2
- package/dist/extraction.js +7 -7
- package/dist/harmonic-retrieval.js +4 -4
- package/dist/index.js +38 -38
- package/dist/location/index.js +5 -5
- package/dist/maintenance/memory-governance.js +4 -4
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +4 -4
- package/dist/maintenance/rebuild-memory-projection-runner.js +6 -6
- package/dist/maintenance/rebuild-memory-projection.js +5 -5
- package/dist/namespaces/migrate.js +5 -5
- package/dist/namespaces/storage.js +4 -4
- package/dist/operator-doctor-corpus.js +7 -7
- package/dist/operator-toolkit.js +13 -13
- package/dist/orchestration/backlog-scheduler.js +39 -39
- package/dist/orchestration/buffer-drain-runner.js +39 -39
- package/dist/orchestration/extraction-dedupe.d.ts +46 -0
- package/dist/orchestration/extraction-dedupe.d.ts.map +1 -0
- package/dist/orchestration/extraction-drain.d.ts +12 -1
- package/dist/orchestration/extraction-drain.d.ts.map +1 -1
- package/dist/orchestration/extraction-run.d.ts.map +1 -1
- package/dist/orchestration/maintenance.js +12 -12
- package/dist/orchestrator.js +38 -38
- package/dist/recall-navigation.js +38 -38
- package/dist/resume-bundles.js +7 -7
- package/dist/semantic-consolidation.js +5 -5
- package/dist/semantic-rule-promotion.js +4 -4
- package/dist/semantic-rule-verifier.js +4 -4
- package/dist/source-agent-qualifier.js +6 -6
- package/dist/standup/build.js +4 -4
- package/dist/storage/buffer-drain-claims.d.ts +19 -4
- package/dist/storage/buffer-drain-claims.d.ts.map +1 -1
- package/dist/storage/buffer-drain-claims.js +2 -2
- package/dist/storage/buffer-session-files.js +2 -2
- package/dist/storage/drain-claim-totals.d.ts +54 -0
- package/dist/storage/drain-claim-totals.d.ts.map +1 -0
- package/dist/storage.js +3 -3
- package/dist/transfer/export-okf.js +4 -4
- package/dist/verified-recall.js +4 -4
- package/dist/who-knows-cli.js +5 -5
- package/dist/who-knows.js +4 -4
- package/package.json +2 -2
- package/src/access-service-health.test.ts +102 -1
- package/src/access-service.ts +10 -1
- package/src/buffer-turn-helpers.ts +25 -15
- package/src/buffer-turn.ts +10 -0
- package/src/extraction-liveness.test.ts +229 -0
- package/src/extraction-liveness.ts +89 -6
- package/src/orchestration/extraction-dedupe.test.ts +101 -0
- package/src/orchestration/extraction-dedupe.ts +80 -0
- package/src/orchestration/extraction-drain-dedupe.test.ts +477 -0
- package/src/orchestration/extraction-drain.ts +69 -9
- package/src/orchestration/extraction-run.ts +2 -0
- package/src/storage/buffer-drain-claims.test.ts +66 -0
- package/src/storage/buffer-drain-claims.ts +49 -4
- package/src/storage/drain-claim-totals.test.ts +356 -0
- package/src/storage/drain-claim-totals.ts +175 -0
- package/dist/chunk-AWD36R4D.js.map +0 -1
- package/dist/chunk-AYWW6JEH.js.map +0 -1
- package/dist/chunk-KNT3BZZH.js.map +0 -1
- package/dist/chunk-PUKLCFCU.js.map +0 -1
- package/dist/chunk-UXXK523X.js.map +0 -1
- /package/dist/{chunk-BNRKSJMO.js.map → chunk-2BBCM2PX.js.map} +0 -0
- /package/dist/{chunk-2GSPNTOU.js.map → chunk-2G72JBQB.js.map} +0 -0
- /package/dist/{chunk-IDCZEKK6.js.map → chunk-34YQ7CVE.js.map} +0 -0
- /package/dist/{chunk-4VWZ4HPL.js.map → chunk-4DJSDH2M.js.map} +0 -0
- /package/dist/{chunk-YJEOQ72B.js.map → chunk-6FPJPSQK.js.map} +0 -0
- /package/dist/{chunk-YKUW2EZF.js.map → chunk-7T7I5D3F.js.map} +0 -0
- /package/dist/{chunk-ERR7ZFPJ.js.map → chunk-7TC2PWKH.js.map} +0 -0
- /package/dist/{chunk-DH2CDGAE.js.map → chunk-ALLI23GW.js.map} +0 -0
- /package/dist/{chunk-RTIHO7AJ.js.map → chunk-AYBRQJXP.js.map} +0 -0
- /package/dist/{chunk-C7BTGSCY.js.map → chunk-FPBFDQZZ.js.map} +0 -0
- /package/dist/{chunk-5DCCVEKT.js.map → chunk-GWFL6LUU.js.map} +0 -0
- /package/dist/{chunk-JTY3NA3I.js.map → chunk-HJ7M322C.js.map} +0 -0
- /package/dist/{chunk-HURBXNNB.js.map → chunk-JCPEXUNP.js.map} +0 -0
- /package/dist/{chunk-LKGTTX74.js.map → chunk-JK2IVISS.js.map} +0 -0
- /package/dist/{chunk-7XG7KMIW.js.map → chunk-LNQQEFKH.js.map} +0 -0
- /package/dist/{chunk-IB4TDPCC.js.map → chunk-LR2X3FJM.js.map} +0 -0
- /package/dist/{chunk-6IRJWKR5.js.map → chunk-LU2GQ4Q4.js.map} +0 -0
- /package/dist/{chunk-4VCASS3Q.js.map → chunk-MCTGYIYN.js.map} +0 -0
- /package/dist/{chunk-XN43HAIV.js.map → chunk-MGCV3VGC.js.map} +0 -0
- /package/dist/{chunk-KWVGRNKL.js.map → chunk-NYZ6ZNFO.js.map} +0 -0
- /package/dist/{chunk-6VAN7VZR.js.map → chunk-ORMJT23N.js.map} +0 -0
- /package/dist/{chunk-DL7K5PMQ.js.map → chunk-PPPY2PCU.js.map} +0 -0
- /package/dist/{chunk-5DP4GVKR.js.map → chunk-PXZLVFNC.js.map} +0 -0
- /package/dist/{chunk-GSCIRMPR.js.map → chunk-QKYOMKRG.js.map} +0 -0
- /package/dist/{chunk-QF64W4YM.js.map → chunk-QRZNVNNS.js.map} +0 -0
- /package/dist/{chunk-CQMH65IP.js.map → chunk-TJJPT2OV.js.map} +0 -0
- /package/dist/{chunk-2AVPRUML.js.map → chunk-TJY6AKWV.js.map} +0 -0
- /package/dist/{chunk-RRHLI6VU.js.map → chunk-TQ5NOVMT.js.map} +0 -0
- /package/dist/{chunk-47W3ALIS.js.map → chunk-XMKUABIG.js.map} +0 -0
- /package/dist/{chunk-UGCLNASV.js.map → chunk-XUWDB53W.js.map} +0 -0
- /package/dist/{chunk-XLHLZALR.js.map → chunk-YCJRYM3Q.js.map} +0 -0
- /package/dist/{chunk-DB4THCGN.js.map → chunk-YFUHFPV6.js.map} +0 -0
- /package/dist/{chunk-42JE2CF4.js.map → chunk-YPE3O5VH.js.map} +0 -0
- /package/dist/{chunk-7TJMXZPO.js.map → chunk-ZO377APE.js.map} +0 -0
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-TBBDFYXW.js";
|
|
4
4
|
import {
|
|
5
5
|
StorageManager
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-LR2X3FJM.js";
|
|
7
7
|
import {
|
|
8
8
|
requestEntityCanonicalIdReconcile
|
|
9
9
|
} from "./chunk-O3GZPLVY.js";
|
|
@@ -769,4 +769,4 @@ export {
|
|
|
769
769
|
listMemoryGovernanceRuns,
|
|
770
770
|
readMemoryGovernanceRunArtifact
|
|
771
771
|
};
|
|
772
|
-
//# sourceMappingURL=chunk-
|
|
772
|
+
//# sourceMappingURL=chunk-PPPY2PCU.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-B7RWBZXW.js";
|
|
4
4
|
import {
|
|
5
5
|
StorageManager
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-LR2X3FJM.js";
|
|
7
7
|
import {
|
|
8
8
|
countRecallTokenOverlap,
|
|
9
9
|
normalizeRecallTokens
|
|
@@ -109,4 +109,4 @@ export {
|
|
|
109
109
|
compareVerifiedEpisodeResults,
|
|
110
110
|
searchVerifiedEpisodes
|
|
111
111
|
};
|
|
112
|
-
//# sourceMappingURL=chunk-
|
|
112
|
+
//# sourceMappingURL=chunk-PXZLVFNC.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runPostConsolidationMaterialize
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LU2GQ4Q4.js";
|
|
4
4
|
import {
|
|
5
5
|
discoverMemoryExtensions,
|
|
6
6
|
renderExtensionsBlock,
|
|
@@ -220,4 +220,4 @@ export {
|
|
|
220
220
|
buildExtensionsBlockForConsolidation,
|
|
221
221
|
materializeAfterSemanticConsolidation
|
|
222
222
|
};
|
|
223
|
-
//# sourceMappingURL=chunk-
|
|
223
|
+
//# sourceMappingURL=chunk-QKYOMKRG.js.map
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from "./chunk-D3ZKHLN2.js";
|
|
9
9
|
import {
|
|
10
10
|
deriveSourceConnector
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-VY3DHUL7.js";
|
|
12
12
|
import {
|
|
13
13
|
resolvePipelineProcessingCapabilities
|
|
14
14
|
} from "./chunk-C5LWPYS3.js";
|
|
@@ -130,4 +130,4 @@ export {
|
|
|
130
130
|
renderExtractionConversation,
|
|
131
131
|
applyGroundingWithConnector
|
|
132
132
|
};
|
|
133
|
-
//# sourceMappingURL=chunk-
|
|
133
|
+
//# sourceMappingURL=chunk-QRZNVNNS.js.map
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from "./chunk-FL3O34XF.js";
|
|
12
12
|
import {
|
|
13
13
|
StorageManager
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-LR2X3FJM.js";
|
|
15
15
|
import {
|
|
16
16
|
isValidityExpiredNow
|
|
17
17
|
} from "./chunk-6CIAGZ6X.js";
|
|
@@ -552,4 +552,4 @@ export {
|
|
|
552
552
|
readProjectedHarmonicGraph,
|
|
553
553
|
searchHarmonicRetrieval
|
|
554
554
|
};
|
|
555
|
-
//# sourceMappingURL=chunk-
|
|
555
|
+
//# sourceMappingURL=chunk-TJJPT2OV.js.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
WHO_KNOWS_DEFAULT_LIMIT,
|
|
3
3
|
WHO_KNOWS_MAX_LIMIT,
|
|
4
4
|
validateWhoKnowsInput
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-HJ7M322C.js";
|
|
6
6
|
|
|
7
7
|
// src/who-knows-cli.ts
|
|
8
8
|
function extractWhoKnowsRawArgs(rest) {
|
|
@@ -74,4 +74,4 @@ export {
|
|
|
74
74
|
renderWhoKnowsText,
|
|
75
75
|
renderWhoKnows
|
|
76
76
|
};
|
|
77
|
-
//# sourceMappingURL=chunk-
|
|
77
|
+
//# sourceMappingURL=chunk-TJY6AKWV.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
parseFrontmatter
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LR2X3FJM.js";
|
|
4
4
|
import {
|
|
5
5
|
activityDigestPath,
|
|
6
6
|
isValidActivityDate
|
|
@@ -199,4 +199,4 @@ export {
|
|
|
199
199
|
buildStandup,
|
|
200
200
|
standupHelp
|
|
201
201
|
};
|
|
202
|
-
//# sourceMappingURL=chunk-
|
|
202
|
+
//# sourceMappingURL=chunk-TQ5NOVMT.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
bufferTurnIdentityKey,
|
|
3
3
|
subtractBufferTurns
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-BR7CZVMO.js";
|
|
5
5
|
import {
|
|
6
6
|
withHeldFileLock
|
|
7
7
|
} from "./chunk-EBV6VXKF.js";
|
|
@@ -19,10 +19,10 @@ import {
|
|
|
19
19
|
// src/storage/buffer-drain-claims.ts
|
|
20
20
|
import { randomUUID } from "crypto";
|
|
21
21
|
import { hostname } from "os";
|
|
22
|
-
import { z } from "zod";
|
|
22
|
+
import { z as z2 } from "zod";
|
|
23
23
|
import { existsSync } from "fs";
|
|
24
|
-
import { mkdir, readdir as
|
|
25
|
-
import
|
|
24
|
+
import { mkdir, readdir as readdir3, readFile as readFile2, rename, stat as stat2, unlink as unlink2, writeFile } from "fs/promises";
|
|
25
|
+
import path3 from "path";
|
|
26
26
|
|
|
27
27
|
// src/storage/buffer-session-files.ts
|
|
28
28
|
import { createHash } from "crypto";
|
|
@@ -93,16 +93,16 @@ var BufferSessionFiles = class {
|
|
|
93
93
|
*/
|
|
94
94
|
async assertDirSafe() {
|
|
95
95
|
if (this.dirVerified) return;
|
|
96
|
-
let
|
|
96
|
+
let stat3 = null;
|
|
97
97
|
try {
|
|
98
|
-
|
|
98
|
+
stat3 = await lstat(this.dir);
|
|
99
99
|
} catch (err) {
|
|
100
100
|
if (!(err instanceof Error) || !isMissing(asFsError(err))) throw err;
|
|
101
101
|
}
|
|
102
|
-
if (
|
|
102
|
+
if (stat3 && (stat3.isSymbolicLink() || !stat3.isDirectory())) {
|
|
103
103
|
throw new Error(`buffer session directory must be a real directory, not a symlink or file: ${this.dir}`);
|
|
104
104
|
}
|
|
105
|
-
this.dirVerified =
|
|
105
|
+
this.dirVerified = stat3 !== null;
|
|
106
106
|
}
|
|
107
107
|
/** Persist ONE session atomically. Compact JSON: machine-read state, and
|
|
108
108
|
* pretty-printing a large buffer costs CPU and bytes on every observe.
|
|
@@ -304,6 +304,102 @@ var HandInMemo = class {
|
|
|
304
304
|
}
|
|
305
305
|
};
|
|
306
306
|
|
|
307
|
+
// src/storage/drain-claim-totals.ts
|
|
308
|
+
import { readdir as readdir2, readFile, stat } from "fs/promises";
|
|
309
|
+
import path2 from "path";
|
|
310
|
+
import { z } from "zod";
|
|
311
|
+
var DEFAULT_MAX_CLAIMS = 4096;
|
|
312
|
+
var CLAIM_BODY_PATTERN = /^s-[0-9a-f]{64}\.json$/;
|
|
313
|
+
var sidecarSchema = z.object({
|
|
314
|
+
size: z.number(),
|
|
315
|
+
mtimeMs: z.number(),
|
|
316
|
+
pending: z.number().nonnegative(),
|
|
317
|
+
oldestTurnAt: z.string().optional()
|
|
318
|
+
});
|
|
319
|
+
function verifiedSidecar(raw, identity) {
|
|
320
|
+
let parsed;
|
|
321
|
+
try {
|
|
322
|
+
parsed = sidecarSchema.parse(JSON.parse(raw));
|
|
323
|
+
} catch {
|
|
324
|
+
return null;
|
|
325
|
+
}
|
|
326
|
+
if (parsed.size !== identity.size || parsed.mtimeMs !== identity.mtimeMs) return null;
|
|
327
|
+
return { pending: parsed.pending, oldestTurnAt: parsed.oldestTurnAt };
|
|
328
|
+
}
|
|
329
|
+
async function readDrainClaimTotals(claimsDir, opts = {}) {
|
|
330
|
+
const totals = {
|
|
331
|
+
claimedSessions: 0,
|
|
332
|
+
claimedPendingTurns: 0,
|
|
333
|
+
oldestClaimedTurnAt: null,
|
|
334
|
+
oldestClaimedAgeBasis: null,
|
|
335
|
+
verifiedSidecars: 0,
|
|
336
|
+
unverifiedClaims: 0,
|
|
337
|
+
claimsPendingInbox: 0,
|
|
338
|
+
truncated: false
|
|
339
|
+
};
|
|
340
|
+
let oldest = null;
|
|
341
|
+
let bodies;
|
|
342
|
+
try {
|
|
343
|
+
bodies = (await readdir2(claimsDir)).filter((name) => CLAIM_BODY_PATTERN.test(name)).sort();
|
|
344
|
+
} catch {
|
|
345
|
+
return totals;
|
|
346
|
+
}
|
|
347
|
+
totals.claimedSessions = bodies.length;
|
|
348
|
+
const maxClaims = opts.maxClaims ?? DEFAULT_MAX_CLAIMS;
|
|
349
|
+
if (bodies.length > maxClaims) {
|
|
350
|
+
totals.truncated = true;
|
|
351
|
+
bodies = bodies.slice(0, maxClaims);
|
|
352
|
+
}
|
|
353
|
+
for (const name of bodies) {
|
|
354
|
+
const bodyPath = path2.join(claimsDir, name);
|
|
355
|
+
let identity;
|
|
356
|
+
try {
|
|
357
|
+
identity = await stat(bodyPath);
|
|
358
|
+
} catch {
|
|
359
|
+
totals.unverifiedClaims += 1;
|
|
360
|
+
continue;
|
|
361
|
+
}
|
|
362
|
+
let raw;
|
|
363
|
+
try {
|
|
364
|
+
raw = await readFile(`${bodyPath}.count`, "utf8");
|
|
365
|
+
} catch {
|
|
366
|
+
totals.unverifiedClaims += 1;
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
369
|
+
const sidecar = verifiedSidecar(raw, { size: identity.size, mtimeMs: identity.mtimeMs });
|
|
370
|
+
if (sidecar === null) {
|
|
371
|
+
totals.unverifiedClaims += 1;
|
|
372
|
+
continue;
|
|
373
|
+
}
|
|
374
|
+
totals.verifiedSidecars += 1;
|
|
375
|
+
totals.claimedPendingTurns += sidecar.pending;
|
|
376
|
+
const inboxStat = await stat(`${bodyPath}.inbox.jsonl`).catch(() => null);
|
|
377
|
+
const inboxPending = inboxStat !== null && inboxStat.size > 0;
|
|
378
|
+
if (inboxPending) totals.claimsPendingInbox += 1;
|
|
379
|
+
if (sidecar.pending > 0 || inboxPending) {
|
|
380
|
+
const candidates = [];
|
|
381
|
+
if (sidecar.pending > 0) {
|
|
382
|
+
const turnIso = sidecar.oldestTurnAt;
|
|
383
|
+
if (turnIso !== void 0) {
|
|
384
|
+
const turnMs = Date.parse(turnIso);
|
|
385
|
+
if (Number.isFinite(turnMs)) candidates.push({ ms: turnMs, iso: turnIso, basis: "turn" });
|
|
386
|
+
else candidates.push({ ms: identity.mtimeMs, iso: new Date(identity.mtimeMs).toISOString(), basis: "claim-mtime-lower-bound" });
|
|
387
|
+
} else {
|
|
388
|
+
candidates.push({ ms: identity.mtimeMs, iso: new Date(identity.mtimeMs).toISOString(), basis: "claim-mtime-lower-bound" });
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
if (inboxPending && inboxStat !== null) {
|
|
392
|
+
candidates.push({ ms: inboxStat.mtimeMs, iso: new Date(inboxStat.mtimeMs).toISOString(), basis: "claim-mtime-lower-bound" });
|
|
393
|
+
}
|
|
394
|
+
const claimOldest = candidates.sort((a, b) => a.ms - b.ms)[0];
|
|
395
|
+
if (claimOldest !== void 0 && (oldest === null || claimOldest.ms < oldest.ms)) oldest = claimOldest;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
totals.oldestClaimedTurnAt = oldest?.iso ?? null;
|
|
399
|
+
totals.oldestClaimedAgeBasis = oldest?.basis ?? null;
|
|
400
|
+
return totals;
|
|
401
|
+
}
|
|
402
|
+
|
|
307
403
|
// src/storage/buffer-drain-claims.ts
|
|
308
404
|
var CLAIM_LOCK_STALE_MS = 12e4;
|
|
309
405
|
var CLAIM_LOCK_MAX_WAIT_MS = 12e4;
|
|
@@ -397,23 +493,23 @@ function isLeaseExpired(lease, now = Date.now()) {
|
|
|
397
493
|
const heartbeat = Date.parse(lease.heartbeatAt);
|
|
398
494
|
return !Number.isFinite(heartbeat) || now - heartbeat > lease.leaseMs;
|
|
399
495
|
}
|
|
400
|
-
var claimBodySchema =
|
|
401
|
-
key:
|
|
402
|
-
entry:
|
|
403
|
-
turns:
|
|
404
|
-
retainedTurns:
|
|
405
|
-
lastExtractionAt:
|
|
406
|
-
extractionCount:
|
|
496
|
+
var claimBodySchema = z2.object({
|
|
497
|
+
key: z2.string().min(1),
|
|
498
|
+
entry: z2.object({
|
|
499
|
+
turns: z2.array(z2.unknown()),
|
|
500
|
+
retainedTurns: z2.array(z2.unknown()).optional(),
|
|
501
|
+
lastExtractionAt: z2.string().nullable().optional(),
|
|
502
|
+
extractionCount: z2.number().optional()
|
|
407
503
|
}).optional(),
|
|
408
|
-
turns:
|
|
409
|
-
retainedTurns:
|
|
410
|
-
lastExtractionAt:
|
|
411
|
-
extractionCount:
|
|
412
|
-
claimedAt:
|
|
413
|
-
drained:
|
|
414
|
-
drainedRetained:
|
|
415
|
-
movedTurns:
|
|
416
|
-
foldedRecords:
|
|
504
|
+
turns: z2.array(z2.unknown()).optional(),
|
|
505
|
+
retainedTurns: z2.array(z2.unknown()).optional(),
|
|
506
|
+
lastExtractionAt: z2.string().nullable().optional(),
|
|
507
|
+
extractionCount: z2.number().optional(),
|
|
508
|
+
claimedAt: z2.string().optional(),
|
|
509
|
+
drained: z2.array(z2.unknown()).optional(),
|
|
510
|
+
drainedRetained: z2.array(z2.unknown()).optional(),
|
|
511
|
+
movedTurns: z2.array(z2.unknown()).optional(),
|
|
512
|
+
foldedRecords: z2.array(z2.string()).optional()
|
|
417
513
|
});
|
|
418
514
|
function parseBody(raw) {
|
|
419
515
|
let body;
|
|
@@ -448,12 +544,12 @@ function parseBody(raw) {
|
|
|
448
544
|
if (body.foldedRecords) claim.foldedRecords = body.foldedRecords;
|
|
449
545
|
return claim;
|
|
450
546
|
}
|
|
451
|
-
var inboxRecordSchema =
|
|
452
|
-
id:
|
|
453
|
-
turns:
|
|
454
|
-
retainedTurns:
|
|
455
|
-
lastExtractionAt:
|
|
456
|
-
extractionCount:
|
|
547
|
+
var inboxRecordSchema = z2.object({
|
|
548
|
+
id: z2.string().min(1),
|
|
549
|
+
turns: z2.array(z2.unknown()),
|
|
550
|
+
retainedTurns: z2.array(z2.unknown()).optional(),
|
|
551
|
+
lastExtractionAt: z2.string().nullable().optional(),
|
|
552
|
+
extractionCount: z2.number().optional()
|
|
457
553
|
});
|
|
458
554
|
function parseInbox(raw) {
|
|
459
555
|
const records = [];
|
|
@@ -481,20 +577,32 @@ function parseInbox(raw) {
|
|
|
481
577
|
function pendingTurns(entry) {
|
|
482
578
|
return entry.turns.length + (entry.retainedTurns?.length ?? 0);
|
|
483
579
|
}
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
580
|
+
function oldestTurnTimestamp(turns) {
|
|
581
|
+
let oldest;
|
|
582
|
+
let oldestMs = Number.POSITIVE_INFINITY;
|
|
583
|
+
for (const turn of turns) {
|
|
584
|
+
const parsed = Date.parse(turn.timestamp);
|
|
585
|
+
if (!Number.isFinite(parsed) || parsed >= oldestMs) continue;
|
|
586
|
+
oldestMs = parsed;
|
|
587
|
+
oldest = turn.timestamp;
|
|
588
|
+
}
|
|
589
|
+
return oldest;
|
|
590
|
+
}
|
|
591
|
+
var summarySchema = z2.object({
|
|
592
|
+
key: z2.string().min(1),
|
|
593
|
+
size: z2.number(),
|
|
594
|
+
mtimeMs: z2.number(),
|
|
595
|
+
pending: z2.number(),
|
|
596
|
+
drained: z2.number(),
|
|
597
|
+
oldestTurnAt: z2.string().optional()
|
|
490
598
|
});
|
|
491
|
-
var leaseSchema =
|
|
492
|
-
ownerId:
|
|
493
|
-
pid:
|
|
494
|
-
host:
|
|
495
|
-
acquiredAt:
|
|
496
|
-
heartbeatAt:
|
|
497
|
-
leaseMs:
|
|
599
|
+
var leaseSchema = z2.object({
|
|
600
|
+
ownerId: z2.string().min(1),
|
|
601
|
+
pid: z2.number().optional(),
|
|
602
|
+
host: z2.string().optional(),
|
|
603
|
+
acquiredAt: z2.string().optional(),
|
|
604
|
+
heartbeatAt: z2.string(),
|
|
605
|
+
leaseMs: z2.number()
|
|
498
606
|
});
|
|
499
607
|
function parseLease(raw) {
|
|
500
608
|
let lease;
|
|
@@ -520,6 +628,7 @@ var COUNT_SUFFIX = ".count";
|
|
|
520
628
|
var INBOX_LISTING_PARSE_LIMIT = 1048576;
|
|
521
629
|
var INBOX_UNREADABLE_BYTES = 536870888;
|
|
522
630
|
var LIST_PAGE_SCAN_FACTOR = 8;
|
|
631
|
+
var CLAIM_TOTALS_TTL_MS = 3e4;
|
|
523
632
|
var BufferDrainClaims = class {
|
|
524
633
|
constructor(stateDir, io) {
|
|
525
634
|
this.stateDir = stateDir;
|
|
@@ -528,11 +637,27 @@ var BufferDrainClaims = class {
|
|
|
528
637
|
stateDir;
|
|
529
638
|
io;
|
|
530
639
|
handIns = new HandInMemo();
|
|
640
|
+
/** Last `claimTotals` scan; the /health path polls per request (#3442). */
|
|
641
|
+
totalsCache = null;
|
|
642
|
+
/**
|
|
643
|
+
* Claimed-backlog totals for liveness surfaces (#3442): sidecars only, no
|
|
644
|
+
* claim-body parse, bounded scan, cached for `ttlMs` (default 30s) so a
|
|
645
|
+
* health poll per request cannot turn into a directory storm. `ttlMs: 0`
|
|
646
|
+
* forces a rescan; `nowMs`/`maxClaims` are test/bounds seams.
|
|
647
|
+
*/
|
|
648
|
+
async claimTotals(opts = {}) {
|
|
649
|
+
const nowMs = opts.nowMs ?? Date.now();
|
|
650
|
+
const cached = this.totalsCache;
|
|
651
|
+
if (cached !== null && nowMs - cached.atMs < (opts.ttlMs ?? CLAIM_TOTALS_TTL_MS)) return cached.totals;
|
|
652
|
+
const totals = await readDrainClaimTotals(this.dir, { maxClaims: opts.maxClaims });
|
|
653
|
+
this.totalsCache = { atMs: nowMs, totals };
|
|
654
|
+
return totals;
|
|
655
|
+
}
|
|
531
656
|
get dir() {
|
|
532
|
-
return
|
|
657
|
+
return path3.join(this.stateDir, "buffer", "drain");
|
|
533
658
|
}
|
|
534
659
|
fileFor(key) {
|
|
535
|
-
return
|
|
660
|
+
return path3.join(this.dir, bufferSessionFileName(key));
|
|
536
661
|
}
|
|
537
662
|
leaseFileFor(key) {
|
|
538
663
|
return `${this.fileFor(key)}.lease.json`;
|
|
@@ -601,7 +726,7 @@ var BufferDrainClaims = class {
|
|
|
601
726
|
const bodyPath = this.fileFor(key);
|
|
602
727
|
const foldedRecords = consumed.length > 0 ? [...consumed] : void 0;
|
|
603
728
|
await this.io.write(bodyPath, JSON.stringify({ ...claim, key, foldedRecords }));
|
|
604
|
-
await
|
|
729
|
+
await stat2(bodyPath).then((identity) => this.writeSummary(bodyPath, claim, identity), () => {
|
|
605
730
|
});
|
|
606
731
|
await unlink2(this.inboxFor(key)).catch(() => {
|
|
607
732
|
});
|
|
@@ -618,7 +743,8 @@ var BufferDrainClaims = class {
|
|
|
618
743
|
size: identity.size,
|
|
619
744
|
mtimeMs: identity.mtimeMs,
|
|
620
745
|
pending: pendingTurns(claim.entry),
|
|
621
|
-
drained: (claim.drained?.length ?? 0) + (claim.drainedRetained?.length ?? 0)
|
|
746
|
+
drained: (claim.drained?.length ?? 0) + (claim.drainedRetained?.length ?? 0),
|
|
747
|
+
oldestTurnAt: oldestTurnTimestamp([...claim.entry.turns, ...claim.entry.retainedTurns ?? []])
|
|
622
748
|
};
|
|
623
749
|
try {
|
|
624
750
|
await writeFile(`${bodyPath}${COUNT_SUFFIX}`, JSON.stringify(summary));
|
|
@@ -636,12 +762,12 @@ var BufferDrainClaims = class {
|
|
|
636
762
|
async readSummary(bodyPath) {
|
|
637
763
|
let identity;
|
|
638
764
|
try {
|
|
639
|
-
identity = await
|
|
765
|
+
identity = await stat2(bodyPath);
|
|
640
766
|
} catch {
|
|
641
767
|
return null;
|
|
642
768
|
}
|
|
643
769
|
try {
|
|
644
|
-
const cached = summarySchema.parse(JSON.parse(await
|
|
770
|
+
const cached = summarySchema.parse(JSON.parse(await readFile2(`${bodyPath}${COUNT_SUFFIX}`, "utf8")));
|
|
645
771
|
if (cached.size === identity.size && cached.mtimeMs === identity.mtimeMs) return cached;
|
|
646
772
|
} catch {
|
|
647
773
|
}
|
|
@@ -649,7 +775,7 @@ var BufferDrainClaims = class {
|
|
|
649
775
|
try {
|
|
650
776
|
claim = parseBody(await this.io.read(bodyPath));
|
|
651
777
|
} catch (err) {
|
|
652
|
-
log.debug(`buffer drain: skipping unreadable claim file ${
|
|
778
|
+
log.debug(`buffer drain: skipping unreadable claim file ${path3.basename(bodyPath)}: ${err instanceof Error ? err.message : String(err)}`);
|
|
653
779
|
return null;
|
|
654
780
|
}
|
|
655
781
|
return claim ? await this.writeSummary(bodyPath, claim, identity) : null;
|
|
@@ -677,7 +803,7 @@ var BufferDrainClaims = class {
|
|
|
677
803
|
*/
|
|
678
804
|
async claimFromSessionFile(key, lease) {
|
|
679
805
|
await mkdir(this.dir, { recursive: true });
|
|
680
|
-
const sessionPath =
|
|
806
|
+
const sessionPath = path3.join(this.stateDir, "buffer", bufferSessionFileName(key));
|
|
681
807
|
if (existsSync(sessionPath)) {
|
|
682
808
|
try {
|
|
683
809
|
const seeded = parseBody(await this.io.read(sessionPath));
|
|
@@ -710,7 +836,7 @@ var BufferDrainClaims = class {
|
|
|
710
836
|
});
|
|
711
837
|
return "empty";
|
|
712
838
|
}
|
|
713
|
-
await
|
|
839
|
+
await stat2(this.fileFor(key)).then((identity) => this.writeSummary(this.fileFor(key), claim, identity), () => {
|
|
714
840
|
});
|
|
715
841
|
await this.writeLease(key, lease);
|
|
716
842
|
return "claimed";
|
|
@@ -757,7 +883,7 @@ var BufferDrainClaims = class {
|
|
|
757
883
|
/** The inbox as this process last left it (identity, size, mtime); "absent" when there is none, null when unknown. */
|
|
758
884
|
async handInStamp(key) {
|
|
759
885
|
try {
|
|
760
|
-
const inbox = await
|
|
886
|
+
const inbox = await stat2(this.inboxFor(key));
|
|
761
887
|
return `${inbox.ino}:${inbox.size}:${inbox.mtimeMs}`;
|
|
762
888
|
} catch (err) {
|
|
763
889
|
return isErrnoCode(err, "ENOENT") ? "absent" : null;
|
|
@@ -986,7 +1112,7 @@ ${JSON.stringify({ id: randomUUID(), key, ...plan.record })}`);
|
|
|
986
1112
|
/** Claim body file names in the drain directory (no leases, inboxes, summaries or locks). */
|
|
987
1113
|
async claimNames() {
|
|
988
1114
|
try {
|
|
989
|
-
return (await
|
|
1115
|
+
return (await readdir3(this.dir)).filter((name) => name.endsWith(".json") && !name.endsWith(".lease.json")).sort();
|
|
990
1116
|
} catch (err) {
|
|
991
1117
|
if (err?.code === "ENOENT") return null;
|
|
992
1118
|
throw err;
|
|
@@ -1000,11 +1126,11 @@ ${JSON.stringify({ id: randomUUID(), key, ...plan.record })}`);
|
|
|
1000
1126
|
* inbox, so an over-count costs one cheap drain run, never a lost turn.
|
|
1001
1127
|
*/
|
|
1002
1128
|
async describeClaim(name) {
|
|
1003
|
-
const summary = await this.readSummary(
|
|
1129
|
+
const summary = await this.readSummary(path3.join(this.dir, name));
|
|
1004
1130
|
if (!summary) return null;
|
|
1005
1131
|
let inboxTurns = 0;
|
|
1006
1132
|
try {
|
|
1007
|
-
const inboxBytes = (await
|
|
1133
|
+
const inboxBytes = (await stat2(this.inboxFor(summary.key)).catch(() => null))?.size ?? 0;
|
|
1008
1134
|
if (inboxBytes > INBOX_UNREADABLE_BYTES) throw new Error(`inbox is ${inboxBytes} bytes, too long to read`);
|
|
1009
1135
|
if (inboxBytes <= INBOX_LISTING_PARSE_LIMIT) {
|
|
1010
1136
|
for (const record of await this.readInbox(summary.key)) inboxTurns += pendingTurns(record.entry);
|
|
@@ -1071,7 +1197,7 @@ ${JSON.stringify({ id: randomUUID(), key, ...plan.record })}`);
|
|
|
1071
1197
|
async foldAllInboxes() {
|
|
1072
1198
|
let names;
|
|
1073
1199
|
try {
|
|
1074
|
-
names = (await
|
|
1200
|
+
names = (await readdir3(this.dir)).filter((name) => name.endsWith(INBOX_SUFFIX));
|
|
1075
1201
|
} catch (err) {
|
|
1076
1202
|
if (isErrnoCode(err, "ENOENT")) return 0;
|
|
1077
1203
|
throw err;
|
|
@@ -1101,7 +1227,7 @@ ${JSON.stringify({ id: randomUUID(), key, ...plan.record })}`);
|
|
|
1101
1227
|
}
|
|
1102
1228
|
async readClaimBodyByName(name) {
|
|
1103
1229
|
try {
|
|
1104
|
-
return parseBody(await this.io.read(
|
|
1230
|
+
return parseBody(await this.io.read(path3.join(this.dir, name)));
|
|
1105
1231
|
} catch (err) {
|
|
1106
1232
|
log.debug(`buffer drain: skipping unreadable claim file ${name}: ${err instanceof Error ? err.message : String(err)}`);
|
|
1107
1233
|
return null;
|
|
@@ -1115,4 +1241,4 @@ export {
|
|
|
1115
1241
|
legacyStateToEntries,
|
|
1116
1242
|
BufferSessionFiles
|
|
1117
1243
|
};
|
|
1118
|
-
//# sourceMappingURL=chunk-
|
|
1244
|
+
//# sourceMappingURL=chunk-UWU6KEZU.js.map
|