v0.1.0-pre.013

This commit is contained in:
2026-07-24 16:44:51 +02:00
parent e753a80c3a
commit 5f6f7df509
38 changed files with 1202 additions and 172 deletions

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env python3
# file: scripts/audit_khadhroony_workspace_rules.py
# version: 6
# version: 7
"""Audit mechanically verifiable rules specific to khadhroony-bot3."""
@@ -278,6 +278,87 @@ def audit_reserved_decoder_scaffolds(root: pathlib.Path) -> list[Violation]:
return violations
def audit_reserved_materializer_scaffolds(root: pathlib.Path) -> list[Violation]:
"""Reject temporary materializer markers and incomplete reserved materializers."""
violations: list[Violation] = []
materializer_root = root / "kb-lib/src/materializer"
forbidden = (
"MIGRATION_BOUNDARIES",
"LEGACY_CRATE",
"MIGRATION_STATUS",
"source-preserved-pending-port",
)
struct_pattern = re.compile(r"^pub struct (Mt[A-Za-z0-9]+Materializer);$", re.MULTILINE)
for path in sorted(materializer_root.rglob("*.rs")):
relative = path.relative_to(root).as_posix()
text = path.read_text(encoding="utf-8")
for marker in forbidden:
offset = text.find(marker)
if offset >= 0:
violations.append(
Violation(
"KH_MT001",
relative,
text[:offset].count("\n") + 1,
f"temporary materializer migration marker `{marker}` is forbidden",
)
)
if not text.startswith("// file:") or "\n//! Reserved " not in text:
continue
struct_match = struct_pattern.search(text)
if struct_match is None:
violations.append(
Violation(
"KH_MT002",
relative,
1,
"reserved materializer must expose one `Mt*Materializer` unit struct",
)
)
continue
type_name = struct_match.group(1)
legacy_implementation = f"impl crate::MtMaterializer for crate::{type_name} {{"
if legacy_implementation not in text:
violations.append(
Violation(
"KH_MT003",
relative,
text[: struct_match.start()].count("\n") + 1,
f"`{type_name}` must implement `MtMaterializer`",
)
)
api_implementation = f"impl crate::MtApiEventMaterializer for crate::{type_name} {{"
if api_implementation not in text:
violations.append(
Violation(
"KH_MT004",
relative,
text[: struct_match.start()].count("\n") + 1,
f"`{type_name}` must implement `MtApiEventMaterializer`",
)
)
if "fn accepted_families(&self) -> &'static [crate::MdEventFamily]" not in text:
violations.append(
Violation(
"KH_MT005",
relative,
1,
"reserved materializer must declare its inactive family boundary",
)
)
if "crate::MtApiMaterializerExecutionResult::ignored()" not in text:
violations.append(
Violation(
"KH_MT006",
relative,
1,
"reserved materializer must return an ignored API result",
)
)
return violations
def audit_token2022_naming(root: pathlib.Path) -> list[Violation]:
"""Reject obsolete internal Token2022 spellings while preserving legacy evidence."""
@@ -421,6 +502,7 @@ def main() -> int:
+ audit_kb_lib_tracing(root)
+ audit_kb_lib_symbol_prefixes(root)
+ audit_reserved_decoder_scaffolds(root)
+ audit_reserved_materializer_scaffolds(root)
+ audit_token2022_naming(root)
+ audit_private_kb_lib_paths_in_active_docs(root)
+ audit_solana_types(root)