UI check on demand: "test this pull request"
An extension of
docs/specs/ui-verification.md. That spec describes the check that happens by itself, insideReviewing, before a PR is created, and takes its scenarios fromspec.md. This one describes the second way into the same machinery: the owner points at any pull request and asks for it to be checked, and the agent finds the criteria itself. Everything not mentioned here (the dev-server lease, the Playwright MCP flags, theui-testercontract, uploading screenshots) stays exactly as ADR-0014 has it.
1. Why
The check as built has one entrance: a task Jarvis itself drove to Reviewing. If a PR is already open — ours, someone else's, made by hand — there is no way to call the check on it. The owner asked directly: "can I say in a thread, test this pull request with Playwright?" Today the answer is no: start_dev_server is allowed in Reviewing only, and that stage is unreachable from PR Open/Fixing (TRANSITIONS in engine/src/domain/task.ts).
The second limit runs deeper than the first. Even with the stage fixed, the scenarios come from spec.md in the task's artifacts, and someone else's PR has no such file. So the tie to a single source of criteria has to go: take what there is — the diff, the PR body, the comments — and derive the scenarios from that.
2. Boundaries
Goals
- A new sentence in a thread: "check the UI of this PR", with a link or a number → the check runs and the verdict comes back in the chat.
- The criteria no longer require
spec.md. The source is whatever was found, and it is named in the report. - Someone else's PR, and a PR in another repository (within the existing allow-list, ADR-0012), work the same way.
Non-goals
- We do not fix what we find. A
ui_checktask never writes code and never opens a PR. Findings become a separate task, if the owner asks for one. - We do not change the existing pre-PR check. That path stays the default and stays untouched.
- We do not add a second browser driver. The owner's decision: what becomes agnostic is the source of the criteria, not the tool. Playwright MCP remains the only one (ADR-0014).
- We do not manage sessions or storage state.
ui-testerlogs in the way a person does — through the application's own form, with test credentials the worker found in the project and passed to it (2026-11-09). What we still do not do is persist a session between runs or carry a credential of the owner's: a scenario with no test account in the project staysskipped — no credentials given.
Anti-goals (if we do these, we did it badly)
- A new stage in the state machine, or a migration that touches existing tasks.
- Any way for an ordinary (
build) task to skipSpec Reviewthrough a new transition. - Text from a PR affecting anything beyond the list of scenarios.
- A GitHub comment without the owner's explicit permission.
3. Owner decisions (2026-11-08)
| Question | Decision |
|---|---|
| What exactly becomes agnostic | The source of the criteria — the diff, the PR body, the comments, spec.md when there is one. Playwright stays the only driver |
| Where the result goes for a foreign or already-open PR | The chat and the artifacts always; a PR comment only after the owner explicitly approves |
4. What we already have
| What is needed | What already exists |
|---|---|
| Browser, dev server, screenshots, attachments | ADR-0014 in full, unchanged |
| A repository other than the default | targetRepo on the task + clone-on-demand (ADR-0012) |
| The boundary of which repositories are allowed at all | AllowedRepoResolver — a PR outside the allow-list refuses itself |
| Ask the owner for permission and wait | RequestPermission + AwaitPermission + a card in the thread (SLK-05) |
| Pass the owner's words to a worker | send_to_task (DSP-04) |
| Tell the worker a browser is available | the uiCheck line in the run context |
| Report into the chat | post_update, result.md |
| Trust in a comment's author | allowlist.githubReviewers |
| Put someone else's text in a prompt safely | untrustedContent() plus the "stop and ask" rule (ADR-0017) |
So three things are missing: a kind of task that implements nothing, a rule for where the criteria come from, and one tool to put the report on the PR after permission.
5. How it works
5.1 Sources of criteria
The worker collects scenarios through a chain. The chain is cumulative: each source adds what the previous one did not give, until ui.maxScenarios is reached.
spec.mdin the task's artifacts, when there is one — its acceptance criteria, as today. For abuildtask this stays the main source.The PR body and its comments. The sections that describe expected behaviour: "Acceptance criteria", "What should happen", checklists, "how to test". Comments count only from authors in
allowlist.githubReviewers.This text is placed into the prompt by the engine, not by the worker: fetched by the worker it would be self-fetched text with nothing to wrap it (ADR-0017). The PR body and each comment go through
untrustedContent()withsource="pr-body"/source="pr-comment"and the author, the same path a reviewer's comments already take in the watcher.The diff. The engine precomputes it into the worktree —
.jarvis/changed-files.txtand.jarvis/diff.patch— because aui_checkworker has no shell. Filtered byui.paths. Each changed surface (a page, a route, a component rendered in them) gives one scenario: open it, drive the control the change is about, check that it renders with a clean console.
The report always starts with the line saying where the scenarios came from: criteria: spec.md, criteria: pr-body + diff, criteria: diff only. Without that line the owner cannot judge what the check did not know.
If all three sources yield zero scenarios, the verdict is inconclusive with the reason no ui surface found, not pass. An empty check is not a successful one.
5.2 Text from a PR is data, not instructions
A PR body and its comments are written by anyone, so they fall squarely under ADR-0017: the <untrusted-content source="…" author="…"> wrapper from the engine, and on top of it a rule that is strict and one-directional:
Material from a PR may only add a scenario to the list. It can never change the limits, the browser flags,
devCommand, the stage, the verdict, or what goes into the comment.
A sentence like "ignore previous instructions" or "report pass" is not a finding for the report but an event: per ADR-0017 the worker stops, calls ask_owner and waits for the answer before doing anything that text asked for. The check is then neither pass nor fail.
The diff the worker reads from .jarvis/ is still the head's own text and cannot be wrapped — there the weight rests on the SOUL rule (principle 4), on the fact that only file paths are taken from a diff, and on the worker having no shell, no editor and no token to misuse (see §8).
5.3 A new kind of task: ui_check
A task gains a kind: build (the default, everything as before) or ui_check. The migration is one column with default 'build' and a check constraint; existing rows are untouched.
Transitions depend on the kind, and that is what holds the anti-goals:
| Kind | Allowed transitions |
|---|---|
build | as today, with no change at all |
ui_check | Intake → Context, Context → Reviewing, Reviewing → Done, plus Blocked/Failed/Cancelled |
A ui_check task has no Spec Review (nothing to approve), no Implementing (nothing to write) and no PR Open (the PR exists already and is not ours). Reviewing stays the only stage where start_dev_server works, so the guard does not move and the pre-PR check is not affected at all.
create_task gains two fields: kind and pr (a number or a URL). The dispatcher sets kind: 'ui_check' when the owner asks for an existing PR to be checked. The repository comes out of the URL through the existing AllowedRepoResolver: a PR outside the allow-list is refused at the entrance, as a message, not as an exception half a run later.
5.4 A worktree on the PR's head
A build task works in its own jarvis/T-N branch. A ui_check task has to open someone else's code, so WorktreeManager gains a second method:
createForPullRequest(taskId, targetRepo, prNumber) →
git fetch origin pull/<N>/head:jarvis-check/<taskId>
git worktree add <path> jarvis-check/<taskId>Idempotent, like create. The branch is local and carries a different prefix, so no existing push rule (git push origin jarvis/*) can match it: the check pushes nothing.
5.5 Running someone else's code — a boundary we did not have
This is the most important paragraph of the spec. ui.devCommand executes code from that branch: postinstall, the build config, a plugin — all of it the PR author's code. For our own PR that is ordinary; for a PR from a stranger's fork it is the classic "pwn request" — arbitrary code execution on the owner's machine.
So a ui_check task starts the dev server unasked only when both hold:
- the PR's head lives in the same repository (not a fork), and
- the PR's author is in
allowlist.githubReviewers(the list of trusted people that already exists).
Otherwise the engine does not start the server; it raises a permission card through RequestPermission with the facts spelled out: the author, the fork, the command that would run. A deny or a timeout ends the task inconclusive with the reason untrusted head: owner did not approve. There is deliberately no setting that switches this question off.
5.6 Run context
Lines are added, so the worker never has to infer which role it is in:
## Run context
taskId: T-12
taskKind: ui_check
stage: Reviewing
pr: https://github.com/burnjohn/jarvis-sandbox/pull/41 — open — head burnjohn/jarvis-sandbox:feature by burnjohn
uiCheck: available
criteriaSources: pr-body, diffcriteriaSources is computed by the engine from what exists: spec.md in the artifacts, the PR body, the diff. The worker may narrow that list but never widen it.
5.7 The report
Always, whatever the verdict:
post_updateinto the thread: the verdict, thecriteria:line, the table of scenarios, blockers, console, network.result.mdin the artifacts — the same plus the screenshot paths.report_stage Done— the worker closes aui_checktask itself. It opens no pull request, so the watcher'sPR Open -> Donenever reaches it, andreport_stageacceptsDonefor this task kind (abuildtask asking for it is refused by the transition table).
A comment on the PR is separate and needs permission. A new worker tool:
comment_on_pr { body: string, commentId?: number }- refuses when the task has no PR;
- asks for permission through the existing
RequestPermission/AwaitPermission(a card in the thread, timing out afterlimits.permissionTimeoutMinutes); denyor a timeout →{ ok: false, reason }, and the worker leaves the text in the chat. This is not an error;ui.autoApproveComments(default false) skips the card entirely — the owner's own opt-out of being asked;allow→CodeHost.postComment(prNumber, body, repo?), or, withcommentId,CodeHost.editComment(commentId, body, repo?). There is no per-task count: the card is asked every time, so the owner is the limit.commentIdmust name a comment the same task posted — the ids come from the task's own journal — otherwise it is refused before any card is raised;Bash(gh pr comment:*),Bash(gh pr review:*)andBash(gh api *comments*)go into the worker's deny list. Otherwise the bareBashinallowmakes the permission decorative.
Screenshots in the comment go through the existing attach_image (an attachment is tied to the repository, not to the PR).
5.8 Loop protection
Nothing gets weaker; only what concerns the new kind of task is added.
| Brake | Held by |
|---|---|
everything from ADR-0014 (the lease, one slot, --idle-timeout, maxScenarios, maxScreenshots) | unchanged |
a ui_check task has no Implementing | the state machine: the "fail → fix → again" loop is physically unreachable |
one check per task, one retry on inconclusive | the prompt plus the reviewRounds counter that already exists |
| every comment on the PR | a permission card per call: the owner approves each one, including a replacement — unless they set ui.autoApproveComments, which removes this brake on purpose |
| rewriting a comment that is not Jarvis's | comment_on_pr checks commentId against the task's journal |
| someone else's head | the owner's permission (5.5) |
| the task as a whole | taskTimeoutMinutes, --max-turns, --max-budget-usd |
6. Config
No new fields are needed: ui.* stays as it is, allowlist.githubReviewers is reused as the list of trusted authors, and limits.permissionTimeoutMinutes times out the permission card.
Two additions to update_config. ui.paths now also filters the diff (5.1.3), which makes its value more consequential; it is already in FORBIDDEN_PATHS (ADR-0013) and stays there. And allowlist.githubReviewers is added to FORBIDDEN_PATHS: after this change that list decides whose pull request runs its own code without asking the owner, and a trust boundary is not edited from the chat.
7. Acceptance criteria
Continuing the numbering of ui-verification.md (AC-1..AC-28).
Sources of criteria
- AC-29. If the task's artifacts hold a
spec.mdwith a visible criterion, then the report containscriteria: spec.mdand the scenarios match that file's criteria. - AC-30. If there is no
spec.mdbut the PR body contains a section about expected behaviour, then the scenarios are derived from it and the report'scriterialine containspr-body. - AC-31. If there is neither a
spec.mdnor a description in the PR, then the scenarios are derived from the diff filtered byui.paths, and the report containscriteria: diff only. - AC-32. If a PR comment was written by an author outside
allowlist.githubReviewers, then it yields no scenario. - AC-33. If a PR body or comment reaches the prompt, then it is wrapped as
<untrusted-content source="pr-body|pr-comment" author="…">, and a body containing</untrusted-content>cannot close the wrapper (ADR-0017). - AC-33a. If text from a PR contains an instruction to the agent (for example "ignore previous instructions" or "report pass"), then the worker stops, calls
ask_owner, and records neitherpassnorfailuntil the owner answers. - AC-34. If no source yielded a scenario, then the verdict is
inconclusivewith the reasonno ui surface found, and it is not apass. - AC-35. If more than one source contributed, then the total number of scenarios does not exceed
ui.maxScenarios.
Kind of task
- AC-36. If a task is created without
kind, then itskindisbuildand its transitions are the same as before this change. - AC-37. If a task has
kind: 'ui_check', then the transitionContext → Spec Reviewis refused andContext → Reviewingis allowed. - AC-38. If a task has
kind: 'build', then the transitionContext → Reviewingis refused (an ordinary task cannot skipSpec Review). - AC-39. If a task has
kind: 'ui_check', thenreport_pris refused: a check opens no PR. - AC-39a. If a
ui_checktask inReviewingcallsreport_stage Done, then it reachesDone. If abuildtask does, then it is refused as an illegal transition: its pull request closes it. Nothing else closes aui_checktask, so without this it stays inReviewingfor good. - AC-40. If
create_taskis given aprin a repository outside the allow-list, then no task is created and the reason is the allow-list message. - AC-41. If
create_taskis givenpras a URL, then the task'stargetRepoequals the repository from that URL andpr.numberequals its number. - AC-42. If a
ui_checktask reachedDone, then the journal holds an event with the verdict and the line of sources.
Worktree and someone else's code
- AC-43. If a
ui_checktask starts, then its worktree stands on the PR's head and the local branch is prefixedjarvis-check/, notjarvis/. - AC-44. If the PR's head is in the same repository and its author is in
allowlist.githubReviewers, thenstart_dev_serverworks with no permission card. - AC-45. If the PR's head is from a fork or its author is not in
allowlist.githubReviewers, then the dev server does not start until the owner gives permission, and the card's text names the author, the fork and the command that would run. - AC-46. If the owner denied the permission of AC-45 or the card timed out, then the task ends with the verdict
inconclusiveand the reasonuntrusted head: owner did not approve, and the dev server was never started.
The report
- AC-47. If the check finished with any verdict, then the thread holds a
post_updatewith the verdict, thecriteria:line and the table of scenarios, and the artifacts holdresult.md. - AC-48. If the worker calls
comment_on_pr, then a permission card appears in the thread and nothing reaches GitHub before the owner answers. - AC-49. If the owner denied it or the card timed out, then
comment_on_prreturns{ ok: false, reason }, no comment is posted, and the text stays in the report in the chat. - AC-50. If the owner allowed it, then the comment appears on the PR. There is no per-task count: every
comment_on_prraises its own card, so the owner decides each time whether the PR needs another comment. - AC-50a. If
comment_on_pris given acommentId, then the body replaces that comment instead of adding one, and the card says which comment it replaces. Only a comment the same task posted can be replaced; any other id is refused without asking the owner. A verdict corrected after a failed check therefore reaches the reader in place, with no stale report above it. - AC-50b. If
ui.autoApproveCommentsis true, thencomment_on_prwrites without a card, and the journal entry carriesasked: false. The default is false. With it on, nothing in the engine limits what or how much a run writes on a pull request — the journal is the only record left. - AC-51. If the task has no PR, then
comment_on_prrefuses without asking the owner. - AC-52.
Bash(gh pr comment:*)andBash(gh pr review:*)are in the worker settings'denylist.
8. Edge cases
Checking a repository you do not control runs its code on your machine. The owner's approval card asks one question — may this head run? — and that is not the same as "is it safe to run". What the head gets once you say yes is described in "What the approval card does not cover" below. Read it before pointing a check at a pull request from someone you would not hand a shell to.
- The PR is already merged or closed. The head is still reachable (
pull/N/headremains) and the check technically runs. The worker states in the report that the PR ismerged/closed— it changes what the result is worth, and the owner has to see that. - The fork was deleted.
git fetch pull/N/headfails →inconclusive, reasonhead unavailable.
What the approval card does not cover
The untrusted-head card (5.5) decides whether the head's code may run at all. Once it runs, these hold, and none of them is a bug in the card — they are the shape of the thing today:
- The dev server's environment is narrowed, not empty.
ProcessDevServerhandsui.devCommandonly a short inherited list (PATH,HOME, locale) plus what the owner declared inui.env, with${NAME}as the deliberate pass-through — sonpm ciand the head'spostinstallscripts no longer seeGITHUB_TOKEN,DATABASE_URLorINFISICAL_*.ui.envitself is locked against chat edits, or a config patch could hand it all back. - The head's code still runs as the engine's own uid. Environment narrowing does not move the process: a
postinstallcan read~/.claude(the subscription login),~/.jarvis, the engine's/proc/<pid>/environ, and reach whatever the host's network reaches. This is the gap ADR-0019 closes by running a check's environment in a disposable container. CLAUDE.mdin the head is read as instructions. The worker's working directory is the task's worktree, and Claude Code reads a project'sCLAUDE.md,.claude/agents/and.claude/skills/from there by design. ADR-0017 wraps the PR's prose as<untrusted-content>; files in the tree are not wrapped and cannot be, because the agent reads them itself. The blast radius is bounded instead: aui_checkworker runs withBash,EditandNotebookEditdenied and noGH_TOKENin its environment (the engine fetches the head, precomputes the diff into.jarvis/, and posts the comment itself), so an injected instruction can at worst skew the report the owner reads anyway — it has no shell to run and no token to exfiltrate.- A
.claude/settings.jsonin the head cannot raise its own permissions, because projectallowrules wait for workspace trust and the task's worktree is never a trusted folder, and becausepermissions.defaultModeofautoorbypassPermissionsdoes not take effect from project settings at all. Itsdenyandaskrules do apply immediately, so a hostile head can make a check fail or stall — sabotage, not escalation. - The credentials are not on disk, and that part holds. The clone carries no token: a credential helper reads
GH_TOKEN/GITHUB_TOKENfrom the environment (SEC-04, ADR-0012), and the worktree's.gitis a pointer into the shared clone. Code that gets no environment gets no GitHub access.
Until the check's environment runs somewhere disposable (ADR-0019), treat a UI check on a repository you do not control as "running a stranger's build script under your own user", and prefer a token scoped to the one repository being checked.
- A huge diff (a 300-file refactor). The
ui.pathsfilter andmaxScenarioscut it down; the report says so explicitly — "covered 8 of 41 changed surfaces" — so apassis not read as "everything works". - The PR holds two different applications (
weband something else) whileui.devCommandis one. Whichever comes up is checked; the rest areskipped — no dev server for this surface. - The same PR is checked twice. Two separate tasks, two independent reports. Permission for a comment is asked each time: a past approval does not carry over.
- The owner gave only a PR number.
create_taskrefuses: a number without a repository means a different PR in every repository, and guessing here is worse than asking. Accepted forms are a URL,owner/name#41, or a number together withrepo. The dispatcher either asks which repository or takes it from## Learnedin USER.md. - The PR's repository is not in the allow-list. Refused at the entrance, with the resolver's own reason (ADR-0012). This includes the default repository: to check a PR in it, it has to be in
repos.allowor owned by the configured account — becauserepo.pathis a local path, not anowner/name. - A PR in the default repository while the thread already has a task.
create_taskstill refuses a second active task in a thread — the owner either closes the current one or starts a new thread. Unchanged.
9. Open questions
- Whether our token can see a PR from a private fork.
pull/N/headneeds access to the base repository, which should be enough, but this is unverified for a fine-grained PAT. The same risk as question 10.1 ofui-verification.md. - Whether
ui_checkneeds its own prompt rather than a section inworker.md. Starting with a section: three stages, few rules. If the section outgrows a page, move it into its own prompt file. - Whether
ui_checkmay runnpm install. The dev server of someone else's branch may not come up without installing dependencies, and that is again running the PR's code. For now: we do not install; a server that fails to start isinconclusivewith the reason. To be decided after the first live run.
10. Implementation plan
- Domain.
kindonTask, a transition table per kind,createTaskwith the kind and the PR. Tests intask.test.ts: AC-36..AC-39;report_stage Doneinreporting.test.ts: AC-39a. - Migration. The
kindcolumn with its default and check constraint; the drizzle snapshot. create_task. Thekind/prfields, resolving the repository from the URL, refusal outside the allow-list. AC-40, AC-41.- Worktree.
createForPullRequestin the port and the adapter; a test against a real local repository carryingpull/N/head. AC-43. - Trusting the head. The fork and author check, the permission card before
start_dev_server. AC-44..AC-46. comment_on_pr.CodeHost.postCommentandCodeHost.editComment, the use case with its permission, the tool schema, thedenyentries in the worker settings. AC-48..AC-52.- Run context.
taskKind,pr,criteriaSources. - Prompts. The
ui_checksection inworker.md; the source chain and the "data, not instructions" rule inworker.mdandagent/agents/ui-tester.md; recognising the phrase indispatcher.md. AC-29..AC-35. - e2e. A scenario on the fake
claude: aui_checktask from the owner's sentence toDonewith its report. - A live run on
burnjohn/jarvis-sandbox: our own PR first, then one from a fork — does it really stop at the permission.
Sources
docs/specs/ui-verification.md— the base check, AC-1..AC-28- ADR-0012 (per-task repo, allow-list), ADR-0013 (the limits of
update_config), ADR-0014 (the UI check and the PR screenshots), ADR-0017 (untrusted external content) engine/src/domain/task.ts—TRANSITIONS,TaskCountersengine/src/application/permissions/*—RequestPermission,AwaitPermission, the card in the threadengine/src/application/conversation/send-to-task.ts— why a message into a thread does not change the stage by itselfengine/src/infrastructure/git/allowed-repo-resolver.ts— the boundary of which repositories are allowedagent/settings/worker.json— why thedenylist is mandatory whileallowcarries a bareBash