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/recursive-lock.py

View on GitHub
#!/usr/bin/env python3
"""
Lock a recursive-mode artifact after validating gates, structure, and audit requirements.
"""

from __future__ import annotations

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


LOCK_HASH_LINE_RE = re.compile(r"(?m)^[ \t]*LockHash:.*(?:\n|$)")


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


def load_lint_module():
    module_path = Path(__file__).with_name("lint-recursive-run.py")
    spec = importlib.util.spec_from_file_location("recursive_mode_lint", module_path)
    if spec is None or spec.loader is None:
        raise RuntimeError(f"Unable to load lint module from {module_path}")
    module = importlib.util.module_from_spec(spec)
    spec.loader.exec_module(module)
    return module


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


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


def render_field(field_name: str, value: str) -> str:
    return f"{field_name}: `{value}`"


def set_or_insert_field(content: str, field_name: str, value: str, after_fields: list[str]) -> str:
    line = render_field(field_name, value)
    field_re = re.compile(rf"(?m)^[ \t]*(?:[-*][ \t]+)?{re.escape(field_name)}:\s*.*$")
    if field_re.search(content):
        return field_re.sub(line, content, count=1)

    lines = content.replace("\r\n", "\n").replace("\r", "\n").split("\n")
    insert_at = 0
    for after_field in after_fields:
        after_re = re.compile(rf"^[ \t]*(?:[-*][ \t]+)?{re.escape(after_field)}:\s*.*$")
        for index, existing_line in enumerate(lines):
            if after_re.match(existing_line):
                insert_at = max(insert_at, index + 1)
    lines.insert(insert_at, line)
    return "\n".join(lines)


def validate_lockable(lint, repo_root: Path, run_dir: Path, artifact_path: Path) -> tuple[list[str], str, str]:
    issues: list[str] = []
    content = artifact_path.read_text(encoding="utf-8")
    workflow_profile = lint.get_workflow_profile(run_dir)
    requirement_ids: list[str] = []
    status = lint.get_md_field_value(content, "Status") or "UNKNOWN"

    requirements_path = run_dir / "00-requirements.md"
    if requirements_path.exists():
        requirement_ids = lint.parse_requirement_ids(requirements_path.read_text(encoding="utf-8"))

    actual_changed_files: list[str] | None = None
    diff_basis_error: str | None = None
    if workflow_profile == lint.STRICT_WORKFLOW_PROFILE:
        diff_basis = lint.get_run_diff_basis(run_dir)
        raw_changed_files, diff_basis_error = lint.get_git_changed_files(repo_root, diff_basis)
        if raw_changed_files is not None:
            actual_changed_files = lint.filter_runtime_changed_files(raw_changed_files, run_dir.name)

    if status not in {"DRAFT", "LOCKED"}:
        issues.append(f"Artifact Status must be DRAFT before locking (found {status})")

    missing_header_fields = [
        field for field in ("Run", "Phase", "Status", "Inputs", "Outputs", "Scope note") if not lint.has_header_field(content, field)
    ]
    if missing_header_fields:
        issues.append(f"Missing required header field(s): {', '.join(missing_header_fields)}")

    todo_has_section, _todo_total, _todo_checked, todo_unchecked = lint.get_todo_stats(content)
    if not todo_has_section:
        issues.append("Missing required section: ## TODO")
    elif todo_unchecked > 0:
        issues.append(f"Unchecked TODO items remain: {todo_unchecked}")

    for heading in lint.get_artifact_required_sections(artifact_path.name, workflow_profile):
        if not lint.has_heading(content, heading):
            issues.append(f"Missing required section heading: ## {heading}")

    for gate_name in ("Coverage", "Approval"):
        if not lint.has_gate_line(content, gate_name):
            issues.append(f"Missing required gate line: {gate_name}: PASS|FAIL")

    issues.extend(lint.lint_traceability(artifact_path, content, requirement_ids))
    issues.extend(
        lint.lint_audit_sections(
            artifact_path,
            content,
            workflow_profile,
            actual_changed_files,
            diff_basis_error,
            run_dir.name,
            run_dir,
        )
    )
    issues.extend(
        lint.lint_phase_specific_rules(
            artifact_path,
            content,
            workflow_profile,
            run_dir,
            repo_root,
            requirement_ids,
            actual_changed_files,
        )
    )

    if lint.get_gate_status(content, "Coverage") != "PASS":
        issues.append("Coverage gate must be PASS before locking")
    if lint.get_gate_status(content, "Approval") != "PASS":
        issues.append("Approval gate must be PASS before locking")
    if artifact_path.name == "03-implementation-summary.md" and lint.get_gate_status(content, "TDD Compliance") != "PASS":
        issues.append("TDD Compliance gate must be PASS before locking Phase 3")
    if workflow_profile == lint.STRICT_WORKFLOW_PROFILE and artifact_path.name in lint.AUDITED_PHASE_FILES:
        if lint.get_gate_status(content, "Audit") != "PASS":
            issues.append("Audit gate must be PASS before locking this audited phase")

    deduped_issues = sorted(set(issues))
    if status == "LOCKED":
        locked_at = lint.get_md_field_value(content, "LockedAt")
        stored_hash = lint.get_md_field_value(content, "LockHash")
        actual_hash = lock_hash_from_content(content) if stored_hash else None
        if locked_at and stored_hash and actual_hash and stored_hash.lower() == actual_hash.lower() and not deduped_issues:
            return [], content, workflow_profile
        if not deduped_issues:
            deduped_issues.append("Artifact is already LOCKED but its lock metadata is invalid")
        else:
            deduped_issues.append("Artifact is already LOCKED but not lock-valid under current rules; set it back to DRAFT before re-locking")

    return sorted(set(deduped_issues)), content, workflow_profile


