Repository navigation
fix(github): make hosted review report like the Actions workflow, and add REVIEW_DEFAULTS - #305
Conversation
before copied the security-reviewer droid into ~/.factory/droids, but a droid run with FACTORY_ENV=development reads its droids from ~/.factory-dev/droids. On a Factory dev computer, the subagent the review prompt requires was then missing, and the session ended without a review. A caller whose droid keeps its user files elsewhere now passes that directory as SESSION_FACTORY_DIR; without it, the droids still go to ~/.factory/droids, so GitHub Actions is unchanged. Refs AUT-3073 Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
…ry fallback The hosted runner now takes the review droids' directory only from SESSION_FACTORY_DIR, so it hardcodes no Factory config path. before refuses to start without the variable and names it, as it does for GITHUB_ACTOR, and a failed droids copy names the directory it tried. Refs AUT-3073 Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
as_session_user clears the environment, so the security-engineer plugin install ran droid without FACTORY_ENV, and droid installed the plugin into its production directory, where a dev computer's session droid does not look. before now requires SESSION_FACTORY_ENV, the FACTORY_ENV the session's droid runs with, and keeps it for the plugin install. Refs AUT-3073 Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
…directory validate ran base-action in an allowlisted environment without FACTORY_ENV, so on a dev computer the validator's droid used its production directory, and setupDroidSettings wrote ~/.factory/droid/settings.json whichever directory the session droid reads. validate now requires SESSION_FACTORY_DIR and SESSION_FACTORY_ENV, as before does, and names a missing one for after to report. Its validator gets FACTORY_ENV=$SESSION_FACTORY_ENV and SESSION_FACTORY_DIR. setupDroidSettings takes the Factory config directory instead of a home directory, and base-action passes it SESSION_FACTORY_DIR, so the validator's settings land in the session droid's directory. The CI callers pass no directory and keep ~/.factory. Refs AUT-3073 Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
🟡 Changes recommendedValidation confirmed one regression: an empty optional session-directory value makes direct base-action runs attempt to write under /droid and fail on non-root runners. The other two candidates did not meet the evidence bar; all 66 existing focused tests passed, while the direct-entrypoint reproduction exited 1 as described. 🔒 Security review: no findings. 1 open finding · What changedHosted review preparation now requires the session's Factory directory and environment, copies review droids into that directory, and passes the session environment to plugin installation and validation. Base-action forwards the session directory to the settings helper, whose default remains ~/.factory.
Fix with an agentReply to a finding with a question, or comment |
setupDroidSettings wrote under /droid when its directory was an empty string, which base-action passes when a workflow sets SESSION_FACTORY_DIR to an empty value, as an unset input or variable does. An empty directory now means ~/.factory, like an unset one. Refs AUT-3073 Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
A failed review closed its Droid Review check as neutral. In Actions the failed job shows the failure next to it, but github/run-review.sh has no job, so a hosted failure looked like a review with nothing to say. run-review.sh now exports FACTORY_AUTOMATION=true for every part, not only for prepare, and reviewCheckConclusion concludes a failed run as failure when it is set. That covers finalize from the finish trap (before or after failing once the check is open) and a review that failed to post. A superseded or skipped run still concludes neutral, and validate's validator keeps its allowlisted environment without the variable. Actions never sets it, so CI keeps neutral. Refs AUT-3073 Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
When before failed, its reason went only to stderr and to the check, and prepare.ts opens no check when it fails early, as it does when an unlisted bot opened the PR. A caller that posts its own failed check then had no reason to show. fail() now also writes the message, as printed, to $RUNNER_TEMP/github-review/before-error, which only root writes and which outlives before. before makes that directory afresh, so a run that succeeds or exits 78 has no such file. Failures before fail() can run, such as a missing variable or installing bun, write none. Refs AUT-3073 Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
The Droid Review check's details_url and every "View job" link pointed at the Actions run page for GITHUB_RUN_ID, which does not exist when github/run-review.sh runs outside Actions. githubJobUrl() now returns REVIEW_JOB_URL when it is set, and the review lifecycle, the posted review's summary, the tracking comment's job link and update-comment-link build their links with it. run-review.sh passes its environment through to the entrypoints, so the caller sets the variable in before and after. Without it the links are unchanged. Refs AUT-3073 Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
When the org's model policy disallowed the configured review model, prepare dropped the model and output model_fallback_note, but no finished review showed it. In Actions only the publisher step had MODEL_FALLBACK_NOTE, and it hands a review to finishReviewLifecycle, which never rendered it; github/run-review.sh did not keep it at all. finishReviewLifecycle now reads MODEL_FALLBACK_NOTE and the summary shows it as a "> [!NOTE]" block, as the tracking comment does, in the clean, findings, failed and skipped states. The post step of action.yml, review/action.yml and security/action.yml gets the variable, with the publisher step's fallback order, since it finishes a review that posts. run-review.sh keeps MODEL_FALLBACK_NOTE from prepare's output for after and its finalize. Command replies are unchanged. Refs AUT-3073 Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
…gger c52bf57 (#287) deliberately reworded the skip reason for a disabled automatic trigger to the user-facing "automatic reviews of "labeled" events are turned off for this repository". This lifecycle test still expected the old "automatic trigger labeled is disabled". No code or other test asserts the old wording; the other uses of it in this file pass it in as an arbitrary skip reason. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
On github/run-review.sh only prepare's fallback note reached after. When the validator pass fell back on its own (its prompt step, or its droid retrying without --model), the note was lost, while action.yml's post and publisher steps take prepare's note, then the validator prompt's, then the validator's. validate now writes the first of the validator prompt's and the validator's notes to $RUNNER_TEMP/droid-prompts/github-review-model-fallback-note, also when the validator fails, and clears it first. after uses it, read as the session user, when prepare left no note, so posting and finalize see the same order as in Actions. validate runs as the session user and cannot write the root-owned state file, so the note goes where validate's error already does. Since that note can come from the session, the summary now escapes the note's text and keeps only its `code` spans as <code>, so it cannot add links or mentions to Droid's comment. Refs AUT-3073 Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
An org-wide install needs Factory to set review defaults, such as security_block_on_critical and security_block_on_high, that a repo's .factory/review.yaml can still override. resolveReviewUxConfig now reads REVIEW_DEFAULTS, JSON with review.yaml's keys, and layers it between the built-in defaults and the base-branch file, below nonempty action inputs. It goes through parseReviewConfigYaml, so every review.yaml key, alias and rule applies, and a malformed value fails the run as a malformed review.yaml does, with an error naming REVIEW_DEFAULTS. ReviewConfigError takes the source it names. The config is resolved once (prepare, generate-review-prompt), in steps that inherit the job's environment, and run-review.sh's before passes its environment to prepare; later steps read the resolved REVIEW_CONFIG_JSON. Nothing sets the variable yet. Refs AUT-3173 Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
When the caller stopped a hosted review session (its turn cap or the job's time limit), validate still ran the validator, which failed with "The review session did not write valid candidates", and the summary showed that instead of why the session stopped. In Actions the validator step does not run after a failed session step, and finalize gets the session step's error as DROID_ERROR_MESSAGE. The caller now sets SESSION_ERROR_MESSAGE in validate and after when a review's session failed. validate then skips the validator and exits 0, and after fails with it as DROID_ERROR_MESSAGE before looking at validate's result, so finalize closes the check and summary with it. When validate failed without writing its own error, after reports the caller's VALIDATE_ERROR_MESSAGE, after validate's error file and before the generic message. Commands are unchanged: Actions passes their publisher only DROID_SUCCESS, not the session's error. Refs AUT-3073 Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
after told github-post-command that a command's session succeeded whenever it left a result file, so a session the caller stopped (its turn cap or the job's time limit) could still have a partial result published. Actions passes DROID_SUCCESS from the session step's conclusion. after now passes DROID_SUCCESS=false when SESSION_ERROR_MESSAGE is set, and the publisher replies that Droid could not finish without publishing the result. Refs AUT-3073 Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
…el text The note can come from the hosted review's session, so the summary renders it with prose(), its escaping for model text, instead of a formatter of its own that kept `code` spans. Drops two test cases others already cover, and rewraps run-review.sh's notes for callers. Refs AUT-3073 Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
A finding thread counts as Droid's when its first comment's author is Factory's production App or the login in DROID_BOT_LOGIN. GitHub's GraphQL API names a bot without the "[bot]" its REST API adds, so a thread whose bot DROID_BOT_LOGIN names, as a hosted review on another Factory App does, never matched: @droid fix answered that there were no open findings, and a question in a finding's thread got the command list. A GraphQL Bot author now matches DROID_BOT_LOGIN with "[bot]" added; a user of the same name still does not. Refs AUT-3073 Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
A failed review's check listed only its steps when it had any, so a review that stopped partway showed which step failed but not why. The summary now adds the reason the failure comment gives after the steps. The rendered previews and the Failed check snapshot show it. Refs AUT-3073 Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
When droid exec rejects --model it prints "Invalid model:" and then every model the organization can use. runDroid looked for that line in the last 1,500 characters of stderr, so a long model list hid it: the review retried the same model three times and failed with the tail of the list as its error. runDroid now notes the line as each stderr line arrives, for both the tier alias swap and the fallback to the organization's default model. Refs AUT-3073 Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
A hosted run's before opens the review check before its session exists, so REVIEW_JOB_URL is the automation's page then, and the check kept that link: after had the session's page, but updateReviewCheck never set details_url. Each check update now sets it from REVIEW_JOB_URL, so the check opens the session once after updates it. Refs AUT-3073 Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Factory Code Review: Web · Desktop
What
Factory's automation runner runs
github/run-review.sh(before, the review session, validate, after) on a Factory computer instead of in GitHub Actions ("hosted review"). This PR makes hosted review report the way the Actions workflow does. It also adds a Factory-supplied defaults layer to the review config. Most changes touch onlygithub/run-review.sh, which GitHub Actions never runs. Items 5 to 10 change GitHub Actions too.Hosted review only
FACTORY_ENV(a673c3a, 81cc3d1, 95a1c8e, a31d575, f307fcb).github/run-review.shruns droids for the session's user outside the session. It sets up the review droids, including thesecurity-reviewersubagent the review prompt requires, installs the security-engineer plugin for@droid security --full, and runs the validator's droid in validate. Each used the droid's production directory. A droid withFACTORY_ENV=development, as on Factory's dev and preview computers, reads~/.factory-dev, so the subagent was missing and the session ended with "Required security-reviewer subagent is unavailable".beforeandvalidaterequireSESSION_FACTORY_DIRandSESSION_FACTORY_ENV, the session droid's Factory config directory andFACTORY_ENV, and name the one that is missing.copy_review_droids(lib/factory-run.sh) copies into$SESSION_FACTORY_DIR/droidsas the session user, with no~/.factoryfallback. The plugin is installed withFACTORY_ENV=$SESSION_FACTORY_ENV.FACTORY_ENV=$SESSION_FACTORY_ENV, andsetupDroidSettingswritesdroid/settings.jsonintoSESSION_FACTORY_DIR. Its other callers (GitLab, Bitbucket and Azure DevOps prepare, and base-action in GitHub Actions) pass no directory and keep~/.factory. An empty directory means~/.factory, as none does.failure(4c8e21f). In Actions, the failed job shows beside a neutral check. A hosted run has no job, so its check has to show the failure. This applies only withFACTORY_AUTOMATION=true, whichrun-review.shnow exports for every part instead of passing it to prepare alone.beforewrites why it failed to$RUNNER_TEMP/github-review/before-error(211c91a), unless it failed setting itself up. Factory's runner reads it for the failed check it posts.SESSION_ERROR_MESSAGE, set by the caller in validate and after, says why the session failed (9a4b284). validate then skips the validator, and after closes the review with that reason. For a@droidcommand, after tells the publisher the session failed, as Actions does (b2b23d5).VALIDATE_ERROR_MESSAGE, set in after, says why validate failed when it wrote no error of its own because it was killed or never started (9a4b284).REVIEW_JOB_URLwhen it is set (d072749), so hosted runs link to the Factory run page. Without it, links keep pointing at the Actions run.Also changes GitHub Actions
The org model-policy fallback note shows in the review summary (cb119e7, 2d0365f, 03ab6f8). When the org's model policy rejects the configured model, the summary carries the fallback note as a
[!NOTE]block in clean, findings, failed and skipped summaries. The threeaction.ymlfiles (action.yml,review/action.yml,security/action.yml) now passMODEL_FALLBACK_NOTEto the post-review step, so CI summaries show the note too. Hosted review takes prepare's note, or else validate's, which the session user writes. The note is escaped withprose(), like other model text in the summary, because on hosted runs it can come from the session.REVIEW_DEFAULTS(acd10d4): Factory-supplied review defaults, JSON with.factory/review.yaml's keys and rules. Precedence is built-in defaults, thenREVIEW_DEFAULTS, then the base-branch.factory/review.yaml, then nonempty action inputs. This is for AUT-3173's org-wide install. Nothing sets the variable yet, so behavior is unchanged until something does. A malformed value fails the run, with an error namingREVIEW_DEFAULTS.A bot named by
DROID_BOT_LOGINis recognized in review threads (2f236ac). droid-action trusts a finding thread when its first comment's author is Factory's production App, matched by id, or the botDROID_BOT_LOGINnames. GitHub's GraphQL API names a bot without the[bot]its REST API adds, solistDroidThreadsnever matched a bot named that way. On a hosted review through another Factory App (dev'sfactory-droid-dev),@droid fixanswered "No open Droid findings were found" and a question in a finding's thread got the command list. A GraphQLBotauthor now matchesDROID_BOT_LOGINwith[bot]added; a user of the same name still does not.A failed review's check keeps its reason after the steps (dcbf3ba). A failed review's check listed only its steps when it had any, so it showed which step failed but not why. The summary now adds the reason the failure comment gives (
friendlyReviewError) after the steps.docs/review-ux-preview.mdand the "Failed check" snapshot show it.A rejected model falls back even when the CLI's model list is long (4854230). When droid exec rejects
--model, it printsInvalid model:and then every model the organization can use. base-action looked for that line in the last 1,500 characters of stderr, so a long list hid it: the run retried the same model three times and failed with the end of the list as its error. This happened live on factory-mono#37912's preview with a model id that does not exist.runDroidnow notes the line as each stderr line arrives, for both the tier alias swap and the fallback to the organization's default model.The check's details link follows
REVIEW_JOB_URLat each update (0c34d07). A hosted run's before opens the check before its session exists, soREVIEW_JOB_URLis then the automation's page, and the check kept that link becauseupdateReviewChecknever setdetails_url. Each update now sets it, so the check opens the run's session once after updates it. In Actions the URL is the same run page at every update, so nothing changes there.Test only
devsince fix(review): explain disabled auto-trigger skips in plain English #287. test(review): expect the plain-English skip reason for disabled labeled triggers #301 (Mark) makes the identical one-line change. The two merge cleanly in either order (checked withgit merge-tree), so whichever merges second changes nothing on that line, and test(review): expect the plain-English skip reason for disabled labeled triggers #301 is not needed once this merges.Why
Factory's hosted code review (factory-mono#37912) runs this script on a Factory computer and follows droid-action's
mainbranch, as Factory-written CI workflows do. Hosted review reaches these changes once droid-action releasesdevtomain. Until then, a backend can pointAUTOMATION_DROID_ACTION_REFat this branch.Testing
bun test: 2,759 pass, 0 fail.bun run typecheck,bun run format:checkandshellcheck -x github/run-review.shpass.test/github/run-review.test.ts,test/github/review-lifecycle.test.ts,test/github/comments-common.test.ts,test/core/review/config.test.ts,test/review-posting-wiring.test.ts,test/core/review/ux-acceptance.test.ts,test/core/review/design.test.ts,base-action/test/run-droid-tier-alias.test.tsandbase-action/test/setup-droid-settings.test.ts. The tests cover:FACTORY_AUTOMATION=true;before-error,SESSION_ERROR_MESSAGEandVALIDATE_ERROR_MESSAGE;REVIEW_JOB_URLin the check, the summary and comments;action.ymlpasses it;REVIEW_DEFAULTSprecedence and its errors;Botauthor is the botDROID_BOT_LOGINnames is Droid's, and one by a user of that name is not.--modelwhose model list outgrows the stderr runDroid keeps still falls back to the organization's default model;REVIEW_JOB_URLchanges links the new URL.Refs AUT-3073, AUT-3173