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 no-op lifecycle (#5074)

[._.]/ Adam Eivyd82b5186addf
diff --git a/server/lib/cosValidation.js b/server/lib/cosValidation.js
index 5d1f39054a..150b0ff02d 100644
--- a/server/lib/cosValidation.js
+++ b/server/lib/cosValidation.js
@@ -1475,6 +1475,9 @@ export const createCosJobSchema = z.object({
// deliverable is intentionally outside the worktree — see
// ALLOWED_TASK_METADATA_KEYS below and agentTuiSpawning.js (#3102).
worktreeChangesExpected: z.boolean().optional(),
+ // PortOS-owned audits may succeed after proving the branch is empty; the
+ // finalizer still requires the forge/no-commit proof before honoring this.
+ noChangeSuccess: z.boolean().optional(),
}).optional(),
});
@@ -1682,6 +1685,10 @@ const ALLOWED_TASK_METADATA_KEYS = [
// against a GitHub/GitLab/JIRA work tracker files its proposals as issues and,
// per the prompt, edits no application code, so a clean worktree is expected.
'worktreeChangesExpected',
+ // Allows a PortOS-owned audit's verified-empty-branch contract to survive
+ // app task-type override sanitization. The finalizer also requires the
+ // autonomous-job marker and a live forge proof before honoring it.
+ 'noChangeSuccess',
// Audit-type toggle: file tracker issues (no code) vs implement the fix.
// Dispatch stamps `noCodeOutput` when this is true. See server/lib/auditCatalog.js.
'fileIssues',
diff --git a/server/lib/cosValidation.test.js b/server/lib/cosValidation.test.js
index 493c4f4620..81526f6b69 100644
--- a/server/lib/cosValidation.test.js
+++ b/server/lib/cosValidation.test.js
@@ -124,6 +124,24 @@ describe('cosValidation job taskMetadata.worktreeChangesExpected (#3102)', () =>
});
});
+describe('cosValidation job taskMetadata.noChangeSuccess (#5074)', () => {
+ it('accepts the verified no-change marker and rejects non-boolean values', () => {
+ const parsed = createCosJobSchema.parse({
+ name: 'catalog audit',
+ taskMetadata: { useWorktree: true, noChangeSuccess: true },
+ });
+ expect(parsed.taskMetadata).toEqual({ useWorktree: true, noChangeSuccess: true });
+ expect(createCosJobSchema.safeParse({ name: 'catalog audit', taskMetadata: { noChangeSuccess: 'yes' } }).success)
+ .toBe(false);
+ });
+
+ it('keeps the marker available to app task-type override sanitization', () => {
+ expect(sanitizeTaskMetadata({ noChangeSuccess: true })).toEqual({ noChangeSuccess: true });
+ expect(sanitizeTaskMetadata({ noChangeSuccess: false })).toEqual({ noChangeSuccess: false });
+ expect(sanitizeTaskMetadata({ noChangeSuccess: 'true' })).toBeNull();
+ });
+});
+
describe('cosValidation task metadata claimFlow marker', () => {
it('sanitizes the claim lifecycle marker as a boolean', () => {
expect(sanitizeTaskMetadata({ claimFlow: true })).toEqual({ claimFlow: true });
diff --git a/server/routes/cosJobRoutes.js b/server/routes/cosJobRoutes.js
index fd7f1d8092..e1aa88d382 100644
--- a/server/routes/cosJobRoutes.js
+++ b/server/routes/cosJobRoutes.js
@@ -209,7 +209,11 @@ router.post('/jobs/:id/trigger', asyncHandler(async (req, res) => {
// Preserve the markers consumed by the job:spawned listener so Run now
// records the execution and re-registers the saved schedule.
autonomousJob: task.metadata?.autonomousJob,
- jobId: task.metadata?.jobId
+ jobId: task.metadata?.jobId,
+ // A marked audit may complete successfully with a verified empty branch;
+ // preserve that contract on the manually queued task as well as the
+ // scheduled task path.
+ noChangeSuccess: task.metadata?.noChangeSuccess
}, 'internal');
if (!taskResult?.id) {
diff --git a/server/routes/cosJobRoutes.test.js b/server/routes/cosJobRoutes.test.js
index aca289995c..5971fcf26d 100644
--- a/server/routes/cosJobRoutes.test.js
+++ b/server/routes/cosJobRoutes.test.js
@@ -500,6 +500,32 @@ describe('CoS Job Routes', () => {
);
});
+ it('should preserve the no-change success contract when Run now queues an agent job', async () => {
+ autonomousJobs.getJob.mockResolvedValue({ id: 'j1', type: 'agent', name: 'Catalog audit' });
+ autonomousJobs.isShellJob.mockReturnValue(false);
+ autonomousJobs.isScriptJob.mockReturnValue(false);
+ autonomousJobs.generateTaskFromJob.mockResolvedValue({
+ description: 'Audit catalogs',
+ priority: 'MEDIUM',
+ metadata: {
+ autonomousJob: true,
+ jobId: 'j1',
+ useWorktree: true,
+ openPR: true,
+ noChangeSuccess: true,
+ }
+ });
+ cos.addTask.mockResolvedValue({ id: 'task-no-change' });
+
+ const response = await request(app).post('/api/cos/jobs/j1/trigger');
+
+ expect(response.status).toBe(200);
+ expect(cos.addTask).toHaveBeenCalledWith(
+ expect.objectContaining({ autonomousJob: true, jobId: 'j1', noChangeSuccess: true }),
+ 'internal'
+ );
+ });
+
it('should forward provider + model overrides into addTask', async () => {
autonomousJobs.getJob.mockResolvedValue({ id: 'j1', type: 'agent', name: 'Pinned Review' });
autonomousJobs.isShellJob.mockReturnValue(false);
diff --git a/server/services/agentFinalization.js b/server/services/agentFinalization.js
index 9a6e94a578..421a37fabd 100644
--- a/server/services/agentFinalization.js
+++ b/server/services/agentFinalization.js
@@ -131,9 +131,7 @@ export async function evaluateSuccessCriteria({ task, terminatedByUser, workspac
// no PR exists AND the branch was proven empty; the task marker narrows this
// 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
- && task?.metadata?.autonomousJob === true
- && task?.metadata?.noChangeSuccess === true) return true;
+ if (success && noChangesToShip === true && isVerifiedNoChangeTask(task)) return true;
// 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 =
@@ -239,6 +237,11 @@ const HOOK_ABORTED_BEFORE_EVALUATION = new Set(['no-app', 'app-not-found']);
export const PR_MISSING_CATEGORY = 'pr-missing';
export const FORGE_UNREACHABLE_CATEGORY = 'forge-unreachable';
+function isVerifiedNoChangeTask(task) {
+ const isPersistedTrue = (value) => value === true || value === 'true';
+ return isPersistedTrue(task?.metadata?.autonomousJob) && isPersistedTrue(task?.metadata?.noChangeSuccess);
+}
+
/**
* The branch a finished agent's workspace is sitting on, or null when the
* workspace is gone / not a repo / detached. Read at finalize time, while the
@@ -666,6 +669,22 @@ export async function finalizeAgent({
return { ok: true };
});
+ // Codex/Antigravity/OpenCode sessions can own the PR workflow without being
+ // able to type slashdo commands, so their spawners deliberately pass
+ // `prExpected: false` and let cleanup act as the PR-creation backstop. A
+ // marked catalog audit still needs the same forge + empty-branch proof before
+ // 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;
+
// Record the verdict in the lifecycle ledger (#4540) — but ONLY when the
// check actually reached one. `verifyPrClaim` returns the same `{ ok: true }`
// for "the PR is there", for "this run never promised one", for "there was no
@@ -747,11 +766,12 @@ export async function finalizeAgent({
emitLog('warn', `⚠️ ${prVerdict.message} — recording ${agentId} as needs-attention (${prVerdict.category}) rather than complete`, {
agentId, taskId: task?.id, branch: prVerdict.branch, category: prVerdict.category
});
- } else if (prVerdict.noChangesToShip) {
+ } 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.
- emitLog('info', `🫧 ${agentId} opened no change request and committed nothing to ${prVerdict.branch} — recording the run as complete with no change warranted`, {
- agentId, taskId: task?.id, branch: prVerdict.branch
+ const noChangeBranch = prVerdict.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
});
}
@@ -810,7 +830,7 @@ export async function finalizeAgent({
startedAt: runStartedAt,
success,
hookResult,
- noChangesToShip: prVerdict.noChangesToShip === true,
+ noChangesToShip,
})
.catch(err => {
emitLog('warn', `⚠️ Success-criteria validation failed for ${agentId}: ${err.message}`, { agentId });
diff --git a/server/services/agentFinalization.prVerification.test.js b/server/services/agentFinalization.prVerification.test.js
index 5c6668894d..b9af231292 100644
--- a/server/services/agentFinalization.prVerification.test.js
+++ b/server/services/agentFinalization.prVerification.test.js
@@ -345,6 +345,23 @@ describe('finalizeAgent — a PR-shaped run with no PR is not a success (#3358)'
expect(resolveFailedTaskUpdateMock).not.toHaveBeenCalled();
});
+ it('proves a marked no-op audit even when cleanup owns PR creation', async () => {
+ onBranch('cos/sys-1/agent-1');
+ git.ahead = 0;
+ findPullRequestForBranchMock.mockResolvedValue({ status: 'none', number: null, url: null, detail: null });
+ await finalize({
+ prExpected: false,
+ task: {
+ ...prTask(),
+ metadata: { ...prTask().metadata, autonomousJob: true, noChangeSuccess: true }
+ }
+ });
+
+ 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 });
+ });
+
it('records validation success when the marked catalog audit has no change to ship', async () => {
onBranch('cos/sys-1/agent-1');
git.ahead = 0;
diff --git a/server/services/agentFinalization.successCriteria.test.js b/server/services/agentFinalization.successCriteria.test.js
index 0b455da586..d9000ebf4f 100644
--- a/server/services/agentFinalization.successCriteria.test.js
+++ b/server/services/agentFinalization.successCriteria.test.js
@@ -393,6 +393,18 @@ describe('evaluateSuccessCriteria — commit criterion (#2344, #3637)', () => {
expect(committedDuringRun).toHaveBeenCalledWith('/w', STARTED_AT);
});
+ it('accepts persisted string markers after the task markdown round-trip', async () => {
+ const task = {
+ id: 'catalog-audit-3',
+ taskType: 'internal',
+ metadata: { autonomousJob: 'true', noChangeSuccess: 'true' }
+ };
+ expect(await evaluateSuccessCriteria({
+ task, workspacePath: '/w', success: true, noChangesToShip: true, startedAt: STARTED_AT
+ })).toBe(true);
+ expect(committedDuringRun).not.toHaveBeenCalled();
+ });
+
it('passes an autonomous code run that COMMITTED during its window', async () => {
committedDuringRun.mockResolvedValueOnce(true);
expect(await evaluateSuccessCriteria({ task: { id: 't1', taskType: 'internal' }, workspacePath: '/w', startedAt: STARTED_AT })).toBe(true);
diff --git a/server/services/agentPromptBuilder.js b/server/services/agentPromptBuilder.js
index b7bdc03bcc..9d91f4e132 100644
--- a/server/services/agentPromptBuilder.js
+++ b/server/services/agentPromptBuilder.js
@@ -34,6 +34,7 @@ import {
buildCliCompletionSection,
buildCompletionGuidelineBullet,
buildInlineReviewLoopSection,
+ NO_CHANGE_AUDIT_GUIDANCE,
buildProgrammaticOutputCompletionSection,
buildReadOnlyCompletionSection,
buildResumeSection,
@@ -314,6 +315,7 @@ export async function buildAgentPrompt(task, config, workspaceDir, worktreeInfo
// `pending` BEFORE this flag existed (persisted across an upgrade) are still
// recognized without a metadata migration.
const noCodeOutput = isTruthyMetaFn(task.metadata?.noCodeOutput) || isCreativeDirectorTask;
+ const noChangeSuccess = isTruthyMetaFn(task.metadata?.noChangeSuccess);
const isWorktreeOnExistingBranch = isPrBranchWorktree(task, worktreeInfo);
const worktreeSection = worktreeInfo ? `
## Git Worktree Context
@@ -326,6 +328,8 @@ ${worktreeInfo.baseBranch ? `- **Based on**: \`${worktreeInfo.baseBranch}\` (lat
? 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
@@ -367,7 +371,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 ? `
+ const simplifySection = simplifyEnabled && !isTui && !discardWorktree && !claimFlow && !noChangeSuccess ? `
## 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`'}.
` : '';
@@ -420,9 +424,11 @@ After completing your work and before committing, ${simplifyInstruction}. Fix an
? buildProgrammaticOutputCompletionSection(sentinelPath)
: claimFlow
? buildClaimFlowCompletionSection({ isTui, sentinelPath, reviewersCsv: claimReviewersCsv(task, codeReviewDefaults, defaultReviewers) })
- : isTui
+ : 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
? buildTuiCompletionSection({
- willOpenPR, prCompletion, simplifyEnabled,
+ willOpenPR, prCompletion, simplifyEnabled, noChangeSuccess,
// Unreachable today — every `tui`/`cli` provider returns early at the
// LIGHT_CONTEXT gate above, so `isTui` is always false on this path
// (same situation as buildCompletionGuidelineBullet's `isTui` arm).
@@ -638,7 +644,7 @@ ${(() => {
const bullet = buildCompletionGuidelineBullet({
isReadOnly: isTruthyMetaFn(task.metadata?.readOnly),
isTui, tuiCompletionCommand, slashdoFree: isTui && !canRunSlashCommands,
- worktreeInfo, willOpenPR, prCompletion, discardWorktree, noCodeOutput,
+ worktreeInfo, willOpenPR, prCompletion, discardWorktree, noCodeOutput, noChangeSuccess,
leavePrOpen: leavesPrForHuman(task),
isPrFollowUp: isReviewLoopFollowUp, claimFlow,
});
@@ -657,6 +663,8 @@ ${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
? `- **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
@@ -734,6 +742,7 @@ function buildLightContextSections(task, workspaceDir, worktreeInfo, isTruthyMet
// derive from a CD task's `creativeDirector` marker so pre-upgrade `pending`
// tasks (queued before this flag existed) are recognized without a migration.
const noCodeOutput = isTruthyMetaFn(task.metadata?.noCodeOutput) || !!task.metadata?.creativeDirector;
+ const noChangeSuccess = isTruthyMetaFn(task.metadata?.noChangeSuccess);
const isReviewLoopFollowUp = isTruthyMetaFn(task.metadata?.reviewLoopFollowUp);
const isWorktreeOnExistingBranch = isPrBranchWorktree(task, worktreeInfo);
// Ordered reviewer list + flags for the Review Loop (task metadata wins; else
@@ -829,7 +838,7 @@ function buildLightContextSections(task, workspaceDir, worktreeInfo, isTruthyMet
`- **Path**: \`${worktreeInfo.worktreePath}\``,
worktreeInfo.baseBranch ? `- **Based on**: \`${worktreeInfo.baseBranch}\`` : null,
'',
- worktreeCommitGuidance({ isTui, hasSlashdo, ownsPrWorkflow, isWorktreeOnExistingBranch, willOpenPR, discardWorktree, claimFlow }),
+ worktreeCommitGuidance({ isTui, hasSlashdo, ownsPrWorkflow, isWorktreeOnExistingBranch, willOpenPR, discardWorktree, claimFlow, noChangeSuccess }),
'Do NOT manually switch branches or modify the worktree configuration.',
// Resuming a previous failed agent's branch: establish what's already done
// before writing code (see buildResumeSection). '' when not a resume.
@@ -905,7 +914,7 @@ function buildLightContextSections(task, workspaceDir, worktreeInfo, isTruthyMet
}
} else if (isTui) {
contractSections.push(buildTuiCompletionSection({
- willOpenPR, prCompletion, simplifyEnabled, slashdoFree: tuiSlashdoFree, ownsPrWorkflow,
+ willOpenPR, prCompletion, simplifyEnabled, noChangeSuccess, slashdoFree: tuiSlashdoFree, ownsPrWorkflow,
sentinelPath: resolveSentinelPath(worktreeInfo, workspaceDir, agentId),
branchName: worktreeInfo?.branchName || null,
baseBranch: worktreeInfo?.baseBranch || null,
@@ -914,7 +923,7 @@ function buildLightContextSections(task, workspaceDir, worktreeInfo, isTruthyMet
forgeCli: resolvedForgeCli
}));
} else {
- contractSections.push(buildCliCompletionSection({ worktreeInfo, willOpenPR, prCompletion, hasSlashdo, ownsPrWorkflow, simplifyEnabled, leavePrOpen: leavesPrForHuman(task), reviewers: lightReviewers, usernames: lightReviewerUsernames, optionalReviewers: lightOptionalReviewers, reviewerMaxRounds: lightReviewerMaxRounds, reviewerModels: lightReviewerModels, reviewerEfforts: lightReviewerEfforts, reviewStopMode: lightReviewStopMode, reviewerApplies: lightReviewerApplies, forgeCli: resolvedForgeCli }));
+ contractSections.push(buildCliCompletionSection({ worktreeInfo, willOpenPR, prCompletion, hasSlashdo, ownsPrWorkflow, simplifyEnabled, noChangeSuccess, leavePrOpen: leavesPrForHuman(task), reviewers: lightReviewers, usernames: lightReviewerUsernames, optionalReviewers: lightOptionalReviewers, reviewerMaxRounds: lightReviewerMaxRounds, reviewerModels: lightReviewerModels, reviewerEfforts: lightReviewerEfforts, reviewStopMode: lightReviewStopMode, reviewerApplies: lightReviewerApplies, forgeCli: resolvedForgeCli }));
}
// The manual workflow's step 4 points here — it must follow the completion
diff --git a/server/services/agentPromptBuilder.test.js b/server/services/agentPromptBuilder.test.js
index 2ab15cd7bf..de7192e755 100644
--- a/server/services/agentPromptBuilder.test.js
+++ b/server/services/agentPromptBuilder.test.js
@@ -1123,6 +1123,27 @@ describe('buildLightContextPrompt', () => {
expect(prompt).not.toMatch(/PortOS will push and open the PR/);
});
+ it('gives a marked catalog audit an explicit no-change exit while retaining the change workflow', () => {
+ const task = makeTask({ metadata: {
+ autonomousJob: true,
+ noChangeSuccess: true,
+ useWorktree: true,
+ openPR: true,
+ simplify: true,
+ } });
+ const prompt = buildLightContextPrompt(
+ task,
+ '/r',
+ { branchName: 'b', worktreePath: '/tmp/wt' },
+ isTruthyMeta,
+ { isTui: false, providerId: 'codex', providerCommand: 'codex' });
+ 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/);
+ });
+
// #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
@@ -2140,6 +2161,17 @@ describe('buildCompletionGuidelineBullet', () => {
expect(none).toBeNull();
});
+ it('marks a catalog audit no-op as a valid completion without weakening the change path', () => {
+ const bullet = 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(/leave the worktree clean/i);
+ expect(bullet).toMatch(/exit without committing/i);
+ expect(bullet).toMatch(/If a change is needed, continue/);
+ });
+
it('discardWorktree short-circuits to the reasoning-only bullet (wins over TUI/openPR)', () => {
const bullet = buildCompletionGuidelineBullet({
isReadOnly: false, isTui: true, tuiCompletionCommand: '/do:pr',
diff --git a/server/services/cosTaskStore.js b/server/services/cosTaskStore.js
index 287a8a26a4..8e443952a3 100644
--- a/server/services/cosTaskStore.js
+++ b/server/services/cosTaskStore.js
@@ -338,6 +338,8 @@ export async function addTask(taskData, taskType = 'user', { raw = false, ignore
if (taskData.app) metadata.app = taskData.app;
if (taskData.autonomousJob === true) metadata.autonomousJob = true;
if (typeof taskData.jobId === 'string' && taskData.jobId) metadata.jobId = taskData.jobId;
+ if (taskData.noChangeSuccess === true) metadata.noChangeSuccess = true;
+ else if (taskData.noChangeSuccess === false) metadata.noChangeSuccess = false;
// Pin this task to ONE federated instance (#4520): only that instance's CoS
// evaluator claims and runs it, every other peer passes over it. Absent —
// the default — leaves the opportunistic first-claim-wins behavior intact.
diff --git a/server/services/cosTaskStore.test.js b/server/services/cosTaskStore.test.js
index 0a6bb029ea..6a988ebaae 100644
--- a/server/services/cosTaskStore.test.js
+++ b/server/services/cosTaskStore.test.js
@@ -323,6 +323,20 @@ describe('cosTaskStore.addTask', () => {
expect(mock.events.some(e => e.name === 'tasks:changed' && e.payload.action === 'added' && e.payload.type === 'user')).toBe(true);
});
+ it('persists the no-change success marker for an autonomous audit', async () => {
+ const created = await addTask({
+ description: 'Audit shipped catalogs',
+ id: 'catalog-audit-task',
+ autonomousJob: true,
+ jobId: 'job-refresh-cli-provider-catalogs',
+ noChangeSuccess: true,
+ }, 'internal');
+
+ expect(created.metadata.noChangeSuccess).toBe(true);
+ const reloaded = (await getTaskById(created.id)).metadata.noChangeSuccess;
+ expect(reloaded === true || reloaded === 'true').toBe(true);
+ });
+
describe('targeted instance pin (#4520)', () => {
it('persists targetInstanceId and round-trips it through markdown', async () => {
const created = await addTask({ description: 'gpu work', id: 'task-pin', targetInstanceId: 'instance-bbbb' }, 'user');
diff --git a/server/services/promptSections/completion.js b/server/services/promptSections/completion.js
index cce62cf3d6..04c5f40843 100644
--- a/server/services/promptSections/completion.js
+++ b/server/services/promptSections/completion.js
@@ -10,6 +10,8 @@ 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.';
+
/**
* Build the single "## Guidelines" completion-handoff bullet for the full
* (api) prompt path. Mirrors the helper pattern the light path already uses
@@ -29,12 +31,14 @@ import { buildCiMergeGateSteps, buildReviewLoopFollowUpSection, LEAVE_PR_OPEN_ST
* @param {Object|null} opts.worktreeInfo
* @param {boolean} opts.willOpenPR
* @param {'review-then-merge'|'merge-on-green'|'leave-open'} opts.prCompletion
+ * @param {boolean} [opts.noChangeSuccess] - The task may succeed after a
+ * verified clean branch instead of producing a commit/PR.
* @returns {string|null}
*/
export function buildCompletionGuidelineBullet({
isReadOnly, isTui, tuiCompletionCommand, slashdoFree = false,
worktreeInfo, willOpenPR, prCompletion = PR_COMPLETIONS.MERGE_ON_GREEN, discardWorktree = false, noCodeOutput = false,
- leavePrOpen = false, isPrFollowUp = false, claimFlow = false,
+ leavePrOpen = false, isPrFollowUp = false, claimFlow = false, noChangeSuccess = false,
}) {
// A PR follow-up (review-loop or merge-only) already carries its own PRIMARY
// OBJECTIVE section with the full procedure, and its cleanup runs with
@@ -64,6 +68,9 @@ 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
@@ -291,9 +298,10 @@ export function buildClaimFlowCompletionSection({ isTui = false, sentinelPath =
* push workflow (TUI or Claude Code CLI with slashdo), reuse an existing PR
* branch (review fixes), or hand off to PortOS's post-exit push.
*/
-export function worktreeCommitGuidance({ isTui, hasSlashdo, ownsPrWorkflow = false, isWorktreeOnExistingBranch, willOpenPR, discardWorktree, claimFlow = false }) {
+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 (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.';
@@ -423,14 +431,14 @@ export function buildSentinelWriteSteps(stepNumber, sentinelPath, sentinelTail)
* return this IS a Claude session, so `/simplify` and `/do:pr` are both safe to
* emit without a second provider check.
*/
-export function buildTuiCompletionSection({ willOpenPR, prCompletion = PR_COMPLETIONS.MERGE_ON_GREEN, simplifyEnabled, sentinelPath, slashdoFree = false, ownsPrWorkflow = false, branchName = null, baseBranch = null, leavePrOpen = false, reviewers = DEFAULT_REVIEWERS, usernames = [], optionalReviewers = [], reviewerMaxRounds = {}, reviewerModels = {}, reviewerEfforts = {}, reviewStopMode = DEFAULT_REVIEW_STOP_MODE, reviewerApplies = false, forgeCli = 'gh' }) {
+export function buildTuiCompletionSection({ willOpenPR, prCompletion = PR_COMPLETIONS.MERGE_ON_GREEN, simplifyEnabled, sentinelPath, slashdoFree = false, ownsPrWorkflow = false, branchName = null, baseBranch = null, leavePrOpen = false, reviewers = DEFAULT_REVIEWERS, usernames = [], optionalReviewers = [], reviewerMaxRounds = {}, reviewerModels = {}, reviewerEfforts = {}, reviewStopMode = DEFAULT_REVIEW_STOP_MODE, reviewerApplies = false, forgeCli = 'gh', noChangeSuccess = false }) {
const policyLeavesOpen = prCompletion === PR_COMPLETIONS.LEAVE_OPEN;
const runsReviewLoop = prCompletion === PR_COMPLETIONS.REVIEW_THEN_MERGE;
if (slashdoFree) {
// Plain `git`/`gh` instead of `/do:pr` — but still the whole lifecycle when
// the session is a real coding harness (`ownsPrWorkflow`); the reviewer
// procedure it needs is inlined in the Review Loop section that follows.
- return buildManualTuiCompletionSection({ willOpenPR, prCompletion, simplifyEnabled, sentinelPath, branchName, baseBranch, leavePrOpen, ownsPrWorkflow, forgeCli });
+ return buildManualTuiCompletionSection({ willOpenPR, prCompletion, simplifyEnabled, sentinelPath, branchName, baseBranch, leavePrOpen, ownsPrWorkflow, forgeCli, noChangeSuccess });
}
const cmd = willOpenPR ? '/do:pr' : '/do:push';
// `/do:pr` may inherit a saved `review-with` default. Explicitly opt out
@@ -457,7 +465,9 @@ 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 = willOpenPR ? ' ## PR\n <PR URL>' : ' ## Branch\n <branch name>';
+ const sentinelTail = noChangeSuccess
+ ? ' ## PR\n No change needed; no PR opened.'
+ : willOpenPR ? ' ## 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).
@@ -468,6 +478,7 @@ export function buildTuiCompletionSection({ willOpenPR, prCompletion = PR_COMPLE
return [
'## Completion Workflow',
+ ...(noChangeSuccess ? ['', NO_CHANGE_AUDIT_GUIDANCE, ''] : []),
'When the task is complete, run these in order:',
'',
simplifyStep,
@@ -549,7 +560,7 @@ function buildManualPrCreateStep(step, { branchName, baseBranch, forgeCli = 'gh'
* `ownsPrWorkflow: false` (lean mode) keeps the original handoff: commit and
* stop, PortOS owns the post-exit push / PR / review / merge lifecycle.
*/
-function buildManualTuiCompletionSection({ willOpenPR, prCompletion = PR_COMPLETIONS.REVIEW_THEN_MERGE, simplifyEnabled, sentinelPath, branchName = null, baseBranch = null, leavePrOpen = false, ownsPrWorkflow = false, forgeCli = 'gh' }) {
+function buildManualTuiCompletionSection({ willOpenPR, prCompletion = PR_COMPLETIONS.REVIEW_THEN_MERGE, simplifyEnabled, sentinelPath, branchName = null, baseBranch = null, leavePrOpen = false, ownsPrWorkflow = false, forgeCli = 'gh', noChangeSuccess = false }) {
const policyLeavesOpen = prCompletion === PR_COMPLETIONS.LEAVE_OPEN;
const runsReviewLoop = prCompletion === PR_COMPLETIONS.REVIEW_THEN_MERGE;
// `ownsPrWorkflow` already folds in `willOpenPR`, the worktree, and the
@@ -559,10 +570,13 @@ 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 = drivesOwnPr ? ' ## PR\n <PR URL>' : ' ## Branch\n <branch name>';
+ const sentinelTail = noChangeSuccess
+ ? ' ## PR\n No change needed; no PR opened.'
+ : drivesOwnPr ? ' ## PR\n <PR URL>' : ' ## Branch\n <branch name>';
const lines = [
'## Completion Workflow',
+ ...(noChangeSuccess ? ['', NO_CHANGE_AUDIT_GUIDANCE, ''] : []),
drivesOwnPr
? `This provider does NOT have slashdo (\`/do:*\`) commands, so drive the handoff with plain \`git\` and \`${forgeCli}\`. **You own this ${forgeCli === 'glab' ? 'MR' : 'PR'} end to end — nothing else will open, review, or merge it.** Run these in order:`
: 'This provider does NOT have slashdo (`/do:*`) commands, so finish the handoff with plain `git`. Run these in order:',
@@ -691,11 +705,11 @@ export function buildInlineReviewLoopSection({
* CLI providers fall through to the legacy commit-only block where PortOS
* handles push+PR on exit.
*/
-export function buildCliCompletionSection({ worktreeInfo, willOpenPR, prCompletion = PR_COMPLETIONS.MERGE_ON_GREEN, hasSlashdo = false, ownsPrWorkflow = false, simplifyEnabled = false, leavePrOpen = false, reviewers = DEFAULT_REVIEWERS, usernames = [], optionalReviewers = [], reviewerMaxRounds = {}, reviewerModels = {}, reviewerEfforts = {}, reviewStopMode = DEFAULT_REVIEW_STOP_MODE, reviewerApplies = false, forgeCli = 'gh' }) {
+export function buildCliCompletionSection({ worktreeInfo, willOpenPR, prCompletion = PR_COMPLETIONS.MERGE_ON_GREEN, hasSlashdo = false, ownsPrWorkflow = false, simplifyEnabled = false, leavePrOpen = false, reviewers = DEFAULT_REVIEWERS, usernames = [], optionalReviewers = [], reviewerMaxRounds = {}, reviewerModels = {}, reviewerEfforts = {}, reviewStopMode = DEFAULT_REVIEW_STOP_MODE, reviewerApplies = false, forgeCli = 'gh', noChangeSuccess = false }) {
const policyLeavesOpen = prCompletion === PR_COMPLETIONS.LEAVE_OPEN;
const runsReviewLoop = prCompletion === PR_COMPLETIONS.REVIEW_THEN_MERGE;
if (hasSlashdo && worktreeInfo && willOpenPR) {
- const lines = ['## Completion', 'When finished, run these in order:'];
+ const lines = ['## Completion', ...(noChangeSuccess ? ['', NO_CHANGE_AUDIT_GUIDANCE, ''] : []), 'When finished, run these in order:'];
let step = 1;
if (simplifyEnabled) {
lines.push(`${step++}. \`/simplify\` — review the changed code for reuse, quality, and efficiency, and fix any findings.`);
@@ -724,7 +738,7 @@ export function buildCliCompletionSection({ worktreeInfo, willOpenPR, prCompleti
return lines.join('\n');
}
if (hasSlashdo && worktreeInfo) {
- const lines = ['## Completion', 'When finished, run these in order:'];
+ const lines = ['## Completion', ...(noChangeSuccess ? ['', NO_CHANGE_AUDIT_GUIDANCE, ''] : []), 'When finished, run these in order:'];
let step = 1;
if (simplifyEnabled) {
lines.push(`${step++}. \`/simplify\` — review the changed code for reuse, quality, and efficiency, and fix any findings.`);
@@ -739,7 +753,7 @@ export function buildCliCompletionSection({ worktreeInfo, willOpenPR, prCompleti
// `ownsPrWorkflow` already folds in `willOpenPR`, the worktree, and the
// leave-open exclusions (it is `inlinePrLifecycleSection() !== null`).
if (ownsPrWorkflow) {
- const lines = ['## Completion', '**You own this PR end to end — nothing else will open, review, or merge it.** When finished, run these in order:'];
+ const lines = ['## Completion', ...(noChangeSuccess ? ['', NO_CHANGE_AUDIT_GUIDANCE, ''] : []), '**You own this PR end to end — nothing else will open, review, or merge it.** When finished, run these in order:'];
let step = 1;
lines.push(simplifyEnabled
? `${step++}. Before committing, ${SIMPLIFY_INLINE_REVIEW} and fix any findings.`
@@ -767,5 +781,5 @@ export function buildCliCompletionSection({ worktreeInfo, willOpenPR, prCompleti
const simplifyLine = simplifyEnabled
? `Before committing, ${SIMPLIFY_INLINE_REVIEW} and fix any findings. `
: '';
- return `## Completion\n${simplifyLine}${body}`;
+ return `## Completion\n${noChangeSuccess ? `${NO_CHANGE_AUDIT_GUIDANCE} ` : ''}${simplifyLine}${body}`;
}