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
quota-burn audit presets run in the app checkout instead of a worktree
[._.]/ Adam Eivye2b2b8d217a1
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 086fa39b0f..7f8f154693 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -48,4 +48,4 @@- **Switching manuscript formats no longer discards an unsaved section edit.** Sections save onBlur, but a format switch replaced the whole section list — and its baselines — so an edit that hadn't blurred (or whose save had failed) was dropped, and switching back refetched the server's older text. The switch now flushes pending saves first and aborts if one fails, leaving the text and its tab dot on screen. Saves are also queued per section, so the blur save and the switch's flush can't PATCH the same text twice and snapshot a redundant version. (#3399)- **"Continue Today's Routine" no longer dead-ends on the drill you just finished.** The handler navigated straight to the top recommendation's deep link with no check that it pointed somewhere else — and a sub-50% run makes the drill just missed the very item the scheduler resurfaces first, so Continue on Element Flash re-navigated to the URL already in the address bar and left the completion panel untouched. A self-referential recommendation now restarts the drill in place: a `run` nonce goes into the query string (preserving unrelated params like Morse's `?ref=`) and flows into the key of every surface the handler drives — Elements, Morse, Wordplay, and memory practice — so the drill remounts for a fresh run. Recommendations pointing elsewhere navigate exactly as before, and the comparison is path-only so a deep link carrying its own query string is still recognized as self-referential. (#3428)- **Quota-burn plan editor: nothing spends or destroys on one click any more.** The row's ▶ force-dispatched the job past the window/reserve/cap gates on a single click, sitting in a strip of small icons on a page that has no Save button — so it reads as "save" and got hit by accident. It now arms first, like the row's delete (and arming either disarms the other). Two more one-click losses went with it: the job-type picker no longer wipes `params`, so clicking through it can't silently destroy a long work prompt, and a preset asks before overwriting prompt text the user wrote. The page header now says "Changes save automatically" / "Saving changes…" — the missing feedback that sent people hunting for a save button in the first place. The step-name box also stopped using the job-type label ("Agent prompt") as its placeholder, which made it look like a second prompt field next to the real Work prompt, and a collapsed family card now shows its job count so "healthy window, no plan" is visible without expanding.-- **Quota-burn work prompts ship with presets.** A burn window is spent unattended, so a blank "what should this provider spend its remaining quota on?" textarea was the weakest part of the feature. Ten ready-made prompts (`server/lib/quotaBurnPresets.js`, served in the config catalog) each run ONE narrow audit — UX, accessibility, mobile, failure paths, performance, test gaps, dead code, data/upgrade safety, docs drift, security — the single-focus form of `/do:better --issues`: read real code in a bounded slice, de-dupe against open issues, file at most five decision-complete GitHub issues, change nothing. They set `openPR: false` / `simplify: false` (no diff to ship), `useWorktree: true` (an audit must not dirty the primary checkout), and `discardWorktree: true` — which is what makes the first two safe, since worktree-plus-no-PR otherwise *auto-merges* whatever the agent committed onto the managed app's default branch while the spawner is telling it to commit. `discardWorktree` is a new `agent-prompt` param (default `false`, so hand-written land-code jobs are unchanged) that removes the worktree without merging and flips the spawner's guidance to "do not commit, push, or open a PR"; it carries `worktreeChangesExpected: false` so a run that correctly changed nothing isn't judged a failure. The shared contract also requires scratch files go to `mktemp` (an untracked leftover makes the worktree undeletable, stranding one checkout per burn) and that secrets, hostnames, and personal records are redacted before anything is filed — an issue is world-readable the moment it exists. There is a `curl` fallback so a `gh` network failure doesn't end the window having filed nothing. Add one from a family card ("Add a preset job", inheriting the plan's app) or a job row ("Start from a preset"). Presets are templates — picking one copies the text into the job, so editing a preset never rewrites a configured job on any install.+- **Quota-burn work prompts ship with presets.** A burn window is spent unattended, so a blank "what should this provider spend its remaining quota on?" textarea was the weakest part of the feature. Ten ready-made prompts (`server/lib/quotaBurnPresets.js`, served in the config catalog) each run ONE narrow audit — UX, accessibility, mobile, failure paths, performance, test gaps, dead code, data/upgrade safety, docs drift, security — the single-focus form of `/do:better --issues`: read real code in a bounded slice, de-dupe against open issues, file at most five decision-complete GitHub issues, change nothing. They run in the app's own checkout with no worktree at all — they read code and file issues, so there is nothing to isolate, and `useWorktree: true` + `openPR: false` is in fact the *auto-merge* posture (the agent's branch is merged onto the managed app's default branch on success, unreviewed), meaning "isolating an audit for safety" would hand it a way to land code. Instead `agent-prompt` gains two distinct never-lands-code params (both default `false`, so jobs meant to land code are unchanged): `noCodeOutput` — the deliverable is what the agent DOES during the run, used by the presets — and `discardWorktree`, for a job that does want a scratch checkout (to build or test) whose contents must never land. Either one forces `openPR`/`simplify` off (an `openPR` that can never produce a PR makes the spawner report `pr-missing` and *retry*, burning up to five agent runs per window) and marks a clean tree as success. `noCodeOutput` also strips every commit/push/PR instruction from the prompt — including the Git Hygiene arm that told a no-worktree task to `/do:push` **to the branch it is standing on**, which for a task in the app's live checkout is its default branch; that arm also covered the Creative Director agents, which run in the same shape. The shared contract also requires scratch files go to `mktemp`, that the run leave the tree and branch exactly as it found them (it is the user's working copy), and that secrets, hostnames, and personal records are redacted before anything is filed — an issue is world-readable the moment it exists. There is a `curl` fallback so a `gh` network failure doesn't end the window having filed nothing. Add one from a family card ("Add a preset job", inheriting the plan's app) or a job row ("Start from a preset"). Presets are templates — picking one copies the text into the job, so editing a preset never rewrites a configured job on any install.diff --git a/client/src/pages/QuotaBurn.test.jsx b/client/src/pages/QuotaBurn.test.jsxindex 5aa573afbf..8d4eff99fc 100644--- a/client/src/pages/QuotaBurn.test.jsx+++ b/client/src/pages/QuotaBurn.test.jsx@@ -55,7 +55,9 @@ const catalog = {label: 'UX issues',summary: 'Audit the UI and file issues.',jobType: 'agent-prompt',- params: { prompt: 'Audit the UI. File issues. Change no code.', useWorktree: true, openPR: false, simplify: false, discardWorktree: true },+ // Mirrors the real audit posture in server/lib/quotaBurnPresets.js: no+ // worktree (it writes nothing), no code output, nothing to ship.+ params: { prompt: 'Audit the UI. File issues. Change no code.', useWorktree: false, noCodeOutput: true, openPR: false, simplify: false },}],apps: [{ id: 'a1', name: 'App One' }],universes: [{ id: 'u1', name: 'Example Universe' }],@@ -125,11 +127,12 @@ describe('QuotaBurn page', () => {expect(added.jobType).toBe('agent-prompt');expect(added.label).toBe('UX issues');expect(added.params.prompt).toContain('File issues');- // Read-only audit work: no PR to open, no diff for /simplify to clean, and- // the worktree discarded so a stray commit can't auto-merge onto the managed- // app's default branch.+ // Read-only audit work: it reads the app's checkout in place (no worktree —+ // worktree + no PR is the auto-merge posture), delivers by filing issues,+ // and has no diff to open a PR for or run /simplify against.+ expect(added.params.useWorktree).toBe(false);+ expect(added.params.noCodeOutput).toBe(true);expect(added.params.openPR).toBe(false);- expect(added.params.discardWorktree).toBe(true);});it('asks before a preset overwrites a work prompt the user already wrote', async () => {diff --git a/docs/QUOTA-BURN.md b/docs/QUOTA-BURN.mdindex 7e4ab7ac69..6cfaadb9aa 100644--- a/docs/QUOTA-BURN.md+++ b/docs/QUOTA-BURN.md@@ -77,20 +77,38 @@ Presets are **templates**: picking one COPIES its prompt into the job's own`params.prompt`, and nothing on disk points back at the preset id. So editing thetext here never rewrites a configured job on any install (no migration needed) —and an improved prompt reaches an existing job only when the user re-picks it.-They set `openPR: false` / `simplify: false` (there is no diff to ship),-`useWorktree: true` (an audit must not dirty the primary checkout), and-`discardWorktree: true` — which is what makes the first two safe. `useWorktree`-with `openPR: false` is the **auto-merge** posture: `agentWorktreeCleanup.js`-merges the agent branch onto the source workspace's default branch on success,-and the spawner's own guidance tells a worktree agent to commit and push. So an-audit that decided one dead export was trivially removable would land that commit-on a managed app's `main`, unreviewed, at 3am. `discardWorktree` removes the-worktree without merging and swaps the spawner's guidance to "do not commit,-push, or open a PR" — enforcing the preset's instruction by isolation rather than-by trusting the prose. It also carries `worktreeChangesExpected: false`, so a run-that correctly changed nothing isn't failed by the idle-complete gate. The flag is-a normal `agent-prompt` param, so a hand-written job can opt into the same posture-(it defaults to `false`, preserving the land-code behavior).+### The "lands no code" postures++An `agent-prompt` job has two of them, and they are not the same thing:++| Param | Means | Use when |+| --- | --- | --- |+| `noCodeOutput` | The deliverable is what the agent **does during the run** — files an issue, calls an endpoint. It needs no branch and no isolation because it writes nothing, so it runs in the app's own checkout on whatever branch that is. | The audit presets |+| `discardWorktree` | The job **does** want a scratch checkout (it builds, runs tests, edits to reason) but nothing in it may land: the worktree is removed without merging. | A job that must run a build/test cycle |++Either one forces `openPR`/`simplify` off in the runner (both presuppose a diff+to ship, and an `openPR: true` that can never produce a PR makes the spawner+report `pr-missing` and **retry**, burning up to five agent runs per window) and+sets `worktreeChangesExpected: false`, so a run that correctly changed nothing+isn't failed by the idle-complete gate. Both default to `false`, so a job meant+to land code is unaffected.++The audit presets take the **first** posture: `useWorktree: false` ++`noCodeOutput: true` + `openPR: false` + `simplify: false`. Isolating a+read-only audit would be worse, not better — `useWorktree: true` with+`openPR: false` is the **auto-merge** posture (`agentWorktreeCleanup.js` merges+the agent branch onto the source workspace's default branch on success), so+"isolating for safety" hands the audit a way to land code. Writing nothing is+the stronger guarantee, and `noCodeOutput` strips every commit/push/PR+instruction from the prompt — including the Git Hygiene arm that would otherwise+tell a **no-worktree** task to `/do:push` to the branch it is standing on, which+for a task in the app's live checkout is its default branch. (That arm also+covered the Creative Director agents, which run in the same shape.)++The tradeoff: an audit runs in the user's working copy, so its prompt is+explicit that it must leave the tree and the branch exactly as it found them.+A job that genuinely needs to build or test should tick `discardWorktree`+instead.Every numeric bound (windows, reserve, caps, entry limits) lives in`QUOTA_BURN_BOUNDS` in `server/lib/quotaBurnConfig.js`, read by the normalizerdiff --git a/server/lib/quotaBurnConfig.js b/server/lib/quotaBurnConfig.jsindex acd8fec46e..53ac899425 100644--- a/server/lib/quotaBurnConfig.js+++ b/server/lib/quotaBurnConfig.js@@ -82,11 +82,20 @@ export const QUOTA_BURN_JOB_CATALOG = Object.freeze([{ key: 'useWorktree', kind: 'boolean', label: 'Run in a worktree', default: true },{ key: 'openPR', kind: 'boolean', label: 'Open a PR', default: true },{ key: 'simplify', kind: 'boolean', label: 'Run /simplify', default: true },- // Worktree + no PR means AUTO-MERGE onto the source workspace's default- // branch (agentWorktreeCleanup.js). That is the right posture for a burn- // that is supposed to land code, and the wrong one for a job whose- // deliverable is filed issues — so the audit presets turn this on and the- // agent is told, by the spawner itself, not to commit at all.+ // The two "this job does not land code" postures, which are NOT the same:+ //+ // `noCodeOutput` — the deliverable is something the agent DOES during the+ // run (files an issue, calls an endpoint). It needs no branch and no+ // isolation because it writes nothing, so it runs in the app's checkout+ // as-is; the prompt drops every commit/push/PR instruction.+ // `discardWorktree` — the job DOES want a scratch checkout (it builds, it+ // runs tests, it edits to reason) but nothing it produces may land.+ // Without it, worktree + no PR means AUTO-MERGE onto the source+ // workspace's default branch (agentWorktreeCleanup.js).+ //+ // Either one forces `openPR`/`simplify` off in the job runner — both+ // presuppose a diff to ship.+ { key: 'noCodeOutput', kind: 'boolean', label: 'No code output (files issues / calls an API)', default: false },{ key: 'discardWorktree', kind: 'boolean', label: 'Discard the worktree (nothing lands)', default: false },]),},diff --git a/server/lib/quotaBurnPresets.js b/server/lib/quotaBurnPresets.jsindex f45c1eb831..205baf4e9d 100644--- a/server/lib/quotaBurnPresets.js+++ b/server/lib/quotaBurnPresets.js@@ -23,26 +23,30 @@ import { QUOTA_BURN_JOB_TYPE } from './quotaBurnConfig.js';/** Params every audit preset sets, and why they differ from the job defaults. */const AUDIT_PARAMS = Object.freeze({- // Read-only work still gets an isolated checkout: an audit that wanders into- // an edit must not dirty (or switch the branch of) the primary working copy- // the user has open.- useWorktree: true,- // No code changes means no PR and nothing for /simplify to clean up. Leaving- // these on makes the agent hunt for a diff to ship and end the window- // confused.+ // These jobs READ code and file issues — they never write a file, so there is+ // nothing to isolate. Running in the app's own checkout, on whatever branch it+ // is already on, is the honest shape: no branch is created, nothing is+ // merged, and no worktree is left to clean up.+ //+ // This is deliberately NOT the worktree posture. `useWorktree` + `openPR:+ // false` is the AUTO-MERGE posture — on success the agent's branch is merged+ // onto the source workspace's default branch with no PR and no review — so+ // isolating an audit "for safety" actually buys it a way to land code.+ // Isolation would only earn its keep for an audit that had to build or run+ // tests; those can still opt in via the job's `discardWorktree` checkbox.+ useWorktree: false,+ // The deliverable is what the agent DOES during the run (`gh issue create`),+ // not a commit and not the completion sentinel. This is what strips every+ // commit/push/PR instruction out of the prompt — including the one that would+ // otherwise tell a no-worktree task to `/do:push` to the branch it is+ // standing on, which here is the app's default branch.+ noCodeOutput: true,+ // Both presuppose a diff to ship. Leaving them on sends the agent hunting for+ // one at the end of a window where there is none. (The job runner forces them+ // off for a no-code job anyway — belt and braces, since a hand-edited plan+ // reaches the runner without passing through this file.)openPR: false,simplify: false,- // The one that makes the two above SAFE. `useWorktree` + `openPR: false` is- // not "read-only" — it is the auto-merge posture: on success the worktree- // branch is merged straight onto the source workspace's default branch, with- // no PR and no review. Meanwhile the spawner's own instructions tell a- // worktree agent to commit and push. So an audit that decided one dead export- // was trivially removable would land that commit on a managed app's `main` at- // 3am. `discardWorktree` removes the worktree WITHOUT merging and swaps the- // spawner's guidance to "do not commit, push, or open a PR" — enforcing the- // preset's own instruction by isolation instead of by hoping the model obeys- // the prose.- discardWorktree: true,});/**@@ -69,8 +73,10 @@ const auditContract = ({ labels, dedupeSearch }) => `4. **File each surviving finding as its own issue.** Write the body to a scratchfile OUTSIDE the repository — \`BODY=$(mktemp)\` — then\`gh issue create --title "..." --body-file "$BODY" --label ...\`. Keep scratch- files out of the working tree — a run that ends dirty is indistinguishable- from one that edited code it was told not to touch. Suggested labels:+ files out of the working tree: you are running in the repository's OWN+ checkout, on the branch it is currently on — not a throwaway copy — so+ anything you leave behind is left in the user's working tree. Suggested+ labels:${labels}. Run \`gh label list\` first and use only labels that exist. Oneproblem per issue — never a bundle.5. **Bodies must be decision-complete**, in this shape:@@ -92,8 +98,11 @@ const auditContract = ({ labels, dedupeSearch }) => `Report it in your final summary to the user, say it needs rotating, and fileat most a location-free issue ("a committed credential needs rotating andpurging from history — details in the run summary").-8. **Change no code.** No commits, no branches, no pull requests. The deliverable- is the filed issues, and the run should end with a clean \`git status\`.+8. **Change no code.** No edits, no commits, no branches, no pull requests, and+ no \`git checkout\`/\`switch\` — you are standing in the user's live checkout of+ this repository, so an edit or a branch change is felt immediately by whoever+ is working in it. The deliverable is the filed issues, and the run must end+ with the same \`git status\` and the same branch it started on.9. **Report at the end**: the slice you audited, each issue number and title, andanything you deliberately did not file and why.diff --git a/server/lib/quotaBurnPresets.test.js b/server/lib/quotaBurnPresets.test.jsindex d300bd41f1..4ce7835c33 100644--- a/server/lib/quotaBurnPresets.test.js+++ b/server/lib/quotaBurnPresets.test.js@@ -48,19 +48,22 @@ describe('QUOTA_BURN_PROMPT_PRESETS', () => {expect(() => quotaBurnConfigUpdateSchema.parse(body)).not.toThrow();});- it('configures audit presets as read-only work that cannot land code', () => {- // These prompts file issues and change nothing. Leaving openPR/simplify on- // sends the agent hunting for a diff to ship at the end of a window where- // there is none — and `useWorktree` + `openPR: false` WITHOUT- // `discardWorktree` is the auto-merge posture: whatever the agent committed- // goes straight onto the managed app's default branch, unreviewed, while the- // spawner's own guidance is telling it to commit. `discardWorktree` is what- // makes the other two safe, so assert them together.+ it('configures audit presets to read the app checkout in place and land nothing', () => {+ // These prompts read code and file issues — they write no file, so they need+ // no branch and no isolation. Asserted together because the combination is+ // the safety property, not any one flag: `useWorktree: true` ++ // `openPR: false` is the AUTO-MERGE posture (the agent's branch is merged+ // onto the app's default branch on success, unreviewed), so "isolating an+ // audit for safety" would actually hand it a way to land code.+ // `noCodeOutput` is what strips every commit/push/PR instruction from the+ // prompt — including the one that would otherwise tell a no-worktree task to+ // `/do:push` to the branch it is standing on.for (const preset of QUOTA_BURN_PROMPT_PRESETS) {+ expect(preset.params.useWorktree).toBe(false);+ expect(preset.params.noCodeOutput).toBe(true);expect(preset.params.openPR).toBe(false);expect(preset.params.simplify).toBe(false);- expect(preset.params.useWorktree).toBe(true);- expect(preset.params.discardWorktree).toBe(true);+ expect(preset.params.discardWorktree).toBeUndefined();}});@@ -74,7 +77,10 @@ describe('QUOTA_BURN_PROMPT_PRESETS', () => {// An untracked scratch file makes the run's worktree undeletable, so the// burn strands one full checkout per window.expect(prompt).toMatch(/mktemp/);- expect(prompt).toMatch(/clean `git status`/);+ // It runs in the user's live checkout, so "leave the tree as you found it"+ // is about their working copy, not a throwaway one.+ expect(prompt).toMatch(/live checkout/);+ expect(prompt).toMatch(/same branch it started on/);}});diff --git a/server/services/agentPromptBuilder.js b/server/services/agentPromptBuilder.jsindex dd75e4a59f..41d6114656 100644--- a/server/services/agentPromptBuilder.js+++ b/server/services/agentPromptBuilder.js@@ -1493,7 +1493,9 @@ ${skillSection ? `## Task-Type Skill Guidelines\n\n${skillSection}\n` : ''}${too1. Analyze the task requirements carefully2. Make necessary changes to complete the task3. Test your changes when possible-4. ${discardWorktree+4. ${noCodeOutput+ ? 'Deliver your result the way the task describes (the API call or command it names) — do NOT commit, push, or open a PR; this task changes no code'+ : discardWorktree? 'Write your result to the completion sentinel (see the Completion section above) — do NOT commit, push, or open a PR; this worktree is discarded on exit': isReviewLoopFollowUp? 'Follow the follow-up section above — push any fixes you make to the PR branch; a run that needed no fix makes no commit and that is a success, not a miss'@@ -1526,7 +1528,9 @@ ${(() => {- **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.-${discardWorktree+${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? `- **Do NOT commit, push, or open a PR.** This worktree is discarded on exit — your only output is the completion sentinel (see the Completion section above).`: 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.`@@ -1537,7 +1541,7 @@ ${discardWorktree: worktreeInfo && willOpenPR? `- **Commit only — do NOT push.** Stage specific files, use \`feat:\`/\`fix:\`/\`breaking:\` prefix in the commit message, no Co-Authored-By annotations. The system will push your branch and open the PR after you exit, so do NOT run \`git push\` or \`/do:push\` yourself.`: `- **Commit and push using \`/do:push\`** — this handles changelog updates, staging specific files, writing a conventional commit message, and pushing safely. If \`/do:push\` is unavailable, follow its conventions manually: stage specific files, use \`feat:\`/\`fix:\`/\`breaking:\` prefix, no Co-Authored-By annotations, and push with \`git pull --rebase && git push\`.`}-${discardWorktree ? '' : worktreeInfo ? `- **Your PR should contain only your task's commits.** If you see unrelated commits in your branch history, something is wrong — do not open a PR with other agents' work.` : `- **Commit directly to the current branch.** Do NOT create feature branches or PRs unless explicitly instructed.`}+${discardWorktree || noCodeOutput ? '' : worktreeInfo ? `- **Your PR should contain only your task's commits.** If you see unrelated commits in your branch history, something is wrong — do not open a PR with other agents' work.` : `- **Commit directly to the current branch.** Do NOT create feature branches or PRs unless explicitly instructed.`}## Working Directory${task.metadata?.app ? `You are working in the target app directory: \`${workspaceDir}\`. All code changes, research, plans, and docs for this task belong in this directory — NOT in the PortOS repo.` : 'You are working in the project directory.'} Use the available tools to explore, modify, and test code.diff --git a/server/services/agentPromptBuilder.test.js b/server/services/agentPromptBuilder.test.jsindex ae6d983293..0f420ff4d0 100644--- a/server/services/agentPromptBuilder.test.js+++ b/server/services/agentPromptBuilder.test.js@@ -1659,6 +1659,21 @@ describe('discardWorktree (reasoning-only) completion contract', () => {const prompt = await buildAgentPrompt(auditTask(), {}, '/r', wt, isTruthyMeta, { providerType: 'api' });assertActionOutput(prompt);});++ it('a no-code task with NO worktree is never told to commit to the branch it is on', async () => {+ // The dangerous shape: no worktree means the agent stands in the app's own+ // checkout, on its default branch. Git Hygiene's fallback arm ("Commit and+ // push using `/do:push`" + "Commit directly to the current branch") would+ // aim a push straight at that branch — and for a task that changes no code,+ // whatever it swept up would be the user's own uncommitted work.+ const task = makeTask({ metadata: { noCodeOutput: true, useWorktree: false, openPR: false } });+ const prompt = await buildAgentPrompt(task, {}, '/r', null, isTruthyMeta, { providerType: 'api' });+ expect(prompt).toMatch(/## Completion \(No Code Output\)/);+ expect(prompt).toMatch(/Do NOT commit, push, or open a PR/);+ expect(prompt).not.toMatch(/Commit and push using/);+ expect(prompt).not.toMatch(/Commit directly to the current branch/);+ expect(prompt).not.toMatch(/Commit and push your changes/);+ });});it('full (api) path suppresses the commit/push instructions in Instructions + Git Hygiene', async () => {diff --git a/server/services/quotaBurnJobs/agentPrompt.js b/server/services/quotaBurnJobs/agentPrompt.jsindex 9cbaa8b9df..f585fe9266 100644--- a/server/services/quotaBurnJobs/agentPrompt.js+++ b/server/services/quotaBurnJobs/agentPrompt.js@@ -79,6 +79,13 @@ export async function run({ params, job, family, candidate, context } = {}) {const { app, prompt, provider } = resolved;const label = job?.label?.trim() || 'quota-burn work';+ // The two "lands no code" postures. `noCodeOutput` = the deliverable is an+ // action performed during the run (a filed issue, an endpoint call), so the+ // job needs no branch at all. `discardWorktree` = the job wants a scratch+ // checkout but nothing in it may land. Either one means there is no diff to+ // ship, which is what the coercions below rest on.+ const discardsWorktree = params?.discardWorktree === true;+ const landsNoCode = params?.noCodeOutput === true || discardsWorktree;const task = await addTask({description: `[Quota burn: ${family.id}] ${label} for ${app.name}`,app: app.id,@@ -86,27 +93,29 @@ export async function run({ params, job, family, candidate, context } = {}) {provider: provider.id,model: job?.model || undefined,useWorktree: params?.useWorktree !== false,- // A discarding job can never produce a PR — the worktree is thrown away- // before anything is pushed. Leaving `openPR: true` on it (the param's- // default, one checkbox away) makes the spawner expect a PR that cannot- // exist: the run is downgraded to `pr-missing` and RETRIED, burning up to- // five agent runs of subscription quota per misconfigured job. Coerced here- // rather than only in the UI so a hand-edited plan can't reach that state.- openPR: params?.discardWorktree !== true && params?.openPR !== false,- simplify: params?.discardWorktree !== true && params?.simplify !== false,- // Opt-in throwaway posture for jobs whose deliverable is NOT code (the audit- // presets). Without it, `useWorktree + !openPR` auto-merges whatever the- // agent happened to commit onto the managed app's default branch, unreviewed- // — and a run that correctly changed nothing is judged a failure by the- // idle-complete gate, which expects a dirty tree.- discardWorktree: params?.discardWorktree === true,- worktreeChangesExpected: params?.discardWorktree !== true,- // Where the deliverable goes. A discarding burn job's output is whatever it- // did during the run (files an issue, calls an endpoint) — never a commit- // and never the completion sentinel, which is only the done-signal. Without- // this the prompt tells it "write your result to the sentinel", and an audit- // dutifully writes its findings into a file that is then thrown away.- noCodeOutput: params?.discardWorktree === true,+ // A job that lands no code can never produce a PR. Leaving `openPR: true`+ // on it (the param's default, one checkbox away) makes the spawner expect a+ // PR that cannot exist: the run is downgraded to `pr-missing` and RETRIED,+ // burning up to five agent runs of subscription quota per misconfigured job.+ // `/simplify` reviews changed code ahead of a commit that never happens.+ // Coerced here rather than only in the UI so a hand-edited plan can't reach+ // that state.+ openPR: !landsNoCode && params?.openPR !== false,+ simplify: !landsNoCode && params?.simplify !== false,+ // Scratch-checkout posture. Without it, `useWorktree + !openPR` auto-merges+ // whatever the agent happened to commit onto the managed app's default+ // branch, unreviewed.+ discardWorktree: discardsWorktree,+ // Where the deliverable goes: the action the agent takes DURING the run, not+ // a commit and not the completion sentinel (which is only the done-signal).+ // Without this the prompt tells it "write your result to the sentinel" — so+ // an audit writes its findings into a file instead of filing anything — and,+ // on a no-worktree job, tells it to `/do:push` to the branch it is standing+ // on, which is the app's default branch.+ noCodeOutput: landsNoCode,+ // A run that correctly changed nothing must not be failed by the+ // idle-complete gate, which otherwise requires a dirty tree.+ worktreeChangesExpected: !landsNoCode,reviewLoop: false,}, 'internal');diff --git a/server/services/quotaBurnJobs/agentPrompt.test.js b/server/services/quotaBurnJobs/agentPrompt.test.jsindex f6698398be..1b3f116236 100644--- a/server/services/quotaBurnJobs/agentPrompt.test.js+++ b/server/services/quotaBurnJobs/agentPrompt.test.js@@ -89,6 +89,18 @@ describe('run', () => {expect(state.added[1].task).toMatchObject({ discardWorktree: true, worktreeChangesExpected: false });});+ it('runs a no-code job in the app checkout with every commit path stripped', async () => {+ // The audit-preset posture: no worktree (it writes nothing, so there is+ // nothing to isolate — and worktree + no PR is the auto-merge posture), and+ // `noCodeOutput` so the prompt neither routes the deliverable to the+ // sentinel nor tells a no-worktree task to push to the branch it is on.+ await run({ params: { appId: 'app-1', prompt: 'x', useWorktree: false, noCodeOutput: true }, job: { id: 'j4' }, family, candidate });+ expect(state.added[0].task).toMatchObject({+ useWorktree: false, noCodeOutput: true, discardWorktree: false,+ openPR: false, simplify: false, worktreeChangesExpected: false,+ });+ });+it('forces off the flags a discarded worktree makes impossible', async () => {// `openPR` defaults to true and sits one checkbox from `discardWorktree`.// The combination makes the spawner expect a PR that cannot exist (the