Command Pipeline

/dr-archive

Archive completed task with mandatory reflection and evolution proposals

Overview

/dr-archive is the final pipeline stage. It resolves the target task, verifies all git repos are clean, runs a mandatory reflection (Step 0.5) that generates evolution proposals, packages the task into a permanent archive document, updates the backlog, handles follow-up task creation, and resets the workspace. Since v1.10.0 (<TASK-ID>), the previously separate /dr-reflect command is consolidated here because an "optional mandatory gate" was identified as a design defect.

Usage

/dr-archive
/dr-archive cancel
/dr-archive cancel TASK-NNNN

What It Does

  1. Step 0 — Task Resolution — resolves which task is being archived from the argument or by disambiguation when multiple tasks are active.
  2. Step 0.1 — Pre-Archive Git Check (mandatory, multi-agent aware since v1.18.0 / <TASK-ID>) — classifies every touched repo as workspace (shared by parallel agent sessions) or project (single-agent). For workspace repos, scripts/pre-archive-check.sh --task-id <ID> --shared <repo> classifies each modified file's hunks as own, foreign, mixed, or unattributed: foreign-only is NOT a blocker (parallel sessions own their hunks), but own/mixed/unattributed hunks block until the patch-staging recipe (git add -p or non-interactive blob-swap) is applied. For project repos, the legacy <TASK-ID> contract (any uncommitted change blocks; 3-way prompt: commit / accept pending / abort) is unchanged.
  3. Step 0.5 — Reflect (mandatory, non-skippable) — loads the reflecting skill and executes the full reflection workflow:
    • Creates datarim/reflection/reflection-[task_id].md
    • Generates evolution proposals classified as Class A (safe, apply now) or Class B (requires PRD update first)
    • Presents Class A proposals for approval; applies approved ones to runtime
    • Logs changes in datarim/history/evolution-log.md
    • Runs health-metrics check; suggests /dr-optimize if thresholds exceeded
    • Notes follow-up tasks for Step 4

    This step cannot be skipped. No --no-reflect flag exists. On failure, archive stops — re-running re-enters Step 0.5.

  4. Step 1 — Determine Archive Area — extracts the prefix from the task ID (e.g., INFRA from <TASK-ID>) and maps it to an archive subdirectory.
  5. Step 2 — Create Archive Document — writes documentation/archive/{area}/archive-{task_id}.md following the canonical templates/archive-template.md (v2.14.0+, <TASK-ID>). The archive carries four operator-facing top sections in strict order — «Начальная задача» (one Russian sentence sourced from the operator brief), «Как решили» (single-level bullet list mapping every brief item to a quoted bullet + Russian status word + one or two plain-language sentences; expectations from tasks/{ID}-expectations.md fold into the same list with marker «(уточнение брифа)»), «Артефакты задачи» (what was produced or changed), «Следующие шаги» (concrete /dr-* commands or operator actions, or «всё закрыто»). Under a --- horizontal rule sits an audit addendum carrying ### verification_outcome, ### Acceptance Criteria, ### Lessons Learned, ### Operator Handoff, ### Related. Status words: «выполнено» / «частично» / «не выполнено» / «неприменимо» — never the schema enum met/partial/missed/n-a. Includes a Known Loss Verification Gate: before recording any content as "permanently lost", the agent runs a 5-channel disaster recovery checklist. Only after all channels are exhausted may a loss claim enter the archive.
  6. Step 3 — Update Backlog — removes the completed task from backlog.md. The committed archive document is the permanent record; there is no second backlog file.
  7. Step 4 — Follow-up Tasks — reads follow-up items from the reflection document and asks whether to add them as new backlog entries.
  8. Step 5 — Update Tasks Table — adds a row to the Archived Tasks table in tasks.md.
  9. Step 6 — Update Context — removes the archived task from ## Active Tasks in activeContext.md, prepends it to ## Recently Completed. Does not reset the entire file — other active tasks are preserved.

Cancellation Mode

If you say "cancel task" or provide a task ID to cancel, the command writes documentation/archive/cancelled/archive-{task_id}.md, removes the task from the active backlog and context, and skips reflection because the task was not completed.

Arguments

Optional. Use cancel to cancel instead of archive. Optionally specify a task ID for multi-task disambiguation.

Output

Creates: documentation/archive/{area}/archive-{task_id}.md, datarim/reflection/reflection-[task_id].md. Removes the completed entry from datarim/backlog.md, datarim/tasks.md, and datarim/activeContext.md; approved framework evolution is recorded in datarim/history/evolution-log.md. The retired backlog-archive.md is never written.

Example Session

> /dr-archive

Task Resolution: <TASK-ID> (only active task)

Pre-Archive Clean-Git Check:
  arcanada workspace: clean
  Projects/Datarim/code/datarim: clean

Step 0.5 — Reflection:
  Created: datarim/reflection/reflection-<TASK-ID>.md
  Evolution proposals:
    [Class A] Update security.md with OAuth patterns (approved → applied)
    [Class B] Refactor auth agent — deferred (requires PRD)
  Health metrics: within thresholds

Archiving <TASK-ID>...
  Area: auth (mapped from AUTH prefix)
  Archive: documentation/archive/auth/archive-<TASK-ID>.md

Backlog updated:
  Removed <TASK-ID> from backlog.md
  Permanent record: documentation/archive/auth/archive-<TASK-ID>.md

Follow-up tasks from reflection:
  1. Add rate limiting to AUTH module
  2. Write user-facing auth documentation
Add to backlog? (y/n)

Context updated. Ready for next task.

Next step: /dr-init or /dr-dream (5+ docs since last run)

Related Commands

  • /dr-qa — previous stage: quality verification
  • /dr-compliance — optional previous stage: hardening
  • /dr-init — start a new task
  • /dr-dream — suggested if knowledge base has grown