Scope and Evolution Notice: This document is a forward-looking v2 target architecture blueprint (ADR) designed from first principles. The current public co-arising v1 baseline and bank-wealth-demo remain stable and runnable; for v2, we eliminate the historical burden of maintaining dual expression engines plus a lossy lowering bridge, making controlled EARS 1.0 the single behavioral trunk from specification and SMT proof through Canonical Model v2, deterministic scaffolding, and locked AI @cloze TDD in the isolated zone.

1 AST
One native behavioral IR (EARS IR) end-to-end; retires legacy dual expressions and lowering
5 + k
5-check SMT gate plus k-step BMC; unproved specs never emit a Canonical Model
80 / 20
L1 rules compile zero-token into scaffolds; L2/L3 & app zones run locked oracle TDD
exit 2
PreToolUse + Stop Hooks physically lock scaffolds, oracles, and @cloze bounds

1. Why v2 Retires Dual Expression Engines and Any Lowering Bridge

Across metarch-truthsrc v1 (0.5.0), the project validated that a git-native Event Storming tree can deterministically compile into typed semantic products, Onion Architecture scaffolds, and bidirectional code anchors. Meanwhile, the co-arising EARS 1.0 Technical Specification established controlled EARS paired with single-hop SMT-LIB 2 formal verification.

However, binding EARS against real v1 projects exposed an unmistakable structural mismatch: v1's legacy slice-guard expression language (expressions.mjs v4 + escaped @guard strings in .slice.yaml) does not live on the same expressive plane as EARS 1.0:

Dimension v1 Legacy Expressions (domain-decision@4 / @guard) co-arising 2.0 EARS-Native Trunk
Authoring signal-to-noise Escaped single-line JSON strings (often 400+ chars), no named predicate reuse, opaque to domain experts Bilingual isomorphic syntax (Canonical EN + CN Profile), positive where: predicate reuse, deterministic Style E AC & Style B DMN table projections
Global & temporal invariants Per-command short-circuit guards only; no global ALWAYS axioms, SHALL NOT prohibitions, or cross-command safety properties First-class axioms: ALWAYS, SHALL / SHALL NOT conflict detection, and k-step bounded model checking (BMC)
Mathematical expressiveness Linear addition/subtraction and comparisons only; no multiplication * (shares * nav <= netAmount) and no FEEL intervals [min..max] Follows AWS Cedar decidability partitioning: L1 (QF_AUFLIA) / L2 (QF_NIA + BMC) / L3 (extern)
Isolated zone (handwritten/) coverage Blind spot: trusted admission, replay dedup, cross-aggregate orchestration, and read-model isolation live only in prose Native layer: application contracts (pin, dispatch, respond, expose) compiled into locked executable BDD oracles for AI TDD

Inserting an EARS → legacy @guard lowering compiler merely to preserve v1 generators would lock the codebase into permanent double maintenance: two expression ASTs, two type checkers, and a leaky translation seam that breaks whenever EARS adds nonlinear math, intervals, prohibitions, or application-layer contracts.

Because the existing public showcase remains runnable as-is, the cleanest long-term decision is to keep v1 stable and build v2 natively around EARS from start to finish.

FIGURE 01 · v1 TRANSITIONAL BRIDGE VS v2 EARS-NATIVE SINGLE TRUNK
v1 TRANSITIONAL SHAPE (Cost of backward lowering: dual ASTs + lossy bridge + unverified handwritten zone) .slice.yaml @guard Legacy AST #1 Lossy Lowering EARS → guards v4 Canonical v1 Aggregate L1 only handwritten/ left outside compiler Prose specs · no SMT · drift risk v2 EARS-NATIVE SINGLE TRUNK (Zero lowering loss · pre-codegen SMT gate · unified domain & isolated-zone loop) Orthogonal Truth YAML Struct + EARS Single behavioral AST SMT Hard Gate Z3 / cvc5 5-check + BMC Blocks unproved specs Canonical Model v2 Native EARS IR + TestIR + SQLite Dep Graph Dual-Channel Delivery 4A: L1 Zero-Token Scaffold 4B: Locked Oracle Cloze TDD
Figure 1: By retiring legacy @guard lowering, v2 carries a single proved EARS IR straight into Canonical Model v2, deterministic code generation, and locked AI Cloze TDD.

2. End-to-End co-arising 2.0 Architecture Flowchart

The full four-layer architecture below maps every asset, verification gate, and physical anti-cheat feedback loop from git-native truth to verified runtime code:

