feat(framework+cli): Phase 2 PR 7 — pre-PR hook + devtrail init --hooks#79
Merged
feat(framework+cli): Phase 2 PR 7 — pre-PR hook + devtrail init --hooks#79
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Seventh of 8 PRs. Adds the opt-in friction layer that runs
devtrail charter driftbeforegit 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 scansdocs/charters/*.mdforstatus: in-progress, runsdevtrail charter drift <id> --range $UPSTREAM..HEADfor 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 isorigin/main; override viaDEVTRAIL_UPSTREAMenv var. Manual install:cp .devtrail/hooks/pre-pr.sh .git/hooks/pre-push.CLI
--hooksflag ondevtrail init(default: false). After init succeeds, copies.devtrail/hooks/pre-pr.shto.git/hooks/pre-pushand makes it executable.pre-pushhook (warns and continues without).Behavior tradeoffs
devtrailis not in PATH, so adopters who haven't installed the CLI yet can still push without friction.--no-verify(standard git escape hatch); documented use case: "drift was intentional, captured in AILOG, push anyway".Test plan
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_repoinstall_pre_pr_hook_refuses_to_overwrite_existinginstall_pre_pr_hook_errors_when_source_missingbash -n pre-pr.sh).🤖 Generated with Claude Code