Skip to content

Tasks: keep the task status in step with its assignments - #44

Merged
anishmehta24 merged 2 commits into
mainfrom
fix/task-status
Nov 18, 2026
Merged

anishmehta24 merged 2 commits into
mainfrom
fix/task-status

Conversation

@anishmehta24

@anishmehta24 anishmehta24 commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Follow-up to the audit's M-13. #14 fixed the stats half; this is the remaining half: Task.status was never written, so every task's badge said PENDING.

Summary

  • A task's status now sums up its assignments. It is worked out again whenever an assignment is assigned, started, submitted or reviewed:
    • APPROVED once every assignment is approved;
    • SUBMITTED while any waits for review;
    • REWORK while any was sent back;
    • IN_PROGRESS once anyone has started, or some but not all are approved;
    • otherwise PENDING.
  • The task row is locked while the status is worked out, so two changes at the same moment can't leave the status computed by whichever read first.
  • From review: the assign, start, submit and review events carry the status just worked out. They were built from the task as read before the change, so they carried the old status.
  • Existing tasks are fixed once. Migration task_status_backfill applies the same rule to every task with assignments, so tasks that already had approved or submitted work stop showing PENDING.

Rules used

  1. SUBMITTED wins over REWORK because work waiting for review is what the manager acts on next. REWORK wins over IN_PROGRESS because it says something came back.
  2. The status is stored, not worked out on each read, since the task list and dashboards read it directly.

Validation

  • pnpm test (373 passed, 2 new), pnpm lint, pnpm typecheck, pnpm build, git diff --check, prisma migrate status.
  • Locally, through the API on a temporary task (deleted afterwards): created PENDING, assigned PENDING, started IN_PROGRESS, submitted SUBMITTED, sent back REWORK, then resubmitted and approved APPROVED.
  • The backfill SQL, run inside a rolled-back transaction on four temporary tasks:
    • both assignments approved → APPROVED;
    • submitted plus rework → SUBMITTED;
    • approved plus pending → IN_PROGRESS;
    • no assignments → stays PENDING.

Task.status was never written, so every task showed PENDING. It is now worked
out from the task's assignments whenever one is assigned, started, submitted
or reviewed, with the task row locked: approved once all are approved,
submitted while any awaits review, rework while any was sent back, in progress
once anyone started, otherwise pending. Migration task_status_backfill applies
the same rule once to existing tasks.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 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-18T10:44:30.593194Z 5785cf1 PR opened
ℹ️ 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: 5785cf1c5d

ℹ️ 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 apps/api/src/tasks/tasks.service.ts Outdated
data: { collegeId: context.collegeId, actorId: context.userId, action: 'TASK_SUBMITTED', entityType: 'TaskAssignment', entityId: assignmentId, metadata: { taskId: existing!.taskId, content: input.content } },
});
});
await this.syncTaskStatus(existing!.taskId, context.collegeId);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Emit the recomputed task status in workflow events

When a submission changes the aggregate status, existing.task was fetched before the update and is not refreshed here; the event below therefore emits the previous status even though syncTaskStatus has stored the new one. The same pattern affects start and review events. Listeners that use the documented TaskEventPayload.status field will receive stale state; refetch the task after synchronization before building the payload.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 8f79403. syncTaskStatus now returns the status it stored, and the assign, start, submit and review events build their payload with that status instead of the task read before the change.

Assign, start, submit and review events built their payload from the task as
read before the change, so they carried the old status. syncTaskStatus now
returns the status it stored, and the events use it.
@anishmehta24
anishmehta24 merged commit fb6d5b1 into main Nov 18, 2026
@anishmehta24
anishmehta24 deleted the fix/task-status branch November 18, 2026 10:46
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