Skip to content

ALP Specification — Lifecycle

Version: 80.0.0 Status: Stable


1. Lifecycle Flow

mermaid
flowchart LR
    discover --> understand
    understand --> plan
    plan --> design
    design --> implement
    implement --> test
    test --> review
    review --> refactor
    refactor --> verify
    verify --> complete

2. Overview

ALP defines a deterministic lifecycle that every feature progresses through. The lifecycle ensures that work follows a structured, verifiable path from discovery to completion.

The lifecycle is NOT optional. Every @feature MUST declare its current lifecycle_stage. Agents MUST respect the lifecycle ordering when planning and executing work.


2. Lifecycle Stages

Every feature progresses through these 10 stages in order:

discover → understand → plan → design → implement → test → review → refactor → verify → complete

2.1 Stage Definitions

Stage 1: discover

Purpose: Identify what needs to be built.

PropertyValue
InputsUser requirements, PRD, stakeholder needs
OutputsFeature description, initial scope
VerificationFeature has a clear description and scope
Completion RuleFeature is understood well enough to analyze

Agent actions:

  • Read project goals
  • Identify the feature's purpose
  • Define initial scope boundaries
  • Create the @feature object

Stage 2: understand

Purpose: Deeply analyze requirements and context.

PropertyValue
InputsFeature description, project context, existing codebase
OutputsDetailed requirements, edge cases, constraints
VerificationAll requirements documented, no ambiguity
Completion RuleAgent can explain the feature without external input

Agent actions:

  • Analyze existing code that relates to this feature
  • Identify edge cases
  • Document business rules
  • Identify constraints and dependencies
  • Create @context object for this feature
  • Record unknowns in @memory entries

Stage 3: plan

Purpose: Break the feature into atomic tasks.

PropertyValue
InputsDetailed requirements, architecture, dependencies
OutputsTask list with dependencies, estimates, assignments
VerificationAll tasks have acceptance criteria and verification rules
Completion RuleTask graph is complete and acyclic

Agent actions:

  • Create @task objects for each unit of work
  • Define depends_on relationships
  • Estimate time and difficulty for each task
  • Assign agents to tasks
  • Define acceptance criteria for each task
  • Define verification rules for each task
  • Build the dependency graph

Stage 4: design

Purpose: Design the technical approach.

PropertyValue
InputsTask list, architecture, constraints
OutputsTechnical design, API contracts, data models
VerificationDesign reviewed, decisions documented
Completion RuleAll significant design decisions are recorded

Agent actions:

  • Define data models and schemas
  • Design API contracts
  • Choose implementation patterns
  • Record decisions in @decision objects
  • Update @context objects with architecture details
  • Identify potential risks and document them

Stage 5: implement

Purpose: Write the code.

PropertyValue
InputsTask list, design, context
OutputsSource code, configurations
VerificationCode compiles/lints, basic functionality works
Completion RuleAll tasks are implemented

Agent actions:

  • Execute tasks in dependency order
  • Write source code
  • Create @artifact objects for each file produced
  • Update task status markers
  • Record errors in @memory entries
  • Checkpoint progress regularly

Stage 6: test

Purpose: Verify the implementation works correctly.

PropertyValue
InputsImplemented code, acceptance criteria
OutputsTest results, coverage reports
VerificationAll tests pass, coverage meets threshold
Completion RuleAll @verify blocks with required: true pass

Agent actions:

  • Write unit tests
  • Write integration tests
  • Run @verify commands
  • Record test results
  • Fix failing tests
  • Update @accept criteria status markers

Stage 7: review

Purpose: Quality assurance and code review.

PropertyValue
InputsImplemented and tested code
OutputsReview feedback, approval or revision requests
VerificationAll review criteria satisfied
Completion RuleReview approved by designated agent

Agent actions:

  • Review code for quality, patterns, and standards
  • Check compliance with @rule objects
  • Check compliance with @constraint objects
  • Provide feedback
  • Request changes if needed
  • Approve when all criteria met

Stage 8: refactor

Purpose: Improve code quality without changing behavior.

PropertyValue
InputsReviewed code, improvement suggestions
OutputsRefactored code
VerificationAll existing tests still pass
Completion RuleCode meets quality standards, no regressions

Agent actions:

  • Improve code structure
  • Reduce duplication
  • Improve naming
  • Optimize performance
  • Ensure all tests still pass after changes

Stage 9: verify

Purpose: Final verification before marking complete.

PropertyValue
InputsRefactored code, all verification rules
OutputsFinal verification report
VerificationALL verification rules pass (not just required ones)
Completion RuleZero failures in verification report

Agent actions:

  • Run ALL @verify blocks (required AND optional)
  • Run security checks
  • Run performance checks
  • Run accessibility checks
  • Generate verification report
  • Record results in @event objects

