diff --git a/README.md b/README.md index ca8b744..9c0d969 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,54 @@ npx --no-install torch-lock unpin-memory --id npx --no-install torch-lock memory-stats ``` +### Prompt Governance & Versioning CLI + +Agent prompts are changed through a governance workflow that archives the previous version before overwriting, enabling full rollback. + +```bash +# Propose a change to an agent prompt +npx --no-install torch-lock proposal create \ + --agent my-agent \ + --target src/prompts/daily/my-agent.md \ + --content /path/to/new-content.md \ + --reason "Add missing EXIT CRITERIA section" + +# List pending proposals +npx --no-install torch-lock proposal list +npx --no-install torch-lock proposal list --status pending + +# Inspect or apply a proposal +npx --no-install torch-lock proposal show --id +npx --no-install torch-lock proposal apply --id +npx --no-install torch-lock proposal reject --id --reason "..." + +# List available archived versions of a prompt +npx --no-install torch-lock rollback --target src/prompts/daily/my-agent.md --list + +# Roll back to the most recent archived version +npx --no-install torch-lock rollback --target src/prompts/daily/my-agent.md + +# Roll back to a specific version by hash fragment +npx --no-install torch-lock rollback --target src/prompts/daily/my-agent.md --strategy +``` + +### State Backup CLI + +Snapshot agent runtime state (long-term memory and scheduler state) to a timestamped directory under `.torch/backups/`. + +```bash +# Create a snapshot +npx --no-install torch-lock backup + +# List existing snapshots +npx --no-install torch-lock backup --list + +# Write snapshot to a custom directory +npx --no-install torch-lock backup --output /path/to/backup-dir +``` + +See [docs/prompt-versioning.md](docs/prompt-versioning.md) for the full workflow, restore procedure, and storage layout. + ### Configuration (`torch-config.json`) Create a `torch-config.json` file in your project root to configure TORCH for your repository. You can use the included `torch-config.example.json` as a template. diff --git a/TORCH.md b/TORCH.md index ee5767e..7a41b6e 100644 --- a/TORCH.md +++ b/TORCH.md @@ -425,6 +425,54 @@ The lock CLI resolves roster names in this order: 3. Preserve database state for post-incident analysis; do not drop or rewrite memory tables during rollback. 4. Keep prune actions in `dry-run` (or disabled) until lifecycle policy and data integrity are revalidated. +## Prompt Versioning & State Backup + +### How prompt changes are governed + +Every agent prompt in `src/prompts/daily/` and `src/prompts/weekly/` must be changed through the governance workflow — direct file edits skip the archive and break rollback lineage. + +**Proposal → Apply → Rollback cycle:** + +```bash +# 1. Propose a change +torch-lock proposal create \ + --agent \ + --target src/prompts/daily/.md \ + --content /path/to/new.md \ + --reason "reason" + +# 2. Review and apply +torch-lock proposal list --status pending +torch-lock proposal show --id +torch-lock proposal apply --id # archives old version, writes new +torch-lock proposal reject --id --reason "..." + +# 3. Inspect available versions +torch-lock rollback --target src/prompts/daily/.md --list + +# 4. Roll back (defaults to most recent archive; falls back to git) +torch-lock rollback --target src/prompts/daily/.md +torch-lock rollback --target src/prompts/daily/.md --strategy +``` + +Archives are stored in `.torch/prompt-history/` with filenames that embed an ISO timestamp and SHA-256 hash (`__.md`) alongside a `.meta.json` sidecar recording who applied the change, why, and when. + +### State backup + +Runtime state lives outside git. Snapshot it before destructive operations or on a schedule: + +```bash +torch-lock backup # creates .torch/backups// +torch-lock backup --list # list all snapshots +``` + +Files captured per snapshot: +- `.scheduler-memory/memory-store.json` (agent long-term memory) +- `task-logs/daily/.scheduler-run-state.json` (scheduler deferral state) + +See [docs/prompt-versioning.md](docs/prompt-versioning.md) for the full reference including restore steps and storage layout. + + ## Offline & Air-Gapped Installation TORCH is designed to operate in diverse environments, including high-security, air-gapped, or offline networks where direct access to the npm registry is restricted.