Skip to content

fix: add scope-lock-apply helper to unblock autonomous pipeline lock step#27

Merged
intel352 merged 3 commits into
mainfrom
copilot/fix-scope-lock-write-step
May 8, 2026
Merged

fix: add scope-lock-apply helper to unblock autonomous pipeline lock step#27
intel352 merged 3 commits into
mainfrom
copilot/fix-scope-lock-write-step

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 7, 2026

  • Create hooks/scope-lock-apply helper script (computes sha256 of manifest, writes .scope-lock via shell — bypasses the Write-tool gate)
  • Update skills/scope-lock/SKILL.md to instruct the agent to call the helper via Bash instead of using the Write tool
  • Update skills/alignment-check/SKILL.md with same helper invocation description
  • Update hooks/pre-tool-scope-guard — header and inline comments now document both the agent path (scope-lock-apply) and the operator path (SUPERPOWERS_SCOPE_LOCK_WRITE=1); long block reason refactored into readable variable segments
  • All existing tests pass (plan-scope-check.sh, skill-cross-refs.sh, skill-content-grep.sh)

The pre-tool-scope-guard hook blocks Write/Edit/MultiEdit tool calls to
*.scope-lock paths unconditionally. The scope-lock skill had no in-session
way to write the lock file: using the Write tool was blocked, and setting
SUPERPOWERS_SCOPE_LOCK_WRITE=1 via Bash was also blocked by the self-bypass
prevention logic.

Fix: add hooks/scope-lock-apply, a dedicated helper the scope-lock skill
invokes via the Bash tool. Shell redirection is not gated by the Write tool
guard, so the hook never fires. The script extracts the Scope Manifest
section using the same awk pattern as tests/plan-scope-check.sh, computes
sha256 portably (sha256sum or shasum -a 256), and writes <plan>.scope-lock.

Update SKILL.md (scope-lock and alignment-check) to replace the naive
"compute sha256 and write the file" instruction with the explicit helper
invocation. Update the pre-tool-scope-guard block message to point agents
at the helper instead of the now-misleading SUPERPOWERS_SCOPE_LOCK_WRITE
env var note.

Agent-Logs-Url: https://github.com/GoCodeAlone/claude-superpowers/sessions/5f1aafea-9d74-4c24-be43-32e5f16de6b7

Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot May 7, 2026 21:31
Copilot AI changed the title [WIP] Fix scope-lock skill write step under default install fix: add scope-lock-apply helper to unblock autonomous pipeline lock step May 7, 2026
Copilot AI requested a review from intel352 May 7, 2026 21:31
@intel352 intel352 marked this pull request as ready for review May 8, 2026 14:21
Copilot AI review requested due to automatic review settings May 8, 2026 14:21
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a dedicated scope-lock-apply helper script to allow the autonomous pipeline to generate <plan>.scope-lock files without using the Write/Edit tools (which are intentionally blocked for *.scope-lock), and updates skill docs + guard messaging to point to this sanctioned path.

Changes:

  • Introduces hooks/scope-lock-apply to extract the ## Scope Manifest section, compute SHA-256 portably, and write <plan>.scope-lock.
  • Updates skills/scope-lock/SKILL.md and skills/alignment-check/SKILL.md to explicitly invoke the helper via Bash instead of using the Write tool.
  • Updates hooks/pre-tool-scope-guard messaging to direct users to the helper when .scope-lock writes are blocked.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
skills/scope-lock/SKILL.md Documents the new Bash-helper-based lockfile write procedure.
skills/alignment-check/SKILL.md Aligns alignment-check’s PASS steps with the new helper invocation.
hooks/scope-lock-apply New helper to compute and write <plan>.scope-lock deterministically/portably.
hooks/pre-tool-scope-guard Updates comments and the block message to recommend scope-lock-apply.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread hooks/pre-tool-scope-guard Outdated
Comment on lines 145 to 148
if printf '%s' "$fpath" | grep -qE '\.scope-lock$'; then
if [ "${SUPERPOWERS_SCOPE_LOCK_WRITE:-}" != "1" ]; then
block "Writing to '$(basename "$fpath")' is blocked — .scope-lock files are written exclusively by the scope-lock skill during alignment-check PASS. Direct edits break the manifest integrity guarantee and allow silent scope tampering. To update the lock legitimately: go through the unlock path (recording-decisions → update manifest → re-run alignment-check), which will regenerate the lock file."
block "Writing to '$(basename "$fpath")' is blocked — .scope-lock files must be written by the scope-lock skill's helper, not via the Write tool. Run: bash \"\${CLAUDE_PLUGIN_ROOT}/hooks/scope-lock-apply\" <plan-path>. The helper extracts the Scope Manifest section, computes its sha256, and writes the lock file via shell redirection (which is not blocked). Direct Write/Edit calls break the manifest integrity guarantee and allow silent scope tampering. To update the lock legitimately after a scope reduction: go through the unlock path (recording-decisions → update manifest → re-run alignment-check → re-run scope-lock-apply)."
fi
@intel352
Copy link
Copy Markdown
Contributor

intel352 commented May 8, 2026

@copilot apply changes based on the comments in this thread

…and break up long block message

- Header comment now documents both override paths (agent: scope-lock-apply
  via Bash; operator: SUPERPOWERS_SCOPE_LOCK_WRITE=1) instead of mentioning
  only the new helper
- Inline section comment updated to match, explicitly calling out both paths
- Long block reason string broken into named-variable segments for
  readability and safer future edits

Agent-Logs-Url: https://github.com/GoCodeAlone/claude-superpowers/sessions/b771bd78-7761-446e-b094-f26f0b0e2a38

Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 8, 2026

@copilot apply changes based on the comments in this thread

Done in ed32867:

  • Header comment (line 13) now documents both override paths: agent path: hooks/scope-lock-apply via Bash; operator path: SUPERPOWERS_SCOPE_LOCK_WRITE=1 — so the comment accurately reflects what the code actually does.
  • Inline section comment (above the guard block) similarly calls out both paths explicitly.
  • Block reason string refactored from a single long escaped string into readable _reason variable segments assembled line by line.

@intel352 intel352 merged commit df7f531 into main May 8, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

scope-lock skill cannot complete its own write step under default install (hook blocks .scope-lock writes unconditionally)

3 participants