Repository navigation
feat(action-center): an action becomes a cycle, not a row - #819
Merged
Merged
Conversation
Phase 1 of #818. 00081 gave every action `dedup_key = kind` under a plain unique constraint, so a brand held at most one action per kind for its entire lifetime. Three things followed, all wrong. The nightly pass overwrote an active action's payload, so a recovery someone had already started silently became a recovery for a different set of prompts. A completed action was resurrected by setting its status back to `new` and clearing `completed_at`, which erased the historical record rather than adding to it. And a kind could therefore never produce a second execution cycle, which is why History had nothing to accumulate. The rule the engine wants is one *active* action per kind, not one ever. A partial unique index says exactly that: active actions still collide, closed ones pile up behind them. Closing a cycle frees the slot; once a rest window has passed — the same fourteen days the old reopen path used, now deciding when the next cycle may begin rather than whether to resurrect the last one — a still-firing condition opens a NEW action beside the old one, with its own baseline, tasks and outcome. An active action keeps the scope it was created with. Signals detected since are still linked to it as evidence, because they are why it exists, but its payload is left alone: it is a work package someone may be executing against, and new targets are better left for the next cycle than folded in silently. `no_improvement` leaves the status column. It was never an execution status — an action arrives there by being completed and then measured — and keeping both facts in one column made the second unanswerable for an action that was completed but never measured, which today is every one of them. Status now answers "was the work done", the new `outcome` column answers "did it help", and phase 2 is what will fill the second. Task statuses pick up the execution vocabulary they were missing: `canceled` becomes `skipped` and now records why, alongside `failed` for a run that was attempted and `waiting_approval` for work that needs a person. A skip without a reason cannot be told apart from an abandoned task, so the UI asks. The generator had no tests; it does now, covering the two behaviours this commit changes and the three it must not. Applied to the hosted database. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01SQ2H6mSd9JDpmqonk2VWBj
This was referenced Sep 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 1 of #818.
Summary
Every action carried
dedup_key = kindunder a plainunique (brand_id, dedup_key), so a brand held at most one action per kind for its entire lifetime. Three things followed from that, all wrong:newandcompleted_atcleared, which erased the historical record rather than adding to it;This is the reported symptom: a new action never appeared beside an old one, because it became the old one.
The change
One active action per kind, unlimited closed ones. A partial unique index says exactly that — active actions still collide, closed ones pile up behind them. Closing frees the slot. After a rest window (the same fourteen days the old reopen path used, now deciding when the next cycle may begin rather than whether to resurrect the last one) a still-firing condition opens a new action beside the old one, with its own baseline, tasks and outcome.
An active action keeps its scope. Signals detected since are still linked to it as evidence — they are why it exists — but its payload is left alone. It is a work package someone may be executing against; a new target is better left for the next cycle than folded in silently.
Outcome leaves the status column.
no_improvementwas never an execution status: an action arrives there by being completed and then measured. Holding both facts in one column made the second unanswerable for an action that was completed but never measured — which today is all of them.statusnew,in_progress,on_hold,completed,dismissedoutcomepending_measurement,improved,no_meaningful_change,declined,not_measurablePhase 2 is what fills the second. Until then every row reads
pending_measurement, and History says so rather than implying a measurement that did not happen.Task statuses pick up the execution vocabulary they were missing.
canceledbecomesskippedand records why;failedcovers a run that was attempted and did not work;waiting_approvalcovers work that needs a person. A skip without a reason cannot be told apart from an abandoned task later, so the drawer asks for one before committing the change. Skipped and failed both leave the progress denominator — neither is outstanding work.Tests
The generator had none. It does now — seven, covering both behaviours this PR changes and the three it must not break:
completed_atwrite, noreopenedevent)Related issue
Phase 1 of #818.
Type of change
feat— New featurefix— Bug fixDatabase
00084_action_lifecycle— already applied to the hosted database. Swaps the unique constraint for a partial index, addsactions.outcomeandaction_tasks.skip_reason, and migrates the old status values. All 24 actions and 87 tasks intact.How to test
neworin_progresskeeps its counts across a nightly run, even when new signals of the same kind arrive. Its Signals tab still grows.CompletedwithNot measured, rather than claiming an improvement nobody measured.Run from
server/:yarn test(422 passing),yarn lint,yarn format:check.Run from
web/:yarn test(216 passing),yarn lint,yarn typecheck,yarn format:check,yarn build.Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdsupabase/schema.sqlregenerated withbash supabase/build-schema.shyarn lintpasses (run fromweb/) — 0 errorsyarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)🤖 Generated with Claude Code
https://claude.ai/code/session_01SQ2H6mSd9JDpmqonk2VWBj