Validate Tool Index
Mô tả công cụ: validate.py
Script: /tools/validate/validate.py
Mục đích: Đảm bảo mọi tài liệu .md trong repo đều hợp lệ theo schema trong /.okf/profile.yaml và không có broken internal links.
Hai pass kiểm tra
Pass 1 — Syntactic Check:
- Kiểm tra frontmatter có đủ
required_fieldscho type tương ứng không. - Validate enum values (
status,tlp,classification). - Kiểm tra
review_bykhông vượt quá review cycle limit (90 hoặc 365 ngày từtimestamp). - Kiểm tra
schema_versioncompatibility (cho phép 1 minor version drift).
Pass 2 — Semantic Check:
- Phân loại links: internal (
/path/file.md), external (https://), anchor (#heading). - Internal links: kiểm tra file tồn tại. Broken link = ERROR (fail CI).
- Anchor links: kiểm tra heading slug tồn tại trong cùng file. Missing anchor = WARNING (non-blocking).
- External links: bỏ qua (không validate existence).
- Kiểm tra
../relative paths — nghiêm cấm, fail ngay.
Index completeness check:
- Với mỗi directory có
index.md: cảnh báo nếu có.mdfile trong thư mục nhưng không được reference trongindex.md.
Cách chạy
# Validate toàn bộ repo
python tools/validate/validate.py --path .
# Validate một file cụ thể
python tools/validate/validate.py --path services/payment-gateway.md
# Bao gồm cả templates directory
python tools/validate/validate.py --path . --templates
# Verbose mode (hiện chi tiết từng file)
python tools/validate/validate.py --path . --verbose
Exit codes
0— Pass (không có error)1— Fail (có ít nhất 1 error)