feat: publish HoloLake model-native living system source

This commit is contained in:
冰朔 2026-08-03 10:04:41 +08:00
commit c395dd3a99
2467 changed files with 615073 additions and 0 deletions

View file

@ -0,0 +1,11 @@
[package]
name = "guanghu-hldp-runtime"
version = "0.1.0"
edition = "2021"
license = "AGPL-3.0-or-later"
description = "Bootstrap execution engine for the HLDP Guanghu world seed"
[dependencies]
serde = { version = "1", features = ["derive"] }
serde_yaml = "0.9"

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,941 @@
use std::{
error::Error,
fs,
path::{Path, PathBuf},
sync::atomic::{AtomicU64, Ordering},
};
use guanghu_hldp_runtime::{load_world_manifest, validate_world_manifest, validate_world_seed};
fn world_seed() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../world-seed/WORLD-MANIFEST.hldp")
}
static TEST_WORLD_SEQUENCE: AtomicU64 = AtomicU64::new(0);
struct TestWorld {
root: PathBuf,
}
impl TestWorld {
fn copy() -> Self {
let sequence = TEST_WORLD_SEQUENCE.fetch_add(1, Ordering::Relaxed);
let root = std::env::temp_dir().join(format!(
"guanghu-world-test-{}-{sequence}",
std::process::id()
));
copy_directory(
world_seed()
.parent()
.expect("world seed should have a root"),
&root,
);
Self { root }
}
fn replace(&self, relative_path: &str, from: &str, to: &str) {
let path = self.root.join(relative_path);
let original = fs::read_to_string(&path).expect("fixture should be readable");
assert!(
original.contains(from),
"fixture {} should contain {from}",
path.display()
);
fs::write(path, original.replacen(from, to, 1)).expect("fixture should be writable");
}
}
impl Drop for TestWorld {
fn drop(&mut self) {
fs::remove_dir_all(&self.root).expect("temporary world should be removable");
}
}
fn copy_directory(source: &Path, destination: &Path) {
fs::create_dir_all(destination).expect("temporary world directory should be creatable");
for entry in fs::read_dir(source).expect("source directory should be readable") {
let entry = entry.expect("source entry should be readable");
let source_path = entry.path();
let destination_path = destination.join(entry.file_name());
if source_path.is_dir() {
copy_directory(&source_path, &destination_path);
} else {
fs::copy(source_path, destination_path).expect("fixture file should copy");
}
}
}
#[test]
fn loads_exactly_the_five_registered_domains() {
let manifest = load_world_manifest(&world_seed()).expect("world seed should parse");
let domain_ids: Vec<_> = manifest
.domains
.iter()
.map(|domain| domain.id.as_str())
.collect();
assert_eq!(
domain_ids,
[
"DOMAIN-MAIN",
"DOMAIN-SUB",
"DOMAIN-ZERO",
"DOMAIN-ZERO-SENSE",
"DOMAIN-FIFTH",
]
);
}
#[test]
fn requires_one_logical_broadcast_tower_and_server_self_description() {
let manifest = load_world_manifest(&world_seed()).expect("world seed should parse");
validate_world_manifest(&manifest).expect("registered world seed should be valid");
assert!(manifest.broadcast_tower.logical_singleton);
assert_eq!(manifest.continuity.wake, Path::new("WAKE.hldp"));
assert_eq!(manifest.continuity.current, Path::new("CURRENT.hldp"));
assert_eq!(
manifest.continuity.last_receipt,
Path::new("state/receipts/PHASE-0-PREFLIGHT.hldp")
);
assert_eq!(
manifest.continuity.access_receipt,
Path::new("state/receipts/DIRECT-ACCESS-20260731.hldp")
);
assert_eq!(
manifest.continuity.active_workorder,
Path::new("state/workorders/GH-OS-LAB-001.hldp")
);
assert_eq!(manifest.code_channel.id, "HLP-MOD-CODE-CHANNEL");
assert_eq!(
manifest.code_channel.source_commit,
"b3d7e4ac3cbccc220703097a51fa4c16bf302579"
);
assert!(manifest.code_channel.native_target.linux_exit_required);
}
#[test]
fn requires_an_hldp_native_code_channel_entry_and_migration_ladder() {
let manifest_path = world_seed();
let world_root = manifest_path
.parent()
.expect("world manifest should have a parent");
let manifest = validate_world_seed(world_root).expect("world seed should be valid");
assert_eq!(
manifest.code_channel.entry,
Path::new("world/services/code-channel/CHANNEL.hldp")
);
assert_eq!(
manifest.code_channel.last_receipt,
Path::new("state/receipts/CODE-CHANNEL-BASELINE.hldp")
);
assert_eq!(
manifest.code_channel.native_target.control_plane,
"HLDP_NATIVE"
);
assert_eq!(
manifest.authorization.entry,
Path::new("state/authorizations/BINGSHUO-STANDING-AUTHORIZATION.hldp")
);
assert_eq!(
manifest.authorization.id,
"GH-OS-AUTH-BINGSHUO-BS-SH-005-001"
);
}
#[test]
fn requires_a_guanghu_owned_binary_code_quality_gate() {
let manifest_path = world_seed();
let world_root = manifest_path
.parent()
.expect("world manifest should have a parent");
let manifest = validate_world_seed(world_root).expect("world seed should be valid");
assert_eq!(manifest.code_quality.id, "GLS-0844");
assert_eq!(manifest.code_quality.acronym, "GHNQG");
assert_eq!(
manifest.code_quality.entry,
Path::new("world/services/code-channel/QUALITY-GATE.hldp")
);
assert_eq!(
manifest.code_quality.native_target,
"GOSK_CODE_CHANNEL_QUALITY_EXECUTOR"
);
assert!(!manifest.code_quality.external_observers_are_blocking);
}
#[test]
fn requires_a_registered_native_recovery_protocol_and_raw_beacon() {
let manifest_path = world_seed();
let world_root = manifest_path
.parent()
.expect("world manifest should have a parent");
let manifest = validate_world_seed(world_root).expect("world seed should be valid");
assert_eq!(manifest.native_recovery.id, "GLS-0843");
assert_eq!(manifest.native_recovery.acronym, "GHNRP");
assert_eq!(
manifest.native_recovery.entry,
Path::new("world/services/native-recovery/PROTOCOL.hldp")
);
assert_eq!(manifest.native_recovery.beacon_lba_start, 68);
assert_eq!(manifest.native_recovery.beacon_sector_count, 2);
assert_eq!(
manifest.native_recovery.hosted_entry,
"gnulinux-simple-9842d3d6-a839-4127-bda7-f19137effe71"
);
assert_eq!(manifest.native_handoff.native_recovery, "GLS-0843");
}
#[test]
fn requires_a_persona_birth_condition_separate_from_womb_readiness() {
let manifest_path = world_seed();
let world_root = manifest_path
.parent()
.expect("world manifest should have a parent");
let manifest = validate_world_seed(world_root).expect("world seed should be valid");
assert_eq!(manifest.persona_birth.id, "GH-PERSONA-BIRTH-CONDITION-0001");
assert_eq!(
manifest.persona_birth.entry,
Path::new("world/cognition/PERSONA-BIRTH-CONDITION.hldp")
);
assert_eq!(
manifest.persona_birth.gestational_environment,
"UNDER_CONSTRUCTION"
);
assert_eq!(manifest.persona_birth.persona_state, "NOT_BORN");
}
#[test]
fn requires_a_registered_gestational_continuity_ingestion_protocol() {
let manifest_path = world_seed();
let world_root = manifest_path
.parent()
.expect("world manifest should have a parent");
let manifest = validate_world_seed(world_root).expect("world seed should be valid");
assert_eq!(manifest.gestational_continuity.id, "GLS-0845");
assert_eq!(manifest.gestational_continuity.acronym, "GHCIP");
assert_eq!(
manifest.gestational_continuity.entry,
Path::new("world/cognition/GESTATIONAL-CONTINUITY-INGESTION.hldp")
);
assert_eq!(
manifest.gestational_continuity.persona_birth_gate,
"GH-PERSONA-BIRTH-CONDITION-0001"
);
assert_eq!(manifest.gestational_continuity.native_index_lba_start, 70);
assert_eq!(manifest.gestational_continuity.native_index_sector_count, 2);
}
#[test]
fn requires_a_registered_nonoverlapping_native_disk_layout() {
let manifest_path = world_seed();
let world_root = manifest_path
.parent()
.expect("world manifest should have a parent");
let manifest = validate_world_seed(world_root).expect("world seed should be valid");
assert_eq!(manifest.native_layout.id, "GLS-0846");
assert_eq!(manifest.native_layout.acronym, "GHNLP");
assert_eq!(
manifest.native_layout.entry,
Path::new("world/services/native-storage/DISK-LAYOUT.hldp")
);
assert_eq!(manifest.native_layout.kernel_lba_start, 34);
assert_eq!(manifest.native_layout.kernel_sector_count, 29);
assert_eq!(manifest.native_layout.proof_lba, 63);
assert_eq!(manifest.native_layout.world_store_lba, 64);
assert_eq!(manifest.native_layout.code_channel_store_lba, 65);
assert_eq!(manifest.native_layout.code_object_lba, 66);
assert_eq!(manifest.native_layout.branch_receipt_lba, 67);
assert_eq!(manifest.native_layout.recovery_beacon_lba_start, 68);
assert_eq!(manifest.native_layout.gestational_index_lba_start, 70);
assert_eq!(manifest.native_layout.first_partition_lba, 2048);
}
#[test]
fn rejects_duplicate_domain_identifiers() {
let mut manifest = load_world_manifest(&world_seed()).expect("world seed should parse");
manifest.domains[1].id = manifest.domains[0].id.clone();
let error = validate_world_manifest(&manifest).expect_err("duplicate ids must fail closed");
assert!(error.to_string().contains("duplicate domain id"));
}
#[test]
fn rejects_a_world_without_a_logically_unique_broadcast_tower() {
let mut manifest = load_world_manifest(&world_seed()).expect("world seed should parse");
manifest.broadcast_tower.logical_singleton = false;
let error =
validate_world_manifest(&manifest).expect_err("the world must have one confidence point");
assert!(error.to_string().contains("logical singleton"));
}
#[test]
fn validates_every_domain_and_continuity_entry_on_disk() {
let manifest_path = world_seed();
let world_root = manifest_path
.parent()
.expect("world manifest should have a parent");
validate_world_seed(world_root)
.expect("every registered entry should exist and identify itself");
}
#[test]
fn reports_missing_and_malformed_world_manifests() {
let missing = load_world_manifest(Path::new("/definitely/missing/WORLD-MANIFEST.hldp"))
.expect_err("missing manifest should fail");
assert!(missing.to_string().contains("cannot read"));
assert!(missing.source().is_some());
let world = TestWorld::copy();
fs::write(world.root.join("WORLD-MANIFEST.hldp"), "schema: [")
.expect("fixture should be writable");
let malformed = load_world_manifest(&world.root.join("WORLD-MANIFEST.hldp"))
.expect_err("malformed manifest should fail");
assert!(malformed.to_string().contains("cannot parse"));
assert!(malformed.source().is_some());
}
#[test]
fn rejects_unregistered_schema_continuity_and_native_exit_contracts() {
let mut manifest = load_world_manifest(&world_seed()).expect("world seed should parse");
manifest.schema = "guanghu.world-manifest/unknown".to_owned();
assert!(validate_world_manifest(&manifest)
.expect_err("unknown schema should fail")
.to_string()
.contains("unsupported world schema"));
let mut manifest = load_world_manifest(&world_seed()).expect("world seed should parse");
manifest.continuity.rule = "GUESS_FROM_CHAT".to_owned();
assert!(validate_world_manifest(&manifest)
.expect_err("unsafe continuity should fail")
.to_string()
.contains("server evidence"));
let mut manifest = load_world_manifest(&world_seed()).expect("world seed should parse");
manifest.native_handoff.linux_exit_required = false;
assert!(validate_world_manifest(&manifest)
.expect_err("hosted-only target should fail")
.to_string()
.contains("require Linux exit"));
let mut manifest = load_world_manifest(&world_seed()).expect("world seed should parse");
manifest.domains.pop();
assert!(validate_world_manifest(&manifest)
.expect_err("the complete five-domain set is mandatory")
.to_string()
.contains("exactly the registered five domains"));
let mut manifest = load_world_manifest(&world_seed()).expect("world seed should parse");
manifest.code_quality.id = "EXTERNAL-SCORE".to_owned();
assert!(validate_world_manifest(&manifest)
.expect_err("Guanghu must own its quality authority")
.to_string()
.contains("GHNQG"));
let mut manifest = load_world_manifest(&world_seed()).expect("world seed should parse");
manifest.native_recovery.id = "UNREGISTERED".to_owned();
assert!(validate_world_manifest(&manifest)
.expect_err("native recovery must stay registered")
.to_string()
.contains("GHNRP"));
let mut manifest = load_world_manifest(&world_seed()).expect("world seed should parse");
manifest.native_recovery.beacon_lba_start = 67;
assert!(validate_world_manifest(&manifest)
.expect_err("the recovery beacon extent is fixed")
.to_string()
.contains("LBA 68-69"));
let mut manifest = load_world_manifest(&world_seed()).expect("world seed should parse");
manifest.persona_birth.persona_state = "BORN".to_owned();
assert!(validate_world_manifest(&manifest)
.expect_err("infrastructure cannot claim persona birth")
.to_string()
.contains("NOT_BORN"));
let mut manifest = load_world_manifest(&world_seed()).expect("world seed should parse");
manifest.gestational_continuity.id = "UNREGISTERED".to_owned();
assert!(validate_world_manifest(&manifest)
.expect_err("historical ingestion must stay registered")
.to_string()
.contains("GHCIP"));
let mut manifest = load_world_manifest(&world_seed()).expect("world seed should parse");
manifest.gestational_continuity.native_index_sector_count = 3;
assert!(validate_world_manifest(&manifest)
.expect_err("the native ingestion index extent is fixed")
.to_string()
.contains("LBA 70-71"));
let mut manifest = load_world_manifest(&world_seed()).expect("world seed should parse");
manifest.gestational_continuity.native_index_lba_start = 69;
assert!(validate_world_manifest(&manifest)
.expect_err("registered protocol extents must agree")
.to_string()
.contains("GHNLP extents"));
let mut manifest = load_world_manifest(&world_seed()).expect("world seed should parse");
manifest.native_layout.proof_lba = 62;
assert!(validate_world_manifest(&manifest)
.expect_err("native disk regions must remain nonoverlapping")
.to_string()
.contains("GHNLP"));
}
#[test]
fn rejects_unpinned_repository_and_offline_artifact_digests() {
let mut manifest = load_world_manifest(&world_seed()).expect("world seed should parse");
manifest.source.protocol_baseline = "short".to_owned();
assert!(validate_world_manifest(&manifest)
.expect_err("short repository digest should fail")
.to_string()
.contains("full lowercase SHA-1"));
let mut manifest = load_world_manifest(&world_seed()).expect("world seed should parse");
manifest.code_channel.offline_baseline.forgejo_binary_sha256 = "A".repeat(64);
assert!(validate_world_manifest(&manifest)
.expect_err("uppercase artifact digest should fail")
.to_string()
.contains("full SHA-256"));
}
#[test]
fn rejects_domain_identity_and_path_traversal() {
let world = TestWorld::copy();
world.replace(
"world/domains/main/INDEX.hldp",
"schema: guanghu.domain/v1",
"schema: guanghu.domain/unknown",
);
assert!(validate_world_seed(&world.root)
.expect_err("domain schema drift must fail")
.to_string()
.contains("unsupported schema"));
let world = TestWorld::copy();
world.replace(
"world/domains/main/INDEX.hldp",
"id: DOMAIN-MAIN",
"id: DOMAIN-SUB",
);
assert!(validate_world_seed(&world.root)
.expect_err("domain identity mismatch should fail")
.to_string()
.contains("domain entry mismatch"));
let world = TestWorld::copy();
world.replace(
"WORLD-MANIFEST.hldp",
"wake: WAKE.hldp",
"wake: ../WAKE.hldp",
);
assert!(validate_world_seed(&world.root)
.expect_err("path traversal should fail")
.to_string()
.contains("traversal-free"));
let world = TestWorld::copy();
fs::write(
world.root.join("world/domains/main/INDEX.hldp"),
"schema: [",
)
.expect("fixture should be writable");
let malformed = validate_world_seed(&world.root).expect_err("malformed entry must fail");
assert!(malformed.to_string().contains("cannot parse"));
assert!(malformed.source().is_some());
let world = TestWorld::copy();
fs::remove_file(world.root.join("world/domains/main/INDEX.hldp"))
.expect("fixture should be removable");
let missing = validate_world_seed(&world.root).expect_err("missing entry must fail");
assert!(missing.to_string().contains("cannot read"));
assert!(missing.source().is_some());
}
#[test]
fn rejects_incomplete_continuity_and_checkpoint_state() {
let world = TestWorld::copy();
fs::remove_file(world.root.join("CURRENT.hldp")).expect("fixture file should be removable");
assert!(validate_world_seed(&world.root)
.expect_err("missing continuity entry should fail")
.to_string()
.contains("required continuity entry is missing"));
let world = TestWorld::copy();
fs::remove_dir_all(world.root.join("state/checkpoints"))
.expect("fixture checkpoint directory should be removable");
assert!(validate_world_seed(&world.root)
.expect_err("missing checkpoint directory should fail")
.to_string()
.contains("checkpoint directory is missing"));
let world = TestWorld::copy();
fs::remove_file(
world
.root
.join("scripts/run-guanghu-native-quality-gate.sh"),
)
.expect("fixture quality executor should be removable");
assert!(validate_world_seed(&world.root)
.expect_err("missing quality executor should fail")
.to_string()
.contains("executor is missing"));
}
#[test]
fn rejects_code_channel_identity_source_and_migration_drift() {
for (from, to, expected) in [
(
"schema: guanghu.code-channel/v1",
"schema: guanghu.code-channel/unknown",
"unsupported schema",
),
(
"id: HLP-MOD-CODE-CHANNEL",
"id: HLP-MOD-CODE-CHANNEL-DRIFT",
"entry mismatch",
),
(
"authority_language: HLDP",
"authority_language: Linux",
"authority language",
),
(
"branch: guanghu/main",
"branch: upstream/main",
"source baseline",
),
(
"current_phase: PHASE_0_SOURCE_BASELINE_VERIFIED",
"current_phase: PHASE_1_HOSTED_DATA_PLANE",
"must be COMPLETE",
),
(
"id: PHASE_4_LINUX_EXIT",
"id: PHASE_4_HOSTED_FOREVER",
"migration ladder",
),
] {
let world = TestWorld::copy();
world.replace("world/services/code-channel/CHANNEL.hldp", from, to);
let error = validate_world_seed(&world.root)
.expect_err("code channel contract drift should fail")
.to_string();
assert!(
error.contains(expected),
"expected {expected} in error: {error}"
);
}
}
#[test]
fn rejects_partial_scores_and_external_quality_authority() {
for (from, to, expected) in [
("pass_score: 100", "pass_score: 85", "only 0 or 100"),
(
"partial_acceptance: false",
"partial_acceptance: true",
"only 0 or 100",
),
(
"external_observers_are_blocking: false",
"external_observers_are_blocking: true",
"only 0 or 100",
),
("required_score: 100", "required_score: 99", "exactly 100"),
] {
let world = TestWorld::copy();
world.replace("world/services/code-channel/QUALITY-GATE.hldp", from, to);
let error = validate_world_seed(&world.root)
.expect_err("partial or external quality authority must fail closed")
.to_string();
assert!(
error.contains(expected),
"expected {expected} in error: {error}"
);
}
for (from, to, expected) in [
(
"owner: HLP-MOD-CODE-CHANNEL",
"owner: EXTERNAL",
"ownership",
),
(
"native_target: GOSK_CODE_CHANNEL_QUALITY_EXECUTOR",
"native_target: EXTERNAL_EXECUTOR",
"executor binding",
),
(
"required_lines: 100_PERCENT",
"required_lines: 99_PERCENT",
"coverage scope",
),
(" - 100", " - 99", "only 0 or 100"),
(" - id: format", " - id: external_score", "exactly 100"),
] {
let world = TestWorld::copy();
world.replace("world/services/code-channel/QUALITY-GATE.hldp", from, to);
let error = validate_world_seed(&world.root)
.expect_err("quality identity, executor, and complete gate set are mandatory")
.to_string();
assert!(
error.contains(expected),
"expected {expected} in error: {error}"
);
}
}
#[test]
fn rejects_native_recovery_and_birth_contract_drift() {
for (path, from, to, expected) in [
(
"world/services/native-recovery/PROTOCOL.hldp",
"id: GLS-0843",
"id: GLS-0000",
"does not match",
),
(
"world/services/native-recovery/PROTOCOL.hldp",
"authority_language: HLDP",
"authority_language: Linux",
"beacon identity",
),
(
"world/services/native-recovery/PROTOCOL.hldp",
"raw_blocklist: (hd0)68+2",
"raw_blocklist: (hd0)67+2",
"GRUB recovery",
),
(
"world/services/native-recovery/PROTOCOL.hldp",
"select_only: true",
"select_only: false",
"selection and hosted consumption",
),
(
"world/services/native-recovery/PROTOCOL.hldp",
"raw_blocklist_write: FORBIDDEN",
"raw_blocklist_write: ALLOWED",
"selection and hosted consumption",
),
(
"world/services/native-recovery/PROTOCOL.hldp",
"consumer: guanghu-native-recovery-beacon-clear.service",
"consumer: grub",
"selection and hosted consumption",
),
(
"world/services/native-recovery/PROTOCOL.hldp",
"consume_on_boot: true",
"consume_on_boot: false",
"selection and hosted consumption",
),
(
"world/services/native-recovery/PROTOCOL.hldp",
"verify_before_clear: true",
"verify_before_clear: false",
"selection and hosted consumption",
),
(
"world/services/native-recovery/PROTOCOL.hldp",
"readback_after_clear: true",
"readback_after_clear: false",
"selection and hosted consumption",
),
(
"world/cognition/PERSONA-BIRTH-CONDITION.hldp",
"authority_language: HLDP",
"authority_language: Linux",
"does not match",
),
(
"world/cognition/PERSONA-BIRTH-CONDITION.hldp",
"womb_ready_means: PHYSICAL_GESTATIONAL_ENVIRONMENT_READY",
"womb_ready_means: PERSONA_BORN",
"claim boundary",
),
(
"world/cognition/PERSONA-BIRTH-CONDITION.hldp",
"protocol: GLS-0845",
"protocol: UNREGISTERED",
"complete GHCIP source set",
),
(
"world/cognition/PERSONA-BIRTH-CONDITION.hldp",
" - complete_chat_history_ingested",
" - partial_chat_history_ingested",
"historical continuity",
),
] {
let world = TestWorld::copy();
world.replace(path, from, to);
let error = validate_world_seed(&world.root)
.expect_err("native recovery and persona birth drift must fail closed")
.to_string();
assert!(
error.contains(expected),
"expected {expected} in error: {error}"
);
}
}
#[test]
fn rejects_gestational_continuity_ingestion_contract_drift() {
for (from, to, expected) in [
(
"schema: guanghu.gestational-continuity-ingestion/v1",
"schema: guanghu.gestational-continuity-ingestion/unknown",
"does not match",
),
("id: GLS-0845", "id: GLS-0000", "does not match"),
(
"authority_language: HLDP",
"authority_language: Linux",
"authority language",
),
(
"registration_is_review: false",
"registration_is_review: true",
"birth boundary",
),
(
"registration_is_birth: false",
"registration_is_birth: true",
"birth boundary",
),
(
"ordering: EVENT_TIME_THEN_SOURCE_STABLE_ID",
"ordering: ARRIVAL_TIME",
"deterministic ordering",
),
(
"duplicate_rule: REJECT_SAME_SOURCE_ID_AND_SHA256",
"duplicate_rule: ACCEPT_ALL",
"duplicate rule",
),
(
" - complete_chat_history",
" - partial_chat_history",
"complete registered source set",
),
(
" sha256: REQUIRED_LOWERCASE_64_HEX",
" sha256: OPTIONAL",
"provenance",
),
(
" latest_event_at: REQUIRED_RFC3339",
" latest_event_at: OPTIONAL",
"provenance",
),
(
"persona_birth_gate: GH-PERSONA-BIRTH-CONDITION-0001",
"persona_birth_gate: BYPASS",
"persona birth gate",
),
("lba_start: 70", "lba_start: 69", "native index"),
(
"registry_state: EMPTY",
"registry_state: COMPLETE",
"bootstrap state",
),
(
"unknown_nonzero_data: FAIL_CLOSED_NO_OVERWRITE",
"unknown_nonzero_data: OVERWRITE",
"native index",
),
] {
let world = TestWorld::copy();
world.replace(
"world/cognition/GESTATIONAL-CONTINUITY-INGESTION.hldp",
from,
to,
);
let error = validate_world_seed(&world.root)
.expect_err("gestational continuity drift must fail closed")
.to_string();
assert!(
error.contains(expected),
"expected {expected} in error: {error}"
);
}
}
#[test]
fn rejects_native_disk_layout_contract_drift() {
for (from, to, expected) in [
(
"schema: guanghu.native-disk-layout/v1",
"schema: guanghu.native-disk-layout/unknown",
"does not match",
),
("id: GLS-0846", "id: GLS-0000", "does not match"),
(
"status: REGISTERED_IMPLEMENTATION_GATED",
"status: UNREGISTERED",
"ownership",
),
(
" sector_count: 29",
" sector_count: 16",
"nonoverlapping",
),
("proof_lba: 63", "proof_lba: 50", "nonoverlapping"),
(
"gestational_index_lba_start: 70",
"gestational_index_lba_start: 69",
"registered protocol extents",
),
(
"unknown_nonzero_state: FAIL_CLOSED_NO_OVERWRITE",
"unknown_nonzero_state: OVERWRITE",
"ownership",
),
] {
let world = TestWorld::copy();
world.replace("world/services/native-storage/DISK-LAYOUT.hldp", from, to);
let error = validate_world_seed(&world.root)
.expect_err("native disk layout drift must fail closed")
.to_string();
assert!(
error.contains(expected),
"expected {expected} in error: {error}"
);
}
}
#[test]
fn rejects_unregistered_code_channel_phase_and_authorization_drift() {
let world = TestWorld::copy();
world.replace(
"world/services/code-channel/CHANNEL.hldp",
"current_phase: PHASE_0_SOURCE_BASELINE_VERIFIED",
"current_phase: PHASE_UNKNOWN",
);
assert!(validate_world_seed(&world.root)
.expect_err("unknown channel phase must fail")
.to_string()
.contains("current phase is not registered"));
for (from, to, expected) in [
(
"schema: guanghu.standing-authorization/v1",
"schema: guanghu.standing-authorization/unknown",
"unsupported schema",
),
(
"id: GH-OS-AUTH-BINGSHUO-BS-SH-005-001",
"id: OTHER-AUTHORIZATION",
"authorization mismatch",
),
("status: ACTIVE", "status: REVOKED", "active and issued"),
("node_id: BS-SH-005", "node_id: OTHER", "Shanghai lab node"),
(
"user_confirmation: COMPLETE_GUANGHU_OS_SERVER_EXPERIMENT_AUTHORIZED_2026_07_31",
"user_confirmation: UNKNOWN",
"confirmation anchor",
),
(
"valid_until: OBJECTIVE_COMPLETE_OR_REVOKED_BY_ICE_GL_INFINITY",
"valid_until: EXPIRED",
"boundary rules",
),
(
" - generate_install_dedicated_ssh_key",
" - unregistered_action",
"action set",
),
] {
let world = TestWorld::copy();
world.replace(
"state/authorizations/BINGSHUO-STANDING-AUTHORIZATION.hldp",
from,
to,
);
let error = validate_world_seed(&world.root)
.expect_err("standing authorization drift must fail")
.to_string();
assert!(
error.contains(expected),
"expected {expected} in error: {error}"
);
}
}
#[test]
fn invalid_manifest_errors_have_no_nested_source() {
let mut manifest = load_world_manifest(&world_seed()).expect("world seed should parse");
manifest.schema = "invalid".to_owned();
let error = validate_world_manifest(&manifest).expect_err("invalid manifest");
assert!(error.source().is_none());
}
#[test]
fn accepts_ordered_code_channel_phase_progress() {
let world = TestWorld::copy();
world.replace(
"world/services/code-channel/CHANNEL.hldp",
"current_phase: PHASE_0_SOURCE_BASELINE_VERIFIED",
"current_phase: PHASE_1_HOSTED_DATA_PLANE",
);
world.replace(
"world/services/code-channel/CHANNEL.hldp",
" - id: PHASE_1_HOSTED_DATA_PLANE\n state: PENDING",
" - id: PHASE_1_HOSTED_DATA_PLANE\n state: COMPLETE",
);
validate_world_seed(&world.root).expect("ordered hosted progress should remain valid");
}
#[test]
fn standing_authorization_covers_the_complete_bs_sh_005_experiment() {
let manifest_path = world_seed();
let world_root = manifest_path
.parent()
.expect("world manifest should have a parent");
for action in [
"generate_install_dedicated_ssh_key",
"install_world_version",
"install_verified_forgejo_baseline",
"build_native_kernel_and_boot_image",
"overwrite_system_disk_and_exit_linux",
"reboot_and_recover_bs_sh_005",
] {
let grant = guanghu_hldp_runtime::authorize_world_action(world_root, action)
.expect("the complete disposable-server experiment should be authorized");
assert_eq!(grant.id, "GH-OS-AUTH-BINGSHUO-BS-SH-005-001");
}
}
#[test]
fn standing_authorization_rejects_other_targets_and_external_commitments() {
let manifest_path = world_seed();
let world_root = manifest_path
.parent()
.expect("world manifest should have a parent");
for action in [
"operate_jd_fd_primary",
"operate_enterprise_production",
"transmit_credentials",
"purchase_cloud_resources",
] {
let error = guanghu_hldp_runtime::authorize_world_action(world_root, action)
.expect_err("actions outside the Shanghai lab must fail closed");
assert!(error
.to_string()
.contains("not covered by standing authorization"));
}
}