v0.1.0-pre.006
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
# file: scripts/audit_khadhroony_workspace_rules.py
|
||||
# version: 2
|
||||
# version: 3
|
||||
|
||||
"""Audit mechanically verifiable rules specific to khadhroony-bot3."""
|
||||
|
||||
@@ -161,6 +161,69 @@ def audit_solana_types(root: pathlib.Path) -> list[Violation]:
|
||||
return violations
|
||||
|
||||
|
||||
def audit_wincode_resolution(root: pathlib.Path) -> list[Violation]:
|
||||
"""Require the currently compatible Solana wincode dependency family."""
|
||||
|
||||
violations: list[Violation] = []
|
||||
cargo_path = root / "Cargo.toml"
|
||||
lock_path = root / "Cargo.lock"
|
||||
if not cargo_path.exists():
|
||||
return violations
|
||||
cargo = tomllib.loads(cargo_path.read_text(encoding="utf-8"))
|
||||
workspace_wincode = cargo.get("workspace", {}).get("dependencies", {}).get("wincode")
|
||||
version = workspace_wincode.get("version") if isinstance(workspace_wincode, dict) else None
|
||||
if version != "^0.5":
|
||||
violations.append(
|
||||
Violation(
|
||||
"KH_DEP001",
|
||||
"Cargo.toml",
|
||||
1,
|
||||
"workspace wincode must remain constrained to `^0.5`",
|
||||
)
|
||||
)
|
||||
if not lock_path.exists():
|
||||
violations.append(
|
||||
Violation(
|
||||
"KH_DEP002",
|
||||
"Cargo.lock",
|
||||
1,
|
||||
"versioned application workspace lockfile is required",
|
||||
)
|
||||
)
|
||||
return violations
|
||||
lock = tomllib.loads(lock_path.read_text(encoding="utf-8"))
|
||||
packages = lock.get("package", [])
|
||||
resolved_wincode = [
|
||||
package.get("version")
|
||||
for package in packages
|
||||
if package.get("name") == "wincode"
|
||||
]
|
||||
resolved_varint = [
|
||||
package.get("version")
|
||||
for package in packages
|
||||
if package.get("name") == "solana-wincode-varint"
|
||||
]
|
||||
if resolved_wincode != ["0.5.5"]:
|
||||
violations.append(
|
||||
Violation(
|
||||
"KH_DEP003",
|
||||
"Cargo.lock",
|
||||
1,
|
||||
f"expected only wincode 0.5.5, resolved {resolved_wincode}",
|
||||
)
|
||||
)
|
||||
if resolved_varint != ["1.0.0"]:
|
||||
violations.append(
|
||||
Violation(
|
||||
"KH_DEP004",
|
||||
"Cargo.lock",
|
||||
1,
|
||||
f"expected only solana-wincode-varint 1.0.0, resolved {resolved_varint}",
|
||||
)
|
||||
)
|
||||
return violations
|
||||
|
||||
|
||||
def main() -> int:
|
||||
"""Run the khadhroony-specific audit."""
|
||||
|
||||
@@ -169,7 +232,12 @@ def main() -> int:
|
||||
parser.add_argument("--report-only", action="store_true")
|
||||
arguments = parser.parse_args()
|
||||
root = pathlib.Path(arguments.root).resolve()
|
||||
violations = audit_tracing(root) + audit_kb_lib_tracing(root) + audit_solana_types(root)
|
||||
violations = (
|
||||
audit_tracing(root)
|
||||
+ audit_kb_lib_tracing(root)
|
||||
+ audit_solana_types(root)
|
||||
+ audit_wincode_resolution(root)
|
||||
)
|
||||
violations.sort(key=lambda item: (item.code, item.path, item.line, item.message))
|
||||
if not violations:
|
||||
sys.stdout.write("Khadhroony workspace rule audit: clean\n")
|
||||
|
||||
Reference in New Issue
Block a user