mirror of
https://github.com/SHOGGOTH-SECTOR/sica-fondt.git
synced 2026-09-30 01:15:10 +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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user