Skip to content

feat: architecture policy, enforcement tests and guidance skills - #3

Merged
kieronlanning merged 4 commits into
mainfrom
feat/architecture-policy
Oct 15, 2026
Merged

kieronlanning merged 4 commits into
mainfrom
feat/architecture-policy

Conversation

@kieronlanning

Copy link
Copy Markdown
Contributor

Implements the project responsibility catalogue, naming convention, dependency matrix and architecture enforcement, plus the shared agent guidance skills and Mermaid diagrams A-N.

One definition per rule

.config/architecture-policy.json is authoritative. The architecture tests read it rather than restating its rules, and PolicyDocumentationTests asserts the wiki tables match it, so a rule cannot be true in prose and false in code.

Enforced (16 tests)

Dependency matrix, sibling independence, nothing depending on Composition, forbidden framework packages per responsibility, cycles, catch-all project names, production-to-test references, and waiver justification. Failures name the project, the rule, the offending reference and the direction the dependency should run.

Waivers

A rule suppressed silently is a rule that is a lie. A waiver records the departure and excuses the name only - mapsTo keeps the project classified so every dependency rule still applies. This repository's Infrastructure project is the worked example: it holds one adapter, so it is not the catch-all the rule targets, and renaming it would churn the wiki, AGENTS.md and NamespaceRemoveSuffix for no gain.

Diagrams

A-N, split across three pages. All 16 Mermaid sources were rendered with mermaid-cli to confirm they parse - they sit in ```text fences because Mermaid is not enabled in mkdocs.yml.

Verification

  • just build - 0 warnings, 0 errors
  • just test - 53/53 pass (was 37)
  • just lint-check - clean

The project responsibility catalogue, naming convention and dependency matrix are
defined once, in .config/architecture-policy.json. The architecture tests read it
rather than restating its rules, and PolicyDocumentationTests asserts the wiki
tables match it, so a rule cannot be true in prose and false in code.

Enforced: the dependency matrix, sibling independence, nothing depending on
Composition, forbidden framework packages per responsibility, cycles, catch-all
project names, and production code referencing a test project. Failures name the
project, the rule, the offending reference and the direction it should run.

Waivers record a deliberate departure instead of suppressing a rule silently. This
repository's own Infrastructure project is the worked example: it maps to Adapters,
so the name is excused and every dependency rule still applies.

Adds the Project-Responsibilities and Agent-Guidance-Skills pages with Mermaid
diagrams A-N, all verified to render with mermaid-cli.
…kill

purview-architecture now covers naming (<Responsibility>[.<Implementation>]) and
dependency direction, pointing at the policy rather than restating it.

purview-architecture-testing is new: how to turn a rule a reviewer keeps repeating
into a build failure without a brittle suite. It insists the matrix is defined once,
that failures name the fix rather than the fact, and that existing code gets a
recorded waiver instead of a weakened rule.

Extends the review scenarios to cover modular monoliths, multiple persistence
implementations, and a repository that already has a catch-all project name.
The policy declared "$schema": "./architecture-policy.schema.json" and no such file
existed. A dangling pointer is worse than none: an editor reports no error, so the
format looks validated when nothing checks it.

Adds the schema (draft 2020-12), published by $id at the raw GitHub URL so editors
can fetch it, matching the purview-build.json convention. Renames the policy's
"exceptions" key to "waivers" so the file, the schema and the C# agree.

The schema is enforced rather than decorative. PolicySchemaTests validates the
policy against it, checks both files agree on the published identifier, and asserts
the schema *rejects* a document missing a required field, a waiver with a token
reason, and a misspelled key - a schema that cannot fail proves nothing.

additionalProperties:false throughout, because a misspelled key reads as an absent
rule rather than an error, which is the most dangerous mistake a policy file can
carry. Validation uses JsonSchema.Net, the same library Purview.Build uses.
The rule engine now ships as Purview.Architecture.Testing, so adoption is a policy
file and one derived test class rather than copying the C#.

Calls out that [InheritsTests] is required: TUnit does not walk base types during
discovery, so without it the class compiles, the run is green and nothing is
enforced.
@kieronlanning
kieronlanning merged commit dbdbefc into main Oct 15, 2026
1 check passed
@kieronlanning
kieronlanning deleted the feat/architecture-policy branch October 15, 2026 10:36
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