Private
Public Access
0
0

feat(directives): add rule-statement header to 9-16 of 66 v1.md files

This commit is contained in:
2026-07-03 09:45:46 -04:00
parent cf8eab9f79
commit 85ae99c6a5
8 changed files with 16 additions and 0 deletions
@@ -1,3 +1,5 @@
# getattr(x, 'field', default) used for type-dispatch polymorphism is banned
### 17.5 Banned: `getattr(x, 'field', default)` for type dispatch
```python
@@ -1,3 +1,5 @@
# Using hasattr() for entity-type dispatch is banned
### 17.4 Banned: `hasattr()` for entity type dispatch
```python
@@ -1,3 +1,5 @@
# Local imports inside function bodies are banned (use module-level imports)
- Local imports inside functions (top-of-module imports only)
**The one exception:** the literal wire boundary (TOML/JSON parse functions) may use `dict[str, Any]` + `Metadata.from_dict(...)`.
@@ -1,3 +1,5 @@
# The type Optional[T] is banned as a return type — use Result[T] or NIL_T sentinels
### 17.3 Banned: `Optional[T]` returns
```python
@@ -1 +1,3 @@
# `import X as _X` aliasing for naming convenience is banned (use the full type name)
- `import X as _PREFIX` aliasing (use the original name)
@@ -1 +1,3 @@
# Calling .from_dict() repeatedly in the same expression is banned — promote the type at the boundary
- Repeated `.from_dict()` calls in the same expression (cache the result or promote the type)
@@ -1,3 +1,5 @@
# For live_gui tests, verification must be batch — not isolated
### Isolated-Pass Verification Fallacy (Added 2026-06-09)
A test that "passes when run after test X but fails in isolation" is a **fragile test, not a fragile fixture**. The flip side is also true: a test that "passes in isolation but fails in batch" is failing — its failure is masked by isolation. The only verification that matters for `live_gui` tests (or any test that depends on shared subprocess state) is the **batch run** in the suite the test will ship in.
@@ -1,3 +1,5 @@
# dict[str, Any], Any, Optional[T] returns are allowed only at the literal wire boundary (TOML/JSON parse)
### 17.7 The one exception: the boundary layer
The ONLY place these patterns are allowed is at the literal wire boundary — the function that calls `tomllib.load()`, `json.loads()`, or a vendor SDK's response parser. The boundary is 2-3 functions per file. Every consumer IMMEDIATELY converts to a typed dataclass via `from_dict()`.