Skip to content

fix: retrospective review fixes for merged PR #25#110

Merged
ikeikeikeike merged 1 commit into
mainfrom
fix/retro-review-pr25
Jul 16, 2026
Merged

fix: retrospective review fixes for merged PR #25#110
ikeikeikeike merged 1 commit into
mainfrom
fix/retro-review-pr25

Conversation

@ikeikeikeike

Copy link
Copy Markdown
Member

Retrospective /code-review sweep of merged PR #25 that shipped without pre-merge review.

PR #25 ("v0.7.2: ECC compat + dogfooding bridge") wired bough hook handle's quality-gate dispatch (dispatchQualityGates / buildMatchContext in internal/cli/hook.go). That code is unchanged since v0.7.2 — it survived the later v0.9 architecture reset (which deleted internal/ecc/ and rewrote the ECC import path elsewhere) — and has two still-live bugs:

  1. Config never found outside the monorepo root. dispatchQualityGates resolved its config path as a bare cwd-relative .bough.yaml (or $BOUGH_CONFIG), instead of going through resolveMonorepoRoot + resolveConfigPath like every sibling dispatcher in the same file (resolveObserverConfig, dispatchEvolveClaudeMD). This file's own docs describe the intended model: every sub-repo / worktree session pools into one monorepo project, so bough hook handle ordinarily runs with cwd inside e.g. <root>/extremo-api/, not at <root> itself. From there, the old code's bare os.Stat(".bough.yaml") always missed the canonical config, so no quality gate ever ran except when the hook happened to fire with cwd exactly at the monorepo root. This is the same class of bug already fixed for dispatchObserverAutostart (commit 487ea4c) but never applied to this sibling.
  2. on_repo matcher was dead code from day one. buildMatchContext never populated qualitygate.MatchContext.Repo, so a gate declaring on_repo: (a documented, schema-validated QualityGateCfg field) always compared against the empty string and could never match — silently disabling any gate an operator scoped to a specific sub-repo.

Fix: dispatchQualityGates now resolves the monorepo root and goes through resolveConfigPath (keeping $BOUGH_CONFIG as the highest-priority override, so that existing behavior is preserved), and a new repoNameFromCwd helper derives the sub-repo name from cwd — handling both the worktrees/ and legacy .worktrees/ layouts — to populate MatchContext.Repo.

Test plan

  • go build ./...
  • go test ./...
  • golangci-lint run ./...
  • New regression tests reproduce both bugs pre-fix and pass post-fix: TestDispatchQualityGates_ResolvesConfigFromSubRepoCwd, TestDispatchQualityGates_OnRepoMatchesDerivedRepo, TestRepoNameFromCwd, TestBuildMatchContext_CarriesRepo

…po matcher

Retrospective review of merged PR #25 (v0.7.2 "ECC compat + dogfooding
bridge"), which wired `bough hook handle`'s quality-gate dispatch. Two
bugs in that wiring are still live at HEAD (dispatchQualityGates and
buildMatchContext are unchanged since v0.7.2, having survived the v0.9
architecture reset):

1. dispatchQualityGates resolved cfgPath as a bare cwd-relative
   ".bough.yaml" (or $BOUGH_CONFIG), instead of going through
   resolveMonorepoRoot + resolveConfigPath like every sibling
   dispatcher in this file (see resolveObserverConfig, fixed for the
   same class of bug in 487ea4c). Per this file's own documented ECC
   model, every sub-repo / worktree session pools into one monorepo
   project, so a `bough hook handle` invocation with cwd inside e.g.
   <root>/extremo-api/ (the ordinary case) silently never found
   <root>/.bough.yaml and no quality gate ever ran outside the exact
   root directory.

2. buildMatchContext never populated qualitygate.MatchContext.Repo,
   so a gate's on_repo matcher (config.QualityGateCfg.OnRepo,
   documented and schema-validated since v0.7.1) always compared
   against the empty string and could never match — a dead feature
   from day one.

Fixes both: dispatchQualityGates now resolves root via
resolveMonorepoRoot and the config via resolveConfigPath (keeping
$BOUGH_CONFIG as the highest-priority override), and a new
repoNameFromCwd helper derives the sub-repo name from cwd (handling
both the worktrees/ and legacy .worktrees/ layouts) to populate
MatchContext.Repo.

Added table-driven tests for repoNameFromCwd plus regression tests
that reproduce both bugs end-to-end (gate now runs from a sub-repo
cwd; on_repo correctly includes/excludes based on the derived repo).
@ikeikeikeike
ikeikeikeike merged commit 83af424 into main Jul 16, 2026
11 checks passed
@ikeikeikeike
ikeikeikeike deleted the fix/retro-review-pr25 branch July 16, 2026 06:49
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