Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review (claude): keep cos-history manifest entry-cap under the 32MB byte cap

[._.]/ Adam Eivy5e4522bdc1ff
diff --git a/server/lib/peerSyncValidation.js b/server/lib/peerSyncValidation.js
index bf4c1b8144..2336c82185 100644
--- a/server/lib/peerSyncValidation.js
+++ b/server/lib/peerSyncValidation.js
@@ -307,7 +307,7 @@ const peerCosHistoryManifestEntrySchema = z.object({
export const peerCosHistoryManifestSchema = z.object({
schemaVersion: z.number().int().min(0).max(1_000_000),
manifestHash: hex64,
- entries: z.array(peerCosHistoryManifestEntrySchema).max(300_000),
+ entries: z.array(peerCosHistoryManifestEntrySchema).max(150_000),
}).strict();
export const peerPullMetadataSchema = z.object({
diff --git a/server/services/sharing/peerSync.js b/server/services/sharing/peerSync.js
index fc831fe15a..420e68022d 100644
--- a/server/services/sharing/peerSync.js
+++ b/server/services/sharing/peerSync.js
@@ -3048,10 +3048,14 @@ function cosAgentsDir() {
}
// Cap so a pathologically large history can't build an unbounded manifest. Each
-// agent contributes up to 3 files; 300k entries ≈ 100k agents, far beyond any
+// agent contributes up to 3 files; 150k entries ≈ 50k agents, far beyond any
// realistic single-user history. When exceeded we LOG + truncate (CLAUDE.md "no
// silent caps"). Kept in sync with the `entries` cap in peerCosHistoryManifestSchema.
-const COS_HISTORY_MANIFEST_CAP = 300_000;
+// Chosen so the worst-case serialized manifest (~180 bytes/entry ≈ 27MB) stays
+// UNDER COS_HISTORY_MANIFEST_MAX_BYTES below — otherwise this sender-side
+// truncation never engages and a receiver instead rejects the whole manifest on
+// its content-length check (mirrors media-library's 100k-entries-under-32MB).
+const COS_HISTORY_MANIFEST_CAP = 150_000;
// The manifest JSON itself (not the archive bytes — those ride the per-file cap).
const COS_HISTORY_MANIFEST_MAX_BYTES = 32 * 1024 * 1024;
// Per-archive-file hard cap. Agent transcripts (output.txt) can be large; 64MB is