🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

feat: add on_success workspace build request handling - #25758

Merged
geokat merged 3 commits into
george/plat-143/1-workspace-build-orchestration-storagefrom
george/plat-143/2-on-success-workspace-build-request-handling
Jul 6, 2026
Merged

feat: add on_success workspace build request handling#25758
geokat merged 3 commits into
george/plat-143/1-workspace-build-orchestration-storagefrom
george/plat-143/2-on-success-workspace-build-request-handling

Conversation

@geokat

@geokat geokat commented May 27, 2026

Copy link
Copy Markdown
Contributor

This PR is part of a stack that adds durable server-side workspace restart support
to the API.

Add an on_success field to workspace build requests so callers can attach
durable follow-up build intent to a parent build. In this stack, the supported
flow is a stop build with an on_success start build, which lets the server
persist restart intent before the parent stop build finishes.

This adds SDK/API request types, validation, generated API documentation, and
persistence of the child build request into workspace_build_orchestrations. It
also adds coverage for validation, persistence, and stored child request fields.

Ref: https://linear.app/codercom/issue/PLAT-143/add-workspace-restart-functionality-to-api
Ref: #5800


This PR is part of a stack that merges into main:

  1. feat: add workspace build orchestration storage #25757
  2. feat: add on_success workspace build request handling #25758 👈
  3. feat(coderd): process on_success workspace build orchestration #25759
  4. chore(coderd/database): purge terminal workspace build orchestrations #25760
  5. feat(cli): server-side restart orchestration demo #25761

Created with stakk

@github-actions

Copy link
Copy Markdown

Docs preview

📖 View docs preview for docs/reference/api/builds.md

@geokat geokat changed the title feat(coderd): add on_success workspace build request handling feat: add on_success workspace build request handling May 27, 2026
@geokat
geokat force-pushed the george/plat-143/1-workspace-build-orchestration-storage branch from 92bf471 to 17867b6 Compare May 28, 2026 04:27
@geokat
geokat force-pushed the george/plat-143/2-on-success-workspace-build-request-handling branch from 58700d9 to 3edff4e Compare May 28, 2026 04:27
@geokat
geokat marked this pull request as ready for review May 28, 2026 05:30
@github-actions github-actions Bot added the stale This issue is like stale bread. label Jun 9, 2026
@github-actions github-actions Bot closed this Jun 12, 2026
@geokat geokat reopened this Jun 12, 2026
@geokat geokat removed the stale This issue is like stale bread. label Jun 12, 2026
@geokat
geokat force-pushed the george/plat-143/2-on-success-workspace-build-request-handling branch 3 times, most recently from dca2e69 to 2e97f53 Compare June 17, 2026 20:55
Add the on_success request shape for workspace builds and validate the
supported server-side restart flow.

When a stop build includes on_success, persist the requested child
start build intent in workspace_build_orchestrations for later
processing. Add SDK/API generated docs and tests for validation,
persistence, and child request fields.

Ref: https://linear.app/codercom/issue/PLAT-143/add-workspace-restart-functionality-to-api
Ref: #5800
@geokat
geokat force-pushed the george/plat-143/2-on-success-workspace-build-request-handling branch from 2e97f53 to fa1fd82 Compare June 17, 2026 23:23
@Emyrk

Emyrk commented Jun 23, 2026

Copy link
Copy Markdown
Member

/coder-agents-review

@coder-agents-review

coder-agents-review Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Chat: Review posted | View chat
Requested: 2026-06-23 18:29 UTC by @Emyrk
Spend: $46.04 / $100.00

Review history
  • R1 (2026-06-23): 19 reviewers, 1 Nit, 1 Note, 5 P2, 4 P3, COMMENT. Review

deep-review v0.9.0 | Round 1 | 6cd5c5e..fa1fd82

Last posted: Round 1, 11 findings (5 P2, 4 P3, 1 Nit, 1 Note), COMMENT. Review

Finding inventory

Findings

# Sev Status Location Summary Round Reviewer Posted
CRF-1 P3 Open (subsumed by CRF-8) dbtestutil/workspacebuildorchestrations.go:12 Test helper SELECT omits workspace_id; WorkspaceID always zero R1 Netero No
CRF-2 P4 Dropped by orchestrator (dead code used by stacked PRs) workspacebuilds_on_success_test.go:208 echoResponseOptions.failStopApply and validationRegex wired but never exercised R1 Netero, Zoro No
CRF-3 P2 Open workspacebuilds.go:663 Preset-without-version bypasses validation, hits DB constraint as 500 with leaked constraint name R1 Hisoka P2, Mafuuu P3, Knov P3, Knuckle P3, Razor P3 Yes
CRF-4 P2 Open workspacebuilds.go:521 Child template version stored without validating membership in workspace template R1 Mafuuu P2, Kurapika P2 Yes
CRF-5 P2 Open workspacebuilds_on_success_test.go:161 ParentOrphanRejected test shadowed by pre-existing orphan check; asserts only status code R1 Bisky P2, Chopper P3 Yes
CRF-6 P3 Open workspacebuilds.go:530 ChildLogLevel/ChildReason inherited from parent request without comment R1 Hisoka P3, Gon P3, Pariston P3 Yes
CRF-7 P2 Open codersdk/workspaces.go:145 SDK type CreateWorkspaceBuildOnSuccessRequest has no doc comment or field docs R1 Leorio P2, Gon P2 Yes
CRF-8 P2 Open dbtestutil/workspacebuildorchestrations.go:12 Hand-rolled SQL duplicates SQLC-managed columns, already drifted (missing workspace_id) R1 Robin P2 Yes
CRF-9 P3 Open workspacebuilds_on_success_test.go:69 Happy-path test missing status == "pending" assertion R1 Bisky P3 Yes
CRF-10 Note Open dbauthz.go:6438 Dbauthz version-pin guard gates on ChildTemplateVersionID but not ChildTemplateVersionPresetID R1 Meruem P2 Yes
CRF-11 P3 Open workspacebuilds.go:539 403 Detail restates Message without naming the missing capability R1 Leorio P3 Yes
CRF-12 Nit Open workspacebuilds.go:676 "OnSuccess transition must be start." ambiguous about which transition field R1 Leorio Yes
CRF-13 P3 Open workspacebuilds.go:513 childBuild names a request, not a build; inconsistent with createBuild naming R1 Gon P3 Yes

