The campaign is the product. An advertiser creates one and pays for it, testers apply, some are selected, they do the work and submit proof, two parties rate it, and points are paid. That is two state machines, one nested in the other, with three kinds of actor and a calendar all trying to move them.
Two machines
A campaign is the advertiser’s order: a product or a place, a number of testers, a reward per tester, and its dates. An application is one tester’s path through one campaign. A campaign has one state of its own and one application state per applicant.
They are kept apart because they answer different questions. The campaign’s state says what the public can do: see it, apply to it, or nothing. An application’s state says what one tester owes and is owed.
The campaign

| State | Meaning | Who or what moves it on |
|---|---|---|
pending_approval | Created and paid for in points, waiting for review | An admin approves or rejects |
rejected | Sent back with a reason | An admin can approve it later |
payment_pending | An earlier flow in which payment followed approval | The point payment |
payment_completed | Approved, with a recruitment start date in the future | The 00:01 job, when the date arrives |
active | Visible and open for applications | The 00:02 job at the deadline, or the advertiser closing early |
recruitment_closed | No new applications. Selected testers are working | Closure, by an admin or the 08:00 job |
closed | Finished. Rewards paid and unused budget returned | Final |
cancelled | Withdrawn by the owner or an admin | Final |
Approval looks at the calendar. A campaign approved before its recruitment start goes to payment_completed and waits. One approved on or after that date goes straight to active.
Manual changes go through one route that holds the allowed transitions as a table. The pseudo-code below was written for this page.
allowed = a table: current status -> the statuses it may move to
changeStatus(campaign, target, actor):
reject unless actor is an admin or the owning advertiser # 403
if actor is not an admin:
reject unless campaign.status == active
and target == recruitment_closed # 403: the one move an owner may make
reject unless target is in allowed[campaign.status] # 400, for admins too
apply the change
A test asserts that a transition outside the table, such as closed back to active, is refused even for an admin. Admin power in this system means access to more transitions, not the ability to write an arbitrary state.
Closing is the one transition with a precondition on the applications below it. A campaign is not closed while any tester still has a personal deadline pending, since closing settles the budget.
The application

Selection has two steps. The advertiser marks applicants as selected, which moves them to SELECTED_PENDING. Confirming the selection is a separate action: pending selections become ACTIVE and everyone else becomes REJECTED in one pass. If the advertiser never confirms, a daily job does it two days after the recruitment deadline, and returns the budget for unfilled slots to the advertiser through the ledger. Testers are not left waiting on an advertiser who has gone quiet.
Submission. An active tester submits proof of the review, such as screenshots and receipts. The application moves to REVIEW. Proof can be submitted again from a resubmit state.
Two evaluations. The advertiser and an admin each rate the submission on four axes of up to five stars each, and either can ask for a resubmission instead of rating.
| After | State | What happens |
|---|---|---|
| One evaluation | CLIENT_APPROVED or ADMIN_APPROVED | Waits for the other |
| Both, 20 stars or more out of 40 | COMPLETED | Eligible for the reward |
| Both, fewer than 20 | CLOSED | No reward. The reason recorded is a low score |
| A resubmit request | CLIENT_RESUBMIT or ADMIN_RESUBMIT | The tester may get a personal deadline |
Some campaigns run on a rolling basis with no advertiser evaluation. There the admin’s score is doubled and held to the same cut-off.
Deadlines. The 00:03 job enforces them. Applications that were never confirmed are rejected, and active testers who are past their deadline are closed with no reward. A resubmission can carry a personal deadline, and the job uses it for that tester.
The raw states have grown since launch and include legacy values. Reporting does not read them directly. One normalising function maps every raw value to a small set of funnel stages, and dashboards count those.
Paying the reward
Reaching COMPLETED does not pay anyone. The reward is a separate step with its own guard, and it is held until the campaign’s review deadline has passed. A rolling campaign is the exception: its testers are paid without waiting for that deadline.
A daily job selects completed applications that have no paid-at timestamp. For each one it:
- Computes the amount: the campaign’s reward plus a bonus percentage for the tester’s tier.
- Looks in the ledger for a reward already written for this campaign and tester. If there is one, it copies that row’s time into the paid-at field and stops.
- Claims the application by setting the paid-at timestamp, on the condition that it is still empty.
- Credits the points through the kernel, with a key built from the campaign and the tester. If the credit fails, the claim is released, so the next run tries again.
- Creates the notification.
A second job, when it closes a campaign a week after the review deadline, pays anyone who is still unpaid by the same function. The claim and the key are the two reasons those jobs can overlap.
Separating “the work was accepted” from “the money moved” means a failed payout never undoes an evaluation, and a payout can be retried without anyone rating again.
Failure modes
| What happens | What the system does | Covered by |
|---|---|---|
| A transition outside the table is requested | Refused with a client error, for admins too | An authorisation test on the status route |
| An advertiser tries to move another advertiser’s campaign | Refused by the ownership check | Authorisation tests on the status and approve routes |
| An advertiser never confirms the selection | The job confirms it two days after the deadline and refunds unfilled slots | The noon job and the ledger refund it makes |
| A tester misses the deadline | The 00:03 job closes the application without a reward | A test on submission deadlines |
| Two jobs try to pay the same reward | The paid-at claim stops the second, and the key backs it up | Tests on the reward service against the kernel |
| A raw state the dashboard does not know appears | The normaliser maps it to a funnel stage | A test on the status normaliser |
An API test also walks the whole path once: sign up, apply, submit, approve, and the reward arriving.
Limits
- The states are strings with history. Legacy values and mixed spellings remain in the data, which is why the normaliser exists.
- The evaluation and the reward are not one transaction. They are tied together by the daily job, which pays any completed application that has no paid-at timestamp.
- Several dates drive one campaign. Recruitment start, recruitment deadline, review deadline and personal deadlines interact. The jobs run in a fixed order each night so the interactions resolve the same way every time.
