4.5 KiB
id, title, status, wave, depends_on, plan, requirements, acceptance_criteria, system_design
| id | title | status | wave | depends_on | plan | requirements | acceptance_criteria | system_design | |||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 01-persistence | Persist completion settings | done | 1 | plan.md |
|
|
|
Task 01: Persist completion settings
Summary
Persist explicit completion decisions and preserve existing workflow behavior across upgrade. This work owns schema and legacy stored-data conversion.
In scope
- Add CompleteTaskOnEnter to workflow and task step models, stored definitions, and every repository create/update/select/scan/bootstrap projection.
- Add the shared column in both repository startup paths. Implement workflow-owned transactional backfill plus durable marker, including stored template JSON without overwriting unrelated fields.
- Test real constructor order, fresh databases, pre-column upgrade, mixed names/case/whitespace/positions, explicit false, replay after disabling, and injected failure followed by retry on SQLite and PostgreSQL.
Out of scope
Runtime terminal predicates, portable API behavior, and UI are later work orders.
Acceptance
- Existing qualifying final steps are enabled once; nonqualifying steps and new custom steps default false.
- True/false survive CRUD, bootstrap, table replay, and migration rollback/retry. IDs, timestamps, history, and user edits remain intact.
- Required-store SQL guard, fresh/replay conformance, and legacy upgrade assertions pass on both database dialects.
TDD entry
Create completion_policy_test.go beside workflow repository tests. TestCompletionPolicyMigration should fail because legacy Done has no enabled field after current initialization; TestCompletionPolicyReplayPreservesDisabled must fail if replay re-enables false. Use a minimal field declaration only if needed to compile the regression before implementation.
Verification
Run from apps/backend/. PostgreSQL-dependent cases use an isolated KANDEV_TEST_POSTGRES_DSN; never point tests at the reported installation.
rtk go test -race ./internal/workflow/repository ./internal/task/repository/sqlite -run 'TestCompletionPolicy|TestWorkflowStep|TestBuiltin' -count=1
rtk go run ./cmd/sqlguard ./internal
rtk go test -race ./internal/persistence/requiredstores ./internal/persistence/storeconformance -count=1
Files likely touched
apps/backend/internal/workflow/models/models.goapps/backend/internal/task/models/models.goapps/backend/internal/workflow/repository/sqlite.goapps/backend/internal/workflow/repository/completion_policy_test.go (new)apps/backend/internal/task/repository/sqlite/base_schema.goapps/backend/internal/task/repository/sqlite/base_migrations.goapps/backend/internal/task/repository/sqlite/defaults.goapps/backend/internal/task/repository/sqlite/workspace_bootstrap.goapps/backend/internal/persistence/storeconformance/owner_actions.goapps/backend/internal/persistence/storeconformance/upgrade_test.go
Dependencies
None.
Risks
Do not put a new-column reference ahead of ADD COLUMN, replay a semantic backfill without its marker, or alter historical release snapshots to look like the new schema. Provision an isolated PostgreSQL DSN for the same commands and report skips explicitly.
Parallelism
sequential
Inputs
- Requirements, criteria in frontmatter.
- System design.
- Plan, confirmed source trace and existing reproduction tests.
- Nearby Go repository/handler tests supply fixture conventions.
- Follow
/tddin the primary session.
Results
- RED:
rtk go test ./internal/workflow/repository -run TestCompletionPolicyMigration -count=1failed before the migration implementation because the legacy final step remained disabled. - Final:
rtk go test -race ./internal/workflow/repository ./internal/task/repository/sqlite -run 'TestCompletionPolicy|TestWorkflowStep|TestBuiltin' -count=1passed (8 tests). - Final:
rtk go run ./cmd/sqlguard ./internalpassed. - Final:
rtk go test -race ./internal/persistence/requiredstores ./internal/persistence/storeconformance -count=1passed (305 tests).
The workflow and task repository schemas now persist the explicit boolean. The transactional marker-backed migration preserves explicit false values and normalizes legacy stored templates without overwriting unrelated fields.