Skip to content

feat(relay): one-command director deploy driver - #25642

Merged
Jinwoo-H merged 8 commits into
mainfrom
relay-director-deploy-driver
Oct 5, 2026
Merged

Jinwoo-H merged 8 commits into
mainfrom
relay-director-deploy-driver

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1036 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1036
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1404 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1403

ELI5

Deploying the relay "director" (the service that decides which relay server each desktop connects to) takes several hand-run GitHub workflows in a fixed order, with values copied between them by hand. This adds one script that runs them in that order, copies the values itself, and stops safely if anything goes wrong.

What Changed

Before: an operator dispatched, in order: pause regional rehoming, publish the image, deploy the director, optionally add new cells to the director's config, run the 15-minute safety monitor, then re-enable rehoming. Each step needed values from the earlier ones. On 2026-10-05 the re-enable was given the old director digest; it failed and cost about 16 minutes.

After: from cloud/, on a machine logged in to gh and gcloud, run node dev/scripts/drive-relay-director-deploy.mjs --commit <reviewed main SHA> [--configure <cells>=<cell digest>].

  1. Preflight. It reads state without changing anything:
    • no relay workflow is queued or running, across every page;
    • main is still the reviewed commit;
    • the serving director's digest and configured cells, from gcloud;
    • the cell admission state, from a read-only admission inspect;
    • the rehoming switch, from a read-only rehome inspect.
  2. Publish, after the operator types DEPLOY <commit prefix>. This happens before rehoming is touched. The image digest comes from the registry and must match the push line in the publish run's log.
  3. Pause rehoming, only if it is on, after the operator types PAUSE_REGIONAL_REHOMING.
  4. Deploy the director with that digest.
  5. Configure cells (optional). First a 5-minute soak on director 5xx errors, then the operator types CONFIGURE_ASIA_DIRECTOR.
  6. Digest check. A read-only check that the digests serving now are the ones the re-enable will use.
  7. Monitor. The operator types ENABLE_REGIONAL_REHOMING. The prompt says this arms an automatic re-enable, sent about 17 minutes later, and only on a green monitor whose evidence is at most 150 s old.
  8. Re-enable rehoming.

The driver never fills in a workflow's confirmation phrase.

How a failure or interruption is handled:

  • The driver keeps no state between runs. Each run reads live state and skips what is already done: a matching serving digest, cells already configured.
  • On any failure, Ctrl-C, SIGTERM or SIGHUP it prints:
    • REHOME IS CHANGING, when a pause or enable run is still in flight;
    • PAUSE UNCONFIRMED or ENABLE UNCONFIRMED, when such a run printed nothing usable;
    • REHOME IS PAUSED by this driver, naming the run that paused it;
    • the director re-read, the published digest, and the command that rolls the deploy back.
  • It ends with one command that finishes the deploy from wherever it stopped.

Why the re-run can trust a pause. The only rehoming fact the driver ever claims is "this pause is mine". It proves that by naming the run that made it (--pause-run). That run must be a rehome-control run by the same GitHub user. The driver then checks the run's log, and checks that the live generation hasn't moved since. A failed enable run is never counted as an enable. A pause it cannot prove is never lifted. That covers a director safety pause and another operator's pause. A fresh run that finds rehoming paused stops unless given --pause-run or --leave-rehome-paused.

Why

This is item 2 of the step-1 decision: every planned director deploy should take about 35 minutes and never fail on a mistyped digest.

The driver only dispatches the existing workflows; it changes none of them. They are the audited "evidence code", and their checks stay authoritative.

Why there is no automatic resume. Earlier versions kept a state file and resumed from it. Three review rounds found bugs in which that saved state and the real rehoming switch disagreed after a crash. Live state plus one provable ownership fact has nothing that can drift, so this version dropped the state file and its machinery:

  • --resume and the state file;
  • step statuses;
  • adopting a monitor or an interrupted dispatch on resume.

The trade-off is that a re-run repeats the read-only checks and runs a fresh monitor. Neither is ever safe to reuse anyway.

Linked Issue

N/A (internal ops tooling; tracked in the relay redesign decision doc, step 1 item 2).

Visual Proof

N/A: an operator CLI with no UI.

Testing

  • node --test dev/scripts/drive-relay-director-deploy.test.mjs: 27 tests against a model of the workflows that keeps their side effects. A pause applies before its run can fail, and a failed enable runs its own recovery. Each recovery test runs the exact command the stop report printed. Covered:
    • F1: an interrupt during the pause or the enable reports REHOME IS CHANGING, and the printed command finishes.
    • F2: a fresh run never adopts a paused switch, and a moved main is caught before any pause.
    • F3: a director safety pause found by the enable's recovery is never adopted or lifted, even when the original pause run is named.
    • F5: a tripped soak passes on fresh traffic when re-run.
    • P1: a green enable whose log could not be read is reported ENABLE UNCONFIRMED, then settled.
    • P8 / G1: re-running after DONE only re-reads state and asks nothing. Dropping --pause-run never hides the driver's pause.
    • Round 3:
      • G2: someone else's pause run, or a non-rehome run, is refused.
      • G3: a failed enable run is never reported RE-ENABLED.
      • C1: a pause whose run can't be viewed, or that printed no URL, still reports REHOME IS CHANGING.
      • C2: --leave-rehome-paused refuses an enabled switch.
      • G4: an interrupted enable prints both finishing commands.
      • G5: the driver's own still-listed run doesn't block it.
      • Every command the driver prints is checked against its own parser.
    • Also: the ops-log 05:41Z failed enable, an enable whose own recovery re-paused, a frozen monitor, a stale monitor, the soak window placement, the dry run, and the busy lane.
  • Each of F1, F2, F3, F5, G1–G5, C1 and C2 fails when its fix is reverted.
  • Full cloud script suite: 897/897 pass.
  • A live --dry-run against production read 00710-qul / 1254aff1… and generation 41. Nothing was dispatched.
  • Not tested: a real deploy. Its first use is item 1's director deploy.

Review

  • Final review findings F1–F5, P1 and P8 are fixed, mostly by deleting the resume machinery.
  • Production code is 1,320 lines, down from 1,424 (−104). Round 3 added 19 lines: the actor check and the two finishing commands. Tests went from 764 to 977 lines.
  • CodeRabbit's committable monitor fix was not applied: monitor adoption no longer exists.
  • Merge timing: this edits cloud/package.json, which is in the monitor's trusted-evidence file set. Do not merge between a monitor dry-run and the enable that consumes it.

Agent skill upstream boundary

  • Not applicable

Notes

  • Security: no credentials are handled. The driver uses the operator's gh and gcloud sessions and prints only digests, generations, run URLs, and aggregate monitor failures.
  • Cross-platform: Node plus gh and gcloud; paths use path.join.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • N/A for visual proof, with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform and SSH impact considered (operator CLI; N/A for SSH)
  • Cloud script tests pass locally

One command runs the audited director deploy: preflight, pause rehome if
enabled, publish, deploy, optional cell configure, a digest-bound inspect,
the monitor dry-run, and re-enable. It only dispatches the existing
workflows, reads the published digest from the registry and the run log,
reads the monitor verdict from its sealed state, and enables with the
digests gcloud reports after the deploy. It stops at the first failure,
records state, and resumes from it.
@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 43369b04-4adf-45ab-9a07-7299bc97fe16
📥 Commits

Reviewing files that changed from the base of the PR and between 7f51133 and 8a787e3.

📒 Files selected for processing (3)
  • cloud/dev/scripts/drive-relay-director-deploy.mjs
  • cloud/dev/scripts/drive-relay-director-deploy.test.mjs
  • cloud/docs/relay-workflows.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

Adds a driver that coordinates existing relay deployment workflows, checks live deployment state, and supports resuming interrupted work. Adds helpers to validate workflow inputs and parse workflow results. The driver uses preflight checks, typed confirmations, digest verification, monitor evidence, and rehome ownership checks. Adds simulated tests, documents driver commands and resume behavior, and registers the test in the package script.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 8a787

