Late checking allows small dependency violations to stack up across many changes. Each pass may look harmless, but repeated boundary crossings create architectural debt that is expensive to untangle later. Teams then face more rework, noisier reviews, and maintainability issues that surface only after the codebase has already absorbed the damage.
Why This Matters for Security Teams
When architectural boundaries are checked only after merge, the review process becomes a cleanup mechanism instead of a control. That is especially dangerous when the code touches service accounts, API keys, or other secrets, because the damage is not just stylistic drift. Late detection lets violations spread across multiple changes, making it harder to prove ownership, enforce least privilege, or contain blast radius.
This is where NHI governance and code architecture intersect. The Ultimate Guide to NHIs notes that 97% of NHIs carry excessive privileges, and 79% of organisations have experienced secrets leaks, which shows how quickly weak controls compound once they enter the main branch. The NIST Cybersecurity Framework 2.0 reinforces the same practical point: prevention is easier to operationalise than recovery, especially when identity and access boundaries are part of the delivery pipeline.
In practice, many security teams encounter architectural boundary violations only after dependency sprawl has already made the codebase expensive to unwind.
How It Works in Practice
Boundary checks that run after merge depend on human reviewers to catch structural drift once the code is already moving toward release. That is too late for enforcing package layering, domain isolation, or dependency direction because the violations are now part of the shared history. A better pattern is to make architectural policy executable before merge, so the pipeline rejects changes that cross forbidden boundaries.
In mature environments, this usually combines static analysis, dependency graph rules, and policy-as-code. Teams define which packages may import which layers, which modules may call sensitive services, and where secrets or credentials are allowed to appear. Controls can also be applied to NHI-related paths, for example preventing long-lived tokens from entering application code or CI configuration. The operational goal is not just to stop bad code, but to stop boundary erosion before it becomes normalised.
- Check imports, call paths, and package ownership at pull request time, not after merge.
- Fail builds when new dependencies violate layer or domain rules.
- Require short-lived credentials and disallow secrets in code, configs, or pipeline variables.
- Track exceptions explicitly so architecture debt is visible and time-bound.
For identity-heavy systems, the same discipline aligns with NHI lifecycle controls and Zero Trust principles. The Ultimate Guide to NHIs is useful here because it ties visibility, rotation, and offboarding to the broader control problem, while NIST Cybersecurity Framework 2.0 provides a shared language for prevention and continuous monitoring. These controls tend to break down when repos are large, monorepos mix many ownership models, and teams keep adding allowlists because the architecture was never encoded as policy in the first place.
Common Variations and Edge Cases
Tighter pre-merge enforcement often increases review friction, requiring organisations to balance architectural integrity against delivery speed. That tradeoff becomes visible in fast-moving product teams, where some exceptions are necessary but still need to be bounded, documented, and revisited.
Current guidance suggests a few common variations. For greenfield services, the best practice is to reject violations outright because the design is still flexible. For legacy systems, strict blocking can be too disruptive, so teams often start with warning mode, then move high-risk boundaries to hard fail. There is no universal standard for this yet, but the direction is clear: architecture checks should become part of build governance, not a post-merge audit.
One practical edge case is generated code or vendor-managed modules. Those may not fit normal ownership rules, but they still need explicit exceptions and periodic review. Another is agentic or automation-heavy applications, where service accounts and tool integrations can cross boundaries quickly. In those environments, boundary drift and credential sprawl reinforce each other, which is why architecture policy and NHI policy should be managed together rather than in separate silos.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP Non-Human Identity Top 10 and OWASP Agentic AI Top 10 address the attack and risk surface, while NIST CSF 2.0, NIST Zero Trust (SP 800-207) and NIST AI RMF set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP Non-Human Identity Top 10 | NHI-03 | Late boundary checks often allow excess secrets exposure and weak NHI hygiene. |
| NIST CSF 2.0 | PR.AC-4 | Boundary enforcement supports least privilege and controlled access paths. |
| NIST Zero Trust (SP 800-207) | PL-3 | Architectural boundaries are a trust boundary problem that Zero Trust addresses directly. |
| NIST AI RMF | GOVERN | Policy-driven checks need ownership and accountability to stay effective over time. |
| OWASP Agentic AI Top 10 | A2 | Agentic systems amplify boundary violations through dynamic tool use and autonomy. |
Enforce NHI policy in the pipeline so secrets and service accounts cannot cross approved boundaries.
Related resources from NHI Mgmt Group
- What breaks when AI-generated code is only checked after commit?
- What breaks when secrets and insecure cloud configuration are only checked after code is written?
- What is the difference between code scanning and runtime identity monitoring?
- What breaks when device compliance is checked only after access is granted?