Skip to content

try-works/role-model / .agents/skills/recursive-mode

recursive-mode

Unverified

Repository workflow orchestration skill for staged implementation, locked artifacts, late-phase receipts, and durable memory maintenance. Use when executing recursive-mode runs, resuming a run, locking a phase, or verifying locks.

FileKindSize
.agent/PLANS.mdmarkdown2.6 KB
.codex/AGENTS.mdmarkdown7.5 KB
.gitattributesother522 B
.gitignoreother553 B
.recursive/AGENTS.mdmarkdown3.3 KB
.recursive/DECISIONS.mdmarkdown1.1 KB
.recursive/README.mdmarkdown8.5 KB
.recursive/RECURSIVE.mdmarkdown107.5 KB
.recursive/STATE.mdmarkdown1.6 KB
.recursive/config/recursive-router.jsonconfig1.4 KB
.recursive/memory/MEMORY.mdmarkdown3.3 KB
.recursive/memory/archive/.gitkeepother1 B
.recursive/memory/domains/.gitkeepother1 B
.recursive/memory/episodes/.gitkeepother1 B
.recursive/memory/incidents/.gitkeepother1 B
.recursive/memory/patterns/.gitkeepother1 B
.recursive/memory/skills/SKILLS.mdmarkdown4.3 KB
.recursive/memory/skills/availability/.gitkeepother1 B
.recursive/memory/skills/issues/.gitkeepother1 B
.recursive/memory/skills/patterns/.gitkeepother1 B
.recursive/memory/skills/patterns/delegated-verification-and-refresh.mdmarkdown1.7 KB
.recursive/memory/skills/patterns/phase8-skill-memory-promotion.mdmarkdown1.4 KB
.recursive/memory/skills/usage/.gitkeepother1 B
.recursive/memory/skills/usage/skill-discovery-and-evaluation.mdmarkdown1.6 KB
.recursive/run/.gitkeepother1 B
AGENTS.mdmarkdown7.8 KB
LICENSEother11.1 KB
README.mdmarkdown17.8 KB
SKILL.mdskill md13.1 KB
agents/code-reviewer.mdmarkdown6.1 KB
agents/implementer.mdmarkdown6.3 KB
agents/openai.yamlconfig202 B
docs/templates/commands/check-reusable-repo-hygiene.mdmarkdown1.3 KB
docs/templates/commands/recursive-closeout.mdmarkdown2.8 KB
docs/templates/commands/recursive-init.mdmarkdown2.2 KB
docs/templates/commands/recursive-lock.mdmarkdown1.3 KB
docs/templates/commands/recursive-review-bundle.mdmarkdown3.6 KB
docs/templates/commands/recursive-status.mdmarkdown2.0 KB
docs/templates/commands/recursive-subagent-action.mdmarkdown4.2 KB
docs/templates/commands/test-recursive-mode-smoke.mdmarkdown3.4 KB
docs/templates/hooks/hooks.jsonconfig400 B
docs/templates/hooks/run-hook.cmdscript1.2 KB
docs/templates/hooks/session-start.ps1script3.6 KB
docs/templates/hooks/session-start.shscript3.5 KB
references/agents-block.mdmarkdown7.4 KB
references/artifact-template.mdmarkdown70.7 KB
references/benchmark-addon/recursive-benchmark/BENCHMARK-ADDON.mdmarkdown6.7 KB
references/benchmark-addon/recursive-benchmark/recursive-benchmark/BENCHMARK-ADDON.mdmarkdown6.7 KB
references/benchmark-addon/recursive-benchmark/recursive-benchmark/references/patterns.mdmarkdown4.9 KB
references/benchmark-addon/recursive-benchmark/references/patterns.mdmarkdown4.9 KB
references/benchmarks/README.mdmarkdown1.5 KB
references/benchmarks/local-first-planner/00-requirements.mdmarkdown3.3 KB
references/benchmarks/local-first-planner/README.mdmarkdown1.1 KB
references/benchmarks/local-first-planner/prompt-recursive-off.mdmarkdown1.1 KB
references/benchmarks/local-first-planner/prompt-recursive-on.mdmarkdown14.8 KB
references/benchmarks/local-first-planner/scoring-rubric.mdmarkdown1.3 KB
references/benchmarks/local-first-planner/starter/.gitignoreother30 B
references/benchmarks/local-first-planner/starter/README.mdmarkdown264 B
references/benchmarks/local-first-planner/starter/index.htmlother316 B
references/benchmarks/local-first-planner/starter/package.jsonmanifest628 B
references/benchmarks/local-first-planner/starter/src/App.test.tsxother334 B
references/benchmarks/local-first-planner/starter/src/App.tsxother971 B
references/benchmarks/local-first-planner/starter/src/main.tsxother238 B
references/benchmarks/local-first-planner/starter/src/styles.cssother976 B
references/benchmarks/local-first-planner/starter/src/test-setup.tsscript43 B
references/benchmarks/local-first-planner/starter/src/vite-env.d.tsscript38 B
references/benchmarks/local-first-planner/starter/tsconfig.app.jsonconfig552 B
references/benchmarks/local-first-planner/starter/tsconfig.jsonconfig89 B
references/benchmarks/local-first-planner/starter/vite.config.tsscript214 B
references/benchmarks/release-readiness-dashboard/00-requirements.mdmarkdown5.9 KB
references/benchmarks/release-readiness-dashboard/README.mdmarkdown1.2 KB
references/benchmarks/release-readiness-dashboard/prompt-recursive-off.mdmarkdown1.1 KB
references/benchmarks/release-readiness-dashboard/prompt-recursive-on.mdmarkdown14.8 KB
references/benchmarks/release-readiness-dashboard/scoring-rubric.mdmarkdown1.8 KB
references/benchmarks/release-readiness-dashboard/starter/.gitignoreother30 B
references/benchmarks/release-readiness-dashboard/starter/README.mdmarkdown272 B
references/benchmarks/release-readiness-dashboard/starter/index.htmlother324 B
references/benchmarks/release-readiness-dashboard/starter/package.jsonmanifest628 B
references/benchmarks/release-readiness-dashboard/starter/src/App.test.tsxother342 B
references/benchmarks/release-readiness-dashboard/starter/src/App.tsxother979 B
references/benchmarks/release-readiness-dashboard/starter/src/main.tsxother238 B
references/benchmarks/release-readiness-dashboard/starter/src/styles.cssother976 B
references/benchmarks/release-readiness-dashboard/starter/src/test-setup.tsscript43 B
references/benchmarks/release-readiness-dashboard/starter/src/vite-env.d.tsscript38 B
references/benchmarks/release-readiness-dashboard/starter/tsconfig.app.jsonconfig552 B
references/benchmarks/release-readiness-dashboard/starter/tsconfig.jsonconfig89 B
references/benchmarks/release-readiness-dashboard/starter/vite.config.tsscript214 B
references/benchmarks/scientific-calculator-rust/00-requirements.mdmarkdown4.1 KB
references/benchmarks/scientific-calculator-rust/README.mdmarkdown1.4 KB
references/benchmarks/scientific-calculator-rust/prompt-recursive-off.mdmarkdown1.1 KB
references/benchmarks/scientific-calculator-rust/prompt-recursive-on.mdmarkdown16.6 KB
references/benchmarks/scientific-calculator-rust/scoring-rubric.mdmarkdown1.5 KB
references/benchmarks/scientific-calculator-rust/starter/.gitignoreother14 B
references/benchmarks/scientific-calculator-rust/starter/Cargo.lockmanifest25.7 KB
references/benchmarks/scientific-calculator-rust/starter/Cargo.tomlmanifest226 B
references/benchmarks/team-capacity-board/00-requirements.mdmarkdown3.6 KB
references/benchmarks/team-capacity-board/README.mdmarkdown1.0 KB
references/benchmarks/team-capacity-board/prompt-recursive-off.mdmarkdown1.1 KB
references/benchmarks/team-capacity-board/prompt-recursive-on.mdmarkdown14.8 KB
references/benchmarks/team-capacity-board/scoring-rubric.mdmarkdown1.4 KB
references/benchmarks/team-capacity-board/starter/.gitignoreother30 B
references/benchmarks/team-capacity-board/starter/README.mdmarkdown264 B
references/benchmarks/team-capacity-board/starter/index.htmlother316 B
references/benchmarks/team-capacity-board/starter/package.jsonmanifest628 B
references/benchmarks/team-capacity-board/starter/src/App.test.tsxother334 B
references/benchmarks/team-capacity-board/starter/src/App.tsxother971 B
references/benchmarks/team-capacity-board/starter/src/main.tsxother238 B
references/benchmarks/team-capacity-board/starter/src/styles.cssother976 B
references/benchmarks/team-capacity-board/starter/src/test-setup.tsscript43 B
references/benchmarks/team-capacity-board/starter/src/vite-env.d.tsscript38 B
references/benchmarks/team-capacity-board/starter/tsconfig.app.jsonconfig552 B
references/benchmarks/team-capacity-board/starter/tsconfig.jsonconfig89 B
references/benchmarks/team-capacity-board/starter/vite.config.tsscript214 B
references/bootstrap/RECURSIVE.mdmarkdown109.9 KB
references/fixtures/tiny-tasks-smoke-recipe.mdmarkdown2.6 KB
references/local-first-web-app-checklist.mdmarkdown1.6 KB
references/plans-canonical.mdmarkdown10.8 KB
scripts/check-reusable-repo-hygiene.ps1script625 B
scripts/check-reusable-repo-hygiene.pyscript6.3 KB
scripts/install-recursive-mode.ps1script36.0 KB
scripts/install-recursive-mode.pyscript31.8 KB
scripts/install-recursive-mode.shscript363 B
scripts/lint-recursive-run.ps1script739 B
scripts/lint-recursive-run.pyscript127.4 KB
scripts/recursive-closeout.ps1script1015 B
scripts/recursive-closeout.pyscript24.0 KB
scripts/recursive-init.ps1script18.7 KB
scripts/recursive-init.pyscript12.6 KB
scripts/recursive-lock.ps1script677 B
scripts/recursive-lock.pyscript12.6 KB
scripts/recursive-review-bundle.ps1script2.9 KB
scripts/recursive-review-bundle.pyscript22.1 KB
scripts/recursive-router-cli-configure.ps1script86 B
scripts/recursive-router-cli-configure.pyscript230 B
scripts/recursive-router-cli-init.ps1script81 B
scripts/recursive-router-cli-init.pyscript225 B
scripts/recursive-router-cli-invoke.ps1script83 B
scripts/recursive-router-cli-invoke.pyscript227 B
scripts/recursive-router-cli-probe.ps1script82 B
scripts/recursive-router-cli-probe.pyscript226 B
scripts/recursive-router-cli-resolve.ps1script84 B
scripts/recursive-router-cli-resolve.pyscript228 B
scripts/recursive-router-cli-validate.ps1script85 B
scripts/recursive-router-cli-validate.pyscript229 B
scripts/recursive-router-configure.ps1script798 B
scripts/recursive-router-configure.pyscript2.8 KB
scripts/recursive-router-init.ps1script490 B
scripts/recursive-router-init.pyscript925 B
scripts/recursive-router-invoke.ps1script1.5 KB
scripts/recursive-router-invoke.pyscript4.4 KB
scripts/recursive-router-probe.ps1script735 B
scripts/recursive-router-probe.pyscript1.6 KB
scripts/recursive-router-resolve.ps1script803 B
scripts/recursive-router-resolve.pyscript1.6 KB
scripts/recursive-router-validate.ps1script494 B
scripts/recursive-router-validate.pyscript804 B
scripts/recursive-status.ps1script674 B
scripts/recursive-status.pyscript97.7 KB
scripts/recursive-subagent-action.ps1script5.8 KB
scripts/recursive-subagent-action.pyscript12.4 KB
scripts/recursive-training-extract.ps1script586 B
scripts/recursive-training-extract.pyscript1.0 KB
scripts/recursive-training-grpo.ps1script1.2 KB
scripts/recursive-training-grpo.pyscript47.2 KB
scripts/recursive-training-loader.ps1script2.3 KB
scripts/recursive-training-loader.pyscript20.1 KB
scripts/recursive-training-mcp.ps1script721 B
scripts/recursive-training-mcp.pyscript10.1 KB
scripts/recursive-training-phase8-trigger.ps1script1.4 KB
scripts/recursive-training-phase8-trigger.pyscript4.0 KB
scripts/recursive-training-sync.ps1script735 B
scripts/recursive-training-sync.pyscript6.9 KB
scripts/recursive_phase_rules.pyscript12.7 KB
scripts/recursive_router_cli_lib.pyscript77 B
scripts/recursive_router_lib.pyscript84.5 KB
scripts/run-recursive-benchmark.ps1script2.1 KB
scripts/run-recursive-benchmark.pyscript376.1 KB
scripts/test-recursive-mode-smoke.ps1script1.0 KB
scripts/test-recursive-mode-smoke.pyscript121.0 KB
scripts/test_install_recursive_mode.pyscript38.4 KB
scripts/test_lint_recursive_run.pyscript4.1 KB
scripts/test_recursive_phase_rules.pyscript21.4 KB
scripts/test_recursive_review_bundle.pyscript5.8 KB
scripts/test_recursive_router.pyscript53.3 KB
scripts/test_recursive_subagent_action.pyscript3.2 KB
scripts/test_recursive_training.pyscript12.0 KB
scripts/test_run_recursive_benchmark.pyscript160.0 KB
scripts/verify-locks.ps1script733 B
scripts/verify-locks.pyscript13.8 KB

scripts/verify-locks.py

View on GitHub
#!/usr/bin/env python3
"""
Verify recursive-mode artifact lock integrity.

Python equivalent to scripts/verify-locks.ps1.
"""

from __future__ import annotations

import argparse
import hashlib
import importlib.util
import re
from dataclasses import dataclass
from datetime import datetime, timezone
from pathlib import Path


def load_phase_rules_module():
    module_path = Path(__file__).with_name("recursive_phase_rules.py")
    spec = importlib.util.spec_from_file_location("recursive_phase_rules", module_path)
    if spec is None or spec.loader is None:
        raise RuntimeError(f"Unable to load phase rules module from {module_path}")
    module = importlib.util.module_from_spec(spec)
    try:
        spec.loader.exec_module(module)
    except FileNotFoundError:
        raise RuntimeError(f"Phase rules module not found: {module_path}")
    return module


STATUS_RE = re.compile(r'(?m)^[ \t]*Status:\s*(?:`|")?(\w+)(?:`|")?\s*$')
LOCK_HASH_RE = re.compile(r'(?m)^[ \t]*LockHash:\s*(?:`|")?([a-fA-F0-9]{64})(?:`|")?\s*$')
LOCKED_AT_RE = re.compile(r'(?m)^[ \t]*LockedAt:\s*(?:`|")?([^`"\r\n]+)(?:`|")?\s*$')
LOCK_HASH_LINE_RE = re.compile(r'(?m)^[ \t]*LockHash:.*(?:\n|$)')
WORKFLOW_VERSION_RE = re.compile(r'(?m)^[ \t]*Workflow version:\s*(?:`|")?([^`"\r\n]+)(?:`|")?\s*$')
CURRENT_WORKFLOW_PROFILE = "recursive-mode-audit-v2"
STRICT_WORKFLOW_PROFILE = "recursive-mode-audit-v1"
COMPAT_WORKFLOW_PROFILE = "memory-phase8"
STRICT_WORKFLOW_PROFILES = {CURRENT_WORKFLOW_PROFILE, STRICT_WORKFLOW_PROFILE}
AUDITED_PHASE_FILES = {
    "01-as-is.md",
    "01.5-root-cause.md",
    "02-to-be-plan.md",
    "03-implementation-summary.md",
    "03.5-code-review.md",
    "04-test-summary.md",
    "06-decisions-update.md",
    "07-state-update.md",
    "08-memory-impact.md",
}


@dataclass
class LockResult:
    valid: bool
    error: str | None = None
    stored_hash: str | None = None
    actual_hash: str | None = None
    locked_at: str | None = None
    fixed: bool = False
    new_locked_at: str | None = None
    new_hash: str | None = None


def write_status(status: str, message: str) -> None:
    print(f"[{status}] {message}")


def normalize_for_lock_hash(content: str) -> str:
    normalized = content.replace("\r\n", "\n").replace("\r", "\n")
    normalized = LOCK_HASH_LINE_RE.sub("", normalized)
    return normalized


def lock_hash_from_content(content: str) -> str:
    normalized = normalize_for_lock_hash(content)
    return hashlib.sha256(normalized.encode("utf-8")).hexdigest()


def get_workflow_profile(run_dir: Path) -> str:
    requirements_path = run_dir / "00-requirements.md"
    if requirements_path.exists():
        content = requirements_path.read_text(encoding="utf-8")
        match = WORKFLOW_VERSION_RE.search(content)
        if match:
            workflow_version = match.group(1).strip()
            if workflow_version == CURRENT_WORKFLOW_PROFILE:
                return CURRENT_WORKFLOW_PROFILE
            if workflow_version == STRICT_WORKFLOW_PROFILE:
                return STRICT_WORKFLOW_PROFILE
            if workflow_version == COMPAT_WORKFLOW_PROFILE:
                return COMPAT_WORKFLOW_PROFILE

    for artifact in ("06-decisions-update.md", "07-state-update.md", "08-memory-impact.md"):
        if (run_dir / artifact).exists():
            return COMPAT_WORKFLOW_PROFILE

    return "legacy"