Contested and acknowledged

(none)

Round log

Round 1

Panel. 5 P2, 4 P3, 1 Nit, 1 Note, 1 P4 dropped. CRF-1 subsumed by CRF-8. CRF-2 dropped (dead code for stacked PRs). CRF-10 noted in body (code from prior PR, DB constraint prevents exploit). Reviewed against 6cd5c5e..fa1fd82.

About deep-review

CRF = Coder Review Finding (P0-P4, Nit, Note)

Reviewer Focus
Bisky tests
Chopper ops/errors
Churn-guard change verification
Ging language modernization
Gon naming
Hisoka edge cases
Killua perf
Kite change integrity
Knov contracts
Knuckle SQL
Komugi flake/determinism
Kurapika security
Law decomposition
Leorio docs
Luffy product
Mafu-san process
Mafuuu contracts
Melody dispatch/pairing
Meruem structural
Nami frontend
Netero mechanical checks
Pariston premise testing
Pen-botter product gaps
Razor verification
Robin duplication
Ryosuke Go arch
Takumi concurrency
Zoro shape

🤖 Managed by Coder Agents.

@coder-agents-review coder-agents-review 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.

Clean stack decomposition: PR 1 adds storage, PR 2 (this) adds the API surface and persistence, PR 3 adds processing. The transaction atomicity is correct; the parent build and orchestration insert share a single InTx, so both succeed or both roll back. The dbauthz layer front-loads authorization at insert time so the system-context orchestrator doesn't need to re-check permissions later. Test density is solid at 57.8%.

Severity counts: 5 P2, 4 P3, 1 Nit, 1 Note.

The two highest-impact findings are input validation gaps on the child request: (1) preset-without-version passes validation and hits a raw DB CHECK constraint as a 500 with a leaked constraint name, and (2) a cross-template version ID can be stored without validating the version belongs to the workspace's template. The convergence on these was strong: five reviewers independently flagged the preset gap and two flagged the cross-template gap.

"The user loses both the stop and the restart intent, with an opaque error." (Hisoka, on preset-without-version)


coderd/database/dbauthz/dbauthz.go:6438

Note [CRF-10] Defense-in-depth: this guard checks arg.ChildTemplateVersionID.Valid but not arg.ChildTemplateVersionPresetID.Valid. A preset FK-resolves to exactly one template version, so specifying only a preset is semantically equivalent to a version pin. The DB constraint (workspace_build_orchestrations_child_preset_version_check) currently prevents preset-without-version, so this is not exploitable today. If that constraint is ever relaxed to support auto-resolution, the auth check would need to also gate on arg.ChildTemplateVersionPresetID.Valid.

(Meruem)

🤖

🤖 This review was automatically generated with Coder Agents.

Comment thread coderd/workspacebuilds.go
Comment thread coderd/workspacebuilds.go
Comment thread coderd/workspacebuilds_on_success_test.go
Comment thread codersdk/workspaces.go Outdated
Comment thread coderd/database/dbtestutil/workspacebuildorchestrations.go Outdated
Comment thread coderd/workspacebuilds.go
Comment thread coderd/workspacebuilds_on_success_test.go
Comment thread coderd/workspacebuilds.go Outdated
Comment thread coderd/workspacebuilds.go
Comment thread coderd/workspacebuilds.go Outdated

@Emyrk Emyrk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed the on_success request handling. Behaviour and validation look right, transaction rollback on the dbauthz rejection is correct, and the table-driven validation test maps one-to-one to validateCreateWorkspaceBuildOnSuccess. Three small nits inline, all non-blocking.

This review was drafted by Coder Agents on behalf of @Emyrk.

Comment thread coderd/workspacebuilds.go
Comment thread coderd/database/dbtestutil/workspacebuildorchestrations.go Outdated
Comment thread coderd/workspacebuilds_on_success_test.go
Comment thread coderd/workspacebuilds.go Outdated

@Emyrk Emyrk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

only nits

@github-actions github-actions Bot added the stale This issue is like stale bread. label Jul 2, 2026
@github-actions github-actions Bot closed this Jul 6, 2026
@geokat geokat removed the stale This issue is like stale bread. label Jul 6, 2026
@geokat geokat reopened this Jul 6, 2026
@geokat
geokat merged commit 6b6fcd3 into george/plat-143/1-workspace-build-orchestration-storage Jul 6, 2026
21 of 24 checks passed
@geokat
geokat deleted the george/plat-143/2-on-success-workspace-build-request-handling branch July 6, 2026 20:48
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants