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

A state diagram. The main row runs from pending_approval, created by an advertiser, to active, recruiting testers, to recruitment_closed, reviews in progress, to closed, rewards paid and budget settled. Above the row, payment_completed holds a campaign that was approved with its start date still ahead, and leads into active when the date arrives. Below the row, rejected can be approved later, and cancelled is reached by the owner or an admin. Notes: daily jobs move campaigns by date, start at 00:01, recruitment close at 00:02 and closure at 08:00 Korea time; and manual moves are checked against an allow-list in which the owning advertiser may only close recruitment early. The legend separates transitions a person decides from transitions a date decides through a daily job.
Figure 1. Campaign lifecycle. Blue transitions happen when a person decides. Orange transitions happen when a date arrives and a daily job picks the campaign up.
StateMeaningWho or what moves it on
pending_approvalCreated and paid for in points, waiting for reviewAn admin approves or rejects
rejectedSent back with a reasonAn admin can approve it later
payment_pendingAn earlier flow in which payment followed approvalThe point payment
payment_completedApproved, with a recruitment start date in the futureThe 00:01 job, when the date arrives
activeVisible and open for applicationsThe 00:02 job at the deadline, or the advertiser closing early
recruitment_closedNo new applications. Selected testers are workingClosure, by an admin or the 08:00 job
closedFinished. Rewards paid and unused budget returnedFinal
cancelledWithdrawn by the owner or an adminFinal

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

A state diagram with a main row of five states: APPLIED, the tester applies; SELECTED_PENDING, the advertiser picks the tester; ACTIVE, selection confirmed or auto-confirmed two days after the deadline; REVIEW, the tester submits proof; and COMPLETED, both evaluations in with 20 stars or more of 40. A lower row holds REJECTED, not selected when selection is confirmed; RESUBMIT, an evaluator asks again and may set a personal deadline; one evaluation in, as CLIENT_APPROVED or ADMIN_APPROVED; and CLOSED, below 20 stars or the deadline passed, with no reward. Notes: two evaluators, the advertiser and an admin, each rate the submission, and when both are in the stars are added up; and the reward is paid only after the campaign's review deadline has passed, by a daily job. The legend separates progress, side paths, and endings without a reward.
Figure 2. Application lifecycle. The main row is the path to a reward. The lower row holds the side paths: not selected, asked to resubmit, half evaluated, and closed without a reward.

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.

AfterStateWhat happens
One evaluationCLIENT_APPROVED or ADMIN_APPROVEDWaits for the other
Both, 20 stars or more out of 40COMPLETEDEligible for the reward
Both, fewer than 20CLOSEDNo reward. The reason recorded is a low score
A resubmit requestCLIENT_RESUBMIT or ADMIN_RESUBMITThe 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:

  1. Computes the amount: the campaign’s reward plus a bonus percentage for the tester’s tier.
  2. 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.
  3. Claims the application by setting the paid-at timestamp, on the condition that it is still empty.
  4. 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.
  5. 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 happensWhat the system doesCovered by
A transition outside the table is requestedRefused with a client error, for admins tooAn authorisation test on the status route
An advertiser tries to move another advertiser’s campaignRefused by the ownership checkAuthorisation tests on the status and approve routes
An advertiser never confirms the selectionThe job confirms it two days after the deadline and refunds unfilled slotsThe noon job and the ledger refund it makes
A tester misses the deadlineThe 00:03 job closes the application without a rewardA test on submission deadlines
Two jobs try to pay the same rewardThe paid-at claim stops the second, and the key backs it upTests on the reward service against the kernel
A raw state the dashboard does not know appearsThe normaliser maps it to a funnel stageA 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.