Home

mweinbach / agent-coworker

publicmweinbach/agent-coworker
Overview Code History Branches Pull requestsIssuesInsights
main
HomeOverview Code PRsIssues

fix: harden task artifact revision lifecycle (#175)

3 months ago

97a3148
Authored
Max Weinbach6/20/2026, 7:51:01 PM
* fix: harden task artifact revision lifecycle

Route artifact revision outcomes back through TaskCoordinator completion policy instead of letting persistence advance task state directly.

Reconcile compatible plan updates in place so active revision work items, evidence, ownership, artifacts, and thread links survive, while destructive active-revision rekeys fail atomically.

Validate directive plan and brief updates before persistence so invalid graphs cannot partially mutate objective, requirements, activity, or revision state.

Add deterministic regressions for lifecycle-gate bypasses, terminal-state inertness coverage, active revision preservation, destructive update rejection, concurrent plan/update races, and restart-safe atomicity.

* test: isolate codex disconnect logout

Inject Codex app-server logout through the existing connect OAuth dependency seam so the codex-cli disconnect unit test no longer depends on live app-server startup latency.

Keep production behavior unchanged by defaulting the dependency to logoutCodexAppServer, and keep the disconnect assertions for Cowork state cleanup plus auth.json deletion.

Reproduced the CI-shaped timeout by forcing the app-server command to sleep, then verified the isolated test passes under the same slow-command override.

* fix: preserve artifact revision lifecycle state

Preserve coordinator-owned active revision work item fields during compatible plan updates so status, dependencies, expected outputs, evidence, and thread ownership cannot be overwritten while the revision runtime is active.

Scope abandoned expected-output completion credit to work items with cancelled artifact revision provenance, keeping ordinary abandoned deliverables behind the missing-artifact gate.

Restore prior non-runnable task states after artifact revision settlement before completion proposal failures can strand blocked, draft, or planning tasks in working.

Adds red/green artifact lifecycle regressions for the four Codex review blockers.

* fix: keep revision settlements blocked

Give live blocking input and blockers precedence before restoring any prior artifact-revision task status, including draft and planning revisions. Add coordinator regressions for early-phase cancellation and completion when blockers appear while the revision is running.

* fix: settle deferred artifact revisions safely

Normalize replacement work item ids before active revision reconciliation so padded ids cannot overwrite coordinator-owned status, outputs, ownership, dependencies, or evidence.

Rerun ordinary completion/review gates when the last active sibling revision closes with completed revision work still awaiting settlement, while preserving blocker, review, queued-work, terminal, restart, and replay behavior.

* fix: track deferred artifact revision settlement

Add explicit artifact revision settlement state so completed sibling revisions pending behind active revisions are durable and consumed exactly once by TaskCoordinator.

Protect coordinator-owned revision helper work items during compatible plan reconciliation, including active helpers and pending deferred completed helpers, with normalized ID collision checks and atomic removal rejection.

Route final sibling close through side-effect-free completion gates so pending questions are not defaulted before readiness, stale reviewed material is not re-proposed, and draft/planning/blocker restoration happens only after deferred settlement policy runs.

Expand task artifact regressions for draft/planning deferred settlement, helper mutation/removal, stale reviewed revisions, pending questions, restart, terminal, and concurrency paths.

* fix: migrate artifact revision settlement status

Add a monotonic SessionDb migration for task_artifact_revisions.settlement_status so existing installs that already marked artifact revision migration 20 receive the new column. Backfill legacy rows to fail closed with settlement_status='none' and mark the migration ledger in the same transaction as the schema change.

Cover upgraded migration-20 databases populated with active, completed, cancelled, and failed revisions; fresh databases; column-present partial upgrades; idempotent reopen; pre-upgrade no-column query failure; post-upgrade revision listing and completion paths; and migration rollback when the schema update fails.

* fix: preserve deferred settlement after revision errors

Move pending artifact revision settlement clearing behind successful ordinary completion/review proposal so failed or blocked final sibling outcomes cannot strand completed revision material as draft with no pending settlement marker. Add production-path regression coverage proving the marker survives an error and is cleared on completed/awaiting-review settlement paths.

* fix: commit revision settlements atomically

Move pending artifact revision settlement consumption into coordinator-owned SessionDb transactions with task status, artifact acceptance, review/activity state, and exact settlement row updates committed together.

Add injected SQLite failure regressions for no-review and review-required final sibling paths plus migration/output-binding coverage.

* fix: restore artifact after atomic settlement failure

Parent518c460

11 files changed
  • docs/websocket-protocol.md+2−2
  • src/connect.ts+2−1
  • src/server/sessionDb.ts+220−0
  • src/server/sessionDb/migrations.ts+9−0
  • src/server/sessionDb/repository.ts+4−0
  • src/server/sessionDb/tasks.ts+397−182
  • src/server/tasks/TaskCoordinator.ts+616−58
  • test/connect.test.ts+12−0
  • test/task-artifact-revision-settlement-migration.test.ts+457−0
  • test/task-artifact-versions.test.ts+3497−493
  • test/task-mode.persistence.test.ts+64−0