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
test: pin the cleanup helper's rejection guards and drop two duplicate prompt assertions
[._.]/ Adam Eivy0d3cbf01c097
diff --git a/server/services/agentPromptBuilder.test.js b/server/services/agentPromptBuilder.test.jsindex 8c6eb57b6a..03b64f218a 100644--- a/server/services/agentPromptBuilder.test.js+++ b/server/services/agentPromptBuilder.test.js@@ -112,7 +112,7 @@ vi.mock('./codeReview.js', () => ({}));import { buildLightContextPrompt, buildAgentPrompt, buildCompletionGuidelineBullet, reconcileSplitContext, buildReviewLoopFollowUpSection, getAppWorkspace, getAgentInstructionsContext, detectSkillTemplates, loadSkillTemplates, UI_AUDIT_RUNTIME_RULE, UI_AUDIT_TASK_TYPES, UNATTENDED_RUN_RULE } from './agentPromptBuilder.js';-import { portosMergesBranchOnExit } from './promptSections/completion.js';+import { getCodeReviewDefaults } from './codeReview.js'; // mocked above — control the configured defaultimport { isTruthyMeta } from './agentState.js';import { buildPrompt } from './promptService.js'; // mocked above — inspect call args@@ -994,8 +994,8 @@ describe('buildLightContextPrompt', () => {expect(prompt).not.toMatch(/^\s*\d+\.\s+`\/do:push/m);expect(prompt).not.toMatch(/`\/do:pr`/);expect(prompt).not.toMatch(/gh pr merge/);- // The sentinel still names the branch PortOS is about to merge.- expect(prompt).toMatch(/## Branch/);+ // The sentinel template keeps its branch slot — that is the branch PortOS merges.+ expect(prompt).toMatch(/## Branch\n\s+<branch name>/);});it('runs slashdo-free local reviewers before GitHub PR creation, then keeps PR-side review after it', () => {@@ -1696,7 +1696,6 @@ describe('buildLightContextPrompt', () => {expect(prompt).not.toMatch(/^\s*\d+\.\s+`\/do:push/m);expect(prompt).not.toMatch(/`\/do:pr`/);expect(prompt).not.toMatch(/gh pr merge/);- expect(prompt).not.toMatch(/git push/);});it('suppresses the PR completion workflow but still writes a sentinel when readOnly + TUI', () => {@@ -4072,16 +4071,10 @@ describe('planner attribution', () => {describe('auto-merge posture (worktree, no PR) is commit-only on every path', () => {// `portosMergesBranchOnExit` is the one decision the completion, hygiene and- // worktree sections all key on. Pinned as a table because a wrong answer here- // re-arms the `/do:push` that filed a recovery agent after every- // module-hygiene audit on 2026-09-06/07.- it('answers true only for a worktree run with no PR', () => {- const worktreeInfo = { branchName: 'b', worktreePath: '/tmp/wt' };- expect(portosMergesBranchOnExit({ worktreeInfo, willOpenPR: false })).toBe(true);- expect(portosMergesBranchOnExit({ worktreeInfo, willOpenPR: true })).toBe(false);- expect(portosMergesBranchOnExit({ worktreeInfo: null, willOpenPR: false })).toBe(false);- });-+ // worktree sections all key on. It is pinned through the rendered prompts+ // (here and in the TUI/CLI cases above) rather than as a truth table — a wrong+ // answer re-arms the `/do:push` that filed a recovery agent after every+ // module-hygiene audit on 2026-09-06/07, and the prompt is where that shows.it('api path: the simplify step, instructions and Git Hygiene all say commit only, never /do:push', async () => {const prompt = await buildAgentPrompt(makeTask({ metadata: { openPR: false, simplify: true } }),@@ -4113,11 +4106,5 @@ describe('auto-merge posture (worktree, no PR) is commit-only on every path', ()});expect(bullet).toMatch(/commit only — no push; PortOS merges your branch back after you exit/);expect(bullet).not.toMatch(/`\/do:push`/);- // The command form is untouched when one exists.- const withCommand = buildCompletionGuidelineBullet({- isReadOnly: false, isTui: true, tuiCompletionCommand: '/do:push',- worktreeInfo: null, willOpenPR: false,- });- expect(withCommand).toMatch(/`\/do:push`/);});});diff --git a/server/services/cleanupAgentWorktree.test.js b/server/services/cleanupAgentWorktree.test.jsindex ae7a0c35cc..b8ded5665b 100644--- a/server/services/cleanupAgentWorktree.test.js+++ b/server/services/cleanupAgentWorktree.test.js@@ -1,4 +1,4 @@-import { describe, it, expect, vi, beforeEach } from 'vitest';+import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';// --- Mock every dependency agentWorktreeCleanup.js pulls in transitively ---@@ -2129,8 +2129,13 @@ describe('cleanupAgentWorktree - remote copy of a locally merged branch', () =>beforeEach(() => {vi.clearAllMocks();+ // `clearAllMocks` drains calls, not once-queues — reset both mocks so a test+ // that stops early can never hand its leftover answers to the next one.+ execGitMock.mockReset().mockResolvedValue({ exitCode: 128, stdout: '', stderr: '' });+ git.isBranchMergedInto.mockReset().mockResolvedValue(false);getAgent.mockResolvedValue(mockWorktreeAgent());});+ afterEach(() => removeWorktree.mockResolvedValue(undefined));it('deletes origin\'s copy, lease-protected, when the pushed tip is already merged', async () => {mergedLocally();@@ -2169,13 +2174,27 @@ describe('cleanupAgentWorktree - remote copy of a locally merged branch', () =>expect(execGitMock).not.toHaveBeenCalled();});- it('a refused or failed delete is logged, not warned — the repo-state audit reports what is left', async () => {+ it('a refused delete is not a cleanup warning — the repo-state audit reports what is left', async () => {mergedLocally();execGitMock.mockResolvedValueOnce(tracking(SHA)).mockResolvedValueOnce({ exitCode: 1, stdout: '', stderr: ` ! [rejected] ${BRANCH} (stale info)` });git.isBranchMergedInto.mockResolvedValueOnce(true);const warnings = await cleanupAgentWorktree('agent-1', true, {});+ // The delete was attempted and refused — the silence is deliberate, not a skip.+ expect(execGitMock).toHaveBeenCalledTimes(2);+ expect(execGitMock.mock.calls[1][0][0]).toBe('push');expect(warnings).toEqual([]);});++ it('a git call that throws is swallowed — cleanup still returns its warnings and finishes', async () => {+ // Every await in the helper carries its own catch; drop one and a spawn+ // failure rejects the whole cleanup, losing its warnings and the follow-up.+ mergedLocally();+ execGitMock+ .mockResolvedValueOnce(tracking(SHA))+ .mockRejectedValueOnce(new Error('spawn git ENOENT'));+ git.isBranchMergedInto.mockResolvedValueOnce(true);+ await expect(cleanupAgentWorktree('agent-1', true, {})).resolves.toEqual([]);+ });});