Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .trinity/seals/claw_ClawGithubSurface.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,31 @@
"closure": [
{
"spec": "specs/claw/recipes.t27",
"spec_hash": "sha256:4615e122b6168628dd67b36407724a6ad72e62a80c797b5a6b7132a82c488ec7"
"spec_hash": "sha256:429ab03319e9d59f6a4aad6945693a83374d6d805e32ad72836bf7aff23d6cb3"
}
],
"config": "gen=c,rust,verilog,zig;tests=zig",
"gen_hash_c": "sha256:5d51a2819ce6b8fa8a3f096d2d30ffe3bd1ec516966934c9988768c4d551a4d4",
"gen_hash_rust": "sha256:a0c7fddf229b960f7865510b9d3fef5b55e8f8be7b33392bba40a1b361140634",
"gen_hash_verilog": "sha256:33a2cec5da3824906ca1f37263099fb4a4d5df4a75632110cf0b9b5548e8cd13",
"gen_hash_zig": "sha256:f347d716459dcfbe0b761bf61e6f1afc6ef0ec72232de897e0b845584cdaf16f",
"gen_hash_c": "sha256:67fe08c4a7e8c4f4fe6cc676144d2f6a2674d17ea14b6bb8a26b1d6c91b90c9a",
"gen_hash_rust": "sha256:df9ca813fcb97d3be96814b32801c3999c0f7480f159a8c60043077db0a12583",
"gen_hash_verilog": "sha256:72db719c662ec54e1f30e6ef9e7da18a4de07b81af7c88b7f16ccf384cb56e98",
"gen_hash_zig": "sha256:31da09d08d2231e8d9929d3d457070b6af2ee769c88c1829f71747737879cc44",
"module": "ClawGithubSurface",
"ring": 12,
"seal_schema": 2,
"sealed_at": "2026-10-18T11:06:44Z",
"sealed_at": "2026-10-18T22:11:43Z",
"sealed_by": "t27c-bootstrap@0.5.2",
"spec_hash": "sha256:6c4b153e698cfe91e964e3bd05ffb7f8c611ff5b4eb9535dff11e878303856ae",
"spec_hash": "sha256:42b1a9b096476016af0458355081812f3ca055550ebe12c8c8fcc30e215f0f4c",
"spec_path": "specs/claw/github_surface.t27",
"tests": {
"failed": 0,
"failing": [],
"forced": false,
"passed": 15,
"total": 15,
"passed": 18,
"total": 18,
"vacuous": 0
},
"toolchain": {
"test_runner": "sha256:1982ae948e24d00c5d221ccec12dfce1eb01204b53e37b0f857f93b16d64629d",
"test_runner": "sha256:8512b80da533b79289110fca4a65f3336abd7a059ca4b72ea595d5e33ff8ad10",
"zig": "0.16.0"
}
}
20 changes: 10 additions & 10 deletions .trinity/seals/claw_ClawRecipes.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
{
"built_by": "t27c-bootstrap@0.5.2+d2c8e7d41",
"built_by": "t27c-bootstrap@0.5.2+9448ab4be",
"closure": [],
"config": "gen=c,rust,verilog,zig;tests=zig",
"gen_hash_c": "sha256:711f3b2aaaf8a533d64bd065a42b0128a3f12a9c3bb80e7900590ac0d22b73bc",
"gen_hash_rust": "sha256:66f8ebf4aefac43f0556f27061aa7fb7939ca970cfc29b768bd1c014b507a379",
"gen_hash_verilog": "sha256:54d2af589662485eeda9dd8217e2a55d4ca9946945e283634e4261059d761fd3",
"gen_hash_zig": "sha256:858f820aaabd4c9ebd3f774211b2b87d40776f9374815952950d8657af276f22",
"gen_hash_c": "sha256:fe8c82237dca60c470c4e0f7b58c14f1049ce7abfdcbc9874d1ad9f40a680413",
"gen_hash_rust": "sha256:9c80db73625eab123123beea1d9a1ff11917eb917b1e5c0c4e5d0e2c78342d83",
"gen_hash_verilog": "sha256:57b204d65c2f93000a30e7a1a2bb75beeff3fd60c566fca62ee8738070dc1610",
"gen_hash_zig": "sha256:ddc71e72ebb6a29870bbce76f033ff72fad783a29c7ce1b7a34be1a889399889",
"module": "ClawRecipes",
"ring": 12,
"seal_schema": 2,
"sealed_at": "2026-10-18T05:03:44Z",
"sealed_at": "2026-10-18T22:11:40Z",
"sealed_by": "t27c-bootstrap@0.5.2",
"spec_hash": "sha256:4615e122b6168628dd67b36407724a6ad72e62a80c797b5a6b7132a82c488ec7",
"spec_hash": "sha256:429ab03319e9d59f6a4aad6945693a83374d6d805e32ad72836bf7aff23d6cb3",
"spec_path": "specs/claw/recipes.t27",
"tests": {
"failed": 0,
"failing": [],
"forced": false,
"passed": 11,
"total": 11,
"passed": 16,
"total": 16,
"vacuous": 0
},
"toolchain": {
"test_runner": "sha256:1982ae948e24d00c5d221ccec12dfce1eb01204b53e37b0f857f93b16d64629d",
"test_runner": "sha256:8512b80da533b79289110fca4a65f3336abd7a059ca4b72ea595d5e33ff8ad10",
"zig": "0.16.0"
}
}
86 changes: 74 additions & 12 deletions specs/claw/github_surface.t27
Original file line number Diff line number Diff line change
Expand Up @@ -224,16 +224,23 @@ pub fn granted(perm : str) -> u8 {
return L_NONE;
}

