Files
portal/tools/test-rollback.test.mjs
T
Дмитрий f6b52df613 feat(brain): rollback infra + snapshots + e2e-verified BEFORE any destruction (phase 1 task 1)
Establishes a proven rollback mechanism for the LLM-first router overhaul before
any destructive step. Without this, Phase 1-3 work would be irreversible.

What this commit adds:
- Git tag 'brain-pre-llm-bootstrap' on origin/main 9d4a30c3 (pre-overhaul state).
- docs/archive/llm-bootstrap-2026-05/ archive structure with:
  - settings-snapshot/  — pre-overhaul ~/.claude/settings.json + project settings
  - user-hooks/         — all 14 ~/.claude/hooks/*.py pre-overhaul (incl. §12 ones)
  - runtime-flags-snapshot/ — pre-overhaul ~/.claude/runtime/*-mode.json
  - nodes-yaml-archive/ — pre-overhaul docs/registry/nodes.yaml
- tools/test-rollback.mjs    — rollback planner + executor (--dry-run / --execute)
- tools/test-rollback.test.mjs — TDD: 3 tests for planRollback() contract
- ROLLBACK.md — operator runbook with from->to manifest

E2E smoke proof was run BEFORE this commit (Task 1 step 9):
1. Created TEMP marker commit on top of tag with a dummy file + runtime flag.
2. Ran 'test-rollback.mjs --dry-run' (OK) then '--execute' (user state restored).
3. Reverted git-tracked state and verified marker + flag gone.
4. Verified Task 1 untracked files survived the rollback.

Smoke discovered a bug in the plan's procedure ('git checkout tag -- .' +
'git reset --soft tag' does NOT delete files committed-after-tag — they stay
staged). ROLLBACK.md uses 'git reset --hard <tag>' instead, which correctly
removes overhaul-added tracked files while preserving untracked artefacts
(episodes-*.jsonl, observer notes).

TDD: 3/3 green on test-rollback.test.mjs. Full vitest tools/: 546 passed (was
543 baseline, +3 from this commit), 4 pre-existing 'No test suite' failures
on tools/ruflo-* and tools/subagent-prompt-prefix.test.mjs (out of scope).

Plan: docs/superpowers/plans/2026-05-25-llm-first-router-overhaul.md Task 1.
Spec: docs/superpowers/specs/2026-05-24-llm-first-router-overhaul-design.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-25 14:28:01 +03:00

21 lines
892 B
JavaScript

// tools/test-rollback.test.mjs — TDD spec for the rollback planner.
// Plan: docs/superpowers/plans/2026-05-25-llm-first-router-overhaul.md Task 1 step 4.
import { describe, it, expect } from 'vitest';
import { planRollback } from './test-rollback.mjs';
describe('planRollback', () => {
it('restores git-tracked state via the pre-overhaul tag + lists user-level snapshots', () => {
const plan = planRollback();
expect(plan.gitTag).toBe('brain-pre-llm-bootstrap');
expect(plan.userLevelRestores.some((r) => r.to.includes('settings.json'))).toBe(true);
});
it('resets runtime flags from snapshot (not hardcoded list)', () => {
expect(planRollback().flagStrategy).toBe('restore-snapshot-delete-new');
});
it('lists episodes as PRESERVED, not reverted (G5/G6)', () => {
expect(planRollback().preserve.some((x) => x.includes('episodes'))).toBe(true);
});
});