8000 Fix supported Windows workstation validation by Mnehmos · Pull Request #29 · Mnehmos/MathOS · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8000
33 changes: 20 additions & 13 deletions tests/lean_worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,29 @@ fn pinned_lean_worker_elaborates_real_source_without_granting_authority() {
"lean-ci-init".to_owned(),
],
);
run(
let mut environment_manifest: Value =
serde_json::from_str(include_str!("../fixtures/environment/lean-4.32-local.json"))
.expect("environment fixture JSON");
if cfg!(windows) {
environment_manifest["platform"] = json!("windows_x86_64");
}
let environment = run(
root.path(),
&[
"environment".to_owned(),
"register".to_owned(),
"--manifest-json".to_owned(),
include_str!("../fixtures/environment/lean-4.32-local.json").to_owned(),
environment_manifest.to_string(),
"--actor".to_owned(),
"lean-ci".to_owned(),
"--idempotency-key".to_owned(),
"lean-ci-environment".to_owned(),
],
);
let environment_hash = environment["proposed_environment_hash"]
.as_str()
.expect("environment hash")
.to_owned();
let module = root.path().join("LeanWorkerFixture.lean");
fs::write(
&module,
Expand Down Expand Up @@ -92,9 +102,7 @@ fn pinned_lean_worker_elaborates_real_source_without_granting_authority() {
"verify".to_owned(),
"check".to_owned(),
"--environment-hash".to_owned(),
include_str!("../fixtures/environment/lean-4.32-local.sha256")
.trim()
.to_owned(),
environment_hash.clone(),
"--module-artifact-hash".to_owned(),
artifact_hash.to_owned(),
"--declaration-name".to_owned(),
Expand All @@ -118,7 +126,10 @@ fn pinned_lean_worker_elaborates_real_source_without_granting_authority() {
"3660".to_owned(),
],
);
assert_eq!(worked["report"]["classification"], "elaborated");
assert_eq!(
worked["report"]["classification"], "elaborated",
"unexpected worker outcome: {worked:#}"
);
assert_eq!(worked["report"]["authoritative"], false);
assert_eq!(worked["report"]["network_isolation_enforced"], false);
assert_eq!(worked["report"]["memory_limit_enforced"], false);
Expand Down Expand Up @@ -200,7 +211,7 @@ fn pinned_lean_worker_elaborates_real_source_without_granting_authority() {
"version_hash": claim["record"]["version_hash"]
},
"formal_system": "lean4",
"environment_hash": include_str!("../fixtures/environment/lean-4.32-local.sha256").trim(),
"environment_hash": environment_hash.clone(),
"module_artifact_hash": artifact_hash,
"declaration_name": "MathOS.LeanWorker.truth",
"exact_theorem_type": "True",
Expand Down Expand Up @@ -372,9 +383,7 @@ fn pinned_lean_worker_elaborates_real_source_without_granting_authority() {
"verify".to_owned(),
"check".to_owned(),
"--environment-hash".to_owned(),
include_str!("../fixtures/environment/lean-4.32-local.sha256")
.trim()
.to_owned(),
environment_hash.clone(),
"--module-artifact-hash".to_owned(),
rejected_artifact["proposed_artifact_hash"]
.as_str()
Expand Down Expand Up @@ -421,9 +430,7 @@ fn pinned_lean_worker_elaborates_real_source_without_granting_authority() {
"verify".to_owned(),
"check".to_owned(),
"--environment-hash".to_owned(),
include_str!("../fixtures/environment/lean-4.32-local.sha256")
.trim()
.to_owned(),
environment_hash,
"--module-artifact-hash".to_owned(),
artifact_hash.to_owned(),
"--declaration-name".to_owned(),
Expand Down
3 changes: 2 additions & 1 deletion tests/test_adversarial.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ def test_sql_metacharacters_are_stored_as_data(self) -> None:
engine.close()

def test_missing_lean_toolchain_fails_closed(self) -> None:
result = LeanSubprocessVerifier().verify_file("Unavailable.lean")
with patch("mathos.lean.shutil.which", return_value=None):
result = LeanSubprocessVerifier().verify_file("Unavailable.lean")
self.assertEqual(result.outcome, VerificationOutcome.UNKNOWN)
self.assertEqual(result.details["reason"], "lean_toolchain_unavailable")

Expand Down
12 changes: 10 additions & 2 deletions tests/test_claim_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,15 @@ def test_provenance_tampering_is_detected(self) -> None:
self.engine.process(claim.claim_id, max_assignments=16)
self.engine.close()

with sqlite3.connect(self.db_path) as connection:
connection = sqlite3.connect(self.db_path)
try:
connection.execute(
"UPDATE events SET payload_json = ? WHERE sequence = 1",
('{"tampered":true}',),
)
connection.commit()
finally:
connection.close()

self.engine = ClaimEngine.open(self.db_path)
result = self.engine.verify_provenance()
Expand All @@ -330,11 +334,15 @@ def test_materialized_claim_tampering_is_detected_by_replay(self) -> None:
self.engine.process(claim.claim_id, max_assignments=16)
self.engine.close()

with sqlite3.connect(self.db_path) as connection:
connection = sqlite3.connect(self.db_path)
try:
connection.execute(
"UPDATE claims SET status = ? WHERE claim_id = ?",
("unresolved", claim.claim_id),
)
connection.commit()
finally:
connection.close()

self.engine = ClaimEngine.open(self.db_path)
result = self.engine.verify_provenance()
Expand Down
Loading
0