// 04
ENGINEERING GUARDRAILS AS CODE
$ bind profile --repo benefits-modernization --profile clean-architecture@2.3
Most departments already have architecture standards. Most of them live in a document nobody opens, enforced — if at all — by an analyzer that rejects code after it has been written. PROTECTEDCODE binds the same standard into generation: architects publish versioned engineering profiles, each repository or solution binds a profile and version, the assistant receives that profile when it generates and reviews, and deterministic tooling then verifies the rules that can be enforced mechanically.
WITHOUT A BOUND PROFILEGenerate first, reject later
conformance is somebody else's problem
- The assistant writes whatever it writes
- A controller queries EF Core DbContext directly
- The architecture test fails in CI — if one exists
- Drift lands in the codebase and stays
- Standards erode one merge at a time
WITH A BOUND PROFILEGenerate toward, then verify
conformance shifts left into generation
- The assistant proposes an application-service boundary
- Because that is what the active profile says
- The architecture test proves the dependency is absent
- Confirmation, not cleanup
- Exceptions are explicit, versioned and reviewable
# .protectedcode/profile.yml — bound to this repository, versioned with it
profile: clean-architecture
version: 2.3
owner: enterprise-architecture
architecture:
forbidden: [ presentation -> infrastructure.persistence ]
required: [ use-case boundary for cross-aggregate writes ]
validated_by: [ roslyn-analyzers, architecture-tests ]
security:
packages: approved-feed-only
secrets: no literals in source or prompts
validated_by: [ sast, dependency-scan, secret-scan ]
web:
baseline: gc-web-accessibility
validated_by: [ automated-a11y, human review ]
exceptions:
- rule: presentation -> infrastructure.persistence
scope: LegacyReportsController.cs
approved_by: solution-architect
expires: 2027-03-31
$ ls /profile/domains
[ARCHITECTURE]
Clean, Onion, Layered, Legacy Maintenance or your own pattern. Allowed and forbidden layer and project dependencies, declared per repository rather than imposed as one global house style.
validated_by: roslyn analyzers · architecture tests · project-reference rules
[CODING_STANDARDS]
Dependency injection, async, logging, exception handling, naming, API and testing conventions as your department actually writes them.
validated_by: compiler + analyzer rules · formatter · unit tests
[SECURITY_PACKAGES]
Authentication and authorization patterns, secret handling, cryptography rules, approved NuGet feeds and dependency policy.
validated_by: sast · secret scanning · dependency/SBOM checks · CI policy
[WEB_ACCESSIBILITY]
WET/GCWeb implementation guidance, accessible component patterns and WCAG requirements applied to generated and reviewed UI code.
validated_by: automated a11y testing · component tests · human review
[GOVERNANCE]
Profile ID and version, repository binding, migration status and approved deviations — so exceptions are visible rather than silent.
validated_by: versioned policy file · code review · exception workflow
Two layers, and we are explicit about which is which. Model instructions guide behaviour. They are not sufficient controls. Rules that can be enforced mechanically are backed by Roslyn analyzers, architecture tests, dependency and secret scanning, accessibility checks and CI gates — and where automation cannot prove a requirement, human review stays in the path. We do not claim enforcement we cannot demonstrate.
Start from working examples, not a blank schema. PROTECTEDCODE ships editable starter profiles — Clean Architecture, Onion, Layered, Legacy Maintenance and a GC web/accessibility baseline. A department customizes a working profile rather than authoring policy from scratch, and a legacy maintenance codebase and a greenfield service can sit under different profiles without pretending they are the same.