Scope and Evolution Notice: This document is a forward-looking v2 target architecture blueprint (ADR) designed from first principles. The current public
co-arisingv1 baseline andbank-wealth-demoremain 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 throughCanonical Model v2, deterministic scaffolding, and locked AI@clozeTDD in the isolated zone.
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.
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:
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.
- 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_NIAisolated +k-step BMC): local nonlinear multiplication (shares * nav <= netAmount) runs isolated underQF_NIAwith a 2-second timeout; multi-command stateful slices unrollk-step BMC to prove cross-step safety (such as askippeddue slot never being resurrected intobacklog). - 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.
- L1 Decidable Core (
- Automatic Fixed-Point Scale Alignment:
- Each numeric variable tracks its decimal scale (
Moneyscale = 2, NAVscale = 4, integer sharesscale = 0). Comparisons likeshares * nav <= order.netAmountautomatically align scales ((* shares nav) <= (* netAmount 100)), eliminating floating-point drift.
- Each numeric variable tracks its decimal scale (
- Five
(push 1) ... (pop 1)Checks & A/B Clarification Cards:- Mutual-exclusion conflicts:
SAT(Axioms ∧ G_emit ∧ G_reject)andSHALLvsSHALL NOTmust beunsat. - Logic gaps:
SAT(Axioms ∧ ¬(G_1 ∨ ... ∨ G_n))must beunsat; onsat, 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 beunsat. - Dead-rule detection:
UNSAT(Axioms ∧ G_i)reports blocking axioms viaget-unsat-core. - Boundary witness synthesis:
(get-model)extracts concrete decoded decimals and enum samples directly intoTestIR.
- Mutual-exclusion conflicts:
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 emitsEwithpost: state.x' = ..., the compiler binds those updates as the deterministic fold ofE(and enforces fold equivalence if multiple commands emitE), enabling lossless generation ofhandleCommand,applyEvent, and thePure 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 == domainEARS IR directly fromCanonical 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
@generatedand bidirectional@ProvenanceIdanchors inside read-onlygenerated-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:
- Locked Executable BDD Oracles (
EarsTestEmitter):- Emits locked Gherkin
.featurespecs and executable target-language suites (ScalaTest + Akka Persistence TestKit, Vitest, JUnit 5, orcargo test). - Tags every test with
@CoArisingSpec(id="<RULE_ID>", witness="<witness-id>")and seals all generated test files undergenerated-tests/manifest.sha256.json.
- Emits locked Gherkin
- Graph-Sliced Sandwich Context Pack:
- Exported from
knowledge.sqlitewith three layers — transitive type/port signatures, caller transaction & retry@callercontracts, and linked@CoArisingSpecfailure scenarios — eliminating blind repository grepping.
- Exported from
- Physical Anti-Cheat Hooks & Blind Contract Review (Claude Code Best Practices):
PreToolUseHook (exit 2): blocks writes toprojections/,generated-scaffold/,generated-tests/, or any line outside@cloze:start..end(including marker tampering).StopHook (exit 2): enforces a triple gate before the agent may stop — (a) SHA-256 verification againstmanifest.sha256.jsonto block shell/sed test tampering; (b) real execution of*EarsSpec; (c) bidirectional AST provenance verification. Any failure injects the failing@CoArisingSpecIDs tostderrand forces in-place self-healing.- Fresh Blind Subagent (
contract-reviewer): zero shared reasoning history, hardcodedskip style, auditing only*.ears,TestIR, and the@clozegit diffto 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
- co-arising EARS 1.0 Technical Specification (v1.2 Bilingual Edition) — Bilingual isomorphic EARS grammar, four
bank-wealth-demobenchmarks, and read-only projections - How to Extend a New Code Generator in metarch-truthsrc — v1 artifact pipeline map and multi-language generator plugin contracts
- Specs Have Bugs Too: AWS Kiro & SMT Solvers — Eliminating specification ambiguity and conflicts before writing code
- Implications for co-arising: Strategic Validation & Engineering Route — Ashby's Law, Behaviour Harness, two-speed workflow, and Cloze context packing
- Z3 Prover (Microsoft Research) — Primary SMT-LIB 2 solver for 5-check verification and
k-step BMC - cvc5 SMT Solver — Solver-independent backend supporting
QF_SLIAstring theories - SMT-LIB 2 Standard — Solver-neutral formal verification interchange language
- AWS Cedar Policy Language — Reference design for trading Turing completeness for 100% decidable analysis
- EARS (Easy Approach to Requirements Syntax) — Foundational controlled requirements syntax
- OMG DMN Specification — Reference for Style B decision tables, FEEL intervals, and First-Hit policy
- Cucumber Gherkin Reference — Locked
.featureacceptance oracle syntax - ScalaTest & Akka Persistence TestKit — Event-sourced aggregate test oracle reference harness
- Harness Engineering for Coding Agent Users (Martin Fowler / Birgitta Böckeler) — Variety-reduction topology and Behaviour Harness framing
- Claude Code Best Practices — Deterministic
PreToolUse/StopHooks (exit 2) and fresh-context blind review co-arising/metarch-truthsrc&co-arising/bank-wealth-demo— Current v1 compiler and benchmark repositories
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:
- Orthogonal Bounded-Context Truth Layout: Each bounded context separates
structures/(static nouns in YAML),behaviors/domain/(aggregate.ears),behaviors/application/(*.story.earsuser stories and*.integration.earsexternal integration policies), andbindings/(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. - Full Dual-Stack Parity (TypeScript + Scala):
compile-v2(Z3 + First-Hit + boundary equality witnesses + applicationk-step BMC +.zh.earsbilingual 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). Thebank-wealth-demopilot compiles and passes all 5 TS + 5 Scala oracle suites live. - 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. - Onboarding DX & Editor Tooling: First-class
truthsrc init-v2,truthsrc check-v2 --strict,truthsrc guard-write,truthsrc init-hooks,truthsrc lsp-ears, and a.earsTextMate grammar / VS Code extension scaffold.