Skip to content

Commit b5046d3

Browse files
feat: purity.no_orphan_files — import graph traversal, DI limitation documented
1 parent e9fccf8 commit b5046d3

8 files changed

Lines changed: 1699 additions & 8 deletions

File tree

.intent/enforcement/mappings/code/purity.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,37 @@ mappings:
118118
check_type: dead_code_check
119119
tool: "vulture"
120120
confidence: 80
121+
122+
# 9. LAW: Production source files MUST be reachable from a declared entry point.
123+
# Check type: knowledge_gate (Import graph traversal)
124+
# Rationale: vulture detects unused symbols but cannot detect unreachable files.
125+
# This check traverses the import graph from entry points and flags orphan files.
126+
#
127+
# DYNAMIC PLUGIN DIRECTORIES (loaded via pkgutil.iter_modules / importlib):
128+
# - src/mind/logic/engines/ → EngineRegistry (mind/logic/engines/registry.py)
129+
# - src/mind/governance/checks/ → check_registry.py
130+
# - src/will/workers/ → cli/resources/workers/run.py
131+
# - src/will/phases/ → will/orchestration/phase_registry.py
132+
# - src/body/services/ → body/services/service_registry.py
133+
# These are convention-loaded at runtime — not reachable via static import graph.
134+
purity.no_orphan_files:
135+
engine: knowledge_gate
136+
params:
137+
check_type: orphan_file_check
138+
entry_points:
139+
# Static entry points
140+
- "src/cli/"
141+
- "src/body/atomic/"
142+
- "src/main.py"
143+
- "src/api/main.py"
144+
# Dynamic plugin directories — loaded by registry scan, not static imports
145+
- "src/mind/logic/engines/"
146+
- "src/mind/governance/checks/"
147+
- "src/will/workers/"
148+
- "src/will/phases/"
149+
- "src/body/services/"
150+
excludes:
151+
- "src/**/__init__.py"
152+
- "src/**/__main__.py"
153+
- "src/**/conftest.py"
154+
- "scripts/**/*.py"

.intent/rules/code/purity.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"metadata": {
55
"id": "rules.code.purity",
66
"title": "Code Purity Standards (V2.3 Reflexive)",
7-
"version": "1.1.0",
7+
"version": "1.2.0",
88
"authority": "policy",
99
"phase": "audit",
1010
"status": "active"
@@ -69,6 +69,14 @@
6969
"authority": "policy",
7070
"phase": "audit",
7171
"enforcement": "reporting"
72+
},
73+
{
74+
"id": "purity.no_orphan_files",
75+
"statement": "Production source files MUST be reachable from at least one declared entry point via the import graph. Files that no entry point can reach are orphans and MUST be removed or integrated.",
76+
"authority": "policy",
77+
"phase": "audit",
78+
"enforcement": "reporting",
79+
"rationale": "vulture detects unused symbols within files but cannot detect unreachable files. This rule closes that gap via import graph traversal from declared entry points."
7280
}
7381
]
7482
}

reports/audit/latest_audit.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"audit_id": "d076089f-09c8-4461-ada2-ae8defb5181b",
3-
"timestamp": "2026-03-10T13:59:31Z",
2+
"audit_id": "25c83d2f-5239-4b8e-a6d1-3e63a0d7dfa1",
3+
"timestamp": "2026-03-10T20:45:27Z",
44
"passed": true,
5-
"findings_count": 137,
5+
"findings_count": 305,
66
"executed_rules": [
77
"ai.prompt.artifact.no_provider_leak",
88
"ai.prompt.artifact.required_fields",
@@ -91,6 +91,7 @@
9191
"purity.no_ast_duplication",
9292
"purity.no_dead_code",
9393
"purity.no_metadata_decorators",
94+
"purity.no_orphan_files",
9495
"purity.no_semantic_duplication",
9596
"purity.no_todo_placeholders",
9697
"purity.stable_id_anchor",

reports/audit_auto_ignored.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"generated_at": "2026-03-10T13:59:31Z",
2+
"generated_at": "2026-03-10T20:45:27Z",
33
"items": []
44
}

reports/audit_auto_ignored.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Audit Auto-Ignored Symbols
22

3-
- Generated: `2026-03-10T13:59:31Z`
3+
- Generated: `2026-03-10T20:45:27Z`
44
- Total auto-ignored: **0**

0 commit comments

Comments
 (0)