mirror of
https://github.com/PR0M3TH3AN/TORCH.git
synced 2026-11-04 11:51:53 +00:00
feat(governance): add prompt versioning, rollback --list, and state backup
- governance/index.js: archive filenames now include ISO timestamp for deterministic sorting (<base>_<ts>_<hash>.md); write .meta.json sidecar on every archive with proposalId, author, reason, and archivedAt - governance/index.js: add listPromptVersions(target) — returns archived versions for a prompt sorted newest-first with sidecar metadata surfaced - cmd-rollback.mjs: add --list flag to list available versions without restoring (delegates to listPromptVersions) - cli-parser.mjs: add --list and --output flags - lib.mjs: pass list flag to cmdRollback; add backup command dispatch - cmd-backup.mjs: new torch-lock backup command — snapshots .scheduler-memory/memory-store.json and scheduler run state to .torch/backups/<timestamp>/; supports --output override and --list - docs/prompt-versioning.md: comprehensive guide to the full proposal → apply → list-versions → rollback workflow, state backup and restore procedure, and storage location reference - test/governance.test.mjs: 7 scenario-based tests (SCN-proposal-create, SCN-proposal-list, SCN-proposal-reject, SCN-archive-naming, SCN-version-list, SCN-rollback-latest, SCN-rollback-hash) https://claude.ai/code/session_01Ndq2D72Kp77BYo4owD63uY
This commit is contained in:
7 files changed
+914
-47
No files matched your search
+14
-3
@@ -1,12 +1,23 @@
|
||||
import { rollbackPrompt } from './services/governance/index.js';
|
||||
import { rollbackPrompt, listPromptVersions } from './services/governance/index.js';
|
||||
import { ExitError } from './errors.mjs';
|
||||
|
||||
export async function cmdRollback(target, strategy) {
|
||||
export async function cmdRollback(target, strategy, { list = false } = {}) {
|
||||
if (!target) {
|
||||
console.error('Usage: torch-lock rollback --target <path> [--strategy <hash|latest>]');
|
||||
console.error('Usage: torch-lock rollback --target <path> [--strategy <hash|latest>] [--list]');
|
||||
throw new ExitError(1, 'Missing target');
|
||||
}
|
||||
|
||||
if (list) {
|
||||
try {
|
||||
const versions = await listPromptVersions(target);
|
||||
console.log(JSON.stringify(versions, null, 2));
|
||||
} catch (e) {
|
||||
console.error(`Failed to list versions: ${e.message}`);
|
||||
throw new ExitError(1, 'List versions failed');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const effectiveStrategy = strategy || 'latest';
|
||||
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user