- Imported `randomInt` from `node:crypto` in `src/lock-publisher.mjs` to fix CI failure.
- Centralized `withTimeout` and `mergeRelayList` in `src/utils.mjs`.
- Updated `src/lock-utils.mjs` to re-export them.
- Removed local redefinitions in `src/lock-ops.mjs` and `src/lock-publisher.mjs`.
- Fixed `test/utils.test.mjs` imports.
- Verified all tests pass.
This resolves the N/A documentation task by ensuring the codebase is in a valid state.
Co-authored-by: PR0M3TH3AN <[email protected]>
Refactor cmdRollback to support dependency injection and add comprehensive unit tests covering validation, version listing, and rollback operations.
- Refactor `src/cmd-rollback.mjs` to accept `deps` argument.
- Create `test/cmd-rollback.test.mjs` with test cases for happy paths and error conditions.
Co-authored-by: PR0M3TH3AN <[email protected]>
- 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
Implement a comprehensive governance system to manage agent prompt changes safely.
Key features:
- **Proposal Workflow:** Prompt changes are now "proposals" stored in `src/proposals/` with metadata and diffs.
- **Governance Agent:** A new `governance-agent` reviews and applies proposals using `scripts/governance/process-proposals.mjs`.
- **Validation:** Strict validation ensures changes are limited to allowed directories (`src/prompts/daily|weekly`) and preserve required headers.
- **Lock Enhancements:** Lock events now include `promptHash`, `promptPath`, and `gitCommit` for full auditability.
- **Rollback:** New `torch-lock rollback` command restores prompts from local history (`.torch/prompt-history/`) or git.
- **CLI:** Added `proposal` (create, list, show, apply, reject) and `rollback` commands.
This establishes a "Stage -> Evaluate -> Apply" gate for prompt evolution, preventing silent drift and ensuring constitutional stability.
Co-authored-by: PR0M3TH3AN <[email protected]>