Files
live-quiz/docs/decisions/0002-harness-agnostic-process-lifecycle.md
T
kiskaadee 8e0adb3248 docs(adr): decouple process termination from assessment completion in ADR-0002 and ADR-0006
- ADR-0002: Establish that process exit does not equal assessment completion.
  Define structured lifecycle outcome on stdout (FINALIZED, SUSPENDED, ERROR).
  Add sequence diagram showing in-browser pause/resume vs 2-hour grace period exit.
- ADR-0006: Define Pause as a durable transaction committed to SQLite before ACK.
  Establish a 2-hour configurable pause grace period allowing seamless in-browser
  resumption without CLI or agent intervention.
  Add state diagram for assessment states (RUNNING, PAUSED, COMPLETED, CLOSED_EARLY, TIMED_OUT).
2026-11-11 08:02:00 -05:00

3.4 KiB

ADR-0002: Harness-Agnostic Process Lifecycle

  • Status: Accepted
  • Date: 2026-11-10

Context

When an AI agent or skill invokes live-quiz, the execution must not block agent reasoning indefinitely, yet the agent must be notified when the assessment concludes or suspends. We needed a process coordination mechanism that works cleanly without tight coupling to proprietary agent harnesses, while correctly distinguishing between process exit and assessment completion.

Decision

Design live-quiz as a standard foreground UNIX process whose termination signals that an execution cycle has ended, but not necessarily that the assessment has concluded:

  1. Independent Lifecycles: \text{Process State (Running / Exited)} \neq \text{Assessment State (RUNNING / PAUSED / COMPLETED)} A process exit indicates only that the current HTTP execution cycle has ended.
  2. Structured Lifecycle Outcome: Upon process termination, live-quiz emits a machine-readable JSON outcome on stdout:
    • FINALIZED: The assessment reached a terminal state (COMPLETED, CLOSED_EARLY, TIMED_OUT). attempt.json was durably exported. Caller proceeds to evaluation.
    • SUSPENDED: The assessment was paused and the 2-hour grace period expired (or process terminated). The SQLite journal is retained. Caller does not invoke evaluation.
    • ERROR: An operational error occurred. The SQLite journal is retained for recovery.
  3. Sequence Diagram:
sequenceDiagram
    autonumber
    actor Learner
    participant Browser
    participant Server as live-quiz Server
    participant SQLite as SQLite Journal
    participant Caller as Agent / Harness

    Learner->>Browser: Click Pause
    Browser->>Server: POST /api/session/pause
    Server->>SQLite: Commit drafts & transition status to PAUSED
    SQLite-->>Server: Transaction committed
    Server-->>Browser: 200 OK (Suspension confirmed)
    Browser->>Learner: Display "Assessment Paused" + Resume button

    alt Resumed within 2-hour grace period
        Learner->>Browser: Click Resume
        Browser->>Server: POST /api/session/resume
        Server->>SQLite: Commit status RUNNING & unfreeze clock
        Server-->>Browser: 200 OK
    else Grace period (2h) expires without resume
        Server->>Caller: Process exits (stdout: outcome=SUSPENDED)
        Caller->>Caller: Inspect outcome: SUSPENDED (Do NOT invoke Evaluator)
    end

Alternatives Considered

  • Treating Every Process Exit as Assessment Completion: Rejected. Conflating process termination with assessment finalization leads to evaluating incomplete paused attempts.
  • Immediate Process Exit on Pause: Rejected. Turning an ordinary short interruption (e.g. 2-minute phone call) into an unrecoverable dead browser tab destroys UX.
  • Antigravity Sidecars and agentapi: Rejected. Coupled to internal language server environment variables.

Consequences

  • Positive: Complete decoupling from harness internals; standard OS process semantics (exit 0); portable across Antigravity, Claude Code, terminal shells, and CI pipelines.
  • Negative / Trade-offs: Requires the calling host environment or user to manage process execution (e.g. running as a background task).