def resolve_artifact_path(run_dir: Path, artifact_arg: str) -> Path:
    artifact_path = Path(artifact_arg)
    if not artifact_path.is_absolute():
        artifact_path = run_dir / artifact_path
    artifact_path = artifact_path.resolve()
    run_root = run_dir.resolve()
    try:
        artifact_path.relative_to(run_root)
    except ValueError as exc:
        raise ValueError(f"Artifact path must stay within the run directory: {run_root}") from exc
    return artifact_path


def reopen_artifact(phase_rules, run_dir: Path, artifact_path: Path, repo_root: Path) -> int:
    """
    Revert a locked artifact back to DRAFT status and invalidate all downstream
    lock receipts so they must be re-locked in order.
    """
    content = artifact_path.read_text(encoding="utf-8")
    status_re = re.compile(r"(?m)^[ \t]*Status:.*$")
    locked_at_re = re.compile(r"(?m)^[ \t]*LockedAt:.*\n?")
    hash_re = re.compile(r"(?m)^[ \t]*LockHash:.*\n?")

    updated = status_re.sub("Status: `DRAFT`", content, count=1)
    updated = locked_at_re.sub("", updated, count=1)
    updated = hash_re.sub("", updated, count=1)

    temp_path = artifact_path.with_name(f".{artifact_path.name}.tmp")
    temp_path.write_text(updated, encoding="utf-8", newline="\n")
    temp_path.replace(artifact_path)

    rel = artifact_path.relative_to(repo_root)
    print(f"[OK] Reopened {rel}: reverted to DRAFT")

    artifact_name = artifact_path.name
    if phase_rules.is_core_artifact(artifact_name):
        removed = phase_rules.invalidate_receipt(run_dir, artifact_name)
        if removed:
            print(f"[OK] Invalidated lock receipt for {artifact_name}")

        stale = phase_rules.get_stale_downstream_phases(artifact_name, run_dir)
        if stale:
            print("[WARN] The following downstream phases have stale receipts; re-lock them in order after fixing this phase:")
            for entry in stale:
                phase_rules.invalidate_receipt(run_dir, entry["artifact"])
                print(f"  - {entry['artifact']}: {entry['reason']} (receipt invalidated)")

    return 0


