Create: Goodtocode.Ai.Governance package
- Objectives
Build a reusable AI governance package that enforces 4 principles end-to-end:
Observability
Auditability
Defensibility
Repeatability
Constraints:
No Cannery coupling
No MediatR dependency
Use only Goodtocode ecosystem patterns/libraries and base .NET
2) Package topology (recommended)
Use a small suite with one convenience package:
goodtocode.AI.governance.domain
goodtocode.AI.governance.application
goodtocode.AI.governance.infrastructure.entityframework (optional)
goodtocode.AI.governance (meta-package)
3) domain package scope (pure core)
Include:
GovernanceProfile (policy profile version + 4 required booleans)
Deterministic GovernanceLockHash generation (SHA-256)
GovernedEvaluationOutputSchema + validator
Interfaces/contracts:
IGovernedEntity
IGovernedExecutionArtifact
Domain guard exceptions (or mapped standard exceptions)
Rules:
No persistence/UI/runtime framework references
Deterministic behavior only
Strict constructors/factories; no permissive fallbacks
4) application package scope (use-case enforcement)
Include:
Governance guard services for:
create/update command paths
query/read paths
runtime evaluation paths
Profile resolution abstractions:
IGovernanceProfileResolver
Enforcement orchestration:
IGovernanceEnforcer
Goodtocode pipeline hooks (not MediatR):
integrate via Goodtocode.Mediator pipeline behaviors/interfaces already used by your stack
Goodtocode.Validation validators for request and output checks
5) infrastructure.entityframework package scope (optional)
Include:
EF model configuration helpers for governance columns:
GovernancePolicyProfileVersion
GovernanceObservabilityRequired
GovernanceAuditabilityRequired
GovernanceDefensibilityRequired
GovernanceRepeatabilityRequired
GovernanceLockHash
SaveChanges interceptor/checks for drift prevention
Optional migration helper docs/templates (not auto-running migrations)
6) Non-bypass enforcement model (mandatory)
Enforce governance in all layers:
Create/Update
Profile comes only from authoritative resolver
Caller cannot override governance lock fields
Read/Query
Validate governance lock hash and strictness before returning DTOs
Execution runtime
Validate pipeline/playbook (or equivalent units) lock compatibility
Validate governed output schema completeness and references
Persistence
Required/non-null governance fields
Indexed profile version where useful
Integrity checks before save
Failure behavior:
explicit validation/conflict exceptions
no silent defaults
no broad catch-and-continue patterns
7) Public API design (stable surface)
Expose minimal stable entry points:
services.AddGoodtocodeAiGovernance(...)
IGovernanceProfileResolver
IGovernanceEnforcer
GovernanceProfile
GovernanceLock/hash utilities
governed output validators
Keep internals hidden; keep package API small and versionable.
- Versioning & compatibility policy
Start at 0.x until two real adopters are stable
Move to 1.0.0 once contracts are proven
SemVer rules:
breaking contract changes => major
additive fields/validators => minor
bugfixes => patch
- Adoption checklist for any product
Add package(s)
Implement IGovernanceProfileResolver
Register governance services in DI
Add governance fields to governed entities
Wire create/update/query/runtime enforcement points
Add targeted tests:
create persists strict lock
update preserves/refreshes lock per policy
query rejects drift
runtime rejects mismatched governance
governed output schema validation
- Delivery phases
Phase 1 (foundation)
Build domain + hash/schema validators
Publish prerelease
Phase 2 (application)
Add Goodtocode mediator/validation integrations
Add profile resolver + enforcer pipeline
Phase 3 (persistence)
Add EF helpers + interceptor package
Add implementation samples
Phase 4 (hardening)
Add full contract tests
Validate with at least two external repos
Promote to 1.0.0
- Explicit anti-goals
No product-specific terms (no Cannery/Crucible/Conductor naming)
No MediatR references
No framework-locking behavior in domain
No optional governance for critical paths
Create: Goodtocode.Ai.Governance package
Build a reusable AI governance package that enforces 4 principles end-to-end:
Observability
Auditability
Defensibility
Repeatability
Constraints:
No Cannery coupling
No MediatR dependency
Use only Goodtocode ecosystem patterns/libraries and base .NET
2) Package topology (recommended)
Use a small suite with one convenience package:
goodtocode.AI.governance.domain
goodtocode.AI.governance.application
goodtocode.AI.governance.infrastructure.entityframework (optional)
goodtocode.AI.governance (meta-package)
3) domain package scope (pure core)
Include:
GovernanceProfile (policy profile version + 4 required booleans)
Deterministic GovernanceLockHash generation (SHA-256)
GovernedEvaluationOutputSchema + validator
Interfaces/contracts:
IGovernedEntity
IGovernedExecutionArtifact
Domain guard exceptions (or mapped standard exceptions)
Rules:
No persistence/UI/runtime framework references
Deterministic behavior only
Strict constructors/factories; no permissive fallbacks
4) application package scope (use-case enforcement)
Include:
Governance guard services for:
create/update command paths
query/read paths
runtime evaluation paths
Profile resolution abstractions:
IGovernanceProfileResolver
Enforcement orchestration:
IGovernanceEnforcer
Goodtocode pipeline hooks (not MediatR):
integrate via Goodtocode.Mediator pipeline behaviors/interfaces already used by your stack
Goodtocode.Validation validators for request and output checks
5) infrastructure.entityframework package scope (optional)
Include:
EF model configuration helpers for governance columns:
GovernancePolicyProfileVersion
GovernanceObservabilityRequired
GovernanceAuditabilityRequired
GovernanceDefensibilityRequired
GovernanceRepeatabilityRequired
GovernanceLockHash
SaveChanges interceptor/checks for drift prevention
Optional migration helper docs/templates (not auto-running migrations)
6) Non-bypass enforcement model (mandatory)
Enforce governance in all layers:
Create/Update
Profile comes only from authoritative resolver
Caller cannot override governance lock fields
Read/Query
Validate governance lock hash and strictness before returning DTOs
Execution runtime
Validate pipeline/playbook (or equivalent units) lock compatibility
Validate governed output schema completeness and references
Persistence
Required/non-null governance fields
Indexed profile version where useful
Integrity checks before save
Failure behavior:
explicit validation/conflict exceptions
no silent defaults
no broad catch-and-continue patterns
7) Public API design (stable surface)
Expose minimal stable entry points:
services.AddGoodtocodeAiGovernance(...)
IGovernanceProfileResolver
IGovernanceEnforcer
GovernanceProfile
GovernanceLock/hash utilities
governed output validators
Keep internals hidden; keep package API small and versionable.
Start at 0.x until two real adopters are stable
Move to 1.0.0 once contracts are proven
SemVer rules:
breaking contract changes => major
additive fields/validators => minor
bugfixes => patch
Add package(s)
Implement IGovernanceProfileResolver
Register governance services in DI
Add governance fields to governed entities
Wire create/update/query/runtime enforcement points
Add targeted tests:
create persists strict lock
update preserves/refreshes lock per policy
query rejects drift
runtime rejects mismatched governance
governed output schema validation
Phase 1 (foundation)
Build domain + hash/schema validators
Publish prerelease
Phase 2 (application)
Add Goodtocode mediator/validation integrations
Add profile resolver + enforcer pipeline
Phase 3 (persistence)
Add EF helpers + interceptor package
Add implementation samples
Phase 4 (hardening)
Add full contract tests
Validate with at least two external repos
Promote to 1.0.0
No product-specific terms (no Cannery/Crucible/Conductor naming)
No MediatR references
No framework-locking behavior in domain
No optional governance for critical paths