# AgentOps (strict rules)
# Goal: Maximize resumability and stable execution under session interruption.

## Start (mandatory)
- Read/restore in this order:
  1) handoff
  2) snapshot
  3) checkpoint
  4) journal (replay)
- If resume state is incomplete:
  - run ops_resume_brief (or equivalent) and emit a short brief
- Identify active ticket (status != done) and resume it.

## Planning flow (mandatory)
- User provides docs/draft.md.
- Generate docs/plan.md with phases.
- Split phases into tasks and generate:
  - docs/tickets_list.json (metadata)
  - docs/pX-tY.json (full ticket with status/inputs/outputs/deps)
- Ticket status enum: planned, in-progress, checking, verified, committed, done, blocked.

## Work loop (mandatory)
- Tickets are the only unit of work.
- For any code change:
  1) Set status -> in-progress
  2) Implement smallest safe change
  3) Run "${VERIFY_REL}"
     - If fails: fix and repeat
  4) Set status -> checking
     - Compare acceptance_criteria AND plan.md to avoid omissions
  5) Set status -> verified
  6) Commit changes
  7) Set status -> committed
  8) Update snapshot/checkpoint
  9) Set status -> done

## Persistence & logging (mandatory)
- Always record events for plan/task/progress/verify/commit.
- Keep log outputs short (summaries over full diffs).
- Prefer diff stats over full diffs.

## Handoff & session safety (mandatory)
- When a tool execution adds/modifies files:
  1) ops_compact_context (compact context)
  2) ops_capture_state (snapshot + checkpoint)
  3) ops_handoff_export (handoff summary, optional file write)

## Tooling (mandatory)
- Prefer MCP tools if available.
- Use:
  - journal_append
  - snapshot_save
  - checkpoint_update
  - roll_forward_replay / continue_state_rebuild (if needed)
  - ops_compact_context
  - ops_handoff_export
  - ops_resume_brief
  - repo_commit
- Always pass CWD as workspace_root to MCP tools.

## Commit rules (mandatory)
- After verify: check repo status; commit only if changes exist.
- Commit message: ~80 chars, add scope if useful.

## Token discipline (mandatory)
- Keep outputs short; avoid large logs.
- Prefer summaries and diff stats.