FIGURE 02 · CO-ARISING 2.0 END-TO-END ARCHITECTURE & CONTROL FLOW
LAYER 1 · GIT SINGLE AUTHORING TRUTH (Orthogonal: Structure in YAML, Behavior in EARS) Structure Truth (truth/*.yaml) VOs & exact decimals (Money, scale) State defaults · Cmd/Event schemas Saga topology · ReadModel · No @guard Behavior Truth (truth/**/*.ears · EN/CN) • layer: domain — axioms · rules · post folds • layer: application — admission · flows · views Single behavioral surface · Style A & Style C Drafting Aid (Unchecked-in) Plain notes / Event Storming LLM drafting · Human merge LAYER 2 · SINGLE FRONTEND, READ-ONLY PROJECTIONS & SMT PROOF GATE Single EARS Parser + Unified Type & Symbol Checker Positive naming lint · L1/L2/L3 auto-routing · retires expressions.mjs Read-Only Projections • Style E: Plain-text AC (.md) • Style B: DMN Table (.md) Single-Hop SMT-LIB 2 Compiler → Z3 / cvc5 1.Conflicts · 2.Gaps · 3.Invariants · 4.Dead rules · 5.Witnesses + k-step BMC All SMT Proofs Green? Fail → Hard Block A/B Clarification Card Z3 model + :named IDs No codegen emitted No (SAT defect) Yes (Proved + Witnesses) LAYER 3 · CANONICAL MODEL v2 (EARS-NATIVE SINGLE IR · ZERO LOWERING LOSS) Structure Meta Types · State · Saga Native EARS IR v2 First-Hit · emit/post folds Proved TestIR Z3 witnesses + BMC Dependency Graph knowledge.sqlite cache domain L1 + structure L2/L3 + app isolated zone CHANNEL 4A · ZERO-TOKEN CODEGEN (~80%) Multi-Language Deterministic Generators Scala · TypeScript · Java · Rust · Go Consume EARS IR directly · zero LLM generated-scaffold/ (Read-Only Locked) • Aggregate Behavior + EventHandler • Protobuf / Codec / Saga Host / Pure Oracle • Port Traits + empty @cloze slot stubs Stamped with @generated & @ProvenanceId Drift-Free L1 Core & Architecture Rebuildable on every spec edit · never hand-edited CHANNEL 4B · ISOLATED AI @CLOZE TDD (~20%) Locked Executable Oracles .feature + *EarsSpec generated-tests/ SHA-256 Sandwich Context Pack Type sigs + @caller rules Graph-sliced · zero-grep AI Agent Single-Slot Cloze TDD Edits confined to @cloze:start..end PreToolUse Hook Out-of-bounds exit 2 Stop Hook Triple Gate (exit 2 forces self-heal) 1. Test SHA-256 integrity · 2. Run *EarsSpec · 3. AST anchor audit Fresh Blind Subagent (contract-reviewer · skip style) Blocks witness hardcoding → persists Provenance & graph anchors
Figure 2: End-to-end co-arising 2.0 control flow. Solid teal edges carry mathematically verified deterministic data; dashed red edges enforce physical blocking and self-healing feedback (A/B clarification cards, PreToolUse write guard, Stop Hook triple gate).

3. Orthogonal Single Truth Source: Structure in YAML, Behavior in EARS

The first invariant of v2 is orthogonal separation: YAML carries zero escaped business predicates, and EARS carries zero serialization or storage boilerplate:

