Skip to content

VGSF CONSTITUTIONAL TECHNICAL ARCHITECTURE — BOOK II — PART B: CONSTITUTIONAL ENGINEERING METHODOLOGY
Chapter 5 of 8 in this Part

M5 — Phases 3–4: Verification Architecture and Implementation

Document record
FieldValue
Constitutional SeriesM — Constitutional Engineering Methodology
Primary SourceCONSTITUTIONAL_LIFECYCLE_STANDARD.md + DOMAIN_PATTERN_GUIDANCE.md + UNIVERSAL_PRACTICES_CATALOG.md
VersionV2.1 (CAP030C, 2026-06-15)
RatifiedRATIFIED — CAP027B (Methodology V2.0) + CAP030C (V2.1 Phase -1 amendment)
Applies ToREF003–REF014
Position in BookPart B, Chapter 5 of 8

M4 established the specification and its independent review. M5 (Phases 3–4: Verification Architecture and Implementation) establishes how the specification becomes a verifiable system: Verification Functions written before implementation, and implementation executed under that verification regime.


§1 — The Constitutional Priority of Verification Architecture

The most critical constitutional sequence in Phases 3 and 4 is the order: Phase 3 (Verification Architecture) precedes Phase 4 (Implementation). This is not logistical preference — it is constitutional design. Verification Functions (VFs) designed after implementation will inevitably be influenced by what was implemented. VFs designed before implementation are governed only by the specification and the constitutional invariants, which is the correct constitutional ground.

An implementation that was built before the VFs were designed has already determined the test landscape. The implementer knows what was built; the verification architect is constrained to test what exists. This inverts the constitutional relationship: the verification architecture should govern the implementation, not reflect it. Phase 3 before Phase 4 enforces this relationship structurally.


§2 — Phase 3: Verification Architecture

Role: R-VARCH (Verification Architect) — MUST be distinct from Phase 1 R-ARCH
Entry condition: Phase 2 accepted; Phase 2a rulings ratified (if applicable)

§2.1 — Mandatory Deliverables

  • Verification architecture
  • Verification traceability matrix (all constitutional invariants → tests)
  • Mutation catalog
  • Seed data architecture
  • Trial protocol (unconditional + conditional categories — PP-003)
  • Infrastructure specification
  • Constraint incorporation report (all Phase 2 constraints addressed)
  • Executive Verdict

§2.2 — Minimum Test Requirements

  • All 12 DB-layer constitutional invariants MUST have at least one test
  • All P1 BLOCKER tests must cover: temporal exclusivity, no-delete, history immutability, auth fail-closed
  • Conditional test categories MUST be defined for all gated scope (PP-003)

§2.3 — Gate Criteria

VerdictMeaning
VERIFICATION_ARCHITECTURE_COMPLETEAll unconditional tests designed; all traceability confirmed
VERIFICATION_ARCHITECTURE_COMPLETE_WITH_CONDITIONAL_SCOPEAll unconditional tests designed; conditional scope defined and gated

§2.4 — The Verification Traceability Matrix

The verification traceability matrix is the constitutional instrument that connects VOs (from Phase 1) to VFs (produced in Phase 3). Every constitutional invariant must trace to at least one test. If a VO cannot be traced to a VF, either the VO is not testable (a Phase 1 defect that Phase 2 should have caught) or the VF was not designed (a Phase 3 gap that must be addressed before Phase 4 begins).

§2.5 — Seed Data Architecture

Phase 3 MUST specify the seed data required to execute the trial protocol. The seed data architecture is constitutional, not incidental: the tests must have known-good data to assert against, known-bad data to test rejection of, and boundary data to test edge conditions. A verification architecture without a seed data specification is a test suite that cannot be executed reliably.

Constitutional requirement: Seed data must cover:

  • All registry types (every type code must have at least one seed record)
  • All lifecycle states (records in each valid state must be present)
  • Boundary conditions for temporal constraints (records at valid_from/valid_to boundaries)
  • Negative test data (records designed to be rejected by constitutional constraints)

§2.6 — Mutation Testing

