Skip to content

Commit 5e9a070

Browse files
committed
docs: add governance/persona/phases/product/instructions/self_hosting directories
1 parent 8a93b8a commit 5e9a070

1 file changed

Lines changed: 122 additions & 8 deletions

File tree

docs/INVARIANTS.md

Lines changed: 122 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,125 @@
1-
# Invariant Consolidation (SE v1)
1+
# Invariants (ShieldCraft Engine v1)
22

3-
This file enumerates invariants, where they are enforced, and ensures each is enforced in a single place.
3+
This file defines non-negotiable invariants of the ShieldCraft Engine (SE).
4+
An invariant expresses a condition that must always hold, how violations are classified,
5+
and what actions are permitted or forbidden in response.
46

5-
- Instruction-level invariants: enforced in `shieldcraft.services.validator` via `validate_spec_instructions`.
6-
- Repo sync invariants: enforced in `shieldcraft.services.sync.verify_repo_sync`; errors surfaced as `SyncError`.
7-
- Pointer coverage invariants: checked in `shieldcraft.services.spec.pointer_auditor.ensure_full_pointer_coverage` and used in `preflight`.
8-
- Checklist invariants (must/forbid): evaluated during `ChecklistGenerator.build` via `invariants.evaluate_invariant` and `evaluate_invariant` results are attached to items; enforcement for must/forbid resides in `ChecklistGenerator`/`derived` as appropriate.
9-
- Self-host artifact emission: enforced by `Engine.run_self_host` using `is_allowed_selfhost_path()`.
7+
Each invariant is enforced in exactly one authoritative location.
8+
No invariant may be enforced implicitly or redundantly.
109

11-
Policy: Each invariant is documented and enforced in one authoritative module; enforcement points are referenced above.
10+
---
11+
12+
## Invariant Enforcement Map
13+
14+
- Instruction invariants
15+
Enforced in: `shieldcraft.services.validator.validate_spec_instructions`
16+
17+
- Repository sync invariants
18+
Enforced in: `shieldcraft.services.sync.verify_repo_sync`
19+
Violation surfaced as: `SyncError`
20+
21+
- Pointer coverage invariants
22+
Enforced in: `shieldcraft.services.spec.pointer_auditor.ensure_full_pointer_coverage`
23+
Used during: preflight
24+
25+
- Checklist must/forbid invariants
26+
Evaluated in: `ChecklistGenerator.build` via `invariants.evaluate_invariant`
27+
Enforcement resides in: checklist generation and derived resolution
28+
29+
- Self-host artifact emission invariants
30+
Enforced in: `Engine.run_self_host` using `is_allowed_selfhost_path()`
31+
32+
---
33+
34+
## Failure Classification Invariants
35+
36+
### Failure Classes (Exhaustive)
37+
38+
All failures in SE **must** be classified as exactly one of the following:
39+
40+
- `PRODUCT_INVARIANT_FAILURE`
41+
- `SPEC_CONTRACT_FAILURE`
42+
- `SYNC_DRIFT_FAILURE`
43+
- `ORCHESTRATION_FAILURE`
44+
- `UNKNOWN_FAILURE`
45+
46+
No other failure classes are permitted.
47+
48+
Failure classification is mandatory before any corrective action.
49+
50+
---
51+
52+
### ORCHESTRATION_FAILURE
53+
54+
An `ORCHESTRATION_FAILURE` applies when **all** of the following are true:
55+
56+
- The failure occurs before SE product logic executes.
57+
- The failure originates from the orchestration or execution environment.
58+
- No product artifact hash, spec, checklist, or invariant is violated.
59+
60+
Examples (non-exhaustive):
61+
- Missing tooling (e.g. pytest not installed)
62+
- Missing or incorrect environment setup
63+
- Invalid CI workflow configuration
64+
- Runner, permission, or infrastructure misconfiguration
65+
66+
---
67+
68+
## Enforcement Rules
69+
70+
- Product code **must not** be modified in response to an `ORCHESTRATION_FAILURE`.
71+
- Only orchestration-layer artifacts (e.g. CI workflows, runners, environment setup)
72+
may be changed.
73+
- Resolution of an `ORCHESTRATION_FAILURE` is required before any product-level
74+
work may proceed.
75+
76+
---
77+
78+
## Persona Constraints
79+
80+
- Personas **must** classify the failure before emitting guidance.
81+
- Personas **must not** recommend product-level changes until failure class
82+
is determined.
83+
- If the failure class is `ORCHESTRATION_FAILURE`:
84+
- Personas **must refuse** product-level recommendations.
85+
- Persona output is restricted to orchestration-layer observations or vetoes.
86+
87+
Persona output is data, not inference.
88+
89+
---
90+
91+
## Failure Classification Gate
92+
93+
After any CI or execution failure:
94+
95+
- Evidence **must** be collected.
96+
- Failure **must** be classified into exactly one failure class.
97+
- No instruction block may be issued before classification is recorded.
98+
99+
---
100+
101+
## CI Assumption Invariant
102+
103+
CI workflows **must not** assume project structure or implicit tooling.
104+
105+
Forbidden assumptions include:
106+
- Presence of `requirements.txt`
107+
- Implicit availability of pytest or global tools
108+
109+
All CI setup **must** derive from:
110+
- `pyproject.toml`
111+
- Explicit, versioned installation steps
112+
113+
Violation of this invariant is classified as `ORCHESTRATION_FAILURE`.
114+
115+
---
116+
117+
## Unknown Failures
118+
119+
Any failure that cannot be deterministically classified **must** be classified as
120+
`UNKNOWN_FAILURE`.
121+
122+
On `UNKNOWN_FAILURE`:
123+
- All progress halts.
124+
- Escalation is mandatory.
125+
- No speculative fixes are permitted.

0 commit comments

Comments
 (0)