v0.5.3-pre.003
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
# file: scripts/audit_khadhroony_workspace_rules.py
|
||||
# version: 31
|
||||
# version: 32
|
||||
|
||||
"""Audit mechanically verifiable rules specific to khadhroony-bot3."""
|
||||
|
||||
@@ -1425,6 +1425,38 @@ def audit_store_backend_boundary(root: pathlib.Path) -> list[Violation]:
|
||||
"PostgreSQL tracing must declare one structured `action` field",
|
||||
)
|
||||
)
|
||||
if crate_root.is_file():
|
||||
exported_types = {
|
||||
match.group(1)
|
||||
for match in re.finditer(
|
||||
r"(?m)^pub use self::[^;]+::([A-Z][A-Za-z0-9_]*)\s*;",
|
||||
crate_root.read_text(encoding="utf-8"),
|
||||
)
|
||||
}
|
||||
store_source_root = root / "ks-store/src"
|
||||
for path in sorted(store_source_root.rglob("*.rs")):
|
||||
if path == crate_root:
|
||||
continue
|
||||
relative = path.relative_to(root).as_posix()
|
||||
for index, line in enumerate(path.read_text(encoding="utf-8").splitlines(), 1):
|
||||
stripped = line.lstrip()
|
||||
if stripped.startswith("//") or stripped.startswith("#["):
|
||||
continue
|
||||
code = re.sub(r'"(?:\\.|[^"\\])*"', '""', line)
|
||||
for type_name in sorted(exported_types):
|
||||
declaration_pattern = rf"\bpub(?:\([^)]*\))?\s+(?:struct|enum|type|trait|const)\s+{re.escape(type_name)}\b"
|
||||
if re.search(declaration_pattern, code):
|
||||
continue
|
||||
if re.search(rf"(?<![A-Za-z0-9_:]){re.escape(type_name)}\b", code) is None:
|
||||
continue
|
||||
violations.append(
|
||||
Violation(
|
||||
"KH_STORE007",
|
||||
relative,
|
||||
index,
|
||||
f"crate-owned public store type `{type_name}` must be referenced through `crate::{type_name}`",
|
||||
)
|
||||
)
|
||||
cargo = root / "ks-store/Cargo.toml"
|
||||
if cargo.is_file():
|
||||
data = tomllib.loads(cargo.read_text(encoding="utf-8"))
|
||||
|
||||
Reference in New Issue
Block a user