/// Every mintable row fits inside the measured grant: the App can actually mint what it plans.
pub fn plan_fits_grant(owner_yes : bool) -> bool {
/// Every mintable row of a level column fits inside the measured grant. The column is a
/// parameter so a test can raise one row past the grant: a check that only reads LEVELS can
/// never fail, and no mutant of it can die.
pub fn levels_fit_grant(lv : [27]u8, owner_yes : bool) -> bool {
for i in 0..27 {
if (row_mintable(i, owner_yes)) {
if (LEVELS[i] > granted(PERMS[i])) { return false; }
if (lv[i] > granted(PERMS[i])) { return false; }
}
}
return true;
}

/// Every mintable row fits inside the measured grant: the App can actually mint what it plans.
pub fn plan_fits_grant(owner_yes : bool) -> bool {
return levels_fit_grant(LEVELS, owner_yes);
}

/// How many granted permissions no token will ever use at their granted level -- the part of
/// the grant that only widens a leak. The owner may narrow the App by exactly these.
pub fn over_granted(owner_yes : bool) -> u32 {
Expand All @@ -253,31 +260,42 @@ pub fn count_status(s : u8) -> u32 {
return n;
}

/// Every row has surface, permission, endpoint and value.
pub fn every_row_filled() -> bool {
/// Every row of a table shaped like this one has surface, permission, endpoint and value.
/// The columns are parameters so a test can hand in a copy with one hole.
pub fn rows_filled(s : [27]str, p : [27]str, e : [27]str, v : [27]str) -> bool {
for i in 0..27 {
if SURFACES[i] == "" { return false; }
if PERMS[i] == "" { return false; }
if ENDPOINTS[i] == "" { return false; }
if VALUES[i] == "" { return false; }
if s[i] == "" { return false; }
if p[i] == "" { return false; }
if e[i] == "" { return false; }
if v[i] == "" { return false; }
}
return true;
}

/// No surface appears twice among the first n rows.
pub fn all_surfaces_unique(n : usize) -> bool {
/// The surface table is filled.
pub fn every_row_filled() -> bool {
return rows_filled(SURFACES, PERMS, ENDPOINTS, VALUES);
}

/// No surface appears twice among the first n rows of `xs`.
pub fn surfaces_unique_in(xs : [27]str, n : usize) -> bool {
var i : usize = 0;
while (i < n) {
var j : usize = i + 1;
while (j < n) {
if recipes::str_eq(SURFACES[i], SURFACES[j]) { return false; }
if recipes::str_eq(xs[i], xs[j]) { return false; }
j += 1;
}
i += 1;
}
return true;
}

/// No surface of the table appears twice among its first n rows.
pub fn all_surfaces_unique(n : usize) -> bool {
return surfaces_unique_in(SURFACES, n);
}

test surface_rows_are_filled_and_unique {
assert every_row_filled() == true;
assert all_surfaces_unique((COUNT) as usize) == true;
Expand Down Expand Up @@ -425,3 +443,47 @@ test the_original_rows_keep_their_permission_level_and_status {
assert STATUS[21] == S_REFUSED;
assert COUNT == 27;
}

test a_hole_in_any_column_fails_the_filled_check {
assert rows_filled(SURFACES, PERMS, ENDPOINTS, VALUES) == true;
var s : [27]str = SURFACES;
s[26] = "";
assert rows_filled(s, PERMS, ENDPOINTS, VALUES) == false;
var p : [27]str = PERMS;
p[0] = "";
assert rows_filled(SURFACES, p, ENDPOINTS, VALUES) == false;
var e : [27]str = ENDPOINTS;
e[13] = "";
assert rows_filled(SURFACES, PERMS, e, VALUES) == false;
var v : [27]str = VALUES;
v[13] = "";
assert rows_filled(SURFACES, PERMS, ENDPOINTS, v) == false;
}

test a_repeated_surface_is_caught_wherever_it_sits {
var s : [27]str = SURFACES;
s[1] = s[0];
assert surfaces_unique_in(s, 27) == false;
assert surfaces_unique_in(s, 1) == true;
var t : [27]str = SURFACES;
t[26] = t[25];
assert surfaces_unique_in(t, 27) == false;
assert surfaces_unique_in(t, 26) == true;
}

test a_mintable_row_past_the_grant_breaks_the_plan {
// L_WRITE is the highest grant, so a level of 3 fits nothing.
assert levels_fit_grant(LEVELS, false) == true;
var lv : [27]u8 = LEVELS;
lv[0] = 3;
assert levels_fit_grant(lv, false) == false;
// Row 17 (secrets) is refused: no token carries it, so its level is never checked.
var r : [27]u8 = LEVELS;
r[17] = 3;
assert levels_fit_grant(r, true) == true;
// Row 11 (required-check-ruleset) is minted only with the owner's yes.
var o : [27]u8 = LEVELS;
o[11] = 3;
assert levels_fit_grant(o, false) == true;
assert levels_fit_grant(o, true) == false;
}
107 changes: 91 additions & 16 deletions specs/claw/recipes.t27
Original file line number Diff line number Diff line change
Expand Up @@ -179,46 +179,64 @@ pub fn count_class(c: u8) -> u32 {
return n;
}

/// Every row has gate, kind, tool, condition -- and OWNER rows carry no command.
pub fn every_row_filled() -> bool {
/// Every row of a table shaped like this one has gate, kind, tool, condition -- and OWNER rows
/// carry no command. The table is a parameter so a test can hand it a copy with one hole: a
/// check that only ever reads the constant table can never fail, and no mutant of it can die.
pub fn rows_filled(g: [22]str, k: [22]str, t: [22]str, c: [22]str, cl: [22]u8, cmd: [22]str) -> bool {
for i in 0..22 {
if GATES[i] == "" { return false; }
if KINDS[i] == "" { return false; }
if TOOLS[i] == "" { return false; }
if CONDS[i] == "" { return false; }
if CLASSES[i] == C_OWNER {
if CMDS[i] != "" { return false; }
if g[i] == "" { return false; }
if k[i] == "" { return false; }
if t[i] == "" { return false; }
if c[i] == "" { return false; }
if cl[i] == C_OWNER {
if cmd[i] != "" { return false; }
}
}
return true;
}

/// No kind appears twice among the first n rows -- n*(n-1)/2 pairwise comparisons.
/// The recipe table is filled.
pub fn every_row_filled() -> bool {
return rows_filled(GATES, KINDS, TOOLS, CONDS, CLASSES, CMDS);
}

/// No kind appears twice among the first n rows of `xs` -- n*(n-1)/2 pairwise comparisons.
/// n is a parameter because a hard-coded bound rots when rows land (round 1 kept
/// 19-row while bounds through a 21-row table: rows 19-20 were never compared).
pub fn all_kinds_unique(n: usize) -> bool {
pub fn kinds_unique_in(xs: [22]str, n: usize) -> bool {
var i : usize = 0;
while (i < n) {
var j : usize = i + 1;
while (j < n) {
if str_eq(KINDS[i], KINDS[j]) { return false; }
if str_eq(xs[i], xs[j]) { return false; }
j += 1;
}
i += 1;
}
return true;
}

/// Every AUTO row carries a command and a condition; REVIEW rows carry a command to prepare.
pub fn auto_rows_carry_their_brief() -> bool {
for i in 0..21 {
if CLASSES[i] == C_AUTO {
if CMDS[i] == "" { return false; }
/// No kind of the recipe table appears twice among its first n rows.
pub fn all_kinds_unique(n: usize) -> bool {
return kinds_unique_in(KINDS, n);
}

/// Every AUTO row of a table carries a command. All 22 rows: the bound was 0..21 until
/// 2026-10-19, so row 21 (attest-input-rename, AUTO) was never checked.
pub fn auto_rows_carry(cl: [22]u8, cmd: [22]str) -> bool {
for i in 0..22 {
if cl[i] == C_AUTO {
if cmd[i] == "" { return false; }
}
}
return true;
}

/// Every AUTO row of the recipe table carries its command.
pub fn auto_rows_carry_their_brief() -> bool {
return auto_rows_carry(CLASSES, CMDS);
}

test class_constants_and_the_none_sentinel {
assert C_AUTO == 0;
assert C_REVIEW == 1;
Expand Down Expand Up @@ -333,3 +351,60 @@ test tools_are_the_recorded_instruments {
assert str_eq(tool_of("physics-move"), "tri");
assert str_eq(tool_of("attest-input-rename"), "git");
}

test row_zero_answers_its_own_lookups {
// Row 0 is the first index a lookup can return; `r < 0` read as `r <= 0` would lose it.
assert class_of("fallback-manual") == C_OWNER;
assert str_eq(tool_of("fallback-manual"), "owner");
assert str_eq(gate_of("fallback-manual"), "any");
assert str_eq(cond_of("fallback-manual"), "") == false;
assert str_eq(cmd_of("fallback-manual"), "");
}

test a_hole_in_any_column_fails_the_filled_check {
assert rows_filled(GATES, KINDS, TOOLS, CONDS, CLASSES, CMDS) == true;
var g : [22]str = GATES;
g[21] = "";
assert rows_filled(g, KINDS, TOOLS, CONDS, CLASSES, CMDS) == false;
var k : [22]str = KINDS;
k[0] = "";
assert rows_filled(GATES, k, TOOLS, CONDS, CLASSES, CMDS) == false;
var t : [22]str = TOOLS;
t[3] = "";
assert rows_filled(GATES, KINDS, t, CONDS, CLASSES, CMDS) == false;
var c : [22]str = CONDS;
c[3] = "";
assert rows_filled(GATES, KINDS, TOOLS, c, CLASSES, CMDS) == false;
}

test an_owner_row_with_a_command_is_not_filled {
// Row 0 is OWNER: a command there fails. Row 2 is REVIEW: a command there is allowed.
var cmd : [22]str = CMDS;
cmd[0] = "git push";
assert rows_filled(GATES, KINDS, TOOLS, CONDS, CLASSES, cmd) == false;
var cl : [22]u8 = CLASSES;
cl[0] = C_REVIEW;
assert rows_filled(GATES, KINDS, TOOLS, CONDS, cl, cmd) == true;
}

test a_repeated_kind_is_caught_wherever_it_sits {
var k : [22]str = KINDS;
k[5] = k[4];
assert kinds_unique_in(k, 22) == false;
assert kinds_unique_in(k, 5) == true;
var e : [22]str = KINDS;
e[21] = e[20];
assert kinds_unique_in(e, 22) == false;
assert kinds_unique_in(e, 21) == true;
}

test an_auto_row_without_a_command_fails_through_row_21 {
assert auto_rows_carry(CLASSES, CMDS) == true;
var cmd : [22]str = CMDS;
cmd[21] = "";
assert auto_rows_carry(CLASSES, cmd) == false;
// Only AUTO rows are held to a command: the same hole on a REVIEW row passes.
var cl : [22]u8 = CLASSES;
cl[21] = C_REVIEW;
assert auto_rows_carry(cl, cmd) == true;
}
Loading