Skip to content

fix: correct IN_CONTAINER guard in workspace githooks - #239

Merged
c-vigo merged 3 commits into
devfrom
bugfix/238-fix-agent-blocklist-scripts
Mar 9, 2026
Merged

c-vigo merged 3 commits into
devfrom
bugfix/238-fix-agent-blocklist-scripts

Conversation

@c-vigo

@c-vigo c-vigo commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

Description

Fix the inverted IN_CONTAINER guard in workspace githooks that silently allowed host commits through.

Issue #238 describes three defects (A, B, C) from #163. After analysing the current codebase, defects A and B were already resolved by the vig-utils migration (#218):

  • A (wrong project_root): The old Path(__file__).resolve().parent.parent was replaced by find_repo_root() which traverses up from cwd looking for .github/.
  • B (missing vig_utils dependency): The scripts now live inside vig-utils and are invoked as entry points — no external import needed.

Defect C was the only remaining bug: all three workspace githooks used = "false" to check IN_CONTAINER, but outside the devcontainer the variable is typically unset (empty string), not the literal "false". The guard never triggered, so host commits were not blocked. Changed to != "true" to fail closed.

Type of Change

  • feat -- New feature
  • fix -- Bug fix
  • docs -- Documentation only
  • chore -- Maintenance task (deps, config, etc.)
  • refactor -- Code restructuring (no behavior change)
  • test -- Adding or updating tests
  • ci -- CI/CD pipeline changes
  • build -- Build system or dependency changes
  • revert -- Reverts a previous commit
  • style -- Code style (formatting, whitespace)

Modifiers

  • Breaking change (!) -- This change breaks backward compatibility

Changes Made

  • assets/workspace/.githooks/pre-commit — changed = "false" to != "true"
  • assets/workspace/.githooks/prepare-commit-msg — changed = "false" to != "true"
  • assets/workspace/.githooks/commit-msg — changed = "false" to != "true"
  • tests/bats/githooks.bats — new BATS test suite (12 tests: 3 hooks × 4 scenarios: unset, empty, "false", "true")
  • CHANGELOG.md — added entry under ### Fixed

Changelog Entry

Fixed

  • IN_CONTAINER guard never triggers on host (#238)
    • Workspace githooks used = "false" but IN_CONTAINER is unset (not "false") outside the devcontainer
    • Changed to != "true" in pre-commit, prepare-commit-msg, and commit-msg hooks to fail closed

Testing

  • Tests pass locally (just test)
  • Manual testing performed (describe below)

Manual Testing Details

BATS test suite tests/bats/githooks.bats — 12 tests, all pass:

ok 1 pre-commit blocks when IN_CONTAINER is unset
ok 2 pre-commit blocks when IN_CONTAINER is empty
ok 3 pre-commit blocks when IN_CONTAINER is false
ok 4 pre-commit does not show guard message when IN_CONTAINER is true
ok 5 prepare-commit-msg blocks when IN_CONTAINER is unset
ok 6 prepare-commit-msg blocks when IN_CONTAINER is empty
ok 7 prepare-commit-msg blocks when IN_CONTAINER is false
ok 8 prepare-commit-msg does not show guard message when IN_CONTAINER is true
ok 9 commit-msg blocks when IN_CONTAINER is unset
ok 10 commit-msg blocks when IN_CONTAINER is empty
ok 11 commit-msg blocks when IN_CONTAINER is false
ok 12 commit-msg does not show guard message when IN_CONTAINER is true

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly (edit docs/templates/, then run just docs)
  • I have updated CHANGELOG.md in the [Unreleased] section (and pasted the entry above)
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Additional Notes

The implementation plan with full triage analysis is posted as a comment on issue #238.

Refs: #238

c-vigo added 3 commits March 9, 2026 09:00
The guard uses = "false" but IN_CONTAINER is unset (not "false") outside
the devcontainer, so the guard never triggers on the host.

Refs: #238
Outside the devcontainer IN_CONTAINER is unset, not "false". The
= "false" check never matched, so host commits were not blocked.
Changed to != "true" in all three hooks to fail closed.

Refs: #238
@c-vigo c-vigo self-assigned this Mar 9, 2026
@c-vigo
c-vigo enabled auto-merge March 9, 2026 08:06
@c-vigo
c-vigo merged commit 97f46ff into dev Mar 9, 2026
10 checks passed
@c-vigo
c-vigo deleted the bugfix/238-fix-agent-blocklist-scripts branch March 9, 2026 08:12
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