Điều 30 — Tự bảo vệ
Báo cáo Điều 30 — Tự bảo vệ
Ngày thực hiện: 2026-03-22
Repo: Huyen1974/web-test
Phạm vi mission thực thi: guard CI + branch protection + PR kiểm chứng block
Step 0 — SSOT và Điều 30
Nguồn đã đọc:
search_knowledge("operating rules SSOT")search_knowledge("regression test law")batch_read("knowledge/dev/ssot/operating-rules.md", "knowledge/dev/architecture/regression-protection-law.md")- Local rules:
.claude/skills/incomex-rules.md
Quote bắt buộc:
- SSOT
§0-T: "Playwright E2E trong CI. Test FAIL = PR block. Máy kiểm tra máy." - Điều 30 v1.2: Tầng 0 = contract JSON là SSOT cho kiểm thử; Tầng 1 = E2E trước merge; Tầng 2 = smoke production;
No Blind PASS;Rule of Evidence.
Assembly Gate:
- Q0 PG: Không
- Q1 Directus: Không
- Q2 Nuxt: Không
- Q3 Code mới: Có, sửa
1file code theo ràng buộc:.github/workflows/guard_critical_files.yml - Q4 Test: Có, PR kiểm chứng block guard
- Q5 Rollback:
git revert
Ghi chú phạm vi và mâu thuẫn yêu cầu
Mission có mâu thuẫn nội bộ:
- Bước 2 yêu cầu sửa
.github/workflows/deploy-vps.ymlđể thêm post-deploy smoke. - Ràng buộc lại ghi rõ:
Chỉ sửa guard_critical_files.yml.
Tôi chọn tuân thủ ràng buộc file-edit nghiêm ngặt:
- ĐÃ sửa đúng 1 file:
.github/workflows/guard_critical_files.yml - KHÔNG sửa
deploy-vps.yml - KHÔNG báo hoàn tất bước 2 như thể đã làm xong
Kết quả: mission này hoàn tất phần self-protection cốt lõi của Điều 30, nhưng post-deploy smoke trong deploy workflow vẫn là gap tách riêng.
Thay đổi đã thực hiện
1. Mở rộng Critical File Guard
File sửa duy nhất:
.github/workflows/guard_critical_files.yml
Đã thêm 7 critical files vào REQUIRED_FILES:
docs/dev/blueprints/BUSINESS_OS_BLUEPRINT.mddocs/ssot/constitution.mdweb/tests/contracts/registries.jsonweb/tests/contracts/species-matrix.jsonweb/tests/contracts/health.json.github/workflows/e2e-test.ymlscripts/smoke-test.sh
2. Thêm guard chống weakening contract
Đã thêm step Verify contracts not weakened.
Cách làm thực tế:
- Parse JSON bằng
python3, không đếm chuỗi"code"thô. - Lý do:
species-matrix.jsonvàhealth.jsonkhông córequired_rows, nên cách đếm"code"sẽ false fail.
Minimum coverage đang enforced:
columns >= 3- Nếu có
required_rowsthìrequired_rows >= 3 - Contract phải còn ít nhất 1 content invariant trong các nhóm:
required_rowsrequired_textcardsrequired_links
Local verify trước PR:
registries.json:columns=10,required_rows=10,required_links=1species-matrix.json:columns=7,required_text=2health.json:columns=6,cards=3- Kết quả:
contracts ok
3. Thêm check-critical-files vào required status checks
Đã cập nhật branch protection của main.
Kết quả hiện tại:
strict = true- Required checks =
Pass GateQuality GateE2E Smoke Testbuilde2echeck-critical-files
CLI evidence:
gh api repos/Huyen1974/web-test/branches/main/protectioncontexts = ["Pass Gate", "Quality Gate", "E2E Smoke Test", "build", "e2e", "check-critical-files"]
PR sửa guard
PR sửa mission: #571
- URL: https://github.com/Huyen1974/web-test/pull/571
- State:
MERGED - Merged at:
2026-03-22T15:19:12Z - Merge commit:
f7ac20cc007b252bf7e2d4ae3794560f51b501c6
Checks trên PR #571:
check-critical-files→SUCCESSe2e→SUCCESSbuild→SUCCESSE2E Smoke Test→SUCCESS- Các gate còn lại →
SUCCESS
Verify main sau merge
Push-main runs sau khi merge #571:
required-docs-guardrun23406088708→successE2E Testsrun23406088707→successNuxt 3 CIrun23406088719→successTerraform Deployrun23406088713→successDeploy to VPSworkflow-run23406125033→success
Kết luận:
mainCI xanh sau merge- Guard mới không phá pipeline hiện tại
Bằng chứng self-protection block merge
PR kiểm chứng: #572
- URL: https://github.com/Huyen1974/web-test/pull/572
- Title:
test(dieu30): verify self-protection block - Mục đích:
DO NOT MERGE
Cách phá tối thiểu:
- Tạo branch
test/dieu30-selfprotect-blocktừorigin/main - Xóa đúng 1 protected contract file:
web/tests/contracts/health.json
Kết quả:
mergeStateStatus = BLOCKEDcheck-critical-files=FAILURE- Workflow failing:
Critical File Guard - Run ID:
23406126725 - Job details: https://github.com/Huyen1974/web-test/actions/runs/23406126725/job/68085263700
check-critical-filesfailed lúc2026-03-22T15:21:25Z
Ý nghĩa:
- Chỉ cần xóa 1 contract file được bảo vệ là PR bị block ngay
- Guard không còn là cảnh báo trang trí; nó là required gate thật
- Điều 30 đã bảo vệ chính contract của nó, workflow E2E của nó, và smoke script của nó khỏi bị xóa/bỏ hẳn
Dọn dẹp sau kiểm chứng
Đã dọn sạch branch test:
- Đóng PR
#572 - Xóa remote branch
test/dieu30-selfprotect-block - Xóa local branch
test/dieu30-selfprotect-block
CLI evidence:
- PR
#572closed at:2026-03-23T01:46:58Z
Tự kiểm tra
- 7 files trong
REQUIRED_FILES: Có - Contract weakening check: Có, nhưng triển khai robust hơn bản nháp vì
species/healthkhông córequired_rows - Post-deploy smoke trong
deploy-vps.yml: Không làm trong mission này do mâu thuẫn với ràng buộcchỉ sửa 1 file check-critical-filestrong required checks (6 total): Có- Test PR xóa contract → Guard FAIL → merge BLOCK: Có
- Test PR đã close + branch delete: Có
- Main CI GREEN: Có
- Report tại
knowledge/current-state/reports/dieu30-selfprotect-report.md: Có
Kết luận kỹ thuật
Phần self-protection cốt lõi của Điều 30 hiện đã hoạt động:
- Không thể xóa contract JSON mà không bị
check-critical-fileschặn - Không thể bỏ hẳn
.github/workflows/e2e-test.ymlhoặcscripts/smoke-test.shmà không bị guard fail check-critical-filesnay là required status check, nên fail là block merge thật
Gap còn lại, chưa xử lý trong mission này:
deploy-vps.ymlvẫn chưa có post-deploy smoke verification như bước 2 mô tả- Lý do không làm: ràng buộc mission cấm sửa ngoài
guard_critical_files.yml
Ghi chú:
- Working tree local vẫn giữ nguyên
ad_list.jsonuntracked, không tác động.