Skip to content

feat(coderd): add user saved workflow routes - #336

Merged
ibetitsmike merged 14 commits into
mainfrom
mike/issue-322-saved-workflows-b
Nov 15, 2026
Merged

ibetitsmike merged 14 commits into
mainfrom
mike/issue-322-saved-workflows-b

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Coder Agents opened this PR on behalf of @ibetitsmike.

Part of #322. Stacked on #335 (storage). Second of four PRs: storage, user routes (this one), org routes and ACL, then run_workflow by name.

What changed

  • New user-tier saved workflow routes behind experiment fork-workflows, at /api/v2/chats/fork/organizations/{organization}/members/{user}/workflows[/{workflow}]: list (metadata only), create, get (with script), patch, delete. They mirror the user agent definition routes.
  • codersdk/fork_saved_workflows.go: ForkSavedWorkflowMetadata, ForkSavedWorkflow, create and update requests, and client methods.
  • coderd/x/chatd/fork_saved_workflows.go: exported ValidateWorkflowScript (size limit plus Starlark compile) and ValidateWorkflowArgsSchema (the step schema check, which requires a top-level type: object).
  • Validation on write: name pattern and length, description at most 4096 bytes, the script must compile, at most 32 unique phase names, args schema at most 12 KiB, nested at most 64 levels, with numbers in the exact validation range, and a valid schema. GET and DELETE answer 404 for a path name no workflow can have.
  • PATCH updates only the fields it gets. args_schema: null clears the schema and phases: [] clears the phases.
  • Status codes: a read by another member returns 404, as agent definitions do. A write by another member returns 403. A name conflict returns 409. With the experiment off, the routes return 403 like the other fork routes.
  • Generated: swagger (coderd/apidoc) and site/src/api/typesGenerated.ts. The routes use @x-apidocgen {"skip": true} like the other fork chat routes. I left out the docs/ output of make gen, because main's docs are already behind on many fork types and regenerating them would pull unrelated drift into this PR.

Why

Users need to save Starlark workflows so an agent can run them by name later (#226 scope item 4).

Tests

  • flock ~/.fork-go.lock go test ./coderd/ -run TestForkUserSavedWorkflows -count=1: pass. It covers create, conflict, nine invalid inputs, list, partial update, clearing the schema and phases, another member's 404 on read and 403 on write, delete, and the experiment off.
  • flock ~/.fork-go.lock make gen GEN_SKIP_GOLDEN=1: pass. Helm is not installed in this workspace, so the golden step was skipped.
  • golangci-lint run ./coderd/ ./codersdk/ ./coderd/x/chatd/: no findings in the files of this PR.

Not covered here: the org tier and ACL routes (next PR) and the agent tool (last PR).

@ibetitsmike

Copy link
Copy Markdown
Owner Author

$> Coder Agents acted on behalf of @ibetitsmike.\n\n@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T17:35:22.215439Z f6660b4 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dc1b94a9c8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread coderd/fork_saved_workflows.go Resolved
Comment thread site/src/api/typesGenerated.ts Resolved
Comment thread coderd/x/chatd/fork_saved_workflows.go Resolved
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4f70d030a3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread coderd/fork_saved_workflows.go Resolved
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 315ac5aa8a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread coderd/fork_saved_workflows.go Resolved
Comment thread coderd/fork_saved_workflows.go Resolved
Comment thread coderd/fork_chat_routes.go Resolved
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 92a8a6880a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread coderd/x/chatd/ARCHITECTURE.md Resolved
Comment thread coderd/fork_saved_workflows.go Resolved
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 2c71802e8d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex review

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

Merged main forward through the stack. @codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 863372c067

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread coderd/fork_saved_workflows.go Resolved
Comment thread coderd/fork_saved_workflows.go Resolved
Comment thread coderd/fork_saved_workflows.go Resolved
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 1405c06a4c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: e99ae1f881

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Base automatically changed from mike/issue-322-saved-workflows-a to main November 15, 2026 16:17
…workflows-b

# Conflicts:
#	coderd/database/forkdb/sqlc.yaml
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

#335 merged, so the base is now main and main is merged into the branch. The sqlc.yaml conflict kept main's version. The branch already had A's lines in it.

Phases: checkForkSavedWorkflow rejects empty, spaced, over-long (more than 128 bytes) and duplicate phases, and lists of more than 32. JSON null decodes to an empty phase, so it is rejected too. Go's pq.Array never writes a NULL element. e99ae1f tests this with raw POST and PATCH bodies that contain ["a",null], plus the SpacedPhase, LongPhase and ManyPhases cases.

Creator: the user tier sets created_by and user_id from the actor. The request type has neither field. e99ae1f sends both fields for another user in a raw body and asserts that the member is stored. The org tier test is in #337.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: fbd69d673a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: f6660b4c75

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike
ibetitsmike merged commit b4340bd into main Nov 15, 2026
9 checks passed
@ibetitsmike
ibetitsmike deleted the mike/issue-322-saved-workflows-b branch November 15, 2026 17:55
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

Merged as b4340bd (squash, --match-head-commit f6660b4c75edb45817769e8a50b628d54fb10d2e).

Gates on head f6660b4, checked by script right before the merge:

  1. Head and main (e993903) equal the SHAs I verified.
  2. All check runs on the head passed. fork-ci run 43740157626 succeeded on this exact head.
  3. Codex receipt on f6660b4: "Didn't find any major issues".
  4. No unresolved review threads.
  5. Not behind main.
  6. Independent Opus review at fbd69d6 found no P1 or P2. The only change since then is a merge of main (chore(chatd): add the missing final newline to fork_prompt_load_internal_test.go #342, one newline); the PR's own +/- lines are identical. coderd SavedWorkflow tests passed in CI and in the reviewer run. Five P3 items moved to feat(coderd): add organization saved workflow routes #337.

Previous deploy (e993903) was live before this merge. Not exercised: the routes against the running server; no UI uses them yet (#326, #327).

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

Correction to the gates comment above. Gate 1 said main was e993903 at merge time. That was true when the script checked, but #344 (7c10f9f) merged 3 seconds earlier, at 17:55:06Z, and this PR merged at 17:55:09Z on top of it. So main b4340bd holds #344 and #336, which had not been tested together before the merge.

After the fact: the two PRs share only one file, coderd/x/chatd/ARCHITECTURE.md, and the merge had no conflict. The fork-ci jobs on b4340bd (agent-sdk, build, chat-tests, forkdb, graph, schema, site) all passed. The two PRs will land in one deploy.

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