The driver adds guarded, resumable relay director deployment, and the review found no remaining merge-blocking issues. The first real deploy will be its first production use, so operators should watch it.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 8a787

The driver automates production operations, but retains the existing workflow authorization and safety checks. Image identity, pause ownership, and recovery are guarded. No introduced security vulnerability was established; deployment permissions and live production configuration were not independently verified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — An authorized invocation can affect the production director, requested cell configuration, and regional host rehoming through existing workflows. That scope can affect relay users beyond one cell, but the new caller does not create a tenant-facing entrypoint or a new cloud identity.

Trust Boundaries and Controls

  • observed — Operator-supplied values are validated before dispatch, and typed confirmations gate privileged steps. Cloud mutations remain in existing production workflows using workload identity; the admission workflow also requires main. No new direct cloud-mutation command was identified in the driver.

Resilience and Maintainability Implications

  • observed — The driver checks paginated active runs before dispatch. Destination workflows additionally serialize production mutations. Enable requires usable monitor evidence, a 150-second local freshness budget, unchanged director digests, and the owned control generation; the existing rehome job attempts fail-closed recovery after an unsuccessful enable.

Hardening Proposals

  • proposed — Document that the reviewed commit identifies the image while current main supplies operational workflow code, including resume behavior. If policy instead requires reviewed workflow source throughout, design compatible source binding and recovery rules rather than assuming the existing image check provides that guarantee.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 24.64% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 69 functions across 3 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: a one-command driver for relay director deployments.
Description check ✅ Passed The description covers the change, rationale, testing, visual proof, review notes, and checklist. It marks the linked issue as not applicable for internal ops tooling and explains why visual proof is …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 24.64% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 69 functions across 3 files. (1 skipped: 1 unsupported.)

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: da100189-5f8c-4257-ada3-6f4b627ca25e
📥 Commits

Reviewing files that changed from the base of the PR and between ad5aa01 and e89b9f4.

📒 Files selected for processing (5)
  • cloud/dev/scripts/drive-relay-director-deploy.mjs
  • cloud/dev/scripts/drive-relay-director-deploy.test.mjs
  • cloud/dev/scripts/relay-director-deploy-plan.mjs
  • cloud/docs/relay-workflows.md
  • cloud/package.json

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

A resume after the enable step has run permanently false-stops at deploy(), so the documented --resume recovery cannot finish a run that crashed after the enable concluded. Confirmed by reproducing it against the test harness.

Reviewed changes

  • New driver — cloud/dev/scripts/drive-relay-director-deploy.mjs dispatches the existing publish/director/rehome/admission/monitor workflows in order and threads digests, the rehome generation, and the monitor run id between them, with per-invocation state.json/driver.log.
  • Pure plan helpers — relay-director-deploy-plan.mjs builds each workflow's inputs and parses results (selector, rehome control, monitor verdict, digest log line).
  • Tests — 17 mocked gh/gcloud cases covering order, the 2026-10-05 enable-digest failure, resume, dry-run, run discovery, and fail-closed parsers. All 17 pass locally.
  • Docs + registration — a new section in cloud/docs/relay-workflows.md; the suite added to cloud/package.json's test list.

Verified against the real workflows: every builder's input names/choices match the declared workflow_dispatch inputs, and the monitor/admission artifact names plus the publish digest-log matcher match. cloud/** is in oxlint's ignorePatterns, so the 1070-line .mjs does not trip max-lines.

ℹ️ The reviewed-commit guarantee ends at the first mutation

Preflight verifies main == state.commit only while publish has not yet succeeded (drive-relay-director-deploy.mjs:475-482), and every dispatch uses --ref main (WORKFLOW_REF). Because requireRunIdentity checks only the workflow name, event, and branch — not headSha — a main that advances after preflight (or during a resumed run that skips the check) means the deploy, configure, monitor, and enable steps execute whatever workflow code main holds at that moment, not the reviewed commit. publish validates its own headSha, but the later steps do not.