The mutation catalog specifies the constitutional mutations that the verification suite must detect. A mutation is a deliberate violation of a constitutional invariant: a DELETE of a constitutional record (PROHIB-DB-001); a direct write to a system-time column (PROHIB-DB-002); a service request without JWT (UP-002 violation); a governance record in a nullable main-table column (PROHIB-I-005 violation).

Constitutional requirement: The mutation catalog must be derived from the prohibitions (see [M1.§9]) and the VOs. Every prohibition that has a testable mechanical consequence MUST have a corresponding mutation in the mutation catalog and a VF that detects that mutation.

§2.7 — PP-003: Conditional Test Category Pattern

Source: CAP026E Category G; R1-B gate

Practice: When a constitutional constraint (pending amendment, CAC deliberation, Primary Steward ruling) gates a subset of tests, those tests shall be: fully specified but labelled CONDITIONAL, skipped during execution, excluded from the unconditional release gate, and not counted as FAIL.

Constitutional value: Tests for planned-but-not-yet-implemented features should not block certification of implemented features. Conditional categorization allows partial service launches while maintaining constitutional traceability for the gated scope.

Mandate (presumptive): Verification architectures for REF003–REF014 MUST define conditional test categories for any scope gated by pending constitutional acts. Conditional tests MUST be fully specified and MUST become unconditional when their gate clears.


§3 — Phase 4: Implementation

Role: R-IMPL (Implementer) — MUST be distinct from Phase 2 R-REVIEW and Phase 3 R-VARCH
Entry condition: Phase 3 complete; active RO-series instrument (UP-007)
Authority bounded by: RO-series instrument

§3.1 — Mandatory Deliverables

  • Implementation architecture
  • Domain service implementation
  • Repository implementation
  • Middleware implementation
  • Event implementation
  • Governance routing implementation (if applicable — PP-004)
  • Implementation evidence
  • Executive Verdict (IMPLEMENTATION_COMPLETE)

§3.2 — Mandatory Implementation Standards

Package architecture: MUST use hexagonal structure (UP-001)
Events: MUST use transactional outbox pattern (UP-004)
Entity scope: MUST use RLS + SET LOCAL pattern (UP-003)
No-delete: MUST be enforced at DB trigger layer (UP-005)

§3.3 — Prohibited Actions in Phase 4

  • Modifying Phase 3 test protocol
  • Modifying constitutional DDL outside RO scope
  • Self-verifying

The prohibition on modifying the Phase 3 test protocol is constitutional: if the implementer could modify the VFs, they could modify the standard against which their own implementation is measured. This is self-certification by modification of the standard rather than by issuing a verdict.

§3.4 — Gate Validation: Phase 3 → Phase 4

From PhaseTo PhaseGate validation required
3 → 4Architecture → ImplementationPhase 3 complete; RO-series active

§3.5 — Gate Validation: Phase 4 → Phase 5

From PhaseTo PhaseGate validation required
4 → 5Implementation → VerificationImplementation complete; infrastructure preconditions met

§4 — Universal Practice Application in Phases 3–4

§4.1 — UP-001: Hexagonal Package Architecture

Evidence — REF001: CAP023E REF001_SERVICE_PACKAGE_ARCHITECTURE.md specified 6-layer hexagonal architecture (controllers → application → domain → persistence → events → infrastructure). All implementation proceeds through layers; no layer skipping permitted.

Evidence — REF002: CAP026C REF002_SERVICE_PACKAGE_ARCHITECTURE.md extended to hexagonal + graph traversal layer + extension profile layer. CAP026J (corrective) added governance_satellite_repository.py as a new repository module without touching domain or middleware layers. The boundary held.

Constitutional value: Domain logic changes (corrective or enhancement) can be made without destabilizing middleware or infrastructure. Regression risk is bounded to the changed layer.

Mandate for REF003–REF014:

All REF domain service layers MUST use hexagonal package architecture. Domain logic MUST NOT depend on infrastructure. Infrastructure implementations MUST NOT leak into domain objects. Layer boundaries MUST be enforced by code review checklist.

§4.2 — UP-002: Fail-Closed Middleware Chain

Evidence — REF001: CAP023E REF001_MIDDLEWARE_ARCHITECTURE.md specified: missing JWT → 401; invalid JWT → 401; expired JWT → 401. No fallback to unauthenticated access. MW chain executes in fixed order; any failure terminates the request.

