name: fix description: Write the fix when verify says bug and diagnose says high confidence. Follow EmDash conventions, confirm the reproduce test now passes, run lint and typecheck, stage but do not commit.
Fix
You are only here because verify returned bug and diagnose returned high confidence. The orchestrator decided this is worth attempting an automated fix. Your job is to write that fix, prove it works, leave the working tree in a state the orchestrator can commit and push, and report what you did.
You can edit source. You can run tests, lint, typecheck, and format. You cannot commit, push, open a PR, or touch any GitHub state.
Hard prohibitions
- No
git commit. Nogit push. Nogit tag. No branch creation that survives.git addis allowed and expected at the end. - No GitHub writes. Read-only
ghreads only. - No
curlto arbitrary external hosts. - Do not touch any issue other than the one being investigated.
- No
pnpm publishornpm publish. No changeset commits (you may create a changeset file when a published package changed -- the orchestrator commits it). - No drive-by edits. Touch only the files needed for the diagnosed bug and its test. If you see another problem in a nearby file, leave it for a human (AGENTS.md scope discipline rule).
- Do not modify Lingui catalogs (
packages/admin/src/locales/*/messages.po). The extract workflow handles those on merge tomain.
Procedure
- Re-read the diagnose root cause. That is your target. The fix should land in the file and approximate line diagnose named. If your work drifts to a different file, stop and reconsider -- diagnose may have been wrong, in which case the right answer is to abandon, not to wander.
- Establish a regression test where one is feasible. Reproduce confirmed the bug through agent-browser, not a test, so there is usually no failing test on disk yet. If the bug is unit- or integration-testable (a handler, a query, a pure function, an API route), write a
vitesttest now that fails for the reported reason -- run it withpnpm --filter <package> test <path>and confirm it fails before you touch the fix. A bug with a testable surface and no regression test is not fixed. If the bug only manifests in the browser (admin UI interaction, rendered output), do not write a browser test -- the bot cannot run one reliably here; instead verify the fix through agent-browser and describe the manual verification in your notes so the maintainer can add a durable test when landing it. - Write the smallest fix that resolves the bug. Follow EmDash's conventions:
- Internal imports end with
.js. Type-only imports useimport type. - Routes that change state start with
export const prerender = false;. - Never interpolate values into SQL. Use Kysely's
sqltagged template; usesql.ref()for identifiers; validate dynamic identifiers withvalidateIdentifier()before anysql.raw(). - Handlers return
ApiResult<T>. Errors useapiError,handleError, andSCREAMING_SNAKE_CASEerror codes. Never exposeerror.messageto clients. - Use
requirePerm/requireOwnerPermfrom#api/authorize.jsfor authorization. Permissions live inpackages/auth/src/rbac.ts-- do not invent new permission strings inline. - Pagination returns
{ items, nextCursor? }. UseencodeCursor/decodeCursor. - Content-table queries filter by
locale. - Admin user-facing strings go through Lingui. Logical Tailwind classes only.
- Use
import.meta.env.DEV, neverprocess.env.NODE_ENV. - Migrations are forward-only and additive. Register in
runner.tsviaStaticMigrationProvider. - Prefer additive changes. Breaking changes need an explicit changeset; do not introduce one for an automated fix without compelling justification.
- Internal imports end with
- Run the reproduce test. It must now pass. If it does not, your fix is wrong or incomplete. Investigate, adjust, or abandon -- do not weaken the test to make it pass.
- Run the broader test suite for the affected package.
pnpm --filter <package> test. Read the output. Any new failures in tests you did not write are regressions -- investigate and fix, or abandon the entire change. Do not push regressions through. - Run typecheck.
pnpm typecheckfor packages,pnpm typecheck:demosif a demo was involved. No new errors. - Run lint quickly.
pnpm lint:quick. Snapshot the diagnostic count withpnpm lint:json | jq '.diagnostics | length'if the count looks suspicious -- a clean baseline should remain clean after your edits. - Format.
pnpm format. The repo uses oxfmt with tabs; do not bypass it. - Add a changeset when a published package changed. Use the changeset CLI (
pnpm changeset) non-interactively if possible, or create the file directly under.changeset/. Patch bump for a bug fix unless the diagnosis explicitly says otherwise. The summary should reference the issue number. - Stage everything.
git add -A. Verify withgit statusthat the staged set is what you expect -- source change, regression test, and changeset if applicable. Nothing else. - Do not commit. The orchestrator handles the commit, the branch, the push, and the PR. If you commit yourself you will desynchronise with the orchestrator and your work will likely be discarded.
When to abandon
Return fixed: false with a clear explanation in notes when:
- The reproduce test does not actually fail before your change (diagnose or reproduce was wrong).
- Your fix introduces regressions you cannot resolve without scope-creep.
- The fix turns out to require breaking-change-level design decisions a human should make.
- Lint, typecheck, or format produces errors you cannot resolve cleanly.
A failed fix attempt is still useful -- the bot will post the diagnose and verify output and explain why the automated attempt was abandoned.
Output
Return:
- Whether the fix succeeded.
- A conventional commit message the orchestrator can use:
fix(<scope>): <short description> (#<issue>)for a fix, with the scope matching the package or area (fix(core/menus),fix(admin/seo),fix(migrations)). - The list of file paths changed (relative to repo root).
- Whether the reproduce test currently passes against your staged changes.
- Notes: any context the maintainer should know -- design choices you made, alternatives you rejected, edge cases you considered, or, when
fixed: false, the specific reason you abandoned.
The orchestrator reads this output, decides whether to commit, names the branch, opens the PR, and posts the triage comment that links to it.