import{_ as i,o as a,c as n,ag as t}from"./chunks/framework.CmQHR1bQ.js";const c=JSON.parse('{"title":"Formal Interface Contracts for CIV ↔ Venture Integration","description":"","frontmatter":{},"headers":[],"relativePath":"reference/INTERFACE_CONTRACTS.md","filePath":"reference/INTERFACE_CONTRACTS.md"}'),e={name:"reference/INTERFACE_CONTRACTS.md"};function l(p,s,h,k,r,d){return a(),n("div",null,[...s[0]||(s[0]=[t(`<h1 id="formal-interface-contracts-for-civ-↔-venture-integration" tabindex="-1">Formal Interface Contracts for CIV ↔ Venture Integration <a class="header-anchor" href="#formal-interface-contracts-for-civ-↔-venture-integration" aria-label="Permalink to &quot;Formal Interface Contracts for CIV ↔ Venture Integration&quot;">​</a></h1><p><strong>Date:</strong> 2026-02-21 <strong>Scope:</strong> 5 cross-track integration points with detailed interface specifications <strong>Status:</strong> ACTIVE <strong>Owner:</strong> Kush Ecosystem Integration Team</p><hr><h2 id="executive-summary" tabindex="-1">Executive Summary <a class="header-anchor" href="#executive-summary" aria-label="Permalink to &quot;Executive Summary&quot;">​</a></h2><p>This document defines the formal interface contracts for the 5 integration points connecting CIV (city simulation) and Venture (autonomous agent platform). Each contract specifies:</p><ol><li><strong>Source System</strong>: Which system emits the data</li><li><strong>Target System</strong>: Which system consumes the data</li><li><strong>Data Schema</strong>: Exact shape and format of exchanged data</li><li><strong>Sync Protocol</strong>: Frequency, ordering, and reliability guarantees</li><li><strong>Validation Rules</strong>: Constraints enforced at integration boundary</li><li><strong>Determinism Guarantees</strong>: Replay and idempotency contracts</li><li><strong>Error Handling</strong>: Failure modes and recovery procedures</li></ol><hr><h2 id="contract-1-civ-energy-ledger-↔-venture-treasury-ledger" tabindex="-1">Contract 1: CIV Energy Ledger ↔ Venture Treasury Ledger <a class="header-anchor" href="#contract-1-civ-energy-ledger-↔-venture-treasury-ledger" aria-label="Permalink to &quot;Contract 1: CIV Energy Ledger ↔ Venture Treasury Ledger&quot;">​</a></h2><p><strong>Integration Point ID</strong>: <code>INT-001-LEDGER-ALIGNMENT</code></p><p><strong>Source</strong>: CIV Economy Module (CIV-0100, CIV-0107) <strong>Target</strong>: Venture Treasury System (TRACK-B)</p><p><strong>Purpose</strong>: Synchronize double-entry accounting between CIV simulation and Venture spend ledger, ensuring conservation laws hold cross-system.</p><h3 id="_1-1-data-schema" tabindex="-1">1.1 Data Schema <a class="header-anchor" href="#_1-1-data-schema" aria-label="Permalink to &quot;1.1 Data Schema&quot;">​</a></h3><h4 id="civ-side-economy-transfer-booked-v1" tabindex="-1">CIV Side: economy.transfer_booked.v1 <a class="header-anchor" href="#civ-side-economy-transfer-booked-v1" aria-label="Permalink to &quot;CIV Side: economy.transfer_booked.v1&quot;">​</a></h4><div class="language-typescript vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">typescript</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">interface</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> CivTransferEvent</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  event_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;              </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// UUID</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  event_type</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;civ.economy.transfer_booked.v1&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  tick_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;               </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Tick sequence (deterministic order)</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  run_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;                </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Simulation run ID</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  policy_bundle_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;      </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Policy version pinning</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  created_at</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> ISO8601Timestamp</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  payload</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    sender_account_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;          </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Account ID in CIV ledger</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    receiver_account_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;        </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Account ID in CIV ledger</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    amount</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;                     </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Joules (CIV-0107 unit)</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    transfer_reason</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;            </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// One of: trade, tax, subsidy, inheritance, wage_payment, production_cost</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    ledger_account_pair</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">      debit_account</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;            </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Explicit debit account</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">      credit_account</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;           </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Explicit credit account</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">    };</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    policy_applied_event_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;   </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Link to policy.applied.v1 that triggered this</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    conservation_check_hash</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;    </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// SHA256(state_after_transfer) for verification</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">  };</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><h4 id="venture-side-ledger-entry-created-v1" tabindex="-1">Venture Side: ledger.entry.created.v1 <a class="header-anchor" href="#venture-side-ledger-entry-created-v1" aria-label="Permalink to &quot;Venture Side: ledger.entry.created.v1&quot;">​</a></h4><div class="language-typescript vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">typescript</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">interface</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> VentureTransferEvent</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  event_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;              </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// UUID</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  event_type</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;venture.ledger.entry_created.v1&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  workflow_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;           </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Venture workflow ID (maps to CIV run_id)</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  trace_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;              </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// End-to-end trace ID</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  task_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;               </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Venture task ID (maps to CIV tick_id)</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  policy_bundle_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;      </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Must match CIV policy_bundle_id</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  created_at</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> ISO8601Timestamp</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  payload</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    entry_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;            </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// UUID for this ledger entry</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    debit_account</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;       </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Account ID in Venture chart of accounts</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    credit_account</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;      </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Account ID in Venture chart of accounts</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    amount</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;              </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Joules (converted/normalized)</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    reference_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;        </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Should equal civ_event_id for traceability</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    reference_type</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;civ_transfer&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;internal_spend&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;allocation&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    description</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;         </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Human-readable description</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    conservation_check_hash</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">; </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Mirrors CIV state hash for alignment</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">  };</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><h3 id="_1-2-sync-protocol" tabindex="-1">1.2 Sync Protocol <a class="header-anchor" href="#_1-2-sync-protocol" aria-label="Permalink to &quot;1.2 Sync Protocol&quot;">​</a></h3><p><strong>Timing</strong>:</p><ul><li>CIV emits <code>economy.transfer_booked.v1</code> at end of each tick (during economy phase)</li><li>Venture relay layer picks up event and re-emits as <code>venture.ledger.entry_created.v1</code></li><li>Latency SLA: &lt; 100ms from CIV tick end to Venture ledger update</li></ul><p><strong>Ordering</strong>:</p><ul><li>All transfers within a single CIV tick must be relayed in deterministic order</li><li>Order preserved: <code>tick_id</code> → <code>transfer_sequence_number</code> (if multiple transfers in same tick)</li><li>Venture ledger must apply entries in same order for determinism</li></ul><p><strong>Batch Semantics</strong>:</p><ul><li>Each CIV tick can emit multiple transfer events</li><li>All transfers from a single tick are grouped under same <code>trace_id</code> in Venture</li><li>If relay fails for any transfer in a tick: entire tick is retried (at-least-once semantics)</li></ul><p><strong>Frequency</strong>:</p><ul><li>Every CIV tick produces at least one transfer event (even if zero-amount for accounting)</li><li>Venture reconciliation runs daily; cross-system balance check must pass deterministically</li></ul><h3 id="_1-3-validation-rules" tabindex="-1">1.3 Validation Rules <a class="header-anchor" href="#_1-3-validation-rules" aria-label="Permalink to &quot;1.3 Validation Rules&quot;">​</a></h3><h4 id="at-source-civ" tabindex="-1">At Source (CIV) <a class="header-anchor" href="#at-source-civ" aria-label="Permalink to &quot;At Source (CIV)&quot;">​</a></h4><ul><li><code>sender_account_id</code> and <code>receiver_account_id</code> must exist and be active</li><li><code>amount</code> must be positive and non-NaN</li><li><code>debit_account == sender_account_id</code> and <code>credit_account == receiver_account_id</code></li><li><code>conservation_check_hash</code> must verify: sum of all ledger entries in tick = 0</li><li><code>transfer_reason</code> must be one of allowed enum values</li><li><code>policy_bundle_id</code> must match current policy bundle for this simulation run</li></ul><h4 id="at-target-venture" tabindex="-1">At Target (Venture) <a class="header-anchor" href="#at-target-venture" aria-label="Permalink to &quot;At Target (Venture)&quot;">​</a></h4><ul><li><code>reference_id</code> must be parseable as UUID and must match source <code>event_id</code></li><li><code>debit_account</code> and <code>credit_account</code> must exist in Venture chart of accounts</li><li><code>amount</code> must be positive, finite, and in valid range [0, 1e18] Joules</li><li><code>policy_bundle_id</code> must match Venture&#39;s current policy bundle for the workflow</li><li>Debit and credit amounts must be equal (double-entry invariant)</li><li>For each Venture entry: there must exist a corresponding CIV event in event log (via <code>reference_id</code>)</li></ul><h4 id="cross-system" tabindex="-1">Cross-System <a class="header-anchor" href="#cross-system" aria-label="Permalink to &quot;Cross-System&quot;">​</a></h4><ul><li>Sum of all CIV transfers in tick must equal sum of corresponding Venture ledger entries</li><li>Both systems must reach same final balance for each account (modulo precision errors ≤ 1 Joule)</li><li>Conservation law must hold: <code>sum(all_entries) = 0</code> in both systems</li></ul><h3 id="_1-4-determinism-guarantees" tabindex="-1">1.4 Determinism Guarantees <a class="header-anchor" href="#_1-4-determinism-guarantees" aria-label="Permalink to &quot;1.4 Determinism Guarantees&quot;">​</a></h3><p><strong>Replay Contract</strong>:</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>Given:</span></span>
<span class="line"><span>  - run_id (CIV simulation run identifier)</span></span>
<span class="line"><span>  - policy_bundle_id (version of policy in effect)</span></span>
<span class="line"><span>  - tick_id (tick sequence number)</span></span>
<span class="line"><span>  - RNG seed (from simulation initialization)</span></span>
<span class="line"><span></span></span>
<span class="line"><span>Guarantee:</span></span>
<span class="line"><span>  - Re-executing CIV tick with identical inputs produces identical events in identical order</span></span>
<span class="line"><span>  - Venture replay of same ledger entries with identical policy_bundle_id produces identical balance changes</span></span>
<span class="line"><span>  - Both systems arrive at identical account balances (modulo rounding to nearest Joule)</span></span>
<span class="line"><span>  - Determinism verified by hash comparison: SHA256(civ_state) == SHA256(venture_balances_after_relay)</span></span></code></pre></div><p><strong>Idempotency</strong>:</p><ul><li>Multiple relay of same CIV event produces identical Venture ledger entry</li><li>Idempotency key: <code>hash(reference_id + policy_bundle_id + tick_id)</code></li><li>Venture ledger uses idempotency key to deduplicate; duplicate events rejected with reason &quot;already_processed&quot;</li></ul><p><strong>Hash Verification</strong>:</p><ul><li>CIV emits <code>conservation_check_hash</code> after each tick&#39;s economy phase</li><li>Venture relay layer stores hash with ledger entries</li><li>At reconciliation time: recompute hash from Venture ledger entries; compare with CIV hash</li><li>If hashes diverge: open compliance case with severity=critical</li></ul><h3 id="_1-5-error-handling" tabindex="-1">1.5 Error Handling <a class="header-anchor" href="#_1-5-error-handling" aria-label="Permalink to &quot;1.5 Error Handling&quot;">​</a></h3><table tabindex="0"><thead><tr><th>Failure Mode</th><th>Detection</th><th>Recovery</th></tr></thead><tbody><tr><td>Transfer amount is NaN</td><td>CIV validation</td><td>Reject event; emit error event; fail tick</td></tr><tr><td>Debit/credit accounts missing</td><td>Venture validation</td><td>Reject relay; log error; escalate to ops</td></tr><tr><td>Conservation law violated</td><td>Hash mismatch</td><td>Open compliance case; pause ledger updates; require manual investigation</td></tr><tr><td>Duplicate relay attempt</td><td>Idempotency check</td><td>Accept without re-applying; return existing entry_id</td></tr><tr><td>Policy bundle mismatch</td><td>Version check</td><td>Reject relay; emit compliance.violation.detected.v1</td></tr><tr><td>Precision loss (&gt; 1 Joule)</td><td>Balance drift check</td><td>Log as warning; allow if &lt; 0.1% drift; escalate if &gt; 1% drift</td></tr></tbody></table><h3 id="_1-6-implementation-checklist" tabindex="-1">1.6 Implementation Checklist <a class="header-anchor" href="#_1-6-implementation-checklist" aria-label="Permalink to &quot;1.6 Implementation Checklist&quot;">​</a></h3><ul><li>[ ] CIV emits economy.transfer_booked.v1 with required payload fields</li><li>[ ] Venture relay layer transforms CIV event → Venture ledger.entry.created.v1</li><li>[ ] Venture ledger validates debit/credit account existence and type</li><li>[ ] Double-entry invariant enforced: debit_amount == credit_amount</li><li>[ ] Conservation check: sum(all_entries) == 0 (modulo rounding)</li><li>[ ] Determinism test: replay CIV tick N times with same seed → identical events</li><li>[ ] Reconciliation test: CIV final balance == Venture final balance</li><li>[ ] Cross-system drift detection and alert (daily reconciliation)</li><li>[ ] Compliance case opening for conservation law violations</li><li>[ ] Idempotency test: duplicate relay of same event → same ledger entry returned</li></ul><hr><h2 id="contract-2-civ-simulation-state-↔-venture-workflow-orchestration" tabindex="-1">Contract 2: CIV Simulation State ↔ Venture Workflow Orchestration <a class="header-anchor" href="#contract-2-civ-simulation-state-↔-venture-workflow-orchestration" aria-label="Permalink to &quot;Contract 2: CIV Simulation State ↔ Venture Workflow Orchestration&quot;">​</a></h2><p><strong>Integration Point ID</strong>: <code>INT-002-FSM-STATE-SYNC</code></p><p><strong>Source</strong>: CIV Core Simulation Loop (CIV-0001) <strong>Target</strong>: Venture Control Plane (TRACK-C)</p><p><strong>Purpose</strong>: Synchronize deterministic state machine transitions between CIV tick-based simulation and Venture workflow/task DAG execution.</p><h3 id="_2-1-data-schema" tabindex="-1">2.1 Data Schema <a class="header-anchor" href="#_2-1-data-schema" aria-label="Permalink to &quot;2.1 Data Schema&quot;">​</a></h3><h4 id="civ-side-civ-tick-started-v1-and-civ-tick-completed-v1" tabindex="-1">CIV Side: civ.tick.started.v1 and civ.tick.completed.v1 <a class="header-anchor" href="#civ-side-civ-tick-started-v1-and-civ-tick-completed-v1" aria-label="Permalink to &quot;CIV Side: civ.tick.started.v1 and civ.tick.completed.v1&quot;">​</a></h4><div class="language-typescript vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">typescript</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">interface</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> CivTickEvent</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  event_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  event_type</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;civ.tick.started.v1&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;civ.tick.completed.v1&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  tick_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;                    </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Deterministic tick sequence</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  run_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;                     </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Simulation run ID</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  policy_bundle_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;           </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Policy version</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  created_at</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> ISO8601Timestamp</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  payload</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">    // Common to both started and completed</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    tick_sequence</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;              </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Which tick within run (0-based)</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    phase_order</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">[];              </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Deterministic phases: [&quot;demographics&quot;, &quot;policy&quot;, &quot;economy&quot;, &quot;spatial&quot;, ...]</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    policy_bundle_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;           </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Pinned policy version for this tick</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">    // For tick.started.v1 only</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    estimated_duration_ms</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;     </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Estimated tick execution time</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">    // For tick.completed.v1 only</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    actual_duration_ms</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;         </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Actual wall-clock time</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    state_hash_after</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;           </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// SHA256(compressed_state_after_tick)</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    phase_hashes</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {[</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">phase</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}; </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Hash after each phase (for granular verification)</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    sub_events_count</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;           </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Count of sub-events emitted during tick</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    tick_status</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;success&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;failed&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;reverted&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    error_message</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;             </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// If status != success</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">  };</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><h4 id="venture-side-venture-task-started-v1-and-venture-task-completed-v1" tabindex="-1">Venture Side: venture.task.started.v1 and venture.task.completed.v1 <a class="header-anchor" href="#venture-side-venture-task-started-v1-and-venture-task-completed-v1" aria-label="Permalink to &quot;Venture Side: venture.task.started.v1 and venture.task.completed.v1&quot;">​</a></h4><div class="language-typescript vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">typescript</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">interface</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> VentureTaskEvent</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  event_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  event_type</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;venture.task.started.v1&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;venture.task.completed.v1&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  task_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;                    </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// UUID for this task</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  workflow_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;                </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Links to CIV run_id</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  trace_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;                   </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// End-to-end trace</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  policy_bundle_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;           </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Must match CIV&#39;s policy_bundle_id</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  created_at</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> ISO8601Timestamp</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  payload</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">    // Common to both</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    task_sequence</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;              </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Position in workflow DAG (mirrors tick_sequence)</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    tool_calls_expected</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;        </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// For task.started.v1</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    tool_calls_executed</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;        </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// For task.completed.v1</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    actual_eau_cost</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;           </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Actual resource consumption</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    task_status</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;pending&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;scheduled&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;executing&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;completed&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;failed&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;revoked&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">    // For task.completed.v1 only</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    actual_duration_ms</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    state_hash_after</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;          </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Mirrors CIV state_hash for cross-system verification</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    task_error</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">  };</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><h3 id="_2-2-sync-protocol" tabindex="-1">2.2 Sync Protocol <a class="header-anchor" href="#_2-2-sync-protocol" aria-label="Permalink to &quot;2.2 Sync Protocol&quot;">​</a></h3><p><strong>Semantics</strong>: 1 CIV tick = 1 Venture task (1:1 mapping)</p><p><strong>Mapping</strong>:</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>CIV Simulation Run</span></span>
<span class="line"><span>  ├─ Tick 0 → Venture Workflow starts</span></span>
<span class="line"><span>  ├─   Sub-phase: Demographics</span></span>
<span class="line"><span>  │     └─ May emit multiple CIV sub-events</span></span>
<span class="line"><span>  ├─   Sub-phase: Policy</span></span>
<span class="line"><span>  │     └─ May emit civ.policy.evaluated.v1 events</span></span>
<span class="line"><span>  ├─   Sub-phase: Economy</span></span>
<span class="line"><span>  │     └─ May emit civ.economy.* events</span></span>
<span class="line"><span>  ├─   Sub-phase: Spatial</span></span>
<span class="line"><span>  │     └─ May emit civ.spatial.* events</span></span>
<span class="line"><span>  └─ Tick 0 completes → Venture Task 0 completes</span></span>
<span class="line"><span>       └─ task.completed.v1 with state_hash_after</span></span>
<span class="line"><span>  │</span></span>
<span class="line"><span>  ├─ Tick 1 → Venture Task 1 starts</span></span>
<span class="line"><span>  └─ (repeat for all ticks)</span></span></code></pre></div><p><strong>Ordering</strong>:</p><ul><li>Ticks must execute sequentially (no parallelism within a run)</li><li>Venture tasks within a workflow execute in DAG order (task 0 before task 1, etc.)</li><li>Phase ordering within a tick is deterministic (see phase_order array)</li><li>CIV phase completion must be observable to Venture (via state_hash_after_phase)</li></ul><p><strong>Frequency</strong>:</p><ul><li>CIV: emits tick.started.v1 at tick initialization, tick.completed.v1 at tick end</li><li>Venture: emits task.started.v1 at task scheduling, task.completed.v1 at task completion</li><li>Latency SLA: &lt; 10ms from CIV tick completion to Venture task completion event</li></ul><h3 id="_2-3-validation-rules" tabindex="-1">2.3 Validation Rules <a class="header-anchor" href="#_2-3-validation-rules" aria-label="Permalink to &quot;2.3 Validation Rules&quot;">​</a></h3><h4 id="at-source-civ-1" tabindex="-1">At Source (CIV) <a class="header-anchor" href="#at-source-civ-1" aria-label="Permalink to &quot;At Source (CIV)&quot;">​</a></h4><ul><li><code>tick_sequence</code> must be sequential (0, 1, 2, ...)</li><li><code>phase_order</code> must match canonical phase sequence (no missing or reordered phases)</li><li><code>state_hash_after</code> must be valid SHA256 hash (64 hex characters)</li><li>For tick.completed.v1: <code>actual_duration_ms</code> must be positive and reasonable (e.g., &lt; 60s)</li><li><code>sub_events_count</code> must match actual count of emitted events</li><li><code>tick_status</code> must be one of allowed enum values</li></ul><h4 id="at-target-venture-1" tabindex="-1">At Target (Venture) <a class="header-anchor" href="#at-target-venture-1" aria-label="Permalink to &quot;At Target (Venture)&quot;">​</a></h4><ul><li><code>task_sequence</code> must match CIV <code>tick_sequence</code></li><li><code>workflow_id</code> must exist and be in executing state</li><li><code>policy_bundle_id</code> must match workflow&#39;s policy bundle</li><li>For task.completed.v1: <code>actual_eau_cost</code> must be ≤ budgeted cost (from task.scheduled.v1)</li><li><code>task_status</code> transition must be valid (pending → scheduled → executing → completed)</li><li>If <code>state_hash_after</code> provided: must be valid SHA256 hash</li></ul><h4 id="cross-system-1" tabindex="-1">Cross-System <a class="header-anchor" href="#cross-system-1" aria-label="Permalink to &quot;Cross-System&quot;">​</a></h4><ul><li><code>task_id</code> (Venture) and <code>tick_id</code> (CIV) must have 1:1 mapping (store in cross-reference table)</li><li><code>policy_bundle_id</code> must be identical in both events</li><li>If CIV tick failed: Venture task must fail with corresponding error</li><li>State hashes must match post-execution (if both systems compute them)</li></ul><h3 id="_2-4-determinism-guarantees" tabindex="-1">2.4 Determinism Guarantees <a class="header-anchor" href="#_2-4-determinism-guarantees" aria-label="Permalink to &quot;2.4 Determinism Guarantees&quot;">​</a></h3><p><strong>Replay Contract</strong>:</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>Given:</span></span>
<span class="line"><span>  - run_id (CIV simulation run ID)</span></span>
<span class="line"><span>  - tick_id (specific tick within run)</span></span>
<span class="line"><span>  - policy_bundle_id</span></span>
<span class="line"><span>  - RNG seed from run initialization</span></span>
<span class="line"><span></span></span>
<span class="line"><span>Guarantee:</span></span>
<span class="line"><span>  - Re-executing CIV tick with same inputs produces:</span></span>
<span class="line"><span>    1. Identical state_hash_after</span></span>
<span class="line"><span>    2. Identical phase_order</span></span>
<span class="line"><span>    3. Identical sub-events in identical order</span></span>
<span class="line"><span>    4. Identical tick_status</span></span>
<span class="line"><span>  - Venture replay of same task produces:</span></span>
<span class="line"><span>    1. Identical task status transitions</span></span>
<span class="line"><span>    2. Identical tool call sequence</span></span>
<span class="line"><span>    3. Identical actual_eau_cost (within budget model)</span></span>
<span class="line"><span>    4. Identical state_hash_after (if provided)</span></span>
<span class="line"><span>  - Cross-system validation: both hashes must match (up to representation)</span></span></code></pre></div><p><strong>Idempotency</strong>:</p><ul><li>Multiple relay of same tick completion event must not re-execute task</li><li>Idempotency key: <code>hash(tick_id + run_id + policy_bundle_id)</code></li><li>Venture task idempotency: if task already completed with same task_id, return existing result</li></ul><p><strong>State Hash Verification</strong>:</p><ul><li>Both systems compute SHA256 hash of their respective state after execution</li><li>Hashes must match (or be mathematically equivalent)</li><li>Mismatch indicates determinism bug; open compliance case</li></ul><h3 id="_2-5-error-handling" tabindex="-1">2.5 Error Handling <a class="header-anchor" href="#_2-5-error-handling" aria-label="Permalink to &quot;2.5 Error Handling&quot;">​</a></h3><table tabindex="0"><thead><tr><th>Failure Mode</th><th>Detection</th><th>Recovery</th></tr></thead><tbody><tr><td>Out-of-order ticks</td><td>Sequence check</td><td>Reject; require replay from last known good state</td></tr><tr><td>Invalid phase order</td><td>Phase list validation</td><td>Reject tick; emit error; fail entire run</td></tr><tr><td>State hash mismatch</td><td>Hash comparison post-execution</td><td>Open compliance case; pause workflow; require investigation</td></tr><tr><td>Task status invalid transition</td><td>FSM validation</td><td>Reject state change; emit error</td></tr><tr><td>Policy bundle mismatch</td><td>Version check</td><td>Reject; pause workflow; escalate</td></tr><tr><td>Cost overrun</td><td>Budget check</td><td>Reject if over hard cap; warn if over soft cap</td></tr><tr><td>Missing task prerequisite</td><td>DAG dependency check</td><td>Wait for prerequisite completion or timeout (configurable)</td></tr></tbody></table><h3 id="_2-6-implementation-checklist" tabindex="-1">2.6 Implementation Checklist <a class="header-anchor" href="#_2-6-implementation-checklist" aria-label="Permalink to &quot;2.6 Implementation Checklist&quot;">​</a></h3><ul><li>[ ] CIV emits tick.started.v1 and tick.completed.v1 for every tick</li><li>[ ] Venture relay layer creates task entry for each CIV tick</li><li>[ ] Task sequence numbers match tick sequence numbers</li><li>[ ] Phase order validation: both systems agree on deterministic phases</li><li>[ ] State hash computation and storage (both sides)</li><li>[ ] Determinism test: replay same tick N times with same seed → identical hashes</li><li>[ ] FSM state transition validation in Venture</li><li>[ ] Budget enforcement: actual_eau_cost ≤ budgeted cost</li><li>[ ] Cross-reference table: tick_id ↔ task_id mapping</li><li>[ ] Compliance case auto-open on state hash mismatch</li><li>[ ] Error propagation: CIV tick failure → Venture task failure</li></ul><hr><h2 id="contract-3-civ-institutions-↔-venture-compliance-audit-trail" tabindex="-1">Contract 3: CIV Institutions ↔ Venture Compliance Audit Trail <a class="header-anchor" href="#contract-3-civ-institutions-↔-venture-compliance-audit-trail" aria-label="Permalink to &quot;Contract 3: CIV Institutions ↔ Venture Compliance Audit Trail&quot;">​</a></h2><p><strong>Integration Point ID</strong>: <code>INT-003-INSTITUTION-COMPLIANCE</code></p><p><strong>Source</strong>: CIV Institutional Engine (CIV-0103) <strong>Target</strong>: Venture Compliance Machine (OPS_COMPLIANCE_SPEC)</p><p><strong>Purpose</strong>: Create audit evidence chains for CIV institutional changes, enabling compliance review and regulatory proof.</p><h3 id="_3-1-data-schema" tabindex="-1">3.1 Data Schema <a class="header-anchor" href="#_3-1-data-schema" aria-label="Permalink to &quot;3.1 Data Schema&quot;">​</a></h3><h4 id="civ-side-civ-institution-events" tabindex="-1">CIV Side: civ.institution.* Events <a class="header-anchor" href="#civ-side-civ-institution-events" aria-label="Permalink to &quot;CIV Side: civ.institution.* Events&quot;">​</a></h4><div class="language-typescript vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">typescript</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">interface</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> CivInstitutionEvent</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  event_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  event_type</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;civ.institution.created.v1&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;civ.institution.state_changed.v1&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">              &quot;civ.institution.merged.v1&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;civ.institution.dissolved.v1&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  tick_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  run_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  policy_bundle_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  created_at</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> ISO8601Timestamp</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  payload</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    institution_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    institution_type</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;kingdom&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;city_state&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;alliance&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;corporation&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;religious_order&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;militia&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">    // For institution.created.v1</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    founder_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;                </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Citizen ID of founder</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    location</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;                  </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Location name or coordinate</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    initial_population</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;        </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Citizens in institution at creation</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">    // For institution.state_changed.v1</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    state_before</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;pending&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;active&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;dormant&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;dissolved&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    state_after</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;pending&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;active&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;dormant&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;dissolved&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    state_change_reason</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;       </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Why state changed (e.g., &quot;diplomatic_treaty&quot;, &quot;bankruptcy&quot;, &quot;war_conquest&quot;)</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    affected_citizens_count</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">    // For institution.merged.v1 / institution.split.v1</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    merging_institution_ids</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">[];         </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// All institutions being merged</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    resulting_institution_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;          </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Result of merge</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    source_institution_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;             </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Institution being split</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    new_institution_ids</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">[];             </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Resulting institutions</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    population_distributed</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {[</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}; </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Population per institution</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">    // For institution.dissolved.v1</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    citizen_relocations</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {[</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">destination_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}; </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Where citizens went</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    asset_liquidations</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;        </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Total assets liquidated (Joules)</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">    // Audit metadata</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    causal_event_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;           </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ID of event that triggered this institutional change</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    policy_applied_event_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;   </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ID of policy that triggered this (if applicable)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">  };</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><h4 id="venture-side-compliance-case-events" tabindex="-1">Venture Side: compliance.case.* Events <a class="header-anchor" href="#venture-side-compliance-case-events" aria-label="Permalink to &quot;Venture Side: compliance.case.* Events&quot;">​</a></h4><div class="language-typescript vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">typescript</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">interface</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> VentureComplianceCaseEvent</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  event_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  event_type</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;venture.compliance.case_opened.v1&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;venture.compliance.case_evidence_added.v1&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">              &quot;venture.compliance.case_closed.v1&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  workflow_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  trace_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  policy_bundle_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  created_at</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> ISO8601Timestamp</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  payload</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">    // For case_opened.v1</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    case_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;                   </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// UUID for this audit case</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    case_type</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;institutional_creation&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;institutional_state_change&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">               &quot;institutional_merger&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;institutional_split&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;institutional_dissolution&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    severity_level</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;critical&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;high&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;medium&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;low&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    case_description</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;          </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Human-readable summary</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    entity_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;                 </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Institution ID (from CIV)</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    evidence_chain_start</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> ISO8601Timestamp</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">    // For case_evidence_added.v1</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    case_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;                   </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Links to open case</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    evidence_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;               </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// UUID for this evidence item</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    event_id_reference</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;        </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Reference to CIV event_id</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    evidence_type</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;institutional_change_event&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;policy_application_record&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">                   &quot;state_snapshot&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;causal_chain&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    evidence_content</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> object</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;         </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Full CIV event payload (for audit)</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    evidence_timestamp</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> ISO8601Timestamp</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">    // For case_closed.v1</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    case_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    closure_reason</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;institutional_operation_complete&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;manual_review&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;policy_violation_found&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    evidence_count</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;            </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Total evidence items in chain</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    finding</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;compliant&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;non_compliant&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;requires_investigation&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    closure_timestamp</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> ISO8601Timestamp</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">  };</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><h3 id="_3-2-sync-protocol" tabindex="-1">3.2 Sync Protocol <a class="header-anchor" href="#_3-2-sync-protocol" aria-label="Permalink to &quot;3.2 Sync Protocol&quot;">​</a></h3><p><strong>Case Lifecycle</strong>:</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>CIV Event Emitted (e.g., institution.created.v1)</span></span>
<span class="line"><span>  ↓</span></span>
<span class="line"><span>Venture Relay Layer</span></span>
<span class="line"><span>  └─→ Creates compliance case (case_opened.v1)</span></span>
<span class="line"><span>       └─ case_type = &quot;institutional_creation&quot;</span></span>
<span class="line"><span>       └─ severity = &quot;medium&quot;</span></span>
<span class="line"><span>  ↓</span></span>
<span class="line"><span>Venture Compliance Machine subscribes</span></span>
<span class="line"><span>  └─→ Opens case in audit system</span></span>
<span class="line"><span>  ↓</span></span>
<span class="line"><span>Subsequent CIV events related to same institution</span></span>
<span class="line"><span>  ├─→ institution.state_changed.v1</span></span>
<span class="line"><span>  ├─→ institution.merged.v1 (if applicable)</span></span>
<span class="line"><span>  └─→ Each event = case_evidence_added.v1</span></span>
<span class="line"><span>       └─→ Appends to evidence chain</span></span>
<span class="line"><span>  ↓</span></span>
<span class="line"><span>Institutional lifecycle completes (e.g., dissolution)</span></span>
<span class="line"><span>  └─→ case_closed.v1 emitted</span></span>
<span class="line"><span>       └─ Status = &quot;compliant&quot; (unless audit found issue)</span></span></code></pre></div><p><strong>Timing</strong>:</p><ul><li>Case opened within 10ms of receiving CIV institution creation event</li><li>Evidence appended within 10ms of receiving follow-up events</li><li>Case remains open for duration of institution&#39;s active lifetime</li><li>Case closed within 10ms of receiving dissolution event (or after inactivity timeout of 30 days)</li></ul><p><strong>Ordering</strong>:</p><ul><li>Evidence items must be stored in temporal order (creation_timestamp)</li><li>Full causality chain is reconstructible from evidence_ids and causal_event_id links</li><li>Venture audit system must support chronological replay of institutional evolution</li></ul><h3 id="_3-3-validation-rules" tabindex="-1">3.3 Validation Rules <a class="header-anchor" href="#_3-3-validation-rules" aria-label="Permalink to &quot;3.3 Validation Rules&quot;">​</a></h3><h4 id="at-source-civ-2" tabindex="-1">At Source (CIV) <a class="header-anchor" href="#at-source-civ-2" aria-label="Permalink to &quot;At Source (CIV)&quot;">​</a></h4><ul><li><code>institution_id</code> must be unique and persistent for lifetime of institution</li><li><code>institution_type</code> must be one of allowed enum values</li><li>For state_changed events: <code>state_before</code> must match previous state</li><li>For merge/split events: all institution_ids must exist and be active</li><li><code>causal_event_id</code> (if present) must reference valid prior event</li><li><code>policy_applied_event_id</code> (if present) must reference valid policy.applied.v1 event</li><li>Population changes must balance: sum(initial_population) == sum(post-merge population)</li></ul><h4 id="at-target-venture-2" tabindex="-1">At Target (Venture) <a class="header-anchor" href="#at-target-venture-2" aria-label="Permalink to &quot;At Target (Venture)&quot;">​</a></h4><ul><li><code>case_id</code> must be globally unique</li><li><code>entity_id</code> must match a known CIV institution_id</li><li><code>policy_bundle_id</code> must match workflow&#39;s bundle</li><li>Evidence chain must be append-only: no deletions or modifications</li><li><code>event_id_reference</code> must match CIV event_id format (UUID)</li><li><code>evidence_count</code> must equal actual count of evidence items in case</li></ul><h4 id="cross-system-2" tabindex="-1">Cross-System <a class="header-anchor" href="#cross-system-2" aria-label="Permalink to &quot;Cross-System&quot;">​</a></h4><ul><li>Case lifecycle must span from CIV creation to CIV dissolution</li><li>All institutional changes (state_changed, merged, split) must have corresponding evidence items</li><li>Evidence items must be in temporal order (no time travel)</li><li>Causal chain must be reconstructible: each event must link to its trigger (policy or prior event)</li></ul><h3 id="_3-4-determinism-guarantees" tabindex="-1">3.4 Determinism Guarantees <a class="header-anchor" href="#_3-4-determinism-guarantees" aria-label="Permalink to &quot;3.4 Determinism Guarantees&quot;">​</a></h3><p><strong>Replay Contract</strong>:</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>Given:</span></span>
<span class="line"><span>  - run_id (CIV simulation run)</span></span>
<span class="line"><span>  - institutional_entity_id</span></span>
<span class="line"><span>  - policy_bundle_id</span></span>
<span class="line"><span></span></span>
<span class="line"><span>Guarantee:</span></span>
<span class="line"><span>  - Re-running simulation produces identical institutional events in identical order</span></span>
<span class="line"><span>  - Venture replay of same compliance case produces identical case_id, evidence_chain, and findings</span></span>
<span class="line"><span>  - Cross-system validation: CIV event log == Venture audit trail (1:1 mapping)</span></span>
<span class="line"><span>  - Evidence chain is fully auditable: every event has provenance from CIV</span></span></code></pre></div><p><strong>Idempotency</strong>:</p><ul><li>Multiple relay of same institutional event must not create duplicate evidence items</li><li>Idempotency key: <code>hash(institution_id + event_type + tick_id + policy_bundle_id)</code></li><li>Venture compliance: idempotent on case_evidence_added.v1 (deduplicates by evidence_id)</li></ul><p><strong>Audit Trail Immutability</strong>:</p><ul><li>Evidence items are append-only; no modifications or deletions</li><li>Case status can only transition: open → closed (monotonic)</li><li>Hash of entire evidence chain provides tamper-proofing</li></ul><h3 id="_3-5-error-handling" tabindex="-1">3.5 Error Handling <a class="header-anchor" href="#_3-5-error-handling" aria-label="Permalink to &quot;3.5 Error Handling&quot;">​</a></h3><table tabindex="0"><thead><tr><th>Failure Mode</th><th>Detection</th><th>Recovery</th></tr></thead><tbody><tr><td>Institutional ID collision</td><td>Uniqueness check</td><td>Reject; emit error; require unique ID generation</td></tr><tr><td>State transition invalid</td><td>FSM validation</td><td>Reject; emit error; halt tick</td></tr><tr><td>Population imbalance (merge/split)</td><td>Sum check</td><td>Reject; emit error; require manual correction</td></tr><tr><td>Evidence item missing from chain</td><td>Audit replay</td><td>Log warning; flag case for review; don&#39;t auto-close</td></tr><tr><td>Causal event reference broken</td><td>Link validation</td><td>Log error; flag case as &quot;requires_investigation&quot;</td></tr><tr><td>Case closure without all evidence</td><td>Completeness check</td><td>Warn; allow closure if &gt; 99% evidence collected</td></tr><tr><td>Compliance violation detected during review</td><td>Case analysis</td><td>Change finding to &quot;non_compliant&quot;; escalate</td></tr></tbody></table><h3 id="_3-6-implementation-checklist" tabindex="-1">3.6 Implementation Checklist <a class="header-anchor" href="#_3-6-implementation-checklist" aria-label="Permalink to &quot;3.6 Implementation Checklist&quot;">​</a></h3><ul><li>[ ] CIV emits institution.* events for all institutional lifecycle changes</li><li>[ ] Venture relay creates compliance.case_opened.v1 for each new institution</li><li>[ ] Evidence chain appends for each institutional state change</li><li>[ ] Case closure on institution dissolution or inactivity timeout</li><li>[ ] Evidence items are append-only and immutable</li><li>[ ] Causal chain reconstruction test: can rebuild institutional history from evidence</li><li>[ ] Population balance validation for merge/split events</li><li>[ ] Cross-system determinism test: CIV institutional sequence == Venture evidence sequence</li><li>[ ] Audit trail hash verification</li><li>[ ] Compliance review interface: queryable case findings and evidence chains</li></ul><hr><h2 id="contract-4-civ-energy-accounting-↔-venture-cost-control-quota" tabindex="-1">Contract 4: CIV Energy Accounting ↔ Venture Cost Control &amp; Quota <a class="header-anchor" href="#contract-4-civ-energy-accounting-↔-venture-cost-control-quota" aria-label="Permalink to &quot;Contract 4: CIV Energy Accounting ↔ Venture Cost Control &amp; Quota&quot;">​</a></h2><p><strong>Integration Point ID</strong>: <code>INT-004-ENERGY-QUOTA</code></p><p><strong>Source</strong>: CIV Energy Module (CIV-0102, CIV-0100) <strong>Target</strong>: Venture Treasury &amp; Control Plane (TRACK-B, TRACK-C)</p><p><strong>Purpose</strong>: Align CIV&#39;s energy conservation equation with Venture&#39;s budget model, ensuring resource constraints apply consistently.</p><h3 id="_4-1-data-schema" tabindex="-1">4.1 Data Schema <a class="header-anchor" href="#_4-1-data-schema" aria-label="Permalink to &quot;4.1 Data Schema&quot;">​</a></h3><h4 id="civ-side-civ-energy-and-civ-economy-supply-stress-events" tabindex="-1">CIV Side: civ.energy.* and civ.economy.supply_stress Events <a class="header-anchor" href="#civ-side-civ-energy-and-civ-economy-supply-stress-events" aria-label="Permalink to &quot;CIV Side: civ.energy.* and civ.economy.supply_stress Events&quot;">​</a></h4><div class="language-typescript vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">typescript</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">interface</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> CivEnergyEvent</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  event_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  event_type</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;civ.energy.consumed.v1&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;civ.energy.generated.v1&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">              &quot;civ.energy.stored.v1&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;civ.energy.balance.v1&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">              &quot;civ.economy.supply_stress.v1&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  tick_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  run_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  policy_bundle_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  created_at</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> ISO8601Timestamp</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  payload</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">    // Energy consumption/generation</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    consumer_or_producer_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;   </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Entity ID</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    energy_qty</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;                 </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Joules</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    source_type</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;renewable&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;fossil&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;nuclear&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;storage&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;deficit&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">    // Energy balance (conservation equation)</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    tick_supply_total</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;         </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Total supply this tick (Joules)</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    tick_demand_total</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;         </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Total demand this tick</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    reserves_delta</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;            </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Change in reserves</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    conservation_check_passed</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> boolean</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">; </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// supply + reserves_in - losses - consumption - reserves_out = delta_stock</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    conservation_equation_hash</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">; </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// SHA256 of equation verification</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">    // Supply stress (peak-shaving trigger)</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    supply_shortfall</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;          </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Joules short</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    stress_multiplier</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;         </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Price/cost multiplier applied</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    peak_shaving_triggered</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> boolean</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">  };</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><h4 id="venture-side-venture-budget-and-venture-quota-events" tabindex="-1">Venture Side: venture.budget.* and venture.quota.* Events <a class="header-anchor" href="#venture-side-venture-budget-and-venture-quota-events" aria-label="Permalink to &quot;Venture Side: venture.budget.* and venture.quota.* Events&quot;">​</a></h4><div class="language-typescript vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">typescript</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">interface</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> VentureBudgetEvent</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  event_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  event_type</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;venture.budget.allocation_approved.v1&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;venture.budget.exceeded.v1&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">              &quot;venture.quota.consumption_recorded.v1&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;venture.money.cost_estimate.v1&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  workflow_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  trace_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  policy_bundle_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  created_at</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> ISO8601Timestamp</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  payload</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">    // Budget allocation</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    workspace_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;              </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Workspace receiving allocation</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    allocation_amount</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;         </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// EAU (Ecosystem Allocation Units)</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    allocation_window</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;         </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// e.g., &quot;per_workflow&quot;, &quot;per_month&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">    // Budget consumption</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    consumed_amount</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;           </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// EAU consumed this event</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    available_quota_before</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;    </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// EAU available before</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    available_quota_after</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;     </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// EAU available after</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">    // Quota overflow</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    budget_limit</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;              </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Hard cap (EAU)</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    actual_spend</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;              </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// What was spent</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    overage_amount</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;            </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// How much over limit</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    remediation_action</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;rate_limit&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;escalate&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;reject&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;auto_remediate&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">    // Cost estimate</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    cost_basis</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;energy_consumption&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;artifact_render&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;tool_call&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;storage&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    estimated_cost_eau</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    confidence_pct</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;            </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Confidence in estimate [0, 100]</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">    // Peak-shaving parallel</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    demand_multiplier</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;         </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// EAU cost multiplier (like energy price multiplier)</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    velocity_control_active</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> boolean</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;  </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Rate-limiting engaged (demand-response)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">  };</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><h3 id="_4-2-sync-protocol" tabindex="-1">4.2 Sync Protocol <a class="header-anchor" href="#_4-2-sync-protocol" aria-label="Permalink to &quot;4.2 Sync Protocol&quot;">​</a></h3><p><strong>Conversion Function</strong> (Energy → Budget):</p><div class="language-typescript vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">typescript</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">function</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> civ_energy_to_venture_eau</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  energy_joules</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  source_type</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  stress_multiplier</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> =</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 1.0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  policy_bundle_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">  // Base conversion: 1 Joule ≈ 0.001 EAU</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">  const</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> base_eau</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> energy_joules </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">*</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 0.001</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">  // Source type multiplier (calibrated per policy bundle)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">  const</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> source_multiplier</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">    renewable: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1.0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,      </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Cheapest</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">    fossil: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1.5</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,         </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// More expensive</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">    nuclear: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">0.8</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,        </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Efficient</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">    storage: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">2.0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,        </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Most expensive (discharge/recharge loss)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">    deficit: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">10.0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,       </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Crisis pricing</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">  }[source_type] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">||</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 1.0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">  // Peak-shaving multiplier (demand-response)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">  const</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> eau_cost</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> base_eau </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">*</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> source_multiplier </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">*</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> stress_multiplier;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">  return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> Math.</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">ceil</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(eau_cost </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">*</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 1e6</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">/</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 1e6</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">; </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Round to nearest micro-EAU</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><p><strong>Energy Balance ↔ Budget Conservation</strong>:</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>CIV Tick T:</span></span>
<span class="line"><span>  Energy Conservation Equation:</span></span>
<span class="line"><span>    Supply(t) + Reserves_in(t) - Losses(t) - Consumption(t) - Reserves_out(t) = ΔStock(t)</span></span>
<span class="line"><span></span></span>
<span class="line"><span>  Venture Parallel:</span></span>
<span class="line"><span>    Budget(t) = Budget(t-1) + Allocation(t) - ApprovedSpend(t) - PendingSpend(t) + ReserveInflux(t)</span></span>
<span class="line"><span></span></span>
<span class="line"><span>  Mapping:</span></span>
<span class="line"><span>    CIV Supply(t)        ↔  Venture Allocation(t)</span></span>
<span class="line"><span>    CIV Consumption(t)   ↔  Venture ApprovedSpend(t)</span></span>
<span class="line"><span>    CIV Reserves        ↔  Venture Reserved Accounts</span></span>
<span class="line"><span>    CIV ΔStock(t)        ↔  Venture ΔBudget(t)</span></span>
<span class="line"><span></span></span>
<span class="line"><span>  Both equations must hold deterministically (conservation laws)</span></span></code></pre></div><p><strong>Peak-Shaving Mechanics</strong>:</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>CIV:</span></span>
<span class="line"><span>  if supply &lt; demand then price *= (1.5 + (demand_excess / base_price))</span></span>
<span class="line"><span></span></span>
<span class="line"><span>Venture:</span></span>
<span class="line"><span>  if pending_spend &gt; 80% of budget then</span></span>
<span class="line"><span>    eau_cost *= 1.2 (cost escalation)</span></span>
<span class="line"><span>    rate_limit *= 0.8 (velocity control)</span></span></code></pre></div><p><strong>Timing</strong>:</p><ul><li>CIV emits energy.balance.v1 at end of each tick (after all consumption/generation)</li><li>Venture relay layer converts energy → EAU and records quota consumption</li><li>Latency SLA: &lt; 50ms from CIV tick end to Venture quota update</li><li>Daily reconciliation: CIV energy conservation must match Venture budget conservation</li></ul><h3 id="_4-3-validation-rules" tabindex="-1">4.3 Validation Rules <a class="header-anchor" href="#_4-3-validation-rules" aria-label="Permalink to &quot;4.3 Validation Rules&quot;">​</a></h3><h4 id="at-source-civ-3" tabindex="-1">At Source (CIV) <a class="header-anchor" href="#at-source-civ-3" aria-label="Permalink to &quot;At Source (CIV)&quot;">​</a></h4><ul><li><code>energy_qty</code> must be positive and non-NaN</li><li><code>source_type</code> must be one of allowed enum values</li><li>For energy.balance.v1: <code>conservation_check_passed</code> must be true <ul><li>Verify: supply + reserves_in - losses - consumption - reserves_out ≈ delta_stock (tolerance: 0.1 Joule)</li></ul></li><li><code>conservation_equation_hash</code> must be valid SHA256</li><li><code>stress_multiplier</code> must be ≥ 1.0 and ≤ 10.0</li><li>All numeric values must be finite (no Inf, -Inf, NaN)</li></ul><h4 id="at-target-venture-3" tabindex="-1">At Target (Venture) <a class="header-anchor" href="#at-target-venture-3" aria-label="Permalink to &quot;At Target (Venture)&quot;">​</a></h4><ul><li><code>consumed_amount</code> must be positive and ≤ <code>available_quota_before</code></li><li><code>available_quota_after</code> must equal <code>available_quota_before - consumed_amount</code></li><li><code>budget_limit</code> must be non-negative and finite</li><li><code>cost_basis</code> must be one of allowed enum values</li><li><code>demand_multiplier</code> must be ≥ 1.0 and ≤ 10.0 (mirrors stress_multiplier)</li><li>EAU amounts must be in valid range [0, 1e12] (prevent overflow)</li></ul><h4 id="cross-system-3" tabindex="-1">Cross-System <a class="header-anchor" href="#cross-system-3" aria-label="Permalink to &quot;Cross-System&quot;">​</a></h4><ul><li>Energy conservation equation must hold in CIV</li><li>Budget conservation law must hold in Venture</li><li>Both <code>conservation_check_passed</code> and Venture budget balance must be true</li><li>Peak-shaving multipliers must be consistent (CIV stress_multiplier ≈ Venture demand_multiplier)</li><li>Daily reconciliation: total CIV energy ≈ total Venture EAU (within 0.1% error tolerance)</li></ul><h3 id="_4-4-determinism-guarantees" tabindex="-1">4.4 Determinism Guarantees <a class="header-anchor" href="#_4-4-determinism-guarantees" aria-label="Permalink to &quot;4.4 Determinism Guarantees&quot;">​</a></h3><p><strong>Replay Contract</strong>:</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>Given:</span></span>
<span class="line"><span>  - run_id (CIV simulation run)</span></span>
<span class="line"><span>  - tick_id</span></span>
<span class="line"><span>  - policy_bundle_id (includes energy pricing model)</span></span>
<span class="line"><span>  - energy_source_type</span></span>
<span class="line"><span>  - RNG seed</span></span>
<span class="line"><span></span></span>
<span class="line"><span>Guarantee:</span></span>
<span class="line"><span>  - Re-executing CIV tick produces identical energy balance</span></span>
<span class="line"><span>  - Venture replay of same conversion produces identical EAU cost</span></span>
<span class="line"><span>  - Both conservation equations hold identically across replays</span></span>
<span class="line"><span>  - Conservation equation hash must match (byte-identical)</span></span>
<span class="line"><span>  - Peak-shaving trigger conditions match exactly</span></span></code></pre></div><p><strong>Idempotency</strong>:</p><ul><li>Multiple relay of same energy event must produce identical quota consumption</li><li>Idempotency key: <code>hash(energy_qty + source_type + tick_id + policy_bundle_id)</code></li><li>Venture quota engine deduplicates on idempotency key</li></ul><h3 id="_4-5-error-handling" tabindex="-1">4.5 Error Handling <a class="header-anchor" href="#_4-5-error-handling" aria-label="Permalink to &quot;4.5 Error Handling&quot;">​</a></h3><table tabindex="0"><thead><tr><th>Failure Mode</th><th>Detection</th><th>Recovery</th></tr></thead><tbody><tr><td>Energy conservation failed</td><td>check_passed == false</td><td>Reject tick; emit error; fail run</td></tr><tr><td>Budget conservation failed</td><td>balance mismatch</td><td>Open compliance case; pause quota updates</td></tr><tr><td>Conversion overflow (EAU &gt; 1e12)</td><td>Range check</td><td>Reject; emit error; escalate</td></tr><tr><td>Stress multiplier out of bounds</td><td>Range validation</td><td>Clamp to [1.0, 10.0]; log warning</td></tr><tr><td>Reconciliation drift &gt; 1%</td><td>Daily check</td><td>Log error; open compliance case; require investigation</td></tr><tr><td>Peak-shaving mismatch</td><td>Multiplier comparison</td><td>Log warning; flag for review</td></tr><tr><td>Source type not recognized</td><td>Enum validation</td><td>Reject; emit error</td></tr></tbody></table><h3 id="_4-6-implementation-checklist" tabindex="-1">4.6 Implementation Checklist <a class="header-anchor" href="#_4-6-implementation-checklist" aria-label="Permalink to &quot;4.6 Implementation Checklist&quot;">​</a></h3><ul><li>[ ] CIV emits energy.balance.v1 with conservation_check_passed = true</li><li>[ ] CIV equation verified: supply + reserves_in - losses - consumption - reserves_out = delta_stock</li><li>[ ] Venture conversion function: energy_joules × source_multiplier × stress_multiplier → EAU</li><li>[ ] Budget conservation law: budget(t) = budget(t-1) + allocation - spend</li><li>[ ] Peak-shaving mechanics aligned: CIV stress_multiplier ≈ Venture demand_multiplier</li><li>[ ] Determinism test: replay same tick N times → identical energy balance and EAU cost</li><li>[ ] Reconciliation test: daily sum of CIV energy ≈ daily sum of Venture EAU</li><li>[ ] Conservation equation hash verification (both systems)</li><li>[ ] Quota overflow detection and remediation</li><li>[ ] Compliance case auto-open on conservation law violation</li></ul><hr><h2 id="contract-5-civ-determinism-theorem-↔-venture-artifact-determinism" tabindex="-1">Contract 5: CIV Determinism Theorem ↔ Venture Artifact Determinism <a class="header-anchor" href="#contract-5-civ-determinism-theorem-↔-venture-artifact-determinism" aria-label="Permalink to &quot;Contract 5: CIV Determinism Theorem ↔ Venture Artifact Determinism&quot;">​</a></h2><p><strong>Integration Point ID</strong>: <code>INT-005-DETERMINISM-THEOREM</code></p><p><strong>Source</strong>: CIV Minimal Constraint Set Theorem (CIV-0104) <strong>Target</strong>: Venture Artifact Determinism (TRACK-A)</p><p><strong>Purpose</strong>: Align mathematical foundations of determinism across both systems; provide proof that artifact builds are deterministic given fixed inputs.</p><h3 id="_5-1-data-schema-proof-structure" tabindex="-1">5.1 Data Schema &amp; Proof Structure <a class="header-anchor" href="#_5-1-data-schema-proof-structure" aria-label="Permalink to &quot;5.1 Data Schema &amp; Proof Structure&quot;">​</a></h3><h4 id="civ-proof-artifact-civ-tick-completed-v1-state-verification" tabindex="-1">CIV Proof Artifact: civ.tick.completed.v1 (state verification) <a class="header-anchor" href="#civ-proof-artifact-civ-tick-completed-v1-state-verification" aria-label="Permalink to &quot;CIV Proof Artifact: civ.tick.completed.v1 (state verification)&quot;">​</a></h4><div class="language-typescript vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">typescript</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">interface</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> CivDeterminismProof</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  event_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  tick_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  run_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  policy_bundle_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">  // Minimal constraint set (CIV-0104)</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  minimal_constraint_set</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    population_state</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;         </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// SHA256 hash (not full state)</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    institution_state</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;        </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Hash</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    economy_ledger</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;           </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Hash</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    energy_state</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;             </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Hash</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    policy_bundle_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;         </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Pinned version</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    rng_seed</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;                 </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Simulation seed</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">  };</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">  // Proof verification</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  combined_state_hash</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;        </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// SHA256(sorted(constraint_set))</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  theorem_verification</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    theorem_name</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;minimal_constraint_set_v1&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    is_satisfied</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> boolean</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;            </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Did state transition satisfy the theorem?</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    proof_summary</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;            </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Human-readable proof</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">  };</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">  // Cross-system alignment</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  can_replay_deterministically</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> boolean</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  can_build_artifact_deterministically</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> boolean</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><h4 id="venture-proof-artifact-artifact-build-completed-v1-artifact-verification" tabindex="-1">Venture Proof Artifact: artifact.build.completed.v1 (artifact verification) <a class="header-anchor" href="#venture-proof-artifact-artifact-build-completed-v1-artifact-verification" aria-label="Permalink to &quot;Venture Proof Artifact: artifact.build.completed.v1 (artifact verification)&quot;">​</a></h4><div class="language-typescript vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">typescript</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">interface</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> VentureDeterminismProof</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  event_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  build_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  artifact_ir_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  workflow_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  policy_bundle_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">  // Minimal artifact constraint set (TRACK-A)</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  minimal_constraint_set</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    artifact_ir</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;              </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// SHA256 of IR (input)</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    toolchain_version</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;        </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Pinned version</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    policy_bundle_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;         </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Pinned policy</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    target_surface</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;           </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Build target (web, mobile, etc.)</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    provider_seeds</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;           </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// RNG seeds for non-deterministic providers</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">  };</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">  // Proof verification</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  content_hash</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;               </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// SHA256(artifact output)</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  determinism_contract</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    contract_name</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;deterministic_artifact_build_v1&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    is_satisfied</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> boolean</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;            </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Did build satisfy contract?</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    proof_summary</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;            </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Human-readable proof</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    provider_determinism</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;byte_identical&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;semantic_equivalent&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;non_deterministic&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">  };</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">  // Provenance chain</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">  provenance_signatures</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> Array</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&lt;{</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    provider</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;                 </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// e.g., &quot;openai&quot;, &quot;veo&quot;, &quot;nanobanana&quot;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    model_version</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    signature</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;                </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Ed25519 signature</span></span>
<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">    timestamp</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> ISO8601Timestamp</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">  }&gt;;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><h3 id="_5-2-constraint-set-alignment" tabindex="-1">5.2 Constraint Set Alignment <a class="header-anchor" href="#_5-2-constraint-set-alignment" aria-label="Permalink to &quot;5.2 Constraint Set Alignment&quot;">​</a></h3><p><strong>CIV Minimal Constraint Set</strong> (from CIV-0104):</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>State(t) is deterministic iff these constraints are fixed:</span></span>
<span class="line"><span>  1. Population entities and demographics</span></span>
<span class="line"><span>  2. Institution definitions and state</span></span>
<span class="line"><span>  3. Economy ledger (accounts and balances)</span></span>
<span class="line"><span>  4. Energy state (supplies, demands, reserves)</span></span>
<span class="line"><span>  5. Policy bundle version</span></span>
<span class="line"><span>  6. RNG seed</span></span>
<span class="line"><span></span></span>
<span class="line"><span>Theorem: State(t+1) = f(State(t), policy_bundle_id, rng_seed) is deterministic.</span></span>
<span class="line"><span>Proof: The 6 constraints above are sufficient and necessary to determine next state.</span></span></code></pre></div><p><strong>Venture Minimal Constraint Set</strong> (from TRACK-A):</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>Artifact is deterministic iff these constraints are fixed:</span></span>
<span class="line"><span>  1. Artifact IR (input specification)</span></span>
<span class="line"><span>  2. Toolchain version (compiler/renderer pinned)</span></span>
<span class="line"><span>  3. Policy bundle version (cost model, quality tier, etc.)</span></span>
<span class="line"><span>  4. Target surface (web, mobile, print, etc.)</span></span>
<span class="line"><span>  5. Provider seeds (for non-deterministic generators)</span></span>
<span class="line"><span></span></span>
<span class="line"><span>Theorem: Output = build(ir, toolchain, policy, surface, seeds) is deterministic within provider bounds.</span></span>
<span class="line"><span>Proof: The 5 constraints above determine output within semantics of provider.</span></span></code></pre></div><p><strong>Alignment</strong>:</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>CIV Constraint          ↔  Venture Constraint</span></span>
<span class="line"><span>─────────────────────────────────────────────────</span></span>
<span class="line"><span>Population state        ↔  Artifact IR (encodes current pop metrics)</span></span>
<span class="line"><span>Institution state       ↔  (part of IR)</span></span>
<span class="line"><span>Economy ledger          ↔  (part of IR)</span></span>
<span class="line"><span>Energy state            ↔  (part of IR)</span></span>
<span class="line"><span>Policy bundle v         ↔  Policy bundle v (1:1)</span></span>
<span class="line"><span>RNG seed                ↔  Provider seeds (analogous)</span></span>
<span class="line"><span></span></span>
<span class="line"><span>Result:</span></span>
<span class="line"><span>CIV proof(State(t+1)) must align with Venture proof(Artifact)</span></span>
<span class="line"><span>Both systems demonstrate determinism via identical constraint methodology</span></span></code></pre></div><h3 id="_5-3-proof-verification-protocol" tabindex="-1">5.3 Proof Verification Protocol <a class="header-anchor" href="#_5-3-proof-verification-protocol" aria-label="Permalink to &quot;5.3 Proof Verification Protocol&quot;">​</a></h3><p><strong>At CIV Side</strong>:</p><div class="language-rust vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">rust</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">fn</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> verify_civ_determinism_theorem</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">  current_tick</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> TickState</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">  constraint_set</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> ConstraintSet</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">  policy_bundle_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> PolicyBundleId</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">-&gt;</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> CivDeterminismProof</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">  // 1. Extract minimal constraints</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">  let</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> constraints </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> ConstraintSet</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">    population_state</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> hash</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&amp;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">current_tick</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">.</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">population),</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">    institution_state</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> hash</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&amp;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">current_tick</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">.</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">institutions),</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">    economy_ledger</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> hash</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&amp;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">current_tick</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">.</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">ledger),</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">    energy_state</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> hash</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&amp;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">current_tick</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">.</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">energy),</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">    policy_bundle_id,</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">    rng_seed</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> SIMULATION_SEED</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">  };</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">  // 2. Compute combined state hash</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">  let</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> combined_hash </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> compute_state_hash</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&amp;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">constraints);</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">  // 3. Verify theorem: same constraints → same state transitions</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">  let</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> next_state </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> execute_tick</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(current_state, constraints);</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">  let</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> next_hash </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> compute_state_hash</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&amp;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">next_state);</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">  // 4. Check idempotency: re-execute with same constraints</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">  let</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> next_state_2 </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> execute_tick</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(current_state, constraints);</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">  let</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> theorem_satisfied </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (next_state </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">==</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> next_state_2) </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&amp;&amp;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (next_hash </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">==</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> next_hash);</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">  return</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> CivDeterminismProof</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">    combined_state_hash</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> combined_hash,</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">    theorem_verification</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">      is_satisfied</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> theorem_satisfied,</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">      ...</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">    },</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">  };</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><p><strong>At Venture Side</strong>:</p><div class="language-rust vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">rust</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">fn</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> verify_venture_determinism_contract</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">  artifact_ir</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> ArtifactIR</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">  toolchain_version</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &amp;</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">  policy_bundle_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> PolicyBundleId</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">  target_surface</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &amp;</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">-&gt;</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> VentureDeterminismProof</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">  // 1. Check cache (idempotency key)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">  let</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> idempotency_key </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> hash</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">((</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">    &amp;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">artifact_ir,</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">    toolchain_version,</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">    policy_bundle_id,</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">    target_surface,</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">  ));</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">  if</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> let</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> Some</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(cached_output) </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> ARTIFACT_CACHE</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">.</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">get</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&amp;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">idempotency_key) {</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">    return</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> VentureDeterminismProof</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">      is_satisfied</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> true</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">      provider_determinism</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;byte_identical&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">      ...</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">    };</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">  }</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">  // 2. Build artifact (may be non-deterministic if external provider)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">  let</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (output, content_hash) </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> build_artifact</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">    &amp;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">artifact_ir,</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">    toolchain_version,</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">    policy_bundle_id,</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">    target_surface,</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">  );</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">  // 3. If deterministic provider: verify byte-identical on re-build</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">  let</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (output_2, hash_2) </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> build_artifact</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">...</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">); </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Same inputs</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">  let</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> byte_identical </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (output </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">==</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> output_2) </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&amp;&amp;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (content_hash </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">==</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> hash_2);</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">  // 4. If non-deterministic provider: verify semantic equivalence</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">  let</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> semantic_equivalent </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> byte_identical </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">||</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">    semantic_distance</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&amp;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">output, </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&amp;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">output_2) &lt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">EQUIVALENCE_THRESHOLD</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">  return</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> VentureDeterminismProof</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">    is_satisfied</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> byte_identical </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">||</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> semantic_equivalent,</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">    provider_determinism</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> byte_identical { </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;byte_identical&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">else</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;semantic_equivalent&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> },</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">    ...</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">  };</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><h3 id="_5-4-cross-system-proof-alignment" tabindex="-1">5.4 Cross-System Proof Alignment <a class="header-anchor" href="#_5-4-cross-system-proof-alignment" aria-label="Permalink to &quot;5.4 Cross-System Proof Alignment&quot;">​</a></h3><p><strong>Relay Protocol</strong>:</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>CIV Emits: civ.tick.completed.v1 (includes determinism proof)</span></span>
<span class="line"><span>  ↓</span></span>
<span class="line"><span>Venture Relay Layer</span></span>
<span class="line"><span>  ├─ Extract CivDeterminismProof.combined_state_hash</span></span>
<span class="line"><span>  ├─ Store as reference for cross-system validation</span></span>
<span class="line"><span>  └─ Emit artifact.build.completed.v1 (Venture proof)</span></span>
<span class="line"><span>  ↓</span></span>
<span class="line"><span>Compliance Engine</span></span>
<span class="line"><span>  ├─ Compare CIV proof with Venture proof</span></span>
<span class="line"><span>  ├─ Verify both systems achieve determinism via minimal constraint methodology</span></span>
<span class="line"><span>  └─ If proofs align: emit compliance.determinism_verified.v1</span></span>
<span class="line"><span>     If proofs diverge: emit compliance.violation_detected.v1 (severity=critical)</span></span></code></pre></div><p><strong>Verification Checklist</strong>:</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>For each artifact build tied to CIV simulation run:</span></span>
<span class="line"><span>  1. CIV tick T produces minimal_constraint_set C and hash H_civ</span></span>
<span class="line"><span>  2. Venture artifact build with constraints derived from C:</span></span>
<span class="line"><span>     a. IR contains C (population, institution, ledger, energy snapshots)</span></span>
<span class="line"><span>     b. Policy bundle = same as CIV policy_bundle_id</span></span>
<span class="line"><span>     c. Toolchain version pinned (matches policy bundle)</span></span>
<span class="line"><span>  3. Compute Venture hash H_venture</span></span>
<span class="line"><span>  4. Validate: H_civ ≈ H_venture (within representation differences)</span></span>
<span class="line"><span>  5. If hashes diverge: open compliance case (potential determinism bug)</span></span>
<span class="line"><span>  6. Archive both proofs for audit trail</span></span></code></pre></div><h3 id="_5-5-determinism-guarantees" tabindex="-1">5.5 Determinism Guarantees <a class="header-anchor" href="#_5-5-determinism-guarantees" aria-label="Permalink to &quot;5.5 Determinism Guarantees&quot;">​</a></h3><p><strong>Full Replay Contract</strong>:</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>Given:</span></span>
<span class="line"><span>  - run_id (CIV simulation run)</span></span>
<span class="line"><span>  - artifact_ir_id (Venture artifact to build)</span></span>
<span class="line"><span>  - policy_bundle_id (same in both systems)</span></span>
<span class="line"><span>  - All minimal constraints (population, institutions, ledger, energy, toolchain, seeds)</span></span>
<span class="line"><span></span></span>
<span class="line"><span>Guarantee:</span></span>
<span class="line"><span>  1. CIV tick T produces deterministic state transition:</span></span>
<span class="line"><span>     state(T+1) = f(state(T), constraints) is byte-identical on replay</span></span>
<span class="line"><span></span></span>
<span class="line"><span>  2. Venture artifact build is deterministic within provider bounds:</span></span>
<span class="line"><span>     artifact = build(ir, toolchain, policy, surface, seeds) is</span></span>
<span class="line"><span>     - byte-identical if all components deterministic</span></span>
<span class="line"><span>     - semantic-equivalent if non-deterministic provider (with fingerprint match)</span></span>
<span class="line"><span></span></span>
<span class="line"><span>  3. Both proofs are aligned:</span></span>
<span class="line"><span>     CivDeterminismProof.combined_state_hash ≈</span></span>
<span class="line"><span>       hash(ArtifactIRConstraints derived from CIV minimal_constraint_set)</span></span>
<span class="line"><span></span></span>
<span class="line"><span>  4. Full end-to-end replay:</span></span>
<span class="line"><span>     n-fold execution with same inputs → identical outputs (both systems)</span></span></code></pre></div><p><strong>Idempotency</strong>:</p><ul><li>Artifact builds with identical idempotency_key return cached output (byte-identical)</li><li>CIV ticks with identical seed/policy/constraints produce identical state</li><li>Both idempotency guarantees are mathematically proven via minimal constraint set</li></ul><h3 id="_5-6-error-handling-recovery" tabindex="-1">5.6 Error Handling &amp; Recovery <a class="header-anchor" href="#_5-6-error-handling-recovery" aria-label="Permalink to &quot;5.6 Error Handling &amp; Recovery&quot;">​</a></h3><table tabindex="0"><thead><tr><th>Failure Mode</th><th>Detection</th><th>Recovery</th></tr></thead><tbody><tr><td>CIV theorem not satisfied</td><td>verification fails</td><td>Reject tick; emit error; fail run; investigate determinism bug</td></tr><tr><td>Venture build non-deterministic</td><td>hash mismatch</td><td>Check provider; if internal bug: reject; if provider: tag as semantic-equivalent</td></tr><tr><td>Proof hashes diverge</td><td>cross-system comparison</td><td>Open critical compliance case; pause artifact builds; investigate</td></tr><tr><td>Minimal constraint violation</td><td>constraint check</td><td>Reject; emit error; require re-specification of constraints</td></tr><tr><td>Theorem not applicable</td><td>context validation</td><td>Check that all 6 CIV constraints are specified; fail if any missing</td></tr><tr><td>Cache collision (same idempotency key, different output)</td><td>cache validation</td><td>Reject; open critical bug report; wipe cache entry</td></tr></tbody></table><h3 id="_5-7-implementation-checklist" tabindex="-1">5.7 Implementation Checklist <a class="header-anchor" href="#_5-7-implementation-checklist" aria-label="Permalink to &quot;5.7 Implementation Checklist&quot;">​</a></h3><ul><li>[ ] CIV-0104 theorem implemented: verify minimal constraint set is sufficient for determinism</li><li>[ ] CIV emits determinism proof in each tick.completed.v1 event</li><li>[ ] Venture implements artifact determinism contract (byte-identical or semantic-equivalent)</li><li>[ ] Venture emits determinism proof in each artifact.build.completed.v1 event</li><li>[ ] Idempotency key computed and verified (both systems)</li><li>[ ] Cross-system proof alignment: compare CIV and Venture proofs</li><li>[ ] Compliance auto-check: hashes must match (within tolerance)</li><li>[ ] Full replay test: n-fold execution with same inputs → identical outputs</li><li>[ ] Provider-specific determinism handling (byte-identical vs semantic-equivalent)</li><li>[ ] Determinism bug detection and escalation (critical severity)</li></ul><hr><h2 id="summary-table" tabindex="-1">Summary Table <a class="header-anchor" href="#summary-table" aria-label="Permalink to &quot;Summary Table&quot;">​</a></h2><table tabindex="0"><thead><tr><th>Contract ID</th><th>CIV Component</th><th>Venture Component</th><th>Purpose</th><th>Status</th></tr></thead><tbody><tr><td>INT-001</td><td>Economy (CIV-0100)</td><td>Treasury (TRACK-B)</td><td>Ledger alignment, double-entry sync</td><td>Spec Complete</td></tr><tr><td>INT-002</td><td>Core Loop (CIV-0001)</td><td>Control Plane (TRACK-C)</td><td>FSM state sync, task orchestration</td><td>Spec Complete</td></tr><tr><td>INT-003</td><td>Institutions (CIV-0103)</td><td>Compliance (OPS)</td><td>Institutional audit trail, evidence chains</td><td>Spec Complete</td></tr><tr><td>INT-004</td><td>Energy (CIV-0102)</td><td>Quota/Budget (TRACK-B, TRACK-C)</td><td>Energy conservation → budget model</td><td>Spec Complete</td></tr><tr><td>INT-005</td><td>Theorem (CIV-0104)</td><td>Artifact (TRACK-A)</td><td>Determinism proof alignment</td><td>Spec Complete</td></tr></tbody></table><p>All 5 contracts are fully specified with schemas, protocols, validation rules, determinism guarantees, and implementation checklists.</p><hr><p><strong>Document Control</strong></p><table tabindex="0"><thead><tr><th>Version</th><th>Date</th><th>Author</th><th>Change</th></tr></thead><tbody><tr><td>1.0</td><td>2026-02-21</td><td>Kush Integration Team</td><td>Initial version; 5 formal interface contracts with full specifications</td></tr></tbody></table>`,192)])])}const g=i(e,[["render",l]]);export{c as __pageData,g as default};
