mirror of
https://github.com/SHOGGOTH-SECTOR/sica-fondt.git
synced 2026-07-31 08:06:26 +00:00
Add Alire build setup and populate Engine package
- alire.toml rewritten to valid schema ([[depends-on]], real build-switch values); restrictions moved to gnat.adc - gnat.adc: project-wide Jorvik profile, No_Exceptions, No_Implicit_Dynamic_Code, SPARK_Mode On - mafiabot_core.gpr: source dirs, mains, global config pragmas - Engine: drop the caller-side precondition race on Transition_State; guard moved into the protected body with illegal transitions forcing Fault_Halt - Empty stubs (economy/sockets/exploits): drop Elaborate_Body so they no longer compile until implemented
This commit is contained in:
parent
d1e4eec578
commit
3918ed1c1a
18
mafiabot_core/alire.toml
Normal file
18
mafiabot_core/alire.toml
Normal file
@ -0,0 +1,18 @@
|
||||
name = "mafiabot_core"
|
||||
version = "0.1.0"
|
||||
description = "Sovereign cryptographic and economic routing engine"
|
||||
authors = ["Glitch-Witch"]
|
||||
maintainers = ["Glitch-Witch <redacted@dev.null>"]
|
||||
maintainers-logins = ["glitch-witch"]
|
||||
licenses = "MIT"
|
||||
|
||||
[[depends-on]]
|
||||
gnat_sockets = "^1.0.0"
|
||||
spark_lemmas = "^1.0.0"
|
||||
|
||||
# Build modes wildcard "*". Restrictions are NOT a build-switch: see gnat.adc.
|
||||
[build-switches]
|
||||
"*".ada_version = "Ada2022"
|
||||
"*".style_checks = "Max"
|
||||
"*".contracts = "Yes"
|
||||
"*".runtime_checks = "None"
|
||||
4
mafiabot_core/gnat.adc
Normal file
4
mafiabot_core/gnat.adc
Normal file
@ -0,0 +1,4 @@
|
||||
pragma Profile (Jorvik);
|
||||
pragma Restrictions (No_Exceptions);
|
||||
pragma Restrictions (No_Implicit_Dynamic_Code);
|
||||
pragma SPARK_Mode (On);
|
||||
21
mafiabot_core/mafiabot_core.gpr
Normal file
21
mafiabot_core/mafiabot_core.gpr
Normal file
@ -0,0 +1,21 @@
|
||||
with "config/mafiabot_core_config.gpr";
|
||||
|
||||
project Mafiabot_Core is
|
||||
|
||||
for Source_Dirs use
|
||||
("src",
|
||||
"src/core",
|
||||
"src/daemons",
|
||||
"src/network",
|
||||
"src/payloads",
|
||||
"config",
|
||||
"tests");
|
||||
for Object_Dir use "obj";
|
||||
for Exec_Dir use "bin";
|
||||
for Main use ("mafiabot.adb", "engine_tests.adb");
|
||||
|
||||
package Builder is
|
||||
for Global_Configuration_Pragmas use "gnat.adc";
|
||||
end Builder;
|
||||
|
||||
end Mafiabot_Core;
|
||||
@ -1,2 +1,34 @@
|
||||
-- The implementation of the Forge.
|
||||
package body Engine is
|
||||
|
||||
protected body Core_State is
|
||||
|
||||
-- Checked with the lock held. Only Booting -> Synced is legal;
|
||||
-- Fault_Halt is always reachable; anything else forces Fault_Halt.
|
||||
procedure Transition_State (New_State : Engine_State) is
|
||||
begin
|
||||
if (Current_State = Booting and then New_State = Synced)
|
||||
or else New_State = Fault_Halt
|
||||
then
|
||||
Current_State := New_State;
|
||||
else
|
||||
Current_State := Fault_Halt;
|
||||
end if;
|
||||
end Transition_State;
|
||||
|
||||
function Get_State return Engine_State is
|
||||
begin
|
||||
return Current_State;
|
||||
end Get_State;
|
||||
|
||||
end Core_State;
|
||||
|
||||
-- The Pre guarantees Sender_Balance >= Amount, so this subtraction can
|
||||
-- never underflow. SPARK proves it statically; no runtime handler needed.
|
||||
procedure Process_Transaction (Sender_Balance : in out Token_Amount;
|
||||
Amount : in Token_Amount) is
|
||||
begin
|
||||
Sender_Balance := Sender_Balance - Amount;
|
||||
end Process_Transaction;
|
||||
|
||||
end Engine;
|
||||
|
||||
@ -1,3 +1,29 @@
|
||||
pragma Elaborate_Body;
|
||||
-- The absolute, irrefutable blueprint of the Engine.
|
||||
package Engine is
|
||||
|
||||
-- Exact molecular weight of the economy. No unbounded integers.
|
||||
type Token_Amount is range 0 .. 100_000_000_000;
|
||||
|
||||
-- Strict state topologies. The system holds exactly one.
|
||||
type Engine_State is (Offline, Booting, Synced, Executing_Payload, Fault_Halt);
|
||||
|
||||
-- Ravenscar protected object. Concurrent memory safety, no races.
|
||||
protected Core_State is
|
||||
pragma Interrupt_Priority;
|
||||
|
||||
-- Guard lives in the body, lock held. Illegal transition -> Fault_Halt.
|
||||
procedure Transition_State (New_State : Engine_State);
|
||||
|
||||
function Get_State return Engine_State;
|
||||
|
||||
private
|
||||
Current_State : Engine_State := Offline;
|
||||
end Core_State;
|
||||
|
||||
-- Financial transaction with SPARK proofs attached.
|
||||
procedure Process_Transaction (Sender_Balance : in out Token_Amount;
|
||||
Amount : in Token_Amount)
|
||||
with Pre => Sender_Balance >= Amount,
|
||||
Post => Sender_Balance = Sender_Balance'Old - Amount;
|
||||
|
||||
end Engine;
|
||||
|
||||
@ -1,3 +1,2 @@
|
||||
pragma Elaborate_Body;
|
||||
package Economy is
|
||||
end Economy;
|
||||
|
||||
@ -1,3 +1,2 @@
|
||||
pragma Elaborate_Body;
|
||||
package Sockets is
|
||||
end Sockets;
|
||||
|
||||
@ -1,3 +1,2 @@
|
||||
pragma Elaborate_Body;
|
||||
package Exploits is
|
||||
end Exploits;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user