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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: bound serialized checkout archive manifests
[._.]/ Adam Eivy5d022c0d6e67
diff --git a/server/services/heldCheckoutRecovery.js b/server/services/heldCheckoutRecovery.jsindex 2d2235b5d6..b048f7b22c 100644--- a/server/services/heldCheckoutRecovery.js+++ b/server/services/heldCheckoutRecovery.js@@ -38,6 +38,7 @@ export const heldCheckoutArchiveRoot = (cosDir = PATHS.cos) => join(cosDir, 'helconst evidenceHash = value => createHash('sha256').update(value).digest('hex');const MAX_ARCHIVE_FILES = 1000;+const MAX_MANIFEST_BYTES = 16 * 1024 * 1024;function checkArchiveBudget(content, administration) {if (content.files.length + administration.files.length > MAX_ARCHIVE_FILES) throw new Error('archive-file-budget-exceeded');@@ -64,7 +65,7 @@ async function archiveFile(root, path) {async function archiveManifest(dir) {const path = await archiveFile(dir, join(dir, 'manifest.json'));- if ((await lstat(path)).size > 16 * 1024 * 1024) throw new Error('archive-manifest-budget-exceeded');+ if ((await lstat(path)).size > MAX_MANIFEST_BYTES) throw new Error('archive-manifest-budget-exceeded');const bytes = await readFile(path);return { manifest: JSON.parse(bytes), digest: evidenceHash(bytes) };}@@ -281,7 +282,9 @@ function checkArchiveSize(scope, fileBytes, totalBytes) {} });}-const archiveLimitRefusal = error => error.message === 'archive-file-budget-exceeded'+const archiveLimitRefusal = error => error.message === 'archive-manifest-budget-exceeded'+ ? { ok: false, reason: 'retirement-archive-manifest-limit-exceeded' }+ : error.message === 'archive-file-budget-exceeded'? { ok: false, reason: 'retirement-archive-file-limit-exceeded' }: error.message === 'retirement-archive-limit-exceeded'? { ok: false, reason: error.message, archiveLimit: error.archiveLimit } : null;@@ -758,7 +761,7 @@ async function writeArchive(dir, { repoPath, tree, branch, defaultBranch, releasif (administrationAfter.fingerprint !== administration.fingerprint) throw new Error('administration changed while archiving');if (after.fingerprint !== snapshot.fingerprint) throw new Error('checkout content changed while archiving');- await atomicWrite(join(dir, 'manifest.json'), {+ const manifest = {repoPath, defaultBranch, path: tree.path, head: tree.head, branch,release, review, administration: { ...administration, files: administration.files.map(({ source: _source, ...file }) => file) }, archivedAt: new Date().toISOString(),bundleSha256: await sha256File(bundle),@@ -774,7 +777,12 @@ async function writeArchive(dir, { repoPath, tree, branch, defaultBranch, releasfiles.length ? 'cp -R files/. <checkout>/' : null,symlinks.length ? 'recreate manifest.captured.symlinks with ln -s' : null,].filter(Boolean),- });+ };+ // Check the exact payload atomicWrite receives: escaped review text can make+ // the manifest larger than its individually bounded Git diff inputs.+ const serialized = JSON.stringify(manifest, null, 2);+ if (Buffer.byteLength(serialized) > MAX_MANIFEST_BYTES) throw new Error('archive-manifest-budget-exceeded');+ await atomicWrite(join(dir, 'manifest.json'), serialized);await chmod(join(dir, 'manifest.json'), 0o600);return { dir, fingerprint: snapshot.fingerprint, administrationFingerprint: administration.fingerprint };}diff --git a/server/services/heldCheckoutRecovery.test.js b/server/services/heldCheckoutRecovery.test.jsindex d85b9acaf6..bd79ccd561 100644--- a/server/services/heldCheckoutRecovery.test.js+++ b/server/services/heldCheckoutRecovery.test.js@@ -870,11 +870,11 @@ describe.skipIf(SKIP_HEAVY_INTEGRATION)('held checkout recovery (real git)', ()expect(existsSync(handoff.path)).toBe(true);expect(await archives()).toEqual([]);});- async function reviewedCheckout(name, { superseded = false, gitlink = false, normalMerge = false, featurePath = 'feature.txt', multipleCommits = false } = {}) {+ async function reviewedCheckout(name, { superseded = false, gitlink = false, normalMerge = false, featurePath = 'feature.txt', featureBody = 'original feature\n', multipleCommits = false } = {}) {let firstCommit;let changeBase;const { path, release } = await heldCheckout(name, { branch: `feature/${name}`, beforeLock: async tree => {- await writeFile(join(tree, featurePath), 'original feature\n');+ await writeFile(join(tree, featurePath), featureBody);await execGit(['--literal-pathspecs', 'add', featurePath], tree);if (gitlink) {const commit = (await execGit(['rev-parse', 'HEAD'], tree)).stdout.trim();@@ -932,6 +932,28 @@ describe.skipIf(SKIP_HEAVY_INTEGRATION)('held checkout recovery (real git)', ()return checkout;}+ it('preserves the checkout when escaped review evidence exceeds the recovery manifest limit', async () => {+ const c = await reviewedCheckout('manifest-byte-limit', {+ superseded: true, featurePath: 'tabs.txt', featureBody: '\t'.repeat(4 * 1024 * 1024 - 512) + '\n',+ });+ await execGit(['rm', 'tabs.txt'], repo);+ await execGit(['commit', '-m', 'remove superseded feature'], repo);+ c.forge.defaultHead = (await execGit(['rev-parse', 'main'], repo)).stdout.trim();+ const prepared = await c.prepare();+ expect(prepared.ok).toBe(true);+ expect(Buffer.byteLength(prepared.review.comparison.localPatch)).toBeLessThan(4 * 1024 * 1024);+ expect(Buffer.byteLength(prepared.review.comparison.difference)).toBeLessThan(4 * 1024 * 1024);+ const before = await getBranchReconcileOutcome('app-1');+ const original = await sha256File(join(c.path, 'tabs.txt'));+ expect(await c.confirm(prepared.review)).toEqual({ ok: false, reason: 'retirement-archive-manifest-limit-exceeded' });+ expect(await sha256File(join(c.path, 'tabs.txt'))).toBe(original);+ expect(await registered(c.path)).toBe(true);+ expect(await lockText(c.path)).toBe(c.release.lockReason);+ expect((await execGit(['rev-parse', c.release.branch], repo)).stdout.trim()).toBe(c.release.head);+ expect(await archives()).toEqual([]);+ expect(await getBranchReconcileOutcome('app-1')).toEqual(before);+ });+it('refuses file-count overflow before preview, reviewed retirement or unattended archive publication', async () => {const c = await reviewedCheckout('file-count-overflow', { normalMerge: true });const prepared = await c.prepare();