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

address review (claude): stop audit presets from auto-merging into a managed app

[._.]/ Adam Eivy38384609aa04
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 85f0121365..086fa39b0f 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) and `useWorktree: true` (an audit must not dirty the primary checkout), and include 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 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.
diff --git a/client/src/components/quotaBurn/JobRow.jsx b/client/src/components/quotaBurn/JobRow.jsx
index e8ccef12a9..6e7ee10017 100644
--- a/client/src/components/quotaBurn/JobRow.jsx
+++ b/client/src/components/quotaBurn/JobRow.jsx
@@ -6,7 +6,7 @@
* work — so the move controls are part of the configuration, not a convenience.
*/
-import { useState } from 'react';
+import { useEffect, useState } from 'react';
import { ArrowDown, ArrowUp, Play, Trash2 } from 'lucide-react';
import ConfirmButtonPair from '../ui/ConfirmButtonPair';
import InlineConfirmRow from '../ui/InlineConfirmRow';
@@ -33,6 +33,12 @@ export default function JobRow({
// when there is already prompt text, so picking one never silently discards a
// prompt the user wrote by hand.
const [pendingPreset, setPendingPreset] = useState(null);
+ // Disarm the run confirm the moment the page has unsaved (or stalled) edits.
+ // The confirm asks "spend now?" about the SAVED plan, so an edit invalidates
+ // the question — and the alternative (leaving the pair on screen with both
+ // buttons disabled, since `busy` disables Cancel too) strands an armed
+ // confirm the user cannot dismiss when a save has stopped retrying.
+ useEffect(() => { if (actionsBusy) setRunArmed(false); }, [actionsBusy]);
const spec = catalog.jobTypes.find((type) => type.id === job.jobType);
const idPrefix = `burn-job-${job.id}`;
const setParam = (key, value) => onChange({ ...job, params: { ...job.params, [key]: value } });
@@ -73,7 +79,6 @@ export default function JobRow({
confirmIcon={Play}
cancelText="Cancel"
tone="warning"
- busy={actionsBusy}
ariaLabel={`Confirm running step ${index + 1} now`}
onConfirm={() => { setRunArmed(false); onRun(job); }}
onCancel={() => setRunArmed(false)}
@@ -127,7 +132,11 @@ export default function JobRow({
id={`${idPrefix}-preset`}
label="Start from a preset (optional)"
presets={catalog.presets}
- jobType={job.jobType}
+ // Deliberately NOT filtered to this row's current job type. Filtering
+ // hid the control entirely on a non-agent row, so converting an
+ // existing step into an audit meant deleting and re-adding it — and
+ // the conversion is safe: params carry across the type switch and
+ // existing prompt text is confirmed before it is replaced.
hint="Fills the work prompt below with a ready-made single-focus audit that files issues and changes no code."
onPick={(preset) => (hasPromptText ? setPendingPreset(preset) : applyPreset(preset))}
/>
diff --git a/client/src/pages/QuotaBurn.test.jsx b/client/src/pages/QuotaBurn.test.jsx
index 0df2b3fd50..5aa573afbf 100644
--- a/client/src/pages/QuotaBurn.test.jsx
+++ b/client/src/pages/QuotaBurn.test.jsx
@@ -55,7 +55,7 @@ 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 },
+ params: { prompt: 'Audit the UI. File issues. Change no code.', useWorktree: true, openPR: false, simplify: false, discardWorktree: true },
}],
apps: [{ id: 'a1', name: 'App One' }],
universes: [{ id: 'u1', name: 'Example Universe' }],
@@ -125,8 +125,11 @@ 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 and no diff for /simplify to clean.
+ // 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.
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.md
index 7ed5e78b47..7e4ab7ac69 100644
--- a/docs/QUOTA-BURN.md
+++ b/docs/QUOTA-BURN.md
@@ -77,8 +77,20 @@ 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 the
text 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) and
-`useWorktree: true` (an audit must not dirty the primary checkout).
+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).
Every numeric bound (windows, reserve, caps, entry limits) lives in
`QUOTA_BURN_BOUNDS` in `server/lib/quotaBurnConfig.js`, read by the normalizer
diff --git a/server/lib/quotaBurnConfig.js b/server/lib/quotaBurnConfig.js
index 5952c4f9ea..acd8fec46e 100644
--- a/server/lib/quotaBurnConfig.js
+++ b/server/lib/quotaBurnConfig.js
@@ -82,6 +82,12 @@ 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.
+ { key: 'discardWorktree', kind: 'boolean', label: 'Discard the worktree (nothing lands)', default: false },
]),
},
{
diff --git a/server/lib/quotaBurnPresets.js b/server/lib/quotaBurnPresets.js
index 2c4d9cf27c..3e30634d79 100644
--- a/server/lib/quotaBurnPresets.js
+++ b/server/lib/quotaBurnPresets.js
@@ -32,6 +32,17 @@ const AUDIT_PARAMS = Object.freeze({
// confused.
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,
});
/**
@@ -55,10 +66,13 @@ const auditContract = ({ labels, dedupeSearch }) => `
\`gh issue list --state open --limit 200 --search "${dedupeSearch}"\` (and a
plain keyword search per finding). If it is already filed, skip it; comment on
the existing issue only when you have genuinely new evidence.
-4. **File each surviving finding as its own issue.** Use
- \`gh issue create --title "..." --body-file <file> --label ...\`. Suggested
- labels: ${labels}. Run \`gh label list\` first and use only labels that exist.
- One problem per issue — never a bundle.
+4. **File each surviving finding as its own issue.** Write the body to a scratch
+ file OUTSIDE the repository — \`BODY=$(mktemp)\` — then
+ \`gh issue create --title "..." --body-file "$BODY" --label ...\`. Never write
+ scratch files into the working tree: an untracked leftover makes the run's
+ worktree undeletable, so one is stranded on disk per burn. Suggested labels:
+ ${labels}. Run \`gh label list\` first and use only labels that exist. One
+ problem per issue — never a bundle.
5. **Bodies must be decision-complete**, in this shape:
- **Problem** — what is wrong, with file:line references.
- **Impact** — the user-visible consequence, not the code smell.
@@ -69,16 +83,23 @@ const auditContract = ({ labels, dedupeSearch }) => `
6. **Cap yourself at 5 issues.** A handful of well-evidenced, ready-to-work
issues is worth more than a wall of nits, and a long tail of low-value issues
costs a human real triage time. Fewer than 5 real problems? File fewer.
-7. **Change no code.** No commits, no branches, no pull requests. The deliverable
- is the filed issues.
-8. **Report at the end**: the slice you audited, each issue number and title, and
+7. **Redact before you publish.** An issue is world-readable the moment it is
+ filed. Never paste a secret, credential, token, hostname, IP address, absolute
+ path containing a username, or any personal record into a title or body — cite
+ the location and redact the value (\`<token>\`, \`<hostname>\`, \`<user-email>\`).
+ This applies even when the value IS the finding: "\`config/dev.js:42\` commits a
+ live API key" is the report; the key itself never appears.
+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\`.
+9. **Report at the end**: the slice you audited, each issue number and title, and
anything you deliberately did not file and why.
If \`gh\` cannot reach the network (errors like "bad file descriptor" or a
connect timeout), do not give up silently — fall back to the REST API with the
token from the local keyring:
-\`TOK=$(command gh auth token)\` then
-\`curl -sS -H "Authorization: Bearer $TOK" -H "Accept: application/vnd.github+json" -d @body.json https://api.github.com/repos/<owner>/<repo>/issues\`.
+\`TOK=$(command gh auth token)\` then, with the payload in a \`mktemp\` file outside
+the repo,
+\`curl -sS -H "Authorization: Bearer $TOK" -H "Accept: application/vnd.github+json" -d @"$PAYLOAD" https://api.github.com/repos/<owner>/<repo>/issues\`.
A window spent finding real problems and filing none is a wasted window.
Read this repository's \`CLAUDE.md\` (and any nested per-directory ones covering
diff --git a/server/lib/quotaBurnPresets.test.js b/server/lib/quotaBurnPresets.test.js
index 2435654f64..d300bd41f1 100644
--- a/server/lib/quotaBurnPresets.test.js
+++ b/server/lib/quotaBurnPresets.test.js
@@ -48,14 +48,33 @@ describe('QUOTA_BURN_PROMPT_PRESETS', () => {
expect(() => quotaBurnConfigUpdateSchema.parse(body)).not.toThrow();
});
- it('configures audit presets as read-only work', () => {
+ 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.
+ // 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.
for (const preset of QUOTA_BURN_PROMPT_PRESETS) {
expect(preset.params.openPR).toBe(false);
expect(preset.params.simplify).toBe(false);
expect(preset.params.useWorktree).toBe(true);
+ expect(preset.params.discardWorktree).toBe(true);
+ }
+ });
+
+ it('tells the agent to keep secrets and scratch files out of what it publishes', () => {
+ for (const preset of QUOTA_BURN_PROMPT_PRESETS) {
+ const prompt = preset.params.prompt;
+ // An issue is world-readable the moment it is filed, and "quote the
+ // evidence" plus "find committed secrets" is exactly how one gets
+ // republished to a public repo by an unattended agent.
+ expect(prompt).toMatch(/Redact before you publish/);
+ // 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`/);
}
});
diff --git a/server/services/cosTaskStore.js b/server/services/cosTaskStore.js
index 6db7f5343b..afd9640641 100644
--- a/server/services/cosTaskStore.js
+++ b/server/services/cosTaskStore.js
@@ -290,6 +290,16 @@ export async function addTask(taskData, taskType = 'user', { raw = false, ignore
}
if (taskData.simplify === true) metadata.simplify = true;
else if (taskData.simplify === false) metadata.simplify = false;
+ // Throwaway-worktree posture. Only the raw path could set this before, so a
+ // non-raw caller that wanted "reason/report, never land code" had no way to
+ // ask for it and silently got the auto-merge default instead. `false` is not
+ // persisted — absent already means "normal posture", and writing it would
+ // stamp the key onto every task that never opted in.
+ if (taskData.discardWorktree === true) metadata.discardWorktree = true;
+ // Whether a clean tree at the end is success (issue-filing, reasoning) or a
+ // failure (code work). Both booleans are meaningful, so persist either.
+ if (taskData.worktreeChangesExpected === true) metadata.worktreeChangesExpected = true;
+ else if (taskData.worktreeChangesExpected === false) metadata.worktreeChangesExpected = false;
if (taskData.reviewLoop === true) metadata.reviewLoop = true;
else if (taskData.reviewLoop === false) metadata.reviewLoop = false;
// Ordered multi-reviewer list (normalizes legacy single `reviewer` too).
diff --git a/server/services/quotaBurnJobs/agentPrompt.js b/server/services/quotaBurnJobs/agentPrompt.js
index 3cc6a38273..2708a69caa 100644
--- a/server/services/quotaBurnJobs/agentPrompt.js
+++ b/server/services/quotaBurnJobs/agentPrompt.js
@@ -88,6 +88,13 @@ export async function run({ params, job, family, candidate, context } = {}) {
useWorktree: params?.useWorktree !== false,
openPR: params?.openPR !== false,
simplify: 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,
reviewLoop: false,
}, 'internal');
diff --git a/server/services/quotaBurnJobs/agentPrompt.test.js b/server/services/quotaBurnJobs/agentPrompt.test.js
index f53462bfea..e32ab43f2e 100644
--- a/server/services/quotaBurnJobs/agentPrompt.test.js
+++ b/server/services/quotaBurnJobs/agentPrompt.test.js
@@ -74,6 +74,20 @@ describe('run', () => {
await run({ params: { appId: 'app-1', prompt: 'x', useWorktree: false, openPR: false, simplify: false }, job: { id: 'j1' }, family, candidate });
expect(state.added[0].task).toMatchObject({ useWorktree: false, openPR: false, simplify: false });
});
+
+ it('keeps the auto-merge posture unless the job explicitly discards its worktree', async () => {
+ // `useWorktree` + `openPR: false` merges the agent's branch onto the source
+ // workspace's default branch. That is intended for a burn meant to land
+ // code, so the default must not change — but a job that opts into
+ // `discardWorktree` must get it, or an audit's stray commit lands unreviewed.
+ await run({ params: { appId: 'app-1', prompt: 'x' }, job: { id: 'j1' }, family, candidate });
+ expect(state.added[0].task).toMatchObject({ discardWorktree: false, worktreeChangesExpected: true });
+
+ await run({ params: { appId: 'app-1', prompt: 'x', discardWorktree: true }, job: { id: 'j2' }, family, candidate });
+ // A run that correctly changed nothing must also not be judged a failure by
+ // the idle-complete gate, which otherwise requires a dirty tree.
+ expect(state.added[1].task).toMatchObject({ discardWorktree: true, worktreeChangesExpected: false });
+ });
});
describe('renderBurnPrompt', () => {