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([issue-12758]): tolerate checkout retirement in getRemoteBranches and fetch proof objects in initialized recovery
[._.]/ Adam Eivy1516802aef1d
diff --git a/server/services/git.js b/server/services/git.jsindex 6fc635068e..9d9d135a95 100644--- a/server/services/git.js+++ b/server/services/git.js@@ -1346,7 +1346,7 @@ export async function getRemoteBranches(dir, { force = false } = {}) {// Fetch latest refs if forced or not fresh within windowif (force || !isFetchFresh(dir)) {const { withCheckoutPublication } = await import('../lib/checkoutRetirementAdmission.js');- await withCheckoutPublication(dir, async () => {+ const freshen = () => withCheckoutPublication(dir, async () => {if (activeFetches.has(dir)) {await activeFetches.get(dir);} else {@@ -1364,6 +1364,14 @@ export async function getRemoteBranches(dir, { force = false } = {}) {await fetchPromise;}});+ if (force) {+ await freshen();+ } else {+ await freshen().catch(error => {+ if (error?.code === 'CHECKOUT_RETIREMENT_RESERVED' || error?.message === 'checkout-retirement-reserved') return null;+ throw error;+ });+ }}// Detect default branchdiff --git a/server/services/git.publication.test.js b/server/services/git.publication.test.jsindex 0b1498e63f..ac84fd800a 100644--- a/server/services/git.publication.test.js+++ b/server/services/git.publication.test.js@@ -90,6 +90,8 @@ describe('Git service publication fencing', () => {for (const writer of writers) {await expect(writer(dir)).rejects.toMatchObject({ code: 'CHECKOUT_RETIREMENT_RESERVED' });}+ const branches = await getRemoteBranches(dir);+ expect(branches).toHaveProperty('branches');}expect(await Promise.all([fixture.repo, linked].map(checkoutState))).toEqual(before);} finally {diff --git a/server/services/heldCheckoutRecovery.js b/server/services/heldCheckoutRecovery.jsindex 91f30a1401..80c1483fe0 100644--- a/server/services/heldCheckoutRecovery.js+++ b/server/services/heldCheckoutRecovery.js@@ -559,7 +559,7 @@ const sameRelease = (entry, release) => entry.path === release.path && entry.hea// Preview and receipt paths may acquire exact server-verified proof commits// into the object store, never a branch, index or implicit approval.-async function fetchRetirementProofObjects(repoPath, release, prUrl, expectedHeadSha, opts) {+export async function fetchRetirementProofObjects(repoPath, release, prUrl, expectedHeadSha, opts) {const [{ readRetirementForgeEvidence }, { getOriginInfo }, { resolveForgeExecOptions }] = await Promise.all([import('./heldCheckoutReview.js'), import('../lib/gitRemote.js'), import('./forgeExecOptions.js'),]);diff --git a/server/services/initializedCheckoutRecovery.js b/server/services/initializedCheckoutRecovery.jsindex 8f02687703..e55f8bc749 100644--- a/server/services/initializedCheckoutRecovery.js+++ b/server/services/initializedCheckoutRecovery.js@@ -176,9 +176,22 @@ export function _createInitializedCheckoutRecovery(deps = {}) {ctx.repoPath, release.branch, prUrl, { forgeAccount: ctx.forgeAccount, exactAliasHead: release.head }));const comparison = deps.comparison || (async (ctx, release, prUrl, snapshot, policy, forgeFacts) => {const { buildCheckoutRetirementReview } = await import('./heldCheckoutReview.js');- return buildCheckoutRetirementReview({ repoPath: ctx.repoPath, release, prUrl,+ const run = () => buildCheckoutRetirementReview({ repoPath: ctx.repoPath, release, prUrl,contentFingerprint: snapshot.fingerprint, administrationFingerprint: snapshot.administrationFingerprint, policy },{ readForge: async () => forgeFacts });+ try {+ return await run();+ } catch (error) {+ if (error?.message === 'retirement-local-objects-missing') {+ const { fetchRetirementProofObjects } = await import('./heldCheckoutRecovery.js');+ const fetched = await (deps.fetchProofObjects || fetchRetirementProofObjects)(+ ctx.repoPath, release, prUrl, null,+ { forgeAccount: ctx.forgeAccount, readForge: async () => forgeFacts, exactAliasHead: release.head }+ );+ if (fetched?.ok) return run();+ }+ throw error;+ }});const ensureOwner = async (ctx, release, registration = true) => {const result = await ownership({ repoPath: ctx.repoPath, release, registration });diff --git a/server/services/initializedCheckoutRecovery.test.js b/server/services/initializedCheckoutRecovery.test.jsindex 7016141d7f..7e7b42b2a1 100644--- a/server/services/initializedCheckoutRecovery.test.js+++ b/server/services/initializedCheckoutRecovery.test.js@@ -1155,6 +1155,33 @@ describe('initialized checkout transaction', () => {await writeFile(first, JSON.stringify(value));await expect(fixture.service.status({ appId: 'app', transactionId: result.transactionId })).rejects.toThrow('retirement-journal-invalid');});+ it('acquires missing forge proof objects when review comparison reports retirement-local-objects-missing', async () => {+ let attempts = 0;+ const fetchProofObjects = vi.fn(async () => ({ ok: true }));+ const recovery = _createInitializedCheckoutRecovery({+ ...fixture.deps,+ comparison: undefined,+ fetchProofObjects,+ });+ const heldReview = await import('./heldCheckoutReview.js');+ const spy = vi.spyOn(heldReview, 'buildCheckoutRetirementReview').mockImplementation(async () => {+ if (++attempts === 1) throw new Error('retirement-local-objects-missing');+ return {+ release,+ forge: fixture.facts,+ policy: null,+ comparison: { disposition: 'integrated', difference: '' },+ };+ });+ try {+ const response = await recovery.review({ appId: 'app', release, prUrl });+ expect(response.ok).toBe(true);+ expect(fetchProofObjects).toHaveBeenCalledTimes(1);+ expect(spy).toHaveBeenCalledTimes(2);+ } finally {+ spy.mockRestore();+ }+ });});// These exercise persisted journal discovery through the actual service