Skip to content

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, inside Reviewing, before a PR is created, and takes its scenarios from spec.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, the ui-tester contract, 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_check task 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-tester logs 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 stays skipped — 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 skip Spec Review through 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) ​

QuestionDecision
What exactly becomes agnosticThe 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 PRThe chat and the artifacts always; a PR comment only after the owner explicitly approves

4. What we already have ​

What is neededWhat already exists
Browser, dev server, screenshots, attachmentsADR-0014 in full, unchanged
A repository other than the defaulttargetRepo on the task + clone-on-demand (ADR-0012)
The boundary of which repositories are allowed at allAllowedRepoResolver — a PR outside the allow-list refuses itself
Ask the owner for permission and waitRequestPermission + AwaitPermission + a card in the thread (SLK-05)
Pass the owner's words to a workersend_to_task (DSP-04)
Tell the worker a browser is availablethe uiCheck line in the run context
Report into the chatpost_update, result.md
Trust in a comment's authorallowlist.githubReviewers
Put someone else's text in a prompt safelyuntrustedContent() 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.

  1. spec.md in the task's artifacts, when there is one — its acceptance criteria, as today. For a build task this stays the main source.

  2. 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() with source="pr-body" / source="pr-comment" and the author, the same path a reviewer's comments already take in the watcher.

  3. The diff. The engine precomputes it into the worktree — .jarvis/changed-files.txt and .jarvis/diff.patch — because a ui_check worker has no shell. Filtered by ui.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:

KindAllowed transitions
buildas today, with no change at all
ui_checkIntake → 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, diff

criteriaSources 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:

  1. post_update into the thread: the verdict, the criteria: line, the table of scenarios, blockers, console, network.
  2. result.md in the artifacts — the same plus the screenshot paths.
  3. report_stage Done — the worker closes a ui_check task itself. It opens no pull request, so the watcher's PR Open -> Done never reaches it, and report_stage accepts Done for this task kind (a build task 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 after limits.permissionTimeoutMinutes);
  • deny or 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, with commentId, CodeHost.editComment(commentId, body, repo?). There is no per-task count: the card is asked every time, so the owner is the limit. commentId must 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:*) and Bash(gh api *comments*) go into the worker's deny list. Otherwise the bare Bash in allow makes 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.

