Skip to content

Commit ec8a81d

Browse files
feat(ci): migrate shell safety and docs drift to policy rules
1 parent 19876c8 commit ec8a81d

9 files changed

Lines changed: 547 additions & 146 deletions

File tree

docs/governance/CI_POLICY.md

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ This document defines policy principles, severity handling, and exit code policy
55
Normative policy definitions live in:
66
- `tools/ci/policies/schema/rules.schema.json`
77
- `tools/ci/policies/rules/`
8+
Entry index:
9+
- `docs/governance/POLICY_INDEX.md`
810

911
## Global Rules
1012
- Fail-closed: no silent bypass paths.
11-
- No `continue-on-error: true` in workflow files.
12-
- No `|| true` on critical workflow paths.
13-
- No `set +e` without explicit allow-list entry.
1413
- Workflow YAML only calls entry scripts under `tools/ci/bin/`.
1514

1615
## Result Contract
@@ -22,17 +21,8 @@ All required checks MUST write:
2221
`result.json` must comply with `tools/ci/schema/result.schema.json`.
2322

2423
## Rule Catalog
25-
- `CI-ARTIFACT-001` fail: required artifact missing.
26-
- `CI-POLICY-001` fail: policy rule loading/schema validation failed.
27-
- `CI-SCHEMA-001` fail: `result.json` schema validation failed.
28-
- `CI-SHELL-001` fail: found `continue-on-error: true`.
29-
- `CI-SHELL-002` fail: found `|| true` in critical workflow path.
30-
- `CI-SHELL-003` fail: found `set +e` outside allow-list.
31-
- `CI-SHELL-004` fail: workflow `run: |` block exceeds configured max lines.
32-
- `CI-GRAPH-001` fail: required CI graph edge or job constraint violated.
33-
- `CI-QODANA-001` fail: `QODANA_TOKEN` missing.
34-
- `CI-QODANA-002` fail: expected SARIF missing.
35-
- `CI-QODANA-003` fail: SARIF invalid JSON.
24+
- Rule IDs and file ownership are indexed in `docs/governance/POLICY_INDEX.md`.
25+
- Evaluation details and thresholds are defined only in `tools/ci/policies/rules/`.
3626

3727
## Severity Rules
3828
- `warn`: visible, non-blocking.
@@ -43,5 +33,5 @@ All required checks MUST write:
4333
- `1`: policy/contract/check failure (`fail`)
4434
- `2`: invalid invocation or missing prerequisites
4535

46-
## set +e Allow-list
47-
No allow-list entries in Phase 1.
36+
## Allow-lists
37+
Allow-list definitions are managed in rule parameters under `tools/ci/policies/rules/`.

docs/governance/POLICY_INDEX.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Policy Index (SSOT Navigation)
2+
3+
This index is non-normative. Normative policy definitions are the rule files under `tools/ci/policies/rules/`.
4+
5+
| Rule ID | Rule File |
6+
| --- | --- |
7+
| `CI-ARTIFACT-001` | `tools/ci/policies/rules/artifact_contract.yaml` |
8+
| `CI-SHELL-001` | `tools/ci/policies/rules/shell_safety.yaml` |
9+
| `CI-SHELL-002` | `tools/ci/policies/rules/shell_safety.yaml` |
10+
| `CI-SHELL-003` | `tools/ci/policies/rules/shell_safety.yaml` |
11+
| `CI-SHELL-004` | `tools/ci/policies/rules/shell_safety.yaml` |
12+
| `CI-DOCS-001` | `tools/ci/policies/rules/docs_drift.yaml` |

tools/ci/bin/run.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ run_preflight() {
6363
run_or_fail "CI-PREFLIGHT-001" "Docs check" python3 "${ROOT_DIR}/tools/check-docs.py"
6464
run_or_fail "CI-PREFLIGHT-001" "Versioning guard" bash "${ROOT_DIR}/tools/versioning/check-versioning.sh"
6565
run_or_fail "CI-PREFLIGHT-001" "Format check" dotnet format "${ROOT_DIR}/FileClassifier.sln" --verify-no-changes
66-
run_or_fail "CI-PREFLIGHT-001" "Policy shell safety" bash "${ROOT_DIR}/tools/ci/policies/policy_shell_safety.sh"
66+
if ! ci_run_capture "Policy shell safety" bash "${ROOT_DIR}/tools/ci/policies/policy_shell_safety.sh"; then
67+
return 1
68+
fi
6769
run_or_fail "CI-GRAPH-001" "CI graph assertion" bash "${ROOT_DIR}/tools/ci/bin/assert_ci_graph.sh"
6870

6971
ci_result_append_summary "Preflight checks completed."

0 commit comments

Comments
 (0)