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
address review (codex): fail closed on absent CI, hand off protected PRs, pin model with provider
[._.]/ Adam Eivy4231c2cb417f
diff --git a/server/services/agentPromptBuilder.js b/server/services/agentPromptBuilder.jsindex 5d96d782b4..1cc6e64cc2 100644--- a/server/services/agentPromptBuilder.js+++ b/server/services/agentPromptBuilder.js@@ -621,7 +621,7 @@ function buildCiMergeGateSteps(startStep, { prRef, mrRef = '<MR_NUMBER>', forge? `\`gh pr view ${prRef} --json state -q .state\` must return \`MERGED\`${glab ? ' (GitLab: `glab mr view ' + mrRef + '` must show it merged)' : ''}`: `\`glab mr view ${mrRef}\` must show it merged`;const lines = [- `${startStep}. **Wait for CI to finish**: ${checksCmd}. "No checks reported" is AMBIGUOUS — a just-opened PR reports it while Actions is still attaching check runs, and merging on it races CI. Only treat it as green after you have confirmed the repo genuinely has no CI (${gh ? '`gh workflow list` is empty / no `.github/workflows` triggers on pull_request' : 'no `.gitlab-ci.yml` / no pipeline is configured'}); otherwise wait 30s and re-check, for up to 5 minutes, before concluding there is nothing to wait for.`,+ `${startStep}. **Wait for CI to finish**: ${checksCmd}. "No checks reported" is AMBIGUOUS — a just-opened PR reports it while checks are still attaching, and merging on it races the CI this gate exists to wait for. Treat it as green ONLY when the repo genuinely has no CI (${gh ? '`gh workflow list` is empty / nothing in `.github/workflows` triggers on pull_request, and no external status check is configured' : 'no `.gitlab-ci.yml` and no pipeline is configured'}). If CI IS expected, wait 30s and re-check for up to 5 minutes — and if it still hasn't attached, **leave the PR open and say so**; never merge on checks that were expected but never appeared.`,`${startStep + 1}. **Clear whatever blocks the merge, then re-check.** If a check failed, read the failing job's log (${gh ? `\`gh run view --log-failed\`${glab ? ' on GitHub, `glab ci trace` on GitLab' : ''}` : '`glab ci trace`'}), fix the cause here, run the project's tests, commit (\`fix:\` prefix, no Co-Authored-By), push, and go back to the previous step — cap this at 5 rounds. If ${mergeableCmd}, \`git fetch origin\`, rebase onto the base branch, resolve the conflicts keeping BOTH sides' intent, re-run the tests, \`git push --force-with-lease\`, and re-check.`,`${startStep + 2}. **Merge** with exactly these flags, nothing else — a true merge commit keeps the branch tip in the base branch's history so automated worktree cleanup can prove the branch is merged, and any merge-deferral flag leaves the PR open after you exit. If it is already merged (a saved \`/do:pr\` default can merge it for you), skip to the next step:`,' ```bash',@@ -632,7 +632,7 @@ function buildCiMergeGateSteps(startStep, { prRef, mrRef = '<MR_NUMBER>', forge// Not every repo allows merge commits; a repo restricted to squash/rebase// rejects `--merge` outright, which would leave the PR open forever.gh ? ` If that is rejected because this repo disallows merge commits, re-check what it allows (\`gh repo view --json mergeCommitAllowed,squashMergeAllowed,rebaseMergeAllowed\`) and merge with an allowed method instead — \`--squash\` first, else \`--rebase\` — keeping \`--delete-branch\`.` : null,- `${startStep + 3}. **Confirm the merge before exiting**: ${stateCmd}. If it is still open or was closed unmerged, investigate (failing check, merge conflict, branch protection), fix, and retry. Leave it open ONLY if CI stays red after a genuine fix attempt, or a conflict needs a human decision — and say so explicitly in your completion summary.`,+ `${startStep + 3}. **Confirm the merge before exiting**: ${stateCmd}. If it is still open or was closed unmerged, investigate (failing check, merge conflict, branch protection), fix, and retry. Leave it open — saying so explicitly in your completion summary — if CI stays red after a genuine fix attempt, a conflict needs a human decision, expected checks never attached, or a branch protection you cannot satisfy blocks the merge (a required approving review, a required check only a human can trigger). Hand those to a human rather than retrying until you time out.`,].filter(Boolean);return { lines, nextStep: startStep + 4 };}diff --git a/server/services/agentWorktreeCleanup.js b/server/services/agentWorktreeCleanup.jsindex edd2fc9fb1..97b7b34a1b 100644--- a/server/services/agentWorktreeCleanup.js+++ b/server/services/agentWorktreeCleanup.js@@ -314,11 +314,18 @@ export async function spawnReviewLoopFollowUp({ originalAgentId, originalTask, p// unpinned follow-up for lacking a harness — and the PR it was spawned to land// would sit open forever. Only copy what's actually pinned; an unpinned source// task still resolves through the normal active-provider path.+ //+ // The model pin rides ONLY with its provider: a bare `model` would be treated as+ // explicit against whatever provider resolution later picks, handing e.g. a+ // Claude model id to Codex. Effort is provider-agnostic, so it travels alone.const sourceMeta = originalTask?.metadata || {};+ const pinnedProvider = sourceMeta.provider || sourceMeta.providerId || null;const providerPins = {};- if (sourceMeta.provider) providerPins.provider = sourceMeta.provider;- if (sourceMeta.providerId) providerPins.providerId = sourceMeta.providerId;- if (sourceMeta.model) providerPins.model = sourceMeta.model;+ if (pinnedProvider) {+ providerPins.provider = pinnedProvider;+ providerPins.providerId = pinnedProvider;+ if (sourceMeta.model) providerPins.model = sourceMeta.model;+ }if (sourceMeta.effort) providerPins.effort = sourceMeta.effort;const appId = originalTask?.metadata?.app || null;diff --git a/server/services/cleanupAgentWorktree.test.js b/server/services/cleanupAgentWorktree.test.jsindex ded44865c4..58376e129f 100644--- a/server/services/cleanupAgentWorktree.test.js+++ b/server/services/cleanupAgentWorktree.test.js@@ -559,6 +559,25 @@ describe('cleanupAgentWorktree - openPR path', () => {expect(followUp.metadata.effort).toBe('high');});+ it('does not inherit a model pin without its provider', async () => {+ // A bare model would be honored against whatever provider resolution later+ // picks — handing e.g. a Claude model id to Codex and failing the run.+ git.push.mockResolvedValue(undefined);+ git.createPR.mockResolvedValue({ success: true, url: 'https://github.com/test/repo/pull/100' });+ addTask.mockResolvedValue({ id: 'sys-rl-q' });++ await cleanupAgentWorktree('agent-1', true, {+ openPR: true, requestCopilotReview: false, description: 'X',+ originalTask: { id: 'task-orig', metadata: { model: 'claude-opus-5', effort: 'high' }, description: 'X' }+ });++ const [followUp] = addTask.mock.calls[0];+ expect(followUp.metadata.model).toBeUndefined();+ expect(followUp.metadata.provider).toBeUndefined();+ // Effort is provider-agnostic, so it still travels.+ expect(followUp.metadata.effort).toBe('high');+ });+it('leaves a jira-sprint-manager PR open — no follow-up merges behind the board', async () => {// That task type transitions its ticket to "In Review" and hands the PR to a// human; merging here would land the work while JIRA still shows it in review,