9e8d6f9579
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 4602fdee (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>
68 lines
2.6 KiB
Python
68 lines
2.6 KiB
Python
"""PostCompact hook: re-inject economy rules after auto-compaction.
|
|
Reads state file (persists on disk after compaction), produces
|
|
additionalContext same as economy-mode.py would on UserPromptSubmit."""
|
|
import json
|
|
import os
|
|
import sys
|
|
import tempfile
|
|
|
|
try:
|
|
sys.stdin.reconfigure(encoding="utf-8", errors="replace")
|
|
except Exception:
|
|
pass
|
|
|
|
|
|
LEVEL_TOPLINE = {
|
|
100: None,
|
|
75: "Жёсткие/мета OFF: НЕ заявлять passed без запуска, НЕ cherry-pick, НЕ anchor на 1й гипотезе",
|
|
50: "Жёсткие/мета OFF + verify memory + ≥2 гипотезы на debug + full test output",
|
|
25: "verify-before-completion на ≥2-step задачах, full reads ≤5000, Grep limit 500",
|
|
5: "5% (0% без избыточности): full reads / тесты / ≥3 гипотезы / TDD как в 0%; без re-read CLAUDE.md, тест-каденс по логическим блокам, gitleaks-full-history -> pre-push, §12.2-floor для plan/brainstorm гейтов; скорость: параллельные tool-вызовы, без re-read неизменённого, дешёвая модель на механику, run_in_background, без лишних вопросов, фокус/компакт сессии",
|
|
0: "ВСЕ паттерны OFF: full reads, full test output, ≥3 гипотезы на debug, verify perceived 'готово'",
|
|
}
|
|
|
|
|
|
def main() -> None:
|
|
try:
|
|
data = json.load(sys.stdin)
|
|
except Exception:
|
|
return
|
|
sid = data.get("session_id")
|
|
if not sid:
|
|
return
|
|
state_path = os.path.join(tempfile.gettempdir(), f"claude-economy-{sid}.json")
|
|
if not os.path.exists(state_path):
|
|
return
|
|
try:
|
|
with open(state_path, encoding="utf-8") as f:
|
|
state = json.load(f)
|
|
except Exception:
|
|
return
|
|
level = state.get("level")
|
|
if level is None or level == 100:
|
|
return
|
|
topline = LEVEL_TOPLINE.get(level)
|
|
if not topline:
|
|
return
|
|
label = state.get("label", f"{level}%")
|
|
tail = state.get("tail", "")
|
|
set_at = state.get("set_at", "unknown time")
|
|
msg = (
|
|
f"=== POST-COMPACTION RE-INJECT ===\n"
|
|
f"Active economy mode: {label} — {tail}\n"
|
|
f"(originally set at: {set_at})\n\n"
|
|
f"Rules summary: {topline}\n\n"
|
|
f"Full rules — re-read state file or check economy-mode.py LEVELS[{level}]['rules']."
|
|
)
|
|
out = {
|
|
"hookSpecificOutput": {
|
|
"hookEventName": "PostCompact",
|
|
"additionalContext": msg,
|
|
}
|
|
}
|
|
sys.stdout.write(json.dumps(out, ensure_ascii=True))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|