forked from Dicklesworthstone/pi_agent_rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnon-mock-rubric.json
More file actions
417 lines (413 loc) · 15.7 KB
/
non-mock-rubric.json
File metadata and controls
417 lines (413 loc) · 15.7 KB
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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
{
"schema": "pi.qa.non_mock_rubric.v1",
"bead_id": "bd-1f42.2.8",
"created_at": "2026-02-12T20:00:00Z",
"owner": "OrangeHeron",
"description": "Per-module coverage thresholds, mock/fake exception template, and failure-log schema for non-mock unit/integration testing.",
"references": {
"coverage_baseline": "docs/coverage-baseline-map.json",
"testing_policy": "docs/testing-policy.md",
"test_double_inventory": "docs/test_double_inventory.json",
"suite_classification": "tests/suite_classification.toml"
},
"module_thresholds": {
"_doc": "Per-module coverage minimums. 'floor' is the hard CI-gate minimum (fail below). 'target' is the aspirational goal. Branch metrics are available for 63/107 source files via per-file llvm-cov export workaround (51.95% branch coverage). Branch floor enforcement is deferred until full-file coverage is achievable (see coverage-baseline-map.json).",
"global": {
"line_floor_pct": 75.0,
"function_floor_pct": 73.0,
"branch_floor_pct": null,
"line_target_pct": 85.0,
"function_target_pct": 82.0,
"branch_target_pct": null,
"baseline_line_pct": 78.64,
"baseline_function_pct": 77.36,
"notes": "Global floor set ~3-4% below baseline to absorb CI variance. Branch gating remains deferred; fallback branch metrics are emitted as 0.0/0/0 while llvm-cov branch export is unstable."
},
"modules": [
{
"name": "agent_loop",
"paths": ["src/agent.rs"],
"criticality": "critical",
"line_floor_pct": 75.0,
"function_floor_pct": 70.0,
"branch_floor_pct": null,
"line_target_pct": 85.0,
"function_target_pct": 80.0,
"branch_target_pct": null,
"baseline_line_pct": 79.54,
"baseline_function_pct": 74.76,
"rationale": "Agent loop orchestrates all tool/provider interactions. Uncovered abort/retry/interrupt paths are high-risk."
},
{
"name": "tools",
"paths": ["src/tools.rs"],
"criticality": "critical",
"line_floor_pct": 75.0,
"function_floor_pct": 72.0,
"branch_floor_pct": null,
"line_target_pct": 85.0,
"function_target_pct": 82.0,
"branch_target_pct": null,
"baseline_line_pct": 78.96,
"baseline_function_pct": 76.66,
"rationale": "Tool execution surfaces directly to users. File/shell/search reliability regressions cause visible breakage."
},
{
"name": "providers",
"paths": ["src/provider.rs", "src/providers/*.rs", "src/provider_metadata.rs"],
"criticality": "critical",
"line_floor_pct": 82.0,
"function_floor_pct": 79.0,
"branch_floor_pct": null,
"line_target_pct": 90.0,
"function_target_pct": 88.0,
"branch_target_pct": null,
"baseline_line_pct": 86.30,
"baseline_function_pct": 83.31,
"rationale": "Provider layer has the highest baseline and the most active expansion. Thresholds set to prevent regression during rapid onboarding."
},
{
"name": "session",
"paths": ["src/session.rs", "src/session_index.rs", "src/session_picker.rs", "src/session_sqlite.rs"],
"criticality": "high",
"line_floor_pct": 76.0,
"function_floor_pct": 74.0,
"branch_floor_pct": null,
"line_target_pct": 85.0,
"function_target_pct": 82.0,
"branch_target_pct": null,
"baseline_line_pct": 80.50,
"baseline_function_pct": 77.88,
"rationale": "Session persistence reliability is essential for long-running agent sessions. Replay/index drift under interruption is a known risk."
},
{
"name": "extensions",
"paths": ["src/extensions.rs", "src/extension_dispatcher.rs", "src/extensions_js.rs"],
"criticality": "critical",
"line_floor_pct": 80.0,
"function_floor_pct": 69.0,
"branch_floor_pct": null,
"line_target_pct": 88.0,
"function_target_pct": 80.0,
"branch_target_pct": null,
"baseline_line_pct": 85.01,
"baseline_function_pct": 73.53,
"rationale": "Largest uncovered surface (607 uncovered functions). Function floor set below baseline to avoid blocking on sheer volume; line floor is firm."
},
{
"name": "auth",
"paths": ["src/auth.rs"],
"criticality": "high",
"line_floor_pct": 72.0,
"function_floor_pct": 70.0,
"branch_floor_pct": null,
"line_target_pct": 82.0,
"function_target_pct": 78.0,
"branch_target_pct": null,
"baseline_line_pct": null,
"baseline_function_pct": null,
"rationale": "Auth handles credential chains, OAuth, redaction. Security-sensitive; floor set conservatively pending per-file baseline."
},
{
"name": "error",
"paths": ["src/error.rs", "src/error_hints.rs"],
"criticality": "high",
"line_floor_pct": 72.0,
"function_floor_pct": 70.0,
"branch_floor_pct": null,
"line_target_pct": 82.0,
"function_target_pct": 78.0,
"branch_target_pct": null,
"baseline_line_pct": null,
"baseline_function_pct": null,
"rationale": "Error paths and diagnostic hints are user-facing. Incorrect error messages erode trust and complicate debugging."
},
{
"name": "model",
"paths": ["src/model.rs", "src/models.rs", "src/model_selector.rs"],
"criticality": "high",
"line_floor_pct": 74.0,
"function_floor_pct": 72.0,
"branch_floor_pct": null,
"line_target_pct": 84.0,
"function_target_pct": 80.0,
"branch_target_pct": null,
"baseline_line_pct": null,
"baseline_function_pct": null,
"rationale": "Model serialization and registry routing are foundational. Regressions propagate to all providers."
},
{
"name": "config",
"paths": ["src/config.rs"],
"criticality": "medium",
"line_floor_pct": 70.0,
"function_floor_pct": 68.0,
"branch_floor_pct": null,
"line_target_pct": 80.0,
"function_target_pct": 76.0,
"branch_target_pct": null,
"baseline_line_pct": null,
"baseline_function_pct": null,
"rationale": "Config precedence is well-tested by existing suite; medium criticality because errors are typically caught at startup."
},
{
"name": "sse",
"paths": ["src/sse.rs"],
"criticality": "high",
"line_floor_pct": 76.0,
"function_floor_pct": 74.0,
"branch_floor_pct": null,
"line_target_pct": 86.0,
"function_target_pct": 82.0,
"branch_target_pct": null,
"baseline_line_pct": null,
"baseline_function_pct": null,
"rationale": "SSE parser correctness is critical for all streaming providers. Malformed event handling is a known risk area."
},
{
"name": "compaction",
"paths": ["src/compaction.rs"],
"criticality": "medium",
"line_floor_pct": 70.0,
"function_floor_pct": 68.0,
"branch_floor_pct": null,
"line_target_pct": 80.0,
"function_target_pct": 76.0,
"branch_target_pct": null,
"baseline_line_pct": null,
"baseline_function_pct": null,
"rationale": "Compaction has dedicated test suites and bounded scope."
},
{
"name": "vcr",
"paths": ["src/vcr.rs"],
"criticality": "medium",
"line_floor_pct": 68.0,
"function_floor_pct": 66.0,
"branch_floor_pct": null,
"line_target_pct": 78.0,
"function_target_pct": 74.0,
"branch_target_pct": null,
"baseline_line_pct": null,
"baseline_function_pct": null,
"rationale": "VCR is test infrastructure, not production code. Moderate floor is sufficient."
},
{
"name": "rpc",
"paths": ["src/rpc.rs"],
"criticality": "medium",
"line_floor_pct": 70.0,
"function_floor_pct": 68.0,
"branch_floor_pct": null,
"line_target_pct": 80.0,
"function_target_pct": 76.0,
"branch_target_pct": null,
"baseline_line_pct": null,
"baseline_function_pct": null,
"rationale": "RPC protocol handling has dedicated conformance tests."
},
{
"name": "interactive",
"paths": ["src/interactive.rs", "src/tui.rs", "src/keybindings.rs"],
"criticality": "low",
"line_floor_pct": 60.0,
"function_floor_pct": 58.0,
"branch_floor_pct": null,
"line_target_pct": 72.0,
"function_target_pct": 68.0,
"branch_target_pct": null,
"baseline_line_pct": null,
"baseline_function_pct": null,
"rationale": "UI/TUI code is inherently hard to test with deterministic coverage. Relies on E2E scenarios for validation."
}
]
},
"exception_template": {
"_doc": "Mandatory fields for any mock/fake/stub exception. All exceptions must be time-limited and tracked by a bead.",
"required_fields": [
{
"field": "bead_id",
"type": "string",
"description": "Tracking bead that justifies the exception."
},
{
"field": "owner",
"type": "string",
"description": "Single accountable owner (agent or person name)."
},
{
"field": "expires_at",
"type": "string",
"format": "date",
"description": "Hard expiration date (UTC, YYYY-MM-DD). Maximum 90 days from creation."
},
{
"field": "replacement_plan",
"type": "string",
"description": "Concrete path to remove the double (e.g., 'Replace with VCR cassette in bd-XXXX')."
},
{
"field": "scope",
"type": "array",
"items": "string",
"description": "Exact files/tests where the exception is permitted."
},
{
"field": "double_identifier",
"type": "string",
"description": "The mock/fake/stub type name being excepted."
},
{
"field": "double_type",
"type": "string",
"enum": ["mock", "fake", "stub", "spy", "recording"],
"description": "Category of the test double."
},
{
"field": "rationale",
"type": "string",
"description": "Why the double is necessary and why alternatives were rejected."
},
{
"field": "verification",
"type": "string",
"description": "CI/tests proving behavior remains covered despite the temporary double."
}
],
"validation_rules": [
"expires_at must be within 90 days of creation.",
"replacement_plan must reference a concrete bead or action.",
"scope must be non-empty and list specific file paths.",
"All fields are required; CI rejects entries missing any field."
]
},
"failure_log_schema": {
"_doc": "Mandatory schema for unit/integration test failure diagnostics. Every test failure must emit structured data following this schema.",
"schema_id": "pi.test.failure_log.v1",
"fields": [
{
"field": "correlation_id",
"type": "string",
"format": "uuid",
"required": true,
"description": "Unique ID for this test invocation. Format: <test_name>-<timestamp_ms>-<random_4hex>."
},
{
"field": "test_name",
"type": "string",
"required": true,
"description": "Fully qualified test name (module::test_fn)."
},
{
"field": "suite",
"type": "string",
"enum": ["unit", "vcr", "e2e"],
"required": true,
"description": "Suite classification from suite_classification.toml."
},
{
"field": "timestamp",
"type": "string",
"format": "iso8601",
"required": true,
"description": "UTC timestamp of the failure."
},
{
"field": "fixture",
"type": "object",
"required": false,
"description": "Fixture/cassette metadata if applicable.",
"properties": {
"path": "Path to fixture file or VCR cassette.",
"version": "Fixture schema version.",
"hash": "SHA-256 of the fixture content."
}
},
{
"field": "seed",
"type": "integer",
"required": false,
"description": "Random seed if the test uses deterministic randomness."
},
{
"field": "env",
"type": "object",
"required": true,
"description": "Relevant environment variables (redacted). Keys are variable names, values are redacted or sanitized.",
"redaction_rules": [
"Values matching *_KEY, *_SECRET, *_TOKEN, *_PASSWORD are replaced with [REDACTED].",
"Values matching *_API_KEY are replaced with [REDACTED].",
"Only test-relevant env vars are included (VCR_MODE, RUST_LOG, PI_E2E, CARGO_TARGET_DIR)."
]
},
{
"field": "expected",
"type": "any",
"required": true,
"description": "Expected value or condition."
},
{
"field": "actual",
"type": "any",
"required": true,
"description": "Actual value or condition observed."
},
{
"field": "diff",
"type": "string",
"required": false,
"description": "Human-readable diff between expected and actual when applicable."
},
{
"field": "error_message",
"type": "string",
"required": true,
"description": "The assertion or panic message."
},
{
"field": "backtrace",
"type": "string",
"required": false,
"description": "Filtered backtrace (test-relevant frames only)."
},
{
"field": "duration_ms",
"type": "number",
"required": true,
"description": "Test execution duration in milliseconds."
},
{
"field": "runner",
"type": "object",
"required": true,
"description": "Runner environment metadata.",
"properties": {
"os": "Operating system (uname -s).",
"arch": "CPU architecture.",
"rust_version": "rustc --version output.",
"ci": "Boolean; true if running in CI."
}
}
],
"output_format": "JSONL (one line per failure event)",
"output_path": "target/test-failures.jsonl",
"redaction_policy": "All env values matching secret patterns are force-redacted before write. No raw API keys, tokens, or passwords may appear in failure logs."
},
"ci_enforcement": {
"coverage_gate": {
"command": "cargo llvm-cov --workspace --lib --json --summary-only --output-path target/coverage-summary.json --ignore-run-fail",
"evaluation": "Compare target/coverage-summary.json per-file metrics against module_thresholds.modules[].line_floor_pct and function_floor_pct.",
"failure_mode": "CI job fails if any module's line or function coverage drops below its floor.",
"notes": "Branch metrics now available for 63/107 files (51.95%) via per-file llvm-cov export workaround. Branch gate deferred until full-file coverage is achievable. See docs/coverage-baseline-map.json for deterministic command path."
},
"exception_audit": {
"source": "docs/testing-policy.md (Allowlisted Exceptions table)",
"validation": "CI validates each exception has all required_fields from exception_template and that expires_at has not passed.",
"failure_mode": "CI job fails on expired or incomplete exceptions."
},
"failure_log_compliance": {
"validation": "CI validates that target/test-failures.jsonl entries conform to failure_log_schema.",
"failure_mode": "Warning only (non-blocking) until schema adoption reaches 80% of test files."
}
}
}