Repository navigation
feat(chatd): add workflow phases and the phase() built-in - #343
Conversation
Workflows can now declare their structure in Starlark. A phase(name) built-in sets the run's current phase and tags every step started after it. An optional top-level PHASES = [...] list is read after the script's globals run and before main, so the UI can show declared phases that have not started yet. A phase() with an undeclared name is accepted, not an error: it is appended to the run's phase list in first-reach order after the declared ones. The phases, the current phase and the per-step phase are journaled in three new columns on workflow_runs and workflow_steps through a new chatdmig node. Runs keep their phases across stop, resume and server restart. The run list and detail APIs return them, and the run_workflow tool description documents both. With the fork-workflows experiment off nothing changes. Refs #325
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ef7c266a95
ℹ️ 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".
Add a ForkWorkflowPhaseRail that renders the declared phases of a workflow run as pills with pending, running and done states. Group the steps under their phase on the run card and the panel detail. Runs without declared phases render exactly as before. Refs #325
@codex review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
CI regenerated the forkdb queries and the API docs and found two drifts from the phases commit: - sqlc emitted the COALESCE(@phases, ...) parameter of the phases writes as interface{} on a fresh machine, because the cast sat on the '{}' literal instead of the parameter. Every other text[] parameter in the fork queries casts the parameter, which sqlc emits as []string wrapped in pq.Array. The queries now do the same, so the regenerated code matches the committed code. A nil slice still reads '{}': pq encodes nil as NULL and the '{}' literal keeps the column NOT NULL happy. - swag emitted the todo status enum as canceled from the fork_chat_todos annotation, while the committed docs.go still said cancelled. The committed docs.go and swagger.json now match the annotations and the regenerated codersdk and site types. The merge of origin/main also pulls in the saved workflows backend and the state-driven waker. Refs #325
The regenerated ChatTodoStatus type spells the value canceled, matching the todo_write tool annotation and the codersdk constant. The pill map, the progress filter, the line-through class and the test mock still said cancelled, which the type check rejects. Refs #325
The parallel subtests of PhaseBuiltinsRejectBadNames shared one fixture and one 25s context. On a slow CI box the concurrent CreateChat calls exhausted the deadline before any test ran. Match the pattern of BadDeclarationsFailTheRun: one fixture and context per subtest.
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d7b34cb28b
ℹ️ 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".
- Journal await results and terminal run rows now keep Phases, CurrentPhase and per-step Phase instead of dropping them. - setPhase and readDeclaredPhases take the run mutex so the phase state is not read outside the goroutine that writes it. - Status updates on stop and resume pass the row's phases back so a NULL COALESCE cannot wipe them. - Restore the cancelled spelling from main that lint autofixes on this branch had flipped in fork chat todo and GitHub activity code. - Note the phase rail follow-ups in the chatd architecture notes. - Regenerate API docs (enum order drift from origin/main).
I pushed the Codex fix commit 93888e6 to the branch and fork-ci did not start for this push: only fork-quiet ran. The workflow triggers on pull_request synchronize and push to main, so a manual fork-ci run on this exact head is needed to satisfy the green-checks gate. @ibetitsmike could you dispatch fork-ci (Actions > fork-ci > Run workflow > branch mike/issue-325-phases-a), or is a rebase-with-empty-commit push acceptable to retrigger it? |
Merging origin/main restored the cancelled spelling in typesGenerated.ts that 19d7b22 had matched to the old canceled docs output. The pill map, the progress filter, the line-through class and the test mock went back with it.
@codex review The last review's P1 findings are fixed on head 4490cb4 (phases carried through journaled results, phase state under the run mutex, status-only writes no longer wipe phases, the cancelled spellings restored, ARCHITECTURE TODOs added, empty phase arrays). Please re-review this head. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4490cb4532
ℹ️ 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".
Responds to the Codex review of 4490cb4: - startWorkflowRun now seeds a saved workflow phases list into the run, so a run started from a saved workflow shows its phases before any phase() call. - Drop doc comments on ForkWorkflowPhaseRailProps and ForkWorkflowStepsProps that restated the field names. - Add a rail-only story to ForkWorkflowTool.stories.tsx. - Announce the phase state to screen readers in the rail pill. - awaitPhases no longer waits for a current phase. The subtest that asserts one now waits for the first step instead, since a visible step proves phase() already ran.
@codex review Head is now 64ea864 (fixes commit 94a0350 plus a merge of origin/main). All six threads from the review of 4490cb4 are resolved. |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
…tten the step list Codex round-5 fixes: the merge takes a live detail's phase state unless the detail's list is a strict prefix of the snapshot's, so the card no longer pins to the tool-result snapshot; setPhase skips the journal write when a script re-enters its current phase; the step list puts its list semantics on the actual steps, with phase headings attached to the first step of each group.
@codex review Head is now 2e45d54. It fixes the three findings from the review of fbbf57e: the merge advances the rail from any live detail whose phase list is not a strict prefix of the snapshot's, setPhase skips the journal write when a script re-enters its current phase, and the step list carries its list semantics on the actual steps. All review threads are resolved. Please review this head. |
@codex review Head is now 1573edd: a plain merge of origin/main 54e2b41 (#361), no code changes beyond the round-5 fixes and that merge. Please review this head. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1573eddb7d
ℹ️ 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".
The step list found each step's phase group while rendering, so a script that re-entered a phase showed its later steps under the previous phase's heading. The list now walks the phase groups once and renders a heading per group, and each group's first step points at its heading with aria-describedby, which replaces the unused heading id. RepeatedPhaseCallSkipsTheJournalWrite now counts UpdateWorkflowRunPhases calls through a store wrapper, so the test fails when a re-entered phase journals its write again.
@codex review Head is now 6da3bdc (merge of origin/main d4b1539 into 79ef345). Changes on this head:
Verified: go build ./..., go vet ./coderd/x/chatd/, go test -count=1 ./coderd/x/chatd/ all pass; pnpm format, tsc, and the ForkWorkflows, ForkWorkflowTool and ForkWorkflowsPanel vitest suites (72 tests) pass. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6da3bdc117
ℹ️ 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".
Both review threads from the last pass are resolved in 51bdbcc: phase groups are now formed from consecutive steps in run order, and heading ids come from React useId instead of the raw phase name. ForkWorkflowSteps vitest (44 tests across the ForkWorkflows suite), tsc and biome format pass. Ready for another review pass. |
Merged origin/main (5e28a43, #365) into the branch with a merge commit; no conflicts. go build ./... and go test -count=1 ./coderd/x/chatd/ pass locally (48s). New head 3acc97f pushed to both branches. Both threads from the previous pass remain resolved and no new findings yet. Ready for review on this head. |
@codex review Head is now 3acc97f: 51bdbcc (consecutive phase groups in spawn order, useId heading ids) plus a clean merge of main 5e28a43. An independent delta review found no P1 or P2 issues. Phase Go tests pass with -race, and the ForkWorkflows vitest suites pass. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3acc97ff6e
ℹ️ 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".
…a contracts in vitest
@codex review Head is now 96f1f9d. It moves the rendering-only phase-group coverage into ForkWorkflowSteps.stories.tsx and makes the vitest cases assert the aria-describedby contract, per the FE1 finding on 3acc97f. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 96f1f9d764
ℹ️ 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".
…cribed-by behavior with semantic queries
@codex review Head is now eabc1c1. Changes since 96f1f9d:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eabc1c1d21
ℹ️ 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".
@codex review Head is now 6a43714. The only change since eabc1c1 removes a three-line comment from ForkWorkflowSteps.test.tsx. An independent review of eabc1c1 found no P1 or P2 issues. |
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Merged as 2de8654 (squash, Gates on head 6a43714:
Not exercised: the live dev-build check from #325 (an agent running a PHASES workflow and watching the rail update in the card and panel), a restart and resume on a real server, and Pixel screenshots. |
What
Workflows can now declare and mark their structure in Starlark, and the run APIs carry it.
phase(name)is a new built-in. It sets the run's current phase and tags every step started after it. A step started before the firstphase()call has an empty phase.PHASES = [...]list is read after the script's globals run and beforemain, so the UI can show declared phases that have not started yet.phase()with an undeclared name is accepted, not an error: the name is appended to the run's phase list, after the declared ones, in first-reach order. Display order is declared order first, then undeclared reach order.PHASEStogether; passing the cap fails the run. A runtimephase()past the cap is logged and ignored; a script declaring more than 32PHASESentries, or aPHASESthat is not a list of non-empty byte strings, fails the run like a brokenmain.workflow_runs.phases,workflow_runs.current_phase,workflow_steps.phase) through a new chatdmig node. Existing nodes are untouched. Runs keep their phases across stop, resume and server restart.phasesandcurrent_phase, and run detail steps returnphase(codersdk/fork_workflow_runs.go,coderd/fork_workflow_runs.go).run_workflowtool description documentsphase()andPHASES.With the
fork-workflowsexperiment off nothing changes.Refs #325
Review notes for Mike
coderd/x/chatd/ARCHITECTURE.mdcarries two new TODOs for the human author: thephase()built-in at the fork-workflows bullet (line 1282) and the workflow-phases journaling entry at the top of the fork section. They follow the file's existing TODO pattern.ChatContextResourceKindenum order incoderd/apidoc/docs.goandswagger.jsonmovedsubagentfirst in commit 0efbd7b, which does not match what the generator produces on main (main lists it last, because the fork constant lives incodersdk/fork_agent_definitions.go). That reorder is regeneration drift, not the generator's output; if fork-ci's apidoc check passes it stays, otherwise a follow-up regeneration will restore main's order.make genpasses:docs/admin/setup/configuration-reference.md(50 lines),docs/reference/api/users.mdanddocs/reference/api/general.md(stale upstream text), and thecancelledspelling restored for ChatTodoStatus indocs/reference/api/schemas.md.Tests
go test ./coderd/x/chatd/ -count=1: ok.TestForkWorkflowPhasescovers: phase tags steps and journals, undeclared name accepted and appended, declared list shown before the first step (with the journaled DB row), badPHASESdeclarations failing the run (including a NUL byte),phase()rejecting bad names (NUL, control, format characters), resume keeps phases, run without phases, saved-workflow phases seeding the run, stop keeping the phases throughstopJournaledRun, and the 32-phase cap counting saved and declared phases together.go test ./coderd/ -run 'TestForkWorkflow' -count=1: ok.go build ./...: ok.go vet ./coderd/x/chatd/: clean.make gen: ran.pnpm run lint:typesclean;pnpm test:ci src/pages/AgentsPage173 files, 2972 tests green, including the phase-state matrix for pending, running, done, failed, completed, stopped, failed and interrupted runs;pnpm formatapplied.pnpm linthas one pre-existing React Compiler finding inForkHtmlAttachmentViewer.tsxon main, outside this PR.make lint: the whole-tree golangci run reports pre-existing issues only, in files this PR does not touch. The PR-scopedlint/go/new-codegate againstorigin/mainpasses with 0 issues on the PR's packages.Not exercised