Stage 10: complete

Purpose: Feature is done.

PropertyValue
InputsVerification report
OutputsUpdated project state, completion event
VerificationVerification report shows all pass
Completion RuleFeature marked complete, state updated

Agent actions:

  • Mark all tasks as [x]
  • Update feature lifecycle_stage to complete
  • Update feature progress to 100
  • Update project state if needed
  • Create milestone @event
  • Update @memory with lessons learned
  • Update @state checkpoint

3. State Transitions

3.1 Valid Transitions

The lifecycle is primarily linear, but the following backward transitions are allowed:

discover → understand → plan → design → implement → test → review → refactor → verify → complete
                                            ↑                  ↑
                                            └──── review ──────┘  (review can send back to implement)
                                            ↑         ↑
                                            └─ test ──┘  (test failures can send back to implement)

                                            refactor ──────────┘  (refactor can go back to test)

                                            verify ───────────────────────┘  (verify can go back to refactor)

Forward transitions: Any stage can advance to the next stage in sequence.

Backward transitions (allowed):

FromToReason
testimplementTest failures require code changes
reviewimplementReview feedback requires changes
refactortestMust re-verify after refactoring
verifyrefactorFinal verification found issues
verifyimplementCritical issues found in final check

Invalid transitions (NOT allowed):

FromToWhy
implementdiscoverCannot go back to discovery after implementation
completeAnyCompleted features do not reopen (create a new feature)
planimplementCannot skip design
discoverimplementCannot skip planning and design

3.2 Transition Recording

Every stage transition MUST be recorded in the feature's @lifecycle block or in an @event object:

@event
  id: evt-auth-to-implement
  type: state_change
  name: "feat-auth moved to implement"
  payload: |
    Previous stage: design
    New stage: implement
    Reason: Design review approved, ready to implement
    Tasks ready: 5
  timestamp: 2025-07-14T14:00:00Z
  source: -> agent-planner
  related_to: -> feat-auth

4. Project State Machine

Separate from the feature lifecycle, the project itself has a state:

planning → architecture → development → testing → review → completed
    ↓          ↓              ↓            ↓         ↓
  blocked    blocked        blocked      blocked   blocked
    ↓          ↓              ↓            ↓         ↓
  waiting    waiting        waiting      waiting   waiting

4.1 Project States

StateDescriptionEntry Condition
planningInitial planning phaseProject created
architectureDefining architecturePlanning complete
developmentActive developmentArchitecture approved
testingIntegration/system testingCore features implemented
reviewFinal review before releaseTesting complete
completedProject is doneAll features verified
blockedCannot proceedExternal dependency or issue
waitingWaiting for external inputDecision or resource needed
archivedNo longer activePost-completion or abandoned

4.2 Valid Project State Transitions

FromToCondition
planningarchitectureProject goals and features defined
architecturedevelopmentArchitecture decisions documented
developmenttestingCore features in test or review lifecycle stage
testingreviewAll critical tests passing
reviewcompletedFinal verification passed
completedarchivedProject archived
AnyblockedBlocking issue identified
AnywaitingWaiting for external input
blockedPrevious stateBlocking issue resolved
waitingPrevious stateInput received

5. Checkpoint System

Checkpoints capture project state at a point in time, enabling recovery after interruption.

5.1 When to Checkpoint

Agents SHOULD create a checkpoint:

  • After completing any task
  • After a lifecycle stage transition
  • Before any risky operation
  • At the end of any agent session

5.2 Checkpoint Format

Checkpoints are recorded in .alp/state.alp:

@state
  id: state-project
  current: development
  checkpoint: "chk-2025-07-14-003"
  checkpoint_timestamp: 2025-07-14T20:30:00Z

5.3 Resuming from Checkpoint

When an agent begins a new session, it SHOULD:

  1. Read .alp/state.alp to find the latest checkpoint
  2. Read .alp/memory.alp to load relevant memory
  3. Identify incomplete tasks (status [~] or [ ])
  4. Resume work from the highest-priority incomplete task
  5. Respect dependency ordering

6. Lifecycle Compliance

6.1 Mandatory Rules

  1. Features MUST NOT skip lifecycle stages (forward)
  2. Features in complete MUST NOT be reopened
  3. All tasks in a feature MUST be [x] before the feature can reach complete
  4. All required: true verifications MUST pass before complete
  5. Backward transitions MUST record the reason in an @event

6.2 Agent Responsibilities

Lifecycle StageResponsible Agent Role
discoverplanner
understandplanner, architect
planplanner
designarchitect
implementfrontend, backend, fullstack
testqa, implementing agent
reviewreviewer
refactorimplementing agent
verifyqa
completeplanner (marks complete)