def test_lock_valid(artifact_path: Path, fix: bool = False) -> LockResult:
    if not artifact_path.exists():
        return LockResult(valid=False, error="File not found")

    content = artifact_path.read_text(encoding="utf-8")

    status_match = STATUS_RE.search(content)
    if not status_match:
        return LockResult(valid=False, error="No Status field found")
    status = status_match.group(1)
    if status != "LOCKED":
        return LockResult(valid=False, error=f"Status is '{status}', expected 'LOCKED'")

    hash_match = LOCK_HASH_RE.search(content)
    if not hash_match:
        return LockResult(valid=False, error="No LockHash field found")
    stored_hash = hash_match.group(1).lower()

    locked_at_match = LOCKED_AT_RE.search(content)
    if not locked_at_match:
        return LockResult(valid=False, error="No LockedAt field found")
    locked_at = locked_at_match.group(1)

    actual_hash = lock_hash_from_content(content)
    if stored_hash == actual_hash:
        return LockResult(valid=True, locked_at=locked_at, stored_hash=stored_hash)

    result = LockResult(
        valid=False,
        error="Hash mismatch",
        stored_hash=stored_hash,
        actual_hash=actual_hash,
        locked_at=locked_at,
    )

    if fix:
        new_locked_at = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
        content_with_new_locked_at = re.sub(
            r"(?m)^[ \t]*LockedAt:.*$",
            f"LockedAt: `{new_locked_at}`",
            content,
        )
        new_hash = lock_hash_from_content(content_with_new_locked_at)
        new_content = re.sub(
            r"(?m)^[ \t]*LockHash:.*$",
            f"LockHash: `{new_hash}`",
            content_with_new_locked_at,
        )
        artifact_path.write_text(new_content, encoding="utf-8", newline="")

        result.fixed = True
        result.new_locked_at = new_locked_at
        result.new_hash = new_hash

    return result