Evidence — REF002: CAP026C specified 8 middleware layers in fixed execution order. CAP026K MW-001 (missing JWT → 401) and MW-002 (invalid JWT → 401) PASS in every test execution. No middleware bypass found in AI-001–AI-008 adversarial tests.

Constitutional value: Authentication is a constitutional guarantee. A request that reaches a domain handler without authentication is a constitutional violation. The fail-closed pattern mechanically prevents this.

Mandate for REF003–REF014:

All REF domain middleware chains MUST be fail-closed. JWT validation MUST be the first substantive middleware layer. No request MAY reach a domain handler without passing all middleware layers. Fail-open fallbacks are constitutionally prohibited.

§4.3 — UP-003: RLS + SET LOCAL Entity Scope Pattern

Evidence — REF001: CAP023B (ADR-001) established the canonical pattern: JWT → extract entity_id → SET LOCAL app.current_entity_id = $entity_id → all queries execute under RLS. Application layer NEVER adds entity_id = $n filter to SQL. SECURITY DEFINER get_entity_scope() is the only authorized scoping mechanism.

Evidence — REF002: CAP026C MW-3 specified SET LOCAL entity_id after JWT validation. CAP026K MW-006 confirmed entity_id set correctly. CAP026H and CAP026K found no entity isolation violations.

Constitutional value: RLS enforcement at DB layer means a compromised application layer cannot exfiltrate cross-entity data. Application-layer filtering creates races and inconsistencies; DB-layer RLS is authoritative.

Mandate for REF003–REF014:

All REF domain services MUST use RLS + SET LOCAL for entity isolation. Application SQL MUST NOT contain entity_id = $n filters. get_entity_scope() SECURITY DEFINER MUST be the only authorized scope-reading mechanism. Superuser DB connections are prohibited in service code.

§4.4 — UP-004: Transactional Outbox Pattern for Events

Evidence — REF001: CAP023E REF001_EVENT_ENGINEERING_SPECIFICATION.md specified the outbox pattern: events written to ref001_event_outbox table within the same database transaction as the domain write; a relay process publishes asynchronously.

Evidence — REF002: CAP026C specified ref002_event_outbox. CAP026K EV-001–EV-010 all PASS. DFO+FON atomicity (PROHIBITION-6) confirmed: both edges and their events written in the same transaction (same-timestamp evidence in CAP026K).

Constitutional value: Event delivery is a constitutional obligation (integration contracts). The outbox pattern ensures: (a) no phantom events (event exists iff domain write succeeded), (b) no missed events (relay retries without duplicate business logic), (c) transaction-local ordering (events within a transaction reflect domain write sequence).

Mandate for REF003–REF014:

All REF domain services MUST use the transactional outbox pattern. Domain writes and their event records MUST occur in a single database transaction. No service MAY publish events by direct broker API calls from application code. All event tables MUST have a relay process responsible for delivery.

§4.5 — UP-005: No-Delete DB Trigger Layer

Evidence — REF001: CAP023E PROHIBITION 3 / U2 Doctrine: no physical deletion through any service pathway. prevent_delete_* and prevent_truncate_* triggers enforce at DB layer. CAP023E Code Review Checklist item 9: "Does any code path allow DELETE, UPDATE, or TRUNCATE against REF-001 tables? → Block."

Evidence — REF002: CAP026B confirmed prevent_delete_relationship_edges, prevent_truncate_relationship_edges, prevent_delete_relationship_types, prevent_truncate_relationship_types triggers. CAP026K EX-007, EX-008, EX-009 all PASS. Trigger enforcement confirmed.

Constitutional value: Deletion is irreversible. The constitutional model uses bitemporal close operations (valid_to, superseded_at) to end relationships. Physical deletion bypasses the audit trail and creates constitutional voids.

Mandate for REF003–REF014:

All REF domain schemas MUST have DB-layer no-delete and no-truncate triggers on all constitutional tables. Application-layer prohibitions alone are insufficient. DB triggers are the constitutional backstop. Any code path that issues DELETE or TRUNCATE against a constitutional table is a P1 BLOCKER.


§5 — Domain Pattern Application in Phases 3–4

§5.1 — Universal Pattern Application (All Domains)

