soma.cell

Interview Process

Candidate moves through interview stages.

Example 069 of the basic Soma programs: a small, commented program that teaches one thing. Every output below was printed by soma 3.2.4 when this page was built.

How it is built

The cell InterviewProcess keeps 2 memory slots: candidates (Map<String, String>, persistent and consistent) and status (Map<String, String>, persistent and consistent). Its state machine interview_status starts in applied and allows 10 transitions: applied -> phone_screen, phone_screen -> technical, phone_screen -> rejected, technical -> onsite, technical -> rejected, onsite -> offer, onsite -> rejected, offer -> accepted, offer -> declined and rejected -> applied. accepted and declined are terminal. Handlers: apply (line 37) and demo (line 45).

Generated from soma describe on this file.

The source

069_interview_process.cell

// ============================================================================
// 069 — Interview Process
// ============================================================================
// Candidate moves through interview stages.
//
// Run:   soma run 069_interview_process.cell demo
// Expect:
//   Candidate: Alice Chen
//   Phone screen...
//   Technical interview...
//   Onsite interview...
//   Offer extended!
//   Final: offer

cell InterviewProcess {

    memory {
        candidates: Map<String, String> [persistent, consistent]
        status: Map<String, String> [persistent, consistent]
    }

    state interview_status {
        initial: applied

        applied -> phone_screen
        phone_screen -> technical
        phone_screen -> rejected
        technical -> onsite
        technical -> rejected
        onsite -> offer
        onsite -> rejected
        offer -> accepted
        offer -> declined
        rejected -> applied
    }

    on apply(name: String, role: String) {
        let id = to_string(next_id())
        let candidate = map("name", name, "role", role)
        candidates.set(id, to_json(candidate))
        status.set(id, "applied")
        return candidate
    }

    on demo() {
        let c = apply("Alice Chen", "Engineer")
        print("Candidate: {c.name}")

        transition("1", "phone_screen")
        print("Phone screen...")

        transition("1", "technical")
        print("Technical interview...")

        transition("1", "onsite")
        print("Onsite interview...")

        transition("1", "offer")
        print("Offer extended!")

        let st = get_status("1")
        print("Final: {st}")

        return "done"
    }
}

What the toolchain says

$ soma check 069_interview_process.cell
✓ All checks passed.
$ soma run 069_interview_process.cell demo
Candidate: Alice Chen
Phone screen...
Technical interview...
Onsite interview...
Offer extended!
Final: offer
done