From 255b927694b3abfaaab145bb0c7c967b4037c7ed Mon Sep 17 00:00:00 2001 From: gravermistakes Date: Sun, 18 Oct 2026 22:49:29 -0700 Subject: [PATCH] M3: expose native engine registry and horizon clocks through M0 --- core/src/economy/stomach.tcl | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/core/src/economy/stomach.tcl b/core/src/economy/stomach.tcl index 235bdd0..96625f5 100644 --- a/core/src/economy/stomach.tcl +++ b/core/src/economy/stomach.tcl @@ -1,15 +1,20 @@ # M0 stomach/economy organ composition for sica-fondt. -# Tcl 8.6, external-dependency free. This scaffold is simulation-only: no RPC, -# signing, or private-key surface exists yet. -namespace eval ::stomach { variable version 0.1 } +# The stomach is an OUTER organ. Market execution remains simulation-only here; +# M3's native engines are registered as subordinate simulation processes. +namespace eval ::stomach { variable version 0.2; variable root } set __stomach_dir [file dirname [file normalize [info script]]] -foreach __stomach_file {traders.tcl wallets.tcl sae.tcl conductor.tcl feeds.tcl sims/hub.tcl marketplace.tcl} { +set ::stomach::root $__stomach_dir +foreach __stomach_file { + traders.tcl wallets.tcl sae.tcl conductor.tcl feeds.tcl + sims/registry.tcl sims/scheduler.tcl sims/hub.tcl + marketplace.tcl +} { source [file join $__stomach_dir $__stomach_file] } unset __stomach_file oo::class create ::stomach::Economy { - variable traders wallets sae conductor feeds sims market taxes + variable traders wallets sae conductor feeds sims registry clock market taxes constructor {args} { set cap 256 if {[llength $args] % 2 != 0} { error "options must be key/value pairs" } @@ -25,11 +30,15 @@ oo::class create ::stomach::Economy { set conductor [::stomach::Conductor new $traders] set feeds [::stomach::Feeds new $cap] set sims [::stomach::SimsHub new] + set registry [::stomach::EngineRegistry new [file join $::stomach::root sims]] + set clock [::stomach::HorizonClock new] set market [::stomach::Marketplace new $traders $wallets $conductor $sae $sims] set taxes {} } destructor { - foreach obj [list $market $sims $feeds $conductor $sae $wallets $traders] { catch {$obj destroy} } + foreach obj [list $market $clock $registry $sims $feeds $conductor $sae $wallets $traders] { + catch {$obj destroy} + } } method register_trader {id specialization} { return [$traders register $id $specialization] } method bind_wallet {wallet_id trader_id daily_limit per_action_limit} { @@ -48,6 +57,10 @@ oo::class create ::stomach::Economy { method feed_history {feed_type} { return [$feeds history $feed_type] } method sim_publish {sim_type prediction} { return [$sims publish $sim_type $prediction] } method query_predictions {trader_id sim_type} { return [$market predictions $trader_id $sim_type] } + method sim_engines {} { return [$registry names] } + method sim_engine_status {} { return [$registry status] } + method sim_horizons {} { return [$clock horizons] } + method sim_advance {wall_seconds} { return [$clock advance $wall_seconds] } method tax_event {trader_id amount source_wallet dest_wallet} { if {![string is double -strict $amount] || $amount < 0} { error "invalid_tax_amount" } set receipt [dict create receipt_id [format "tax-%06d" [expr {[llength $taxes] + 1}]] status staged transferred 0 trader_id $trader_id amount $amount source_wallet $source_wallet dest_wallet $dest_wallet] @@ -55,7 +68,7 @@ oo::class create ::stomach::Economy { return $receipt } method secretion {} { - return [dict create source stomach destination ada_border provenance organ_secretion live_execution 0 traders [$traders count] wallets [$wallets count] predictions [$sims count] executions [$market execution_count] paused_traders [$traders paused_count] tax_receipts [llength $taxes]] + return [dict create source stomach destination ada_border provenance organ_secretion live_execution 0 traders [$traders count] wallets [$wallets count] sim_engines [llength [$registry names]] predictions [$sims count] executions [$market execution_count] paused_traders [$traders paused_count] tax_receipts [llength $taxes]] } method sae_log {} { return [$sae log] } method decision_log {} { return [$conductor log] }