sica-fondt/core/tests/trust_tests.adb
Claude b6bcab794f
Reorg step 1: consolidate repo under core/, drop the mafiabot label
Mechanical structure-only pass (no document/guide content edits):

- Move src/ichor, src/endocrine, and docs/ into core/; the old top-level
  mafiabot_core/ becomes core/. Everything now lives under a single core/ root.
- Drop the "mafiabot" label from the Ada/Alire crate: core.gpr (project Core),
  alire.toml name = "core"; the generated *_config.* regenerate as core_config.*.
- Repoint build-critical wiring only:
  - .claude/skills/run-sica-fondt/smoke.sh (ponyc + Ada + COBOL paths)
  - core/src/endocrine R source()/runner paths and the test glob
  - .github/workflows/ci.yml (working-directory + gpr name)

Verified green: smoke ALL GREEN (Pony Ichor, Ada core crate + tests, COBOL E1
vault); R endocrine 14/0; Octave ETR 26/0/1.

Deferred (reserved for a less-ephemeral doc/guide pass): docmap.yaml, the guide
files and nested AGENTS.md/README prose + now-stale relative links, SOUL.md, and
the deeper ring/storage restructure.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015hmgREHNsxYCuim33yUF2c
2026-06-23 07:46:47 +00:00

70 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.Border_Message :=
(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;