def test_gate(content: str, name: str) -> tuple[bool, str | None]:
    pass_re = re.compile(rf"{name}:\s*PASS")
    fail_re = re.compile(rf"{name}:\s*FAIL")
    if pass_re.search(content):
        return True, None
    if fail_re.search(content):
        return False, f"{name} gate shows FAIL"
    return False, f"No {name} gate result found"


def main() -> int:
    parser = argparse.ArgumentParser(description="Verify recursive-mode artifact lock integrity.")
    parser.add_argument("--run-id", default="", help="Run ID to verify. If omitted, scans all runs.")
    parser.add_argument("--repo-root", default=".", help="Repository root path.")
    parser.add_argument("--fix", action="store_true", help="Fix incorrect lock hashes (updates LockedAt + LockHash).")
    parser.add_argument("--show-hashes", action="store_true", help="Show valid lock hashes in output.")
    args = parser.parse_args()

    resolved_repo_root = Path(args.repo_root).resolve()
    print("\nRecursive Lock Verification")
    print("=====================\n")
    print(f"Repository: {resolved_repo_root}")
    print(f"Run ID: {args.run_id if args.run_id else '(scanning all runs)'}\n")

    run_base_dir = resolved_repo_root / ".recursive" / "run"
    if not run_base_dir.exists():
        write_status("FAIL", f"recursive run directory not found: {run_base_dir}")
        return 1

    if args.run_id:
        runs = [args.run_id]
    else:
        runs = sorted([d.name for d in run_base_dir.iterdir() if d.is_dir()])

    artifacts = [
        {"file": "00-requirements.md", "name": "Requirements", "optional": False},
        {"file": "00-worktree.md", "name": "Worktree Setup", "optional": False},
        {"file": "01-as-is.md", "name": "AS-IS Analysis", "optional": True},
        {"file": "01.5-root-cause.md", "name": "Root Cause", "optional": True},
        {"file": "02-to-be-plan.md", "name": "TO-BE Plan", "optional": True},
        {"file": "03-implementation-summary.md", "name": "Implementation", "optional": True},
        {"file": "03.5-code-review.md", "name": "Code Review", "optional": True},
        {"file": "04-test-summary.md", "name": "Test Summary", "optional": True},
        {"file": "05-manual-qa.md", "name": "Manual QA", "optional": True},
        {"file": "06-decisions-update.md", "name": "Decisions Update", "optional": False},
        {"file": "07-state-update.md", "name": "State Update", "optional": False},
        {"file": "08-memory-impact.md", "name": "Memory Impact", "optional": False},
    ]

    total_runs = 0
    valid_runs = 0
    fixed_runs = 0
    failed_runs = 0
    stale_chain_runs = 0

    phase_rules = load_phase_rules_module()

    for run in runs:
        total_runs += 1
        run_dir = run_base_dir / run
        workflow_profile = get_workflow_profile(run_dir)
        print(f"Checking run: {run}")
        print("-" * 50)
        print(f"Workflow profile: {workflow_profile}")

        run_valid = True
        run_fixed = False

        for artifact in artifacts:
            artifact_path = run_dir / artifact["file"]
            is_required = not artifact["optional"]
            if workflow_profile == "legacy" and artifact["file"] in {"06-decisions-update.md", "07-state-update.md", "08-memory-impact.md"}:
                is_required = False
            if not artifact_path.exists():
                if not is_required:
                    write_status("INFO", f"{artifact['name']}: Not found (optional)")
                else:
                    write_status("FAIL", f"{artifact['name']}: Missing (required)")
                    run_valid = False
                continue

            content = artifact_path.read_text(encoding="utf-8")
            if not re.search(r'(?m)^[ \t]*Status:\s*(?:`|")?LOCKED(?:`|")?\s*$', content):
                write_status("WARN", f"{artifact['name']}: Not locked (DRAFT)")
                run_valid = False
                continue

            result = test_lock_valid(artifact_path, fix=args.fix)
            if result.valid:
                write_status("PASS", f"{artifact['name']}: Valid (locked at {result.locked_at})")
                if args.show_hashes and result.stored_hash:
                    print(f"         Hash: {result.stored_hash}")
            else:
                if result.fixed:
                    write_status("WARN", f"{artifact['name']}: Fixed hash mismatch (was tampered)")
                    if result.stored_hash:
                        print(f"         Old hash: {result.stored_hash}")
                    if result.new_hash:
                        print(f"         New hash: {result.new_hash}")
                    if result.new_locked_at:
                        print(f"         Updated at: {result.new_locked_at}")
                    run_fixed = True
                else:
                    write_status("FAIL", f"{artifact['name']}: {result.error}")
                    if result.stored_hash and result.actual_hash:
                        print(f"         Stored: {result.stored_hash}")
                        print(f"         Actual: {result.actual_hash}")
                    run_valid = False

            # Gate checks
            updated_content = artifact_path.read_text(encoding="utf-8")
            coverage_ok, coverage_reason = test_gate(updated_content, "Coverage")
            approval_ok, approval_reason = test_gate(updated_content, "Approval")
            audit_required = workflow_profile in STRICT_WORKFLOW_PROFILES and artifact["file"] in AUDITED_PHASE_FILES
            audit_ok = True
            audit_reason = None
            if audit_required:
                audit_ok, audit_reason = test_gate(updated_content, "Audit")
            if not coverage_ok:
                write_status("FAIL", f"{artifact['name']}: Coverage gate - {coverage_reason}")
                run_valid = False
            if not approval_ok:
                write_status("FAIL", f"{artifact['name']}: Approval gate - {approval_reason}")
                run_valid = False
            if not audit_ok:
                write_status("FAIL", f"{artifact['name']}: Audit gate - {audit_reason}")
                run_valid = False

        addenda_dir = run_dir / "addenda"
        if addenda_dir.exists():
            addenda_files = sorted(addenda_dir.glob("*.md"))
            if addenda_files:
                print("\nAddenda:")
                for addendum in addenda_files:
                    result = test_lock_valid(addendum, fix=args.fix)
                    if result.valid:
                        write_status("PASS", f"  {addendum.name}: Valid")
                    elif result.fixed:
                        write_status("WARN", f"  {addendum.name}: Fixed")
                        run_fixed = True
                    else:
                        write_status("FAIL", f"  {addendum.name}: {result.error}")
                        run_valid = False

        # Stale-chain detection: check whether any prerequisite hash in a receipt
        # no longer matches the current artifact content.
        stale_entries = phase_rules.get_all_stale_receipts(run_dir)
        run_stale = False
        if stale_entries:
            print("\nStale lock-chain receipts:")
            for entry in stale_entries:
                write_status("WARN", f"  {entry['artifact']}: {entry['reason']}")
                run_stale = True

        print()
        if run_stale:
            stale_chain_runs += 1
            run_valid = False
            write_status("WARN", f"Run '{run}': Stale lock-chain receipts detected (re-lock in phase order)")
        elif run_valid and not run_fixed:
            valid_runs += 1
            write_status("PASS", f"Run '{run}': All locks valid")
        elif run_fixed:
            fixed_runs += 1
            write_status("WARN", f"Run '{run}': Locks fixed (tampering detected)")
        else:
            failed_runs += 1
            write_status("FAIL", f"Run '{run}': Lock verification failed")
        print()

    print("=====================")
    print("Summary")
    print("=====================\n")
    print(f"Total runs checked: {total_runs}")
    write_status("PASS", f"Valid runs: {valid_runs}")
    if stale_chain_runs > 0:
        write_status("WARN", f"Stale-chain runs: {stale_chain_runs}")
    if fixed_runs > 0:
        write_status("WARN", f"Fixed runs (tampered): {fixed_runs}")
    if failed_runs > 0:
        write_status("FAIL", f"Failed runs: {failed_runs}")
    print()

    if failed_runs == 0 and stale_chain_runs == 0:
        write_status("PASS", "All locks verified successfully")
        return 0
    if failed_runs == 0:
        write_status("WARN", "Lock hashes valid but stale-chain receipts detected")
        return 1
    write_status("FAIL", "Some locks failed verification")
    return 1


if __name__ == "__main__":
    raise SystemExit(main())
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 467kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 319kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 319kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 319kUpdated Claude CodeCodexVerifiedInstall