forked from Dicklesworthstone/pi_agent_rust
-
Notifications
You must be signed in to change notification settings - Fork 0
2167 lines (1982 loc) · 87.4 KB
/
ci.yml
File metadata and controls
2167 lines (1982 loc) · 87.4 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
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
name: ci
on:
pull_request:
push:
branches: [main]
jobs:
rust:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
env:
CI: "true"
VCR_MODE: "playback"
VCR_CASSETTE_DIR: "tests/fixtures/vcr"
RUST_BACKTRACE: "1"
CARGO_INCREMENTAL: "0"
CARGO_PROFILE_DEV_DEBUG: "line-tables-only"
CI_GATE_PROMOTION_MODE: ${{ vars.CI_GATE_PROMOTION_MODE || 'strict' }}
CI_GATE_THRESHOLD_VERSION: ${{ vars.CI_GATE_THRESHOLD_VERSION || '2026-02-08.v1' }}
CI_GATE_MIN_PASS_RATE_PCT: ${{ vars.CI_GATE_MIN_PASS_RATE_PCT || '80.0' }}
CI_GATE_MAX_FAIL_COUNT: ${{ vars.CI_GATE_MAX_FAIL_COUNT || '36' }}
CI_GATE_MAX_NA_COUNT: ${{ vars.CI_GATE_MAX_NA_COUNT || '170' }}
defaults:
run:
working-directory: pi_agent_rust
shell: bash
steps:
- name: Free disk space [linux]
if: runner.os == 'Linux'
working-directory: /
run: |
set -euxo pipefail
df -h /
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc \
/opt/hostedtoolcache/CodeQL /opt/hostedtoolcache/go \
/opt/hostedtoolcache/Python /opt/hostedtoolcache/Ruby \
/opt/hostedtoolcache/Java_Temurin-Hotspot_jdk \
/usr/local/share/powershell /usr/share/swift \
/usr/local/graalvm /usr/local/.ghcup /usr/local/julia*
sudo docker image prune --all --force || true
sudo apt-get clean || true
df -h /
- name: Checkout pi_agent_rust
uses: actions/checkout@v4
with:
path: pi_agent_rust
fetch-depth: 0
- name: PR Definition-of-Done evidence guard [linux]
if: runner.os == 'Linux' && github.event_name == 'pull_request'
env:
PR_BODY: ${{ github.event.pull_request.body || '' }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
set -euxo pipefail
python3 - <<'PY'
import os
import re
import subprocess
import sys
base_sha = os.environ.get("BASE_SHA", "").strip()
head_sha = os.environ.get("HEAD_SHA", "").strip()
pr_body = os.environ.get("PR_BODY", "").replace("\r\n", "\n")
if not base_sha or not head_sha:
print("missing pull_request base/head SHA", file=sys.stderr)
sys.exit(1)
diff_proc = subprocess.run(
["git", "diff", "--name-only", f"{base_sha}...{head_sha}"],
check=True,
capture_output=True,
text=True,
)
changed_files = [line.strip() for line in diff_proc.stdout.splitlines() if line.strip()]
if not changed_files:
print("No changed files in PR diff; skipping DoD evidence guard.")
sys.exit(0)
feature_path_pattern = re.compile(
r"^(src/|Cargo\.toml$|Cargo\.lock$|scripts/e2e/|scripts/release_gate\.sh$|scripts/check_conformance_regression\.py$|scripts/check_traceability_matrix\.py$)"
)
feature_files = [path for path in changed_files if feature_path_pattern.search(path)]
if not feature_files:
print("No feature-surface changes detected; skipping DoD evidence guard.")
sys.exit(0)
required_patterns = {
"Definition-of-Done header": r"(?mi)^##\s+Definition of Done Evidence\s*$",
"Unit evidence checkbox": r"(?mi)^\s*-\s*\[[xX]\]\s+Unit evidence linked\s*$",
"E2E evidence checkbox": r"(?mi)^\s*-\s*\[[xX]\]\s+E2E evidence linked\s*$",
"Extension evidence checkbox": r"(?mi)^\s*-\s*\[[xX]\]\s+Extension evidence linked\s*$",
"Failing-path diagnostics checkbox": r"(?mi)^\s*-\s*\[[xX]\]\s+Failing paths include artifact links and repro commands\s*$",
"Reproduction Commands header": r"(?mi)^##\s+Reproduction Commands\s*$",
}
missing = [label for label, pattern in required_patterns.items() if not re.search(pattern, pr_body)]
evidence_links = re.findall(r"\[[^\]]+\]\((https?://[^)]+)\)", pr_body)
if len(evidence_links) < 3:
missing.append("At least three HTTP(S) evidence links")
command_patterns = {
"Unit reproduction command": r"(?mi)`?cargo test --all-targets`?",
"E2E reproduction command": r"(?mi)`?\./scripts/e2e/run_all\.sh --profile ci`?",
"Extension reproduction command": r"(?mi)`?cargo test (?:--all-targets )?--features ext-conformance`?",
}
for label, pattern in command_patterns.items():
if not re.search(pattern, pr_body):
missing.append(label)
forbidden_placeholders = (
"<link>",
"<artifact link>",
"<paste command>",
"<command>",
)
if any(token in pr_body for token in forbidden_placeholders):
missing.append("Template placeholders removed")
if missing:
print("Definition-of-Done evidence guard failed for feature-surface changes.", file=sys.stderr)
print("Changed feature files:", file=sys.stderr)
for path in feature_files:
print(f" - {path}", file=sys.stderr)
print("Missing PR body requirements:", file=sys.stderr)
for item in missing:
print(f" - {item}", file=sys.stderr)
print(
"Complete .github/pull_request_template.md with evidence links and repro commands before merging.",
file=sys.stderr,
)
sys.exit(1)
print("Definition-of-Done evidence guard passed.")
PY
- name: Install system deps (fd, rg, xcb) [linux]
if: runner.os == 'Linux'
run: |
set -euxo pipefail
sudo apt-get update
sudo apt-get install -y fd-find ripgrep libxcb1-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev
sudo ln -sf "$(command -v fdfind)" /usr/local/bin/fd
- name: Install system deps (fd, rg) [macos]
if: runner.os == 'macOS'
run: |
set -euxo pipefail
brew install fd ripgrep
- name: Install system deps (fd, rg) [windows]
if: runner.os == 'Windows'
shell: pwsh
run: |
choco install -y fd ripgrep
- name: Install Rust toolchain (nightly)
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt, clippy, llvm-tools-preview
- name: Install cargo-llvm-cov
if: runner.os == 'Linux'
uses: taiki-e/install-action@v2
with:
tool: cargo-llvm-cov
- name: No-mock dependency guard
run: |
set -euxo pipefail
if rg -n --fixed-strings -e mockall -e mockito -e wiremock Cargo.toml Cargo.lock; then
echo "Mocking crates are forbidden in dependencies."
exit 1
fi
- name: Cargo bin manifest parity
run: |
set -euxo pipefail
bash scripts/check_cargo_bin_parity.sh
- name: Docs purpose/header lint
run: |
set -euxo pipefail
if command -v python3 >/dev/null 2>&1; then
python3 scripts/check_docs_purpose_headers.py
elif command -v python >/dev/null 2>&1; then
python scripts/check_docs_purpose_headers.py
else
echo "python interpreter not found"
exit 1
fi
- name: Completion audit closeout gate self-test
run: |
set -euxo pipefail
python3 scripts/check_completion_audit_gate.py --self-test --generated-at 2026-01-02T03:04:05+00:00
- name: No-mock code guard
run: |
set -euxo pipefail
# Allowlisted exceptions (audited):
# - MockHttp{Server,Request,Response}: deterministic local TCP server test infra.
# - MockSpec{,Interceptor}: VCR cassette spec validation + conformance interceptor.
# - Mocked: comment heading in node_http_shim.rs.
# - Stubs: string literal in repair event diagnostics (not a mock type).
allow_re='^(MockHttp(Server|Request|Response)|MockSpec(Interceptor)?|Mocked|Stubs)$'
matches="$(rg -n --column --no-heading --color never --glob '!tests/ext_conformance/artifacts/**' -o '\b(Mock|Fake|Stub)[A-Za-z0-9_]+\b' tests || true)"
if [ -z "$matches" ]; then
exit 0
fi
violations="$(echo "$matches" | awk -F: -v allow_re="$allow_re" '$4 !~ allow_re { print }')"
if [ -n "$violations" ]; then
echo "$violations"
echo
echo "No-mock policy violation: Mock*/Fake*/Stub* identifiers are forbidden in tests."
echo "Use VCR fixtures or real deps instead. See docs/TEST_COVERAGE_MATRIX.md."
exit 1
fi
- name: Traceability matrix guard
run: |
set -euxo pipefail
if command -v python3 >/dev/null 2>&1; then
python3 scripts/check_traceability_matrix.py
elif command -v python >/dev/null 2>&1; then
python scripts/check_traceability_matrix.py
else
echo "python interpreter not found"
exit 1
fi
- name: Evidence freshness claim integrity
run: |
set -euxo pipefail
if command -v python3 >/dev/null 2>&1; then
python3 scripts/check_readme_evidence_freshness.py
elif command -v python >/dev/null 2>&1; then
python scripts/check_readme_evidence_freshness.py
else
echo "python interpreter not found"
exit 1
fi
- name: Closeout and runpack freshness integrity
run: |
set -euo pipefail
if command -v python3 >/dev/null 2>&1; then
PYTHON=python3
elif command -v python >/dev/null 2>&1; then
PYTHON=python
else
echo "python interpreter not found"
exit 1
fi
closeout_report="$(mktemp)"
if ! "$PYTHON" scripts/check_closeout_gate_freshness.py --compact > "$closeout_report"; then
echo "Closeout freshness audit failed:"
"$PYTHON" -m json.tool "$closeout_report" || cat "$closeout_report"
exit 1
fi
"$PYTHON" -m json.tool "$closeout_report" >/dev/null
# Keep --run-runpack-smoke out of PR CI: it exercises the broader
# runpack builder. The self-test is the bounded freshness-guard
# contract proof; live closeout artifacts are audited above.
"$PYTHON" scripts/check_swarm_runpack_freshness.py --self-test
- name: Built-in tool count claim guard
run: |
set -euo pipefail
files="$(git ls-files README.md AGENTS.md 'docs/*.md' 'tests/*.rs')"
stale_claims="$(printf '%s\n' "$files" | xargs rg -n --color never \
-e '7 built-in' \
-e '7 Built-in' \
-e 'seven built-in' \
-e 'Seven built-ins' \
-e 'all 7 built-in' \
-e 'all 7 tools' \
-e 'exercise all 7 tools' || true)"
if [ -n "$stale_claims" ]; then
echo "$stale_claims"
echo "Built-in tool count drift: Pi exposes 8 built-ins including hashline_edit."
exit 1
fi
rg -n --fixed-strings '### 8 Built-in Tools' README.md >/dev/null
rg -n --fixed-strings '`hashline_edit`' README.md AGENTS.md >/dev/null
- name: Provider count claim guard
run: |
set -euo pipefail
files="$(git ls-files README.md AGENTS.md 'docs/*.md' 'tests/*.rs')"
native_claims="$(printf '%s\n' "$files" | xargs rg -n --color never \
-e '\b[0-9]+[[:space:]]+native providers?\b' \
-e '\b[0-9]+[[:space:]]+native provider implementation modules?\b' || true)"
stale_claims="$(printf '%s\n' "$native_claims" | rg -v \
-e '\b10[[:space:]]+native providers?\b' \
-e '\b10[[:space:]]+native provider implementation modules?\b' \
-e 'Expected 10 native providers' || true)"
if [ -n "$stale_claims" ]; then
echo "$stale_claims"
echo "Native provider count drift: use 10 native provider implementation modules, counted as src/providers/*.rs excluding mod.rs."
exit 1
fi
rg -n --fixed-strings '10 native provider implementation modules' README.md AGENTS.md docs/providers.md >/dev/null
- name: SQLite sessions feature claim guard
run: |
set -euo pipefail
files="$(git ls-files README.md AGENTS.md 'docs/*.md' 'tests/*.rs')"
stale_claims="$(printf '%s\n' "$files" | xargs rg -n --color never -i \
-e 'optional[[:space:]]+sqlite[[:space:]]+session' \
-e 'sqlite-sessions.*optional' \
-e 'optional.*sqlite-sessions' \
-e 'sqlite-sessions.*behind[[:space:]]+(a[[:space:]]+)?feature[[:space:]]+flag' \
-e 'behind[[:space:]]+(a[[:space:]]+)?feature[[:space:]]+flag.*sqlite-sessions' || true)"
if [ -n "$stale_claims" ]; then
echo "$stale_claims"
echo "sqlite-sessions claim drift: Cargo.toml enables sqlite-sessions by default; document opt-out with --no-default-features instead."
exit 1
fi
rg -n --fixed-strings 'default = ["image-resize", "jemalloc", "clipboard", "wasm-host", "sqlite-sessions"]' Cargo.toml >/dev/null
rg -n --fixed-strings 'Default builds enable `image-resize`, `jemalloc`, `clipboard`, `wasm-host`, and `sqlite-sessions`.' README.md >/dev/null
- name: Suite classification guard
run: |
set -euo pipefail
# Every tests/*.rs file must appear in tests/suite_classification.toml.
# Subdirectories (common/, provider_streaming/, conformance/, ext_conformance/) are excluded.
classification="tests/suite_classification.toml"
if [ ! -f "$classification" ]; then
echo "Missing $classification — see docs/testing-policy.md"
exit 1
fi
missing=0
for f in tests/*.rs; do
stem="$(basename "$f" .rs)"
if ! rg -q --fixed-strings "\"$stem\"" "$classification"; then
echo "UNCLASSIFIED: $f is not listed in $classification"
missing=$((missing + 1))
fi
done
if [ "$missing" -gt 0 ]; then
echo
echo "Suite classification violation: $missing test file(s) missing from $classification."
echo "Add each file to [suite.unit], [suite.vcr], or [suite.e2e]. See docs/testing-policy.md."
exit 1
fi
echo "All test files classified."
- name: VCR leak guard (unit suite)
run: |
set -euo pipefail
classification="tests/suite_classification.toml"
# Extract unit suite file names.
unit_files="$(sed -n '/\[suite\.unit\]/,/\[suite\./{ /^files/,/\]/p }' "$classification" \
| rg -o '"([^"]+)"' -r '$1' || true)"
if [ -z "$unit_files" ]; then
echo "No unit suite files found; skipping VCR leak check."
exit 0
fi
violations=0
for stem in $unit_files; do
f="tests/${stem}.rs"
[ -f "$f" ] || continue
if rg -q 'VcrRecorder|VcrMode|cassette_root|cassette_dir|fixtures/vcr' "$f"; then
echo "VCR LEAK: $f is in suite.unit but references VCR infrastructure."
violations=$((violations + 1))
fi
done
if [ "$violations" -gt 0 ]; then
echo
echo "VCR leak violation: $violations unit-suite file(s) reference VCR."
echo "Move to [suite.vcr] or remove VCR usage. See docs/testing-policy.md."
exit 1
fi
echo "No VCR leaks in unit suite."
- name: Quarantine expiry guard
run: |
set -euo pipefail
classification="tests/suite_classification.toml"
python3 - "$classification" <<'PY'
import json
import pathlib
import re
import sys
from datetime import date, datetime, timezone
toml_path = sys.argv[1]
with open(toml_path, encoding="utf-8") as fh:
content = fh.read()
# Simple TOML parser: find [quarantine.<name>] sections and extract key=value pairs.
section_re = re.compile(r"^\[quarantine\.(\w+)\]\s*$", re.MULTILINE)
kv_re = re.compile(r'^(\w+)\s*=\s*"([^"]*)"', re.MULTILINE)
entries = {}
for match in section_re.finditer(content):
name = match.group(1)
start = match.end()
# Find next section or end of file.
next_section = re.search(r"^\[", content[start:], re.MULTILINE)
end = start + next_section.start() if next_section else len(content)
block = content[start:end]
fields = {m.group(1): m.group(2) for m in kv_re.finditer(block)}
entries[name] = fields
allowed_categories = {
"FLAKE-TIMING",
"FLAKE-ENV",
"FLAKE-NET",
"FLAKE-RES",
"FLAKE-EXT",
"FLAKE-LOGIC",
}
max_quarantine_days = 14
retry_policy = {
"max_auto_retries": 1,
"retry_delay_seconds": 5,
"retry_scope": "failed-target-only",
"second_failure_policy": "deterministic-failure",
}
today = date.today()
report = {
"schema": "pi.test.quarantine_report.v2",
"generated_at": datetime.now(timezone.utc).isoformat(),
"policy_version": "2026-02-10",
"today": today.isoformat(),
"max_quarantine_days": max_quarantine_days,
"retry_policy": retry_policy,
"active_count": 0,
"expiring_soon_count": 0,
"expired_count": 0,
"category_counts": {},
"entries": [],
"escalations": [],
}
required_fields = {
"category",
"owner",
"quarantined",
"expires",
"bead",
"evidence",
"repro",
"reason",
"remove_when",
}
errors = []
for name, fields in sorted(entries.items()):
missing = required_fields - set(fields.keys())
if missing:
errors.append(f"quarantine.{name}: missing required fields: {sorted(missing)}")
continue
category = fields.get("category", "").strip()
if category not in allowed_categories:
errors.append(
f"quarantine.{name}: invalid category {category!r}; expected one of {sorted(allowed_categories)}"
)
continue
try:
quarantined_date = date.fromisoformat(fields["quarantined"])
except ValueError:
errors.append(
f"quarantine.{name}: invalid quarantined date: {fields['quarantined']}"
)
continue
try:
expires_date = date.fromisoformat(fields["expires"])
except ValueError:
errors.append(f"quarantine.{name}: invalid expires date: {fields['expires']}")
continue
quarantine_span_days = (expires_date - quarantined_date).days
if quarantine_span_days < 0:
errors.append(
f"quarantine.{name}: expires precedes quarantined ({fields['quarantined']} -> {fields['expires']})"
)
continue
if quarantine_span_days > max_quarantine_days:
errors.append(
f"quarantine.{name}: quarantine window {quarantine_span_days}d exceeds max {max_quarantine_days}d"
)
continue
if not fields.get("evidence", "").strip():
errors.append(f"quarantine.{name}: evidence must reference CI run URL or artifact path")
continue
if not fields.get("repro", "").strip():
errors.append(f"quarantine.{name}: repro must include exact reproduction command")
continue
if not fields.get("remove_when", "").strip():
errors.append(f"quarantine.{name}: remove_when must define exit criteria")
continue
days_remaining = (expires_date - today).days
if days_remaining < 0:
status = "expired"
report["expired_count"] += 1
report["escalations"].append(
{
"name": name,
"severity": "critical",
"action": "Fix now or remove quarantine entry before merge",
"owner": fields.get("owner", ""),
"bead": fields.get("bead", ""),
}
)
elif days_remaining <= 2:
status = "expiring-soon"
report["expiring_soon_count"] += 1
report["active_count"] += 1
report["escalations"].append(
{
"name": name,
"severity": "warning",
"action": "Prepare fix/extension with updated evidence before expiry",
"owner": fields.get("owner", ""),
"bead": fields.get("bead", ""),
}
)
else:
status = "active"
report["active_count"] += 1
report["category_counts"][category] = report["category_counts"].get(category, 0) + 1
report["entries"].append({
"name": name,
"category": category,
"owner": fields.get("owner", ""),
"quarantined": fields.get("quarantined", ""),
"expires": fields.get("expires", ""),
"bead": fields.get("bead", ""),
"evidence": fields.get("evidence", ""),
"repro": fields.get("repro", ""),
"reason": fields.get("reason", ""),
"remove_when": fields.get("remove_when", ""),
"status": status,
"quarantine_span_days": quarantine_span_days,
"days_remaining": days_remaining,
})
report_path = pathlib.Path("tests/quarantine_report.json")
report_path.write_text(
json.dumps(report, indent=2) + "\n", encoding="utf-8"
)
audit_path = pathlib.Path("tests/quarantine_audit.jsonl")
audit_lines = []
for entry in report["entries"]:
audit_lines.append(
json.dumps(
{
"schema": "pi.test.quarantine_audit_entry.v1",
"generated_at": report["generated_at"],
"name": entry["name"],
"category": entry["category"],
"owner": entry["owner"],
"bead": entry["bead"],
"status": entry["status"],
"expires": entry["expires"],
"days_remaining": entry["days_remaining"],
"evidence": entry["evidence"],
"repro": entry["repro"],
"remove_when": entry["remove_when"],
},
sort_keys=True,
)
)
audit_path.write_text(("\n".join(audit_lines) + "\n") if audit_lines else "", encoding="utf-8")
print(
"Quarantine report:"
f" {report['active_count']} active,"
f" {report['expiring_soon_count']} expiring-soon,"
f" {report['expired_count']} expired."
)
print(f" report: {report_path}")
print(f" audit: {audit_path}")
if errors:
for err in errors:
print(f"ERROR: {err}", file=sys.stderr)
sys.exit(1)
if report["expired_count"] > 0:
print("Expired quarantine entries (must fix or extend):", file=sys.stderr)
for entry in report["entries"]:
if entry["status"] == "expired":
print(f" - {entry['name']} (expired {-entry['days_remaining']} days ago, owner: {entry['owner']}, bead: {entry['bead']})", file=sys.stderr)
sys.exit(1)
if report["expiring_soon_count"] > 0:
print("Expiring-soon quarantine entries (review and refresh evidence/remove_when):")
for entry in report["entries"]:
if entry["status"] == "expiring-soon":
print(
f" - {entry['name']} (expires in {entry['days_remaining']} day(s), owner: {entry['owner']}, bead: {entry['bead']})"
)
print("All quarantine entries are within policy bounds.")
PY
- name: Parity suite gate
run: |
set -euo pipefail
python3 - <<'PY'
import json
import sys
from pathlib import Path
# Validate that all parity test suites are classified and will run in CI.
classification = Path("tests/suite_classification.toml")
content = classification.read_text(encoding="utf-8")
parity_suites = [
"json_mode_parity",
"cross_surface_parity",
"config_precedence",
"vcr_parity_validation",
"e2e_cross_provider_parity",
]
missing = []
for suite in parity_suites:
if f'"{suite}"' not in content:
missing.append(suite)
if missing:
print(f"PARITY GATE FAIL: {len(missing)} parity suite(s) not classified:", file=sys.stderr)
for name in missing:
print(f" - {name}", file=sys.stderr)
sys.exit(1)
# Validate parity evidence artifacts exist (if available from prior runs).
evidence_path = Path("tests/ext_conformance/reports/conformance_summary.json")
if evidence_path.exists():
summary = json.loads(evidence_path.read_text(encoding="utf-8"))
evidence = summary.get("evidence", {})
required = {"parity_logs", "smoke_logs"}
present = set(evidence.keys()) if isinstance(evidence, dict) else set()
missing_keys = required - present
if missing_keys:
print(f"WARNING: conformance_summary.json missing evidence keys: {sorted(missing_keys)}")
else:
print(f"Parity evidence keys present: {sorted(present & required)}")
print(f"Parity suite gate: all {len(parity_suites)} suites classified.")
PY
- name: Beads ledger reconciliation check [linux]
if: runner.os == 'Linux'
run: |
set -euo pipefail
# Verify that active critical/high parity gaps have exact active bead coverage,
# and that active gap-tracking beads do not outlive active ledger entries.
if ! ./scripts/reconcile_beads_ledger.sh; then
echo "RECONCILIATION FAILED: Found orphan ledger gaps or stale gap-tracking beads" >&2
echo "Run './scripts/reconcile_beads_ledger.sh' locally to see details" >&2
exit 1
fi
echo "Beads ↔ ledger reconciliation passed: no orphan gaps or stale active gap beads found"
- name: cargo fmt
run: cargo fmt --check
- name: cargo clippy
run: cargo clippy --all-targets -- -D warnings
- name: cargo clippy (wasm-host) [linux]
if: runner.os == 'Linux'
run: cargo clippy --all-targets --features wasm-host -- -D warnings
- name: cargo doc
run: cargo doc --no-deps
- name: Reclaim disk space before tests [linux]
if: runner.os == 'Linux'
run: |
set -euxo pipefail
df -h /
# Full clean: clippy/doc artefacts are not reusable by cargo test and
# can consume 20+ GB. Tests will recompile from scratch.
cargo clean 2>/dev/null || true
df -h /
- name: cargo test
run: cargo test --all-targets
- name: Upload inclusion manifest artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: inclusion-manifest-${{ matrix.os }}-${{ github.sha }}
path: |
pi_agent_rust/docs/extension-inclusion-list.json
pi_agent_rust/tests/ext_conformance/reports/inclusion_manifest/**
if-no-files-found: warn
- name: Reclaim disk space before wasm-host tests [linux]
if: runner.os == 'Linux'
run: |
set -euxo pipefail
df -h /
# Full clean again: default-feature test binaries are not reusable by
# wasm-host feature tests and consume 20+ GB.
cargo clean 2>/dev/null || true
df -h /
- name: cargo test (wasm-host) [linux]
if: runner.os == 'Linux'
run: cargo test --all-targets --features wasm-host
- name: Prepare claim-integrity perf paths [linux]
if: runner.os == 'Linux'
run: |
set -euxo pipefail
PERF_CLAIM_CORRELATION_ID="ci-claim-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
PERF_EVIDENCE_DIR="tests/e2e_results/perf-ci-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
echo "PERF_CLAIM_CORRELATION_ID=${PERF_CLAIM_CORRELATION_ID}" >> "$GITHUB_ENV"
echo "PERF_EVIDENCE_DIR=${PERF_EVIDENCE_DIR}" >> "$GITHUB_ENV"
echo "PERF_BASELINE_CONFIDENCE_JSON=${PERF_EVIDENCE_DIR}/results/baseline_variance_confidence.json" >> "$GITHUB_ENV"
echo "PERF_EXTENSION_STRATIFICATION_JSON=${PERF_EVIDENCE_DIR}/results/extension_benchmark_stratification.json" >> "$GITHUB_ENV"
echo "PERF_SCENARIO_CELL_STATUS_JSON=${PERF_EVIDENCE_DIR}/claim_integrity_scenario_cell_status.json" >> "$GITHUB_ENV"
echo "PERF_SCENARIO_CELL_STATUS_MD=${PERF_EVIDENCE_DIR}/claim_integrity_scenario_cell_status.md" >> "$GITHUB_ENV"
- name: Generate perf claim-integrity evidence bundle [linux]
if: runner.os == 'Linux'
run: |
set -euxo pipefail
CI_CORRELATION_ID="$PERF_CLAIM_CORRELATION_ID" \
PERF_OUTPUT_DIR="$PERF_EVIDENCE_DIR" \
./scripts/perf/orchestrate.sh \
--profile ci \
--skip-build \
--skip-env-check
- name: Unified verification runner (ci profile) [linux]
if: runner.os == 'Linux'
run: |
set -euxo pipefail
CI_CORRELATION_ID="$PERF_CLAIM_CORRELATION_ID" \
CLAIM_INTEGRITY_REQUIRED=1 \
PERF_EVIDENCE_DIR="$PERF_EVIDENCE_DIR" \
PERF_BASELINE_CONFIDENCE_JSON="$PERF_BASELINE_CONFIDENCE_JSON" \
PERF_EXTENSION_STRATIFICATION_JSON="$PERF_EXTENSION_STRATIFICATION_JSON" \
./scripts/e2e/run_all.sh --profile ci
- name: Publish scenario-cell gate status [linux]
if: runner.os == 'Linux'
run: |
set -euxo pipefail
python3 - <<'PY'
import json
import os
import sys
from pathlib import Path
json_path = Path(os.environ["PERF_SCENARIO_CELL_STATUS_JSON"])
md_path = Path(os.environ["PERF_SCENARIO_CELL_STATUS_MD"])
if not json_path.is_file():
print(f"missing scenario-cell status JSON: {json_path}", file=sys.stderr)
sys.exit(1)
payload = json.loads(json_path.read_text(encoding="utf-8"))
summary = payload.get("summary", {})
total = int(summary.get("total_cells", 0))
passing = int(summary.get("passing_cells", 0))
failing = int(summary.get("failing_cells", 0))
print(
"Scenario-cell claim-integrity status: "
f"total={total}, passing={passing}, failing={failing}"
)
if failing > 0:
print(
"Scenario-cell failures detected; run_all gate should already fail in strict mode.",
file=sys.stderr,
)
step_summary = os.environ.get("GITHUB_STEP_SUMMARY")
if step_summary:
with open(step_summary, "a", encoding="utf-8") as handle:
handle.write("\n## Scenario Cell Gate Status\n\n")
handle.write(
f"- Total cells: `{total}`\n- Passing: `{passing}`\n- Failing: `{failing}`\n\n"
)
if md_path.is_file():
markdown = md_path.read_text(encoding="utf-8")
handle.write(markdown)
if not markdown.endswith("\n"):
handle.write("\n")
else:
handle.write(
f"_Detailed markdown artifact not found at `{md_path}`._\n"
)
PY
- name: Upload scenario-cell gate artifacts [linux]
if: runner.os == 'Linux' && always()
uses: actions/upload-artifact@v4
with:
name: scenario-cell-gate-${{ github.run_id }}-${{ github.run_attempt }}
path: |
pi_agent_rust/${{ env.PERF_SCENARIO_CELL_STATUS_JSON }}
pi_agent_rust/${{ env.PERF_SCENARIO_CELL_STATUS_MD }}
if-no-files-found: warn
- name: CI gate promotion (strict/rollback) [linux]
if: runner.os == 'Linux'
run: |
set -euxo pipefail
python3 - <<'PY'
import json
import os
import sys
from datetime import datetime, timezone
from pathlib import Path
def parse_float(name: str) -> float:
raw = os.environ.get(name, "").strip()
try:
return float(raw)
except ValueError:
print(f"invalid {name}: {raw!r}", file=sys.stderr)
sys.exit(1)
def parse_int(name: str) -> int:
raw = os.environ.get(name, "").strip()
try:
return int(raw)
except ValueError:
print(f"invalid {name}: {raw!r}", file=sys.stderr)
sys.exit(1)
def load_json(path: Path, label: str) -> dict:
if not path.is_file():
raise RuntimeError(f"missing required {label}: {path}")
with path.open(encoding="utf-8") as handle:
payload = json.load(handle)
if not isinstance(payload, dict):
raise RuntimeError(f"invalid {label}: expected JSON object at {path}")
return payload
mode = os.environ.get("CI_GATE_PROMOTION_MODE", "strict").strip().lower()
if mode not in {"strict", "rollback"}:
print(
f"invalid CI_GATE_PROMOTION_MODE={mode!r}; expected 'strict' or 'rollback'",
file=sys.stderr,
)
sys.exit(1)
threshold_version = os.environ.get("CI_GATE_THRESHOLD_VERSION", "2026-02-08.v1").strip()
thresholds = {
"min_pass_rate_pct": parse_float("CI_GATE_MIN_PASS_RATE_PCT"),
"max_fail_count": parse_int("CI_GATE_MAX_FAIL_COUNT"),
"max_na_count": parse_int("CI_GATE_MAX_NA_COUNT"),
}
# Rollback semantics are intentionally simple and asserted each run.
def gate_allows(mode_name: str, has_failures: bool) -> bool:
return not (has_failures and mode_name == "strict")
assert gate_allows("strict", False)
assert not gate_allows("strict", True)
assert gate_allows("rollback", True)
summary_candidates = sorted(
Path("tests/e2e_results").rglob("summary.json"),
key=lambda path: path.stat().st_mtime,
reverse=True,
)
if not summary_candidates:
print("no summary.json found under tests/e2e_results", file=sys.stderr)
sys.exit(1)
summary_path = summary_candidates[0]
artifact_dir = summary_path.parent
evidence_path = artifact_dir / "evidence_contract.json"
conformance_summary_path = Path("tests/ext_conformance/reports/conformance_summary.json")
try:
summary = load_json(summary_path, "summary")
evidence = load_json(evidence_path, "evidence_contract")
conformance_summary = load_json(conformance_summary_path, "conformance_summary")
except RuntimeError as exc:
print(str(exc), file=sys.stderr)
sys.exit(1)
checks = []
failures = []
def add_check(check_id: str, actual, threshold, ok: bool) -> None:
checks.append(
{
"id": check_id,
"actual": actual,
"threshold": threshold,
"ok": ok,
}
)
if not ok:
failures.append(check_id)
evidence_schema = evidence.get("schema")
evidence_status = evidence.get("status")
evidence_errors = evidence.get("errors")
if not isinstance(evidence_errors, list):
evidence_errors = []
evidence_warnings = evidence.get("warnings")
if not isinstance(evidence_warnings, list):
evidence_warnings = []
add_check(
"evidence_contract.schema",
evidence_schema,
"pi.evidence.contract.v1",
evidence_schema == "pi.evidence.contract.v1",
)
add_check(
"evidence_contract.status",
evidence_status,
"pass",
evidence_status == "pass",
)
add_check(
"evidence_contract.errors",
len(evidence_errors),
0,
len(evidence_errors) == 0,
)
conformance_schema = conformance_summary.get("schema")
counts = conformance_summary.get("counts")
if not isinstance(counts, dict):
counts = {}
pass_rate_pct = conformance_summary.get("pass_rate_pct")
fail_count = counts.get("fail")
na_count = counts.get("na")
total_count = counts.get("total")
try:
pass_rate_pct = float(pass_rate_pct)
except (TypeError, ValueError):
pass_rate_pct = None
try:
fail_count = int(fail_count)
except (TypeError, ValueError):
fail_count = None
try:
na_count = int(na_count)
except (TypeError, ValueError):
na_count = None
try:
total_count = int(total_count)
except (TypeError, ValueError):
total_count = None
evidence_payload = conformance_summary.get("evidence")
required_evidence_keys = {"golden_fixtures", "load_time_benchmarks", "parity_logs", "smoke_logs"}
if isinstance(evidence_payload, dict):
evidence_keys = set(evidence_payload.keys())
else:
evidence_keys = set()
add_check(
"conformance_summary.schema",
conformance_schema,
"pi.ext.conformance_summary.v2",
conformance_schema == "pi.ext.conformance_summary.v2",
)