BrakeHeld by
everything from ADR-0014 (the lease, one slot, --idle-timeout, maxScenarios, maxScreenshots)unchanged
a ui_check task has no Implementingthe state machine: the "fail → fix → again" loop is physically unreachable
one check per task, one retry on inconclusivethe prompt plus the reviewRounds counter that already exists
every comment on the PRa 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'scomment_on_pr checks commentId against the task's journal
someone else's headthe owner's permission (5.5)
the task as a wholetaskTimeoutMinutes, --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.md with a visible criterion, then the report contains criteria: spec.md and the scenarios match that file's criteria.
  • AC-30. If there is no spec.md but the PR body contains a section about expected behaviour, then the scenarios are derived from it and the report's criteria line contains pr-body.
  • AC-31. If there is neither a spec.md nor a description in the PR, then the scenarios are derived from the diff filtered by ui.paths, and the report contains criteria: 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 neither pass nor fail until the owner answers.
  • AC-34. If no source yielded a scenario, then the verdict is inconclusive with the reason no ui surface found, and it is not a pass.
  • 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 its kind is build and its transitions are the same as before this change.
  • AC-37. If a task has kind: 'ui_check', then the transition Context → Spec Review is refused and Context → Reviewing is allowed.
  • AC-38. If a task has kind: 'build', then the transition Context → Reviewing is refused (an ordinary task cannot skip Spec Review).
  • AC-39. If a task has kind: 'ui_check', then report_pr is refused: a check opens no PR.
  • AC-39a. If a ui_check task in Reviewing calls report_stage Done, then it reaches Done. If a build task does, then it is refused as an illegal transition: its pull request closes it. Nothing else closes a ui_check task, so without this it stays in Reviewing for good.
  • AC-40. If create_task is given a pr in a repository outside the allow-list, then no task is created and the reason is the allow-list message.
  • AC-41. If create_task is given pr as a URL, then the task's targetRepo equals the repository from that URL and pr.number equals its number.
  • AC-42. If a ui_check task reached Done, 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_check task starts, then its worktree stands on the PR's head and the local branch is prefixed jarvis-check/, not jarvis/.
  • AC-44. If the PR's head is in the same repository and its author is in allowlist.githubReviewers, then start_dev_server works 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 inconclusive and the reason untrusted 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_update with the verdict, the criteria: line and the table of scenarios, and the artifacts hold result.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_pr returns { 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_pr raises its own card, so the owner decides each time whether the PR needs another comment.
  • AC-50a. If comment_on_pr is given a commentId, 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.autoApproveComments is true, then comment_on_pr writes without a card, and the journal entry carries asked: 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_pr refuses without asking the owner.
  • AC-52. Bash(gh pr comment:*) and Bash(gh pr review:*) are in the worker settings' deny list.

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/head remains) and the check technically runs. The worker states in the report that the PR is merged/closed — it changes what the result is worth, and the owner has to see that.
  • The fork was deleted. git fetch pull/N/head fails → inconclusive, reason head 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. ProcessDevServer hands ui.devCommand only a short inherited list (PATH, HOME, locale) plus what the owner declared in ui.env, with ${NAME} as the deliberate pass-through — so npm ci and the head's postinstall scripts no longer see GITHUB_TOKEN, DATABASE_URL or INFISICAL_*. ui.env itself 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 postinstall can 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.md in the head is read as instructions. The worker's working directory is the task's worktree, and Claude Code reads a project's CLAUDE.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: a ui_check worker runs with Bash, Edit and NotebookEdit denied and no GH_TOKEN in 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.json in the head cannot raise its own permissions, because project allow rules wait for workspace trust and the task's worktree is never a trusted folder, and because permissions.defaultMode of auto or bypassPermissions does not take effect from project settings at all. Its deny and ask rules 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_TOKEN from the environment (SEC-04, ADR-0012), and the worktree's .git is 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.paths filter and maxScenarios cut it down; the report says so explicitly — "covered 8 of 41 changed surfaces" — so a pass is not read as "everything works".
  • The PR holds two different applications (web and something else) while ui.devCommand is one. Whichever comes up is checked; the rest are skipped — 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_task refuses: 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 with repo. The dispatcher either asks which repository or takes it from ## Learned in 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.allow or owned by the configured account — because repo.path is a local path, not an owner/name.
  • A PR in the default repository while the thread already has a task. create_task still refuses a second active task in a thread — the owner either closes the current one or starts a new thread. Unchanged.

9. Open questions ​

  1. Whether our token can see a PR from a private fork. pull/N/head needs 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 of ui-verification.md.
  2. Whether ui_check needs its own prompt rather than a section in worker.md. Starting with a section: three stages, few rules. If the section outgrows a page, move it into its own prompt file.
  3. Whether ui_check may run npm 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 is inconclusive with the reason. To be decided after the first live run.

10. Implementation plan ​

  1. Domain. kind on Task, a transition table per kind, createTask with the kind and the PR. Tests in task.test.ts: AC-36..AC-39; report_stage Done in reporting.test.ts: AC-39a.
  2. Migration. The kind column with its default and check constraint; the drizzle snapshot.
  3. create_task. The kind/pr fields, resolving the repository from the URL, refusal outside the allow-list. AC-40, AC-41.
  4. Worktree. createForPullRequest in the port and the adapter; a test against a real local repository carrying pull/N/head. AC-43.
  5. Trusting the head. The fork and author check, the permission card before start_dev_server. AC-44..AC-46.
  6. comment_on_pr. CodeHost.postComment and CodeHost.editComment, the use case with its permission, the tool schema, the deny entries in the worker settings. AC-48..AC-52.
  7. Run context. taskKind, pr, criteriaSources.
  8. Prompts. The ui_check section in worker.md; the source chain and the "data, not instructions" rule in worker.md and agent/agents/ui-tester.md; recognising the phrase in dispatcher.md. AC-29..AC-35.
  9. e2e. A scenario on the fake claude: a ui_check task from the owner's sentence to Done with its report.
  10. 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, TaskCounters
  • engine/src/application/permissions/* — RequestPermission, AwaitPermission, the card in the thread
  • engine/src/application/conversation/send-to-task.ts — why a message into a thread does not change the stage by itself
  • engine/src/infrastructure/git/allowed-repo-resolver.ts — the boundary of which repositories are allowed
  • agent/settings/worker.json — why the deny list is mandatory while allow carries a bare Bash