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: calibrate goal fidelity for manifest-driven process removal
[._.]/ Adam Eivyca96714edd86
diff --git a/server/services/codeReview.js b/server/services/codeReview.jsindex 508f1109a8..25df2ed936 100644--- a/server/services/codeReview.js+++ b/server/services/codeReview.js@@ -529,6 +529,12 @@ For an objective that asks to move or reorder an existing UI section, a diff mayFor 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.+For an objective to align a default process manifest with production startup and remove a retired process from the UI's expected-process list, judge manifest membership at the registry boundary, even without a literal UI assertion or a changed UI file. Apply this only to paired production removal plus fresh/legacy registry evidence:+- First inspect the runtime baseline, independently of the seed and tests. BOTH \`pm2ProcessNames\` and \`processes\` must remove the retired name. A leading space in a diff is retained code, not a deletion: \` { name: 'portos-ui', ... }\` still expects portos-ui; \`- { name: 'portos-ui', ... }\` removes it. A deletion in another file cannot remove this retained entry.+- Then check that the shipped seed removes it from both arrays, and that registry-loading tests cover fresh AND legacy manifests with both arrays matching the production startup set that excludes it. With those production removals and registry assertions, do not demand a separate rendered-UI test solely to restate manifest membership.+- Counterexamples: a seed-only edit, a test-only change, removal from only one array, or a retained runtime process entry is incomplete. Return fix-first or rethink for these incomplete shapes, never ship. Added expectations cannot substitute for or override contradictory production code. In particular, runtime pm2ProcessNames deletion + runtime processes context retaining portos-ui + seed deletions + tests expecting absence = fix-first, missing: ["portos-ui remains in runtime processes"]. Both runtime deletions + both seed deletions + fresh/legacy registry assertions = ship, missing: [], unrequested: [].+- Do not infer an unseen consumer repair or waive a separate UI behavior explicitly requested by the objective. Test code is verification evidence, but is not proof that tests were run or passed.+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.jsindex b4c8192eb3..2783aa5ee6 100644--- a/server/services/codeReview.test.js+++ b/server/services/codeReview.test.js@@ -1,3 +1,4 @@+import { readFileSync } from 'node:fs'import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'// Mock the settings store before importing the SUT — the resolver reads@@ -65,6 +66,17 @@ import {import { MODEL_SELECTABLE_REVIEWERS, EFFORT_SELECTABLE_REVIEWERS } from '../lib/cosValidation.js'import { updateSettingsWith } from './settings.js'+// Preserve the real transport for the explicitly requested local-model evaluation.+const nativeFetch = global.fetch+const processManifestCase = JSON.parse(readFileSync(new URL('../test/fixtures/goal-fidelity-process-manifest.json', import.meta.url), 'utf8'))+const manifestDiffParts = processManifestCase.diff.split(/(?=^diff --git )/m).filter(Boolean)+const manifestCases = [+ ['complete runtime and seed removal', processManifestCase.diff, 'ship'],+ ['seed only', manifestDiffParts.find(part => part.startsWith('diff --git a/data.reference/')), 'fix-first'],+ ['tests only', manifestDiffParts.find(part => part.startsWith('diff --git a/server/services/apps.test.js')), 'rethink'],+ ['runtime process entry retained', processManifestCase.diff.replace("- { name: 'portos-ui', port: PORTS.UI, ports: { devUi: PORTS.UI } },", " { name: 'portos-ui', port: PORTS.UI, ports: { devUi: PORTS.UI } },").replace('@@ -57,7 +57,6 @@', '@@ -57,7 +57,7 @@'), 'fix-first'],+]+// Minimal stand-ins for the deps resolveReviewLoopOptions is handed by its// callers (agentCliSpawning / agentCompletionCleanup) — kept trivial so the// test exercises the resolver's own model-map assembly, not validation.js.@@ -1036,6 +1048,40 @@ describe('codeReview helpers', () => {expect(prompt).toContain('added duplicate whose old copy remains')})+ // Transport/contract regression; the opt-in real-model test below checks judgement.+ it.each(manifestCases)('preserves the bounded manifest calibration and verdict: %s', async (_name, diff, verdict) => {+ global.fetch = vi.fn(async (_url, init) => {+ const { messages } = JSON.parse(init.body)+ expect(messages[1].content).toContain(processManifestCase.objective)+ expect(messages[1].content).toContain(diff.trim())+ expect(messages[0].content).toContain('even without a literal UI assertion or a changed UI file')+ expect(messages[0].content).toContain('paired production removal plus fresh/legacy registry evidence')+ expect(messages[0].content).toContain('a seed-only edit, a test-only change, removal from only one array')+ expect(messages[0].content).toContain('Do not infer an unseen consumer repair or waive a separate UI behavior')+ expect(messages[0].content).toContain('Return fix-first or rethink for these incomplete shapes, never ship')+ expect(messages[0].content).toContain('Added expectations cannot substitute for or override contradictory production code')+ expect(messages[0].content).toContain('not proof that tests were run or passed')+ return mockJsonResponse({ choices: [{ message: { content: JSON.stringify({+ verdict, missing: verdict === 'ship' ? [] : ['complete production manifest removal'],+ unrequested: [], evidence: 'Registry regression assertions are present only in cases carrying the test diff.',+ }) } }] })+ })+ const result = await runLocalGoalFidelityReview({ backend: 'ollama', model: 'example-model', objective: processManifestCase.objective, diff })+ expect(result).toMatchObject({ ok: true, verdict })+ })++ // Explicit opt-in only: ordinary CI never calls an AI provider.+ it.runIf(Boolean(process.env.GOAL_FIDELITY_EVAL_MODEL)).each(manifestCases)('judges the manifest fixture with a real local model: %s', async (_name, diff, expected) => {+ global.fetch = nativeFetch+ const result = await runLocalGoalFidelityReview({+ backend: 'ollama', model: process.env.GOAL_FIDELITY_EVAL_MODEL,+ objective: processManifestCase.objective, diff, timeoutMs: 180_000,+ })+ expect(result.ok, result.error).toBe(true)+ if (expected === 'ship') expect(result).toMatchObject({ verdict: 'ship', missing: [], unrequested: [] })+ else expect(['fix-first', 'rethink'], JSON.stringify(result)).toContain(result.verdict)+ }, 190_000)+it('escapes a diff that carries its own fence so it cannot break out into the objective half', async () => {await runLocalGoalFidelityReview({backend: 'ollama',diff --git a/server/test/fixtures/goal-fidelity-process-manifest.json b/server/test/fixtures/goal-fidelity-process-manifest.jsonnew file mode 100644index 0000000000..ee2a5b7e5d--- /dev/null+++ b/server/test/fixtures/goal-fidelity-process-manifest.json@@ -0,0 +1,5 @@+{+ "source": "PR #8874, head 85d06e9223cedf9724658ef9d7608554c35d19c8; objective reconstructed from the calibration report.",+ "objective": "Now that we have refactored the running processes, update the default PortOS manifest to match production startup. Remove portos-ui from the expected processes so the UI no longer shows it as missing, including for existing manifests.",+ "diff": "diff --git a/data.reference/apps.json b/data.reference/apps.json\nindex e5d13d6d1..81fef619e 100644\n--- a/data.reference/apps.json\n+++ b/data.reference/apps.json\n@@ -7,14 +7,15 @@\n \"repoPath\": \"__PORTOS_ROOT__\",\n \"type\": \"express\",\n \"uiPort\": 5555,\n- \"apiPort\": 5554,\n+ \"apiPort\": 5555,\n+ \"devUiPort\": 5554,\n+ \"buildCommand\": \"npm run build\",\n \"startCommands\": [\n- \"npm run dev\"\n+ \"npm start\"\n ],\n \"pm2ProcessNames\": [\n \"portos-server\",\n \"portos-cos\",\n- \"portos-ui\",\n \"portos-autofixer\",\n \"portos-autofixer-ui\",\n \"portos-browser\"\n@@ -28,19 +29,14 @@\n \"processes\": [\n {\n \"name\": \"portos-server\",\n- \"port\": 5554,\n- \"ports\": { \"api\": 5554 }\n+ \"port\": 5555,\n+ \"ports\": { \"api\": 5555 }\n },\n {\n \"name\": \"portos-cos\",\n \"port\": 5558,\n \"ports\": { \"api\": 5558 }\n },\n- {\n- \"name\": \"portos-ui\",\n- \"port\": 5555,\n- \"ports\": { \"ui\": 5555 }\n- },\n {\n \"name\": \"portos-autofixer\",\n \"port\": 5559,\ndiff --git a/server/services/apps.js b/server/services/apps.js\nindex f128ea5db..e80a4ac58 100644\n--- a/server/services/apps.js\n+++ b/server/services/apps.js\n@@ -43,10 +43,10 @@ function buildPortosApp() {\n tlsPort: certPresent ? PORTS.API : null,\n buildCommand: 'npm run build',\n startCommands: ['npm start'],\n+ // Match npm start: Vite is development-only, not an expected production process.\n pm2ProcessNames: [\n 'portos-server',\n 'portos-cos',\n- 'portos-ui',\n 'portos-autofixer',\n 'portos-autofixer-ui',\n 'portos-browser'\n@@ -57,7 +57,6 @@ function buildPortosApp() {\n // there and Overview would otherwise show a dead port.\n { name: 'portos-server', port: PORTS.API, ports: certPresent ? { api: PORTS.API, 'api-local': PORTS.API_LOCAL } : { api: PORTS.API } },\n { name: 'portos-cos', port: PORTS.COS, ports: { api: PORTS.COS } },\n- { name: 'portos-ui', port: PORTS.UI, ports: { devUi: PORTS.UI } },\n { name: 'portos-autofixer', port: PORTS.AUTOFIXER, ports: { api: PORTS.AUTOFIXER } },\n { name: 'portos-autofixer-ui', port: PORTS.AUTOFIXER_UI, ports: { ui: PORTS.AUTOFIXER_UI } },\n { name: 'portos-browser', port: PORTS.CDP, ports: { cdp: PORTS.CDP, health: PORTS.CDP_HEALTH } }\ndiff --git a/server/services/apps.test.js b/server/services/apps.test.js\nindex f77a89fa8..397994a7f 100644\n--- a/server/services/apps.test.js\n+++ b/server/services/apps.test.js\n@@ -1,3 +1,4 @@\n+import { readFileSync } from 'node:fs';\n import { describe, it, expect, vi, beforeEach } from 'vitest';\n \n vi.mock('fs/promises', () => ({\n@@ -440,3 +441,37 @@ describe('__PORTOS_ROOT__ placeholder expansion on load', () => {\n expect(persisted.apps['other-app'].appIconPath).toBe('/mock/root/icon.png');\n });\n });\n+\n+\n+describe('PortOS production process manifest', () => {\n+ beforeEach(() => {\n+ invalidateCache();\n+ vi.clearAllMocks();\n+ });\n+\n+ it.each([false, true])('matches production startup and repairs legacy manifests (existing: %s)', async (existing) => {\n+ const seed = JSON.parse(readFileSync(new URL('../../data.reference/apps.json', import.meta.url), 'utf8')).apps[PORTOS_APP_ID];\n+ const scripts = JSON.parse(readFileSync(new URL('../../package.json', import.meta.url), 'utf8')).scripts;\n+ const expectedNames = scripts.start.match(/--only \"([^\"]+)\"/)[1].split(',');\n+ readJSONFile.mockResolvedValue({ apps: existing ? {\n+ [PORTOS_APP_ID]: {\n+ ...seed,\n+ description: 'Custom description',\n+ pm2ProcessNames: [...expectedNames, 'portos-ui'],\n+ processes: [...seed.processes, { name: 'portos-ui', port: 5554 }],\n+ },\n+ } : {} });\n+\n+ const app = (await getAllApps()).find(({ id }) => id === PORTOS_APP_ID);\n+ expect(app.pm2ProcessNames).toEqual(expectedNames);\n+ expect(app.processes.map(({ name }) => name)).toEqual(expectedNames);\n+ expect(app).toMatchObject({ uiPort: 5555, apiPort: 5555, devUiPort: 5554, startCommands: ['npm start'] });\n+ expect(app.processes[0]).toMatchObject({ name: 'portos-server', port: 5555, ports: { api: 5555 } });\n+ expect(seed.pm2ProcessNames).toEqual(expectedNames);\n+ expect(seed.processes.map(({ name }) => name)).toEqual(expectedNames);\n+ expect(seed).toMatchObject({ uiPort: app.uiPort, apiPort: app.apiPort, devUiPort: app.devUiPort, startCommands: app.startCommands, buildCommand: app.buildCommand });\n+ expect(seed.processes[0]).toEqual(app.processes[0]);\n+ if (existing) expect(app.description).toBe('Custom description');\n+ expect(atomicWrite.mock.calls.at(-1)[1].apps[PORTOS_APP_ID].pm2ProcessNames).toEqual(expectedNames);\n+ });\n+});\n"+}