1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
// `apr-tool-*` family algorithm-level PARTIAL discharge for the 5
// falsification conditions shared by every `apr-tool-*-v1.yaml` contract.
//
// Contracts: `contracts/apr-tool-*.yaml` (21 contracts × 5 conditions =
// 105 falsifier instantiations).
//
// All apr-tool-* contracts (bashrs, ccpo, cohete, copia, decy, depyler,
// etc.) share an identical falsification schema. Each declares 5
// conditions describing a "healthy active-tool repo":
//
// 1. "gh repo view paiml/<tool> returns archived=true" (P0 — reclassify)
// 2. "README.md missing or empty" (P0 — create_readme)
// 3. "No CI workflow in .github/workflows/" (P1 — add_ci)
// 4. "cargo build fails (Rust) or equivalent build fails" (P0 — fix_build)
// 5. "Zero tests in repository" (P1 — add_tests)
//
// One verdict module satisfies the algorithm-level pin for all 21
// apr-tool contracts. Live discharge is `gh repo view` + filesystem
// inspection + per-language build. This module pins the predicates so
// future tool consolidations cannot drift on the shape of any of the 5
// invariants.
//
// Local IDs FALSIFY-APRTOOL-001..005 are synthesized to give each
// unkeyed YAML entry a stable handle.
/// Minimum CI-workflow files in `.github/workflows/`.
pub const AC_APRTOOL_MIN_CI_WORKFLOWS: u32 = 1;
/// Minimum test count per FALSIFY-APRTOOL-005.
pub const AC_APRTOOL_MIN_TESTS: u32 = 1;
// =============================================================================
// FALSIFY-APRTOOL-001 — repo is NOT archived
// =============================================================================
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum NotArchivedVerdict {
/// Repo is live (archived == false).
Pass,
/// Repo is archived but still classified as active-tool (P0 reclassify).
Fail,
}
#[must_use]
pub fn verdict_from_not_archived(archived: bool) -> NotArchivedVerdict {
if archived {
NotArchivedVerdict::Fail
} else {
NotArchivedVerdict::Pass
}
}
// =============================================================================
// FALSIFY-APRTOOL-002 — README.md present and non-empty
// =============================================================================
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ReadmeVerdict {
/// README.md exists AND has content.
Pass,
/// Missing OR empty (P0 create_readme).
Fail,
}
#[must_use]
pub fn verdict_from_readme(readme_exists: bool, readme_size_bytes: u64) -> ReadmeVerdict {
if !readme_exists {
return ReadmeVerdict::Fail;
}
if readme_size_bytes == 0 {
return ReadmeVerdict::Fail;
}
ReadmeVerdict::Pass
}
// =============================================================================
// FALSIFY-APRTOOL-003 — at least 1 CI workflow file
// =============================================================================
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CiWorkflowVerdict {
/// .github/workflows/ contains ≥ 1 .yml/.yaml workflow.
Pass,
/// Empty or missing (P1 add_ci).
Fail,
}
#[must_use]
pub fn verdict_from_ci_workflow(workflow_count: u32) -> CiWorkflowVerdict {
if workflow_count >= AC_APRTOOL_MIN_CI_WORKFLOWS {
CiWorkflowVerdict::Pass
} else {
CiWorkflowVerdict::Fail
}
}
// =============================================================================
// FALSIFY-APRTOOL-004 — build passes
// =============================================================================
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum BuildPassesVerdict {
/// `cargo build` (or per-language equivalent) exits 0.
Pass,
/// Build failed (P0 fix_build).
Fail,
}
#[must_use]
pub fn verdict_from_build_passes(build_exit_code: i32) -> BuildPassesVerdict {
if build_exit_code == 0 {
BuildPassesVerdict::Pass
} else {
BuildPassesVerdict::Fail
}
}
// =============================================================================
// FALSIFY-APRTOOL-005 — at least 1 test
// =============================================================================
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum HasTestsVerdict {
/// Repository has ≥ 1 test (anywhere — `tests/`, `src/**/*::tests`, etc.).
Pass,
/// Zero tests (P1 add_tests).
Fail,
}
#[must_use]
pub fn verdict_from_has_tests(test_count: u32) -> HasTestsVerdict {
if test_count >= AC_APRTOOL_MIN_TESTS {
HasTestsVerdict::Pass
} else {
HasTestsVerdict::Fail
}
}
#[cfg(test)]
mod tests {
use super::*;
// -------------------------------------------------------------------------
// Section 1: Provenance pins.
// -------------------------------------------------------------------------
#[test]
fn provenance_min_ci_workflows_is_1() {
assert_eq!(AC_APRTOOL_MIN_CI_WORKFLOWS, 1);
}
#[test]
fn provenance_min_tests_is_1() {
assert_eq!(AC_APRTOOL_MIN_TESTS, 1);
}
// -------------------------------------------------------------------------
// Section 2: APRTOOL-001 not archived.
// -------------------------------------------------------------------------
#[test]
fn at001_pass_repo_live() {
assert_eq!(verdict_from_not_archived(false), NotArchivedVerdict::Pass);
}
#[test]
fn at001_fail_repo_archived() {
assert_eq!(verdict_from_not_archived(true), NotArchivedVerdict::Fail);
}
// -------------------------------------------------------------------------
// Section 3: APRTOOL-002 README.
// -------------------------------------------------------------------------
#[test]
fn at002_pass_readme_present() {
assert_eq!(verdict_from_readme(true, 1024), ReadmeVerdict::Pass);
}
#[test]
fn at002_pass_readme_minimal() {
// 1 byte still counts.
assert_eq!(verdict_from_readme(true, 1), ReadmeVerdict::Pass);
}
#[test]
fn at002_fail_no_readme() {
assert_eq!(verdict_from_readme(false, 0), ReadmeVerdict::Fail);
}
#[test]
fn at002_fail_empty_readme() {
assert_eq!(verdict_from_readme(true, 0), ReadmeVerdict::Fail);
}
// -------------------------------------------------------------------------
// Section 4: APRTOOL-003 CI workflow.
// -------------------------------------------------------------------------
#[test]
fn at003_pass_one_workflow() {
assert_eq!(verdict_from_ci_workflow(1), CiWorkflowVerdict::Pass);
}
#[test]
fn at003_pass_many_workflows() {
assert_eq!(verdict_from_ci_workflow(10), CiWorkflowVerdict::Pass);
}
#[test]
fn at003_fail_zero_workflows() {
assert_eq!(verdict_from_ci_workflow(0), CiWorkflowVerdict::Fail);
}
// -------------------------------------------------------------------------
// Section 5: APRTOOL-004 build passes.
// -------------------------------------------------------------------------
#[test]
fn at004_pass_build_clean() {
assert_eq!(verdict_from_build_passes(0), BuildPassesVerdict::Pass);
}
#[test]
fn at004_fail_build_compile_error() {
assert_eq!(verdict_from_build_passes(1), BuildPassesVerdict::Fail);
}
#[test]
fn at004_fail_build_panic() {
assert_eq!(verdict_from_build_passes(101), BuildPassesVerdict::Fail);
}
// -------------------------------------------------------------------------
// Section 6: APRTOOL-005 has tests.
// -------------------------------------------------------------------------
#[test]
fn at005_pass_one_test() {
assert_eq!(verdict_from_has_tests(1), HasTestsVerdict::Pass);
}
#[test]
fn at005_pass_many_tests() {
assert_eq!(verdict_from_has_tests(500), HasTestsVerdict::Pass);
}
#[test]
fn at005_fail_zero_tests() {
assert_eq!(verdict_from_has_tests(0), HasTestsVerdict::Fail);
}
// -------------------------------------------------------------------------
// Section 7: Realistic — full healthy active-tool repo passes all 5.
// -------------------------------------------------------------------------
#[test]
fn realistic_healthy_tool_passes_all_5() {
// bashrs / cohete / copia state: live, has README, CI present, builds
// clean, has tests.
assert_eq!(verdict_from_not_archived(false), NotArchivedVerdict::Pass);
assert_eq!(verdict_from_readme(true, 4096), ReadmeVerdict::Pass);
assert_eq!(verdict_from_ci_workflow(3), CiWorkflowVerdict::Pass);
assert_eq!(verdict_from_build_passes(0), BuildPassesVerdict::Pass);
assert_eq!(verdict_from_has_tests(125), HasTestsVerdict::Pass);
}
#[test]
fn realistic_pre_fix_all_5_failures() {
// Each gate's regression class.
assert_eq!(verdict_from_not_archived(true), NotArchivedVerdict::Fail);
assert_eq!(verdict_from_readme(false, 0), ReadmeVerdict::Fail);
assert_eq!(verdict_from_ci_workflow(0), CiWorkflowVerdict::Fail);
assert_eq!(verdict_from_build_passes(1), BuildPassesVerdict::Fail);
assert_eq!(verdict_from_has_tests(0), HasTestsVerdict::Fail);
}
// -------------------------------------------------------------------------
// Section 8: Family coverage — all 21 apr-tool-* contracts.
// -------------------------------------------------------------------------
#[test]
fn family_coverage_uniform_schema() {
// The 21 apr-tool-* contracts share this falsification schema.
// Verdicts work regardless of the tool's identity or implementation language.
let tools = [
"bashrs", "ccpo", "cohete", "copia", "decy", "depyler",
"forjar", "fueguia", "ggsa", "kit", "labrador", "letrar",
"linguamatic", "lupa", "manodura", "molino", "pmat",
"ramificar", "ruchy", "sembrar", "tomb",
];
assert_eq!(tools.len(), 21);
for t in tools {
assert_eq!(
verdict_from_not_archived(false),
NotArchivedVerdict::Pass,
"tool {t} live"
);
}
}
}