sica-fondt/mafiabot_core/tests/config_tests.adb
gravermistakes 42ef321c4c
Add Gen.03 organ-systems core: Ada Medium, Soul/Tarot, trust boundary, Hermes MCP bridge
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.
2026-06-09 21:50:50 +00:00

55 lines
1.5 KiB
Ada

pragma SPARK_Mode (Off); -- test harness uses Ada.Text_IO
with Ada.Text_IO; use Ada.Text_IO;
with Config_Loader;
with Mafiabot_Types; use Mafiabot_Types;
procedure Config_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;
Store : Config_Loader.Config_Store;
St : Operation_Status;
Buf : constant String :=
"# gen.03 config" & ASCII.LF &
"host: localhost" & ASCII.LF &
"port: 8080" & ASCII.LF &
"" & ASCII.LF &
"name: ada" & ASCII.LF;
begin
Config_Loader.Load_From_Buffer (Buf, Store, St);
Check ("load ok", St = OK);
Check ("count = 3", Store.Count = 3);
declare
V : constant Bounded_Text := Config_Loader.Get_Value (Store, "host");
begin
Check ("host = localhost", To_String (V) = "localhost");
end;
declare
V : constant Bounded_Text := Config_Loader.Get_Value (Store, "port");
begin
Check ("port = 8080", To_String (V) = "8080");
end;
declare
V : constant Bounded_Text := Config_Loader.Get_Value (Store, "missing");
begin
Check ("missing key empty", V.Length = 0);
end;
if Fails = 0 then
Put_Line ("ALL CONFIG TESTS PASSED");
else
Put_Line ("CONFIG FAILURES:" & Natural'Image (Fails));
end if;
end Config_Tests;