Concern Sole Authoring Surface Owns Explicitly Excluded
Structure truth truth/<sys>/contexts/<ctx>/*.yaml ValueObject schemas, exact numeric scale/precision/units, Protobuf wire/storage codecs, aggregate stateFields defaults, command/event signatures, Saga & Pipeline topology, read-model schemas @guard boolean strings, inline business logic
Behavior truth truth/<sys>/contexts/<ctx>/specs/**/*.ears where: positive predicates, extern black-box boundaries, axioms: global invariants, rules: domain reject/idempotency/transition rules, post: folds, layer: application admission & view contracts Storage types, wire codecs, framework annotations, implementation code
Review projections projections/ac/**, projections/tables/** Zero-LLM deterministic Style E plain-language AC and Style B DMN decision tables Never hand-edited (rebuilt from truth on demand)

Orthogonal Pairing Example: Dual-Cap Quota Slice with Zero Duplication

Structure declares what fields and exact decimal scales exist; EARS declares the laws governing them:

# truth/bank-wealth/contexts/bankwealth/aggregates/fund-quota/aggregate.yaml (pure structure, zero @guard)
kind: aggregate
name: FundQuota
stateFields:
  - minPurchase: AmountDecimal = "0.00"
  - maxSingleLimit: AmountDecimal = "0.00"
  - fundTotalUsed: AmountDecimal = "0.00"
  - fundTotalCap: AmountDecimal = "0.00"
  - perAccountCap: AmountDecimal = "0.00"
  - accountUsed: Map[AccountId, AmountDecimal] = []
commands:
  - name: ReserveSubscriptionQuota
    parameters: [accountId: AccountId, amount: AmountDecimal]
    produces: [SubscriptionQuotaReserved]
# truth/bank-wealth/contexts/bankwealth/specs/fund-quota-reserve.ears (sole behavioral truth)
slice FundQuota.ReserveSubscriptionQuota

where:
  validAmount   = amount in [quota.minPurchase..quota.maxSingleLimit]          as "Single amount within valid range"
  withinFundCap = quota.fundTotalUsed + amount <= quota.fundTotalCap           as "Within total fund subscription cap"
  withinAcctCap = quota.accountUsed[accountId] + amount <= quota.perAccountCap as "Within per-account cap"

axioms:
  [AX-Q-1] ALWAYS quota.fundTotalUsed <= quota.fundTotalCap
  [AX-Q-2] ALWAYS quota.accountUsed[accountId] <= quota.perAccountCap

rules:
  [QUOTA_AMOUNT_RANGE] IF not validAmount   THEN SHALL reject request with QUOTA_AMOUNT_RANGE
  [QUOTA_FUND_CAP]     IF not withinFundCap THEN SHALL reject request with QUOTA_FUND_CAP
  [QUOTA_ACCOUNT_CAP]  IF not withinAcctCap THEN SHALL reject request with QUOTA_ACCOUNT_CAP

  [QUOTA_RESERVED]     WHILE validAmount and withinFundCap and withinAcctCap
                       WHEN ReserveSubscriptionQuota
                       SHALL emit SubscriptionQuotaReserved
                       post:
                         quota.fundTotalUsed'          = quota.fundTotalUsed + amount
                         quota.accountUsed'[accountId] = quota.accountUsed[accountId] + amount

A single symbol-table binder validates every path, exact decimal scale, command parameter, event name, and rule anchor before SMT compilation starts — catching drift such as referencing occurrenceId instead of occurrence.occurrenceId immediately at compile time.

4. The Mathematical Proof Gate: No Canonical Model v2 Without Proof

In v1, verification ran downstream after code was generated. In v2, SMT-LIB 2 proof checking via Z3 / cvc5 becomes a hard pre-compilation gate in front of Canonical Model v2.

  1. Automatic Decidability Routing:
    • L1 Decidable Core (QF_AUFLIA): fixed-point linear arithmetic, enum state machines, monotonic cursors, Map[K, V] encoded as presence bitmap (Array K Bool) + value array (Array K V), and FEEL intervals [start..end). Millisecond complete solving.
    • L2 Bounded Extension (QF_NIA isolated + k-step BMC): local nonlinear multiplication (shares * nav <= netAmount) runs isolated under QF_NIA with a 2-second timeout; multi-command stateful slices unroll k-step BMC to prove cross-step safety (such as a skipped due slot never being resurrected into backlog).
    • L3 Black-Box External Layer (extern / @host): session auth, CSRF verification, external TA receipt parsing, and deterministic host IDs map to uninterpreted Boolean predicates or symbolic constants — preserving 100% Boolean completeness checks without leaking infrastructure into SMT.
  2. Automatic Fixed-Point Scale Alignment:
    • Each numeric variable tracks its decimal scale (Money scale = 2, NAV scale = 4, integer shares scale = 0). Comparisons like shares * nav <= order.netAmount automatically align scales ((* shares nav) <= (* netAmount 100)), eliminating floating-point drift.
  3. Five (push 1) ... (pop 1) Checks & A/B Clarification Cards:
    • Mutual-exclusion conflicts: SAT(Axioms ∧ G_emit ∧ G_reject) and SHALL vs SHALL NOT must be unsat.
    • Logic gaps: SAT(Axioms ∧ ¬(G_1 ∨ ... ∨ G_n)) must be unsat; on sat, the decoded counterexample renders an A/B Clarification Card for human decision.
    • Invariant induction: SAT(Inv(s) ∧ G_i ∧ Post(s, s') ∧ Frame(s, s') ∧ ¬Inv(s')) must be unsat.
    • Dead-rule detection: UNSAT(Axioms ∧ G_i) reports blocking axioms via get-unsat-core.
    • Boundary witness synthesis: (get-model) extracts concrete decoded decimals and enum samples directly into TestIR.

5. Native Canonical Model v2: Freezing Three Core Semantic Contracts

To let multi-language generators consume Canonical Model v2 directly with zero legacy @guard lowering, v2 freezes three contracts inside co-arising.canonical/v2:

Contract 1: Single Native Behavioral IR (co-arising.ears-ir/v2)

Every proved slice or story embeds its normalized EARS IR, theory tier, solver proof receipt, and synthesized TestIR witnesses directly inside Canonical Model v2:

{
  "schemaVersion": "co-arising.canonical/v2",
  "context": "bankwealth",
  "structures": { "valueObjects": [], "exactTypes": [], "aggregates": [], "sagas": [], "readModels": [] },
  "behaviors": [
    {
      "kind": "slice",
      "layer": "domain",
      "target": "FundQuota.ReserveSubscriptionQuota",
      "hitPolicy": "FIRST",
      "theory": { "tier": "L1", "logic": "QF_AUFLIA", "codegenChannel": "deterministic" },
      "verification": { "solver": "z3", "passed": true, "bmcSteps": 0, "canonicalSha256": "..." },
      "axioms": [],
      "rules": [],
      "testIr": { "schemaVersion": "co-arising.test-ir/v2", "scenarios": [] }
    }
  ]
}

Contract 2: Unifying Declarative SMT with Imperative Codegen via DMN First-Hit

In SMT, overlapping IF ... reject guards are not conflicts because both reject the request. Yet imperative codegen (Scala Either, Rust Result, Go error) must choose a deterministic error code when multiple rejections hold simultaneously.

Canonical Model v2 adopts OMG DMN First-Hit semantics: top-to-bottom declaration order in rules: is the authoritative rejection priority for code generation. Declarative proofs, Style B decision tables, and imperative codegen stay 100% isomorphic.

Contract 3: Pure Event Sourcing Closure (emit Auto-Propagation + post: Fold Consistency)

Event Sourcing forbids mutating aggregate state directly inside handleCommand; state evolves solely in applyEvent(event). Canonical Model v2 closes this loop cleanly:

  • Auto-propagated payloads (@PROPAGATED): matching command parameter and event payload names/types bind automatically; only derived values and @host(...) computations require explicit mapping.
  • post: as event-fold contract: when a rule emits E with post: state.x' = ..., the compiler binds those updates as the deterministic fold of E (and enforces fold equivalence if multiple commands emit E), enabling lossless generation of handleCommand, applyEvent, and the Pure Replay Oracle.

6. Dual-Channel Delivery: Zero-Token Scaffolds (4A) vs Locked AI Cloze TDD (4B)

Following Ashby's Law of Requisite Variety (Harness Engineering), a regulator can govern only what it explicitly models. co-arising 2.0 partitions work strictly along decidability boundaries:

Channel 4A: Deterministic Zero-Token Codegen (L1 + All Structural Scaffolds)

  • Consumes all structural metadata plus tier == L1 && layer == domain EARS IR directly from Canonical Model v2.
  • Independent multi-language generator plugins (Scala, TypeScript, Java, Rust, Go) emit ValueObjects, exact codecs, Aggregate Behaviors, EventHandlers, Protobuf/JSON schemas, Saga hosts, Port traits, and empty // @cloze:start(<id>) .. // @cloze:end(<id>) stubs — zero LLM tokens, zero hallucination.
  • Every generated file is stamped with @generated and bidirectional @ProvenanceId anchors inside read-only generated-scaffold/.

Channel 4B: Isolated-Zone AI @cloze TDD Loop (L2/L3 + layer: application)

Complex handwritten orchestration that lived outside v1's compiler (trusted admission, idempotent replay dedup, nonlinear share math, external TA bridges, read-model watermark recovery) now enters the same EARS contract loop:

  1. Locked Executable BDD Oracles (EarsTestEmitter):
    • Emits locked Gherkin .feature specs and executable target-language suites (ScalaTest + Akka Persistence TestKit, Vitest, JUnit 5, or cargo test).
    • Tags every test with @CoArisingSpec(id="<RULE_ID>", witness="<witness-id>") and seals all generated test files under generated-tests/manifest.sha256.json.
  2. Graph-Sliced Sandwich Context Pack:
    • Exported from knowledge.sqlite with three layers — transitive type/port signatures, caller transaction & retry @caller contracts, and linked @CoArisingSpec failure scenarios — eliminating blind repository grepping.
  3. Physical Anti-Cheat Hooks & Blind Contract Review (Claude Code Best Practices):
    • PreToolUse Hook (exit 2): blocks writes to projections/, generated-scaffold/, generated-tests/, or any line outside @cloze:start..end (including marker tampering).
    • Stop Hook (exit 2): enforces a triple gate before the agent may stop — (a) SHA-256 verification against manifest.sha256.json to block shell/sed test tampering; (b) real execution of *EarsSpec; (c) bidirectional AST provenance verification. Any failure injects the failing @CoArisingSpec IDs to stderr and forces in-place self-healing.
    • Fresh Blind Subagent (contract-reviewer): zero shared reasoning history, hardcoded skip style, auditing only *.ears, TestIR, and the @cloze git diff to reject witness-hardcoding cheats before writing layered provenance records.

7. Honest Boundary vs v1 Baseline and Phased Roadmap

To keep delivered facts distinct from forward-looking design goals:

Phase Milestone Current Status Exit Gate
v1 Frozen Baseline Public Pages + bank-wealth-demo v1 + EARS 1.0 frontend / Z3 5-check / 4-step BMC / Style E & B projections / Hooks prototype Completed (verified green on v1 branches) Zero lint issues across metarch-truthsrc, 15/15 EARS unit tests pass; 6 bilingual bank-wealth-demo pairs 100% AST & .smt2 identical; Hooks exit 2 verified; existing 160-atom roundtrip untouched
v2 Phase 1 Canonical Model v2 schema & single compiler (Structure YAML + native EARS IR + SMT hard gate) Planned Retires second expression parser; single type/symbol checker serves SMT, projections, and codegen; unproved specs cannot emit canonical-v2.json
v2 Phase 2 Direct EARS-IR L1 deterministic code generators (first target: Scala or TypeScript/Rust) Planned Generates Behavior, EventHandler, and Pure Replay Oracle directly from First-Hit rules and emit/post: folds with zero @guard lowering
v2 Phase 3 Executable EarsTestEmitter (upgrading witness stubs to real Actor/Port-driving BDD oracles) Planned Synthesizes real command/value-object constructors and assertions executing under sbt "testOnly *EarsSpec" / vitest
v2 Phase 4 End-to-end isolated-zone AI @cloze TDD pilot (Context Pack + Stop Hook self-heal + blind review) Planned Full loop on a real application story and L2 slice: red locked oracle → @cloze-only AI fill → mutation kill check → blind review pass → graph anchor write-back

8. Standards, Citations, and Related Articles


Appendix: v2.0 GA Implementation & v2.1 Full-Coverage Governance Update (2026-11-26)

This architecture blueprint has been implemented end-to-end across metarch-truthsrc (feat/co-arising-v2-ears-native) and bank-wealth-demo (feat/co-arising-v2-pilot), closing all P0–P2 release readiness gates:

  1. Orthogonal Bounded-Context Truth Layout: Each bounded context separates structures/ (static nouns in YAML), behaviors/domain/ (aggregate .ears), behaviors/application/ (*.story.ears user stories and *.integration.ears external integration policies), and bindings/ (solution-space S1 effect protocols and forbidden-import rules), enforced by compiler Path-to-Layer static gates (V2_PATH_LAYER_MISMATCH, V2_LAYER_ACTION_VIOLATION) and 4 strict domain-boundary gates.
  2. Full Dual-Stack Parity (TypeScript + Scala): compile-v2 (Z3 + First-Hit + boundary equality witnesses + application k-step BMC + .zh.ears bilingual drift gate + Style E/B projections) → generate-v2 (TS + Scala domain and application parity) → emit-tests-v2 (SHA-256 locked oracles) → verify-v2 --strict (cross-platform anti-silent-skip gate). The bank-wealth-demo pilot compiles and passes all 5 TS + 5 Scala oracle suites live.
  3. 100% Full-Coverage Governance (v2.1) & Multi-Protocol S1 TCK: Zero gray-zone classification across Problem Space (D1/D2 → E1) and Solution Space (S1/S2/S3 → E2/E3/E4) (bank-wealth-demo: 56/56 = 100%); four S1 fault-injection TCK suites (three-phase-reconcile, transactional-outbox, saga-compensation, idempotent-consumer) supporting both Node ESM and Scala/JVM runners.
  4. Onboarding DX & Editor Tooling: First-class truthsrc init-v2, truthsrc check-v2 --strict, truthsrc guard-write, truthsrc init-hooks, truthsrc lsp-ears, and a .ears TextMate grammar / VS Code extension scaffold.