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

fix: calibrate federation schema gap fidelity

[._.]/ Adam Eivyf0e1da15002c
diff --git a/server/services/codeReview.js b/server/services/codeReview.js
index 8e0442cbd1..b6d72fca30 100644
--- a/server/services/codeReview.js
+++ b/server/services/codeReview.js
@@ -498,6 +498,8 @@ Judge the production behavior before treating a regression test as the behavior
For an objective that asks to move or reorder an existing UI section, a diff may show the move as a complete added block and a complete deleted block. When the same complete named section, with materially unchanged contents, is added at the requested position and its former placement is removed, judge the pair as one relocation that satisfies the requested order. Do not call the insertion an unrequested addition or the removal a missing section. This rule applies only when the diff establishes that matched move: an added duplicate whose old copy remains, a different section, or independent content changes must still be judged on their own; matching headings alone do not prove a relocation.
+For an objective about clearing a federated peer's displayed schema-mismatch warning, a diff that makes the unchanged-checksum shortcut conditional on an already saved peer/category schema gap is a production retry, not a check-only change. The saved gap sends that category through the existing snapshot apply path again, where the receiver checks the newly fetched envelope's \`portosMeta.schemaVersions\`; a successful apply clears the saved warning for that peer/category. \`portosMeta.portosVersion\` is only the friendly label captured for display, while \`schemaVersions\` controls compatibility, so an older displayed label does not make this retry ineffective. Count the bypass as requested behavior only when the diff scopes it to an existing peer/category gap and preserves the ordinary unchanged-checksum return otherwise. An unconditional retry, a display-label-only edit, or a generic checksum change does not receive this interpretation and must be judged against the objective as usual.
+
Answer these three questions and nothing else: is anything the objective asked for missing from the diff, is anything in the diff outside what the objective asked for, and does the diff carry real evidence that its work was verified (tests, checks, a stated verification step).
Return exactly one JSON object and no markdown:
diff --git a/server/services/codeReview.test.js b/server/services/codeReview.test.js
index 72c02d35dd..b4c8192eb3 100644
--- a/server/services/codeReview.test.js
+++ b/server/services/codeReview.test.js
@@ -873,6 +873,62 @@ describe('codeReview helpers', () => {
expect(request.messages[0].content).toContain('test-only change')
})
+ it('ships a same-checksum retry scoped to a saved federated schema gap, not an unconditional retry', async () => {
+ const objective = 'On our federated instances page, I see a schema version mismatch.'
+ const scopedRetryDiff = [
+ 'diff --git a/server/services/syncOrchestrator.js b/server/services/syncOrchestrator.js',
+ '@@ -524,7 +524,11 @@',
+ ' const lastChecksum = cachedChecksums?.[category] ?? null;',
+ '- if (lastChecksum && lastChecksum === checksumRes.checksum) {',
+ '+ // A saved schema gap is compatibility state, independent of payload changes.',
+ '+ const hasSchemaGap = Boolean(peer?.schemaGaps?.[category]);',
+ '+ if (lastChecksum && lastChecksum === checksumRes.checksum && !hasSchemaGap) {',
+ ' return { totalApplied: 0, checksum: checksumRes.checksum };',
+ ' }',
+ ].join('\n')
+ const unconditionalRetryDiff = scopedRetryDiff
+ .replace('+ // A saved schema gap is compatibility state, independent of payload changes.\n', '')
+ .replace('+ const hasSchemaGap = Boolean(peer?.schemaGaps?.[category]);\n', '')
+ .replace('+ if (lastChecksum && lastChecksum === checksumRes.checksum && !hasSchemaGap) {', '+ if (false) {')
+
+ global.fetch = vi.fn(async (_url, init) => {
+ const request = JSON.parse(init.body)
+ const rubric = request.messages[0].content
+ const evidence = request.messages[1].content
+ const recognizesScopedRetry = rubric.includes('conditional on an already saved peer/category schema gap')
+ && rubric.includes('newly fetched envelope\'s `portosMeta.schemaVersions`')
+ && rubric.includes('older displayed label does not make this retry ineffective')
+ const diffShowsScopedRetry = evidence.includes('peer?.schemaGaps?.[category]')
+ && evidence.includes('&& !hasSchemaGap')
+ && evidence.includes('lastChecksum === checksumRes.checksum')
+ return mockJsonResponse({
+ choices: [{ message: { content: JSON.stringify(recognizesScopedRetry && diffShowsScopedRetry
+ ? { verdict: 'ship', missing: [], unrequested: [], evidence: 'the saved category gap retries the unchanged snapshot through the current schemaVersions gate and clears on successful apply' }
+ : { verdict: 'rethink', missing: ['a scoped retry for the saved schema gap'], unrequested: ['an unconditional checksum bypass'], evidence: 'this diff retries unchanged categories without limiting the retry to a saved gap' }) } }],
+ })
+ })
+
+ const scoped = await runLocalGoalFidelityReview({ backend: 'ollama', model: 'example-model', objective, diff: scopedRetryDiff })
+ const unconditional = await runLocalGoalFidelityReview({ backend: 'ollama', model: 'example-model', objective, diff: unconditionalRetryDiff })
+
+ expect(scoped).toMatchObject({
+ ok: true,
+ verdict: 'ship',
+ missing: [],
+ unrequested: [],
+ })
+ expect(unconditional).toMatchObject({
+ ok: true,
+ verdict: 'rethink',
+ missing: ['a scoped retry for the saved schema gap'],
+ unrequested: ['an unconditional checksum bypass'],
+ })
+ const prompt = JSON.parse(global.fetch.mock.calls[0][1].body).messages[0].content
+ expect(prompt).toContain('a production retry, not a check-only change')
+ expect(prompt).toContain('An unconditional retry')
+ expect(prompt).toContain('schemaVersions` controls compatibility')
+ })
+
it('ships a complete section relocation without exempting a duplicate insertion', async () => {
const objective = 'On the code animation page, I think the format should be ordered before the brief.'
const formatSection = [