def main() -> int:
    parser = argparse.ArgumentParser(description="Lock a recursive-mode artifact after validating gates and structure.")
    parser.add_argument("--run-id", required=True, help="Run ID under .recursive/run/.")
    parser.add_argument("--artifact", required=True, help="Artifact file inside the run directory, e.g. 04-test-summary.md or addenda/foo.addendum-01.md")
    parser.add_argument("--repo-root", default=".", help="Repository root path.")
    parser.add_argument("--reopen", action="store_true", help="Reopen a locked artifact: revert to DRAFT, remove lock metadata, and invalidate downstream receipts.")
    args = parser.parse_args()

    repo_root = Path(args.repo_root).resolve()
    run_dir = repo_root / ".recursive" / "run" / args.run_id.strip()
    if not run_dir.exists():
        print(f"[FAIL] Run directory not found: {run_dir}")
        return 1

    try:
        artifact_path = resolve_artifact_path(run_dir, args.artifact.strip())
    except ValueError as exc:
        print(f"[FAIL] {exc}")
        return 1

    if not artifact_path.exists():
        print(f"[FAIL] Artifact not found: {artifact_path}")
        return 1

    phase_rules = load_phase_rules_module()

    if args.reopen:
        return reopen_artifact(phase_rules, run_dir, artifact_path, repo_root)

    # Prerequisite gate: all earlier phases that exist must be LOCKED first.
    artifact_name = artifact_path.name
    if phase_rules.is_core_artifact(artifact_name):
        blockers = phase_rules.get_prerequisite_blockers(artifact_name, run_dir)
        if blockers:
            print(f"[FAIL] Cannot lock {artifact_path.relative_to(repo_root)}: prerequisite phases are not yet LOCKED")
            for blocker in blockers:
                print(f"  - {blocker['artifact']}: {blocker['status']} ({blocker['path']})")
            return 1

    lint = load_lint_module()
    issues, content, workflow_profile = validate_lockable(lint, repo_root, run_dir, artifact_path)

    if not issues:
        status = lint.get_md_field_value(content, "Status") or "UNKNOWN"
        if status == "LOCKED":
            print(f"[OK] Artifact already lock-valid: {artifact_path.relative_to(repo_root)}")
            print(f"Workflow Profile: {workflow_profile}")
            return 0

    if issues:
        print(f"[FAIL] Refusing to lock {artifact_path.relative_to(repo_root)}")
        print(f"Workflow Profile: {workflow_profile}")
        for issue in issues:
            print(f"- {issue}")
        return 1

    locked_at = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
    updated = set_or_insert_field(content, "Status", "LOCKED", ["Phase"])
    updated = set_or_insert_field(updated, "LockedAt", locked_at, ["Status"])
    provisional = set_or_insert_field(updated, "LockHash", "0" * 64, ["LockedAt", "Status"])
    lock_hash = lock_hash_from_content(provisional)
    final_content = set_or_insert_field(updated, "LockHash", lock_hash, ["LockedAt", "Status"])

    temp_path = artifact_path.with_name(f".{artifact_path.name}.tmp")
    temp_path.write_text(final_content, encoding="utf-8", newline="\n")
    temp_path.replace(artifact_path)

    # Write lock receipt for chain tracking.
    if phase_rules.is_core_artifact(artifact_name):
        phase_rules.write_receipt(run_dir, artifact_name, artifact_path)

    # Report stale downstream phases so the caller knows what needs re-locking.
    if phase_rules.is_core_artifact(artifact_name):
        stale = phase_rules.get_stale_downstream_phases(artifact_name, run_dir)
        if stale:
            print(f"[WARN] The following downstream phases have stale receipts and may need re-locking:")
            for entry in stale:
                print(f"  - {entry['artifact']}: {entry['reason']}")

    print(f"[OK] Locked {artifact_path.relative_to(repo_root)}")
    print(f"Workflow Profile: {workflow_profile}")
    print(f"LockedAt: {locked_at}")
    print(f"LockHash: {lock_hash}")
    return 0


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: 466kUpdated Claude CodeCodexVerifiedInstall
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: 466kUpdated 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