Technical details
# Workflow-code identity is only checked at preflight

## Affected sites
- `cloud/dev/scripts/drive-relay-director-deploy.mjs:255-267` — `requireRunIdentity` ignores `run.headSha`.
- `cloud/dev/scripts/drive-relay-director-deploy.mjs:475-482` — the `main == state.commit` check is skipped once `publish` has succeeded.
- `cloud/dev/scripts/relay-director-deploy-plan.mjs:11` — `WORKFLOW_REF = 'main'`; dispatches always resolve the workflow file at `main`.

## Open questions for the human
- Is running the latest audited workflow code on a later resume intended, or should every dispatched run be pinned to `state.commit` (e.g. check `headSha` in `requireRunIdentity`)? The PR's premise is that the workflows are the audited evidence code, so this looks like an intentional trade-off worth stating explicitly in the docs.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

)
}
if (control.enabled) {
if (stepSucceeded('pause'))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the enable run concludes success but its onSuccess throws (e.g. runLog exhausts its retries, or rehomeControlFromLog finds no control line), workflowStep stores the step as rejected while the live control is already enabled. On resume this branch then reads that as an external re-enable and blocks every subsequent --resume with rehome was re-enabled outside this driver after the pause.

Technical details
# Green-but-unparsed `enable` reads as an external re-enable

## Affected sites
- `cloud/dev/scripts/drive-relay-director-deploy.mjs:557-561` — `control.enabled && stepSucceeded('pause')` is assumed to mean an external actor re-enabled rehome.
- `cloud/dev/scripts/drive-relay-director-deploy.mjs:408-414` — a run that concluded success whose `onSuccess` throws is persisted as `rejected`, discarding the fact that it applied.

## Required outcome
- Distinguish "our enable applied but its result could not be parsed" from a genuine external re-enable, so the former reconciles instead of permanently refusing to resume.

- Read the control back from pause and enable runs whatever their conclusion,
  and report PAUSED or UNCONFIRMED loudly.
- Resume re-enables only the pause this driver recorded (generation and run).
- Ctrl-C and SIGTERM print the same state and resume report.
- The operator types every workflow confirmation. A 5-minute soak gated on
  director 5xx runs before configure.
- A dry run keeps no state file. The quiet check pages through all runs.
  Run IDs come only from the printed URL. One step table drives execute,
  dry run and resume. The monitor verdict reuses verify-authority.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: eae5ea77-0a7e-4df3-b506-059a5b0ebb8b
📥 Commits

Reviewing files that changed from the base of the PR and between e89b9f4 and 27b1c19.

📒 Files selected for processing (4)
  • cloud/dev/scripts/drive-relay-director-deploy.mjs
  • cloud/dev/scripts/drive-relay-director-deploy.test.mjs
  • cloud/dev/scripts/relay-director-deploy-plan.mjs
  • cloud/docs/relay-workflows.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

--resume can stop for good after the driver's own pause or enable was applied but its result was never recorded, so the documented recovery path cannot finish. Two confirmed cases are inline; the pause run-crash window is new in this commit.

Reviewed changes

Since the prior pullfrog review (e89b9f4c4a), 27b1c193 rewrote the driver's state machine:

  • Owns the rehome pause — pause/enable bookkeeping moved into a settleRehome hook that reads the control back from the run log whatever the run's conclusion, backed by a pausedByDriver record that guards re-enabling.
  • Operator types every phrase — DEPLOY, PAUSE_REGIONAL_REHOMING, CONFIGURE_ASIA_DIRECTOR, and ENABLE_REGIONAL_REHOMING are now prompted by the driver rather than filled in by it.
  • Monitor verdict reuses the audited code — monitorVerdict replaced by verifyDryRunAuthority from relay-monitor-evidence.mjs run against the downloaded artifact.
  • Soak before configure — a local 5-minute gate that stops when director 5xx exceed twice the pre-deploy span plus 25.
  • Dry runs keep no state file; the quiet lane pages every status; an interrupted dispatch is adopted only as the single stable new run on two polls.
  • Tests and docs — the suite grew to 19 cases, and the doc section rewrites the sequence and the resume rules.

Verified: all 19 tests pass (node --test cloud/dev/scripts/drive-relay-director-deploy.test.mjs); builders match the real workflow_dispatch inputs and the workflow display names; the monitor artifact name and verify-authority argument shape match the enable job. The prior review's deploy() false-stop on resume is fixed — a full run followed by --resume now reaches DONE (probed against the harness).

ℹ️ Nitpicks

  • sameSelector in relay-director-deploy-plan.mjs:102 is now unused — the driver's preflight comparison was replaced by the generation-only check in preflight().

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

Comment on lines +851 to +863
} else if (stepSucceeded('enable')) {
// Nothing to reconcile.
} else if (control.enabled) {
if (state.pausedByDriver)
throw new DriverStop(
'rehome was re-enabled outside this driver after its pause; investigate'
)
} else if (state.pausedByDriver?.generation !== control.generation) {
// A director safety pause or another operator looks the same; this driver never lifts it.
throw new DriverStop(
`rehome is paused at generation ${control.generation}, which this driver did not pause (${state.pausedByDriver ? `its pause was generation ${state.pausedByDriver.generation}` : 'it has not paused'}). Find out who paused it; this driver will not re-enable it`
)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--resume cannot recover a pause/enable this driver applied when its settle/result did not persist ownership, and both cases stop for good. (1) A crash or Ctrl-C between a green pause run finishing and settleRehome persisting pausedByDriver leaves state.steps.pause as completed/success; the resume-time settle gate skips it, so the live control is paused but pausedByDriver is unset and this block throws "which this driver did not pause". (2) A green enable whose log cannot be read is persisted rejected, and the settled state.rehome.enabled plus the still-set pausedByDriver lands in the control.enabled branch at line 853 and throws "re-enabled outside this driver". Neither clears with --rehome-generation, and both were reproduced against the test harness.

Technical details
# Resume cannot recover a driver-applied mutation whose settle/result did not run

## Affected sites
- `drive-relay-director-deploy.mjs:942-948` — the resume-time settle gate runs `settleRehome` only when `!stepSucceeded(name)`, so a pause run that finished green but was never settled is skipped.
- `drive-relay-director-deploy.mjs:851-863` — `reconcileRehome` infers ownership only from `stepSucceeded('enable')` and `state.pausedByDriver`; neither survives these windows.
- `drive-relay-director-deploy.mjs:853-857` — green `enable` + unreadable log: `settleRehome` already recorded `state.rehome.enabled`, `stepSucceeded('enable')` is false, `pausedByDriver` is still set.
- `drive-relay-director-deploy.mjs:858-862` — completed-but-unsettled `pause`: `pausedByDriver` was never set.

## Required outcome
- A resume must recognize a `pause`/`enable` this driver dispatched (its `state.steps[name].runId`/log) even when the settle/result did not run, and either finish it or continue safely instead of stopping for good. The `state.steps` entry is the durable evidence of dispatch; `pausedByDriver` alone is not.

## Evidence
- Harness probe A: interrupt after `pause: success` before settle → resume fails `rehome is paused at generation 40, which this driver did not pause (it has not paused)`.
- Harness probe B: make the enable run's log unreadable on the first pass → resume fails `rehome was re-enabled outside this driver after its pause; investigate`.

function stopReport(reason) {
const lines = [`STOPPED: ${reason}`, '', 'State now:']
const rehome = state.rehome
if (rehome?.unconfirmedBy) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unconfirmedBy is set by settleRehome for both pause and enable runs, but this message always claims "It MAY BE PAUSED". When the unconfirmed run was an enable, rehome may actually be ENABLED, so the report points the operator the wrong way at the moment the driver cannot confirm the switch. Record which step set unconfirmedBy (or read the live control) and word the state accordingly.

…ak at the traffic switch

- The pause and enable read-back accepts only the control line its own step's mode prints, at the
  generation its own dispatch expected. A run adopted after a crash is settled even when green.
- The soak window opens a minute before the deploy run completed and is read a minute after it
  ends, for log ingestion lag.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

The new resume gate fixes the pause recovery window, but a green enable whose log was unreadable when it settled still cannot be recovered by --resume — it stops for good at reconcileRehome. Reproduced against the test harness.

Reviewed changes

Since the prior pullfrog review (27b1c193), c17ac950 narrows rehome read-back ownership and re-anchors the soak:

  • Own-run control read-back — settleRehome now takes the step name and accepts only the control line that step's own mode prints, at the generation delta its dispatch expected (OWN_RUN_STEPS), so an adopted foreign run is not mistaken for the driver's pause.
  • A completed-but-unsettled pause now settles on resume — the resume gate keys on state.steps[name].status !== 'succeeded' instead of stepSucceeded, so a green pause run that finished before settleRehome ran is recovered; a crash mid-dispatch of pause resumes to DONE.
  • Soak anchored at the traffic switch — the 5-minute window opens a minute before the deploy run completed and is read a minute later for log-ingestion lag.
  • Tests + docs — two recovery tests (own pause adopted after a crash; foreign rehome run not adopted), soak-window assertions, and the doc section updated.

Verified: 21 tests pass (cd cloud && node --test dev/scripts/drive-relay-director-deploy.test.mjs); the prior review's completed-but-unsettled pause case is fixed.

ℹ️ Nitpicks

  • relay-director-deploy-plan.mjs:339 — parseSelector(found.selector, \rehome ${mode} selector`), and the "printed no … control result" message at :334, still interpolate mode, which settleRehomenow passes as an array; a malformed selector would reportrehome enable,recover-enable selector. Use found.mode`, as the control label on the line above already does.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

state.steps[name].status !== 'succeeded'
) {
// Includes a green run adopted above, whose result was never read.
await settleRehome(state.steps[name], name)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new gate settles a pause run that reached completed/success (case 1 from the prior review is fixed), but the sibling enable case still cannot recover. When a green enable run's log is unreadable at settle time, the step is persisted rejected; on resume settleRehome re-reads the log and sets state.rehome.enabled = true, yet the step stays rejected and state.pausedByDriver stays set, so preflight() → reconcileRehome() throws rehome was re-enabled outside this driver after its pause; investigate and every later --resume stops the same way. Reproduced against the harness (green enable, --log fails the first pass, succeeds on resume).

Technical details
# A driver-applied `enable` that settled without its result still blocks every resume

## Affected sites
- `cloud/dev/scripts/drive-relay-director-deploy.mjs:450-470` — `settleRehome('enable', …)` confirms the run's own `enable` line and records `state.rehome.enabled`, but never marks the step settled or clears `state.pausedByDriver`.
- `cloud/dev/scripts/drive-relay-director-deploy.mjs:873-885` — `reconcileRehome` keys ownership on `stepSucceeded('enable')` and `state.pausedByDriver`; neither reflects a settled-but-unread enable.
- `cloud/dev/scripts/drive-relay-director-deploy.mjs:964-971` — the resume gate that now re-settles this entry.

## Required outcome
- After `settleRehome` confirms the driver's own enable run applied (its `enable` mode at the expected generation delta), a resume must treat that enable as done: `reconcileRehome` must not throw, and the step must not be re-dispatched.

## Evidence
- Harness probe: green `enable`, `gh run view <id> --log` returns non-zero on the first pass (settle records `unconfirmedBy`, `result` throws, step persisted `rejected`), then succeeds on resume → resume fails `rehome was re-enabled outside this driver after its pause; investigate`.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a4b24cbf-5ebd-450d-ab25-4c53f417c4c6
📥 Commits

Reviewing files that changed from the base of the PR and between 27b1c19 and b1ce949.

📒 Files selected for processing (4)
  • cloud/dev/scripts/drive-relay-director-deploy.mjs
  • cloud/dev/scripts/drive-relay-director-deploy.test.mjs
  • cloud/dev/scripts/relay-director-deploy-plan.mjs
  • cloud/docs/relay-workflows.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

Comment thread cloud/docs/relay-workflows.md Outdated
Comment on lines +633 to +637
PAUSED by the driver, or UNCONFIRMED. The PAUSED state is read back from the pause or enable run,
even when that run failed. Only the control line that the step's own mode prints is accepted, and
only at the generation its own dispatch expected, so a foreign run is never taken for the driver's
pause. UNCONFIRMED means
the run printed nothing. It also covers the serving director re-read, the published

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

State that UNCONFIRMED also covers a foreign or non-matching control line.

settleRehome sets unconfirmedBy in three cases: the log is unreadable, the log has no matching line, or the generation delta does not match. The current text says "UNCONFIRMED means the run printed nothing". An operator can then read UNCONFIRMED as "no output" while the switch did change. Update the sentence.

Proposed wording
-pause. UNCONFIRMED means
-the run printed nothing. It also covers the serving director re-read, the published
+pause. UNCONFIRMED means the run's log gave no control line from its own mode at the expected
+generation; the switch may still have changed. It also covers the serving director re-read, the published
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
PAUSED by the driver, or UNCONFIRMED. The PAUSED state is read back from the pause or enable run,
even when that run failed. Only the control line that the step's own mode prints is accepted, and
only at the generation its own dispatch expected, so a foreign run is never taken for the driver's
pause. UNCONFIRMED means
the run printed nothing. It also covers the serving director re-read, the published
PAUSED by the driver, or UNCONFIRMED. The PAUSED state is read back from the pause or enable run,
even when that run failed. Only the control line that the step's own mode prints is accepted, and
only at the generation its own dispatch expected, so a foreign run is never taken for the driver's
pause. UNCONFIRMED means the run's log gave no control line from its own mode at the expected
generation; the switch may still have changed. It also covers the serving director re-read, the published

…ume machinery

The driver keeps no state between runs. Each run reads the serving
director, its configured cells and the rehome control, and skips what is
already done.

- The only rehome fact it owns is the run that paused rehome. A re-run
  names it (--pause-run), and the driver checks it against that run's log
  and the live generation.
- A recover-enable line counts as the driver's own pause only with
  recovered: true. A director safety pause is never adopted (F3).
- Publish runs before the pause. A fresh run that finds rehome paused
  stops unless given --pause-run or --rehome-disabled (F2).
- Interrupts report a pause or enable still in flight as REHOME IS
  CHANGING (F1). PAUSE UNCONFIRMED and ENABLE UNCONFIRMED are distinct.
- A tripped soak is judged again on fresh traffic (F5). SIGHUP is
  handled, and a pending signal stops the driver before its next dispatch.
- Every stop prints the single command that finishes the deploy.

Removes the state file, --resume, step statuses, monitor adoption and
interrupted-dispatch adoption.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: eb198803-2b7c-4db5-a74f-c0d08e0a867a
📥 Commits

Reviewing files that changed from the base of the PR and between b1ce949 and 7f51133.

📒 Files selected for processing (4)
  • cloud/dev/scripts/drive-relay-director-deploy.mjs
  • cloud/dev/scripts/drive-relay-director-deploy.test.mjs
  • cloud/dev/scripts/relay-director-deploy-plan.mjs
  • cloud/docs/relay-workflows.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

…ownership by actor

- G1: always read rehome; no early DONE.
- G2: --pause-run must be a rehome-control run by the same user.
- G3: a failed enable run is never an enable.
- C1: a pause or enable is reported as changing from the moment it is
  dispatched.
- C2: --leave-rehome-paused (was --rehome-disabled) refuses an enabled
  switch. Every printed command parses.
- G4: the enable-in-flight report prints both finishing commands.
- G5: the driver's own runs never block the quiet-lane check.
…d disable after a failed enable

Claude-Session: 1145a80d-dec4-4a9b-9373-bbbb876b9041
@Jinwoo-H
Jinwoo-H merged commit ab91559 into main Oct 5, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant