Skip to content

Reject-and-detach option for mission submissions#690

Open
dhamariT wants to merge 2 commits into
mainfrom
reject-and-detach-submission
Open

Reject-and-detach option for mission submissions#690
dhamariT wants to merge 2 commits into
mainfrom
reject-and-detach-submission

Conversation

@dhamariT

@dhamariT dhamariT commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

What & why

On /admin/missions/<mission>/submissions the reviewer could only Approve or Reject. When a submission was rejected the project stayed attached to that mission, so the builder was stuck on the mission they'd just been rejected from with no clean way to move on.

This adds a third path: reject and detach the project from the mission, freeing the builder to pick a different mission.

The flow

The verdict form now has a "Also detach this project from the mission" checkbox. It only takes effect on rejections (ignored on approve):

  • Plain reject — rejects the submission, project keeps its mission. Unchanged behaviour.
  • Reject + detach — rejects and detaches the project from the mission so the builder can pick a different one.

How it works

  • Detach reuses the existing Project#detach_mission! (soft-detaches the MissionAttachment).
  • The detach is guarded: it only fires while the rejected mission is still the project's current mission, so a mission the builder has since swapped to is never yanked.
  • Runs inside the existing reject transaction.

Audit / papertrail

  • Project::MissionAttachment has has_paper_trail, so the detach is versioned, with whodunnit set via the admin controller chain (attributed to the reviewer).

No migration — reuses the existing soft-detach column.

Tests

  • Plain reject → project keeps mission
  • Reject + detach → project freed from the mission
  • Detach flag ignored when approving
3 runs, 12 assertions, 0 failures, 0 errors

(Rubocop clean on the changed files.)

Notes

  • Undo: undo moves a submission back to pending but does not re-attach the mission. Detach is intentionally a one-way reviewer action; flag if you want undo to reverse it too.
  • Fallback mission: detach_mission! re-attaches a fallback if the project previously shipped (non-rejected) to another mission — a shipped project never goes mission-less. For a typical first rejection there's no fallback, so the project just becomes mission-free.

Note

Medium Risk
Changes mission attachment state on reject (guarded to current mission only) inside the existing transaction; undo does not re-attach per PR notes.

Overview
Mission reviewers can optionally detach the builder's project from the mission when rejecting a submission, so the builder is not stuck on a mission they failed.

The review verdict form adds an "Also detach this project from the mission" checkbox (with hint copy and styling). On reject, if that flag is set, the update action calls new detach_submission_project!, which uses existing Project#detach_mission! only when the submission's mission is still the project's current mission. Approve ignores the flag; plain reject behavior is unchanged. The flash notice reflects when a detach actually occurred.

Controller tests cover plain reject, reject+detach, and detach ignored on approve.

Reviewed by Cursor Bugbot for commit e62b7ff. Bugbot is set up for automated code reviews on this repo. Configure here.

Reviewers can now reject a mission submission and, in the same step,
detach the project from the mission so the builder is freed to pick a
different one. Detaching deducts 5 stardust from the builder.

- Add a 'detach project' checkbox to the verdict form (rejections only)
- Detach via Project#detach_mission!, guarded to the submission's current
  mission so a since-swapped mission is never yanked
- Charge DETACH_PENALTY (5) stardust via a ledger entry on detach, which
  writes its own balance_adjustment PaperTrail audit
- Tests for plain reject (no charge), reject+detach (-5, mission freed),
  and detach flag ignored on approve

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 58f969d. Configure here.

Comment thread app/controllers/admin/missions/submissions_controller.rb
Reject-and-detach now just frees the project from the mission with no
stardust deduction.
@dhamariT dhamariT changed the title Reject-and-detach option for mission submissions (with 5 stardust penalty) Reject-and-detach option for mission submissions Jun 25, 2026
@qcoral

qcoral commented Jun 26, 2026

Copy link
Copy Markdown
Member

@dhamariT this should have a demo of it working!

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.

2 participants