mirror of
https://github.com/SHOGGOTH-SECTOR/sica-fondt.git
synced 2026-11-29 08:25:10 +00:00
M3: expose native engine registry and horizon clocks through M0
This commit is contained in:
@@ -1,15 +1,20 @@
|
|||||||
# M0 stomach/economy organ composition for sica-fondt.
|
# M0 stomach/economy organ composition for sica-fondt.
|
||||||
# Tcl 8.6, external-dependency free. This scaffold is simulation-only: no RPC,
|
# The stomach is an OUTER organ. Market execution remains simulation-only here;
|
||||||
# signing, or private-key surface exists yet.
|
# M3's native engines are registered as subordinate simulation processes.
|
||||||
namespace eval ::stomach { variable version 0.1 }
|
namespace eval ::stomach { variable version 0.2; variable root }
|
||||||
set __stomach_dir [file dirname [file normalize [info script]]]
|
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]
|
source [file join $__stomach_dir $__stomach_file]
|
||||||
}
|
}
|
||||||
unset __stomach_file
|
unset __stomach_file
|
||||||
|
|
||||||
oo::class create ::stomach::Economy {
|
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} {
|
constructor {args} {
|
||||||
set cap 256
|
set cap 256
|
||||||
if {[llength $args] % 2 != 0} { error "options must be key/value pairs" }
|
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 conductor [::stomach::Conductor new $traders]
|
||||||
set feeds [::stomach::Feeds new $cap]
|
set feeds [::stomach::Feeds new $cap]
|
||||||
set sims [::stomach::SimsHub new]
|
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 market [::stomach::Marketplace new $traders $wallets $conductor $sae $sims]
|
||||||
set taxes {}
|
set taxes {}
|
||||||
}
|
}
|
||||||
destructor {
|
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 register_trader {id specialization} { return [$traders register $id $specialization] }
|
||||||
method bind_wallet {wallet_id trader_id daily_limit per_action_limit} {
|
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 feed_history {feed_type} { return [$feeds history $feed_type] }
|
||||||
method sim_publish {sim_type prediction} { return [$sims publish $sim_type $prediction] }
|
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 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} {
|
method tax_event {trader_id amount source_wallet dest_wallet} {
|
||||||
if {![string is double -strict $amount] || $amount < 0} { error "invalid_tax_amount" }
|
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]
|
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
|
return $receipt
|
||||||
}
|
}
|
||||||
method secretion {} {
|
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 sae_log {} { return [$sae log] }
|
||||||
method decision_log {} { return [$conductor log] }
|
method decision_log {} { return [$conductor log] }
|
||||||
|
|||||||
Reference in New Issue
Block a user