Appearance
ADR-0091: Dynamic Local Branch Point Detection and Offline ADR Validation
- Status: Accepted
- Date: 2026-07-28
- Authors: @fderuiter
- Deciders: @fderuiter
- Requirements Reference: PRD-SYS-001
1. Context & Problem Statement
When developers work on multi-commit feature branches offline or in network-restricted environments, the Architectural Decision Record (ADR) validation system was unable to resolve remote tracking branches (such as origin/main). This dependency caused the validation pipeline to fail or default to verifying only the single most recent commit (HEAD), potentially bypassing mandatory compliance and metadata tracing checks across multi-commit branches. We need a robust, network-independent mechanism to compute the closest local merge base across all local and remote branches to ensure offline compliance and 100% test validation coverage.
2. Decision Drivers & Constraints
- Compliance: CDISC USDM, CDISC ODM, and 21 CFR Part 11 requirements mandate strict auditability and validation of all architectural decisions and GxP requirements.
- Developer Experience: Developers must be able to run fast, robust, and completely offline architectural validation checks locally.
- First-Parent Traversal: When computing file changes, merge commits can introduce extraneous changes from the parent branch, polluting branch lineage. We must cleanly traverse first-parents to isolate branch-specific changes.
- Workspace Integration: Active development files (staged, unstaged, and untracked) must be seamlessly integrated into active scans to prevent accidental commits of invalid ADR files.
3. Options Considered
Option 1: Hardcoded Primary Branch Resolution
- Overview: Rely on a default branch name like
origin/mainormainas the fixed ancestor point. - Pros:
- ✅ Simple to implement.
- Cons:
- ❌ Fails completely in offline modes or when working with custom feature-branch topologies.
- ❌ Hardcoded defaults break flexibility for custom workspace patterns.
Option 2: Dynamic Offline Ancestor Point Calculation (Selected)
- Overview: Dynamically resolve the closest local branch ancestor entirely offline by querying both local and remote-tracking references via git commands, filtering out headless or irrelevant pointers, and identifying the closest merge-base.
- Pros:
- ✅ 100% network-independent and offline-capable.
- ✅ Bypasses merge commits cleanly via
--first-parenttraversal. - ✅ Includes all active workspace states (staged, unstaged, untracked).
- Cons:
- ❌ Slower than a hardcoded string, though overhead is negligible (<1s).
4. Decision Outcome
- Chosen Option: Option 2
- Justification: Dynamic offline ancestor point calculation completely eliminates network dependencies, ensuring that ADR validation is continuous, bulletproof, and robust in headless CI environments or local sandboxes.
5. Consequences & Trade-offs
- Positive Impact: Developers receive immediate compliance feedback locally offline, and multi-commit branches are validated seamlessly.
- Negative Impact / Technical Debt: Marginal increase in script complexity inside
validate_adrs.pyto handle edge cases like headless detaches and branch name filtering. - Mitigation Strategy: Solidified with a robust unit testing suite inside
tests/test_validate_adrs.pyverifying fallback behaviors and mock branch states.
6. Implementation & Verification
- Affected Repositories / Services:
scripts/validate_adrs.py,tests/test_validate_adrs.py - Verification Plan: Unit tests executed and passed successfully with 100% coverage on the resolved branch base methods.