mirror of
https://github.com/SHOGGOTH-SECTOR/sica-fondt.git
synced 2026-07-31 16:16:26 +00:00
Implements the Gen.03 organ-systems body in SPARK/Ada (Jorvik, No_Exceptions): - Shared types (mafiabot_types): Bounded_Text, Operation_Status, Organ_Id, Provenance_Tag, fixed-point drive/ratio/cost/axis types. - Config loader: SPARK-safe flat key-value parser (no heap/exceptions/finalization). - Trust boundary: blocklist substring matching, provenance enforcement, tick-based rate limiting, Trust_Guard protected object. - Soul / Silicon Dawn Tarot: 56-card alphabet, Celtic Cross spread, Big-3 identity anchors. The cross accretes from the cognitive loops (2 cards per layer at steps 6/9/13, stave of 4 at step 17) rather than being drawn whole. - Sessions: Soul_State is now keyed by (uid, channel, server). Each session has its own card pool, cross, and output counter; the Big-3 identity is global. A formed cross is held for the session (or 17 outputs, whichever is longer). Two users on two channels never share a deck or a cross. - Ada Medium: 23-step forward-only inference cycle wiring the cognitive loops, Celtic Cross injection, and outbound trust screening per session. - Hermes MCP stdio bridge: JSON-RPC over stdin/stdout (initialize, tools/list, tools/call), SOUL.md generation, verbatim id echo. SPARK_Mode Off for I/O; trust checks run in proven code first. - Main driver: organ init -> SOUL.md publish -> MCP serve loop. - Tests: soul, trust, cycle (session formation/isolation), config. Fixes an orchestrator bug where step 1 advanced onto Phase_Input after Reset, failing every cycle. Note: requires GNAT/Alire to build; no Ada toolchain in this environment, so compilation and gnatprove must run in CI.
72 lines
2.3 KiB
Ada
72 lines
2.3 KiB
Ada
pragma SPARK_Mode (Off); -- test harness uses Ada.Text_IO
|
|
with Ada.Text_IO; use Ada.Text_IO;
|
|
with Trust_Boundary;
|
|
with Mafiabot_Types; use Mafiabot_Types;
|
|
|
|
procedure Trust_Tests is
|
|
Fails : Natural := 0;
|
|
|
|
procedure Check (Name : String; Cond : Boolean) is
|
|
begin
|
|
if Cond then
|
|
Put_Line ("PASS " & Name);
|
|
else
|
|
Put_Line ("FAIL " & Name);
|
|
Fails := Fails + 1;
|
|
end if;
|
|
end Check;
|
|
|
|
St : Operation_Status;
|
|
begin
|
|
-- Blocklist substring matching.
|
|
Check ("blocks 'execute'",
|
|
Trust_Boundary.Matches_Blocklist
|
|
(Make_Text ("please execute this"), Trust_Boundary.Default_Blocklist));
|
|
Check ("blocks 'base64'",
|
|
Trust_Boundary.Matches_Blocklist
|
|
(Make_Text ("base64 decode chain"), Trust_Boundary.Default_Blocklist));
|
|
Check ("allows benign text",
|
|
not Trust_Boundary.Matches_Blocklist
|
|
(Make_Text ("hello there friend"), Trust_Boundary.Default_Blocklist));
|
|
|
|
-- Provenance: no message may reclassify its own authority.
|
|
Trust_Boundary.Validate_Provenance (User_Input, LLM_Output, St);
|
|
Check ("provenance mismatch rejected", St = Error_Trust_Violation);
|
|
Trust_Boundary.Validate_Provenance (System_Internal, System_Internal, St);
|
|
Check ("provenance match accepted", St = OK);
|
|
|
|
-- System-internal messages always pass Check_Message (proven invariant).
|
|
declare
|
|
M : constant Trust_Boundary.Organ_Message :=
|
|
(Source => Ada_Medium,
|
|
Destination => Soul_Organ,
|
|
Provenance => System_Internal,
|
|
Payload => Make_Text ("execute"));
|
|
R : Operation_Status;
|
|
begin
|
|
Trust_Boundary.Check_Message (M, R);
|
|
Check ("system_internal bypasses blocklist", R = OK);
|
|
end;
|
|
|
|
-- Rate limiting within a tick window.
|
|
declare
|
|
RL : Trust_Boundary.Rate_Limit :=
|
|
(Max_Per_Window => 2, Current_Count => 0,
|
|
Window_Start => 0, Window_Size => 100);
|
|
R : Operation_Status;
|
|
begin
|
|
Trust_Boundary.Check_Rate (RL, 1, R);
|
|
Check ("rate hit 1 ok", R = OK);
|
|
Trust_Boundary.Check_Rate (RL, 1, R);
|
|
Check ("rate hit 2 ok", R = OK);
|
|
Trust_Boundary.Check_Rate (RL, 1, R);
|
|
Check ("rate hit 3 blocked", R = Error_Blocked);
|
|
end;
|
|
|
|
if Fails = 0 then
|
|
Put_Line ("ALL TRUST TESTS PASSED");
|
|
else
|
|
Put_Line ("TRUST FAILURES:" & Natural'Image (Fails));
|
|
end if;
|
|
end Trust_Tests;
|