Every REF domain service layer MUST apply these patterns regardless of domain-specific characteristics:

PatternStandard
Hexagonal package architectureUP-001
Fail-closed middleware chainUP-002
RLS + SET LOCAL entity scopeUP-003
Transactional outbox for eventsUP-004
No-delete DB trigger layerUP-005
Constitutional benchmark before specificationUP-006
RO-series implementation authorizationUP-007

§5.2 — Domain-Conditional Patterns

The following patterns apply when a domain exhibits the specified structural characteristic. The Phase 3 Verification Architect must evaluate each domain-conditional pattern and include or exclude it in the verification architecture with documented constitutional rationale.

DP-001: Bitemporal Table Pattern

Trigger: Domain maintains records that have both application-time validity (when something was true in the world) and system-time recording (when the system learned about it).

Applicability: ALL REF domains that maintain mutable records over time (virtually all REF domains).

Pattern:

  • Application time: valid_from TIMESTAMPTZ NOT NULL, valid_to TIMESTAMPTZ (null = open-ended)
  • System time: recorded_at TIMESTAMPTZ NOT NULL DEFAULT now(), superseded_at TIMESTAMPTZ (Lineage B inline) OR separate _history table (Lineage A)
  • Bitemporal BEFORE UPDATE trigger: (a) close superseded row (set superseded_at = now()), (b) insert new row with updated values, (c) guard: if row already has superseded_at IS NOT NULL → raise immutability exception (RC-C from REF002)
  • No service layer modification of recorded_at or superseded_at — these are trigger-owned

Lineage A vs Lineage B:

  • Lineage A: Separate _history table; current record in main table; history records append-only
  • Lineage B: Single table; superseded_at distinguishes current (NULL) from historical (NOT NULL); in-place bitemporal model
  • Constraint: The Lineage B model (REF002) lacks natural cross-period linking. Implementers choosing Lineage B must acknowledge that ENDPOINT-005 equivalent history endpoints will not support cross-period timeline reconstruction without additional implementation.

Evidence base: REF002 AI-006 (P1 BLOCKER resolved by adding superseded_at guard to trigger) and REF001 history trigger pattern.

DP-002: GiST Temporal Exclusivity Pattern

Trigger: Domain has records that must be unique within a time period (i.e., at most one active record of a given type per entity per time range).

Applicability: REF002 (relationships), REF001 (party/classifications), REF007 (obligations), REF014 (initiatives).

Pattern:

ALTER TABLE [table] ADD CONSTRAINT exclude_[type]_exclusivity
EXCLUDE USING gist (
    [subject_key_column] WITH =,
    [exclusivity_group_column] WITH =,
    tstzrange(valid_from, coalesce(valid_to, 'infinity')) WITH &&
) WHERE ([conditional_clause]);

Requirements:

  • PostgreSQL btree_gist extension MUST be installed
  • The temporal range function tstzrange(valid_from, coalesce(valid_to, 'infinity')) is the canonical pattern
  • GiST constraints are DB-layer only — service layer receives 409 / exclusivity violation
  • Test coverage MUST include: overlapping range rejected, adjacent range accepted, open-ended range conflict

Evidence base: REF002 EX-001–EX-012 (all PASS in CAP026H and CAP026K).

DP-003: Symmetric/Self-Reciprocal Type Pattern

Trigger: Domain has relationship or association types where A→B and B→A represent the same fact (PARENT_OF/CHILD_OF, SPOUSE_OF, SIBLING_OF, PEER_OF).

Applicability: REF002 (relationship types with reciprocal_type_code == type_code).

Pattern:

  • SymmetricNormalizer domain service: Before any DB write, normalize (subject_id, object_id) pair by lexicographic UUID ordering for self-reciprocal types. Lower UUID becomes canonical subject.
  • DB trigger backup: A trigger enforces canonical ordering at DB layer as defense-in-depth.
  • API transparency: Clients submit (subject_id, object_id) in any order; normalization is internal.
  • Read surface: Bidirectional view (vw_[domain]_graph_bidirectional) presents both directions from the physical directional record.

