v0.1.0-pre.014
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
# file: scripts/audit_khadhroony_workspace_rules.py
|
||||
# version: 7
|
||||
# version: 8
|
||||
|
||||
"""Audit mechanically verifiable rules specific to khadhroony-bot3."""
|
||||
|
||||
@@ -359,6 +359,97 @@ def audit_reserved_materializer_scaffolds(root: pathlib.Path) -> list[Violation]
|
||||
return violations
|
||||
|
||||
|
||||
def audit_reserved_executor_scaffolds(root: pathlib.Path) -> list[Violation]:
|
||||
"""Reject temporary executor markers and incomplete reserved executors."""
|
||||
|
||||
violations: list[Violation] = []
|
||||
executor_root = root / "kb-lib/src/executor"
|
||||
forbidden = (
|
||||
"MIGRATION_BOUNDARIES",
|
||||
"LEGACY_CRATE",
|
||||
"MIGRATION_STATUS",
|
||||
"source-preserved-pending-port",
|
||||
)
|
||||
struct_pattern = re.compile(r"^pub struct (Ex[A-Za-z0-9]+Executor);$", re.MULTILINE)
|
||||
reserved_count = 0
|
||||
for path in sorted(executor_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_EX001",
|
||||
relative,
|
||||
text[:offset].count("\n") + 1,
|
||||
f"temporary executor migration marker `{marker}` is forbidden",
|
||||
)
|
||||
)
|
||||
if "\n//! Reserved executor for `" not in text:
|
||||
continue
|
||||
reserved_count += 1
|
||||
struct_match = struct_pattern.search(text)
|
||||
if struct_match is None:
|
||||
violations.append(
|
||||
Violation(
|
||||
"KH_EX002",
|
||||
relative,
|
||||
1,
|
||||
"reserved executor must expose one `Ex*Executor` unit struct",
|
||||
)
|
||||
)
|
||||
continue
|
||||
type_name = struct_match.group(1)
|
||||
implementation = f"impl crate::ExApiInstructionExecutor for crate::{type_name} {{"
|
||||
if implementation not in text:
|
||||
violations.append(
|
||||
Violation(
|
||||
"KH_EX003",
|
||||
relative,
|
||||
text[: struct_match.start()].count("\n") + 1,
|
||||
f"`{type_name}` must implement `ExApiInstructionExecutor`",
|
||||
)
|
||||
)
|
||||
if "fn program_ids(&self) -> &'static [&'static str]" not in text:
|
||||
violations.append(
|
||||
Violation(
|
||||
"KH_EX004",
|
||||
relative,
|
||||
1,
|
||||
"reserved executor must declare its exact Program ID boundary",
|
||||
)
|
||||
)
|
||||
if "crate::ExApiExecutionSupport::Maybe" not in text:
|
||||
violations.append(
|
||||
Violation(
|
||||
"KH_EX005",
|
||||
relative,
|
||||
1,
|
||||
"reserved executor must remain explicitly `Maybe` until implemented",
|
||||
)
|
||||
)
|
||||
if '"status":"reserved_executor"' not in text or "instruction_count: 0" not in text:
|
||||
violations.append(
|
||||
Violation(
|
||||
"KH_EX006",
|
||||
relative,
|
||||
1,
|
||||
"reserved executor must build only an explicit zero-instruction plan",
|
||||
)
|
||||
)
|
||||
if reserved_count != 104:
|
||||
violations.append(
|
||||
Violation(
|
||||
"KH_EX007",
|
||||
"kb-lib/src/executor",
|
||||
1,
|
||||
f"expected 104 reserved executor boundaries, found {reserved_count}",
|
||||
)
|
||||
)
|
||||
return violations
|
||||
|
||||
|
||||
def audit_token2022_naming(root: pathlib.Path) -> list[Violation]:
|
||||
"""Reject obsolete internal Token2022 spellings while preserving legacy evidence."""
|
||||
|
||||
@@ -503,6 +594,7 @@ def main() -> int:
|
||||
+ audit_kb_lib_symbol_prefixes(root)
|
||||
+ audit_reserved_decoder_scaffolds(root)
|
||||
+ audit_reserved_materializer_scaffolds(root)
|
||||
+ audit_reserved_executor_scaffolds(root)
|
||||
+ audit_token2022_naming(root)
|
||||
+ audit_private_kb_lib_paths_in_active_docs(root)
|
||||
+ audit_solana_types(root)
|
||||
|
||||
Reference in New Issue
Block a user