feat(pi): add focused guardrail workflow tools #208

Merged
jwilger merged 8 commits from add-some-tools into main 2026-05-15 16:11:53 -07:00
Owner

Summary

  • add focused Pi verification tools: verify_harness for guardrail contracts and verify_release_tooling for release tooling dry-runs
  • move Pi guardrail contracts to tests/pi_guardrails/contract_test.mjs while leaving a compatibility shim at the old release-tooling path
  • tighten project BDD/TDD guardrails so RED/GREEN require real focused command output and implementation stops at one diagnostic
  • make safe_commit/safe_push guard against closed or merged PR branches, and require explicit PR metadata review before pushing to open PR branches
  • add baseline semantic file/index tools: safe_remove, safe_unstage, and safe_restore
  • remove obsolete pi-lens guardrail references and add guidance to prefer new semantic tools over misusing existing tools

Verification

  • verify_harness passed after adding safe_remove
  • verify_harness passed after adding safe_unstage
  • verify_harness passed after adding safe_restore
  • final verify_harness passed

Notes

This PR has grown beyond the original safe branch workflow tools; the title and description now cover all commits currently on add-some-tools.

## Summary - add focused Pi verification tools: `verify_harness` for guardrail contracts and `verify_release_tooling` for release tooling dry-runs - move Pi guardrail contracts to `tests/pi_guardrails/contract_test.mjs` while leaving a compatibility shim at the old release-tooling path - tighten project BDD/TDD guardrails so RED/GREEN require real focused command output and implementation stops at one diagnostic - make `safe_commit`/`safe_push` guard against closed or merged PR branches, and require explicit PR metadata review before pushing to open PR branches - add baseline semantic file/index tools: `safe_remove`, `safe_unstage`, and `safe_restore` - remove obsolete pi-lens guardrail references and add guidance to prefer new semantic tools over misusing existing tools ## Verification - `verify_harness` passed after adding safe_remove - `verify_harness` passed after adding safe_unstage - `verify_harness` passed after adding safe_restore - final `verify_harness` passed ## Notes This PR has grown beyond the original safe branch workflow tools; the title and description now cover all commits currently on `add-some-tools`.
Add a typed Pi tool for validated branch switching so sessions can leave main without direct bash access.

The guardrail requires a clean working tree and rejects unsafe branch names or switches to main.
Keep the stashed guardrail helper formatting from the post-hook cleanup on the branch where the safe branch-switch tool work now lives.
Add typed branch creation/switch validation and prevent safe_commit from committing on main.

Move full verification to pre-push, remove pi-lens to avoid deferred end-of-turn formatting stalls, and make git mutation tools use async child process execution so long hooks do not block Pi's event loop.
Write raw git command output to a temporary file and return only a concise summary plus the file path to Pi context.

This keeps safe_commit, safe_create_branch, safe_switch_branch, and safe_push from flooding context while preserving access to full command output when needed.
The release-tooling check runs the Pi guardrails contract test with node, so include nodejs in the derivation inputs used by pre-push verification.
test(release): align pi tool verification inputs
Some checks failed
CI / Verify PR with nix flake check (pull_request) Has been cancelled
CI / Request auto_review semantic review (pull_request) Has been cancelled
CI / Build PR artifacts (no token) (pull_request) Has been cancelled
CI / Publish PR artifact packages (pull_request) Has been cancelled
c67dc8852e
Include nodejs for the Pi guardrails contract and update the lefthook contract to expect full verification on pre-push.
docs: add semantic tool guardrail
Some checks failed
CI / Verify PR with nix flake check (pull_request) Has been cancelled
CI / Request auto_review semantic review (pull_request) Has been cancelled
CI / Build PR artifacts (no token) (pull_request) Has been cancelled
CI / Publish PR artifact packages (pull_request) Has been cancelled
ee5ce17ea6
Encourage adding purpose-built tools or workflows when a new operation does not fit existing tool semantics.
docs: remove obsolete pi-lens guardrail
All checks were successful
CI / Verify PR with nix flake check (pull_request) Successful in 2m20s
CI / Request auto_review semantic review (pull_request) Successful in 1s
CI / Build PR artifacts (no token) (pull_request) Successful in 2s
CI / Publish PR artifact packages (pull_request) Successful in 1s
auto_review auto_review: 1 warning
ab51718ccb
Drop the deferred pi-lens formatting instruction now that pi-lens is no longer used.
auto-review left a comment

This PR introduces safe branch workflow tools, moving verification from pre-commit to pre-push, and adds Node.js to the environment. The changes appear well-structured, but the shift to pre-push verification should be documented due to its impact on the workflow.

Walkthrough

  • .pi/extensions/auto-review-git-safety.mjs: Introduces functions to validate safe branch operations and commit inputs, ensuring operations are not performed on the main branch or with a dirty working tree.
  • .pi/extensions/auto-review-guardrails.ts: Refactors git command execution to be asynchronous and introduces concise command result logging, improving the safety and clarity of git operations.
  • flake.nix: Adds Node.js to the environment, which is necessary for the new tooling.
  • lefthook.yml: Changes the hook from pre-commit to pre-push, which affects when full verification is performed.
  • tests/release_tooling/pi_guardrails_contract_test.mjs: Adds tests for the new validation functions and ensures that verbose output is handled correctly.
  • tests/release_tooling/release_script_flake_test.sh: Updates tests to reflect the change from pre-commit to pre-push hooks.
This PR introduces safe branch workflow tools, moving verification from pre-commit to pre-push, and adds Node.js to the environment. The changes appear well-structured, but the shift to pre-push verification should be documented due to its impact on the workflow. ## Walkthrough - **.pi/extensions/auto-review-git-safety.mjs**: Introduces functions to validate safe branch operations and commit inputs, ensuring operations are not performed on the main branch or with a dirty working tree. - **.pi/extensions/auto-review-guardrails.ts**: Refactors git command execution to be asynchronous and introduces concise command result logging, improving the safety and clarity of git operations. - **flake.nix**: Adds Node.js to the environment, which is necessary for the new tooling. - **lefthook.yml**: Changes the hook from pre-commit to pre-push, which affects when full verification is performed. - **tests/release_tooling/pi_guardrails_contract_test.mjs**: Adds tests for the new validation functions and ensures that verbose output is handled correctly. - **tests/release_tooling/release_script_flake_test.sh**: Updates tests to reflect the change from pre-commit to pre-push hooks.
@ -2,3 +1,4 @@
pre-push:
commands:
full-verification:
run: nix flake check
Owner

🟡 Warning: The change from pre-commit to pre-push in the lefthook configuration should be clearly documented in the project's documentation or changelog, as it alters the workflow significantly.

🟡 **Warning:** The change from `pre-commit` to `pre-push` in the lefthook configuration should be clearly documented in the project's documentation or changelog, as it alters the workflow significantly.
jwilger marked this conversation as resolved
jwilger changed title from chore(pi): add safe branch workflow tools to feat(pi): add focused guardrail workflow tools 2026-05-15 16:14:42 -07:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Slipstream/auto_review!208
No description provided.