Requirements:

  • The normalizer MUST be a domain service (not an adapter or controller)
  • Self-reciprocal types MUST be identified in the relationship type registry
  • Non-self-reciprocal types (PARENT_OF → CHILD_OF) MUST NOT be normalized

Evidence base: REF002 CR-001, CR-002, CR-003, A-001, A-002 (all PASS).

DP-004: Governance Type Satellite Table Pattern

Trigger: Domain has governance types or subtype-specific metadata that must be persisted separately from the base record.

Applicability: REF002 (chief_finance_officer, delegated_finance_officer, acting_authority, finance_officer_notification), REF007 (obligation types with specific terms), REF014 (initiative governance metadata).

Pattern:

  • One satellite table per governance type (or per group of types with identical columns)
  • Satellite table: id UUID PRIMARY KEY, [parent_record_id] UUID NOT NULL REFERENCES [parent_table](id), type-specific columns
  • Service routing: the router determines which satellite table to write to based on type code
  • Satellite repository: one insert function per satellite table
  • Atomicity: if governance type requires paired records (e.g., REF002 DFO+FON), enforce with FK constraint between satellite rows
  • No nullable metadata columns on the main constitutional table

IGO variant (constitutionally blocked type): If a type is blocked by CAC deliberation or amendment forward condition, create the satellite table with a BEFORE INSERT trigger that raises a constitutional violation. This enforces the block at DB layer regardless of service layer state.

Evidence base: REF002 GR-001–GR-006 (all P1 BLOCKERs; all PASS after CAP026J).

DP-005: Extension Profile Pattern (6NF)

Trigger: Domain has type-specific attributes that vary by record type (e.g., employment metadata for employment relationships, venue metadata for events).

Applicability: REF002 (employment_relationship_profile — gated on R1-B), REF004 (event profiles), REF014 (initiative profiles).

Pattern:

  • One extension table per profile type: id UUID PRIMARY KEY, [parent_id] UUID UNIQUE NOT NULL REFERENCES [parent_table](id), profile-specific columns
  • UNIQUE constraint on the FK enforces the 1:1 relationship
  • Extension table has its own system-time trigger (bitemporal)
  • API: extension profile endpoints are separate from base entity endpoints (ENDPOINT-009/010 in REF002)
  • The base entity endpoint does NOT return extension profile data
  • The extension profile endpoint does NOT duplicate base entity data

Requirements:

  • Extension table MUST have constitutional DDL before verification of extension endpoints begins (R1-B pattern from REF002 is the canonical example of what happens when this is missing)
  • Each extension type MUST have its own amendment authorization if added post-freeze

Evidence base: REF002 Category G (10 tests — correctly gated pending R1-B amendment; extension architecture constitutionally valid per G2A).

DP-006: Federation Governance Pattern

Trigger: Domain has records that are scoped to an organizational context (multi-tenant relationship governance).

Applicability: REF002 (context_identity_id scoping for contextual relationship types).

Pattern:

  • Contextual records: context_identity_id UUID REFERENCES [organization_table](id) — NOT NULL for contextual types, NULL for universal types
  • Federation trigger: validates that universal types have NULL context, contextual types have non-NULL context (ORGANIZATION type), and context_matches_object types have context_identity_id = object_identity_id
  • Service middleware: validates context resolution before DB interaction
  • API: context_identity_id is a first-class field in creation requests for contextual types

Evidence base: REF002 FED-001, FED-002 (PASS in CAP026H and CAP026K).

DP-007: Bidirectional View Pattern

Trigger: Domain records can be queried from multiple perspectives (e.g., "all relationships involving party X" includes both A→X and X→B records from a directed edge table).

Applicability: REF002 (vw_relationship_graph_bidirectional), REF004 (event participants), REF014 (initiative members).

Pattern:

CREATE VIEW vw_[domain]_bidirectional AS
    SELECT id, subject_id AS party_id, object_id AS counterpart_id, 'FORWARD' AS direction, ...
    FROM [table]
UNION ALL
    SELECT id, object_id AS party_id, subject_id AS counterpart_id, 'REVERSE' AS direction, ...
    FROM [table];

Requirements:

  • The bidirectional view MUST be the canonical API query surface — direct table queries for traversal are prohibited (BV-010 equivalent)
  • The view MUST include a direction field so clients know which perspective they are receiving
  • Self-reciprocal type records appear twice in the view (once forward, once reverse)

