Repository navigation
feat: add --wait to osc admin sync-fork - #151
Conversation
Adds a -w/--wait option to `osc admin sync-fork` that polls the sync-fork job to completion and then polls for the auto-triggered remake order, waiting for that to finish too. - packages/core/src/platform/maker.ts: new getOrderIdByRepositoryUrl(), reusing the existing Order/OutputOrder shapes and error handling style from getOrderIdByName. Prefers an order in an active phase (NEW/PENDING/RUNNING), falls back to the first returned order. - packages/cli/src/admin/syncfork.ts: new waitForSyncFork() that polls GET /sync-fork/by-repo until the job leaves pending/running. - packages/cli/src/admin/cmd.ts: sync-fork command gains --wait; when set, waits for the sync-fork job, then polls (bounded, ~2 minutes) for the remake order maker-manager's service-builder creates after a successful sync, then waits for that order via the existing waitForOrder(). Co-Authored-By: Claude <noreply@anthropic.com>
Research ReviewTier: 2 (Standard) — CLI feature touching two integration points (maker-manager sync-fork API, maker order API), no auth/secret/K8s manifest changes. Verified
Needs Verification
Adjacent Stubs DetectedNone found. Swept all three touched files ( Orphaned Files DetectedNot applicable — no new files added; all changes are to existing, already-imported files ( Selector ReachabilityNot applicable — no Playwright/e2e test files touched. Escape Hatch CoverageNot applicable — this PR is a CLI polling feature, not an MCP tool or request handler; it introduces no new terminal-rejection branches ( Impact Analysis
Risks Not Tested
Research Suggestions
VerdictApprove. This PR is a strong example of researched-not-guessed work: every backend field name, endpoint path, and status value was cross-checked against the actual Reviewed by PR Research Validator. This review checks whether code is based on verified sources rather than assumptions. |
Summary
Adds a
-w, --waitoption toosc admin sync-fork <serviceId>that waits forthe full two-stage fork-sync-and-rebuild flow to complete, instead of
returning right after the single status check that's currently printed.
sync-forkis not a single async job the wayremake-orderis — it's twostages that don't share an id:
GET /sync-fork/by-repo?repositoryUrl=):pending → running → succeeded|failed. This does the git-level fork sync.On success, maker-manager's service-builder auto-triggers a remake order —
there's no explicit "start remake" call from the CLI.
GET /maker/:orderId):NEW/PENDING/RUNNING → DONE|FAILED|ERROR. This is the actual image rebuild, and is whatwaitForOrder()(already used byremake-order --wait) polls.Because the sync-fork job response has no
orderIdfield linking it to theorder that gets created after it succeeds, the correlation between the two
stages is done by looking up maker orders for the same
repositoryUrlviaGET /maker?repositoryUrl=...(maker-manager filters server-side byorder.spec.githubRepository). This mirrors the existing pattern inosaas-app'ssrc/server/actions/builders/serviceUpdate.ts(
getServiceUpdateStatus/findActiveOrder).Changes
packages/core/src/platform/maker.ts: newgetOrderIdByRepositoryUrl(),following the same style/error-handling as the existing
getOrderIdByName(). Prefers an order in an active phase(
NEW/PENDING/RUNNING), falls back to the first returned order,returns
undefinedif none found.packages/cli/src/admin/syncfork.ts: newwaitForSyncFork()that pollsgetSyncForkStatus()every 5s until the job leavespending/running.packages/cli/src/admin/cmd.ts:sync-forkcommand gains-w, --wait.When set: waits for the sync-fork job to finish (reusing the existing
failed-status output for the terminal-failure case), then polls (bounded
to ~24 attempts × 5s ≈ 2 minutes) for the remake order to appear via
getOrderIdByRepositoryUrl, then waits for that order via the existingwaitForOrder(). Behavior without--waitis unchanged.Lessons
SyncForkJobStatusResponse/SyncForkByRepoResponsein maker-manager have noorderIdfield linking a sync-fork job to the remake order thatservice-builder auto-triggers after a successful sync — so
--waithas topoll
GET /maker?repositoryUrl=...with a bounded timeout rather than assumea fixed hand-off point (a fresh order may take a moment to appear after the
sync-fork job reports success). This mirrors an existing pattern already
proven in
osaas-app/src/server/actions/builders/serviceUpdate.ts. Alsoworth noting:
SyncForkByRepoResponse's TypeBoxdescriptionstring saysthe terminal success status is
"completed", but the actual runtime value(confirmed in
osaas-maker-manager/src/prepare_service/provider.ts:776-782)is
"succeeded"— the description is stale. This PR doesn't hardcode eitherstring (it only special-cases
"pending"/"running"as non-terminal and"failed"as an error), so it isn't affected, but a future consumer of thatfield should not trust the schema description.
Risks Not Tested
No live integration test was run against maker-manager — that would need a
real PAT and a fork that's genuinely behind on its upstream. The bounded
remake-order polling path (sync-fork succeeds but no remake order ever
appears within ~2 minutes) was reasoned through against the maker-manager
source but not exercised against a live environment.
🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com