# 7.4 Mechanical enforcement

Linters and structural tests enforce invariants, and their error messages carry remediation into context.

1. Architectural invariant: dependencies only point forward.
2. An agent edit introduces a backward dependency.
3. The linter error injects remediation into context.
4. The agent self-corrects; the invariant holds at any throughput.

- **Use when:** Agent throughput exceeds human review capacity.
- **Avoid:** Prose-only rules, and errors that say what failed but not how to fix it.

```
# structural test, run as a hook and in CI
for edge in import_graph(domain):
    if layer(edge.dst) < layer(edge.src):
        fail(f"""{edge}: backward dependency.
        Fix: expose it through Providers,
        see ARCHITECTURE.md#layers""")
```

## References

- [Harness engineering](https://openai.com/index/harness-engineering/) (OpenAI)
- [Agent harness engineering](https://addyosmani.com/blog/agent-harness-engineering/) (Addy Osmani)
- [The anatomy of an agent harness](https://www.langchain.com/blog/the-anatomy-of-an-agent-harness) (LangChain)