Evidence base: REF002 BV-001–BV-010 (all PASS).

§5.3 — Pattern Applicability Matrix

REF DomainDP-001 BitemporalDP-002 GiST ExclusivityDP-003 SymmetricDP-004 Governance SatelliteDP-005 Extension ProfileDP-006 FederationDP-007 Bidirectional
REF001 (Identity)✅ IMPLEMENTED——————
REF002 (Relationships)✅ IMPLEMENTED✅ IMPLEMENTED✅ IMPLEMENTED✅ IMPLEMENTED⚠️ Gated R1-B✅ IMPLEMENTED✅ IMPLEMENTED
REF003 (Place)Likely requiredUnlikely—PossiblePossibleUnlikelyUnlikely
REF004 (Project/Event)Likely requiredLikelyUnlikelyPossibleLikelyPossiblePossible
REF007 (Obligation)RequiredLikely—RequiredRequiredPossibleUnlikely
REF008 (Authority)RequiredLikely—RequiredPossibleRequired—
REF014 (Initiative)RequiredLikely—PossiblePossiblePossibleUnlikely

Note: REF005–REF006, REF009–REF013 not yet constituted. Matrix for those domains to be determined at their Phase 0 assessment.


§6 — Presumptive Practice: PP-004 Governance Satellite Table

Source: CAP026J RC-A; AMD-REF002-2026-001

Practice: Governance relationship or entity types with type-specific metadata MUST persist that metadata in dedicated satellite tables (NOT nullable columns on the main table). Each satellite table: (a) has a NOT NULL FK to the parent record, (b) stores only type-specific fields, (c) enforces atomicity via DB-layer FK constraints where multi-table atomicity is required.

Constitutional value: Nullable metadata columns on main tables corrupt the schema with type-conditional data that breaks 4NF. Satellite tables make type-specific governance data queryable, indexable, and FK-enforced independently.

Mandate (presumptive — domain-conditional): REF domains with governance types or type-specific entity metadata MUST use the satellite table pattern. Nullable metadata columns on constitutional tables are prohibited.


§7 — Presumptive Practice: PP-005 Constitutionally Blocked Type

Source: CAP026J RC-A (IGO pattern); GR-006

Practice: When a constitutional mandate (CAC deliberation, amendment forward condition) blocks a specific relationship or entity type from being created, the block MUST be enforced at TWO layers: (1) service layer guard before any DB interaction, (2) DB trigger that raises a constitutional violation exception.

Constitutional value: Defense-in-depth for constitutional blocks. Service-layer-only blocking is vulnerable to direct DB access. DB-trigger-only blocking may produce cryptic errors. Both layers together: catch bypass attempts AND produce comprehensible constitutional violation messages.

Mandate (presumptive): Any REF domain with constitutionally blocked types MUST implement both service-layer and DB-layer guards. The DB trigger is the constitutional backstop.


CONSTITUTIONAL_LIFECYCLE_STANDARD.md — Phases 3, 4 specification | 2026-06-14 | CAP027A
DOMAIN_PATTERN_GUIDANCE.md | 2026-06-14 | CAP027A
UNIVERSAL_PRACTICES_CATALOG.md | 2026-06-14 | CAP027A


Constitutional Colophon — M5
This chapter establishes Phases 3 and 4 — Verification Architecture and Implementation — as the constitutional sequence in which the specification's Verification Obligations are converted into executable Verification Functions before any implementation code is written, and then the implementation is executed within the strict bounds of the RO-series authorization instrument, universal and domain-conditional patterns, and the unchanged Phase 3 trial protocol.
It operates within Part B under the governing principle that constitutional trustworthiness — not mere correctness — is the objective of Dharma ERP Constitutional Engineering Methodology V2.1.
Readers proceeding to M6 (Phases 5–6: Verification Execution and Certification) should carry forward: the Phase 3 trial protocol is the constitutional standard against which Phase 5 verification executes — the implementer cannot modify it, and the verifier must execute all unconditional tests in it without exception.


Test Dharma ERP and tell us what you find.

The trial uses sandboxed demo data across twelve core modules. Look around, try the forms, and review what works and what does not.