v0.1.0-pre.012

This commit is contained in:
2026-07-24 15:59:00 +02:00
parent 60660ca555
commit e753a80c3a
179 changed files with 5653 additions and 10813 deletions

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env python3
# file: scripts/audit_khadhroony_workspace_rules.py
# version: 5
# version: 6
"""Audit mechanically verifiable rules specific to khadhroony-bot3."""
@@ -207,6 +207,77 @@ def audit_kb_lib_symbol_prefixes(root: pathlib.Path) -> list[Violation]:
return violations
def audit_reserved_decoder_scaffolds(root: pathlib.Path) -> list[Violation]:
"""Reject temporary decoder migration markers and incomplete reserved decoders."""
violations: list[Violation] = []
decoder_root = root / "kb-lib/src/decoder"
forbidden = (
"MIGRATION_BOUNDARIES",
"LEGACY_CRATE",
"MIGRATION_STATUS",
"source-preserved-pending-port",
)
struct_pattern = re.compile(r"^pub struct (Dc[A-Za-z0-9]+Decoder);$", re.MULTILINE)
for path in sorted(decoder_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_DC001",
relative,
text[:offset].count("\n") + 1,
f"temporary decoder migration marker `{marker}` is forbidden",
)
)
if "Reserved protocol decoder for `" not in text:
continue
struct_match = struct_pattern.search(text)
if struct_match is None:
violations.append(
Violation(
"KH_DC002",
relative,
1,
"reserved decoder must expose one `Dc*Decoder` unit struct",
)
)
continue
type_name = struct_match.group(1)
implementation = f"impl crate::DcApiProtocolDecoder for crate::{type_name} {{"
if implementation not in text:
violations.append(
Violation(
"KH_DC003",
relative,
text[: struct_match.start()].count("\n") + 1,
f"`{type_name}` must implement `DcApiProtocolDecoder`",
)
)
if "fn program_ids(&self) -> &'static [&'static str]" not in text:
violations.append(
Violation(
"KH_DC004",
relative,
1,
"reserved decoder must declare its exact Program ID boundary",
)
)
if "crate::DcApiDecoderSupport::Maybe" not in text:
violations.append(
Violation(
"KH_DC005",
relative,
1,
"reserved decoder must remain explicitly `Maybe` until implemented",
)
)
return violations
def audit_token2022_naming(root: pathlib.Path) -> list[Violation]:
"""Reject obsolete internal Token2022 spellings while preserving legacy evidence."""
@@ -242,6 +313,38 @@ def audit_token2022_naming(root: pathlib.Path) -> list[Violation]:
return violations
def audit_private_kb_lib_paths_in_active_docs(root: pathlib.Path) -> list[Violation]:
"""Reject documentation that presents private kb-lib modules as public APIs."""
violations: list[Violation] = []
candidates = [
root / "README.md",
root / "ROADMAP.md",
root / "RULES.md",
root / "kb-lib/README.md",
root / "kb-program-ids/README.md",
]
candidates.extend(sorted((root / "docs").glob("*.md")))
candidates.extend(sorted((root / "docs").glob("*.json")))
pattern = re.compile(r"kb_lib::(?:decoder|executor|materializer|model)::")
for path in candidates:
if not path.is_file():
continue
relative = path.relative_to(root).as_posix()
for index, line in enumerate(path.read_text(encoding="utf-8").splitlines(), 1):
match = pattern.search(line)
if match is not None:
violations.append(
Violation(
"KH_API001",
relative,
index,
f"private kb-lib module path `{match.group(0)}` is forbidden in active documentation",
)
)
return violations
def audit_wincode_resolution(root: pathlib.Path) -> list[Violation]:
"""Require the currently compatible Solana wincode dependency family."""
@@ -317,7 +420,9 @@ def main() -> int:
audit_tracing(root)
+ audit_kb_lib_tracing(root)
+ audit_kb_lib_symbol_prefixes(root)
+ audit_reserved_decoder_scaffolds(root)
+ audit_token2022_naming(root)
+ audit_private_kb_lib_paths_in_active_docs(root)
+ audit_solana_types(root)
+ audit_wincode_resolution(root)
)

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env python3
# file: scripts/audit_rust_general_rules.py
# version: 5
# version: 6
"""Audit mechanically verifiable Rust rules shared by all Rust projects."""
@@ -96,6 +96,7 @@ def audit_file(root: pathlib.Path, path: pathlib.Path) -> list[Violation]:
violations.append(Violation("RUST016", relative, index, "re-export aliases are forbidden"))
previous_export_line: int | None = None
previous_export_visibility: str | None = None
previous_export_path: str | None = None
blank_since_export = False
for index, line in enumerate(lines, 1):
if not line.strip():
@@ -119,12 +120,30 @@ def audit_file(root: pathlib.Path, path: pathlib.Path) -> list[Violation]:
"re-export block contains an empty line",
)
)
export_path = line.split(" use ", 1)[1]
if (
previous_export_line is not None
and previous_export_visibility == visibility
and not blank_since_export
and previous_export_path is not None
and export_path < previous_export_path
):
violations.append(
Violation(
"RUST023",
relative,
index,
"re-export block is not ordered alphabetically",
)
)
previous_export_line = index
previous_export_visibility = visibility
previous_export_path = export_path
blank_since_export = False
continue
previous_export_line = None
previous_export_visibility = None
previous_export_path = None
blank_since_export = False
if path.name in {"lib.rs", "main.rs"}:
for attribute in ("#![warn(missing_docs)]", "#![deny(unreachable_pub)]", "#![forbid(unsafe_code)]"):