Skip to content

feat(usage): log blocked hook-bypass attempts - #384

Merged
BenSheridanEdwards merged 1 commit into
mainfrom
feat/log-blocked-gate-bypass
Nov 16, 2026
Merged

BenSheridanEdwards merged 1 commit into
mainfrom
feat/log-blocked-gate-bypass

Conversation

@BenSheridanEdwards

Copy link
Copy Markdown
Owner

Why does this feature exist?

Blocked --no-verify, HUSKY=0, and other hook-bypass attempts were already rejected, but those blocked attempts were not written to the factory usage log alongside the per-rule lint counts from ADR 0100. This PR records each blocked attempt as one JSON Lines event so the monitoring epic can see when someone tries to skip the gates.

Closes #361.

What changed?

The existing block-gate-bypass hook still exits 2 and stops the commit. On a blocked attempt it now calls scripts/lint-usage.mjs --blocked-bypass to append one record (timestamp, branch, agent and model when known, and the attempted command) to .cache/factory-usage/lint-runs.jsonl. Logging stays best-effort: a missing or failing logger does not weaken the block. ADR 0100, QUALITY_GATES.md and tasks.md note the new event. No guarded paths changed; enforcement sign-off is not required.

7 files, +156/−21, 177 hand-written changed lines.

Behavioural Proof (with video and screenshots)

Not applicable: hook and usage-log change with no rendered UI surface.

  • Video: not required; this is hook tooling, not a user-visible journey.
  • Screenshots: not required; no rendered surface.
  • Behaviour tests: scripts/block-gate-bypass.test.ts and scripts/lint-usage.test.ts (red then green). A manual blocked attempt returned exit 2 and wrote exactly one log record; a normal commit is not recorded as a bypass.
  • E2E mapping: no product behaviour changed, so no E2E map update.

Verification Summary

  • Head commit: d1f032b
  • PRDs checked: None: hook and usage-log tooling only
  • PRD impact: None
  • North Star commit: e3e180b
  • Commands run: pnpm exec jest --selectProjects tooling scripts/lint-usage.test.ts scripts/block-gate-bypass.test.ts, node scripts/enforcement-approval.mjs --git ben/main HEAD, pnpm verify, pnpm e2e.
  • Results: tooling Jest 70 suites / 3,103 tests passed at this head, including the two new behaviour files. Enforcement: {"head":"d1f032b44ea96af77e411b226852427ba4b1938d","problems":[]}. Codex pnpm verify passed 3,221 tests (one benchmark timed out, then all three benchmark tests passed on recheck); contract, integration, coverage, build and size passed. Pre-push against Ben origin/main re-ran pnpm verify and pnpm e2e; Playwright last-run status was passed with failedTests: [] at 17:24:19 GMT.
  • Definition of Done (.agents/project/PR_QUALITY.md) satisfied, or each gap named: local verify and e2e passed; no user-visible behaviour change; logic covered by unit and behaviour tests; no interactive UI, so accessibility does not apply; ADR 0100 updated; hooks were not bypassed.
  • pnpm verify
  • pnpm e2e
  • Behaviour is covered by the E2E map when user-visible behaviour changed.
  • Logic is unit-tested where logic changed.
  • Accessibility considered and verified for interactive/UI changes.
  • The diff follows .agents/project/ARCHITECTURE.md and CONVENTIONS.md; new decisions recorded as ADRs.
  • No gates were bypassed or weakened.
  • Known risks or skipped checks (with reason, risk, and rollback): logging is best-effort and must not weaken the block; if the logger is off or fails, the commit is still rejected and no record is written. Rollback: revert this commit. Hosted checks are unverified until the PR runs. Review is deferred; this PR is not merged in this step.

PRD Behaviours to Review

  • None

PR Proof Law

  • I followed .agents/project/PR_QUALITY.md and .agents/skills/pr-quality-contract/SKILL.md; the PR quality check verifies the proof format.

@github-actions github-actions Bot added confidence: red A required gate is failing or pending, or evidence is unavailable. confidence: green Required gates, slice E2E/PRDs, unit line coverage and import blast radius passed. and removed confidence: red A required gate is failing or pending, or evidence is unavailable. labels Nov 16, 2026
@BenSheridanEdwards

Copy link
Copy Markdown
Owner Author

Review

VERDICT: APPROVE

Reviewed head d1f032b44ea96af77e411b226852427ba4b1938d at 17:49:07 GMT on Studio Opus (claude-2).

The PR meets every acceptance point in #361 and follows the approved plan. The hook still exits 2 and stays blocking when logging is off or fails. A blocked attempt appends one blocked-bypass record to the existing usage log; a normal commit is not recorded. Enforcement is problems: []. No .husky/** change.

Blocking findings: none.

Non-blocking:

  1. The "logging fails" half of the test at scripts/block-gate-bypass.test.ts:357 misses node via a narrowed PATH, so it never reaches block() or the logger. A hand check with .cache as a file still exited 2.
  2. runInRepo leaves git-ignored .scratch/bypass-* folders behind.
  3. Lint-run records now also resolve the log folder via git rev-parse --show-toplevel; pre-commit still runs from the repo root, so the result is the same, but the PR body does not mention it.
  4. The stored command is verbatim in a local git-ignored log, as the plan accepted under ADR 0100.

Targeted tests: 192/192 passed. Size: 7 files, +156/−21.

@BenSheridanEdwards
BenSheridanEdwards merged commit e7653ac into main Nov 16, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

confidence: green Required gates, slice E2E/PRDs, unit line coverage and import blast radius passed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(usage): log blocked --no-verify attempts

1 participant