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: preserve catalog audit lifecycle guidance (#5074)

[._.]/ Adam Eivye478181f8bf4
diff --git a/server/services/agentFinalization.js b/server/services/agentFinalization.js
index 421a37fabd..2f2f366679 100644
--- a/server/services/agentFinalization.js
+++ b/server/services/agentFinalization.js
@@ -103,7 +103,7 @@ export function releaseAgentLane({ agentId, success, duration, exitCode, executi
*
* @returns {Promise<boolean|null|'skip-learning'>}
*/
-export async function evaluateSuccessCriteria({ task, terminatedByUser, workspacePath, startedAt = null, success = false, hookResult = null, noChangesToShip = false }) {
+export async function evaluateSuccessCriteria({ task, terminatedByUser, workspacePath, startedAt = null, success = false, hookResult = null, noChangesToShip = false, noChangeProof = null }) {
if (terminatedByUser) return null;
const taskType = task?.taskType || 'user';
// The SCHEDULED type (`metadata.analysisType`) if any, else the queue category —
@@ -132,6 +132,16 @@ export async function evaluateSuccessCriteria({ task, terminatedByUser, workspac
// exception to an explicitly opted-in autonomous job. Do not use the marker
// as a general no-commit exemption: a real change still needs the commit probe.
if (success && noChangesToShip === true && isVerifiedNoChangeTask(task)) return true;
+ // A marked no-change audit needs a forge answer and an unambiguous empty-branch
+ // proof. If either check was inconclusive, leave learning undeclared rather than
+ // scoring a correct no-op as a commit miss. A non-empty branch remains a real
+ // change path and still uses the ordinary commit criterion below.
+ if (success && isVerifiedNoChangeTask(task) && (
+ noChangeProof?.inconclusive === true
+ || noChangeProof?.category === FORGE_UNREACHABLE_CATEGORY
+ || noChangeProof?.commitsAhead === null
+ || noChangeProof?.branch === null
+ )) return null;
// Pipeline/media tasks deliver artifacts, not a commit — the
// commit criterion doesn't apply, so don't mislabel a clean artifact run as a
// validation miss (which would also pollute the correlation window). null =
@@ -319,7 +329,7 @@ async function countCommitsAhead(workspacePath) {
* branch that DOES hold commits
* - `ok: false, category: 'forge-unreachable'` — we could not ask
*
- * @returns {Promise<{ ok: boolean, category?: string, message?: string, branch?: string|null, noChangesToShip?: boolean, commitsAhead?: number|null }>}
+ * @returns {Promise<{ ok: boolean, category?: string, message?: string, branch?: string|null, noChangesToShip?: boolean, commitsAhead?: number|null, inconclusive?: boolean }>}
*/
export async function verifyPrClaim({ task, workspacePath, success, prExpected }) {
// Only a run that CLAIMED success has a claim to verify; a failed run is
@@ -329,7 +339,7 @@ export async function verifyPrClaim({ task, workspacePath, success, prExpected }
if (!branch) {
// No branch to ask about (detached HEAD, non-repo workspace). Nothing was
// verified — say nothing rather than invent a failure.
- return { ok: true, branch: null };
+ return { ok: true, branch: null, inconclusive: true };
}
const { resolveForgeForRepo } = await import('./git.js');
@@ -363,6 +373,7 @@ export async function verifyPrClaim({ task, workspacePath, success, prExpected }
ok: false,
branch,
commitsAhead: ahead,
+ inconclusive: ahead === null,
category: PR_MISSING_CATEGORY,
message: `Agent reported success but no ${noun} exists for branch ${branch}`
};
@@ -371,7 +382,8 @@ export async function verifyPrClaim({ task, workspacePath, success, prExpected }
ok: false,
branch,
category: FORGE_UNREACHABLE_CATEGORY,
- message: `Could not confirm a ${noun} for branch ${branch} — the forge is unreachable${found.detail ? ` (${String(found.detail).split('\n')[0].slice(0, 120)})` : ''}`
+ message: `Could not confirm a ${noun} for branch ${branch} — the forge is unreachable${found.detail ? ` (${String(found.detail).split('\n')[0].slice(0, 120)})` : ''}`,
+ inconclusive: true,
};
}
@@ -660,6 +672,7 @@ export async function finalizeAgent({
// A THROW here is not a verdict — fall back to the reported outcome rather
// than manufacturing a failure out of a check that never ran.
let prCheckThrew = false;
+ const noChangeAudit = !terminatedByUser && reportedSuccess && isVerifiedNoChangeTask(task);
const prVerdict = terminatedByUser
? { ok: true }
: await verifyPrClaim({ task, workspacePath, success: reportedSuccess, prExpected })
@@ -676,14 +689,21 @@ export async function finalizeAgent({
// a clean exit can satisfy its no-change success criterion. Keep this
// auxiliary verdict separate: a non-empty branch must remain eligible for
// cleanup to open the PR after finalize rather than being downgraded here.
- const noChangeProof = !terminatedByUser && !prExpected && reportedSuccess && isVerifiedNoChangeTask(task)
- ? await verifyPrClaim({ task, workspacePath, success: reportedSuccess, prExpected: true })
- .catch(err => {
- emitLog('warn', `⚠️ No-change verification failed for ${agentId}: ${err.message}`, { agentId });
- return { ok: false };
- })
- : { ok: true };
- const noChangesToShip = prVerdict.noChangesToShip === true || noChangeProof.noChangesToShip === true;
+ const noChangeProof = noChangeAudit
+ ? prExpected
+ ? (prCheckThrew
+ ? { ok: false, category: FORGE_UNREACHABLE_CATEGORY, inconclusive: true }
+ : prVerdict)
+ : await verifyPrClaim({ task, workspacePath, success: reportedSuccess, prExpected: true })
+ .catch(err => {
+ emitLog('warn', `⚠️ No-change verification failed for ${agentId}: ${err.message}`, { agentId });
+ return { ok: false, category: FORGE_UNREACHABLE_CATEGORY, inconclusive: true };
+ })
+ : null;
+ const effectivePrVerdict = typeof prVerdict.branch === 'string'
+ ? prVerdict
+ : (noChangeProof || prVerdict);
+ const noChangesToShip = prVerdict.noChangesToShip === true || noChangeProof?.noChangesToShip === true;
// Record the verdict in the lifecycle ledger (#4540) — but ONLY when the
// check actually reached one. `verifyPrClaim` returns the same `{ ok: true }`
@@ -701,8 +721,8 @@ export async function finalizeAgent({
// being down is not evidence about the PR. Recording it as `verified: false`
// would put "this run shipped no PR" on the record for a run that may well
// have shipped one.
- if (!prCheckThrew && typeof prVerdict.branch === 'string' && prVerdict.category !== FORGE_UNREACHABLE_CATEGORY) {
- const verified = prVerdict.ok === true;
+ if (!prCheckThrew && typeof effectivePrVerdict.branch === 'string' && effectivePrVerdict.category !== FORGE_UNREACHABLE_CATEGORY) {
+ const verified = effectivePrVerdict.ok === true;
await appendRunEvent({
kind: 'run.pr-verified',
runId,
@@ -713,12 +733,12 @@ export async function finalizeAgent({
// path) into one entry; the verdict part keeps a run whose SECOND check
// found the PR its first check missed from being silently suppressed by
// the miss — that transition is the whole reason to look at the ledger.
- eventId: `pr-verify:${agentId}:${runId || 'no-run'}:${verified ? 'ok' : prVerdict.category || 'failed'}`,
+ eventId: `pr-verify:${agentId}:${runId || 'no-run'}:${verified ? 'ok' : effectivePrVerdict.category || 'failed'}`,
data: {
verified,
- branch: prVerdict.branch ?? null,
- category: prVerdict.category ?? null,
- noChangesToShip: prVerdict.noChangesToShip === true,
+ branch: effectivePrVerdict.branch ?? null,
+ category: effectivePrVerdict.category ?? null,
+ noChangesToShip: effectivePrVerdict.noChangesToShip === true,
},
});
}
@@ -769,7 +789,7 @@ export async function finalizeAgent({
} else if (noChangesToShip) {
// A no-op run is a legitimate completion, not a silent one — the human still
// wants to know a task burned an agent and concluded there was nothing to do.
- const noChangeBranch = prVerdict.branch || noChangeProof.branch;
+ const noChangeBranch = effectivePrVerdict.branch || noChangeProof?.branch;
emitLog('info', `🫧 ${agentId} opened no change request and committed nothing to ${noChangeBranch} — recording the run as complete with no change warranted`, {
agentId, taskId: task?.id, branch: noChangeBranch
});
@@ -831,6 +851,7 @@ export async function finalizeAgent({
success,
hookResult,
noChangesToShip,
+ noChangeProof,
})
.catch(err => {
emitLog('warn', `⚠️ Success-criteria validation failed for ${agentId}: ${err.message}`, { agentId });
@@ -969,7 +990,7 @@ export async function finalizeAgent({
// downgraded to `pr-missing` would still be cleaned up as a success — worktree
// removed, local branch deleted, and no resume pointer recorded — destroying
// the state the retry needs to open the PR that is missing.
- return { success, prVerdict };
+ return { success, prVerdict: effectivePrVerdict };
}
// Tail of the agent's raw PTY spool scanned by the transcript rescue. The
diff --git a/server/services/agentFinalization.prVerification.test.js b/server/services/agentFinalization.prVerification.test.js
index b9af231292..a3f1826a87 100644
--- a/server/services/agentFinalization.prVerification.test.js
+++ b/server/services/agentFinalization.prVerification.test.js
@@ -290,6 +290,7 @@ describe('verifyPrClaim (#3358)', () => {
const verdict = await verifyPrClaim({ task: prTask(), workspacePath: '/w', success: true, prExpected: true });
expect(verdict.ok).toBe(true);
expect(verdict.branch).toBeNull();
+ expect(verdict.inconclusive).toBe(true);
expect(findPullRequestForBranchMock).not.toHaveBeenCalled();
});
});
@@ -349,7 +350,7 @@ describe('finalizeAgent — a PR-shaped run with no PR is not a success (#3358)'
onBranch('cos/sys-1/agent-1');
git.ahead = 0;
findPullRequestForBranchMock.mockResolvedValue({ status: 'none', number: null, url: null, detail: null });
- await finalize({
+ const finalized = await finalize({
prExpected: false,
task: {
...prTask(),
@@ -360,6 +361,38 @@ describe('finalizeAgent — a PR-shaped run with no PR is not a success (#3358)'
expect(findPullRequestForBranchMock).toHaveBeenCalledWith('cos/sys-1/agent-1', { cwd: '/w', env: null });
const [, result] = completeAgentMock.mock.calls[0];
expect(result).toMatchObject({ success: true, validationPassed: true });
+ expect(finalized.prVerdict).toMatchObject({ ok: true, branch: 'cos/sys-1/agent-1', noChangesToShip: true });
+ });
+
+ it('leaves validation undeclared when a marked no-op audit cannot reach the forge', async () => {
+ onBranch('cos/sys-1/agent-1');
+ findPullRequestForBranchMock.mockResolvedValue({ status: 'unavailable', number: null, url: null, detail: 'connection refused' });
+ await finalize({
+ prExpected: false,
+ task: {
+ ...prTask(),
+ metadata: { ...prTask().metadata, autonomousJob: true, noChangeSuccess: true }
+ }
+ });
+
+ const [, result] = completeAgentMock.mock.calls[0];
+ expect(result).toMatchObject({ success: true, validationPassed: null });
+ });
+
+ it('leaves validation undeclared when a marked no-op audit cannot prove its empty branch', async () => {
+ onBranch('cos/sys-1/agent-1');
+ git.ahead = null;
+ findPullRequestForBranchMock.mockResolvedValue({ status: 'none', number: null, url: null, detail: null });
+ await finalize({
+ prExpected: false,
+ task: {
+ ...prTask(),
+ metadata: { ...prTask().metadata, autonomousJob: true, noChangeSuccess: true }
+ }
+ });
+
+ const [, result] = completeAgentMock.mock.calls[0];
+ expect(result).toMatchObject({ success: true, validationPassed: null });
});
it('records validation success when the marked catalog audit has no change to ship', async () => {
@@ -495,6 +528,28 @@ describe('finalizeAgent — records the PR verdict in the lifecycle ledger', ()
expect(prVerified()).toHaveLength(0);
});
+ it('records the auxiliary no-change proof and returns it to cleanup', async () => {
+ onBranch('cos/sys-1/agent-1');
+ git.ahead = 0;
+ findPullRequestForBranchMock.mockResolvedValue({ status: 'none', number: null, url: null, detail: null });
+ const finalized = await finalize({
+ prExpected: false,
+ task: {
+ ...prTask(),
+ metadata: { ...prTask().metadata, autonomousJob: true, noChangeSuccess: true }
+ }
+ });
+
+ expect(prVerified()).toEqual([expect.objectContaining({
+ data: expect.objectContaining({
+ verified: true,
+ branch: 'cos/sys-1/agent-1',
+ noChangesToShip: true,
+ })
+ })]);
+ expect(finalized.prVerdict).toMatchObject({ branch: 'cos/sys-1/agent-1', noChangesToShip: true });
+ });
+
it('writes NOTHING when the check itself threw', async () => {
// A throw is not a verdict — the finalize path already falls back to the
// reported outcome, and the ledger must not claim a forge confirmed anything.
diff --git a/server/services/agentPromptBuilder.js b/server/services/agentPromptBuilder.js
index 9d91f4e132..a1cac900a3 100644
--- a/server/services/agentPromptBuilder.js
+++ b/server/services/agentPromptBuilder.js
@@ -317,6 +317,18 @@ export async function buildAgentPrompt(task, config, workspaceDir, worktreeInfo
const noCodeOutput = isTruthyMetaFn(task.metadata?.noCodeOutput) || isCreativeDirectorTask;
const noChangeSuccess = isTruthyMetaFn(task.metadata?.noChangeSuccess);
const isWorktreeOnExistingBranch = isPrBranchWorktree(task, worktreeInfo);
+ const worktreeCommitNote = worktreeInfo
+ ? worktreeCommitGuidance({
+ isTui,
+ hasSlashdo: false,
+ ownsPrWorkflow: false,
+ isWorktreeOnExistingBranch,
+ willOpenPR,
+ discardWorktree,
+ claimFlow,
+ noChangeSuccess,
+ })
+ : '';
const worktreeSection = worktreeInfo ? `
## Git Worktree Context
You are working in an **isolated git worktree** to avoid conflicts with other agents working concurrently.
@@ -324,17 +336,7 @@ You are working in an **isolated git worktree** to avoid conflicts with other ag
- **Worktree Path**: \`${worktreeInfo.worktreePath}\`
${worktreeInfo.baseBranch ? `- **Based on**: \`${worktreeInfo.baseBranch}\` (latest from origin)` : ''}
-**Important**: ${discardWorktree
- ? DISCARD_WORKTREE_NOTE
- : claimFlow
- ? 'The claim workflow in the Completion section owns its claim branch, push, PR/MR, review, merge or human-handoff, and cleanup — do not hand those steps back to PortOS.'
- : noChangeSuccess
- ? NO_CHANGE_AUDIT_GUIDANCE
- : isTui
- ? 'Commit your changes to this branch — see the **Completion Workflow** section below for the full push/PR/exit sequence.'
- : isWorktreeOnExistingBranch
- ? 'Commit and **push** any review-fix commits to this branch — the PR points at it, so pushed commits are how Copilot sees your fixes. Use `git pull --rebase` before pushing if needed.'
- : `Commit your changes to this branch.${willOpenPR ? ' When your task completes, the system will push this branch and open a pull request against the default branch — do NOT push or open a PR yourself.' : ' Your commits will be automatically merged back to the main development branch when your task completes.'}`} Do NOT manually switch branches or modify the worktree configuration.
+**Important**: ${worktreeCommitNote} Do NOT manually switch branches or modify the worktree configuration.
${buildResumeSection(task, worktreeInfo)}` : '';
// Build pipeline context section if this is a pipeline stage
@@ -371,7 +373,7 @@ Use the findings from the previous stage to inform your work. If the previous st
? 'run `/simplify` to review the changed code for reuse, quality, and efficiency'
: SIMPLIFY_INLINE_REVIEW;
// Discard tasks don't commit, so the simplify-before-commit step is moot.
- const simplifySection = simplifyEnabled && !isTui && !discardWorktree && !claimFlow && !noChangeSuccess ? `
+ const simplifySection = simplifyEnabled && !isTui && !discardWorktree && !claimFlow ? `
## Simplify Step
After completing your work and before committing, ${simplifyInstruction}. Fix any issues found, then ${worktreeInfo && willOpenPR ? 'commit your changes (do NOT push — on a successful run the system will push and open the PR after you exit; if the run fails, no push or PR happens)' : 'commit and push using `/do:push`'}.
` : '';
@@ -424,9 +426,7 @@ After completing your work and before committing, ${simplifyInstruction}. Fix an
? buildProgrammaticOutputCompletionSection(sentinelPath)
: claimFlow
? buildClaimFlowCompletionSection({ isTui, sentinelPath, reviewersCsv: claimReviewersCsv(task, codeReviewDefaults, defaultReviewers) })
- : noChangeSuccess
- ? `${NO_CHANGE_AUDIT_GUIDANCE} If the catalogs are current, leave the worktree clean and complete using the no-change path above; if they are stale, continue through the normal commit/PR workflow.`
- : isTui
+ : isTui
? buildTuiCompletionSection({
willOpenPR, prCompletion, simplifyEnabled, noChangeSuccess,
// Unreachable today — every `tui`/`cli` provider returns early at the
@@ -655,6 +655,7 @@ ${(() => {
- **Before starting work**, run \`git status\` to verify a clean working tree. Do NOT stash or discard uncommitted changes — other agents may be working concurrently and expecting those changes to be present. If the tree is dirty, only commit files YOU changed for this task.
- **NEVER use \`git stash\`** in any form (\`git stash push\`, \`git stash pop\`, etc.). This is a multi-agent system — stashing can silently destroy or corrupt another agent's or the user's in-progress work. Work around uncommitted changes instead. (Note: the backend may use \`--autostash\` in user-triggered pull operations — that is safe because those are single-user UI actions, not concurrent agent operations.)
- **Only commit files YOU changed** for this task. Never use \`git add -A\` or \`git add .\` — always stage specific files by name.
+${noChangeSuccess ? `- **No-change audits may exit cleanly.** ${NO_CHANGE_AUDIT_GUIDANCE}` : ''}
${noCodeOutput
? `- **Do NOT commit, push, or open a PR.** This task changes no code — its result is delivered by the API call or command described above. Without this, a no-worktree task of this shape was told to \`/do:push\` **directly to the branch it is standing on**, which for a task running in the app's live checkout is its default branch.`
: discardWorktree
@@ -663,9 +664,7 @@ ${noCodeOutput
? `- **Follow the claim workflow prompt above.** It owns the claim worktree and the full PR/MR lifecycle; do not stop after committing or hand push/PR/merge/cleanup back to PortOS.`
: isReviewLoopFollowUp
? `- **Push fixes straight to the PR branch you are on** (the follow-up section above is the procedure). Stage specific files, use a \`fix:\` prefix, no Co-Authored-By annotations. Do NOT open a new PR.`
- : noChangeSuccess
- ? `- **No-change audits may exit cleanly.** ${NO_CHANGE_AUDIT_GUIDANCE}`
- : isTui && tuiSlashdoFree
+ : isTui && tuiSlashdoFree
? `- **Commit only — do NOT push.** Stage specific files, use \`feat:\`/\`fix:\`/\`breaking:\` prefix in the commit message, no Co-Authored-By annotations, then write the completion sentinel. PortOS will handle the branch after it closes the session.`
: isTui
? `- **Use \`${tuiCompletionCommand}\` to ${willOpenPR ? 'commit, push, and open the PR' : 'commit and push the branch'}** — see the Completion Workflow section above. Stage specific files (no \`git add -A\`), use \`feat:\`/\`fix:\`/\`breaking:\` prefix in the commit message, no Co-Authored-By annotations.`
diff --git a/server/services/agentPromptBuilder.test.js b/server/services/agentPromptBuilder.test.js
index de7192e755..f1f7dbcf8f 100644
--- a/server/services/agentPromptBuilder.test.js
+++ b/server/services/agentPromptBuilder.test.js
@@ -284,6 +284,28 @@ describe('claim-flow completion handoff', () => {
expect(prompt).not.toMatch(/PortOS will merge it back after completion/);
});
+ it('keeps the full API no-change prompt coupled to the normal change workflow', async () => {
+ const prompt = await buildAgentPrompt(
+ makeTask({ metadata: {
+ autonomousJob: true,
+ noChangeSuccess: true,
+ useWorktree: true,
+ openPR: true,
+ simplify: true,
+ } }),
+ {}, '/repo',
+ { branchName: 'b', worktreePath: '/tmp/wt', baseBranch: 'origin/main' },
+ isTruthyMeta,
+ { providerType: 'api' },
+ );
+
+ expect(prompt).toMatch(/leave the worktree clean/i);
+ expect(prompt).toMatch(/If a change is needed, continue through the normal workflow/i);
+ expect(prompt).toMatch(/## Simplify Step/);
+ expect(prompt).toMatch(/system will push and open/i);
+ expect(prompt).toMatch(/Only commit files YOU changed/);
+ });
+
it('recognizes a queued legacy claim task by analysisType', () => {
const prompt = buildLightContextPrompt(
makeTask({ metadata: { analysisType: 'claim-issue', useWorktree: false, openPR: false } }),
@@ -1140,11 +1162,30 @@ describe('buildLightContextPrompt', () => {
expect(prompt).toMatch(/no change is needed/i);
expect(prompt).toMatch(/leave the worktree clean/i);
expect(prompt).toMatch(/exit without committing/i);
- expect(prompt).toMatch(/If a change is needed, continue through the normal workflow/i);
- expect(prompt).toMatch(/gh pr create/);
- });
+ expect(prompt).toMatch(/If a change is needed, continue through the normal workflow/i);
+ expect(prompt).toMatch(/gh pr create/);
+ });
+
+ it('keeps the TUI no-change sentinel compatible with a real PR result', () => {
+ const prompt = buildLightContextPrompt(
+ makeTask({ metadata: {
+ autonomousJob: true,
+ noChangeSuccess: true,
+ useWorktree: true,
+ openPR: true,
+ simplify: true,
+ } }),
+ '/r',
+ { branchName: 'b', worktreePath: '/tmp/wt' },
+ isTruthyMeta,
+ { isTui: true, providerId: 'claude-code-tui', providerCommand: 'claude' },
+ );
+
+ expect(prompt).toMatch(/`\/do:pr/);
+ expect(prompt).toMatch(/<PR URL, or "No change needed; no PR opened\." if the audit made no change>/);
+ });
- // #3114 — the gates now derive from `resolveSlashdoStyle` with the spawners'
+ // #3114 — the gates now derive from `resolveSlashdoStyle` with the spawners'
// blank-command posture, so a CLI provider with NO id and NO command reads as
// Claude: `buildCliSpawnConfig`'s default branch launches `claude`, and the
// session that actually runs does have `/do:pr` / `/simplify`.
@@ -2166,7 +2207,7 @@ describe('buildCompletionGuidelineBullet', () => {
isReadOnly: false, isTui: false, tuiCompletionCommand: '/do:pr',
worktreeInfo: { worktreePath: '/wt' }, willOpenPR: true, noChangeSuccess: true,
});
- expect(bullet).toMatch(/no code changes/i);
+ expect(bullet).toMatch(/no change is needed/i);
expect(bullet).toMatch(/leave the worktree clean/i);
expect(bullet).toMatch(/exit without committing/i);
expect(bullet).toMatch(/If a change is needed, continue/);
diff --git a/server/services/autonomousJobs/portosCliCatalogRefresh.js b/server/services/autonomousJobs/portosCliCatalogRefresh.js
index c2a8580077..8a420fe5e4 100644
--- a/server/services/autonomousJobs/portosCliCatalogRefresh.js
+++ b/server/services/autonomousJobs/portosCliCatalogRefresh.js
@@ -37,8 +37,10 @@ fresh-install seed snapshots (server/lib/aiToolkit/defaults/providers.sample.jso
and data.reference/providers.json), keeping those seeds synchronized. Update the
compatibility recognition that protects independently upgraded installs. When a
shipped default changes, preserve the old seeded Antigravity list in
-PRIOR_ANTIGRAVITY_MODEL_CATALOGS (and update any equivalent provider-specific
-prior-default recognition required by the migration). Preserve configured-default
+PRIOR_ANTIGRAVITY_MODEL_CATALOGS. Codex has no prior-catalog recognition today —
+changing CODEX_MODELS requires adding a PRIOR_CODEX_MODEL_CATALOGS list and an
+isPriorSeededList branch in migrateCodexProvider, mirroring
+migrateAntigravityModelCatalog. Preserve configured-default
sentinels, user-selected provider records, live-refreshed model lists, and every
user-selected default/light/medium/heavy pin. Never rewrite data/providers.json or
replace a customized provider list merely because it differs from the shipped
diff --git a/server/services/autonomousJobs/portosCliCatalogRefresh.test.js b/server/services/autonomousJobs/portosCliCatalogRefresh.test.js
index e41e4118bb..8d48c1fcdd 100644
--- a/server/services/autonomousJobs/portosCliCatalogRefresh.test.js
+++ b/server/services/autonomousJobs/portosCliCatalogRefresh.test.js
@@ -32,6 +32,8 @@ describe('PortOS CLI provider catalog refresh custom task', () => {
expect(PORTOS_CLI_CATALOG_REFRESH_JOB.promptTemplate).toContain('CODEX_MODELS')
expect(PORTOS_CLI_CATALOG_REFRESH_JOB.promptTemplate).toContain('ANTIGRAVITY_MODELS')
expect(PORTOS_CLI_CATALOG_REFRESH_JOB.promptTemplate).toContain('PRIOR_ANTIGRAVITY_MODEL_CATALOGS')
+ expect(PORTOS_CLI_CATALOG_REFRESH_JOB.promptTemplate).toContain('PRIOR_CODEX_MODEL_CATALOGS')
+ expect(PORTOS_CLI_CATALOG_REFRESH_JOB.promptTemplate).toContain('migrateCodexProvider')
expect(PORTOS_CLI_CATALOG_REFRESH_JOB.promptTemplate).toContain('Do NOT create a commit, push a branch, or open a PR')
expect(PORTOS_CLI_CATALOG_REFRESH_JOB.promptTemplate).toContain('data/providers.json')
})
diff --git a/server/services/promptSections/completion.js b/server/services/promptSections/completion.js
index 04c5f40843..570d9e95d5 100644
--- a/server/services/promptSections/completion.js
+++ b/server/services/promptSections/completion.js
@@ -10,7 +10,13 @@ import { PR_COMPLETIONS, leavesPrForHuman, resolvePrCompletion } from '../../lib
import { LIGHT_CONTEXT_PROVIDER_TYPES, SIMPLIFY_INLINE_REVIEW } from './constants.js';
import { buildCiMergeGateSteps, buildReviewLoopFollowUpSection, LEAVE_PR_OPEN_STEP } from './reviewLifecycle.js';
-export const NO_CHANGE_AUDIT_GUIDANCE = 'This audit may legitimately conclude that no change is needed. First verify the shipped catalogs against authoritative sources. If they are current, leave the worktree clean and do not run the commit, push, PR, or review steps below; write the completion sentinel when this provider uses one, or exit without committing when it does not. If a change is needed, continue through the normal workflow below.';
+export const NO_CHANGE_AUDIT_GUIDANCE = 'This audit may legitimately conclude that no change is needed. First verify the data this audit owns against authoritative sources. If the audited data is current, leave the worktree clean and do not run the commit, push, PR, or review steps below; write the completion sentinel when this provider uses one, or exit without committing when it does not. If a change is needed, continue through the normal workflow below.';
+
+function withNoChangeAuditGuidance(guidance, noChangeSuccess) {
+ return noChangeSuccess && guidance
+ ? `${NO_CHANGE_AUDIT_GUIDANCE}\n\n${guidance}`
+ : guidance;
+}
/**
* Build the single "## Guidelines" completion-handoff bullet for the full
@@ -68,9 +74,6 @@ export function buildCompletionGuidelineBullet({
if (isReadOnly) {
return '**This is a read-only task.** Do NOT commit, push, or modify any files in the repository. Only read data and generate reports.';
}
- if (noChangeSuccess) {
- return `**This audit may legitimately produce no code changes.** ${NO_CHANGE_AUDIT_GUIDANCE}`;
- }
if (isTui) {
// NOTE: in production this branch is only reachable from the full/api prompt
// path, where `isTui` is currently always false (TUI providers route through
@@ -80,7 +83,7 @@ export function buildCompletionGuidelineBullet({
const howTo = slashdoFree
? 'the Completion Workflow above (plain `git` commit + PortOS handoff — this provider has no slashdo commands)'
: `the Completion Workflow above (\`${tuiCompletionCommand}\`)`;
- return `On successful completion, YOU run ${howTo}, then write the sentinel and stop — PortOS closes the session once it sees the sentinel; do NOT run \`/quit\`.`;
+ return withNoChangeAuditGuidance(`On successful completion, YOU run ${howTo}, then write the sentinel and stop — PortOS closes the session once it sees the sentinel; do NOT run \`/quit\`.`, noChangeSuccess);
}
if (worktreeInfo && willOpenPR) {
const policyLeavesOpen = prCompletion === PR_COMPLETIONS.LEAVE_OPEN;
@@ -92,10 +95,10 @@ export function buildCompletionGuidelineBullet({
: runsReviewLoop
? ' For GitHub PRs, a Copilot code review will also be requested automatically (skipped on GitLab and other non-GitHub forges) — do NOT run `/do:rpr` or attempt to address review comments yourself; you will have already exited.'
: ' No review was requested for this task, so a follow-up agent merges the PR once CI is green — do NOT try to merge it yourself; you will have already exited.';
- return `On successful completion, the system will push your branch and open a pull request — do NOT open a PR manually. (If the task fails, no PR is opened; the worktree is then cleaned up unless a safety check preserves it for manual recovery.)${reviewSuffix}`;
+ return withNoChangeAuditGuidance(`On successful completion, the system will push your branch and open a pull request — do NOT open a PR manually. (If the task fails, no PR is opened; the worktree is then cleaned up unless a safety check preserves it for manual recovery.)${reviewSuffix}`, noChangeSuccess);
}
if (worktreeInfo) {
- return 'Your worktree branch will be automatically merged back to the source branch when your task completes — do NOT open a PR.';
+ return withNoChangeAuditGuidance('Your worktree branch will be automatically merged back to the source branch when your task completes — do NOT open a PR.', noChangeSuccess);
}
return null;
}
@@ -301,24 +304,23 @@ export function buildClaimFlowCompletionSection({ isTui = false, sentinelPath =
export function worktreeCommitGuidance({ isTui, hasSlashdo, ownsPrWorkflow = false, isWorktreeOnExistingBranch, willOpenPR, discardWorktree, claimFlow = false, noChangeSuccess = false }) {
if (discardWorktree) return DISCARD_WORKTREE_NOTE;
if (claimFlow) return 'The claim workflow in the Completion section owns the push, PR/MR, review, merge or human-handoff, and cleanup steps.';
- if (noChangeSuccess) return NO_CHANGE_AUDIT_GUIDANCE;
- if (isTui) return 'Commit your changes to this branch — see **Completion Workflow** below.';
+ if (isTui) return withNoChangeAuditGuidance('Commit your changes to this branch — see **Completion Workflow** below.', noChangeSuccess);
if (isWorktreeOnExistingBranch) {
- return 'Commit and **push** any review-fix commits to this branch (the PR points at it). Use `git pull --rebase` before pushing if needed.';
+ return withNoChangeAuditGuidance('Commit and **push** any review-fix commits to this branch (the PR points at it). Use `git pull --rebase` before pushing if needed.', noChangeSuccess);
}
if (hasSlashdo && willOpenPR) {
- return 'Commit your changes here — the **Completion** section below drives the push and PR.';
+ return withNoChangeAuditGuidance('Commit your changes here — the **Completion** section below drives the push and PR.', noChangeSuccess);
}
if (hasSlashdo) {
- return 'Commit your changes here — the **Completion** section below drives the push.';
+ return withNoChangeAuditGuidance('Commit your changes here — the **Completion** section below drives the push.', noChangeSuccess);
}
if (ownsPrWorkflow && willOpenPR) {
- return 'Commit your changes here — the **Completion** section below drives the push, the PR, the review loop, and the merge.';
+ return withNoChangeAuditGuidance('Commit your changes here — the **Completion** section below drives the push, the PR, the review loop, and the merge.', noChangeSuccess);
}
if (willOpenPR) {
- return 'Commit your changes here. The system will push and open a PR after you exit — do NOT push or open a PR yourself.';
+ return withNoChangeAuditGuidance('Commit your changes here. The system will push and open a PR after you exit — do NOT push or open a PR yourself.', noChangeSuccess);
}
- return 'Commit your changes here. Your branch will be merged back automatically when the task completes.';
+ return withNoChangeAuditGuidance('Commit your changes here. Your branch will be merged back automatically when the task completes.', noChangeSuccess);
}
/**
@@ -465,9 +467,11 @@ export function buildTuiCompletionSection({ willOpenPR, prCompletion = PR_COMPLE
// Reached only for a Claude TUI (a non-Claude one took the slashdoFree branch
// above), so `/simplify` — a Claude Code built-in — is invokable here.
const simplifyStep = simplifyEnabled ? '1. `/simplify`' : '1. (simplify disabled — skip)';
- const sentinelTail = noChangeSuccess
- ? ' ## PR\n No change needed; no PR opened.'
- : willOpenPR ? ' ## PR\n <PR URL>' : ' ## Branch\n <branch name>';
+ const sentinelTail = willOpenPR
+ ? (noChangeSuccess
+ ? ' ## PR\n <PR URL, or "No change needed; no PR opened." if the audit made no change>'
+ : ' ## PR\n <PR URL>')
+ : ' ## Branch\n <branch name>';
// A PR gets merge steps — gated on the review verdict when a loop runs, on CI
// alone when it doesn't (nothing else merges a no-review-loop PR). The one
// exception is a PR a human lands (JIRA-tracked; see lib/prDisposition.js).
@@ -570,9 +574,11 @@ function buildManualTuiCompletionSection({ willOpenPR, prCompletion = PR_COMPLET
const simplifyStep = simplifyEnabled
? `1. Before committing, ${SIMPLIFY_INLINE_REVIEW} and fix any findings.`
: '1. (simplify disabled — skip)';
- const sentinelTail = noChangeSuccess
- ? ' ## PR\n No change needed; no PR opened.'
- : drivesOwnPr ? ' ## PR\n <PR URL>' : ' ## Branch\n <branch name>';
+ const sentinelTail = (drivesOwnPr || willOpenPR)
+ ? (noChangeSuccess
+ ? ' ## PR\n <PR URL, or "No change needed; no PR opened." if the audit made no change>'
+ : ' ## PR\n <PR URL>')
+ : ' ## Branch\n <branch name>';
const lines = [
'## Completion Workflow',