Skip to content

feat(framework+cli): Phase 2 PR 7 — pre-PR hook + devtrail init --hooks#79

Merged
montfort merged 1 commit intomainfrom
feat/phase2-pr7-pre-pr-hook
May 3, 2026
Merged

feat(framework+cli): Phase 2 PR 7 — pre-PR hook + devtrail init --hooks#79
montfort merged 1 commit intomainfrom
feat/phase2-pr7-pre-pr-hook

Conversation

@montfort
Copy link
Copy Markdown
Contributor

@montfort montfort commented May 3, 2026

Summary

Seventh of 8 PRs. Adds the opt-in friction layer that runs devtrail charter drift before git push. Per principle #6 (cognitive discipline > raw productivity), the hook is virtuous when consented to — never installed by default.

Framework

  • dist/.devtrail/hooks/pre-pr.sh — bash hook that scans docs/charters/*.md for status: in-progress, runs devtrail charter drift <id> --range $UPSTREAM..HEAD for each, exits non-zero if any reports unaccounted drift. AILOG-suppression in the CLI (PR 3) silences alerts on paths already documented as risks. Default upstream is origin/main; override via DEVTRAIL_UPSTREAM env var. Manual install: cp .devtrail/hooks/pre-pr.sh .git/hooks/pre-push.

CLI

  • New --hooks flag on devtrail init (default: false). After init succeeds, copies .devtrail/hooks/pre-pr.sh to .git/hooks/pre-push and makes it executable.
  • Refuses to overwrite an existing pre-push hook (warns and continues without).
  • Skips silently if the project isn't a git repository.

Behavior tradeoffs

  • The hook short-circuits when devtrail is not in PATH, so adopters who haven't installed the CLI yet can still push without friction.
  • The hook respects --no-verify (standard git escape hatch); documented use case: "drift was intentional, captured in AILOG, push anyway".

Test plan

  • 4 unit tests in init::hook_tests:
    • install_pre_pr_hook_copies_and_makes_executable (happy path, asserts executable bit)
    • install_pre_pr_hook_skips_when_not_a_git_repo
    • install_pre_pr_hook_refuses_to_overwrite_existing
    • install_pre_pr_hook_errors_when_source_missing
  • 382/382 tests pass.
  • Bash syntax check passes (bash -n pre-pr.sh).

🤖 Generated with Claude Code

Adds the opt-in friction layer that runs `devtrail charter drift` before
`git push`. Per principle #6 (cognitive discipline > raw productivity),
the hook is virtuous when consented to — and never installed by default.

Framework:
- dist/.devtrail/hooks/pre-pr.sh: bash hook that scans
  docs/charters/*.md for status: in-progress, runs `devtrail charter
  drift <id> --range $UPSTREAM..HEAD` for each, exits non-zero if
  any reports unaccounted drift. AILOG-suppression in the CLI (PR 3)
  silences alerts on paths already documented as risks. Default
  upstream is origin/main; override via DEVTRAIL_UPSTREAM env var.
  Manual install: cp .devtrail/hooks/pre-pr.sh .git/hooks/pre-push.

CLI:
- New --hooks flag on `devtrail init` (default: false). After init
  succeeds, copies .devtrail/hooks/pre-pr.sh to .git/hooks/pre-push
  and makes it executable. Refuses to overwrite an existing
  pre-push hook (warns and continues without). Skips silently if
  the project isn't a git repository.

Behavior tradeoffs:
- The hook short-circuits when devtrail is not in PATH, so adopters
  who haven't installed the CLI yet can still push without friction.
- The hook respects --no-verify (standard git escape hatch); the
  documented use case is "drift was intentional, captured in
  AILOG, push anyway".

Tests:
- 4 unit tests in init::hook_tests:
  * install_pre_pr_hook_copies_and_makes_executable (happy path)
  * install_pre_pr_hook_skips_when_not_a_git_repo
  * install_pre_pr_hook_refuses_to_overwrite_existing
  * install_pre_pr_hook_errors_when_source_missing

382/382 tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@montfort montfort merged commit a8d540b into main May 3, 2026
@montfort montfort deleted the feat/phase2-pr7-pre-pr-hook branch May 3, 2026 01:25
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.

1 participant