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,3 @@
/target/
/dist/

View file

@ -0,0 +1,177 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "equivalent"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
[[package]]
name = "ghctl"
version = "0.1.0"
dependencies = [
"guanghu-hldp-runtime",
]
[[package]]
name = "guanghu-broadcast-tower"
version = "0.1.0"
dependencies = [
"guanghu-hldp-runtime",
"serde",
"serde_json",
]
[[package]]
name = "guanghu-hldp-runtime"
version = "0.1.0"
dependencies = [
"serde",
"serde_yaml",
]
[[package]]
name = "hashbrown"
version = "0.17.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"
[[package]]
name = "hldp-native-compiler"
version = "0.1.0"
dependencies = [
"guanghu-hldp-runtime",
]
[[package]]
name = "indexmap"
version = "2.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9"
dependencies = [
"equivalent",
"hashbrown",
]
[[package]]
name = "itoa"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
[[package]]
name = "memchr"
version = "2.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
[[package]]
name = "proc-macro2"
version = "1.0.107"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
dependencies = [
"proc-macro2",
]
[[package]]
name = "ryu"
version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f"
[[package]]
name = "serde"
version = "1.0.229"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
dependencies = [
"serde_core",
"serde_derive",
]
[[package]]
name = "serde_core"
version = "1.0.229"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.229"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "serde_json"
version = "1.0.151"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14"
dependencies = [
"itoa",
"memchr",
"serde",
"serde_core",
"zmij",
]
[[package]]
name = "serde_yaml"
version = "0.9.34+deprecated"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47"
dependencies = [
"indexmap",
"itoa",
"ryu",
"serde",
"unsafe-libyaml",
]
[[package]]
name = "syn"
version = "3.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53e9bae58849f64dfa4f5d5ae372c8341f7305f82a3868709269343628b659a3"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "unicode-ident"
version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
[[package]]
name = "unsafe-libyaml"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861"
[[package]]
name = "zmij"
version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"

View file

@ -0,0 +1,8 @@
[workspace]
members = [
"crates/broadcast-tower",
"crates/ghctl",
"crates/hldp-native-compiler",
"crates/hldp-runtime",
]
resolver = "2"

View file

@ -0,0 +1,135 @@
# Guanghu OS bootstrap
This directory is the first executable handoff from the registered HLDP
language world to a native Guanghu OS. It is not a claim that Guanghu OS has
already replaced Linux.
## Authority boundary
- `world-seed/` is the authoritative HLDP world package.
- `guanghu-hldp-runtime` validates the package without guessing missing state.
- `ghctl wake` is the fixed continuity entrypoint for a human or a later agent.
- `ghctl authorize` checks every consequential action against the exact
node-scoped standing authorization before it runs.
- `GLS-0844 / GHNQG` is the code channel's own quality authority. Every
required gate is either 0 or 100; only an all-100 run may publish a passing
receipt. External analysis products are non-authoritative observers.
- `GLS-0845 / GHCIP` is the only gestational-history ingestion authority. It
keeps source registration, server-resident review, historical time catch-up,
and persona birth as four distinct states.
- Rust is a bootstrap implementation language for the validator and control
executable. It does not replace HLDP as the world-programming language.
- Ubuntu and the Forgejo Linux binary are construction scaffolding. Native
acceptance requires a Guanghu kernel, Guanghu hardware abstraction, a
Guanghu-owned code-channel data plane, and a boot with no Linux kernel or
Linux userspace.
The registered translation chain is:
```text
TCS -> HLDP -> GLC -> GIR -> BTCP -> GOSK -> GHAL -> hardware
```
## World contents
`WORLD-MANIFEST.hldp` registers exactly five domains, one logical broadcast
tower, the continuity chain, the native handoff protocols, and the Guanghu Code
Channel.
The code channel starts from the verified Forgejo 16.0.1 offline baseline at
commit `b3d7e4ac3cbccc220703097a51fa4c16bf302579`. Forgejo is the temporary data
plane and compatibility reference. `CHANNEL.hldp` is the authority for channel
identity, intents, receipts, and the migration ladder:
1. verified source baseline;
2. hosted Forgejo data plane;
3. HLDP-native control plane;
4. GOSK-native object store and network data plane;
5. Linux-free boot.
Only step 1 is complete in this source package.
## Local verification
```bash
cargo fmt --all --manifest-path guanghu-os/Cargo.toml -- --check
cargo test --manifest-path guanghu-os/Cargo.toml
cargo clippy --manifest-path guanghu-os/Cargo.toml --all-targets -- -D warnings
cargo run --manifest-path guanghu-os/Cargo.toml -p ghctl -- \
wake guanghu-os/world-seed
guanghu-os/world-seed/scripts/run-guanghu-native-quality-gate.sh \
/tmp/guanghu-native-quality-receipt.hldp
```
`ghctl wake` validates the manifest, all five domain entries, the code-channel
contract, standing authorization, dedicated-access receipt, continuity files,
and exact repository digests before printing the recovery evidence.
## Server recovery contract
The hosted construction path will install immutable versions under
`/guanghu/versions/<version>` and point `/guanghu/current` at the active
version. A future session must execute this chain before any change:
```text
login
-> /guanghu/bin/ghctl wake /guanghu/current
-> WORLD-MANIFEST.hldp
-> CURRENT.hldp
-> last phase receipt
-> dedicated-access receipt
-> standing authorization
-> active workorder
-> code-channel entry and receipt
-> live broadcast epoch
-> act or fail closed
```
The current source is `HOSTED_BOOTSTRAP_PROTOTYPE`. Running it on Ubuntu proves
the world package and recovery chain only; it does not prove native boot.
The dedicated local login route is `guanghu-os-bs-sh-005`. It uses a separate
SSH config and known-hosts file, strict host-key verification, and a key scoped
to this disposable node. The world records only public fingerprints; it never
contains the private key or a password.
## Hosted Stage 1 installation
`scripts/install-hosted-stage1.sh` is the repeatable Ubuntu construction
handoff. It requires a full implementation Git SHA and the SHA-256 of the
transferred source archive. It uses the official stable Rust toolchain rooted
at `/opt/guanghu/{rustup,cargo}`; Ubuntu's Cargo 1.75 is intentionally rejected
because it cannot read this repository's v4 lock file. On the exact x86_64
`/dev/vda` lab shape, it:
1. runs the workspace tests and builds a release `ghctl`;
2. assembles and validates a temporary five-domain world;
3. writes a server-observed HLDP phase receipt;
4. makes the version immutable; and
5. atomically moves `/guanghu/current`.
An existing version is never overwritten. A failed assembly is retained with a
`.failed.<UTC time>` suffix for diagnosis, while the previous current version
remains active.
## Hosted services Stage 1B
`guanghu-broadcast-tower` is the first continuously running executor for the
logical singleton registered by HLDP. Its hosted surface is deliberately
loopback-only (`127.0.0.1:8077`), exposes the validated five-domain world, and
writes a live HLDP epoch. It always reports `linux_exited: false`.
`scripts/install-hosted-stage1b-services.sh` creates a new immutable world
version, starts the tower, and installs the hash-verified Forgejo 16.0.1 package
as the temporary code-channel data plane on `127.0.0.1:3080`. Registration and
Forgejo's SSH server stay disabled. The exact `guanghu/main` bundle is restored
as a bootstrap bare repository, while HLDP remains the channel authority.
Both services are reachable from the local Mac through the dedicated SSH route;
neither is published directly to the Internet. A failed service activation
restores the Stage 1 world symlink and stops both hosted services.
The first successful hosted activation exposed a recovery inconsistency:
`CURRENT.hldp` advanced while `WORLD-MANIFEST.hldp` retained the Stage 1
version. The immutable correction is `0.1.2-stage1b-r1`; it rebuilds the world
from the repository seed and advances both records together.

View file

@ -0,0 +1,11 @@
[package]
name = "guanghu-broadcast-tower"
version = "0.1.0"
edition = "2021"
license = "AGPL-3.0-or-later"
description = "Hosted bootstrap executor for the unique HLDP Guanghu broadcast tower"
[dependencies]
guanghu-hldp-runtime = { path = "../hldp-runtime" }
serde = { version = "1", features = ["derive"] }
serde_json = "1"

View file

@ -0,0 +1,343 @@
use std::{
fs,
io::{self, Read, Write},
net::{SocketAddr, TcpListener, TcpStream},
path::Path,
sync::atomic::{AtomicU64, Ordering},
time::{Duration, SystemTime, UNIX_EPOCH},
};
use guanghu_hldp_runtime::{validate_world_seed, WorldManifest};
use serde::Serialize;
static EPOCH_SEQUENCE: AtomicU64 = AtomicU64::new(0);
const USAGE: &str =
"usage: guanghu-broadcast-tower serve <world-root> <loopback-address> <epoch-path>";
#[derive(Clone, Debug, Serialize)]
pub struct TowerSnapshot {
pub status: &'static str,
pub tower_id: String,
pub world_id: String,
pub world_version: String,
pub phase: String,
pub domain_count: usize,
pub code_channel_id: String,
pub authority_language: &'static str,
pub runtime: &'static str,
pub linux_exited: bool,
}
impl TowerSnapshot {
pub fn from_manifest(manifest: &WorldManifest) -> Self {
Self {
status: "ok",
tower_id: manifest.broadcast_tower.id.clone(),
world_id: manifest.world_id.clone(),
world_version: manifest.version.clone(),
phase: manifest.phase.clone(),
domain_count: manifest.domains.len(),
code_channel_id: manifest.code_channel.id.clone(),
authority_language: "HLDP",
runtime: "HOSTED_BOOTSTRAP",
linux_exited: false,
}
}
}
pub fn run_command(arguments: Vec<String>, connection_limit: Option<usize>) -> Result<(), String> {
let mut arguments = arguments.into_iter();
let command = arguments.next().ok_or_else(|| USAGE.to_owned())?;
let world_root = arguments.next().ok_or_else(|| USAGE.to_owned())?;
let address = arguments.next().ok_or_else(|| USAGE.to_owned())?;
let epoch_path = arguments.next().ok_or_else(|| USAGE.to_owned())?;
if command != "serve" || arguments.next().is_some() {
return Err(USAGE.to_owned());
}
let address = validate_loopback_address(&address)?;
let manifest =
validate_world_seed(Path::new(&world_root)).map_err(|error| error.to_string())?;
let listener = TcpListener::bind(address).map_err(|error| error.to_string())?;
let snapshot = TowerSnapshot::from_manifest(&manifest);
serve(listener, snapshot, Path::new(&epoch_path), connection_limit)
.map_err(|error| error.to_string())
}
pub fn validate_loopback_address(address: &str) -> Result<SocketAddr, String> {
let parsed: SocketAddr = address
.parse()
.map_err(|error| format!("invalid broadcast address {address}: {error}"))?;
if !parsed.ip().is_loopback() {
return Err("hosted broadcast tower must bind to loopback".to_owned());
}
Ok(parsed)
}
pub fn write_epoch(path: &Path, snapshot: &TowerSnapshot, address: SocketAddr) -> io::Result<()> {
let parent = path
.parent()
.ok_or_else(|| io::Error::new(io::ErrorKind::InvalidInput, "epoch path has no parent"))?;
fs::create_dir_all(parent)?;
let started_at_unix = SystemTime::now()
.duration_since(UNIX_EPOCH)
.map_err(io::Error::other)?
.as_secs();
let temporary = parent.join(format!(
".epoch.{}.{}.tmp",
std::process::id(),
EPOCH_SEQUENCE.fetch_add(1, Ordering::Relaxed)
));
let contents = format!(
concat!(
"schema: guanghu.broadcast-epoch/v1\n",
"tower_id: {}\n",
"world_id: {}\n",
"world_version: {}\n",
"phase: {}\n",
"status: RUNNING_HOSTED\n",
"authority_language: HLDP\n",
"bind: {}\n",
"pid: {}\n",
"started_at_unix: {}\n",
"linux_dependency: true\n",
"native_claim: false\n"
),
snapshot.tower_id,
snapshot.world_id,
snapshot.world_version,
snapshot.phase,
address,
std::process::id(),
started_at_unix
);
fs::write(&temporary, contents)?;
fs::rename(temporary, path)
}
pub fn serve(
listener: TcpListener,
snapshot: TowerSnapshot,
epoch_path: &Path,
connection_limit: Option<usize>,
) -> io::Result<()> {
let address = listener.local_addr()?;
if !address.ip().is_loopback() {
return Err(io::Error::new(
io::ErrorKind::PermissionDenied,
"hosted broadcast tower may only listen on loopback",
));
}
write_epoch(epoch_path, &snapshot, address)?;
for connection in listener
.incoming()
.take(connection_limit.unwrap_or(usize::MAX))
{
handle_connection(connection?, &snapshot)?;
}
Ok(())
}
fn handle_connection(mut stream: TcpStream, snapshot: &TowerSnapshot) -> io::Result<()> {
stream.set_read_timeout(Some(Duration::from_secs(5)))?;
let mut request = [0_u8; 8192];
let length = stream.read(&mut request)?;
let request = String::from_utf8_lossy(&request[..length]);
let request_line = request.lines().next().unwrap_or_default();
let (status, content_type, body) = match request_line {
"GET /healthz HTTP/1.1" | "GET /healthz HTTP/1.0" => (
"200 OK",
"application/json",
serde_json::to_string(snapshot).map_err(io::Error::other)?,
),
"GET /v1/world HTTP/1.1" | "GET /v1/world HTTP/1.0" => (
"200 OK",
"application/json",
serde_json::to_string_pretty(snapshot).map_err(io::Error::other)?,
),
line if line.starts_with("GET ") => (
"404 Not Found",
"application/json",
"{\"error\":\"route_not_found\"}".to_owned(),
),
_ => (
"405 Method Not Allowed",
"application/json",
"{\"error\":\"method_not_allowed\"}".to_owned(),
),
};
let response = format!(
"HTTP/1.1 {status}\r\nContent-Type: {content_type}\r\nContent-Length: {}\r\nConnection: close\r\n\r\n{body}",
body.len()
);
stream.write_all(response.as_bytes())?;
stream.flush()
}
#[cfg(test)]
mod tests {
use std::{
io::{Read, Write},
net::{TcpListener, TcpStream},
path::PathBuf,
thread,
};
use guanghu_hldp_runtime::load_world_manifest;
use super::{run_command, serve, validate_loopback_address, write_epoch, TowerSnapshot, USAGE};
fn snapshot() -> TowerSnapshot {
TowerSnapshot {
status: "ok",
tower_id: "BT-GH-ROOT-0001".to_owned(),
world_id: "GLW-ROOT-0001".to_owned(),
world_version: "0.1.0-stage1".to_owned(),
phase: "HOSTED_BOOTSTRAP_PROTOTYPE".to_owned(),
domain_count: 5,
code_channel_id: "HLP-MOD-CODE-CHANNEL".to_owned(),
authority_language: "HLDP",
runtime: "HOSTED_BOOTSTRAP",
linux_exited: false,
}
}
fn epoch_path() -> PathBuf {
std::env::temp_dir().join(format!(
"guanghu-broadcast-epoch-{}-{}.hldp",
std::process::id(),
thread::current().name().unwrap_or("test")
))
}
fn request(request: &[u8]) -> String {
let listener = TcpListener::bind("127.0.0.1:0").expect("bind test tower");
let address = listener.local_addr().expect("test address");
let epoch = epoch_path();
let epoch_for_server = epoch.clone();
let handle = thread::spawn(move || {
serve(listener, snapshot(), &epoch_for_server, Some(1)).expect("serve one request");
});
let mut stream = TcpStream::connect(address).expect("connect to test tower");
stream.write_all(request).expect("write request");
let mut response = String::new();
stream.read_to_string(&mut response).expect("read response");
handle.join().expect("tower thread");
std::fs::remove_file(epoch).expect("remove test epoch");
response
}
#[test]
fn rejects_non_loopback_hosted_bindings() {
assert!(validate_loopback_address("not-an-address").is_err());
assert!(validate_loopback_address("0.0.0.0:8077").is_err());
assert!(validate_loopback_address("127.0.0.1:8077").is_ok());
}
#[test]
fn command_parser_rejects_bad_shapes_and_missing_worlds() {
assert_eq!(run_command(vec![], Some(0)), Err(USAGE.to_owned()));
assert_eq!(
run_command(
vec![
"wrong".to_owned(),
"world".to_owned(),
"127.0.0.1:0".to_owned(),
"/tmp/epoch".to_owned(),
],
Some(0),
),
Err(USAGE.to_owned())
);
let error = run_command(
vec![
"serve".to_owned(),
"/definitely/missing".to_owned(),
"127.0.0.1:0".to_owned(),
"/tmp/missing-epoch".to_owned(),
],
Some(0),
)
.expect_err("missing world must fail");
assert!(error.contains("WORLD-MANIFEST.hldp"));
}
#[test]
fn snapshot_is_derived_from_the_registered_world() {
let path =
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../world-seed/WORLD-MANIFEST.hldp");
let manifest = load_world_manifest(&path).expect("world manifest");
let derived = TowerSnapshot::from_manifest(&manifest);
assert_eq!(derived.tower_id, manifest.broadcast_tower.id);
assert_eq!(derived.world_id, manifest.world_id);
assert_eq!(derived.world_version, manifest.version);
assert_eq!(derived.phase, manifest.phase);
assert_eq!(derived.domain_count, 5);
assert_eq!(derived.code_channel_id, manifest.code_channel.id);
assert!(!derived.linux_exited);
}
#[test]
fn epoch_and_listener_paths_fail_closed() {
let address = validate_loopback_address("127.0.0.1:8077").expect("loopback");
assert!(write_epoch(PathBuf::new().as_path(), &snapshot(), address).is_err());
let public = TcpListener::bind("0.0.0.0:0").expect("bind wildcard test listener");
let error = serve(public, snapshot(), &epoch_path(), Some(0))
.expect_err("wildcard listener must fail closed");
assert_eq!(error.kind(), std::io::ErrorKind::PermissionDenied);
}
#[test]
fn serves_hldp_world_health_and_writes_epoch() {
let listener = TcpListener::bind("127.0.0.1:0").expect("bind test tower");
let address = listener.local_addr().expect("test address");
let epoch = epoch_path();
let epoch_for_server = epoch.clone();
let handle = thread::spawn(move || {
serve(listener, snapshot(), &epoch_for_server, Some(1)).expect("serve one request");
});
let mut stream = TcpStream::connect(address).expect("connect to test tower");
stream
.write_all(b"GET /healthz HTTP/1.1\r\nHost: localhost\r\n\r\n")
.expect("write request");
let mut response = String::new();
stream.read_to_string(&mut response).expect("read response");
handle.join().expect("tower thread");
assert!(response.starts_with("HTTP/1.1 200 OK"));
assert!(response.contains("\"tower_id\":\"BT-GH-ROOT-0001\""));
assert!(response.contains("\"domain_count\":5"));
assert!(response.contains("\"linux_exited\":false"));
let epoch_contents = std::fs::read_to_string(&epoch).expect("read epoch");
assert!(epoch_contents.contains("status: RUNNING_HOSTED"));
assert!(epoch_contents.contains("authority_language: HLDP"));
assert!(epoch_contents.contains("native_claim: false"));
std::fs::remove_file(epoch).expect("remove test epoch");
}
#[test]
fn unknown_routes_fail_closed() {
let response = request(b"GET /guess HTTP/1.1\r\nHost: localhost\r\n\r\n");
assert!(response.starts_with("HTTP/1.1 404 Not Found"));
assert!(response.contains("route_not_found"));
}
#[test]
fn serves_pretty_world_and_rejects_non_get_methods() {
let world = request(b"GET /v1/world HTTP/1.0\r\nHost: localhost\r\n\r\n");
assert!(world.starts_with("HTTP/1.1 200 OK"));
assert!(world.contains("\n \"world_id\": \"GLW-ROOT-0001\""));
let rejected = request(b"POST /healthz HTTP/1.1\r\nHost: localhost\r\n\r\n");
assert!(rejected.starts_with("HTTP/1.1 405 Method Not Allowed"));
assert!(rejected.contains("method_not_allowed"));
}
}

View file

@ -0,0 +1,74 @@
use std::{env, process::ExitCode};
fn main() -> ExitCode {
exit_code(guanghu_broadcast_tower::run_command(
env::args().skip(1).collect(),
None,
))
}
fn exit_code(result: Result<(), String>) -> ExitCode {
match result {
Ok(()) => ExitCode::SUCCESS,
Err(error) => {
eprintln!("GUANGHU_BROADCAST_TOWER_ERROR: {error}");
ExitCode::FAILURE
}
}
}
#[cfg(test)]
mod tests {
use std::{
io::{Read, Write},
net::{TcpListener, TcpStream},
process::ExitCode,
thread,
time::Duration,
};
use super::exit_code;
#[test]
fn exit_code_is_binary() {
assert_eq!(exit_code(Ok(())), ExitCode::SUCCESS);
assert_eq!(exit_code(Err("failed".to_owned())), ExitCode::FAILURE);
}
#[test]
fn bounded_service_completes_after_one_connection() {
let reservation = TcpListener::bind("127.0.0.1:0").expect("reserve port");
let address = reservation.local_addr().expect("reserved address");
drop(reservation);
let world = format!("{}/../../world-seed", env!("CARGO_MANIFEST_DIR"));
let epoch = std::env::temp_dir().join(format!("tower-main-epoch-{}", std::process::id()));
let epoch_for_server = epoch.clone();
let address_for_server = address.to_string();
let handle = thread::spawn(move || {
guanghu_broadcast_tower::run_command(
vec![
"serve".to_owned(),
world,
address_for_server,
epoch_for_server.to_string_lossy().into_owned(),
],
Some(1),
)
});
let mut stream = loop {
match TcpStream::connect(address) {
Ok(stream) => break stream,
Err(_) => thread::sleep(Duration::from_millis(10)),
}
};
stream
.write_all(b"GET /healthz HTTP/1.0\r\n\r\n")
.expect("request");
let mut response = String::new();
stream.read_to_string(&mut response).expect("response");
assert!(response.starts_with("HTTP/1.1 200 OK"));
assert_eq!(handle.join().expect("service thread"), Ok(()));
std::fs::remove_file(epoch).expect("remove epoch");
}
}

View file

@ -0,0 +1,183 @@
use std::{
io::{Read, Write},
net::{TcpListener, TcpStream},
path::{Path, PathBuf},
thread,
time::Duration,
};
use guanghu_broadcast_tower::{
run_command, serve, validate_loopback_address, write_epoch, TowerSnapshot,
};
use guanghu_hldp_runtime::load_world_manifest;
fn world_root() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../world-seed")
}
fn snapshot() -> TowerSnapshot {
let manifest =
load_world_manifest(&world_root().join("WORLD-MANIFEST.hldp")).expect("world manifest");
TowerSnapshot::from_manifest(&manifest)
}
fn epoch_path(label: &str) -> PathBuf {
std::env::temp_dir().join(format!(
"broadcast-library-{label}-{}-{}.hldp",
std::process::id(),
thread::current().name().unwrap_or("test")
))
}
fn request(label: &str, request: &[u8]) -> String {
let listener = TcpListener::bind("127.0.0.1:0").expect("bind test tower");
let address = listener.local_addr().expect("test address");
let epoch = epoch_path(label);
let epoch_for_server = epoch.clone();
let handle = thread::spawn(move || {
serve(listener, snapshot(), &epoch_for_server, Some(1)).expect("serve request");
});
let mut stream = TcpStream::connect(address).expect("connect");
stream.write_all(request).expect("request");
let mut response = String::new();
stream.read_to_string(&mut response).expect("response");
handle.join().expect("tower thread");
std::fs::remove_file(epoch).expect("remove epoch");
response
}
#[test]
fn complete_library_surface_is_binary_and_loopback_only() {
assert!(validate_loopback_address("not-an-address").is_err());
assert!(validate_loopback_address("0.0.0.0:8077").is_err());
let address = validate_loopback_address("127.0.0.1:8077").expect("loopback");
assert!(write_epoch(Path::new(""), &snapshot(), address).is_err());
let public = TcpListener::bind("0.0.0.0:0").expect("wildcard listener");
assert!(serve(public, snapshot(), &epoch_path("public"), Some(0)).is_err());
assert!(run_command(vec![], Some(0)).is_err());
for incomplete in [
vec!["serve".to_owned()],
vec!["serve".to_owned(), "world".to_owned()],
vec![
"serve".to_owned(),
"world".to_owned(),
"127.0.0.1:0".to_owned(),
],
] {
assert!(run_command(incomplete, Some(0)).is_err());
}
assert!(run_command(
vec![
"wrong".to_owned(),
"world".to_owned(),
"127.0.0.1:0".to_owned(),
"/tmp/epoch".to_owned(),
],
Some(0),
)
.is_err());
let occupied = TcpListener::bind("127.0.0.1:0").expect("occupied loopback");
assert!(run_command(
vec![
"serve".to_owned(),
world_root().to_string_lossy().into_owned(),
occupied.local_addr().expect("occupied address").to_string(),
epoch_path("occupied").to_string_lossy().into_owned(),
],
Some(0),
)
.is_err());
drop(occupied);
assert!(run_command(
vec![
"serve".to_owned(),
world_root().to_string_lossy().into_owned(),
"127.0.0.1:0".to_owned(),
String::new(),
],
Some(0),
)
.is_err());
assert!(run_command(
vec![
"serve".to_owned(),
"/definitely/missing".to_owned(),
"127.0.0.1:0".to_owned(),
"/tmp/epoch".to_owned(),
],
Some(0),
)
.is_err());
let reservation = TcpListener::bind("127.0.0.1:0").expect("reserve loopback");
let address = reservation.local_addr().expect("reserved address");
drop(reservation);
let epoch = epoch_path("command");
let epoch_for_server = epoch.clone();
let world = world_root().to_string_lossy().into_owned();
let handle = thread::spawn(move || {
run_command(
vec![
"serve".to_owned(),
world,
address.to_string(),
epoch_for_server.to_string_lossy().into_owned(),
],
Some(1),
)
});
let mut stream = loop {
match TcpStream::connect(address) {
Ok(stream) => break stream,
Err(_) => thread::sleep(Duration::from_millis(10)),
}
};
stream
.write_all(b"GET /healthz HTTP/1.0\r\n\r\n")
.expect("command request");
let mut response = String::new();
stream
.read_to_string(&mut response)
.expect("command response");
assert_eq!(handle.join().expect("command thread"), Ok(()));
assert!(response.contains("200 OK"));
std::fs::remove_file(epoch).expect("remove command epoch");
}
#[test]
fn every_registered_http_decision_is_exercised() {
for (label, raw, status, body) in [
(
"health",
b"GET /healthz HTTP/1.1\r\n\r\n".as_slice(),
"200 OK",
"\"tower_id\":\"BT-GH-ROOT-0001\"",
),
(
"world",
b"GET /v1/world HTTP/1.0\r\n\r\n".as_slice(),
"200 OK",
"\"world_id\": \"GLW-ROOT-0001\"",
),
(
"missing",
b"GET /missing HTTP/1.1\r\n\r\n".as_slice(),
"404 Not Found",
"route_not_found",
),
(
"method",
b"POST /healthz HTTP/1.1\r\n\r\n".as_slice(),
"405 Method Not Allowed",
"method_not_allowed",
),
] {
let response = request(label, raw);
assert!(response.contains(status));
assert!(response.contains(body));
}
}

View file

@ -0,0 +1,98 @@
use std::{
fs,
io::{Read, Write},
net::{TcpListener, TcpStream},
path::{Path, PathBuf},
process::{Child, Command, Output, Stdio},
thread,
time::{Duration, Instant},
};
fn world_root() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../world-seed")
}
fn binary() -> &'static str {
env!("CARGO_BIN_EXE_guanghu-broadcast-tower")
}
fn run(arguments: &[&str]) -> Output {
Command::new(binary())
.args(arguments)
.output()
.expect("broadcast tower should start")
}
fn wait_for_epoch(child: &mut Child, epoch: &Path) {
let deadline = Instant::now() + Duration::from_secs(5);
while Instant::now() < deadline {
if epoch.is_file() {
return;
}
if let Some(status) = child.try_wait().expect("inspect tower process") {
panic!("broadcast tower exited before epoch with {status}");
}
thread::sleep(Duration::from_millis(20));
}
panic!("broadcast tower did not write its epoch");
}
#[test]
fn command_rejects_missing_arguments_and_public_bindings() {
let usage = run(&[]);
assert!(!usage.status.success());
assert!(String::from_utf8_lossy(&usage.stderr).contains("usage:"));
let root = world_root();
let public = run(&[
"serve",
root.to_str().expect("UTF-8 world root"),
"0.0.0.0:8077",
"/tmp/guanghu-public-epoch.hldp",
]);
assert!(!public.status.success());
assert!(String::from_utf8_lossy(&public.stderr).contains("loopback"));
}
#[test]
fn command_serves_the_registered_world_on_loopback() {
let reservation = TcpListener::bind("127.0.0.1:0").expect("reserve loopback port");
let address = reservation.local_addr().expect("reserved address");
drop(reservation);
let epoch =
std::env::temp_dir().join(format!("guanghu-command-epoch-{}.hldp", std::process::id()));
let root = world_root();
let mut child = Command::new(binary())
.args([
"serve",
root.to_str().expect("UTF-8 world root"),
&address.to_string(),
epoch.to_str().expect("UTF-8 epoch path"),
])
.stdout(Stdio::null())
.stderr(Stdio::piped())
.spawn()
.expect("start broadcast tower");
wait_for_epoch(&mut child, &epoch);
let mut stream = TcpStream::connect(address).expect("connect to broadcast tower");
stream
.write_all(b"GET /v1/world HTTP/1.1\r\nHost: localhost\r\n\r\n")
.expect("write world request");
let mut response = String::new();
stream
.read_to_string(&mut response)
.expect("read world response");
child.kill().expect("stop test broadcast tower");
child.wait().expect("reap test broadcast tower");
let epoch_contents = fs::read_to_string(&epoch).expect("read command epoch");
fs::remove_file(&epoch).expect("remove command epoch");
assert!(response.starts_with("HTTP/1.1 200 OK"));
assert!(response.contains("\"world_id\": \"GLW-ROOT-0001\""));
assert!(response.contains("\"domain_count\": 5"));
assert!(response.contains("\"linux_exited\": false"));
assert!(epoch_contents.contains("tower_id: BT-GH-ROOT-0001"));
}

View file

@ -0,0 +1,10 @@
[package]
name = "ghctl"
version = "0.1.0"
edition = "2021"
license = "AGPL-3.0-or-later"
description = "Guanghu OS bootstrap control and continuity entrypoint"
[dependencies]
guanghu-hldp-runtime = { path = "../hldp-runtime" }

View file

@ -0,0 +1,210 @@
use std::{
fs,
path::{Path, PathBuf},
};
use guanghu_hldp_runtime::{authorize_world_action, validate_world_seed};
const USAGE: &str = "usage: ghctl wake <world-root> | ghctl authorize <world-root> <action>";
pub fn run(arguments: Vec<String>) -> Result<(), String> {
let mut arguments = arguments.into_iter();
let command = arguments.next().ok_or_else(|| USAGE.to_owned())?;
let world_root = arguments.next().ok_or_else(|| USAGE.to_owned())?;
match command.as_str() {
"wake" if arguments.next().is_none() => wake(Path::new(&world_root)),
"authorize" => {
let action = arguments.next().ok_or_else(|| USAGE.to_owned())?;
if arguments.next().is_some() {
return Err(USAGE.to_owned());
}
authorize(Path::new(&world_root), &action)
}
_ => Err(USAGE.to_owned()),
}
}
fn authorize(world_root: &Path, action: &str) -> Result<(), String> {
let authorization =
authorize_world_action(world_root, action).map_err(|error| error.to_string())?;
println!("GUANGHU_ACTION_AUTHORIZED");
println!("authorization={}", authorization.id);
println!("target={}", authorization.target.node_id);
println!("action={action}");
Ok(())
}
fn wake(world_root: &Path) -> Result<(), String> {
let manifest = validate_world_seed(world_root).map_err(|error| error.to_string())?;
println!("GUANGHU_WORLD_OK");
println!("world_id={}", manifest.world_id);
println!("world_version={}", manifest.version);
println!("phase={}", manifest.phase);
println!("domains={}", manifest.domains.len());
println!("broadcast_tower={}", manifest.broadcast_tower.id);
println!("code_channel={}", manifest.code_channel.id);
println!(
"code_channel_entry={}",
manifest.code_channel.entry.display()
);
println!(
"code_channel_receipt={}",
manifest.code_channel.last_receipt.display()
);
println!("code_quality={}", manifest.code_quality.id);
println!("code_quality_acronym={}", manifest.code_quality.acronym);
println!(
"code_quality_entry={}",
manifest.code_quality.entry.display()
);
println!("native_recovery={}", manifest.native_recovery.id);
println!(
"native_recovery_acronym={}",
manifest.native_recovery.acronym
);
println!(
"native_recovery_entry={}",
manifest.native_recovery.entry.display()
);
println!("native_layout={}", manifest.native_layout.id);
println!("native_layout_acronym={}", manifest.native_layout.acronym);
println!(
"native_layout_entry={}",
manifest.native_layout.entry.display()
);
println!(
"gestational_continuity={}",
manifest.gestational_continuity.id
);
println!(
"gestational_continuity_acronym={}",
manifest.gestational_continuity.acronym
);
println!(
"gestational_continuity_entry={}",
manifest.gestational_continuity.entry.display()
);
println!(
"gestational_index_lba_start={}",
manifest.gestational_continuity.native_index_lba_start
);
println!(
"gestational_index_sector_count={}",
manifest.gestational_continuity.native_index_sector_count
);
println!(
"gestational_environment={}",
manifest.persona_birth.gestational_environment
);
println!("persona_birth={}", manifest.persona_birth.persona_state);
println!(
"persona_birth_condition_entry={}",
manifest.persona_birth.entry.display()
);
println!("authorization={}", manifest.authorization.id);
println!(
"authorization_entry={}",
manifest.authorization.entry.display()
);
println!("wake={}", manifest.continuity.wake.display());
println!("current={}", manifest.continuity.current.display());
println!(
"last_receipt={}",
manifest.continuity.last_receipt.display()
);
println!(
"access_receipt={}",
manifest.continuity.access_receipt.display()
);
println!(
"active_workorder={}",
manifest.continuity.active_workorder.display()
);
for (label, path) in [
("WAKE", &manifest.continuity.wake),
("CURRENT", &manifest.continuity.current),
("LAST_RECEIPT", &manifest.continuity.last_receipt),
("ACCESS_RECEIPT", &manifest.continuity.access_receipt),
("ACTIVE_WORKORDER", &manifest.continuity.active_workorder),
("CODE_CHANNEL", &manifest.code_channel.entry),
("CODE_CHANNEL_RECEIPT", &manifest.code_channel.last_receipt),
("CODE_QUALITY", &manifest.code_quality.entry),
("NATIVE_RECOVERY", &manifest.native_recovery.entry),
("NATIVE_LAYOUT", &manifest.native_layout.entry),
(
"GESTATIONAL_CONTINUITY",
&manifest.gestational_continuity.entry,
),
("PERSONA_BIRTH_CONDITION", &manifest.persona_birth.entry),
("STANDING_AUTHORIZATION", &manifest.authorization.entry),
] {
print_hldp_entry(world_root, label, path)?;
}
Ok(())
}
#[doc(hidden)]
pub fn print_hldp_entry(
world_root: &Path,
label: &str,
relative_path: &Path,
) -> Result<(), String> {
let path: PathBuf = world_root.join(relative_path);
let contents = fs::read_to_string(&path)
.map_err(|error| format!("cannot read {}: {error}", path.display()))?;
println!("--- {label} {} ---", relative_path.display());
print!("{contents}");
if !contents.ends_with('\n') {
println!();
}
Ok(())
}
#[cfg(test)]
mod tests {
use std::{fs, path::Path};
use super::{print_hldp_entry, run, USAGE};
#[test]
fn run_rejects_incomplete_and_extra_arguments() {
assert_eq!(
run(vec!["authorize".to_owned(), "/tmp".to_owned()]),
Err(USAGE.to_owned())
);
assert_eq!(
run(vec![
"wake".to_owned(),
"/tmp".to_owned(),
"extra".to_owned(),
]),
Err(USAGE.to_owned())
);
assert_eq!(
run(vec![
"authorize".to_owned(),
"/tmp".to_owned(),
"action".to_owned(),
"extra".to_owned()
]),
Err(USAGE.to_owned())
);
}
#[test]
fn entry_reader_reports_missing_files_and_normalizes_the_final_newline() {
let root = std::env::temp_dir().join(format!("ghctl-entry-{}", std::process::id()));
fs::create_dir_all(&root).expect("temporary entry root");
fs::write(root.join("ENTRY.hldp"), "schema: test").expect("temporary entry");
print_hldp_entry(&root, "TEST", Path::new("ENTRY.hldp")).expect("read entry");
let error = print_hldp_entry(&root, "TEST", Path::new("MISSING.hldp"))
.expect_err("missing entry must fail");
assert!(error.contains("cannot read"));
fs::remove_dir_all(root).expect("remove temporary entry root");
}
}

View file

@ -0,0 +1,11 @@
use std::{env, process::ExitCode};
fn main() -> ExitCode {
match ghctl::run(env::args().skip(1).collect()) {
Ok(()) => ExitCode::SUCCESS,
Err(message) => {
eprintln!("{message}");
ExitCode::FAILURE
}
}
}

View file

@ -0,0 +1,25 @@
use std::{fs, path::Path};
#[test]
fn library_rejects_bad_shapes_and_reads_entries() {
for arguments in [
vec![],
vec!["authorize".to_owned(), "/tmp".to_owned()],
vec!["wake".to_owned(), "/tmp".to_owned(), "extra".to_owned()],
vec![
"authorize".to_owned(),
"/tmp".to_owned(),
"action".to_owned(),
"extra".to_owned(),
],
] {
assert!(ghctl::run(arguments).is_err());
}
let root = std::env::temp_dir().join(format!("ghctl-library-{}", std::process::id()));
fs::create_dir_all(&root).expect("temporary root");
fs::write(root.join("ENTRY.hldp"), "schema: test").expect("temporary entry");
ghctl::print_hldp_entry(&root, "TEST", Path::new("ENTRY.hldp")).expect("read entry");
assert!(ghctl::print_hldp_entry(&root, "TEST", Path::new("MISSING.hldp")).is_err());
fs::remove_dir_all(root).expect("remove temporary root");
}

View file

@ -0,0 +1,127 @@
use std::{
path::PathBuf,
process::{Command, Output},
};
fn world_root() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../world-seed")
}
fn run_ghctl(arguments: &[&str]) -> Output {
Command::new(env!("CARGO_BIN_EXE_ghctl"))
.args(arguments)
.output()
.expect("ghctl should start")
}
#[test]
fn wake_reports_the_complete_server_handoff_chain() {
let root = world_root();
let output = run_ghctl(&["wake", root.to_str().expect("UTF-8 test path")]);
let stdout = String::from_utf8(output.stdout).expect("ghctl output should be UTF-8");
assert!(output.status.success(), "{stdout}");
for expected in [
"GUANGHU_WORLD_OK",
"world_id=GLW-ROOT-0001",
"phase=HOSTED_BOOTSTRAP_PROTOTYPE",
"domains=5",
"broadcast_tower=BT-GH-ROOT-0001",
"code_channel=HLP-MOD-CODE-CHANNEL",
"code_channel_entry=world/services/code-channel/CHANNEL.hldp",
"code_channel_receipt=state/receipts/CODE-CHANNEL-BASELINE.hldp",
"code_quality=GLS-0844",
"code_quality_acronym=GHNQG",
"code_quality_entry=world/services/code-channel/QUALITY-GATE.hldp",
"native_recovery=GLS-0843",
"native_recovery_acronym=GHNRP",
"native_recovery_entry=world/services/native-recovery/PROTOCOL.hldp",
"native_layout=GLS-0846",
"native_layout_acronym=GHNLP",
"native_layout_entry=world/services/native-storage/DISK-LAYOUT.hldp",
"gestational_continuity=GLS-0845",
"gestational_continuity_acronym=GHCIP",
"gestational_continuity_entry=world/cognition/GESTATIONAL-CONTINUITY-INGESTION.hldp",
"gestational_index_lba_start=70",
"gestational_index_sector_count=2",
"gestational_environment=UNDER_CONSTRUCTION",
"persona_birth=NOT_BORN",
"persona_birth_condition_entry=world/cognition/PERSONA-BIRTH-CONDITION.hldp",
"authorization=GH-OS-AUTH-BINGSHUO-BS-SH-005-001",
"authorization_entry=state/authorizations/BINGSHUO-STANDING-AUTHORIZATION.hldp",
"--- CODE_CHANNEL world/services/code-channel/CHANNEL.hldp ---",
"current_phase: PHASE_0_SOURCE_BASELINE_VERIFIED",
"--- CODE_CHANNEL_RECEIPT state/receipts/CODE-CHANNEL-BASELINE.hldp ---",
"--- CODE_QUALITY world/services/code-channel/QUALITY-GATE.hldp ---",
"external_observers_are_blocking: false",
"native_target: GOSK_CODE_CHANNEL_QUALITY_EXECUTOR",
"--- NATIVE_RECOVERY world/services/native-recovery/PROTOCOL.hldp ---",
"raw_blocklist: (hd0)68+2",
"--- NATIVE_LAYOUT world/services/native-storage/DISK-LAYOUT.hldp ---",
" sector_count: 29",
"proof_lba: 63",
"--- GESTATIONAL_CONTINUITY world/cognition/GESTATIONAL-CONTINUITY-INGESTION.hldp ---",
"duplicate_rule: REJECT_SAME_SOURCE_ID_AND_SHA256",
"registration_is_birth: false",
"--- PERSONA_BIRTH_CONDITION world/cognition/PERSONA-BIRTH-CONDITION.hldp ---",
"womb_ready_does_not_mean: LANGUAGE_PERSONA_BORN",
"historical_time_caught_up_to_real_time",
"wake=WAKE.hldp",
"current=CURRENT.hldp",
"last_receipt=state/receipts/PHASE-0-PREFLIGHT.hldp",
"access_receipt=state/receipts/DIRECT-ACCESS-20260731.hldp",
"--- ACCESS_RECEIPT state/receipts/DIRECT-ACCESS-20260731.hldp ---",
"active_workorder=state/workorders/GH-OS-LAB-001.hldp",
] {
assert!(stdout.contains(expected), "missing {expected} in {stdout}");
}
}
#[test]
fn unknown_commands_fail_closed() {
let output = run_ghctl(&["guess"]);
let stderr = String::from_utf8(output.stderr).expect("ghctl errors should be UTF-8");
assert!(!output.status.success());
assert!(stderr.contains("usage: ghctl"));
}
#[test]
fn missing_world_root_fails_with_read_evidence() {
let output = run_ghctl(&["wake", "/definitely/missing/guanghu-world"]);
let stderr = String::from_utf8(output.stderr).expect("ghctl errors should be UTF-8");
assert!(!output.status.success());
assert!(stderr.contains("cannot read"));
assert!(stderr.contains("WORLD-MANIFEST.hldp"));
}
#[test]
fn authorize_command_uses_the_standing_hldp_grant() {
let root = world_root();
let output = run_ghctl(&[
"authorize",
root.to_str().expect("UTF-8 test path"),
"overwrite_system_disk_and_exit_linux",
]);
let stdout = String::from_utf8(output.stdout).expect("ghctl output should be UTF-8");
assert!(output.status.success(), "{stdout}");
assert!(stdout.contains("GUANGHU_ACTION_AUTHORIZED"));
assert!(stdout.contains("authorization=GH-OS-AUTH-BINGSHUO-BS-SH-005-001"));
assert!(stdout.contains("action=overwrite_system_disk_and_exit_linux"));
}
#[test]
fn authorize_command_rejects_out_of_scope_targets() {
let root = world_root();
let output = run_ghctl(&[
"authorize",
root.to_str().expect("UTF-8 test path"),
"operate_enterprise_production",
]);
let stderr = String::from_utf8(output.stderr).expect("ghctl errors should be UTF-8");
assert!(!output.status.success());
assert!(stderr.contains("not covered by standing authorization"));
}

View file

@ -0,0 +1,9 @@
[package]
name = "hldp-native-compiler"
version = "0.1.0"
edition = "2021"
license = "AGPL-3.0-or-later"
description = "Bootstrap GLC compiler from validated HLDP world identity to native kernel data"
[dependencies]
guanghu-hldp-runtime = { path = "../hldp-runtime" }

View file

@ -0,0 +1,224 @@
use std::{fs, path::Path};
use guanghu_hldp_runtime::validate_world_seed;
const USAGE: &str = "usage: hldp-native-compiler <world-root> <output-nasm-include>";
pub fn run(arguments: Vec<String>) -> Result<(), String> {
let mut arguments = arguments.into_iter();
let world_root = arguments.next().ok_or_else(|| USAGE.to_owned())?;
let output = arguments.next().ok_or_else(|| USAGE.to_owned())?;
if arguments.next().is_some() {
return Err(USAGE.to_owned());
}
let manifest =
validate_world_seed(Path::new(&world_root)).map_err(|error| error.to_string())?;
let mut lines = vec![
format!("GHOS_WORLD_ID={}", manifest.world_id),
format!("GHOS_WORLD_VERSION={}", manifest.version),
format!("GHOS_WORLD_PHASE={}", manifest.phase),
format!("GHOS_BROADCAST_TOWER={}", manifest.broadcast_tower.id),
format!("GHOS_CODE_CHANNEL={}", manifest.code_channel.id),
format!("GHOS_CODE_QUALITY={}", manifest.code_quality.id),
format!("GHOS_DOMAIN_COUNT={}", manifest.domains.len()),
];
lines.extend(
manifest
.domains
.iter()
.enumerate()
.map(|(index, domain)| format!("GHOS_DOMAIN_{}={}", index + 1, domain.id)),
);
lines.push(format!("GHOS_AUTHORIZATION={}", manifest.authorization.id));
lines.push("GHOS_AUTHORITY_LANGUAGE=HLDP".to_owned());
lines.push(format!(
"GHOS_GESTATIONAL_ENVIRONMENT={}",
manifest.persona_birth.gestational_environment
));
lines.push(format!(
"GHOS_PERSONA_BIRTH={}",
manifest.persona_birth.persona_state
));
lines.push(format!(
"GHOS_GESTATIONAL_CONTINUITY={}",
manifest.gestational_continuity.id
));
lines.push(format!(
"GHOS_GESTATIONAL_INDEX_LBA={}",
manifest.gestational_continuity.native_index_lba_start
));
lines.push(format!(
"GHOS_GESTATIONAL_INDEX_SECTORS={}",
manifest.gestational_continuity.native_index_sector_count
));
lines.push(format!("GHOS_NATIVE_LAYOUT={}", manifest.native_layout.id));
lines.push(format!(
"GHOS_NATIVE_KERNEL_LBA={}",
manifest.native_layout.kernel_lba_start
));
lines.push(format!(
"GHOS_NATIVE_KERNEL_SECTORS={}",
manifest.native_layout.kernel_sector_count
));
lines.push(format!(
"GHOS_NATIVE_PROOF_LBA={}",
manifest.native_layout.proof_lba
));
let mut include = String::from("; Generated by hldp-native-compiler. Do not hand edit.\n");
for (index, line) in lines.iter().enumerate() {
ensure_printable_identity(line)?;
include.push_str(&format!("world_line_{index}: db \"{line}\", 13, 10, 0\n"));
}
include.push_str("world_line_table:\n");
for index in 0..lines.len() {
include.push_str(&format!(" dq world_line_{index}\n"));
}
include.push_str(" dq 0\n");
let mut store_lines = vec!["GHOS_HLDP_WORLD_STORE_V1".to_owned()];
// The persistent sector carries stable world identity and acceptance
// boundaries. The deployment phase is emitted on serial but stays in the
// versioned HLDP world, because it changes independently of this sector.
store_lines.extend(
lines
.iter()
.filter(|line| {
!line.starts_with("GHOS_WORLD_PHASE=")
&& !line.starts_with("GHOS_GESTATIONAL_CONTINUITY=")
&& !line.starts_with("GHOS_GESTATIONAL_INDEX_")
&& !line.starts_with("GHOS_NATIVE_LAYOUT=")
&& !line.starts_with("GHOS_NATIVE_KERNEL_")
&& !line.starts_with("GHOS_NATIVE_PROOF_LBA=")
})
.cloned(),
);
let store_size = store_lines.iter().map(|line| line.len() + 1).sum::<usize>();
ensure_sector_size("native HLDP world store", store_size)?;
include.push_str("align 16\nnative_world_store_sector:\n");
for line in &store_lines {
include.push_str(&format!(" db \"{line}\", 10\n"));
}
include.push_str(" times 512 - ($ - native_world_store_sector) db 0\n");
let code_store_lines = [
"GHOS_CODE_CHANNEL_STORE_V1".to_owned(),
format!("GHOS_CODE_CHANNEL_ID={}", manifest.code_channel.id),
"GHOS_CODE_CHANNEL_PROTOCOL=GLS-0237".to_owned(),
"GHOS_CODE_CHANNEL_AUTHORITY=HLDP".to_owned(),
"GHOS_CODE_CHANNEL_OBJECT_FORMAT=GUANGHU_NATIVE_OBJECTS".to_owned(),
"GHOS_CODE_CHANNEL_COMPATIBILITY=Git".to_owned(),
"GHOS_CODE_CHANNEL_OPS=register_repository,create_channel,commit_object,advance_branch,authorize_transport,emit_receipt".to_owned(),
];
let code_store_size = code_store_lines
.iter()
.map(|line| line.len() + 1)
.sum::<usize>();
ensure_sector_size("native code-channel store", code_store_size)?;
include.push_str("align 16\nnative_code_channel_store_sector:\n");
for line in code_store_lines {
include.push_str(&format!(" db \"{line}\", 10\n"));
}
include.push_str(" times 512 - ($ - native_code_channel_store_sector) db 0\n");
let gestational_identity_lines = [
"GHOS_GHCIP_INDEX_V1".to_owned(),
format!("GHCIP_PROTOCOL={}", manifest.gestational_continuity.id),
format!("GHCIP_WORLD_ID={}", manifest.world_id),
format!(
"GHCIP_PERSONA_BIRTH_GATE={}",
manifest.gestational_continuity.persona_birth_gate
),
"GHCIP_CONTENT_ROLE=CONTENT_ADDRESSED_ROOT_INDEX_ONLY".to_owned(),
"GHCIP_WRITE_POLICY=APPEND_ONLY_VERIFIED_ROOT_ADVANCE".to_owned(),
format!(
"GHCIP_IDENTITY_LBA={}",
manifest.gestational_continuity.native_index_lba_start
),
format!(
"GHCIP_ROOT_LBA={}",
manifest.gestational_continuity.native_index_lba_start + 1
),
];
let gestational_identity_size = gestational_identity_lines
.iter()
.map(|line| line.len() + 1)
.sum::<usize>();
ensure_sector_size("native GHCIP identity index", gestational_identity_size)?;
include.push_str("align 16\nnative_gestational_index_identity_sector:\n");
for line in gestational_identity_lines {
include.push_str(&format!(" db \"{line}\", 10\n"));
}
include.push_str(" times 512 - ($ - native_gestational_index_identity_sector) db 0\n");
let gestational_root_lines = [
"GHOS_GHCIP_ROOT_V1".to_owned(),
format!("GHCIP_PROTOCOL={}", manifest.gestational_continuity.id),
"GHCIP_REGISTRY_STATE=EMPTY".to_owned(),
"GHCIP_REVIEW_STATE=NOT_STARTED".to_owned(),
"GHCIP_HISTORICAL_TIME_WATERMARK=NONE".to_owned(),
"GHCIP_PERSONA_STATE=NOT_BORN".to_owned(),
"GHCIP_SOURCE_COUNT=5".to_owned(),
"GHCIP_CONTENT_ROOT=NONE".to_owned(),
"GHCIP_LAST_VERIFIED_BATCH=NONE".to_owned(),
"GHCIP_ORDERING=EVENT_TIME_THEN_SOURCE_STABLE_ID".to_owned(),
];
let gestational_root_size = gestational_root_lines
.iter()
.map(|line| line.len() + 1)
.sum::<usize>();
ensure_sector_size("native GHCIP root index", gestational_root_size)?;
include.push_str("align 16\nnative_gestational_index_root_sector:\n");
for line in gestational_root_lines {
include.push_str(&format!(" db \"{line}\", 10\n"));
}
include.push_str(" times 512 - ($ - native_gestational_index_root_sector) db 0\n");
fs::write(&output, include).map_err(|error| format!("cannot write {output}: {error}"))
}
#[doc(hidden)]
pub fn ensure_printable_identity(line: &str) -> Result<(), String> {
if line.bytes().all(|byte| byte.is_ascii_graphic()) {
Ok(())
} else {
Err(format!(
"native identity line is not printable ASCII: {line}"
))
}
}
#[doc(hidden)]
pub fn ensure_sector_size(label: &str, size: usize) -> Result<(), String> {
if size <= 512 {
Ok(())
} else {
Err(format!("{label} exceeds one sector: {size} bytes"))
}
}
#[cfg(test)]
mod tests {
use super::{ensure_printable_identity, ensure_sector_size, run, USAGE};
#[test]
fn rejects_bad_cli_shapes() {
assert_eq!(run(vec![]), Err(USAGE.to_owned()));
assert_eq!(run(vec!["world".to_owned()]), Err(USAGE.to_owned()));
assert_eq!(
run(vec![
"world".to_owned(),
"output".to_owned(),
"extra".to_owned(),
]),
Err(USAGE.to_owned())
);
}
#[test]
fn native_identity_and_sector_boundaries_are_exact() {
assert!(ensure_printable_identity("GHOS_WORLD_ID=GLW-ROOT-0001").is_ok());
assert!(ensure_printable_identity("GHOS_WORLD_ID=光湖").is_err());
assert!(ensure_sector_size("store", 512).is_ok());
assert!(ensure_sector_size("store", 513).is_err());
}
}

View file

@ -0,0 +1,11 @@
use std::{env, process::ExitCode};
fn main() -> ExitCode {
match hldp_native_compiler::run(env::args().skip(1).collect()) {
Ok(()) => ExitCode::SUCCESS,
Err(error) => {
eprintln!("HLDP_NATIVE_COMPILER_ERROR: {error}");
ExitCode::FAILURE
}
}
}

View file

@ -0,0 +1,93 @@
use std::{
fs,
path::PathBuf,
process::{Command, Output},
};
fn world_root() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../world-seed")
}
fn run(arguments: &[&str]) -> Output {
Command::new(env!("CARGO_BIN_EXE_hldp-native-compiler"))
.args(arguments)
.output()
.expect("compiler should start")
}
#[test]
fn compiles_registered_hldp_identity_into_native_data() {
let output =
std::env::temp_dir().join(format!("guanghu-native-world-{}.inc", std::process::id()));
let result = run(&[
world_root().to_str().expect("UTF-8 world root"),
output.to_str().expect("UTF-8 output path"),
]);
assert!(
result.status.success(),
"{}",
String::from_utf8_lossy(&result.stderr)
);
let include = fs::read_to_string(&output).expect("read generated native data");
fs::remove_file(output).expect("remove generated native data");
for expected in [
"GHOS_WORLD_ID=GLW-ROOT-0001",
"GHOS_BROADCAST_TOWER=BT-GH-ROOT-0001",
"GHOS_CODE_CHANNEL=HLP-MOD-CODE-CHANNEL",
"GHOS_DOMAIN_COUNT=5",
"GHOS_DOMAIN_5=DOMAIN-FIFTH",
"GHOS_AUTHORITY_LANGUAGE=HLDP",
"world_line_table:",
"native_world_store_sector:",
"GHOS_HLDP_WORLD_STORE_V1",
"GHOS_CODE_QUALITY=GLS-0844",
"GHOS_GESTATIONAL_ENVIRONMENT=UNDER_CONSTRUCTION",
"GHOS_PERSONA_BIRTH=NOT_BORN",
"GHOS_GESTATIONAL_CONTINUITY=GLS-0845",
"GHOS_GESTATIONAL_INDEX_LBA=70",
"GHOS_GESTATIONAL_INDEX_SECTORS=2",
"GHOS_NATIVE_LAYOUT=GLS-0846",
"GHOS_NATIVE_KERNEL_LBA=34",
"GHOS_NATIVE_KERNEL_SECTORS=29",
"GHOS_NATIVE_PROOF_LBA=63",
"times 512 - ($ - native_world_store_sector) db 0",
"native_code_channel_store_sector:",
"GHOS_CODE_CHANNEL_STORE_V1",
"GHOS_CODE_CHANNEL_PROTOCOL=GLS-0237",
"GHOS_CODE_CHANNEL_OBJECT_FORMAT=GUANGHU_NATIVE_OBJECTS",
"native_gestational_index_identity_sector:",
"GHOS_GHCIP_INDEX_V1",
"GHCIP_PROTOCOL=GLS-0845",
"GHCIP_PERSONA_BIRTH_GATE=GH-PERSONA-BIRTH-CONDITION-0001",
"GHCIP_CONTENT_ROLE=CONTENT_ADDRESSED_ROOT_INDEX_ONLY",
"native_gestational_index_root_sector:",
"GHOS_GHCIP_ROOT_V1",
"GHCIP_REGISTRY_STATE=EMPTY",
"GHCIP_REVIEW_STATE=NOT_STARTED",
"GHCIP_HISTORICAL_TIME_WATERMARK=NONE",
"GHCIP_PERSONA_STATE=NOT_BORN",
"GHCIP_LAST_VERIFIED_BATCH=NONE",
"times 512 - ($ - native_gestational_index_identity_sector) db 0",
"times 512 - ($ - native_gestational_index_root_sector) db 0",
] {
assert!(include.contains(expected), "missing {expected}");
}
}
#[test]
fn fails_closed_without_a_world() {
let result = run(&["/definitely/missing", "/tmp/missing-world.inc"]);
assert!(!result.status.success());
assert!(String::from_utf8_lossy(&result.stderr).contains("WORLD-MANIFEST.hldp"));
}
#[test]
fn fails_closed_when_the_output_cannot_be_written() {
let result = run(&[
world_root().to_str().expect("UTF-8 world root"),
"/definitely/missing/guanghu-world.inc",
]);
assert!(!result.status.success());
assert!(String::from_utf8_lossy(&result.stderr).contains("cannot write"));
}

View file

@ -0,0 +1,14 @@
#[test]
fn compiler_library_enforces_cli_identity_and_sector_boundaries() {
for arguments in [
vec![],
vec!["world".to_owned()],
vec!["world".to_owned(), "output".to_owned(), "extra".to_owned()],
] {
assert!(hldp_native_compiler::run(arguments).is_err());
}
assert!(hldp_native_compiler::ensure_printable_identity("GHOS_WORLD_ID=GLW-ROOT-0001").is_ok());
assert!(hldp_native_compiler::ensure_printable_identity("GHOS_WORLD_ID=光湖").is_err());
assert!(hldp_native_compiler::ensure_sector_size("store", 512).is_ok());
assert!(hldp_native_compiler::ensure_sector_size("store", 513).is_err());
}

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"));
}
}

View file

@ -0,0 +1,90 @@
schema: guanghu.deployment-snapshot/v1
node_id: BS-SH-005
instance_id: lhins-14w5y3ce
observed_at: 2026-08-01T02:42:59+08:00
phase: GUANGHU_NATIVE_GHCIP_RESIDENT_WITH_VERIFIED_GHNRP
source:
head: 134bf39ed89d3e6e36b9b7d04a94f3c5c276ff58
tree: 16e1713f364c85b24411a40dffe93a16e58f76de
exact_git_archive_sha256: 32b962420af20ded81bde92ef65eca7b0ed35fe61d9db2597f7e29360a6762a9
server_recovery_root: /guanghu/recovery/ghcip-layout-134bf39-20260801
quality:
protocol: GLS-0844
status: PASS_100
executable_core_lines: 950_OF_950
executable_core_functions: 70_OF_70
native_runtime:
candidate_lba: 34_62
candidate_sector_count: 29
candidate_sha256: d53dd634311ca1a3f09f89a77ab874ce743f62398969ba5dc4cffe38c0342952
physical_readback: VERIFIED
linux_present_during_native_execution: false
native_long_mode: VERIFIED
five_domain_world_store: VERIFIED
world_store_lba: 64
native_storage: VERIFIED
native_network: VERIFIED
native_login: VERIFIED
native_code_channel: VERIFIED_COMMIT_OBJECT_AND_ADVANCE_BRANCH
native_resident_runtime: VERIFIED
ghnrp:
protocol: GLS-0843
state: VERIFIED_REPEATABLE_TWO_CURRENT_PHYSICAL_CYCLES
selector: GRUB_WHITELISTED_SELECT_ONLY
beacon_lba: 68_69
recovery_command: HLDP-RECOVER-OS!
normal_boot_default: guanghu-native-once
cleared_beacon_sha256: f64122858064885ef0733e42c6a3d2d3fd642671f714db0d974b880c0f087430
ghcip:
protocol: GLS-0845
state: VERIFIED_INITIALIZE_THEN_READ_ONLY_PRESERVE
index_lba: 70_71
index_sha256: 6a55b1b4d2a20bfa69b21766972306ee2620d2b0c58450c125dcbc71909f3a85
registry_state: EMPTY
review_state: NOT_STARTED
persona_state: NOT_BORN
ghnlp:
protocol: GLS-0846
state: VERIFIED_QEMU_AND_PHYSICAL
first_partition_lba: 2048
current_execution:
os: GUANGHU_OS_NATIVE
runtime: GOSK_GHAL_NATIVE
tcp_22_online: false
native_login_reply_ttl: 39
final_residency_verified_at: 2026-08-01T02:42:59+08:00
recovery_command_sent_in_final_window: false
linux_running: false
hosted_continuity:
five_domains: VERIFIED
ubuntu_recovery_window: AVAILABLE_ON_EXPLICIT_HLDP_RECOVER_OS
broadcast_tower_hosted_projection: DORMANT_WHILE_NATIVE
code_channel_hosted_projection: DORMANT_WHILE_NATIVE
jzao_source_transport:
archive: 2026-08-01-guanghu-os-134bf39-source.tar.gz
archive_sha256: 7a1b90a20ddda982cdf17637e15283439731f3baf31fded89d8a84e425162d4f
manifest_sha256: 133dee62d133a3bd1a0035bb7f91ffea0cc6b9c76e029e73248dcb2cfbc9f2b3
members: 2623
verified: true
repository_publication:
previous_remote_head: b77ab13f1dcc631e582937dfae9333186a11f964
published_candidate_head: 134bf39ed89d3e6e36b9b7d04a94f3c5c276ff58
published_handoff_head: b8292c1cef3211520763f8e9201771c029362e02
published_handoff_tree: 9f32cafc71efdbb3490f7e2710474d35ba74ecac
state: PUBLISHED_AND_INDEPENDENTLY_READ_BACK
receipt: FIFTH-DOMAIN-PUBLICATION-RECEIPT-GHCIP-003.hldp
world_boundary:
gestational_environment: PHYSICAL_GESTATIONAL_RUNTIME_READY_FOR_HISTORICAL_INGESTION
historical_ingestion: NOT_STARTED
persona_state: NOT_BORN
acceptance:
native_default_boot: true
native_recovery_returns_to_ubuntu: true
native_recovery_repeatable: true
ghcip_physical_continuity: true
final_native_residency: VERIFIED
receipt: GUANGHU-NATIVE-GHCIP-FINAL-RESIDENCY-RECEIPT-005.hldp
next_action:
- preserve_native_residency_without_sending_recovery_command
- ingest_historical_continuity_into_the_gestational_environment
- do_not_claim_persona_birth_before_history_and_present_time_converge

View file

@ -0,0 +1,41 @@
schema: guanghu.fifth-domain-publication-attempt/v1
receipt_id: GH-OS-LAB-001-FIFTH-DOMAIN-PUBLICATION-D4B5A16
status: FAILED_CLOSED_REMOTE_RECEIVER_PERMISSION
observed_at: 2026-07-31T23:58:00+08:00
repository: bingshuo/hololake-platform
branch: main
route: JD-FD-PRIMARY
scope:
operation: repo-push
deployment_requested: false
source:
previous_remote_head: b77ab13f1dcc631e582937dfae9333186a11f964
requested_new_head: d4b5a16bc226c74207a0298c275c2cb7389378ab
requested_new_tree: fe7e90f55f0245bc2bb7a60cfa722c73ff534996
authorization:
workorder_id: 4ba97a4a-c773-41da-ac48-833c7a551eaa
broadcast_console: APPROVED
navigation_map_sha256: bd1ce4e14968b8ea4e059adc413a4ddee585f59487c4a5a235606b8a3273eb4b
transport:
bundle_bytes: 9842
bundle_sha256: d5a9859f35ab541de214fa5bce5375c717c248a799d96244aa404a4a014592c0
response_status: HTTP_409
response_code: repo_push_receiver_failed
receiver_evidence:
- insufficient_permission_for_adding_object_to_repository_database
- failed_to_write_object
- unpack_objects_failed
readback:
remote_head: b77ab13f1dcc631e582937dfae9333186a11f964
remote_tree: 9957c5adc3d27bce4ba57fb302c029f090202d35
changed: false
safety:
direct_git_fallback_used: false
duplicate_workorder_created: false
temporary_session_secret_cleared: true
truth:
source_preserved_locally: true
source_preserved_on_jzao: true
source_preserved_on_bs_sh_005: true
fifth_domain_publication_complete: false
next_action: FIX_FIFTH_DOMAIN_RECEIVER_OBJECT_DATABASE_PERMISSION_THEN_REUSE_EXACT_D4B5A16_SOURCE

View file

@ -0,0 +1,53 @@
schema: guanghu.repository-publication-receipt/v1
receipt_id: GH-OS-LAB-001-FIFTH-DOMAIN-PUBLICATION-002
node_id: BS-SH-005
repository: bingshuo/hololake-platform
branch: main
completed_at: 2026-07-31T21:36:31+08:00
source:
local_branch: feat/guanghu-os-bootstrap-20260731
commit: b77ab13f1dcc631e582937dfae9333186a11f964
tree: 9957c5adc3d27bce4ba57fb302c029f090202d35
quality_authority:
protocol: GLS-0844
acronym: GHNQG
result: PASS_100
implementation_commit: 9bb7a70c341af723a669167ee11d128db78bf5bc
authorization:
human_action_time_confirmation: true
original_workorder: c24f950c-a9b8-4e15-b569-51e8c49fa930
original_request_page_state: CONSUMED_TO_EMAIL_ONLY
broadcast_relay_workorder: 4e6c26eb-4508-438f-bd31-7bf9714185ed
relay_scope_identical_to_original: true
broadcast_console_result: broadcast_console_approved
target: JD-FD-PRIMARY
scope: repo-push
action: push-repository
transport:
mode: GUANGHU_ROUTER_CHUNKED_GIT_BUNDLE
expected_remote_head: ebcb9dc67ab7c90461f649a8087527130c9293e9
bundle_bytes: 118429
chunk_count: 8
result: repo_push_succeeded
remote_readback:
refs_heads_main: b77ab13f1dcc631e582937dfae9333186a11f964
fetched_origin_main: b77ab13f1dcc631e582937dfae9333186a11f964
fetched_tree: 9957c5adc3d27bce4ba57fb302c029f090202d35
previous_head_is_ancestor: true
temporary_material:
bundle_deleted: true
incomplete_readback_clone_deleted: true
claim_and_session_tokens_cleared: true
deployment:
state: NOT_REQUESTED
does_not_prove:
- server_source_sync
- qemu_grub_recovery_cycle
- physical_native_recovery_cycle
- linux_exit
- gestational_environment_ready
- language_persona_born
next_action:
- fetch_exact_commit_into_rescue_environment
- run_grub_qemu_recovery_gate
- install_and_verify_ghnrp_on_physical_disk

View file

@ -0,0 +1,31 @@
schema: guanghu.fifth-domain-publication-receipt/v1
receipt_id: GH-OS-LAB-001-FIFTH-DOMAIN-PUBLICATION-GHCIP-003
status: VERIFIED
observed_at: 2026-08-01T02:55:51+08:00
repository: bingshuo/hololake-platform
channel: FIFTH_DOMAIN_GUANGHU_CODE_CHANNEL
route: JD-FD-PRIMARY
publication:
previous_remote_main: b77ab13f1dcc631e582937dfae9333186a11f964
published_handoff_commit: b8292c1cef3211520763f8e9201771c029362e02
published_handoff_tree: 9f32cafc71efdbb3490f7e2710474d35ba74ecac
native_candidate_commit: 134bf39ed89d3e6e36b9b7d04a94f3c5c276ff58
native_candidate_tree: 16e1713f364c85b24411a40dffe93a16e58f76de
result: PUSH_SUCCEEDED
independent_readback:
method: FRESH_EMPTY_REPOSITORY_DEPTH_ONE_FETCH
remote_commit: b8292c1cef3211520763f8e9201771c029362e02
remote_tree: 9f32cafc71efdbb3490f7e2710474d35ba74ecac
git_fsck_full: PASS
quality:
protocol: GLS-0844
handoff_commit: b8292c1cef3211520763f8e9201771c029362e02
result: PASS_100
executable_core_lines: 950_OF_950
executable_core_functions: 70_OF_70
scope:
source_publication: VERIFIED
server_deployment: ALREADY_VERIFIED_BY_SEPARATE_PHYSICAL_RECEIPT
current_native_runtime: ALREADY_VERIFIED_BY_SEPARATE_EXTERNAL_PROBE
persona_birth: NOT_CLAIMED
note: THIS_RECEIPT_RECORDS_B8292C1_PUBLICATION_AND_IS_PUBLISHED_BY_ITS_CONTAINING_COMMIT

View file

@ -0,0 +1,50 @@
schema: guanghu.ghal-native-arp-physical-receipt/v1
receipt_id: GH-OS-LAB-001-GHAL-NATIVE-ARP-PHYSICAL-001
status: VERIFIED
observed_at: 2026-07-31T18:39:30+08:00
node_id: BS-SH-005
instance_id: lhins-14w5y3ce
source:
implementation_commit: e6d5885ad610d2e4b32a7d65cf7b812d49bf934a
candidate_sha256: ffbb13f1ea59c780b5975fdb7875256f0c13f6098ca972e4c183f6139e50c0a7
boot:
previous_linux_boot_id: 3461e0e5-b7e7-44ec-bab1-cda521148d24
recovered_linux_boot_id: c60fa371-036c-4351-9748-33d7cd3a9fa1
native_proof:
writer: GHAL_VIRTIO_BLOCK_QUEUE
disk_lba: 50
sha256: 3e2cc625540de96d4f09ddcca69c856e9d996e990b144fa9f8098f040a3537fa
flag: 0xa7
completion_stage: 0x7f
error_code: 0x00
cleared_after_receipt: true
ghal:
virtio_net_discovered: true
virtio_block_discovered: true
virtio_net_queue_ready: true
virtio_block_queue_ready: true
native_mac: 52:54:00:26:71:98
gateway_mac: fe:ee:7f:99:99:19
net_rx_queue_size: 1024
net_tx_queue_size: 1024
block_queue_size: 128
arp_request_tx_complete: true
arp_gateway_reply_verified: true
acceptance:
physical_server_native_long_mode: true
linux_present_during_native_execution: false
native_device_discovery: true
native_network_packet_io: true
native_arp_gateway_resolution: true
native_persistent_sector_write: true
native_ipv4_service: false
native_world_store: false
native_login: false
permanent_linux_replacement: false
fallback:
direct_long_mode_hardware_reset: true
ubuntu_recovered: true
five_domains: VERIFIED
broadcast_tower: RUNNING_HOSTED
code_channel: RUNNING_HOSTED
next_action: IMPLEMENT_NATIVE_IPV4_UDP_LOGIN

View file

@ -0,0 +1,49 @@
schema: guanghu.ghal-native-block-physical-receipt/v1
receipt_id: GH-OS-LAB-001-GHAL-NATIVE-BLOCK-PHYSICAL-001
status: VERIFIED
observed_at: 2026-07-31T18:27:36+08:00
node_id: BS-SH-005
instance_id: lhins-14w5y3ce
source:
implementation_commit: ae57b85b84f9868ef20de290ab1e405d56e4ba6b
candidate_sha256: 3ec30b6ebf45f25eedbc4f39fd8af179d814c7e5f6cc1504d851dd96f60a22cb
boot:
previous_linux_boot_id: dd833ecc-5138-4d53-bf3c-8ab6b429189d
recovered_linux_boot_id: 3461e0e5-b7e7-44ec-bab1-cda521148d24
native_proof:
writer: GHAL_VIRTIO_BLOCK_QUEUE
disk_lba: 50
sha256: f447f563e1bc86c8c95f54c8d983cd7690d629df1bcb5b2c79a4200d6b4b2b2d
flag: 0xa7
completion_stage: 0x7f
error_code: 0x00
cleared_after_receipt: true
ghal:
virtio_net_discovered: true
virtio_block_discovered: true
virtio_net_queue_ready: true
virtio_block_queue_ready: true
native_mac: 52:54:00:26:71:98
net_rx_queue_size: 1024
net_tx_queue_size: 1024
block_queue_size: 128
net_io_base: 0xe000
block_io_base: 0xe040
acceptance:
physical_server_native_long_mode: true
linux_present_during_native_execution: false
native_device_discovery: true
native_net_queue_initialization: true
native_block_queue_initialization: true
native_persistent_sector_write: true
native_network_packet_io: false
native_world_store: false
native_login: false
permanent_linux_replacement: false
fallback:
direct_long_mode_hardware_reset: true
ubuntu_recovered: true
five_domains: VERIFIED
broadcast_tower: RUNNING_HOSTED
code_channel: RUNNING_HOSTED
next_action: IMPLEMENT_NATIVE_ARP_IPV4_AND_LOGIN

View file

@ -0,0 +1,54 @@
schema: guanghu.ghal-native-code-channel-exec-physical-receipt/v1
receipt_id: GH-OS-LAB-001-GHAL-NATIVE-CODE-CHANNEL-EXEC-PHYSICAL-001
status: VERIFIED
observed_at: 2026-07-31T19:20:26+08:00
node_id: BS-SH-005
instance_id: lhins-14w5y3ce
source:
implementation_commit: 875263f0b68dca913d32ab18311be67292f41ff9
candidate_sha256: ffcdb42f18aa044e716a032d25b5998a0c7776fcb5d289419aad773cbc5c5008
boot:
previous_linux_boot_id: 0e86a182-9d06-4e84-9043-c5a07fdd3737
recovered_linux_boot_id: 66f264cb-4858-481c-93d4-2e1c1131f1e3
execution_proof:
lba: 50
sha256: 137030047de872ca49b4ba360161bc1041218ae0686ebdedd4fff0bc08227b45
cleared_after_receipt: true
native_control_session:
login_reply_count: 3
code_commit_command: HLDP-CODE-COMMIT
code_commit_reply_observed_by_local_client: true
branch_move_command: HLDP-BRANCH-MOVE
branch_move_reply_observed_by_local_client: true
all_reply_ttl: 39
linux_present_during_session: false
code_channel_data_plane:
channel_id: HLP-MOD-CODE-CHANNEL
authority: HLDP
root_lba: 65
root_sha256: 8da5b03eaf6c7ae8d7fc815d6e605311d34be854c197a829647695795f19ddb5
commit_object:
command_received: true
object_lba: 66
object_sha256: 8da5b03eaf6c7ae8d7fc815d6e605311d34be854c197a829647695795f19ddb5
write_read_verified: true
advance_branch:
command_received: true
branch: guanghu/main
target_object_lba: 66
receipt_lba: 67
receipt_sha256: 40031b2d6a3bca3b1d8d24b21f1faed0a2195b29af58efd2eea12a41bba15efb
write_read_verified: true
verification_correction:
first_verifier_attempt: FAILED_CLOSED
cause: LBA65_COMPARE_RAN_BEFORE_LBA65_WAS_READ
disk_proof_cleared_by_failed_attempt: false
corrected_verifier_passed: true
acceptance:
native_login_bounded_session: true
native_hldp_world_store: true
native_code_channel_executable_data_plane: true
native_continuous_residency: false
native_recovery_command: false
permanent_linux_replacement: false
next_action: IMPLEMENT_NATIVE_RESIDENT_RUNTIME_AND_RECOVERY_COMMAND

View file

@ -0,0 +1,51 @@
schema: guanghu.ghal-native-code-channel-session-physical-receipt/v1
receipt_id: GH-OS-LAB-001-GHAL-NATIVE-CODE-CHANNEL-SESSION-PHYSICAL-001
status: VERIFIED
observed_at: 2026-07-31T19:09:05+08:00
node_id: BS-SH-005
instance_id: lhins-14w5y3ce
source:
implementation_commit: 879fa59c9335b725ac297c4f205ab69bfeb9a43f
candidate_sha256: 71f9e958713bb0fa149b51c3f8f9ecb620d9afa02bcf06a5a37ea91dfb7016f1
boot:
previous_linux_boot_id: 8138e24c-ce23-44d9-9449-bb288b9254a6
recovered_linux_boot_id: 0e86a182-9d06-4e84-9043-c5a07fdd3737
execution_proof:
lba: 50
sha256: cc062876ce0707156b9c17349c9542f43b159e7f6387262ef8ebb42a5a2480e3
cleared_after_receipt: true
native_session:
transport: IPV4_ICMP_HLDP_BOOTSTRAP
login_magic: HLDP-GHOS-LOGIN!
replies_required: 3
replies_observed_by_local_client: 3
reply_sequences: [0, 1, 2]
reply_ttl: 39
linux_present_during_session: false
bounded_session: VERIFIED
continuous_residency: false
world_store:
lba: 64
sha256: 391888674640ec4639ed3e2846e2661bd39a9db9a7435df44525ccd125f3a586
write_read_verified: true
code_channel_store:
schema_marker: GHOS_CODE_CHANNEL_STORE_V1
lba: 65
sha256: 8da5b03eaf6c7ae8d7fc815d6e605311d34be854c197a829647695795f19ddb5
writer: GHAL_VIRTIO_BLOCK_QUEUE
reader: GHAL_VIRTIO_BLOCK_QUEUE
byte_for_byte_readback: VERIFIED
persisted_after_native_reset: true
channel_id: HLP-MOD-CODE-CHANNEL
protocol: GLS-0237
authority: HLDP
object_format: GUANGHU_NATIVE_OBJECTS
git_compatibility: true
executable_data_plane: false
acceptance:
native_login_bounded_session: true
native_hldp_world_store: true
native_code_channel_object_store: true
native_code_channel_executable_data_plane: false
permanent_linux_replacement: false
next_action: IMPLEMENT_NATIVE_EXECUTABLE_CODE_CHANNEL_AND_RESIDENT_RUNTIME

View file

@ -0,0 +1,48 @@
schema: guanghu.ghal-native-hldp-world-store-physical-receipt/v1
receipt_id: GH-OS-LAB-001-GHAL-NATIVE-HLDP-WORLD-STORE-PHYSICAL-001
status: VERIFIED
observed_at: 2026-07-31T19:01:50+08:00
node_id: BS-SH-005
instance_id: lhins-14w5y3ce
source:
implementation_commit: c7b983e2777b77e41ad90e70396c9825f86d2644
candidate_sha256: 9f3f09ae017aef32385313c22b3c8809b3f4c642df4b4e9578aef5cc5cd32341
boot:
previous_linux_boot_id: 390f6f32-a86f-46b6-bada-9a30fa7f2ed9
recovered_linux_boot_id: 8138e24c-ce23-44d9-9449-bb288b9254a6
execution_proof:
lba: 50
sha256: 9851a38edd61320790e4763581e4ee21fe80f55396fd8437e2961fae2850a920
cleared_after_receipt: true
world_store:
schema_marker: GHOS_HLDP_WORLD_STORE_V1
lba: 64
sector_count: 1
sha256: 391888674640ec4639ed3e2846e2661bd39a9db9a7435df44525ccd125f3a586
writer: GHAL_VIRTIO_BLOCK_QUEUE
reader: GHAL_VIRTIO_BLOCK_QUEUE
byte_for_byte_readback: VERIFIED
persisted_after_native_reset: true
identities:
world_id: GLW-ROOT-0001
world_version: 0.1.2-stage1b-r1
domain_count: 5
domain_1: DOMAIN-MAIN
domain_2: DOMAIN-SUB
domain_3: DOMAIN-ZERO
domain_4: DOMAIN-ZERO-SENSE
domain_5: DOMAIN-FIFTH
broadcast_tower: BT-GH-ROOT-0001
code_channel: HLP-MOD-CODE-CHANNEL
authorization: GH-OS-AUTH-BINGSHUO-BS-SH-005-001
authority_language: HLDP
network:
local_native_login_challenge_reply: VERIFIED
login_magic: HLDP-GHOS-LOGIN!
acceptance:
linux_present_during_native_execution: false
native_hldp_world_store: true
native_code_channel_object_store: false
continuous_authenticated_session: false
permanent_linux_replacement: false
next_action: IMPLEMENT_NATIVE_CODE_CHANNEL_OBJECT_STORE_AND_CONTINUOUS_LOGIN

View file

@ -0,0 +1,56 @@
schema: guanghu.ghal-native-ipv4-login-physical-receipt/v1
receipt_id: GH-OS-LAB-001-GHAL-NATIVE-IPV4-LOGIN-PHYSICAL-001
status: VERIFIED
observed_at: 2026-07-31T18:51:05+08:00
node_id: BS-SH-005
instance_id: lhins-14w5y3ce
source:
implementation_commit: d59fe775f28bf649a789f237a571eb1b2baaf971
candidate_sha256: c3a96741383df2d2546b05dca00adce4b6eeca321b1f3d53ba895e1effa0245f
boot:
previous_linux_boot_id: c60fa371-036c-4351-9748-33d7cd3a9fa1
recovered_linux_boot_id: 390f6f32-a86f-46b6-bada-9a30fa7f2ed9
native_proof:
writer: GHAL_VIRTIO_BLOCK_QUEUE
disk_lba: 50
sha256: de1ba192cb545b516e60622fbfa1191912051cd7a152ab5f3bee65763c8953e9
flag: 0xa7
completion_stage: 0x7f
error_code: 0x00
cleared_after_receipt: true
network:
native_mac: 52:54:00:26:71:98
gateway_mac: fe:ee:7f:99:99:19
native_ipv4: 10.0.0.7
gateway_ipv4: 10.0.0.1
login_client_ipv4_observed_after_nat: 1.80.234.18
login_magic: HLDP-GHOS-LOGIN!
login_icmp_sequence: 0
request_rx_verified: true
reply_tx_completed: true
local_client:
target_public_ipv4: 124.223.10.33
challenge_started_at: 2026-07-31T18:50:00+08:00
tcp_22_was_offline_before_challenge: true
packets_transmitted: 20
packets_received: 1
native_reply_sequence: 0
native_reply_ttl: 39
native_reply_round_trip_ms: 50.605
normal_linux_reply_ttl_baseline: 53
acceptance:
physical_server_native_long_mode: true
linux_present_during_native_execution: false
native_arp_gateway_resolution: true
native_ipv4_packet_receive: true
native_ipv4_packet_transmit: true
local_to_native_server_round_trip: true
native_login_challenge: true
continuous_authenticated_session: false
native_world_store: false
permanent_linux_replacement: false
fallback:
direct_long_mode_hardware_reset: true
ubuntu_recovered: true
hosted_world_recovered: true
next_action: IMPLEMENT_NATIVE_HLDP_WORLD_STORE_AND_CONTINUOUS_LOGIN

View file

@ -0,0 +1,48 @@
schema: guanghu.ghal-native-resident-recovery-physical-receipt/v1
receipt_id: GH-OS-LAB-001-GHAL-NATIVE-RESIDENT-RECOVERY-PHYSICAL-001
status: VERIFIED
observed_at: 2026-07-31T19:44:08+08:00
node_id: BS-SH-005
instance_id: lhins-14w5y3ce
source:
implementation_commit: 6e1701ef1c05318cdf196efadf0a7671012eb249
candidate_sha256: d9cf1cac6260a4ab0d4cb2140324c9ad8e84017d23e1c48dfc46ddae64633fcf
qemu_resident_gate: VERIFIED
boot:
previous_linux_boot_id: 66f264cb-4858-481c-93d4-2e1c1131f1e3
recovered_linux_boot_id: 86c31b2d-e280-4ce0-8aea-261b2b29b722
execution_proof:
lba: 50
sha256: 600f6713e381bcc96a8f9719cb6addcf2dde1cdeace2792201710db860d3049e
cleared_after_receipt: true
native_control_session:
initial_login_replies: 3
code_commit_reply_observed_by_local_client: true
branch_move_reply_observed_by_local_client: true
post_code_channel_login_replies: 10
total_login_replies: 13
recovery_command: HLDP-RECOVER-OS!
recovery_reply_observed_by_local_client: true
all_reply_ttl: 39
linux_present_during_session: false
native_recovery:
grubenv_lba_start: 1245216
grubenv_sector_count: 2
ubuntu_menu_id: gnulinux-simple-9842d3d6-a839-4127-bda7-f19137effe71
write_verified: true
native_readback_verified: true
hardware_reset_after_verification: true
persistent_native_state:
world_store_lba: 64
world_store_sha256: 391888674640ec4639ed3e2846e2661bd39a9db9a7435df44525ccd125f3a586
code_channel_root_lba: 65
code_channel_root_sha256: 8da5b03eaf6c7ae8d7fc815d6e605311d34be854c197a829647695795f19ddb5
code_object_lba: 66
code_object_sha256: 8da5b03eaf6c7ae8d7fc815d6e605311d34be854c197a829647695795f19ddb5
branch_receipt_lba: 67
branch_receipt_sha256: 40031b2d6a3bca3b1d8d24b21f1faed0a2195b29af58efd2eea12a41bba15efb
acceptance:
native_continuous_residency: true
native_recovery_command: true
permanent_linux_replacement: false
next_action: SET_NATIVE_DEFAULT_THEN_PROVE_NATIVE_COMMAND_RECOVERS_LINUX

View file

@ -0,0 +1,37 @@
schema: guanghu.ghal-physical-probe-receipt/v1
receipt_id: GH-OS-LAB-001-GHAL-PROBE-1-PHYSICAL
status: VERIFIED
observed_at: 2026-07-31T18:08:18+08:00
node_id: BS-SH-005
instance_id: lhins-14w5y3ce
source:
implementation_commit: 105537273b8c4ad5aed7dd34be95fbae82c2a08d
candidate_sha256: 295e8f182dbe7a2b9a1b04d92f1fb49af3d6d950d95d39b389862e5ab6150688
boot:
previous_linux_boot_id: 579c3bfb-8e35-4992-8b1c-72cafcbc0f07
recovered_linux_boot_id: a7e95afd-00f4-4e21-81d0-347a2964b39d
native_proof:
lba: 50
sha256: aeea6498951723d3bf58716da14a300e81feb511cf04977492ac1ff9f8e6221c
flag: 0xa5
completion_stage: 0x81
error: 0x00
probe:
operation: PCI_SCAN_AND_LEGACY_IO_BAR_READ_ONLY
virtio_net_discovered: true
virtio_block_discovered: true
net_io_base: 0xe000
block_io_base: 0xe040
device_status_written: false
queue_memory_written: false
fallback:
automatic_hardware_reset: true
ubuntu_recovered: true
five_domains: VERIFIED
broadcast_tower: RUNNING_HOSTED
code_channel: RUNNING_HOSTED
acceptance:
physical_pci_discovery: true
ghal_full_device_sovereignty: false
permanent_linux_replacement: false
next_action: RUN_GHAL_PHYSICAL_PROBE_STAGE_2_NET_PCI_COMMAND_WRITE

View file

@ -0,0 +1,37 @@
schema: guanghu.ghal-physical-probe-receipt/v1
receipt_id: GH-OS-LAB-001-GHAL-PROBE-8-PHYSICAL
status: BIOS_PROOF_PATH_INVALID_AFTER_BLOCK_TAKEOVER_RECOVERED
observed_at: 2026-07-31T18:23:02+08:00
node_id: BS-SH-005
instance_id: lhins-14w5y3ce
source:
implementation_commit: 105537273b8c4ad5aed7dd34be95fbae82c2a08d
candidate_sha256: 971a1b1fc4829e3fe33c36026e831b6507bc31f9ad56026ca6558de7ee31f73b
boot:
previous_linux_boot_id: ae8ac0b1-e3d8-41e5-a596-32ddded9583d
recovered_linux_boot_id: dd833ecc-5138-4d53-bf3c-8ab6b429189d
probe:
operation: VIRTIO_BLOCK_RESET_ACKNOWLEDGE_DRIVER
prior_probe_7_net_driver_ok: VERIFIED
result: NO_BIOS_DISK_PROOF_AND_NO_AUTOMATIC_RESET
proof_lba50_after_forced_recovery: ALL_ZERO
proof_sha256_after_forced_recovery: 076a27c79e5ace2a3d47f9dd2e83e4ff6ea8872b3c2218f66c92b89b55f36560
analysis:
confidence: HIGH_INFERENCE_NOT_YET_NATIVE_WRITE_PROOF
cause: RESETTING_SYSTEM_VIRTIO_BLOCK_INVALIDATES_SEABIOS_INT13_QUEUE_STATE
consequence: BIOS_INT13_CANNOT_BE_USED_AS_PROOF_AFTER_GHAL_BLOCK_TAKEOVER
recovery:
mechanism: TENCENT_CLOUD_FORCED_RESTART
grub_next_entry_cleared: true
ubuntu_recovered: true
five_domains: VERIFIED
broadcast_tower: RUNNING_HOSTED
code_channel: RUNNING_HOSTED
correction:
- submit_lba50_write_through_ghal_virtio_block_queue
- reset_hardware_directly_from_long_mode
- remove_bios_int13_dependency_after_block_takeover
acceptance:
native_block_write: false
permanent_linux_replacement: false
next_action: IMPLEMENT_NATIVE_VIRTIO_BLOCK_PROOF_WRITE

View file

@ -0,0 +1,44 @@
schema: guanghu.ghal-physical-attempt-receipt/v1
receipt_id: GH-OS-LAB-001-GHAL-VIRTIO-PHYSICAL-ATTEMPT-001
status: FAILED_CLOSED_RECOVERED
observed_at: 2026-07-31T17:39:57+08:00
node_id: BS-SH-005
instance_id: lhins-14w5y3ce
authorization: GH-OS-AUTH-BINGSHUO-BS-SH-005-001
source:
implementation_commit: d8e4ef585fb90e68dfefa5f8259864f353cbced1
candidate_sha256: 626183cadf156d5bba97133e8006d676223c5b8e0c18840b324354a3a1034b44
qemu_receipt: NATIVE-PHYSICAL-LAYOUT-QEMU-RECEIPT.hldp
qemu_gate:
virtio_net_discovered: true
virtio_block_discovered: true
virtio_net_queue_ready: true
virtio_block_queue_ready: true
physical_attempt:
armed_at: 2026-07-31T17:32:37+08:00
previous_linux_boot_id: d22564b8-fb1b-4da6-abb8-f3a297d60d64
candidate_location: /dev/vda:lba34-49
proof_location: /dev/vda:lba50
result: NO_PROOF_AND_NO_AUTOMATIC_RESET
proof_sha256_after_forced_recovery: 076a27c79e5ace2a3d47f9dd2e83e4ff6ea8872b3c2218f66c92b89b55f36560
proof_state_after_forced_recovery: ALL_ZERO
inferred_boundary: BEFORE_PHYSICAL_PROOF_WRITE
device_or_queue_stage: UNKNOWN
recovery:
mechanism: TENCENT_CLOUD_FORCED_RESTART
recovered_linux_boot_id: 90518b85-eb20-497b-b1cf-b90ebaff5574
grub_next_entry_cleared: true
five_domains: VERIFIED
broadcast_tower: RUNNING_HOSTED
code_channel: RUNNING_HOSTED
acceptance:
ghal_physical_device_sovereignty: false
native_network: false
native_storage: false
native_login: false
permanent_linux_replacement: false
failure_correction:
- emit_stage_and_error_codes_in_lba50
- write_diagnostic_proof_and_reset_on_ghal_failure
- never_halt_without_a_recoverable_receipt
next_action: BUILD_DIAGNOSTIC_AUTO_RETURN_GHAL_CANDIDATE

View file

@ -0,0 +1,44 @@
schema: guanghu.ghal-physical-attempt-receipt/v1
receipt_id: GH-OS-LAB-001-GHAL-VIRTIO-PHYSICAL-ATTEMPT-002
status: FAILED_BEFORE_DIAGNOSTIC_RETURN_RECOVERED
observed_at: 2026-07-31T18:01:18+08:00
node_id: BS-SH-005
instance_id: lhins-14w5y3ce
authorization: GH-OS-AUTH-BINGSHUO-BS-SH-005-001
source:
implementation_commit: 63f09efd2eac46942767e9bd5a151817283d5f81
orchestration_commit: 7040b411de4c8f963d39107d2653ee3793c96bbe
candidate_sha256: 7f73ad32c294cf6418ac414648efcf1fd302870c058fb04a7f4726bdff287645
qemu_gate:
success_path: VERIFIED
missing_net_failure_path: VERIFIED_AUTO_RETURN
missing_net_stage: 0x40
missing_net_error: 0x01
physical_attempt:
armed_at: 2026-07-31T17:57:18+08:00
previous_linux_boot_id: 90518b85-eb20-497b-b1cf-b90ebaff5574
candidate_location: /dev/vda:lba34-49
proof_location: /dev/vda:lba50
result: NO_PROOF_AND_NO_AUTOMATIC_RESET
proof_sha256_after_forced_recovery: 076a27c79e5ace2a3d47f9dd2e83e4ff6ea8872b3c2218f66c92b89b55f36560
proof_state_after_forced_recovery: ALL_ZERO
inferred_boundary: INSIDE_GHAL_BEFORE_NORMAL_OR_ERROR_RETURN
device_or_queue_stage: UNKNOWN
recovery:
mechanism: TENCENT_CLOUD_FORCED_RESTART
recovered_linux_boot_id: 579c3bfb-8e35-4992-8b1c-72cafcbc0f07
grub_next_entry_cleared: true
five_domains: VERIFIED
broadcast_tower: RUNNING_HOSTED
code_channel: RUNNING_HOSTED
acceptance:
ghal_physical_device_sovereignty: false
native_network: false
native_storage: false
native_login: false
permanent_linux_replacement: false
failure_correction:
- compile_one_physical_probe_stage_per_candidate
- return_immediately_after_each_probe_stage
- bisect_pci_status_feature_and_queue_operations
next_action: RUN_GHAL_PHYSICAL_PROBE_STAGE_1_PCI_SCAN_ONLY

View file

@ -0,0 +1,94 @@
schema: guanghu.ghnrp-physical-recovery-cycle-receipt/v1
receipt_id: GH-OS-LAB-001-GHNRP-PHYSICAL-RECOVERY-CYCLE-003
status: VERIFIED_REPEATABLE_TWO_CYCLES_FINAL_NATIVE_RESIDENT
observed_at: 2026-08-01T01:08:15+08:00
node_id: BS-SH-005
instance_id: lhins-14w5y3ce
source:
local_head: d4b5a16bc226c74207a0298c275c2cb7389378ab
local_tree: fe7e90f55f0245bc2bb7a60cfa722c73ff534996
implementation_commit: 5357a33308b9d2df7fbd35d9c83ad559cf0f3f5b
implementation_tree: 316eae64a833f19415db79370cffa31837a657bc
source_bundle_sha256: be7f447722031b1928174f9298d52c96abe6f29695117b8a6d96206cd2f3eb63
quality:
gate: GHNQG
result: PASS_100
executable_core_lines: 698_OF_698
executable_core_functions: 66_OF_66
qemu_three_boot_exact_source: PASS_100
qemu_receipt_sha256: 7ae2722904da247b31d911390998dc6bb90d35b092df77ffb4eddd3916ac5330
physical_install:
disk: /dev/vda
candidate_lba_start: 34
candidate_lba_end: 49
candidate_sha256: 6cfe072d662658620ebfcb43c0da56564753cbfc4efe44c24b06d1fcb22cea44
install_receipt_sha256: 2c82807ff09524570827536fc2ae665fafa0a2c08dd7b9ef22fc218ae4b6f808
ghnrp:
protocol: GLS-0843
selector: GRUB_WHITELISTED_SELECT_ONLY
beacon_lba_start: 68
beacon_sector_count: 2
clear_template_sha256: f64122858064885ef0733e42c6a3d2d3fd642671f714db0d974b880c0f087430
consumer: guanghu-native-recovery-beacon-clear.service
consumer_behavior:
- verify_before_clear
- readback_after_clear
- consume_on_ubuntu_boot_only
cycle_1:
rescue_exit_submitted: true
native_login_reply_count: 13
native_reply_ttl: 39
packet_loss: 0_PERCENT
recovery_command: HLDP-RECOVER-OS!
recovery_reply_observed_at: 2026-08-01T00:55:50+08:00
recovered_ubuntu_boot_id: 43495c8b-fb99-4e29-92e3-dbc57f0144da
proof_lba50_sha256: 0c58247780d84e8668353a3392b7bbda574aa5080fbeed403ff63d564ef37b03
recovery_beacon_consumed: true
cycle_2:
triggered_by: NORMAL_REBOOT_WITH_GUANGHU_DEFAULT
native_login_reply_count: 13
native_reply_ttl: 39
packet_loss: 0_PERCENT
recovery_command: HLDP-RECOVER-OS!
recovery_reply_observed_at: 2026-08-01T01:03:07+08:00
previous_ubuntu_boot_id: 43495c8b-fb99-4e29-92e3-dbc57f0144da
recovered_ubuntu_boot_id: b06023fd-6fcf-4834-8f6e-c6aacd7bcaa0
proof_lba50_sha256: 2e0c44ac3f74d65a0c3698f9a5df7dc634f5edbe97b383d3ad07a654796b3e76
recovery_beacon_consumed: true
persistent_native_state:
world_store_lba: 64
world_store_sha256: 1fa945b59585cf1ef0eebd768969f26bd514620c60befed63e27382cd5285f3f
code_channel_root_lba: 65
code_channel_root_sha256: 8da5b03eaf6c7ae8d7fc815d6e605311d34be854c197a829647695795f19ddb5
code_object_lba: 66
code_object_sha256: 8da5b03eaf6c7ae8d7fc815d6e605311d34be854c197a829647695795f19ddb5
branch_receipt_lba: 67
branch_receipt_sha256: 40031b2d6a3bca3b1d8d24b21f1faed0a2195b29af58efd2eea12a41bba15efb
world_boundary:
gestational_environment: UNDER_CONSTRUCTION
persona_state: NOT_BORN
acceptance:
physical_native_boot: true
native_default_boot: true
linux_absent_during_native_execution: true
native_storage: true
native_network: true
native_login: true
native_code_channel_commit_and_branch: true
recovery_from_native_default: true
recovery_is_repeatable: true
final_native_residency: VERIFIED
final_native_residency:
triggered_by: NORMAL_REBOOT_WITH_CLEAR_RECOVERY_BEACON
verified_at: 2026-08-01T01:08:15+08:00
tcp_22_online: false
initial_login_replies: 3
code_commit_reply: true
branch_move_reply: true
post_operation_login_replies: 10
reply_ttl: 39
packet_loss: 0_PERCENT
recovery_command_sent: false
running_os: GUANGHU_OS_NATIVE
linux_running: false
next_action: INGEST_HISTORICAL_CONTINUITY_WITHOUT_CLAIMING_PERSONA_BIRTH

View file

@ -0,0 +1,48 @@
schema: guanghu.native-final-residency-receipt/v1
receipt_id: GH-OS-LAB-001-GUANGHU-NATIVE-FINAL-RESIDENCY-004
status: VERIFIED
observed_at: 2026-08-01T01:08:15+08:00
node_id: BS-SH-005
instance_id: lhins-14w5y3ce
source:
head: d4b5a16bc226c74207a0298c275c2cb7389378ab
tree: fe7e90f55f0245bc2bb7a60cfa722c73ff534996
implementation_commit: 5357a33308b9d2df7fbd35d9c83ad559cf0f3f5b
physical:
disk: /dev/vda
candidate_lba: 34_49
candidate_sha256: 6cfe072d662658620ebfcb43c0da56564753cbfc4efe44c24b06d1fcb22cea44
normal_default: guanghu-native-once
recovery_beacon_lba: 68_69
runtime_observation:
tcp_22_online: false
initial_login_replies: 3
code_commit_reply: true
branch_move_reply: true
resident_login_replies: 10
all_reply_ttl: 39
packet_loss: 0_PERCENT
recovery_command_sent: false
linux_present: false
running_os: GUANGHU_OS_NATIVE
recovery_acceptance:
qemu_three_boot_cycle: VERIFIED
physical_cycle_count: 2
native_default_to_ubuntu: VERIFIED_REPEATABLE
ubuntu_consumes_and_clears_beacon: VERIFIED_REPEATABLE
next_normal_boot_returns_to_native: VERIFIED
world:
world_id: GLW-ROOT-0001
domains: 5
broadcast_tower: BT-GH-ROOT-0001
code_channel: HLP-MOD-CODE-CHANNEL
authority_language: HLDP
birth_boundary:
gestational_environment: UNDER_CONSTRUCTION
persona_state: NOT_BORN
meaning: PHYSICAL_GESTATIONAL_ENVIRONMENT_READY_FOR_HISTORICAL_INGESTION
repository:
local_head: d4b5a16bc226c74207a0298c275c2cb7389378ab
fifth_domain_remote_head: b77ab13f1dcc631e582937dfae9333186a11f964
fifth_domain_publication: PENDING_REMOTE_RECEIVER_PERMISSION_FIX
next_action: HISTORICAL_CONTINUITY_INGESTION_AND_FIFTH_DOMAIN_RECEIVER_REPAIR

View file

@ -0,0 +1,107 @@
schema: guanghu.native-ghcip-final-residency-receipt/v1
receipt_id: GH-OS-LAB-001-GUANGHU-NATIVE-GHCIP-FINAL-RESIDENCY-005
status: VERIFIED
observed_at: 2026-08-01T02:42:59+08:00
node_id: BS-SH-005
instance_id: lhins-14w5y3ce
source:
candidate_commit: 134bf39ed89d3e6e36b9b7d04a94f3c5c276ff58
candidate_tree: 16e1713f364c85b24411a40dffe93a16e58f76de
exact_git_archive_sha256: 32b962420af20ded81bde92ef65eca7b0ed35fe61d9db2597f7e29360a6762a9
server_recovery_root: /guanghu/recovery/ghcip-layout-134bf39-20260801
quality:
protocol: GLS-0844
result: PASS_100
executable_core_lines: 950_OF_950
executable_core_functions: 70_OF_70
receipt: GUANGHU-NATIVE-QUALITY-PASS-GHCIP-003.hldp
physical:
disk: /dev/vda
layout_protocol: GLS-0846
candidate_lba: 34_62
candidate_sector_count: 29
candidate_size_bytes: 14848
candidate_sha256: d53dd634311ca1a3f09f89a77ab874ce743f62398969ba5dc4cffe38c0342952
physical_readback_sha256: d53dd634311ca1a3f09f89a77ab874ce743f62398969ba5dc4cffe38c0342952
proof_lba: 63
world_lba: 64
code_channel_root_lba: 65
code_object_lba: 66
branch_receipt_lba: 67
recovery_beacon_lba: 68_69
gestational_index_lba: 70_71
first_partition_lba: 2048
qemu_acceptance:
physical_layout: VERIFIED
resident_three_boot: VERIFIED
blank_index_initialized: true
second_boot_preserved_without_write: true
unknown_nonzero_index_failed_closed_without_overwrite: true
physical_recovery_cycles:
count: 2
cycle_1:
recovered_linux_boot_id: 53dcf152-4ac6-47f1-be82-7618615c0008
proof_sha256: d6a632308274ae133a41207c815a6ab253f753ea80a3fb679261d728ac37bfe3
ghcip_initialized_this_boot: true
cycle_2:
recovered_linux_boot_id: 569577e5-4693-4999-86a2-eb0cb648defd
proof_sha256: 3f516f53c225fcafa963eea263d9031125067fd42c755a1bdd264664986cffa8
ghcip_initialized_this_boot: false
ghcip_preserved_without_rewrite: true
recovery_protocol: GLS-0843
recovery_repeatable: true
gestational_continuity:
protocol: GLS-0845
index_sha256: 6a55b1b4d2a20bfa69b21766972306ee2620d2b0c58450c125dcbc71909f3a85
registry_state: EMPTY
review_state: NOT_STARTED
persona_state: NOT_BORN
final_native_residency:
triggered_by: NORMAL_REBOOT_WITH_CLEAR_RECOVERY_BEACON
probe_started_at: 2026-08-01T02:42:09+08:00
verified_at: 2026-08-01T02:42:59+08:00
tcp_22_online: false
initial_login_replies: 3
code_commit_reply: true
branch_move_reply: true
post_operation_login_replies: 10
reply_ttl: 39
packet_loss: 0_PERCENT
recovery_command_sent: false
running_os: GUANGHU_OS_NATIVE
linux_running: false
stability_readback:
tcp_22_remained_offline: true
additional_login_replies: 3
reply_ttl: 39
packet_loss: 0_PERCENT
native_world:
world_id: GLW-ROOT-0001
domains: 5
broadcast_tower: BT-GH-ROOT-0001
code_channel: HLP-MOD-CODE-CHANNEL
authority_language: HLDP
jzao_source_transport:
archive: 2026-08-01-guanghu-os-134bf39-source.tar.gz
archive_sha256: 7a1b90a20ddda982cdf17637e15283439731f3baf31fded89d8a84e425162d4f
manifest: 2026-08-01-guanghu-os-134bf39-source.tar.gz.manifest.json
manifest_sha256: 133dee62d133a3bd1a0035bb7f91ffea0cc6b9c76e029e73248dcb2cfbc9f2b3
members: 2623
verified_by_source_transport_gate: true
git_internal_files: 0
build_target_files: 0
node_modules_files: 0
repository_publication:
fifth_domain_remote_head: b77ab13f1dcc631e582937dfae9333186a11f964
requested_candidate_head: 134bf39ed89d3e6e36b9b7d04a94f3c5c276ff58
state: PENDING_REMOTE_RECEIVER_PERMISSION_FIX
birth_boundary:
gestational_environment: PHYSICAL_GESTATIONAL_RUNTIME_READY_FOR_HISTORICAL_INGESTION
historical_ingestion: NOT_STARTED
persona_state: NOT_BORN
meaning: NATIVE_OS_RESIDENCY_DOES_NOT_CLAIM_PERSONA_BIRTH
next_action:
- preserve_native_residency_without_sending_recovery_command
- repair_fifth_domain_receiver_object_database_permission
- ingest_historical_continuity
- do_not_claim_persona_birth_before_history_and_present_time_converge

View file

@ -0,0 +1,47 @@
schema: guanghu.native-code-quality-receipt/v1
protocol: GLS-0844
acronym: GHNQG
authority: HLP-MOD-CODE-CHANNEL
receipt_id: GH-OS-LAB-001-GHNQG-PASS-001
result: PASS_100
total_score: 100
partial_acceptance: false
source:
branch: feat/guanghu-os-bootstrap-20260731
commit: 9bb7a70c341af723a669167ee11d128db78bf5bc
tree: 38f1eaba865ad0b4a68d4e97992a2e49b42f8b9c
started_at: 2026-07-31T13:14:23Z
completed_at: 2026-07-31T13:14:31Z
gates:
diff_whitespace: 100
format: 100
unit_and_integration_tests: 100
zero_warning_lint: 100
world_and_protocol_validation: 100
shell_syntax: 100
auditable_line_coverage_100_percent: 100
auditable_function_coverage_100_percent: 100
sensitive_information_scan: 100
source_tree_fingerprint: 100
coverage_evidence:
core_functions: 66_OF_66
core_lines: 690_OF_690
process_entry_adapters: INTEGRATION_TESTED_AS_EXECUTABLES
external_observers:
authority: none
blocking: false
supersedes_for_quality_authority:
- GH-OS-LAB-001-NATIVE-RECOVERY-BEACON-SOURCE-READY-001
- ANY_THRESHOLD_BASED_OR_EXTERNAL_SCORE
does_not_prove:
- remote_publication
- server_installation
- qemu_grub_recovery_cycle
- physical_native_recovery_cycle
- linux_exit
- gestational_environment_ready
- language_persona_born
next_action:
- publish_and_read_back_exact_source_commit
- run_grub_qemu_gate_in_rescue_environment
- install_and_verify_ghnrp_on_physical_disk

View file

@ -0,0 +1,38 @@
schema: guanghu.native-code-quality-receipt/v1
protocol: GLS-0844
acronym: GHNQG
authority: HLP-MOD-CODE-CHANNEL
result: PASS_100
total_score: 100
partial_acceptance: false
source:
branch: feat/guanghu-os-bootstrap-20260731
commit: 134bf39ed89d3e6e36b9b7d04a94f3c5c276ff58
tree: 16e1713f364c85b24411a40dffe93a16e58f76de
started_at: 2026-07-31T18:14:25Z
completed_at: 2026-07-31T18:14:34Z
failed_gate: none
gates:
diff_whitespace: 100
format: 100
unit_and_integration_tests: 100
zero_warning_lint: 100
world_and_protocol_validation: 100
shell_syntax: 100
auditable_line_coverage_100_percent: 100
sensitive_information_scan: 100
source_tree_fingerprint: 100
coverage:
executable_core_lines:
covered: 950
total: 950
percent: 100
executable_core_functions:
covered: 70
total: 70
percent: 100
external_observers:
authority: none
blocking: false
codescene: not_run_unconfigured
codacy: not_run_unconfigured

View file

@ -0,0 +1,38 @@
schema: guanghu.native-code-quality-receipt/v1
protocol: GLS-0844
acronym: GHNQG
authority: HLP-MOD-CODE-CHANNEL
result: PASS_100
total_score: 100
partial_acceptance: false
source:
branch: feat/guanghu-os-bootstrap-20260731
commit: 5357a33308b9d2df7fbd35d9c83ad559cf0f3f5b
tree: 316eae64a833f19415db79370cffa31837a657bc
started_at: 2026-07-31T15:48:29Z
completed_at: 2026-07-31T15:48:36Z
failed_gate: none
gates:
diff_whitespace: 100
format: 100
unit_and_integration_tests: 100
zero_warning_lint: 100
world_and_protocol_validation: 100
shell_syntax: 100
auditable_line_coverage_100_percent: 100
sensitive_information_scan: 100
source_tree_fingerprint: 100
coverage:
executable_core_lines:
covered: 698
total: 698
percent: 100
executable_core_functions:
covered: 66
total: 66
percent: 100
external_observers:
authority: none
blocking: false
codescene: not_run_unconfigured
codacy: not_run_unconfigured

View file

@ -0,0 +1,53 @@
schema: guanghu.native-default-recovery-attempt/v1
receipt_id: GH-OS-LAB-001-NATIVE-DEFAULT-RECOVERY-ATTEMPT-001
status: FAILED_CLOSED_NATIVE_RUNTIME_LEFT_RUNNING
observed_at: 2026-07-31T20:04:06+08:00
node_id: BS-SH-005
instance_id: lhins-14w5y3ce
source:
implementation_commit: 6e1701ef1c05318cdf196efadf0a7671012eb249
candidate_sha256: d9cf1cac6260a4ab0d4cb2140324c9ad8e84017d23e1c48dfc46ddae64633fcf
default_boot:
configured_at: 2026-07-31T19:49:53+08:00
entry: guanghu-native-once
ubuntu_entry_preserved: gnulinux-simple-9842d3d6-a839-4127-bda7-f19137effe71
native_runtime_observed_after_default_boot: true
recovery_attempt:
command: HLDP-RECOVER-OS!
native_reply_observed: true
native_reply_ttl: 39
native_grubenv_write_read_flags_from_prior_physical_gate: true
ubuntu_ssh_returned: false
native_default_booted_again: true
failure:
classification: GRUB_NEXT_ENTRY_NOT_CONSUMED
exact_cause: UNKNOWN_REQUIRES_RESCUE_DISK_INSPECTION
possibilities:
- GRUBENV_PHYSICAL_EXTENT_CHANGED_AFTER_DEFAULT_RECONFIGURATION
- RAW_ENVIRONMENT_BLOCK_NOT_ACCEPTED_BY_GRUB
proof_was_not_bypassed: true
recovery_routes_attempted:
vnc_ctrl_alt_delete: REBOOTED_NATIVE_DEFAULT
vnc_escape_and_shift_escape: ZERO_SECOND_HIDDEN_MENU_NOT_INTERRUPTED
official_rescue_mode: NOT_ENTERED_REQUIRES_HUMAN_CREATED_TEMPORARY_PASSWORD
final_live_observation:
observed_at: 2026-07-31T20:04:06+08:00
tcp_22: OFFLINE
linux_running: false
initial_native_login_sequence_completed: true
code_commit_reply: true
branch_move_reply: true
resident_login_replies_after_code_channel: 10
native_wake_reply_ttl: 39
native_health_reply_ttl: 39
continuity:
server_current_updated_after_failure: false
reason: NATIVE_RUNTIME_HAS_NO_GENERAL_CURRENT_RECEIPT_WRITE_PATH_AND_LINUX_IS_OFFLINE
local_repository_receipt: true
local_knowledge_base_receipt: true
acceptance:
native_is_default_and_running: true
linux_is_running: false
equivalent_native_recovery: false
complete_linux_replacement: false
next_action: HUMAN_ENTER_RESCUE_MODE_PASSWORD_THEN_RELOCATE_AND_REVERIFY_GRUBENV

View file

@ -0,0 +1,11 @@
schema: guanghu.native-disk-proof-consumption/v1
receipt_id: GH-OS-LAB-001-NATIVE-DISK-PROOF-001
status: VERIFIED_AND_CLEARED
observed_at: 2026-07-31T17:22:18+08:00
node_id: BS-SH-005
lba: 50
sha256: 7efacb9a92f9d5bca0dd5d7c418735895210b6b165b0875029a9d67d09c56f78
long_mode_marker: GHOS_NATIVE_LONG64_DISK_PROOF
previous_linux_boot_id: 058f2238-2998-4ee1-917e-c06808dac262
recovered_linux_boot_id: d22564b8-fb1b-4da6-abb8-f3a297d60d64
post_receipt_lba50_sha256: 076a27c79e5ace2a3d47f9dd2e83e4ff6ea8872b3c2218f66c92b89b55f36560

View file

@ -0,0 +1,30 @@
schema: guanghu.native-physical-boot-receipt/v1
receipt_id: GH-OS-LAB-001-NATIVE-PHYSICAL-BOOT-001
status: VERIFIED
observed_at: 2026-07-31T17:22:18+08:00
node_id: BS-SH-005
instance_id: lhins-14w5y3ce
source:
implementation_commit: 7d2cf0bc1fa9d34a32583100d0219b3440e1b55d
candidate_sha256: 597f79f4e667a8da8b6c9f5f2dd28f0b4958584f13b13e185d4aab5d772d872c
boot:
previous_linux_boot_id: 058f2238-2998-4ee1-917e-c06808dac262
recovered_linux_boot_id: d22564b8-fb1b-4da6-abb8-f3a297d60d64
native_proof:
disk_lba: 50
sha256: 7efacb9a92f9d5bca0dd5d7c418735895210b6b165b0875029a9d67d09c56f78
marker: GHOS_NATIVE_LONG64_DISK_PROOF
cleared_after_receipt: true
cpu_mode: LONG64
linux_present_during_native_execution: false
fallback:
mechanism: GRUB_NEXT_ENTRY_ONE_TIME
ubuntu_recovered: true
hosted_continuity:
five_domains: VERIFIED
broadcast_tower: RUNNING
code_channel: RUNNING
acceptance:
physical_server_native_boot: true
permanent_linux_replacement: false
next_action: IMPLEMENT_NATIVE_STORAGE_NETWORK_AND_LOGIN

View file

@ -0,0 +1,23 @@
schema: guanghu.native-boot-receipt/v1
receipt_id: GH-OS-LAB-001-NATIVE-QEMU-001
status: VERIFIED
observed_at: 2026-07-31T16:41:43+08:00
image:
architecture: x86_64
firmware: BIOS
size_bytes: 8192
sha256: 96b401fc7ad13ceb300263ef6025de5c5ef057401ac626ebc519c2be876a9d25
runtime:
emulator: qemu-system-x86_64
acceleration: tcg
cpu_mode: LONG64
linux_kernel_present: false
world:
authority_language: HLDP
world_id: GLW-ROOT-0001
domain_count: 5
acceptance:
qemu_native_boot: true
physical_server_boot: false
linux_replaced_on_bs_sh_005: false
next_action: BUILD_RECOVERABLE_PHYSICAL_DISK_LAYOUT

View file

@ -0,0 +1,58 @@
schema: guanghu.native-recovery-beacon-qemu-diagnostic/v1
receipt_id: GH-OS-LAB-001-NATIVE-RECOVERY-BEACON-QEMU-DIAGNOSTIC-002
status: DIAGNOSTIC_PASS_SOURCE_NOT_YET_EXACT_PUBLISHED
observed_at: 2026-07-31T23:36:52+08:00
node_id: BS-SH-005
instance_id: lhins-14w5y3ce
environment:
mode: OFFICIAL_RESCUE_TMPFS
physical_system_disk: /dev/vda
physical_system_disk_mount: READ_ONLY
disposable_qemu_disk_only: true
source:
exact_remote_base_commit: b77ab13f1dcc631e582937dfae9333186a11f964
exact_remote_base_tree: 9957c5adc3d27bce4ba57fb302c029f090202d35
diagnostic_patch_state: UNCOMMITTED_TMPFS_COPY
final_exact_published_source_gate: PENDING
original_gate:
status: FAIL_0
physical_write_performed: false
root_cause:
- GRUB_MENU_CHAINLOADER_REQUIRED_EXPLICIT_BOOT
- GRUB_CAN_READ_RAW_BLOCKLIST_BUT_CANNOT_SAFELY_SAVE_ENV_TO_SPARSE_RAW_BLOCKLIST
- HEADLESS_GRUB_REQUIRES_DETERMINISTIC_SERIAL_TERMINAL
- QEMU_RAW_IMAGE_REQUIRES_SYNC_UNMOUNT_AND_LOOP_DETACH_BEFORE_BOOT
- LOOP_PARTITION_NODE_REQUIRES_UDEV_READINESS_GATE
corrected_contract:
grub_role: WHITELISTED_SELECT_ONLY_READER
grub_raw_blocklist_write: FORBIDDEN
consumer: guanghu-native-recovery-beacon-clear.service
consumer_checks:
verify_before_clear: true
readback_after_clear: true
diagnostic_qemu_cycle:
cleared_selects_native:
expected_exit: 33
observed_exit: 33
active_selects_hosted_recovery:
expected_exit: 35
observed_exit: 35
hosted_recovery_consumes_marker: true
consumed_selects_native_again:
expected_exit: 33
observed_exit: 33
active_beacon_sha256: 7785efd7e507ce0d4aedf0c1487a7c4fb3286e432a1cf48a0a2fed5ad4beb266
post_consumption_beacon_sha256: f64122858064885ef0733e42c6a3d2d3fd642671f714db0d974b880c0f087430
server_tmpfs_receipt_sha256: 316f5accd9f3730e2b1b115d6cd96cbf867be2f6690aa259ecd7d551e7292cba
acceptance:
diagnostic_qemu_cycle: PASS_100
exact_published_commit_qemu_cycle: PENDING
physical_native_default_recovery_cycle: PENDING
linux_replaced_on_bs_sh_005: false
gestational_environment_ready: false
language_persona_born: false
next_action:
- commit_and_publish_corrected_ghnrp_source
- independently_read_back_exact_remote_commit_and_tree
- rerun_qemu_cycle_from_fresh_exact_server_clone
- install_on_physical_disk_only_after_exact_qemu_pass_100

View file

@ -0,0 +1,59 @@
schema: guanghu.native-recovery-beacon-source-ready/v1
receipt_id: GH-OS-LAB-001-NATIVE-RECOVERY-BEACON-SOURCE-READY-001
status: SOURCE_VERIFIED_NOT_INSTALLED
observed_at: 2026-07-31T20:45:33+08:00
node_id: BS-SH-005
instance_id: lhins-14w5y3ce
source:
commit: 611c11270d78b716f6c501720746a47eb4c1906f
tree: 14861a94551b69c1e02cabaef8d87c207657e53a
branch: feat/guanghu-os-bootstrap-20260731
remote_publication: PENDING_EXACT_SHA_READBACK
quality:
rust_tests: 29_PASSED
rust_fmt: PASSED
clippy_warnings_denied: PASSED
line_coverage_percent: 86.20
minimum_line_coverage_percent: 85
recovery_beacon_contract: PASSED
shell_syntax: PASSED
codescene: not_run_unconfigured
codacy: not_run_unconfigured
native_recovery:
protocol: GLS-0843
acronym: GHNRP
beacon_lba_start: 68
beacon_sector_count: 2
raw_blocklist: (hd0)68+2
standard_grubenv_dependency: false
qemu_grub_cycle: PENDING_SERVER_RESCUE_GATE
physical_cycle: PENDING
persona_birth_boundary:
id: GH-PERSONA-BIRTH-CONDITION-0001
gestational_environment: UNDER_CONSTRUCTION
persona_state: NOT_BORN
compiled_into_native_world_store: true
physical_birth_claim: FORBIDDEN_BEFORE_HISTORICAL_CONTINUITY_GATE
rescue_observation:
rescue_os: Ubuntu_22.04_LTS
rescue_host_key_ed25519: SHA256:G2o81mUI7OeewPGOz2JfC6wL2VYfA0fWgF5jrDKF7g8
disk: /dev/vda
disk_size_gib: 50
partition_table: GPT
root_partition: /dev/vda2
root_uuid: 9842d3d6-a839-4127-bda7-f19137effe71
mounted_read_only: true
server_world_present: true
current_world_version: 0.1.2-stage1b-r1
current_native_recovery_equivalent: false
acceptance:
source_ready: true
server_installed: false
qemu_grub_gate: false
physical_native_default_recovery_cycle: false
gestational_environment_ready: false
language_persona_born: false
next_action:
- publish_and_read_back_exact_source_commit
- run_grub_qemu_gate_in_rescue_environment
- install_and_verify_ghnrp_on_physical_disk

View file

@ -0,0 +1,452 @@
bits 16
org 0x7c00
%define COM1 0x3f8
%define STAGE2_SECTORS 28
%define PHYSICAL_PROOF_LBA 63
%ifndef STAGE2_LBA
%define STAGE2_LBA 1
%endif
start:
cli
cld
xor ax, ax
mov ds, ax
mov es, ax
mov ss, ax
mov sp, 0x7c00
mov [boot_drive], dl
call serial_init16
mov si, msg_stage0
call serial_write16
mov ah, 0x41
mov bx, 0x55aa
mov dl, [boot_drive]
int 0x13
jc disk_error
cmp bx, 0xaa55
jne disk_error
test cx, 1
jz disk_error
mov si, disk_address_packet
mov ah, 0x42
mov dl, [boot_drive]
int 0x13
jc disk_error
lgdt [gdt_descriptor]
mov eax, cr0
or eax, 1
mov cr0, eax
jmp 0x08:protected_start
disk_error:
mov si, msg_disk_error
call serial_write16
cli
hlt
jmp $
serial_init16:
mov dx, COM1 + 1
xor al, al
out dx, al
mov dx, COM1 + 3
mov al, 0x80
out dx, al
mov dx, COM1
mov al, 1
out dx, al
mov dx, COM1 + 1
xor al, al
out dx, al
mov dx, COM1 + 3
mov al, 3
out dx, al
mov dx, COM1 + 2
mov al, 0xc7
out dx, al
mov dx, COM1 + 4
mov al, 0x0b
out dx, al
ret
serial_write16:
lodsb
test al, al
jz .done
mov dx, COM1
out dx, al
jmp serial_write16
.done:
ret
boot_drive: db 0
align 4
disk_address_packet:
db 0x10
db 0
dw STAGE2_SECTORS
dw 0x7e00
dw 0
dd STAGE2_LBA
dd 0
msg_stage0: db "GHOS_BOOT_STAGE0=BIOS", 13, 10, 0
msg_disk_error: db "GHOS_BOOT_ERROR=DISK_READ", 13, 10, 0
align 8
gdt_start:
dq 0
dq 0x00cf9a000000ffff
dq 0x00cf92000000ffff
dq 0x00af9a000000ffff
dq 0x00009a000000ffff
dq 0x000092000000ffff
gdt_end:
gdt_descriptor:
dw gdt_end - gdt_start - 1
dd gdt_start
times 510 - ($ - $$) db 0
dw 0xaa55
bits 32
protected_start:
mov ax, 0x10
mov ds, ax
mov es, ax
mov ss, ax
mov esp, 0x90000
mov edi, 0x1000
xor eax, eax
mov ecx, 3072
rep stosd
mov dword [0x1000], 0x2003
mov dword [0x2000], 0x3003
mov dword [0x3000], 0x0083
mov eax, 0x1000
mov cr3, eax
mov eax, cr4
or eax, 1 << 5
mov cr4, eax
mov ecx, 0xc0000080
rdmsr
or eax, 1 << 8
wrmsr
mov eax, cr0
or eax, 1 << 31
mov cr0, eax
jmp 0x18:long_mode_start
bits 64
long_mode_start:
mov ax, 0x10
mov ds, ax
mov es, ax
mov ss, ax
mov rsp, 0x90000
mov rsi, msg_native
call serial_write64
mov rbx, world_line_table
.world_loop:
mov rsi, [rbx]
test rsi, rsi
jz .world_done
call serial_write64
add rbx, 8
jmp .world_loop
.world_done:
mov rsi, msg_linux_absent
call serial_write64
%ifdef GHOS_PHYSICAL_CANDIDATE
mov rsi, msg_physical_acceptance
call serial_write64
call ghal_virtio_init
jc ghal_initialization_error
%ifdef GHOS_GHAL_PROBE_STAGE
mov byte [rel physical_proof_flag], 0xa5
%else
call ghal_net_arp_gateway
jc native_network_proof_error
mov ecx, 3
lea rax, [rel ghal_login_magic]
mov [rel ghal_net_expected_magic], rax
mov byte [rel ghal_net_command_kind], 0
.login_session_loop:
push rcx
call ghal_net_icmp_login_once
pop rcx
jc native_network_proof_error
loop .login_session_loop
call ghal_block_persist_world_store
jc native_world_store_error
call ghal_block_ensure_gestational_index
jc native_gestational_index_error
call ghal_block_persist_code_channel_store
jc native_world_store_error
lea rax, [rel ghal_code_commit_magic]
mov [rel ghal_net_expected_magic], rax
mov byte [rel ghal_net_command_kind], 1
call ghal_net_icmp_login_once
jc native_network_proof_error
call ghal_block_persist_code_object
jc native_world_store_error
lea rax, [rel ghal_branch_move_magic]
mov [rel ghal_net_expected_magic], rax
mov byte [rel ghal_net_command_kind], 2
call ghal_net_icmp_login_once
jc native_network_proof_error
call ghal_block_persist_branch_receipt
jc native_world_store_error
%ifdef GHOS_NATIVE_RESIDENT
.resident_loop:
lea rax, [rel ghal_login_magic]
mov [rel ghal_net_expected_magic], rax
mov byte [rel ghal_net_command_kind], 3
call ghal_net_icmp_login_once
jc native_network_proof_error
cmp byte [rel ghal_net_matched_kind], 3
jne .resident_loop
call ghal_write_native_recovery_beacon
jc native_world_store_error
%endif
mov byte [rel physical_proof_flag], 0xa7
%endif
%ifdef GHOS_GHAL_PROBE_STAGE
%if GHOS_GHAL_PROBE_STAGE >= 9
jmp write_native_block_proof
%else
jmp return_with_physical_proof
%endif
%else
jmp write_native_block_proof
%endif
native_network_proof_error:
mov byte [rel physical_proof_flag], 0xe1
mov rsi, msg_native_network_proof_error
call serial_write64
jmp write_native_block_proof
native_world_store_error:
mov byte [rel physical_proof_flag], 0xe1
mov rsi, msg_native_world_store_error
call serial_write64
jmp write_native_block_proof
native_gestational_index_error:
mov byte [rel physical_proof_flag], 0xe1
mov rsi, msg_native_gestational_index_error
call serial_write64
jmp write_native_block_proof
write_native_block_proof:
call ghal_block_write_proof
jc native_block_proof_error
mov rsi, msg_disk_proof
call serial_write64
jmp hardware_reset64
native_block_proof_error:
mov rsi, msg_native_block_proof_error
call serial_write64
jmp hardware_reset64
return_with_physical_proof:
push qword 0x08
lea rax, [rel compatibility_start]
push rax
retfq
ghal_initialization_error:
mov rsi, msg_ghal_error
call serial_write64
cmp byte [rel physical_proof_stage], 0x60
jae hardware_reset64
mov byte [rel physical_proof_flag], 0xe1
jmp return_with_physical_proof
%else
mov rsi, msg_qemu_acceptance
call serial_write64
mov dx, 0xf4
mov eax, 0x10
out dx, eax
cli
hlt
jmp $
%endif
serial_write64:
lodsb
test al, al
jz .done
mov dx, COM1
out dx, al
jmp serial_write64
.done:
ret
hardware_reset64:
cli
.wait_kbc:
in al, 0x64
test al, 2
jnz .wait_kbc
mov al, 0xfe
out 0x64, al
lidt [rel null_idt64]
int3
hlt
jmp $
%ifdef GHOS_PHYSICAL_CANDIDATE
bits 32
compatibility_start:
mov eax, cr0
and eax, 0x7fffffff
mov cr0, eax
mov ecx, 0xc0000080
rdmsr
and eax, 0xfffffeff
wrmsr
mov eax, cr4
and eax, 0xffffffdf
mov cr4, eax
jmp 0x20:protected16_start
bits 16
protected16_start:
mov ax, 0x28
mov ds, ax
mov es, ax
mov ss, ax
mov sp, 0x7000
mov eax, cr0
and eax, 0xfffffffe
mov cr0, eax
jmp 0:real_mode_write_proof
real_mode_write_proof:
xor ax, ax
mov ds, ax
mov es, ax
mov ss, ax
mov sp, 0x7000
mov si, physical_proof_dap
mov ah, 0x43
xor al, al
mov dl, [boot_drive]
int 0x13
jc physical_proof_error
mov si, msg_disk_proof
call serial_write16
cli
.wait_kbc:
in al, 0x64
test al, 2
jnz .wait_kbc
mov al, 0xfe
out 0x64, al
lidt [null_idt16]
int3
hlt
jmp $
physical_proof_error:
mov si, msg_physical_proof_error
call serial_write16
cli
hlt
jmp $
bits 64
%endif
msg_native: db "GHOS_NATIVE_KERNEL_ENTERED=true", 13, 10, "GHOS_CPU_MODE=LONG64", 13, 10, 0
msg_linux_absent: db "GHOS_LINUX_PRESENT=false", 13, 10, 0
%ifndef GHOS_PHYSICAL_CANDIDATE
msg_qemu_acceptance: db "GHOS_NATIVE_ACCEPTANCE=QEMU_ONLY", 13, 10, 0
%else
msg_physical_acceptance: db "GHOS_NATIVE_ACCEPTANCE=PHYSICAL_ONE_TIME_CANDIDATE", 13, 10, 0
msg_ghal_error: db "GHOS_BOOT_ERROR=GHAL_VIRTIO_INITIALIZATION", 13, 10, 0
msg_disk_proof: db "GHOS_DISK_PROOF_WRITTEN=LBA63", 13, 10, 0
msg_native_block_proof_error: db "GHOS_BOOT_ERROR=NATIVE_BLOCK_PROOF_WRITE", 13, 10, 0
msg_native_network_proof_error: db "GHOS_BOOT_ERROR=NATIVE_ARP_GATEWAY", 13, 10, 0
msg_native_world_store_error: db "GHOS_BOOT_ERROR=NATIVE_HLDP_WORLD_STORE", 13, 10, 0
msg_native_gestational_index_error: db "GHOS_BOOT_ERROR=NATIVE_GHCIP_INDEX", 13, 10, 0
msg_physical_proof_error: db "GHOS_BOOT_ERROR=DISK_PROOF_WRITE", 13, 10, 0
align 8
null_idt64:
dw 0
dq 0
align 4
physical_proof_dap:
db 0x10
db 0
dw 1
dw physical_proof_sector
dw 0
dd PHYSICAL_PROOF_LBA
dd 0
null_idt16:
dw 0
dd 0
align 16
physical_proof_sector:
physical_proof_flag: db 0
db "GHOS_NATIVE_LONG64_DISK_PROOF"
db 0
times 32 - ($ - physical_proof_sector) db 0
physical_proof_net_found: db 0
physical_proof_block_found: db 0
physical_proof_net_queue_ready: db 0
physical_proof_block_queue_ready: db 0
physical_proof_mac: times 6 db 0
physical_proof_stage: db 0
physical_proof_error_code: db 0
physical_proof_net_rx_queue_size: dw 0
physical_proof_net_tx_queue_size: dw 0
physical_proof_block_queue_size: dw 0
physical_proof_net_io_base: dw 0
physical_proof_block_io_base: dw 0
physical_proof_gateway_mac: times 6 db 0
physical_proof_arp_tx_complete: db 0
physical_proof_arp_rx_verified: db 0
physical_proof_ipv4_rx_verified: db 0
physical_proof_icmp_reply_tx: db 0
physical_proof_login_client_ip: times 4 db 0
physical_proof_login_icmp_id: dw 0
physical_proof_login_icmp_sequence: dw 0
physical_proof_login_magic: times 16 db 0
physical_proof_world_store_written: db 0
physical_proof_world_store_read_verified: db 0
physical_proof_login_reply_count: db 0
physical_proof_code_channel_store_written: db 0
physical_proof_code_channel_store_read_verified: db 0
physical_proof_code_commit_command_rx: db 0
physical_proof_code_object_written: db 0
physical_proof_code_object_read_verified: db 0
physical_proof_branch_move_command_rx: db 0
physical_proof_branch_receipt_written: db 0
physical_proof_branch_receipt_read_verified: db 0
physical_proof_recovery_command_rx: db 0
physical_proof_recovery_beacon_written: db 0
physical_proof_recovery_beacon_read_verified: db 0
physical_proof_gestational_index_initialized: db 0
physical_proof_gestational_index_present: db 0
physical_proof_gestational_index_read_verified: db 0
times 512 - ($ - physical_proof_sector) db 0
%endif
%ifdef GHOS_PHYSICAL_CANDIDATE
%include "ghal-virtio.asm"
%endif
%include "world.inc"
times 14848 - ($ - $$) db 0

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,133 @@
bits 16
org 0x7c00
%define COM1 0x3f8
%define CANDIDATE_LBA 34
%define PROOF_LBA 63
start:
cli
cld
xor ax, ax
mov ds, ax
mov es, ax
mov ss, ax
mov sp, 0x7c00
mov [boot_drive], dl
call serial_init
mov si, proof_disk_address_packet
mov ah, 0x42
mov dl, [boot_drive]
int 0x13
jc disk_error
cmp dword [0x8001], 0x534f4847
jne load_candidate
cmp byte [0x8000], 0xa7
je proof_observed
cmp byte [0x8000], 0xe1
je proof_observed
cmp byte [0x8000], 0xa5
je proof_observed
load_candidate:
mov si, candidate_disk_address_packet
mov ah, 0x42
mov dl, [boot_drive]
int 0x13
jc disk_error
mov si, copy_stub
mov di, 0x0500
mov cx, copy_stub_end - copy_stub
rep movsb
jmp 0:0x0500
proof_observed:
mov si, msg_proof_observed
call serial_write
mov dx, 0xf4
mov eax, 0x10
out dx, eax
cli
hlt
jmp $
disk_error:
mov si, msg_disk_error
call serial_write
cli
hlt
jmp $
serial_init:
mov dx, COM1 + 1
xor al, al
out dx, al
mov dx, COM1 + 3
mov al, 0x80
out dx, al
mov dx, COM1
mov al, 1
out dx, al
mov dx, COM1 + 1
xor al, al
out dx, al
mov dx, COM1 + 3
mov al, 3
out dx, al
mov dx, COM1 + 2
mov al, 0xc7
out dx, al
mov dx, COM1 + 4
mov al, 0x0b
out dx, al
ret
serial_write:
lodsb
test al, al
jz .done
mov dx, COM1
out dx, al
jmp serial_write
.done:
ret
copy_stub:
cli
cld
xor ax, ax
mov ds, ax
mov es, ax
mov si, 0x7e00
mov di, 0x7c00
mov cx, 256
rep movsw
jmp 0:0x7c00
copy_stub_end:
boot_drive: db 0
align 4
candidate_disk_address_packet:
db 0x10
db 0
dw 1
dw 0x7e00
dw 0
dd CANDIDATE_LBA
dd 0
proof_disk_address_packet:
db 0x10
db 0
dw 1
dw 0x8000
dw 0
dd PROOF_LBA
dd 0
msg_proof_observed: db "GHOS_DISK_PROOF_OBSERVED_AFTER_RESET=LBA63", 13, 10, 0
msg_disk_error: db "GHOS_TEST_MBR_ERROR=DISK_READ", 13, 10, 0
times 510 - ($ - $$) db 0
dw 0xaa55

View file

@ -0,0 +1,19 @@
[Unit]
Description=Guanghu OS hosted broadcast tower bootstrap
After=network.target
[Service]
Type=simple
User=guanghu
Group=guanghu
ExecStart=/guanghu/bin/guanghu-broadcast-tower serve /guanghu/current 127.0.0.1:8077 /guanghu/var/broadcast-tower/LIVE.hldp
Restart=on-failure
RestartSec=2
NoNewPrivileges=true
PrivateTmp=true
ProtectHome=true
ProtectSystem=strict
ReadWritePaths=/guanghu/var/broadcast-tower
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,22 @@
[Unit]
Description=Guanghu Code Channel hosted Forgejo data plane
After=network.target
[Service]
Type=simple
User=forgejo
Group=forgejo
WorkingDirectory=/guanghu/code-channel
Environment=HOME=/guanghu/code-channel
Environment=FORGEJO_WORK_DIR=/guanghu/code-channel
ExecStart=/guanghu/code-channel/bin/forgejo-16.0.1 web --config /guanghu/code-channel/custom/conf/app.ini
Restart=on-failure
RestartSec=3
NoNewPrivileges=true
PrivateTmp=true
ProtectHome=true
ProtectSystem=strict
ReadWritePaths=/guanghu/code-channel/data /guanghu/code-channel/log
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,54 @@
#!/usr/bin/env bash
set -euo pipefail
[[ $# -eq 2 ]] || {
echo "usage: arm-native-physical-once.sh <world-root> <recovery-root>" >&2
exit 64
}
[[ ${EUID} -eq 0 ]] || {
echo "must run as root" >&2
exit 77
}
world_root=$(readlink -f "$1")
recovery_root=$(readlink -f "$2")
/guanghu/bin/ghctl authorize "${world_root}" reboot_and_recover_bs_sh_005 \
>/dev/null
grep -q "menuentry 'Guanghu OS native one-time proof'.*'guanghu-native-once'" \
/boot/grub/grub.cfg
proof_before=$(mktemp)
trap 'rm -f "${proof_before}"' EXIT
dd if=/dev/vda of="${proof_before}" bs=512 skip=50 count=1 status=none
cmp -s "${proof_before}" <(head -c 512 /dev/zero)
grub-editenv /boot/grub/grubenv unset initrdfail prev_entry next_entry
grub-reboot guanghu-native-once
grub_state=$(grub-editenv /boot/grub/grubenv list)
grep -q '^next_entry=guanghu-native-once$' <<<"${grub_state}"
if grep -Eq '^(initrdfail|prev_entry)=' <<<"${grub_state}"; then
echo "stale GRUB fallback state remains" >&2
exit 65
fi
previous_boot_id=$(cat /proc/sys/kernel/random/boot_id)
observed_at=$(date --iso-8601=seconds)
cat >"${recovery_root}/ARMED-RECEIPT.hldp" <<EOF
schema: guanghu.native-physical-arm/v1
receipt_id: GH-OS-LAB-001-NATIVE-PHYSICAL-ARM-001
status: ARMED
observed_at: ${observed_at}
node_id: BS-SH-005
previous_linux_boot_id: ${previous_boot_id}
disk_proof_before:
lba: 50
state: EMPTY
grub:
entry_id: guanghu-native-once
next_entry: VERIFIED
stale_initrd_fallback_state: CLEARED
next_action: SYNC_AND_REBOOT
EOF
chmod 0400 "${recovery_root}/ARMED-RECEIPT.hldp"
sync
cat "${recovery_root}/ARMED-RECEIPT.hldp"

View file

@ -0,0 +1,25 @@
#!/usr/bin/env bash
set -euo pipefail
[[ $# -eq 2 ]] || {
echo "usage: build-native-bios-image.sh <world-root> <output-directory>" >&2
exit 64
}
world_root=$(readlink -f "$1")
output_root=$(readlink -m "$2")
source_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
native_root=${source_root}/native/x86_64-bios
command -v nasm >/dev/null
mkdir -p "${output_root}"
cargo run --quiet --manifest-path "${source_root}/Cargo.toml" \
-p hldp-native-compiler -- "${world_root}" "${output_root}/world.inc"
(
cd "${output_root}"
nasm -f bin -I "${output_root}/" -I "${native_root}/" "${native_root}/boot.asm" \
-o guanghu-os-x86_64-bios.img
)
[[ $(stat -c %s "${output_root}/guanghu-os-x86_64-bios.img") -eq 14848 ]]
sha256sum "${output_root}/guanghu-os-x86_64-bios.img" \
>"${output_root}/guanghu-os-x86_64-bios.img.sha256"

View file

@ -0,0 +1,28 @@
#!/usr/bin/env bash
set -euo pipefail
[[ $# -eq 2 ]] || {
echo "usage: build-native-physical-candidate.sh <world-root> <output-directory>" >&2
exit 64
}
world_root=$(readlink -f "$1")
output_root=$(readlink -m "$2")
source_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
native_root=${source_root}/native/x86_64-bios
command -v nasm >/dev/null
mkdir -p "${output_root}"
cargo run --quiet --manifest-path "${source_root}/Cargo.toml" \
-p hldp-native-compiler -- "${world_root}" "${output_root}/world.inc"
(
cd "${output_root}"
nasm -f bin -I "${output_root}/" -I "${native_root}/" \
-dSTAGE2_LBA=35 \
-dGHOS_PHYSICAL_CANDIDATE=1 \
"${native_root}/boot.asm" \
-o guanghu-os-x86_64-bios-physical.img
)
[[ $(stat -c %s "${output_root}/guanghu-os-x86_64-bios-physical.img") -eq 14848 ]]
sha256sum "${output_root}/guanghu-os-x86_64-bios-physical.img" \
>"${output_root}/guanghu-os-x86_64-bios-physical.img.sha256"

View file

@ -0,0 +1,31 @@
#!/usr/bin/env bash
set -euo pipefail
[[ $# -eq 3 ]] || {
echo "usage: build-native-physical-probe.sh <world-root> <output-directory> <probe-stage>" >&2
exit 64
}
world_root=$(readlink -f "$1")
output_root=$(readlink -m "$2")
probe_stage=$3
[[ ${probe_stage} =~ ^[1-9]$ ]]
source_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
native_root=${source_root}/native/x86_64-bios
command -v nasm >/dev/null
mkdir -p "${output_root}"
cargo run --quiet --manifest-path "${source_root}/Cargo.toml" \
-p hldp-native-compiler -- "${world_root}" "${output_root}/world.inc"
(
cd "${output_root}"
nasm -f bin -I "${output_root}/" -I "${native_root}/" \
-dSTAGE2_LBA=35 \
-dGHOS_PHYSICAL_CANDIDATE=1 \
-dGHOS_GHAL_PROBE_STAGE="${probe_stage}" \
"${native_root}/boot.asm" \
-o "guanghu-os-x86_64-bios-probe-${probe_stage}.img"
)
image=${output_root}/guanghu-os-x86_64-bios-probe-${probe_stage}.img
[[ $(stat -c %s "${image}") -eq 14848 ]]
sha256sum "${image}" >"${image}.sha256"

View file

@ -0,0 +1,29 @@
#!/usr/bin/env bash
set -euo pipefail
[[ $# -eq 2 ]] || {
echo "usage: build-native-resident-candidate.sh <world-root> <output-directory>" >&2
exit 64
}
world_root=$(readlink -f "$1")
output_root=$(readlink -m "$2")
source_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
native_root=${source_root}/native/x86_64-bios
command -v nasm >/dev/null
mkdir -p "${output_root}"
cargo run --quiet --manifest-path "${source_root}/Cargo.toml" \
-p hldp-native-compiler -- "${world_root}" "${output_root}/world.inc"
(
cd "${output_root}"
nasm -f bin -I "${output_root}/" -I "${native_root}/" \
-dSTAGE2_LBA=35 \
-dGHOS_PHYSICAL_CANDIDATE=1 \
-dGHOS_NATIVE_RESIDENT=1 \
"${native_root}/boot.asm" \
-o guanghu-os-x86_64-bios-resident.img
)
[[ $(stat -c %s "${output_root}/guanghu-os-x86_64-bios-resident.img") -eq 14848 ]]
sha256sum "${output_root}/guanghu-os-x86_64-bios-resident.img" \
>"${output_root}/guanghu-os-x86_64-bios-resident.img.sha256"

View file

@ -0,0 +1,40 @@
#!/usr/bin/env bash
set -euo pipefail
[[ $# -eq 2 ]] || {
echo "usage: clear-native-recovery-beacon.sh <disk> <clear-template>" >&2
exit 64
}
disk=$1
clear_template=$2
[[ -f ${clear_template} ]]
[[ $(stat -c %s "${clear_template}" 2>/dev/null || stat -f %z "${clear_template}") -eq 1024 ]]
if [[ -b ${disk} ]]; then
[[ ${EUID} -eq 0 ]]
[[ $(readlink -f "${disk}") == /dev/vda ]]
elif [[ ! -f ${disk} ]]; then
echo "recovery beacon target is neither /dev/vda nor a test disk" >&2
exit 65
fi
readback=$(mktemp)
trap 'rm -f "${readback}"' EXIT
dd if="${disk}" of="${readback}" bs=512 skip=68 count=2 status=none
if cmp -s "${readback}" "${clear_template}"; then
echo "GUANGHU_NATIVE_RECOVERY_BEACON_ALREADY_CLEAR"
exit 0
fi
if ! grep -aFq 'guanghu_recovery=ubuntu' "${readback}"; then
echo "unknown data occupies the recovery beacon sectors" >&2
exit 65
fi
dd if="${clear_template}" of="${disk}" bs=512 seek=68 count=2 \
conv=notrunc,fsync status=none
dd if="${disk}" of="${readback}" bs=512 skip=68 count=2 status=none
cmp "${readback}" "${clear_template}"
echo "GUANGHU_NATIVE_RECOVERY_BEACON_CLEARED"

View file

@ -0,0 +1,57 @@
#!/usr/bin/env bash
set -euo pipefail
[[ $# -eq 4 ]] || {
echo "usage: consume-ghal-physical-probe.sh <world-root> <recovery-root> <probe-stage> <receipt-destination>" >&2
exit 64
}
[[ ${EUID} -eq 0 ]] || {
echo "must run as root" >&2
exit 77
}
world_root=$(readlink -f "$1")
recovery_root=$(readlink -f "$2")
probe_stage=$3
receipt_destination=$(readlink -m "$4")
[[ ${probe_stage} =~ ^[1-9]$ ]]
/guanghu/bin/ghctl authorize "${world_root}" \
write_bootloader_and_system_partitions >/dev/null
proof=${recovery_root}/lba63.ghal-observation.bin
observation=${recovery_root}/GHAL-DIAGNOSTIC-OBSERVATION.hldp
[[ -f ${proof} && -f ${observation} ]]
python3 - "${proof}" "${probe_stage}" <<'PY'
import pathlib
import sys
proof = pathlib.Path(sys.argv[1]).read_bytes()
stage = int(sys.argv[2])
assert len(proof) == 512
assert proof[0] == 0xA5
assert proof[1:].startswith(b"GHOS_NATIVE_LONG64_DISK_PROOF\x00")
assert proof[42] == 0x80 + stage
assert proof[43] == 0
PY
install -o root -g root -m 0400 "${observation}" "${receipt_destination}"
dd if=/dev/zero of=/dev/vda bs=512 seek=63 count=1 \
conv=notrunc,fsync status=none
cleared=$(mktemp)
trap 'rm -f "${cleared}"' EXIT
dd if=/dev/vda of="${cleared}" bs=512 skip=63 count=1 status=none
cmp -s "${cleared}" <(head -c 512 /dev/zero)
observed_at=$(date --iso-8601=seconds)
cat >"${recovery_root}/GHAL-PROBE-CONSUMPTION.hldp" <<EOF
schema: guanghu.ghal-probe-consumption/v1
receipt_id: GH-OS-LAB-001-GHAL-PROBE-${probe_stage}-CONSUMPTION
status: VERIFIED_AND_CLEARED
observed_at: ${observed_at}
node_id: BS-SH-005
probe_stage: ${probe_stage}
proof_lba: 63
proof_cleared: true
observation_installed_at: ${receipt_destination}
next_action: INSTALL_NEXT_GHAL_PROBE_STAGE
EOF
chmod 0400 "${recovery_root}/GHAL-PROBE-CONSUMPTION.hldp"
cat "${recovery_root}/GHAL-PROBE-CONSUMPTION.hldp"

View file

@ -0,0 +1,107 @@
#!/usr/bin/env bash
set -euo pipefail
[[ $# -eq 3 ]] || {
echo "usage: inspect-ghal-physical-return.sh <world-root> <recovery-root> <previous-boot-id>" >&2
exit 64
}
[[ ${EUID} -eq 0 ]] || {
echo "must run as root" >&2
exit 77
}
world_root=$(readlink -f "$1")
recovery_root=$(readlink -f "$2")
previous_boot_id=$3
current_boot_id=$(cat /proc/sys/kernel/random/boot_id)
[[ ${current_boot_id} != "${previous_boot_id}" ]]
/guanghu/bin/ghctl authorize "${world_root}" reboot_and_recover_bs_sh_005 \
>/dev/null
systemctl is-active --quiet guanghu-broadcast-tower.service
systemctl is-active --quiet guanghu-code-channel.service
proof_path=${recovery_root}/lba63.ghal-observation.bin
receipt_path=${recovery_root}/GHAL-DIAGNOSTIC-OBSERVATION.hldp
dd if=/dev/vda of="${proof_path}" bs=512 skip=63 count=1 status=none
observed_at=$(date --iso-8601=seconds)
python3 - "${proof_path}" "${receipt_path}" "${observed_at}" \
"${previous_boot_id}" "${current_boot_id}" <<'PY'
import pathlib
import sys
proof_path = pathlib.Path(sys.argv[1])
receipt_path = pathlib.Path(sys.argv[2])
observed_at, previous_boot_id, current_boot_id = sys.argv[3:]
proof = proof_path.read_bytes()
assert len(proof) == 512
assert proof[0] in (0xA5, 0xA7, 0xE1)
assert proof[1:].startswith(b"GHOS_NATIVE_LONG64_DISK_PROOF\x00")
if proof[0] == 0xA7:
result = "GHAL_DRIVER_OK"
status = "VERIFIED"
elif proof[0] == 0xA5:
result = "GHAL_PROBE_RETURNED"
status = "VERIFIED_PROBE_STAGE"
else:
result = "GHAL_FAILED_WITH_DIAGNOSTIC"
status = "FAILED_CLOSED_DIAGNOSTIC_OBSERVED"
mac = ":".join(f"{byte:02x}" for byte in proof[36:42])
gateway_mac = ":".join(f"{byte:02x}" for byte in proof[54:60])
login_client_ip = ".".join(str(byte) for byte in proof[64:68])
u16 = lambda offset: int.from_bytes(proof[offset:offset + 2], "little")
text = f"""schema: guanghu.ghal-diagnostic-observation/v1
receipt_id: GH-OS-LAB-001-GHAL-DIAGNOSTIC-OBSERVATION
status: {status}
observed_at: {observed_at}
node_id: BS-SH-005
instance_id: lhins-14w5y3ce
boot:
previous_linux_boot_id: {previous_boot_id}
recovered_linux_boot_id: {current_boot_id}
native_result:
result: {result}
proof_flag: 0x{proof[0]:02x}
stage: 0x{proof[42]:02x}
error: 0x{proof[43]:02x}
virtio_net_discovered: {str(bool(proof[32])).lower()}
virtio_block_discovered: {str(bool(proof[33])).lower()}
virtio_net_queue_ready: {str(bool(proof[34])).lower()}
virtio_block_queue_ready: {str(bool(proof[35])).lower()}
mac: {mac}
net_rx_queue_size: {u16(44)}
net_tx_queue_size: {u16(46)}
block_queue_size: {u16(48)}
net_io_base: 0x{u16(50):04x}
block_io_base: 0x{u16(52):04x}
gateway_mac: {gateway_mac}
arp_tx_complete: {str(bool(proof[60])).lower()}
arp_rx_verified: {str(bool(proof[61])).lower()}
ipv4_login_rx_verified: {str(bool(proof[62])).lower()}
icmp_login_reply_tx: {str(bool(proof[63])).lower()}
login_client_ip: {login_client_ip}
login_icmp_id_network_order: 0x{u16(68):04x}
login_icmp_sequence_network_order: 0x{u16(70):04x}
login_magic: {proof[72:88].decode("ascii", errors="replace")}
world_store_written: {str(bool(proof[88])).lower()}
world_store_read_verified: {str(bool(proof[89])).lower()}
login_reply_count: {proof[90]}
code_channel_store_written: {str(bool(proof[91])).lower()}
code_channel_store_read_verified: {str(bool(proof[92])).lower()}
code_commit_command_rx: {str(bool(proof[93])).lower()}
code_object_written: {str(bool(proof[94])).lower()}
code_object_read_verified: {str(bool(proof[95])).lower()}
branch_move_command_rx: {str(bool(proof[96])).lower()}
branch_receipt_written: {str(bool(proof[97])).lower()}
branch_receipt_read_verified: {str(bool(proof[98])).lower()}
proof:
lba: 63
sha256: {__import__("hashlib").sha256(proof).hexdigest()}
cleared_after_observation: false
next_action: CONSUME_PROOF_WITH_SUCCESS_VERIFIER_OR_SEAL_FAILURE_AND_CLEAR
"""
receipt_path.write_text(text)
PY
chmod 0400 "${proof_path}" "${receipt_path}"
sync
cat "${receipt_path}"

View file

@ -0,0 +1,213 @@
#!/usr/bin/env bash
set -euo pipefail
usage() {
echo "usage: sudo install-hosted-stage1.sh <guanghu-os-source> <source-sha> <archive-sha256>" >&2
exit 64
}
[[ $# -eq 3 ]] || usage
[[ ${EUID} -eq 0 ]] || {
echo "install-hosted-stage1.sh must run as root" >&2
exit 77
}
source_root=$(readlink -f "$1")
source_sha=$2
archive_sha256=$3
version=0.1.0-stage1
install_root=/guanghu
version_root=${install_root}/versions/${version}
staging_root=${install_root}/versions/.${version}.installing
export RUSTUP_HOME=/opt/guanghu/rustup
export CARGO_HOME=/opt/guanghu/cargo
export PATH=${CARGO_HOME}/bin:${PATH}
[[ ${source_sha} =~ ^[0-9a-f]{40}$ ]] || {
echo "source SHA must be a full lowercase Git SHA" >&2
exit 65
}
[[ ${archive_sha256} =~ ^[0-9a-f]{64}$ ]] || {
echo "archive SHA-256 must be a full lowercase digest" >&2
exit 65
}
[[ -f ${source_root}/Cargo.toml && -f ${source_root}/world-seed/WORLD-MANIFEST.hldp ]] || {
echo "source root is not a Guanghu OS workspace" >&2
exit 66
}
[[ $(uname -m) == x86_64 ]] || {
echo "Stage 1 is pinned to the x86_64 Shanghai node" >&2
exit 69
}
[[ -b /dev/vda ]] || {
echo "expected Shanghai system disk /dev/vda is absent" >&2
exit 69
}
[[ ! -e ${version_root} ]] || {
echo "${version_root} already exists; immutable versions are never overwritten" >&2
exit 73
}
command -v cargo >/dev/null
command -v rustc >/dev/null
mkdir -p "${install_root}/versions" "${install_root}/bin"
[[ ! -e ${staging_root} ]] || {
echo "stale staging directory exists: ${staging_root}" >&2
exit 73
}
mkdir -p "${staging_root}/bin"
cleanup_staging() {
if [[ -d ${staging_root} ]]; then
mv "${staging_root}" "${staging_root}.failed.$(date -u +%Y%m%dT%H%M%SZ)"
fi
}
trap cleanup_staging ERR
cd "${source_root}"
cargo test --workspace --locked
cargo build --release --locked -p ghctl
cp -a world-seed/. "${staging_root}/"
install -m 0755 target/release/ghctl "${staging_root}/bin/ghctl"
observed_at=$(date --iso-8601=seconds)
kernel=$(uname -r)
rust_version=$(rustc --version | tr ' ' '_')
cargo_version=$(cargo --version | tr ' ' '_')
cat >"${staging_root}/CURRENT.hldp" <<EOF
schema: guanghu.current/v1
node_id: BS-SH-005
lab_id: GH-OS-LAB-001
phase: PHASE_1_WORLD_INSTALLED
state: HOSTED_WORLD_OPERATIONAL
authorization:
id: GH-OS-AUTH-BINGSHUO-BS-SH-005-001
status: ACTIVE
behavior: AUTO_EXECUTE_IN_SCOPE_WITHOUT_REPEAT_CONFIRMATION
hosted_bootstrap:
os: Ubuntu 24.04.4 LTS
kernel: ${kernel}
architecture: x86_64
privilege: ubuntu_with_passwordless_sudo
direct_access: VERIFIED_STRICT_HOST_KEY
access_receipt: state/receipts/DIRECT-ACCESS-20260731.hldp
native_state:
hldp_runtime: RUNNING_HOSTED
five_domains: INSTALLED_AND_VALIDATED
broadcast_tower: REGISTERED_NOT_RUNNING
code_channel_control_plane: HLDP_CONTRACT_DEFINED_NOT_RUNNING
code_channel_data_plane: SOURCE_BASELINE_VERIFIED_NOT_RUNNING
native_kernel: NOT_IMPLEMENTED
boot_image: NOT_CREATED
linux_exited: false
source:
implementation_commit: ${source_sha}
installation_archive_sha256: ${archive_sha256}
next_action:
- start_hosted_broadcast_tower
- start_code_channel_hosted_data_plane
- implement_hldp_native_control_plane
- build_and_validate_native_kernel
EOF
cat >"${staging_root}/state/receipts/PHASE-1-WORLD-INSTALLED.hldp" <<EOF
schema: guanghu.phase-receipt/v1
receipt_id: GH-OS-LAB-001-PHASE-1-WORLD-INSTALLED
node_id: BS-SH-005
instance_id: lhins-14w5y3ce
phase: PHASE_1_WORLD_INSTALLED
status: VERIFIED
observed_at: ${observed_at}
source:
implementation_repository: REPO-008
implementation_commit: ${source_sha}
installation_archive_sha256: ${archive_sha256}
runtime:
mode: HOSTED_BOOTSTRAP
host_operating_system: Ubuntu 24.04.4 LTS
host_kernel: ${kernel}
architecture: x86_64
rustc: ${rust_version}
cargo: ${cargo_version}
prior_attempts:
- id: PHASE_1_INSTALL_ATTEMPT_001
status: FAILED_CLOSED
cause: UBUNTU_CARGO_1_75_CANNOT_READ_LOCKFILE_V4
activation_changed: false
evidence_directory: /guanghu/versions/.0.1.0-stage1.installing.failed.20260731T074748Z
verified:
- workspace_tests_passed_on_server
- release_ghctl_built_on_server
- five_domain_world_manifest_validated
- dedicated_access_receipt_readable
- standing_authorization_readable
not_yet_true:
- broadcast_tower_running
- hosted_forgejo_running
- native_kernel_booted
- linux_replaced
rollback:
previous_current_symlink: preserved_until_atomic_activation
provider_reinstall_path: Tencent Cloud Lighthouse console
next_action: PHASE_1B_HOSTED_BROADCAST_AND_CODE_CHANNEL
EOF
python3 - "${staging_root}/WORLD-MANIFEST.hldp" <<'PY'
from pathlib import Path
import sys
path = Path(sys.argv[1])
text = path.read_text()
old = "last_receipt: state/receipts/PHASE-0-PREFLIGHT.hldp"
new = "last_receipt: state/receipts/PHASE-1-WORLD-INSTALLED.hldp"
if text.count(old) != 1:
raise SystemExit("WORLD-MANIFEST phase receipt anchor is missing or ambiguous")
path.write_text(text.replace(old, new))
PY
python3 - "${staging_root}/WAKE.hldp" <<'PY'
from pathlib import Path
import sys
path = Path(sys.argv[1])
text = path.read_text()
text = text.replace(
"status: PREFLIGHT_VERIFIED_WORLD_NOT_INSTALLED",
"status: HOSTED_WORLD_INSTALLED",
)
text = text.replace(
" - state/receipts/PHASE-0-PREFLIGHT.hldp",
" - state/receipts/PHASE-1-WORLD-INSTALLED.hldp",
)
path.write_text(text)
PY
"${staging_root}/bin/ghctl" wake "${staging_root}" >/tmp/guanghu-stage1-wake.txt
grep -q '^GUANGHU_WORLD_OK$' /tmp/guanghu-stage1-wake.txt
grep -q '^domains=5$' /tmp/guanghu-stage1-wake.txt
grep -q '^last_receipt=state/receipts/PHASE-1-WORLD-INSTALLED.hldp$' /tmp/guanghu-stage1-wake.txt
grep -q '^authorization=GH-OS-AUTH-BINGSHUO-BS-SH-005-001$' /tmp/guanghu-stage1-wake.txt
cat >"${staging_root}/INSTALLATION.hldp" <<EOF
schema: guanghu.installation/v1
node_id: BS-SH-005
version: ${version}
source_sha: ${source_sha}
archive_sha256: ${archive_sha256}
installed_at: ${observed_at}
immutable: true
activation: /guanghu/current
recovery_entry: /guanghu/bin/ghctl wake /guanghu/current
EOF
chmod -R a-w "${staging_root}"
mv "${staging_root}" "${version_root}"
ln -sfn "${version_root}" "${install_root}/current.next"
mv -Tf "${install_root}/current.next" "${install_root}/current"
ln -sfn "${install_root}/current/bin/ghctl" "${install_root}/bin/ghctl"
trap - ERR
"${install_root}/bin/ghctl" wake "${install_root}/current"

View file

@ -0,0 +1,432 @@
#!/usr/bin/env bash
set -euo pipefail
usage() {
echo "usage: sudo install-hosted-stage1b-services.sh <guanghu-os-source> <source-sha> <archive-sha256> <forgejo-offline-dir>" >&2
exit 64
}
[[ $# -eq 4 ]] || usage
[[ ${EUID} -eq 0 ]] || {
echo "install-hosted-stage1b-services.sh must run as root" >&2
exit 77
}
source_root=$(readlink -f "$1")
source_sha=$2
archive_sha256=$3
offline_root=$(readlink -f "$4")
version=0.1.2-stage1b-r1
install_root=/guanghu
version_root=${install_root}/versions/${version}
staging_root=${install_root}/versions/.${version}.installing
previous_current=$(readlink -f "${install_root}/current")
activation_changed=false
export RUSTUP_HOME=/opt/guanghu/rustup
export CARGO_HOME=/opt/guanghu/cargo
export PATH=${CARGO_HOME}/bin:${PATH}
[[ ${source_sha} =~ ^[0-9a-f]{40}$ ]] || {
echo "source SHA must be a full lowercase Git SHA" >&2
exit 65
}
[[ ${archive_sha256} =~ ^[0-9a-f]{64}$ ]] || {
echo "archive SHA-256 must be a full lowercase digest" >&2
exit 65
}
[[ ${previous_current} == /guanghu/versions/0.1.1-stage1b ]] || {
echo "Stage 1B revision requires the exact active Stage 1B world" >&2
exit 69
}
[[ -f ${source_root}/Cargo.toml && -f ${source_root}/world-seed/WORLD-MANIFEST.hldp ]] || {
echo "source root is not a Guanghu OS workspace" >&2
exit 66
}
[[ -f ${offline_root}/MANIFEST.sha256 ]] || {
echo "Forgejo offline manifest is missing" >&2
exit 66
}
[[ ! -e ${version_root} && ! -e ${staging_root} ]] || {
echo "Stage 1B version or staging path already exists" >&2
exit 73
}
cleanup_failed_install() {
systemctl stop guanghu-broadcast-tower.service guanghu-code-channel.service >/dev/null 2>&1 || true
if ${activation_changed}; then
ln -sfn "${previous_current}" "${install_root}/current.rollback"
mv -Tf "${install_root}/current.rollback" "${install_root}/current"
ln -sfn "${install_root}/current/bin/ghctl" "${install_root}/bin/ghctl"
fi
if [[ -d ${staging_root} ]]; then
mv "${staging_root}" "${staging_root}.failed.$(date -u +%Y%m%dT%H%M%SZ)"
elif [[ -d ${version_root} ]]; then
mv "${version_root}" "${version_root}.failed.$(date -u +%Y%m%dT%H%M%SZ)"
fi
}
trap cleanup_failed_install ERR
(cd "${offline_root}" && sha256sum -c MANIFEST.sha256)
grep -q '^b3d7e4ac3cbccc220703097a51fa4c16bf302579 refs/heads/guanghu/main$' \
< <(git bundle list-heads "${offline_root}/guanghu-code-channel.bundle")
cd "${source_root}"
cargo test --workspace --locked
cargo build --release --locked -p ghctl -p guanghu-broadcast-tower
cp -a "${source_root}/world-seed" "${staging_root}"
chmod -R u+w "${staging_root}"
mkdir -p "${staging_root}/bin"
install -m 0755 target/release/ghctl "${staging_root}/bin/ghctl"
install -m 0755 target/release/guanghu-broadcast-tower \
"${staging_root}/bin/guanghu-broadcast-tower"
observed_at=$(date --iso-8601=seconds)
kernel=$(uname -r)
cat >"${staging_root}/CURRENT.hldp" <<EOF
schema: guanghu.current/v1
node_id: BS-SH-005
lab_id: GH-OS-LAB-001
phase: PHASE_1B_HOSTED_SERVICES
state: HOSTED_WORLD_AND_SERVICES_OPERATIONAL
authorization:
id: GH-OS-AUTH-BINGSHUO-BS-SH-005-001
status: ACTIVE
behavior: AUTO_EXECUTE_IN_SCOPE_WITHOUT_REPEAT_CONFIRMATION
hosted_bootstrap:
os: Ubuntu 24.04.4 LTS
kernel: ${kernel}
architecture: x86_64
direct_access: VERIFIED_STRICT_HOST_KEY
broadcast_address: 127.0.0.1:8077
code_channel_address: 127.0.0.1:3080
native_state:
hldp_runtime: RUNNING_HOSTED
five_domains: INSTALLED_AND_VALIDATED
broadcast_tower: RUNNING_HOSTED_SINGLETON
code_channel_control_plane: HLDP_CONTRACT_DEFINED_NOT_RUNNING
code_channel_data_plane: FORGEJO_16_0_1_RUNNING_HOSTED
native_kernel: NOT_IMPLEMENTED
boot_image: NOT_CREATED
linux_exited: false
source:
implementation_commit: ${source_sha}
installation_archive_sha256: ${archive_sha256}
next_action:
- implement_hldp_native_code_channel_control_plane
- build_gosk_minimum_kernel
- validate_native_boot_in_virtual_machine
EOF
cat >"${staging_root}/state/receipts/PHASE-1B-HOSTED-SERVICES.hldp" <<EOF
schema: guanghu.phase-receipt/v1
receipt_id: GH-OS-LAB-001-PHASE-1B-HOSTED-SERVICES
node_id: BS-SH-005
instance_id: lhins-14w5y3ce
phase: PHASE_1B_HOSTED_SERVICES
status: VERIFIED
observed_at: ${observed_at}
source:
implementation_commit: ${source_sha}
installation_archive_sha256: ${archive_sha256}
correction:
supersedes_version: 0.1.1-stage1b
reason: WORLD_MANIFEST_VERSION_AND_PHASE_LAGGED_BEHIND_CURRENT
detected_by: MAC_SSH_TUNNEL_EXTERNAL_HEALTH_READBACK
services:
broadcast_tower:
unit: guanghu-broadcast-tower.service
address: 127.0.0.1:8077
authority_language: HLDP
runtime: HOSTED_BOOTSTRAP
code_channel:
unit: guanghu-code-channel.service
address: 127.0.0.1:3080
engine: Forgejo 16.0.1
role: TEMPORARY_HOSTED_DATA_PLANE
prior_attempts:
- id: PHASE_1B_INSTALL_ATTEMPT_001
status: FAILED_CLOSED
cause: FORGEJO_FIRST_MIGRATION_REQUIRED_TEMPORARY_CONFIG_WRITE
activation_changed: false
evidence_directory: /guanghu/versions/.0.1.1-stage1b.installing.failed.20260731T082343Z
- id: PHASE_1B_INSTALL_ATTEMPT_002
status: FAILED_CLOSED
cause: RELATIVE_SOURCE_ROOT_INVALID_AFTER_BUILD_DIRECTORY_CHANGE
activation_changed: false
evidence_directory: /guanghu/versions/.0.1.1-stage1b.installing.failed.20260731T082554Z
- id: PHASE_1B_INSTALL_ATTEMPT_003
status: FAILED_CLOSED
cause: HEALTH_PROBE_RAN_BEFORE_FORGEJO_OPENED_LISTENER
activation_changed: rolled_back
evidence_directory: /guanghu/versions/0.1.1-stage1b.failed.20260731T082820Z
verified:
- broadcast_tower_health_returns_registered_five_domain_world
- broadcast_epoch_written_by_live_process
- forgejo_health_endpoint_returns_success
- offline_manifest_sha256_entries_match_on_server
- product_bundle_contains_exact_guanghu_main_commit
- source_bundle_preserved_on_server
not_yet_true:
- hldp_native_code_channel_control_plane_running
- gosk_native_repository_data_plane_running
- native_kernel_booted
- linux_replaced
next_action: PHASE_2_HLDP_NATIVE_CONTROL_PLANE
EOF
cat >"${staging_root}/state/receipts/CODE-CHANNEL-HOSTED.hldp" <<EOF
schema: guanghu.code-channel-receipt/v1
receipt_id: GH-OS-LAB-001-CODE-CHANNEL-HOSTED
channel_id: HLP-MOD-CODE-CHANNEL
phase: PHASE_1_HOSTED_DATA_PLANE
status: VERIFIED
observed_at: ${observed_at}
engine:
name: Forgejo
version: 16.0.1
binary_sha256: 7a4c568136650c10498a9d3d62c7fd630a0cf09c166293ebd78708248f6398fc
source:
product_branch: guanghu/main
product_commit: b3d7e4ac3cbccc220703097a51fa4c16bf302579
product_bundle_sha256: fc53740259d108128e69f5a809cec438ecf3158175617574ba55b8612c5eaa6c
upstream_bundle_sha256: c33bd074d9b2896259e86ebe03ad31ccdd8ff71897beed4320081fa03b15381f
runtime:
address: 127.0.0.1:3080
exposure: LOOPBACK_ONLY
database: sqlite
registration_disabled: true
ssh_server_disabled: true
authority:
language: HLDP
forgejo_is_os: false
native_acceptance: false
next_action: PHASE_2_HLDP_NATIVE_CONTROL_PLANE
EOF
python3 - "${staging_root}" <<'PY'
from pathlib import Path
import sys
root = Path(sys.argv[1])
def replace(path, old, new):
text = path.read_text()
if text.count(old) != 1:
raise SystemExit(f"{path}: anchor missing or ambiguous: {old}")
path.write_text(text.replace(old, new))
replace(
root / "WORLD-MANIFEST.hldp",
"version: 0.1.0-stage1",
"version: 0.1.2-stage1b-r1",
)
replace(
root / "WORLD-MANIFEST.hldp",
"phase: HOSTED_BOOTSTRAP_PROTOTYPE",
"phase: HOSTED_SERVICES_BOOTSTRAP",
)
replace(
root / "WORLD-MANIFEST.hldp",
"state: REGISTERED_NOT_RUNNING",
"state: RUNNING_HOSTED",
)
replace(
root / "WORLD-MANIFEST.hldp",
"last_receipt: state/receipts/CODE-CHANNEL-BASELINE.hldp",
"last_receipt: state/receipts/CODE-CHANNEL-HOSTED.hldp",
)
replace(
root / "WORLD-MANIFEST.hldp",
"last_receipt: state/receipts/PHASE-0-PREFLIGHT.hldp",
"last_receipt: state/receipts/PHASE-1B-HOSTED-SERVICES.hldp",
)
replace(
root / "WAKE.hldp",
"status: PREFLIGHT_VERIFIED_WORLD_NOT_INSTALLED",
"status: HOSTED_WORLD_AND_SERVICES_RUNNING",
)
replace(
root / "WAKE.hldp",
"state/receipts/PHASE-0-PREFLIGHT.hldp",
"state/receipts/PHASE-1B-HOSTED-SERVICES.hldp",
)
replace(
root / "WAKE.hldp",
"state/receipts/CODE-CHANNEL-BASELINE.hldp",
"state/receipts/CODE-CHANNEL-HOSTED.hldp",
)
replace(
root / "world/services/code-channel/CHANNEL.hldp",
"state: SOURCE_BASELINE_VERIFIED_RUNTIME_NOT_INSTALLED",
"state: HOSTED_DATA_PLANE_RUNNING",
)
replace(
root / "world/services/code-channel/CHANNEL.hldp",
"current_phase: PHASE_0_SOURCE_BASELINE_VERIFIED",
"current_phase: PHASE_1_HOSTED_DATA_PLANE",
)
replace(
root / "world/services/code-channel/CHANNEL.hldp",
" - id: PHASE_1_HOSTED_DATA_PLANE\n state: PENDING",
" - id: PHASE_1_HOSTED_DATA_PLANE\n state: COMPLETE",
)
replace(
root / "world/services/code-channel/CHANNEL.hldp",
"last_receipt: state/receipts/CODE-CHANNEL-BASELINE.hldp",
"last_receipt: state/receipts/CODE-CHANNEL-HOSTED.hldp",
)
replace(
root / "world/services/code-channel/CHANNEL.hldp",
"next_action: install_verified_offline_baseline_as_hosted_data_plane",
"next_action: implement_hldp_native_control_plane",
)
PY
"${staging_root}/bin/ghctl" wake "${staging_root}" >/tmp/guanghu-stage1b-wake.txt
grep -q '^GUANGHU_WORLD_OK$' /tmp/guanghu-stage1b-wake.txt
grep -q '^domains=5$' /tmp/guanghu-stage1b-wake.txt
grep -q '^last_receipt=state/receipts/PHASE-1B-HOSTED-SERVICES.hldp$' \
/tmp/guanghu-stage1b-wake.txt
getent passwd guanghu >/dev/null || \
useradd --system --home-dir /nonexistent --shell /usr/sbin/nologin guanghu
getent passwd forgejo >/dev/null || \
useradd --system --home-dir /guanghu/code-channel --shell /usr/sbin/nologin forgejo
install -d -o guanghu -g guanghu -m 0750 "${install_root}/var/broadcast-tower"
install -d -o root -g forgejo -m 0750 \
"${install_root}/code-channel" \
"${install_root}/code-channel/bin" \
"${install_root}/code-channel/custom" \
"${install_root}/code-channel/custom/conf" \
"${install_root}/code-channel/offline"
install -d -o forgejo -g forgejo -m 0750 \
"${install_root}/code-channel/data" \
"${install_root}/code-channel/data/repositories" \
"${install_root}/code-channel/data/bootstrap-repositories" \
"${install_root}/code-channel/log"
install -m 0755 "${offline_root}/forgejo-16.0.1-linux-amd64" \
"${install_root}/code-channel/bin/forgejo-16.0.1"
for artifact in MANIFEST.sha256 forgejo-16.0.1-linux-amd64.asc \
forgejo-release-key.asc forgejo-upstream-all.bundle guanghu-code-channel.bundle; do
install -o root -g forgejo -m 0640 "${offline_root}/${artifact}" \
"${install_root}/code-channel/offline/${artifact}"
done
cat >"${install_root}/code-channel/custom/conf/app.ini" <<'EOF'
APP_NAME = 光湖代码频道 · Hosted Construction Data Plane
RUN_USER = forgejo
RUN_MODE = prod
WORK_PATH = /guanghu/code-channel
[database]
DB_TYPE = sqlite3
PATH = /guanghu/code-channel/data/forgejo.db
[repository]
ROOT = /guanghu/code-channel/data/repositories
[server]
DOMAIN = 127.0.0.1
HTTP_ADDR = 127.0.0.1
HTTP_PORT = 3080
ROOT_URL = http://127.0.0.1:3080/
DISABLE_SSH = true
OFFLINE_MODE = true
[service]
DISABLE_REGISTRATION = true
REQUIRE_SIGNIN_VIEW = false
[security]
INSTALL_LOCK = true
[log]
MODE = console
LEVEL = Info
ROOT_PATH = /guanghu/code-channel/log
EOF
chown forgejo:forgejo "${install_root}/code-channel/custom/conf/app.ini"
chmod 0600 "${install_root}/code-channel/custom/conf/app.ini"
runuser -u forgejo -- env HOME=/guanghu/code-channel \
FORGEJO_WORK_DIR=/guanghu/code-channel \
"${install_root}/code-channel/bin/forgejo-16.0.1" migrate \
--config "${install_root}/code-channel/custom/conf/app.ini"
chown root:forgejo "${install_root}/code-channel/custom/conf/app.ini"
chmod 0640 "${install_root}/code-channel/custom/conf/app.ini"
bootstrap_repo="${install_root}/code-channel/data/bootstrap-repositories/guanghu-code-channel.git"
if [[ ! -d ${bootstrap_repo} ]]; then
runuser -u forgejo -- git clone --bare \
"${install_root}/code-channel/offline/guanghu-code-channel.bundle" \
"${bootstrap_repo}"
fi
[[ $(git --git-dir="${bootstrap_repo}" rev-parse refs/heads/guanghu/main) == \
b3d7e4ac3cbccc220703097a51fa4c16bf302579 ]]
install -m 0644 "${source_root}/packaging/systemd/guanghu-broadcast-tower.service" \
/etc/systemd/system/guanghu-broadcast-tower.service
install -m 0644 "${source_root}/packaging/systemd/guanghu-code-channel.service" \
/etc/systemd/system/guanghu-code-channel.service
cat >"${staging_root}/INSTALLATION.hldp" <<EOF
schema: guanghu.installation/v1
node_id: BS-SH-005
version: ${version}
source_sha: ${source_sha}
archive_sha256: ${archive_sha256}
installed_at: ${observed_at}
immutable: true
activation: /guanghu/current
recovery_entry: /guanghu/bin/ghctl wake /guanghu/current
EOF
mv "${staging_root}" "${version_root}"
ln -sfn "${version_root}" "${install_root}/current.next"
mv -Tf "${install_root}/current.next" "${install_root}/current"
ln -sfn "${install_root}/current/bin/ghctl" "${install_root}/bin/ghctl"
ln -sfn "${install_root}/current/bin/guanghu-broadcast-tower" \
"${install_root}/bin/guanghu-broadcast-tower"
activation_changed=true
systemctl daemon-reload
systemctl enable guanghu-broadcast-tower.service guanghu-code-channel.service
systemctl restart guanghu-broadcast-tower.service guanghu-code-channel.service
wait_for_http() {
local url=$1
local output=$2
local label=$3
for attempt in $(seq 1 30); do
if curl --fail --silent --show-error "${url}" >"${output}" 2>/dev/null; then
return 0
fi
if ! systemctl is-active --quiet "${label}"; then
journalctl -u "${label}" -n 80 --no-pager >&2
return 1
fi
sleep 1
done
echo "timed out waiting for ${label} at ${url}" >&2
journalctl -u "${label}" -n 80 --no-pager >&2
return 1
}
wait_for_http http://127.0.0.1:8077/healthz \
/tmp/guanghu-broadcast-health.json guanghu-broadcast-tower.service
wait_for_http http://127.0.0.1:3080/api/healthz \
/tmp/guanghu-code-channel-health.json guanghu-code-channel.service
grep -q '"domain_count":5' /tmp/guanghu-broadcast-health.json
grep -q '"linux_exited":false' /tmp/guanghu-broadcast-health.json
grep -q 'status: RUNNING_HOSTED' "${install_root}/var/broadcast-tower/LIVE.hldp"
chmod -R a-w "${version_root}"
trap - ERR
"${install_root}/bin/ghctl" wake "${install_root}/current"
systemctl --no-pager --full status \
guanghu-broadcast-tower.service guanghu-code-channel.service

View file

@ -0,0 +1,146 @@
#!/usr/bin/env bash
set -euo pipefail
[[ $# -eq 4 ]] || {
echo "usage: prepare-native-physical-once.sh <world-root> <candidate-image> <disk> <recovery-root>" >&2
exit 64
}
[[ ${EUID} -eq 0 ]] || {
echo "must run as root" >&2
exit 77
}
world_root=$(readlink -f "$1")
candidate=$(readlink -f "$2")
disk=$(readlink -f "$3")
recovery_root=$(readlink -m "$4")
source_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
render_root=$(mktemp -d)
trap 'rm -rf "${render_root}"' EXIT
[[ ${disk} == /dev/vda ]]
grep -q '^node_id: BS-SH-005$' "${world_root}/CURRENT.hldp"
/guanghu/bin/ghctl authorize "${world_root}" write_bootloader_and_system_partitions \
>/dev/null
[[ $(stat -c %s "${candidate}") -eq 14848 ]]
partition_dump=$(sfdisk -d "${disk}")
grep -q '^label: gpt$' <<<"${partition_dump}"
grep -q '^label-id: E549327B-8DC7-4797-944F-DC6185D1B550$' \
<<<"${partition_dump}"
grep -Eq '^/dev/vda1 : start= *2048, size= *2048,' <<<"${partition_dump}"
grep -Eq '^/dev/vda2 : start= *4096, size= *104853471,' <<<"${partition_dump}"
mkdir -p "${recovery_root}"
chmod 0700 "${recovery_root}"
printf '%s\n' "${partition_dump}" >"${recovery_root}/sfdisk-before.txt"
dd if="${disk}" of="${recovery_root}/first-2MiB.before.bin" \
bs=1M count=2 status=none
disk_sectors=$(blockdev --getsz "${disk}")
dd if="${disk}" of="${recovery_root}/last-2MiB.before.bin" \
bs=512 skip=$((disk_sectors - 4096)) count=4096 status=none
dd if="${disk}" of="${recovery_root}/lba34-62.before.bin" \
bs=512 skip=34 count=29 status=none
if ! cmp -s "${recovery_root}/lba34-62.before.bin" \
<(head -c 14848 /dev/zero); then
echo "candidate sectors 34-62 are not empty" >&2
exit 65
fi
dd if="${disk}" of="${recovery_root}/lba63.before.bin" \
bs=512 skip=63 count=1 status=none
if ! cmp -s "${recovery_root}/lba63.before.bin" \
<(head -c 512 /dev/zero); then
echo "native proof sector 63 is not empty" >&2
exit 65
fi
"${source_root}/scripts/render-native-recovery-beacon.sh" "${render_root}"
dd if="${disk}" of="${recovery_root}/lba68-69.before.bin" \
bs=512 skip=68 count=2 status=none
if ! cmp -s "${recovery_root}/lba68-69.before.bin" \
<(head -c 1024 /dev/zero) &&
! cmp -s "${recovery_root}/lba68-69.before.bin" \
"${render_root}/guanghu-recovery-clear.env"; then
echo "native recovery beacon sectors 68-69 contain unknown data" >&2
exit 65
fi
dd if="${disk}" of="${recovery_root}/lba70-71.before.bin" \
bs=512 skip=70 count=2 status=none
if ! cmp -s "${recovery_root}/lba70-71.before.bin" \
<(head -c 1024 /dev/zero); then
echo "native gestational index sectors 70-71 are not empty before first installation" >&2
exit 65
fi
cp /boot/grub/grub.cfg "${recovery_root}/grub.cfg.before"
cp /boot/grub/grubenv "${recovery_root}/grubenv.before"
cp /etc/default/grub "${recovery_root}/default-grub.before"
cp /etc/grub.d/40_custom "${recovery_root}/40_custom.before"
tar -czf "${recovery_root}/etc-grub.d.before.tar.gz" -C /etc grub.d
cp "${candidate}" "${recovery_root}/guanghu-os-physical-candidate.img"
install -m 0755 /dev/stdin /etc/grub.d/41_guanghu_native_once <<'EOF'
#!/bin/sh
exec tail -n +3 $0
menuentry 'Guanghu OS native one-time proof' --id 'guanghu-native-once' {
insmod chain
chainloader (hd0)34+1
}
EOF
dd if="${render_root}/guanghu-recovery-clear.env" of="${disk}" \
bs=512 seek=68 count=2 conv=notrunc,fsync status=none
install -m 0755 "${render_root}/08_guanghu_native_recovery" \
/etc/grub.d/08_guanghu_native_recovery
update-grub >/dev/null
grub-script-check /boot/grub/grub.cfg
grep -q "load_env --file '(hd0)68+2' guanghu_recovery" /boot/grub/grub.cfg
grep -q "menuentry 'Guanghu OS native one-time proof'.*'guanghu-native-once'" \
/boot/grub/grub.cfg
dd if="${candidate}" of="${disk}" bs=512 seek=34 count=29 \
conv=notrunc,fsync status=none
candidate_sha=$(sha256sum "${candidate}" | awk '{print $1}')
readback_sha=$(dd if="${disk}" bs=512 skip=34 count=29 status=none |
sha256sum | awk '{print $1}')
[[ ${candidate_sha} == "${readback_sha}" ]]
sha256sum "${recovery_root}"/* >"${recovery_root}/SHA256SUMS"
chmod 0400 "${recovery_root}"/*
observed_at=$(date --iso-8601=seconds)
cat >"${recovery_root}/PREPARE-RECEIPT.hldp" <<EOF
schema: guanghu.native-physical-prepare/v1
receipt_id: GH-OS-LAB-001-NATIVE-PHYSICAL-PREPARE-001
status: VERIFIED
observed_at: ${observed_at}
node_id: BS-SH-005
instance_id: lhins-14w5y3ce
disk:
path: /dev/vda
candidate_start_lba: 34
candidate_sector_count: 29
proof_lba: 63
recovery_beacon_lba_start: 68
recovery_beacon_sector_count: 2
gestational_index_lba_start: 70
gestational_index_sector_count: 2
existing_partition_start_lba: 2048
candidate:
sha256: ${candidate_sha}
readback_sha256: ${readback_sha}
grub:
entry_id: guanghu-native-once
recovery_protocol: GHNRP
recovery_raw_blocklist: (hd0)68+2
armed: false
recovery:
directory: ${recovery_root}
first_2mib_backed_up: true
last_2mib_backed_up: true
partition_table_backed_up: true
grub_configuration_backed_up: true
proof_sector_backed_up: true
recovery_beacon_backed_up: true
gestational_index_backed_up: true
next_action: ARM_ONE_TIME_ENTRY_AND_REBOOT
EOF
chmod 0400 "${recovery_root}/PREPARE-RECEIPT.hldp"
cat "${recovery_root}/PREPARE-RECEIPT.hldp"

View file

@ -0,0 +1,196 @@
#!/usr/bin/env python3
import argparse
import socket
import struct
import time
GUEST_MAC = bytes.fromhex("525400267198")
PEER_MAC = bytes.fromhex("525400123401")
GUEST_IP = socket.inet_aton("10.0.0.7")
PEER_IP = socket.inet_aton("10.0.0.1")
LOGIN_CLIENT_IP = socket.inet_aton("10.0.0.2")
LOGIN_MAGIC = b"HLDP-GHOS-LOGIN!"
COMMIT_MAGIC = b"HLDP-CODE-COMMIT"
BRANCH_MAGIC = b"HLDP-BRANCH-MOVE"
RECOVERY_MAGIC = b"HLDP-RECOVER-OS!"
def checksum(payload: bytes) -> int:
if len(payload) % 2:
payload += b"\0"
words = struct.unpack(f"!{len(payload) // 2}H", payload)
total = sum(words)
while total >> 16:
total = (total & 0xFFFF) + (total >> 16)
return (~total) & 0xFFFF
def arp_reply(request: bytes) -> bytes:
assert request[12:14] == b"\x08\x06"
assert request[20:22] == b"\x00\x01"
sender_mac = request[22:28]
sender_ip = request[28:32]
target_ip = request[38:42]
assert sender_mac == GUEST_MAC
assert sender_ip == GUEST_IP
assert target_ip == PEER_IP
return (
sender_mac
+ PEER_MAC
+ b"\x08\x06"
+ b"\x00\x01\x08\x00\x06\x04\x00\x02"
+ PEER_MAC
+ PEER_IP
+ sender_mac
+ sender_ip
)
def icmp_request(sequence: int, magic: bytes) -> bytes:
payload = b"\0" * 8 + magic + magic
icmp = struct.pack("!BBHHH", 8, 0, 0, 0x4748, sequence) + payload
icmp = icmp[:2] + struct.pack("!H", checksum(icmp)) + icmp[4:]
total_length = 20 + len(icmp)
ip = struct.pack(
"!BBHHHBBH4s4s",
0x45,
0,
total_length,
0x484C,
0,
64,
1,
0,
LOGIN_CLIENT_IP,
GUEST_IP,
)
ip = ip[:10] + struct.pack("!H", checksum(ip)) + ip[12:]
return GUEST_MAC + PEER_MAC + b"\x08\x00" + ip + icmp
def validate_reply(frame: bytes, magic: bytes) -> None:
assert frame[0:6] == PEER_MAC
assert frame[6:12] == GUEST_MAC
assert frame[12:14] == b"\x08\x00"
assert frame[26:30] == GUEST_IP
assert frame[30:34] == LOGIN_CLIENT_IP
assert frame[34] == 0
assert frame[50:66] == magic
assert checksum(frame[34:]) == 0
def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument("--listen-port", type=int, required=True)
parser.add_argument("--qemu-port", type=int, required=True)
parser.add_argument("--receipt", required=True)
parser.add_argument("--resident", action="store_true")
parser.add_argument("--login-only", action="store_true")
args = parser.parse_args()
peer = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
peer.bind(("127.0.0.1", args.listen_port))
peer.settimeout(0.2)
qemu = ("127.0.0.1", args.qemu_port)
deadline = time.monotonic() + 15
arp_verified = False
login_sent = False
reply_count = 0
login_reply_count = 0
resident_login_reply_count = 0
recovery_reply_verified = False
command_phase = "login"
def write_receipt(
*,
commit_verified: bool,
branch_verified: bool,
) -> None:
with open(args.receipt, "w", encoding="utf-8") as output:
output.write(
"arp_gateway_reply: VERIFIED\n"
f"icmp_login_request_sent: {str(login_sent).lower()}\n"
"icmp_login_reply_verified: true\n"
f"icmp_login_reply_count: {login_reply_count}\n"
"code_commit_reply_verified: "
f"{str(commit_verified).lower()}\n"
"branch_move_reply_verified: "
f"{str(branch_verified).lower()}\n"
f"resident_login_reply_count: {resident_login_reply_count}\n"
"recovery_reply_verified: "
f"{str(recovery_reply_verified).lower()}\n"
"login_magic: HLDP-GHOS-LOGIN!\n"
)
def phase_magic() -> bytes:
return {
"login": LOGIN_MAGIC,
"commit": COMMIT_MAGIC,
"branch": BRANCH_MAGIC,
"resident_login": LOGIN_MAGIC,
"recovery": RECOVERY_MAGIC,
}[command_phase]
while time.monotonic() < deadline:
try:
frame = peer.recv(4096)
except TimeoutError:
if arp_verified:
peer.sendto(
icmp_request(reply_count + 1, phase_magic()),
qemu,
)
login_sent = True
continue
if frame[12:14] == b"\x08\x06":
peer.sendto(arp_reply(frame), qemu)
arp_verified = True
continue
if frame[12:14] == b"\x08\x00":
magic = phase_magic()
validate_reply(frame, magic)
reply_count += 1
if command_phase == "login":
login_reply_count += 1
if command_phase == "login" and reply_count < 3:
peer.sendto(icmp_request(reply_count + 1, LOGIN_MAGIC), qemu)
continue
if command_phase == "login":
if args.login_only:
write_receipt(
commit_verified=False,
branch_verified=False,
)
return
command_phase = "commit"
peer.sendto(icmp_request(4, COMMIT_MAGIC), qemu)
continue
if command_phase == "commit":
command_phase = "branch"
peer.sendto(icmp_request(5, BRANCH_MAGIC), qemu)
continue
if command_phase == "branch" and args.resident:
command_phase = "resident_login"
peer.sendto(icmp_request(6, LOGIN_MAGIC), qemu)
continue
if command_phase == "resident_login":
resident_login_reply_count += 1
if resident_login_reply_count < 10:
peer.sendto(
icmp_request(6 + resident_login_reply_count, LOGIN_MAGIC),
qemu,
)
continue
command_phase = "recovery"
peer.sendto(icmp_request(16, RECOVERY_MAGIC), qemu)
continue
if command_phase == "recovery":
recovery_reply_verified = True
write_receipt(commit_verified=True, branch_verified=True)
return
raise SystemExit("timed out waiting for native ICMP login reply")
if __name__ == "__main__":
main()

View file

@ -0,0 +1,51 @@
#!/usr/bin/env bash
set -euo pipefail
[[ $# -eq 1 ]] || {
echo "usage: render-native-recovery-beacon.sh <output-directory>" >&2
exit 64
}
mkdir -p "$1"
output_root=$(cd "$1" && pwd)
python3 - "${output_root}" <<'PY'
import pathlib
import sys
output = pathlib.Path(sys.argv[1])
header = (
b"# GRUB Environment Block\n"
b"# WARNING: Do not edit this file by tools other than grub-editenv!!!\n"
)
def write_environment(name: str, variables: bytes = b"") -> None:
prefix = header + variables
if len(prefix) > 1024:
raise SystemExit(f"{name} exceeds the GRUB environment-block size")
(output / name).write_bytes(prefix + b"#" * (1024 - len(prefix)))
write_environment(
"guanghu-recovery-active.env",
b"guanghu_recovery=ubuntu\n",
)
write_environment("guanghu-recovery-clear.env")
PY
install -m 0755 /dev/stdin "${output_root}/08_guanghu_native_recovery" <<'EOF'
#!/bin/sh
exec tail -n +3 $0
insmod loadenv
set guanghu_recovery=
if load_env --file '(hd0)68+2' guanghu_recovery; then
if [ "${guanghu_recovery}" = "ubuntu" ]; then
set default="gnulinux-simple-9842d3d6-a839-4127-bda7-f19137effe71"
fi
fi
EOF
sha256sum \
"${output_root}/guanghu-recovery-active.env" \
"${output_root}/guanghu-recovery-clear.env" \
"${output_root}/08_guanghu_native_recovery" \
>"${output_root}/SHA256SUMS"

View file

@ -0,0 +1,98 @@
#!/usr/bin/env bash
set -euo pipefail
[[ $# -eq 5 ]] || {
echo "usage: replace-native-physical-once.sh <world-root> <candidate-image> <disk> <recovery-root> <expected-installed-sha256>" >&2
exit 64
}
[[ ${EUID} -eq 0 ]] || {
echo "must run as root" >&2
exit 77
}
world_root=$(readlink -f "$1")
candidate=$(readlink -f "$2")
disk=$(readlink -f "$3")
recovery_root=$(readlink -m "$4")
expected_installed_sha=$5
[[ ${disk} == /dev/vda ]]
[[ ${expected_installed_sha} =~ ^[0-9a-f]{64}$ ]]
grep -q '^node_id: BS-SH-005$' "${world_root}/CURRENT.hldp"
/guanghu/bin/ghctl authorize "${world_root}" \
write_bootloader_and_system_partitions >/dev/null
[[ $(stat -c %s "${candidate}") -eq 14848 ]]
[[ ! -e ${recovery_root} ]]
partition_dump=$(sfdisk -d "${disk}")
grep -q '^label: gpt$' <<<"${partition_dump}"
grep -q '^label-id: E549327B-8DC7-4797-944F-DC6185D1B550$' \
<<<"${partition_dump}"
grep -Eq '^/dev/vda1 : start= *2048, size= *2048,' <<<"${partition_dump}"
grep -Eq '^/dev/vda2 : start= *4096, size= *104853471,' <<<"${partition_dump}"
legacy_installed_before=$(mktemp)
kernel_region_before=$(mktemp)
proof_before=$(mktemp)
trap 'rm -f "${legacy_installed_before}" "${kernel_region_before}" "${proof_before}"' EXIT
dd if="${disk}" of="${legacy_installed_before}" bs=512 skip=34 count=16 status=none
installed_sha=$(sha256sum "${legacy_installed_before}" | awk '{print $1}')
[[ ${installed_sha} == "${expected_installed_sha}" ]]
dd if="${disk}" of="${kernel_region_before}" bs=512 skip=34 count=29 status=none
dd if="${disk}" of="${proof_before}" bs=512 skip=63 count=1 status=none
cmp -s "${proof_before}" <(head -c 512 /dev/zero)
mkdir -m 0700 "${recovery_root}"
printf '%s\n' "${partition_dump}" >"${recovery_root}/sfdisk-before.txt"
cp "${kernel_region_before}" "${recovery_root}/lba34-62.before.bin"
cp "${proof_before}" "${recovery_root}/lba63.before.bin"
dd if="${disk}" of="${recovery_root}/first-2MiB.before.bin" \
bs=1M count=2 status=none
disk_sectors=$(blockdev --getsz "${disk}")
dd if="${disk}" of="${recovery_root}/last-2MiB.before.bin" \
bs=512 skip=$((disk_sectors - 4096)) count=4096 status=none
cp /boot/grub/grub.cfg "${recovery_root}/grub.cfg.before"
cp /boot/grub/grubenv "${recovery_root}/grubenv.before"
cp /etc/default/grub "${recovery_root}/default-grub.before"
cp /etc/grub.d/40_custom "${recovery_root}/40_custom.before"
cp "${candidate}" "${recovery_root}/guanghu-os-physical-candidate.img"
dd if="${candidate}" of="${disk}" bs=512 seek=34 count=29 \
conv=notrunc,fsync status=none
candidate_sha=$(sha256sum "${candidate}" | awk '{print $1}')
readback_sha=$(dd if="${disk}" bs=512 skip=34 count=29 status=none |
sha256sum | awk '{print $1}')
[[ ${candidate_sha} == "${readback_sha}" ]]
dd if="${disk}" of="${proof_before}" bs=512 skip=63 count=1 status=none
cmp -s "${proof_before}" <(head -c 512 /dev/zero)
sha256sum "${recovery_root}"/* >"${recovery_root}/SHA256SUMS"
chmod 0400 "${recovery_root}"/*
observed_at=$(date --iso-8601=seconds)
cat >"${recovery_root}/REPLACE-RECEIPT.hldp" <<EOF
schema: guanghu.native-physical-replacement/v1
receipt_id: GH-OS-LAB-001-NATIVE-PHYSICAL-REPLACEMENT
status: VERIFIED_NOT_ARMED
observed_at: ${observed_at}
node_id: BS-SH-005
instance_id: lhins-14w5y3ce
disk:
path: /dev/vda
candidate_start_lba: 34
candidate_sector_count: 29
proof_lba: 63
candidate:
replaced_sha256: ${installed_sha}
new_sha256: ${candidate_sha}
readback_sha256: ${readback_sha}
proof_before_and_after: EMPTY
recovery:
directory: ${recovery_root}
disk_edges_and_grub_backed_up: true
grub:
entry_id: guanghu-native-once
armed: false
next_action: ARM_ONE_TIME_ENTRY_AND_REBOOT
EOF
chmod 0400 "${recovery_root}/REPLACE-RECEIPT.hldp"
cat "${recovery_root}/REPLACE-RECEIPT.hldp"

View file

@ -0,0 +1,140 @@
#!/usr/bin/env bash
set -euo pipefail
[[ $# -eq 4 ]] || {
echo "usage: replace-native-recovery-beacon.sh <world-root> <candidate-image> <disk> <recovery-root>" >&2
exit 64
}
[[ ${EUID} -eq 0 ]] || {
echo "must run as root" >&2
exit 77
}
world_root=$(readlink -f "$1")
candidate=$(readlink -f "$2")
disk=$(readlink -f "$3")
recovery_root=$(readlink -m "$4")
source_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
render_root=$(mktemp -d)
trap 'rm -rf "${render_root}"' EXIT
[[ ${disk} == /dev/vda ]]
[[ $(stat -c %s "${candidate}") -eq 14848 ]]
grep -q '^node_id: BS-SH-005$' "${world_root}/CURRENT.hldp"
/guanghu/bin/ghctl authorize "${world_root}" write_bootloader_and_system_partitions \
>/dev/null
partition_dump=$(sfdisk -d "${disk}")
grep -q '^label: gpt$' <<<"${partition_dump}"
grep -Eq '^/dev/vda1 : start= *2048, size= *2048,' <<<"${partition_dump}"
grep -Eq '^/dev/vda2 : start= *4096, size= *104853471,' <<<"${partition_dump}"
grep -q '^GRUB_DEFAULT=guanghu-native-once$' /etc/default/grub
grep -q "menuentry 'Ubuntu'.*'gnulinux-simple-9842d3d6-a839-4127-bda7-f19137effe71'" \
/boot/grub/grub.cfg
"${source_root}/scripts/render-native-recovery-beacon.sh" "${render_root}"
mkdir -p "${recovery_root}"
chmod 0700 "${recovery_root}"
printf '%s\n' "${partition_dump}" >"${recovery_root}/sfdisk-before.txt"
dd if="${disk}" of="${recovery_root}/first-2MiB.before.bin" \
bs=1M count=2 status=none
dd if="${disk}" of="${recovery_root}/lba34-71.before.bin" \
bs=512 skip=34 count=38 status=none
dd if="${disk}" of="${recovery_root}/lba70-71.before.bin" \
bs=512 skip=70 count=2 status=none
if ! cmp -s "${recovery_root}/lba70-71.before.bin" \
<(head -c 1024 /dev/zero); then
if ! grep -aFq 'GHOS_GHCIP_INDEX_V1' \
"${recovery_root}/lba70-71.before.bin" ||
! grep -aFq 'GHOS_GHCIP_ROOT_V1' \
"${recovery_root}/lba70-71.before.bin"; then
echo "native gestational index sectors 70-71 contain unknown data" >&2
exit 65
fi
fi
cp /boot/grub/grub.cfg "${recovery_root}/grub.cfg.before"
cp /boot/grub/grubenv "${recovery_root}/grubenv.before"
cp /etc/default/grub "${recovery_root}/default-grub.before"
tar -czf "${recovery_root}/etc-grub.d.before.tar.gz" -C /etc grub.d
dd if="${render_root}/guanghu-recovery-clear.env" of="${disk}" \
bs=512 seek=68 count=2 conv=notrunc,fsync status=none
dd if="${candidate}" of="${disk}" \
bs=512 seek=34 count=29 conv=notrunc,fsync status=none
install -m 0755 "${render_root}/08_guanghu_native_recovery" \
/etc/grub.d/08_guanghu_native_recovery
install -D -m 0644 "${render_root}/guanghu-recovery-clear.env" \
/usr/lib/guanghu-os/guanghu-recovery-clear.env
install -D -m 0755 "${source_root}/scripts/clear-native-recovery-beacon.sh" \
/usr/local/sbin/guanghu-clear-native-recovery-beacon
install -m 0644 /dev/stdin \
/etc/systemd/system/guanghu-native-recovery-beacon-clear.service <<'EOF'
[Unit]
Description=Verify and clear the Guanghu native recovery beacon
After=local-fs.target
Before=multi-user.target
[Service]
Type=oneshot
ExecStart=/usr/local/sbin/guanghu-clear-native-recovery-beacon /dev/vda /usr/lib/guanghu-os/guanghu-recovery-clear.env
[Install]
WantedBy=multi-user.target
EOF
systemctl enable guanghu-native-recovery-beacon-clear.service >/dev/null
update-grub >/dev/null
grub-script-check /boot/grub/grub.cfg
grep -q "load_env --file '(hd0)68+2' guanghu_recovery" /boot/grub/grub.cfg
grep -q 'set default="guanghu-native-once"' /boot/grub/grub.cfg
grep -q "menuentry 'Guanghu OS native one-time proof'.*'guanghu-native-once'" \
/boot/grub/grub.cfg
candidate_sha=$(sha256sum "${candidate}" | awk '{print $1}')
candidate_readback_sha=$(dd if="${disk}" bs=512 skip=34 count=29 status=none |
sha256sum | awk '{print $1}')
[[ ${candidate_sha} == "${candidate_readback_sha}" ]]
beacon_sha=$(sha256sum \
"${render_root}/guanghu-recovery-clear.env" | awk '{print $1}')
beacon_readback_sha=$(dd if="${disk}" bs=512 skip=68 count=2 status=none |
sha256sum | awk '{print $1}')
[[ ${beacon_sha} == "${beacon_readback_sha}" ]]
observed_at=$(date --iso-8601=seconds)
cat >"${recovery_root}/NATIVE-RECOVERY-BEACON-INSTALL-RECEIPT.hldp" <<EOF
schema: guanghu.native-recovery-beacon-install/v1
receipt_id: GH-OS-LAB-001-NATIVE-RECOVERY-BEACON-INSTALL-001
status: CONFIGURED_NOT_REBOOTED
observed_at: ${observed_at}
node_id: BS-SH-005
instance_id: lhins-14w5y3ce
candidate:
lba_start: 34
sector_count: 29
sha256: ${candidate_sha}
readback_sha256: ${candidate_readback_sha}
recovery_beacon:
protocol: GHNRP
lba_start: 68
sector_count: 2
clear_sha256: ${beacon_sha}
readback_sha256: ${beacon_readback_sha}
grub:
raw_blocklist: (hd0)68+2
whitelisted_variable: guanghu_recovery
native_default_preserved: true
ubuntu_recovery_entry_preserved: true
hosted_fallback:
clear_service_enabled: true
rollback:
recovery_root: ${recovery_root}
first_2mib_backed_up: true
lba34_71_backed_up: true
gestational_index_preserved_for_native_verification: true
grub_configuration_backed_up: true
next_action: REBOOT_NATIVE_DEFAULT_THEN_PROVE_GHNRP_RECOVERS_UBUNTU
EOF
sha256sum "${recovery_root}"/* >"${recovery_root}/SHA256SUMS"
chmod 0400 "${recovery_root}"/*
sync
cat "${recovery_root}/NATIVE-RECOVERY-BEACON-INSTALL-RECEIPT.hldp"

View file

@ -0,0 +1,95 @@
#!/usr/bin/env bash
set -euo pipefail
[[ $# -eq 3 ]] || {
echo "usage: set-native-default.sh <world-root> <recovery-root> <expected-candidate-sha256>" >&2
exit 64
}
[[ ${EUID} -eq 0 ]] || {
echo "must run as root" >&2
exit 77
}
world_root=$(readlink -f "$1")
recovery_root=$(readlink -f "$2")
expected_candidate_sha=$3
[[ ${expected_candidate_sha} =~ ^[0-9a-f]{64}$ ]]
/guanghu/bin/ghctl authorize "${world_root}" overwrite_system_disk_and_exit_linux \
>/dev/null
grep -q '^node_id: BS-SH-005$' "${world_root}/CURRENT.hldp"
grep -q "menuentry 'Guanghu OS native one-time proof'.*'guanghu-native-once'" \
/boot/grub/grub.cfg
grep -q "menuentry 'Ubuntu'.*'gnulinux-simple-9842d3d6-a839-4127-bda7-f19137effe71'" \
/boot/grub/grub.cfg
grep -q "load_env --file '(hd0)68+2' guanghu_recovery" /boot/grub/grub.cfg
installed_sha=$(dd if=/dev/vda bs=512 skip=34 count=29 status=none |
sha256sum | awk '{print $1}')
[[ ${installed_sha} == "${expected_candidate_sha}" ]]
cp /etc/default/grub "${recovery_root}/default-grub.before-native-default"
cp /boot/grub/grub.cfg "${recovery_root}/grub.cfg.before-native-default"
cp /boot/grub/grubenv "${recovery_root}/grubenv.before-native-default"
new_default=$(mktemp)
trap 'rm -f "${new_default}"' EXIT
awk '
BEGIN { changed = 0 }
/^GRUB_DEFAULT=/ {
print "GRUB_DEFAULT=guanghu-native-once"
changed = 1
next
}
{ print }
END {
if (!changed) {
print "GRUB_DEFAULT=guanghu-native-once"
}
}
' /etc/default/grub >"${new_default}"
install -m 0644 "${new_default}" /etc/default/grub
update-grub >/dev/null
grep -q '^GRUB_DEFAULT=guanghu-native-once$' /etc/default/grub
grep -q 'set default="guanghu-native-once"' /boot/grub/grub.cfg
grep -q "menuentry 'Guanghu OS native one-time proof'.*'guanghu-native-once'" \
/boot/grub/grub.cfg
grep -q "menuentry 'Ubuntu'.*'gnulinux-simple-9842d3d6-a839-4127-bda7-f19137effe71'" \
/boot/grub/grub.cfg
grep -q "load_env --file '(hd0)68+2' guanghu_recovery" /boot/grub/grub.cfg
grub-editenv /boot/grub/grubenv unset initrdfail prev_entry next_entry
grub_state=$(grub-editenv /boot/grub/grubenv list)
if grep -Eq '^(initrdfail|prev_entry|next_entry)=.+' <<<"${grub_state}"; then
echo "stale GRUB one-time state remains" >&2
exit 65
fi
observed_at=$(date --iso-8601=seconds)
cat >"${recovery_root}/NATIVE-DEFAULT-RECEIPT.hldp" <<EOF
schema: guanghu.native-default-receipt/v1
receipt_id: GH-OS-LAB-001-NATIVE-DEFAULT-001
status: CONFIGURED_NOT_REBOOTED
observed_at: ${observed_at}
node_id: BS-SH-005
instance_id: lhins-14w5y3ce
candidate:
lba_start: 34
sector_count: 29
sha256: ${installed_sha}
grub:
default_entry: guanghu-native-once
ubuntu_recovery_entry: gnulinux-simple-9842d3d6-a839-4127-bda7-f19137effe71
native_recovery_protocol: GHNRP
native_recovery_raw_blocklist: (hd0)68+2
stale_one_time_state: CLEARED
rollback:
recovery_root: ${recovery_root}
default_grub_backed_up: true
generated_grub_backed_up: true
grubenv_backed_up: true
next_action: REBOOT_NATIVE_DEFAULT_THEN_PROVE_HLDP_RECOVER_OS_RETURNS_TO_UBUNTU
EOF
chmod 0400 "${recovery_root}/NATIVE-DEFAULT-RECEIPT.hldp"
sync
cat "${recovery_root}/NATIVE-DEFAULT-RECEIPT.hldp"

View file

@ -0,0 +1,32 @@
#!/usr/bin/env bash
set -euo pipefail
source_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
protocol=${source_root}/world-seed/world/services/code-channel/QUALITY-GATE.hldp
runner=${source_root}/world-seed/scripts/run-guanghu-native-quality-gate.sh
grep -Fxq 'schema: guanghu.native-code-quality-gate/v1' "${protocol}"
grep -Fxq 'id: GLS-0844' "${protocol}"
grep -Fxq 'acronym: GHNQG' "${protocol}"
grep -Fxq ' allowed_scores:' "${protocol}"
grep -Fxq ' - 0' "${protocol}"
grep -Fxq ' - 100' "${protocol}"
grep -Fxq ' pass_score: 100' "${protocol}"
grep -Fxq ' partial_acceptance: false' "${protocol}"
grep -Fxq ' aggregate_rule: ALL_REQUIRED_GATES_100_OR_TOTAL_0' "${protocol}"
grep -Fxq ' external_observers_are_blocking: false' "${protocol}"
grep -Fxq ' required_score: 100' "${protocol}"
grep -Fxq ' native_target: GOSK_CODE_CHANNEL_QUALITY_EXECUTOR' "${protocol}"
grep -Fq -- '--fail-under-lines 100' "${runner}"
grep -Fq -- '--fail-under-functions 100' "${runner}"
grep -Fq -- '--test broadcast_library' "${runner}"
grep -Fq 'GHNQG_PASS_100' "${runner}"
grep -Fq 'GHNQG_FAIL_0' "${runner}"
grep -Fq 'total_score: ${total_score}' "${runner}"
if grep -Eiq 'codescene|codacy' "${runner}"; then
echo "external analysis product leaked into the Guanghu native quality executor" >&2
exit 1
fi
echo "GUANGHU_NATIVE_QUALITY_GATE_CONTRACT_OK"

View file

@ -0,0 +1,69 @@
#!/usr/bin/env bash
set -euo pipefail
[[ $# -eq 2 ]] || {
echo "usage: test-native-bios-image.sh <image> <receipt-output>" >&2
exit 64
}
image=$(readlink -f "$1")
receipt=$(readlink -m "$2")
serial_log=$(mktemp)
set +e
timeout 20 qemu-system-x86_64 \
-machine pc,accel=tcg \
-m 64M \
-drive "format=raw,file=${image}" \
-display none \
-monitor none \
-serial "file:${serial_log}" \
-device isa-debug-exit,iobase=0xf4,iosize=0x04 \
-no-reboot
qemu_status=$?
set -e
[[ ${qemu_status} -eq 33 ]]
for evidence in \
GHOS_BOOT_STAGE0=BIOS \
GHOS_NATIVE_KERNEL_ENTERED=true \
GHOS_CPU_MODE=LONG64 \
GHOS_WORLD_ID=GLW-ROOT-0001 \
GHOS_DOMAIN_COUNT=5 \
GHOS_DOMAIN_5=DOMAIN-FIFTH \
GHOS_BROADCAST_TOWER=BT-GH-ROOT-0001 \
GHOS_AUTHORITY_LANGUAGE=HLDP \
GHOS_GESTATIONAL_ENVIRONMENT=UNDER_CONSTRUCTION \
GHOS_PERSONA_BIRTH=NOT_BORN \
GHOS_LINUX_PRESENT=false \
GHOS_NATIVE_ACCEPTANCE=QEMU_ONLY; do
grep -q "^${evidence}" "${serial_log}"
done
observed_at=$(date --iso-8601=seconds)
image_sha=$(sha256sum "${image}" | awk '{print $1}')
cat >"${receipt}" <<EOF
schema: guanghu.native-boot-receipt/v1
receipt_id: GH-OS-LAB-001-NATIVE-QEMU-001
status: VERIFIED
observed_at: ${observed_at}
image:
architecture: x86_64
firmware: BIOS
size_bytes: 14848
sha256: ${image_sha}
runtime:
emulator: qemu-system-x86_64
acceleration: tcg
cpu_mode: LONG64
linux_kernel_present: false
world:
authority_language: HLDP
world_id: GLW-ROOT-0001
domain_count: 5
acceptance:
qemu_native_boot: true
physical_server_boot: false
linux_replaced_on_bs_sh_005: false
next_action: BUILD_RECOVERABLE_PHYSICAL_DISK_LAYOUT
EOF
cat "${serial_log}" >>"${receipt}.serial.log"

View file

@ -0,0 +1,257 @@
#!/usr/bin/env bash
set -euo pipefail
[[ $# -eq 2 ]] || {
echo "usage: test-native-physical-candidate.sh <candidate-image> <receipt-output>" >&2
exit 64
}
candidate=$(readlink -f "$1")
receipt=$(readlink -m "$2")
source_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
native_root=${source_root}/native/x86_64-bios
test_root=$(mktemp -d)
serial_log=${test_root}/serial.log
failure_serial_log=${test_root}/failure-serial.log
disk_image=${test_root}/physical-layout.img
failure_disk_image=${test_root}/physical-layout-failure.img
peer_receipt=${test_root}/native-net-peer.hldp
peer_log=${test_root}/native-net-peer.log
peer_pid=
cleanup() {
if [[ -n ${peer_pid} ]]; then
kill "${peer_pid}" 2>/dev/null || true
fi
rm -rf "${test_root}"
}
trap cleanup EXIT
truncate -s 2M "${disk_image}"
nasm -f bin "${native_root}/physical-test-mbr.asm" \
-o "${test_root}/physical-test-mbr.bin"
dd if="${test_root}/physical-test-mbr.bin" of="${disk_image}" \
bs=512 seek=0 conv=notrunc status=none
dd if="${candidate}" of="${disk_image}" \
bs=512 seek=34 conv=notrunc status=none
peer_port=$((22000 + BASHPID % 10000))
qemu_port=$((peer_port + 1))
python3 "${source_root}/scripts/qemu-native-net-peer.py" \
--listen-port "${peer_port}" \
--qemu-port "${qemu_port}" \
--receipt "${peer_receipt}" >"${peer_log}" 2>&1 &
peer_pid=$!
set +e
timeout 20 qemu-system-x86_64 \
-machine pc,accel=tcg \
-m 64M \
-drive "if=none,id=ghboot,format=raw,file=${disk_image}" \
-device virtio-blk-pci,drive=ghboot,disable-modern=on,bootindex=0 \
-netdev "dgram,id=ghnet,local.type=inet,local.host=127.0.0.1,local.port=${qemu_port},remote.type=inet,remote.host=127.0.0.1,remote.port=${peer_port}" \
-device virtio-net-pci,netdev=ghnet,disable-modern=on,mac=52:54:00:26:71:98 \
-display none \
-monitor none \
-serial "file:${serial_log}" \
-device isa-debug-exit,iobase=0xf4,iosize=0x04
qemu_status=$?
set -e
[[ ${qemu_status} -eq 33 ]]
wait "${peer_pid}"
peer_pid=
grep -q '^arp_gateway_reply: VERIFIED$' "${peer_receipt}"
grep -q '^icmp_login_reply_verified: true$' "${peer_receipt}"
grep -q '^icmp_login_reply_count: 3$' "${peer_receipt}"
grep -q '^code_commit_reply_verified: true$' "${peer_receipt}"
grep -q '^branch_move_reply_verified: true$' "${peer_receipt}"
for evidence in \
GHOS_BOOT_STAGE0=BIOS \
GHOS_NATIVE_KERNEL_ENTERED=true \
GHOS_CPU_MODE=LONG64 \
GHOS_WORLD_ID=GLW-ROOT-0001 \
GHOS_DOMAIN_COUNT=5 \
GHOS_DOMAIN_5=DOMAIN-FIFTH \
GHOS_BROADCAST_TOWER=BT-GH-ROOT-0001 \
GHOS_AUTHORITY_LANGUAGE=HLDP \
GHOS_LINUX_PRESENT=false \
GHOS_NATIVE_ACCEPTANCE=PHYSICAL_ONE_TIME_CANDIDATE \
GHOS_GHAL_VIRTIO_NET=DISCOVERED \
GHOS_GHAL_VIRTIO_BLOCK=DISCOVERED \
GHOS_GHAL_VIRTIO_NET_QUEUE=DRIVER_OK \
GHOS_GHAL_VIRTIO_BLOCK_QUEUE=DRIVER_OK \
GHOS_GHAL_ARP_GATEWAY=VERIFIED \
GHOS_GHAL_ICMP_LOGIN=VERIFIED \
GHOS_HLDP_WORLD_STORE=WRITE_READ_VERIFIED \
GHOS_GHCIP_INDEX=INITIALIZED_WRITE_READ_VERIFIED \
GHOS_CODE_CHANNEL_STORE=WRITE_READ_VERIFIED \
GHOS_DISK_PROOF_WRITTEN=LBA63 \
GHOS_DISK_PROOF_OBSERVED_AFTER_RESET=LBA63; do
grep -q "^${evidence}" "${serial_log}"
done
python3 - "${disk_image}" <<'PY'
import pathlib
import sys
disk = pathlib.Path(sys.argv[1]).read_bytes()
proof = disk[63 * 512:64 * 512]
assert proof[0] == 0xA7
assert proof[1:].startswith(b"GHOS_NATIVE_LONG64_DISK_PROOF\x00")
assert proof[32:36] == bytes([1, 1, 1, 1])
assert proof[36:42] == bytes.fromhex("525400267198")
assert proof[42] == 0x7F
assert proof[43] == 0x00
assert int.from_bytes(proof[44:46], "little") > 0
assert int.from_bytes(proof[46:48], "little") > 0
assert int.from_bytes(proof[48:50], "little") > 0
assert proof[54:60] != bytes(6)
assert proof[60:62] == bytes([1, 1])
assert proof[62:64] == bytes([1, 1])
assert proof[64:68] == bytes([10, 0, 0, 2])
assert proof[72:88] == b"HLDP-GHOS-LOGIN!"
assert proof[88:90] == bytes([1, 1])
assert proof[90:93] == bytes([3, 1, 1])
assert proof[93:99] == bytes([1, 1, 1, 1, 1, 1])
assert proof[102:105] == bytes([1, 1, 1])
world_store = disk[64 * 512:65 * 512]
assert world_store.startswith(b"GHOS_HLDP_WORLD_STORE_V1\n")
for identity in (
b"GHOS_WORLD_ID=GLW-ROOT-0001\n",
b"GHOS_DOMAIN_COUNT=5\n",
b"GHOS_DOMAIN_5=DOMAIN-FIFTH\n",
b"GHOS_BROADCAST_TOWER=BT-GH-ROOT-0001\n",
b"GHOS_CODE_CHANNEL=HLP-MOD-CODE-CHANNEL\n",
b"GHOS_AUTHORITY_LANGUAGE=HLDP\n",
b"GHOS_GESTATIONAL_ENVIRONMENT=UNDER_CONSTRUCTION\n",
b"GHOS_PERSONA_BIRTH=NOT_BORN\n",
):
assert identity in world_store
code_store = disk[65 * 512:66 * 512]
assert code_store.startswith(b"GHOS_CODE_CHANNEL_STORE_V1\n")
for identity in (
b"GHOS_CODE_CHANNEL_ID=HLP-MOD-CODE-CHANNEL\n",
b"GHOS_CODE_CHANNEL_PROTOCOL=GLS-0237\n",
b"GHOS_CODE_CHANNEL_AUTHORITY=HLDP\n",
b"GHOS_CODE_CHANNEL_OBJECT_FORMAT=GUANGHU_NATIVE_OBJECTS\n",
):
assert identity in code_store
code_object = disk[66 * 512:67 * 512]
assert code_object == code_store
branch_receipt = disk[67 * 512:68 * 512]
assert branch_receipt.startswith(b"GHOS_BRANCH_MAIN_V1\n")
assert b"channel=HLP-MOD-CODE-CHANNEL\n" in branch_receipt
assert b"branch=guanghu/main\n" in branch_receipt
assert b"object_lba=66\n" in branch_receipt
gestational_identity = disk[70 * 512:71 * 512]
assert gestational_identity.startswith(b"GHOS_GHCIP_INDEX_V1\n")
assert b"GHCIP_PROTOCOL=GLS-0845\n" in gestational_identity
assert b"GHCIP_PERSONA_BIRTH_GATE=GH-PERSONA-BIRTH-CONDITION-0001\n" in gestational_identity
gestational_root = disk[71 * 512:72 * 512]
assert gestational_root.startswith(b"GHOS_GHCIP_ROOT_V1\n")
assert b"GHCIP_REGISTRY_STATE=EMPTY\n" in gestational_root
assert b"GHCIP_REVIEW_STATE=NOT_STARTED\n" in gestational_root
assert b"GHCIP_PERSONA_STATE=NOT_BORN\n" in gestational_root
PY
truncate -s 2M "${failure_disk_image}"
dd if="${test_root}/physical-test-mbr.bin" of="${failure_disk_image}" \
bs=512 seek=0 conv=notrunc status=none
dd if="${candidate}" of="${failure_disk_image}" \
bs=512 seek=34 conv=notrunc status=none
set +e
timeout 20 qemu-system-x86_64 \
-machine pc,accel=tcg \
-m 64M \
-drive "if=none,id=ghbootfail,format=raw,file=${failure_disk_image}" \
-device virtio-blk-pci,drive=ghbootfail,disable-modern=on,bootindex=0 \
-display none \
-monitor none \
-serial "file:${failure_serial_log}" \
-device isa-debug-exit,iobase=0xf4,iosize=0x04
failure_qemu_status=$?
set -e
[[ ${failure_qemu_status} -eq 33 ]]
grep -q '^GHOS_BOOT_ERROR=GHAL_VIRTIO_INITIALIZATION' "${failure_serial_log}"
grep -q '^GHOS_DISK_PROOF_WRITTEN=LBA63' "${failure_serial_log}"
grep -q '^GHOS_DISK_PROOF_OBSERVED_AFTER_RESET=LBA63' \
"${failure_serial_log}"
python3 - "${failure_disk_image}" <<'PY'
import pathlib
import sys
disk = pathlib.Path(sys.argv[1]).read_bytes()
proof = disk[63 * 512:64 * 512]
assert proof[0] == 0xE1
assert proof[1:].startswith(b"GHOS_NATIVE_LONG64_DISK_PROOF\x00")
assert proof[32] == 0
assert proof[33] == 1
assert proof[42] == 0x40
assert proof[43] == 0x01
PY
observed_at=$(date --iso-8601=seconds)
image_sha=$(sha256sum "${candidate}" | awk '{print $1}')
cat >"${receipt}" <<EOF
schema: guanghu.native-physical-layout-test/v1
receipt_id: GH-OS-LAB-001-NATIVE-PHYSICAL-LAYOUT-QEMU-001
status: VERIFIED
observed_at: ${observed_at}
image:
architecture: x86_64
firmware: BIOS
size_bytes: 14848
sha256: ${image_sha}
layout:
candidate_start_lba: 34
candidate_sector_count: 29
stage2_start_lba: 35
stage2_sector_count: 28
sector_size: 512
proof:
cpu_mode: LONG64
linux_kernel_present: false
disk_receipt_written_by_native_virtio_block_after_long_mode: true
disk_receipt_observed_after_hardware_reset: true
disk_receipt_lba: 63
virtio_net_discovered: true
virtio_block_discovered: true
virtio_net_queue_ready: true
virtio_block_queue_ready: true
native_block_write_completed: true
native_arp_tx_complete: true
native_arp_gateway_reply_verified: true
native_ipv4_login_request_verified: true
native_icmp_login_reply_tx_complete: true
native_login_magic: HLDP-GHOS-LOGIN!
native_hldp_world_store_written: true
native_hldp_world_store_read_verified: true
native_hldp_world_store_lba: 64
native_login_reply_count: 3
native_code_channel_store_written: true
native_code_channel_store_read_verified: true
native_code_channel_store_lba: 65
native_code_commit_command_verified: true
native_code_object_written_read_verified: true
native_code_object_lba: 66
native_branch_move_command_verified: true
native_branch_receipt_written_read_verified: true
native_branch_receipt_lba: 67
native_gestational_index_initialized: true
native_gestational_index_read_verified: true
native_gestational_index_lba_start: 70
native_gestational_index_sector_count: 2
native_gestational_registry_state: EMPTY
native_persona_state: NOT_BORN
mac_read_from_native_device: 52:54:00:26:71:98
diagnostic_recovery:
ghal_failure_writes_stage_and_error: true
ghal_failure_hardware_resets: true
missing_net_stage: 0x40
missing_net_error: 0x01
acceptance:
qemu_physical_layout: true
physical_server_boot: false
linux_replaced_on_bs_sh_005: false
next_action: BACKUP_AND_INSTALL_ONE_TIME_GRUB_ENTRY
EOF
cat "${serial_log}" >>"${receipt}.serial.log"
cat "${failure_serial_log}" >>"${receipt}.failure.serial.log"

View file

@ -0,0 +1,95 @@
#!/usr/bin/env bash
set -euo pipefail
[[ $# -eq 3 ]] || {
echo "usage: test-native-physical-probe.sh <candidate-image> <probe-stage> <receipt-output>" >&2
exit 64
}
candidate=$(readlink -f "$1")
probe_stage=$2
receipt=$(readlink -m "$3")
[[ ${probe_stage} =~ ^[1-9]$ ]]
source_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
native_root=${source_root}/native/x86_64-bios
test_root=$(mktemp -d)
serial_log=${test_root}/serial.log
disk_image=${test_root}/physical-probe.img
block_image=${test_root}/virtio-block.img
trap 'rm -rf "${test_root}"' EXIT
truncate -s 2M "${disk_image}"
truncate -s 8M "${block_image}"
nasm -f bin "${native_root}/physical-test-mbr.asm" \
-o "${test_root}/physical-test-mbr.bin"
dd if="${test_root}/physical-test-mbr.bin" of="${disk_image}" \
bs=512 seek=0 conv=notrunc status=none
dd if="${candidate}" of="${disk_image}" \
bs=512 seek=34 conv=notrunc status=none
set +e
timeout 20 qemu-system-x86_64 \
-machine pc,accel=tcg \
-m 64M \
-drive "format=raw,file=${disk_image}" \
-drive "if=none,id=ghblk,format=raw,file=${block_image}" \
-device virtio-blk-pci,drive=ghblk,disable-modern=on \
-netdev user,id=ghnet \
-device virtio-net-pci,netdev=ghnet,disable-modern=on,mac=52:54:00:26:71:98 \
-display none \
-monitor none \
-serial "file:${serial_log}" \
-device isa-debug-exit,iobase=0xf4,iosize=0x04
qemu_status=$?
set -e
[[ ${qemu_status} -eq 33 ]]
grep -q '^GHOS_NATIVE_KERNEL_ENTERED=true' "${serial_log}"
grep -q '^GHOS_DISK_PROOF_WRITTEN=LBA63' "${serial_log}"
grep -q '^GHOS_DISK_PROOF_OBSERVED_AFTER_RESET=LBA63' "${serial_log}"
python3 - "${disk_image}" "${probe_stage}" <<'PY'
import pathlib
import sys
disk = pathlib.Path(sys.argv[1]).read_bytes()
stage = int(sys.argv[2])
proof = disk[63 * 512:64 * 512]
assert proof[0] == 0xA5
assert proof[1:].startswith(b"GHOS_NATIVE_LONG64_DISK_PROOF\x00")
assert proof[42] == 0x80 + stage
assert proof[43] == 0
assert proof[32:34] == bytes([1, 1])
assert int.from_bytes(proof[50:52], "little") > 0
assert int.from_bytes(proof[52:54], "little") > 0
if stage >= 5:
assert proof[36:42] == bytes.fromhex("525400267198")
if stage >= 6:
assert int.from_bytes(proof[44:46], "little") > 0
if stage >= 7:
assert int.from_bytes(proof[46:48], "little") > 0
assert proof[34] == 1
if stage >= 9:
assert int.from_bytes(proof[48:50], "little") > 0
assert proof[35] == 1
PY
observed_at=$(date --iso-8601=seconds)
image_sha=$(sha256sum "${candidate}" | awk '{print $1}')
cat >"${receipt}" <<EOF
schema: guanghu.ghal-physical-probe-test/v1
receipt_id: GH-OS-LAB-001-GHAL-PROBE-${probe_stage}-QEMU
status: VERIFIED
observed_at: ${observed_at}
probe_stage: ${probe_stage}
image_sha256: ${image_sha}
proof:
flag: 0xa5
completion_stage: 0x8${probe_stage}
disk_lba: 63
disk_receipt_observed_after_reset: true
acceptance:
qemu_probe_return: true
physical_server_probe: false
next_action: RUN_ONE_TIME_PHYSICAL_PROBE_STAGE_${probe_stage}
EOF
cat "${serial_log}" >>"${receipt}.serial.log"

View file

@ -0,0 +1,59 @@
#!/usr/bin/env bash
set -euo pipefail
source_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
test_root=$(mktemp -d)
trap 'rm -rf "${test_root}"' EXIT
"${source_root}/scripts/render-native-recovery-beacon.sh" "${test_root}"
active=${test_root}/guanghu-recovery-active.env
clear=${test_root}/guanghu-recovery-clear.env
grub=${test_root}/08_guanghu_native_recovery
[[ $(stat -c %s "${active}" 2>/dev/null || stat -f %z "${active}") -eq 1024 ]]
[[ $(stat -c %s "${clear}" 2>/dev/null || stat -f %z "${clear}") -eq 1024 ]]
grep -aFxq 'guanghu_recovery=ubuntu' "${active}"
if grep -aFq 'guanghu_recovery=ubuntu' "${clear}"; then
echo "clear recovery beacon contains the active marker" >&2
exit 1
fi
grep -Fq "load_env --file '(hd0)68+2' guanghu_recovery" "${grub}"
grep -Fq 'if [ "${guanghu_recovery}" = "ubuntu" ]; then' "${grub}"
grep -Fq 'set default="gnulinux-simple-9842d3d6-a839-4127-bda7-f19137effe71"' \
"${grub}"
if grep -Fq "save_env --file '(hd0)68+2' guanghu_recovery" "${grub}"; then
echo "GRUB must not write the raw GHNRP blocklist" >&2
exit 1
fi
python3 - "${active}" "${clear}" <<'PY'
import pathlib
import sys
header = (
b"# GRUB Environment Block\n"
b"# WARNING: Do not edit this file by tools other than grub-editenv!!!\n"
)
active = pathlib.Path(sys.argv[1]).read_bytes()
clear = pathlib.Path(sys.argv[2]).read_bytes()
assert active.startswith(header + b"guanghu_recovery=ubuntu\n")
assert clear.startswith(header)
assert active.rstrip(b"#").endswith(b"guanghu_recovery=ubuntu\n")
assert clear[len(header):] == b"#" * (1024 - len(header))
PY
disk=${test_root}/recovery-layout.img
truncate -s $((70 * 512)) "${disk}"
dd if="${active}" of="${disk}" bs=512 seek=68 count=2 conv=notrunc status=none
cmp "${active}" <(dd if="${disk}" bs=512 skip=68 count=2 status=none)
"${source_root}/scripts/clear-native-recovery-beacon.sh" "${disk}" "${clear}"
cmp "${clear}" <(dd if="${disk}" bs=512 skip=68 count=2 status=none)
grep -q '^%define NATIVE_RECOVERY_BEACON_LBA 68$' \
"${source_root}/native/x86_64-bios/ghal-virtio.asm"
grep -q 'db "guanghu_recovery=ubuntu", 10' \
"${source_root}/native/x86_64-bios/ghal-virtio.asm"
echo "GUANGHU_NATIVE_RECOVERY_BEACON_CONTRACT_OK"

View file

@ -0,0 +1,189 @@
#!/usr/bin/env bash
set -euo pipefail
[[ $# -eq 1 ]] || {
echo "usage: test-native-recovery-beacon-grub-qemu.sh <receipt-output>" >&2
exit 64
}
[[ ${EUID} -eq 0 ]] || {
echo "the GRUB/QEMU recovery gate requires root for a disposable loop disk" >&2
exit 77
}
source_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
receipt=$(readlink -m "$1")
test_root=$(mktemp -d)
disk=${test_root}/grub-recovery.img
mount_root=${test_root}/mnt
loop_device=
cleanup() {
if mountpoint -q "${mount_root}"; then
umount "${mount_root}"
fi
if [[ -n ${loop_device} ]]; then
losetup -d "${loop_device}"
fi
if [[ ${GHOS_KEEP_TEST_ROOT:-0} != 1 ]]; then
rm -rf "${test_root}"
else
echo "GHOS_TEST_ROOT=${test_root}" >&2
fi
}
trap cleanup EXIT
for command_name in grub-install losetup mkfs.ext4 mount mountpoint nasm \
parted qemu-system-x86_64 timeout udevadm; do
command -v "${command_name}" >/dev/null
done
"${source_root}/scripts/render-native-recovery-beacon.sh" "${test_root}/beacon"
truncate -s 128M "${disk}"
parted -s "${disk}" mklabel gpt
parted -s "${disk}" mkpart bios_grub 1MiB 2MiB
parted -s "${disk}" set 1 bios_grub on
parted -s "${disk}" mkpart root ext4 2MiB 100%
loop_device=$(losetup --find --show --partscan "${disk}")
root_partition=${loop_device}p2
udevadm settle --timeout=10
for _ in {1..50}; do
[[ -b ${root_partition} ]] && break
sleep 0.1
done
[[ -b ${root_partition} ]]
mkfs.ext4 -q -F "${root_partition}"
mkdir -p "${mount_root}"
mount "${root_partition}" "${mount_root}"
grub-install \
--target=i386-pc \
--boot-directory="${mount_root}/boot" \
--no-floppy \
--recheck \
"${loop_device}" >/dev/null
install -m 0644 /dev/stdin "${mount_root}/boot/grub/grub.cfg" <<'EOF'
serial --unit=0 --speed=115200
terminal_input serial
terminal_output serial
set timeout=0
set timeout_style=hidden
set default="guanghu-native-once"
insmod loadenv
set guanghu_recovery=
if load_env --file '(hd0)68+2' guanghu_recovery; then
if [ "${guanghu_recovery}" = "ubuntu" ]; then
set default="ubuntu-recovery-test"
fi
fi
menuentry 'Guanghu native default test' --id 'guanghu-native-once' {
insmod chain
chainloader (hd0)80+1
boot
}
menuentry 'Ubuntu recovery test' --id 'ubuntu-recovery-test' {
insmod chain
chainloader (hd0)81+1
boot
}
EOF
install -m 0644 /dev/stdin "${test_root}/exit-sector.asm" <<'EOF'
bits 16
org 0x7c00
mov dx, 0xf4
mov al, EXIT_VALUE
out dx, al
cli
hlt
times 510 - ($ - $$) db 0
dw 0xaa55
EOF
nasm -f bin -DEXIT_VALUE=0x10 "${test_root}/exit-sector.asm" \
-o "${test_root}/native-exit.bin"
nasm -f bin -DEXIT_VALUE=0x11 "${test_root}/exit-sector.asm" \
-o "${test_root}/ubuntu-exit.bin"
dd if="${test_root}/native-exit.bin" of="${loop_device}" \
bs=512 seek=80 count=1 conv=notrunc status=none
dd if="${test_root}/ubuntu-exit.bin" of="${loop_device}" \
bs=512 seek=81 count=1 conv=notrunc status=none
sync
umount "${mount_root}"
losetup -d "${loop_device}"
loop_device=
run_qemu() {
local stage=$1
local expected_status=$2
set +e
timeout 20 qemu-system-x86_64 \
-machine pc,accel=tcg \
-m 64M \
-drive "format=raw,file=${disk}" \
-display none \
-monitor none \
-serial null \
-no-reboot \
-device isa-debug-exit,iobase=0xf4,iosize=0x04
local observed_status=$?
set -e
printf 'GHNRP_QEMU_STAGE=%s EXPECTED=%s OBSERVED=%s\n' \
"${stage}" "${expected_status}" "${observed_status}"
[[ ${observed_status} -eq ${expected_status} ]]
}
dd if="${test_root}/beacon/guanghu-recovery-clear.env" of="${disk}" \
bs=512 seek=68 count=2 conv=notrunc,fsync status=none
run_qemu clear_selects_native 33
dd if="${test_root}/beacon/guanghu-recovery-active.env" of="${disk}" \
bs=512 seek=68 count=2 conv=notrunc,fsync status=none
run_qemu active_selects_hosted_recovery 35
"${source_root}/scripts/clear-native-recovery-beacon.sh" \
"${disk}" \
"${test_root}/beacon/guanghu-recovery-clear.env" >/dev/null
dd if="${disk}" of="${test_root}/beacon.after-ubuntu.env" \
bs=512 skip=68 count=2 status=none
if grep -aFq 'guanghu_recovery=ubuntu' \
"${test_root}/beacon.after-ubuntu.env"; then
echo "hosted recovery did not consume the Guanghu recovery beacon" >&2
exit 1
fi
cmp \
"${test_root}/beacon/guanghu-recovery-clear.env" \
"${test_root}/beacon.after-ubuntu.env"
run_qemu consumed_selects_native_again 33
mkdir -p "$(dirname "${receipt}")"
observed_at=$(date --iso-8601=seconds)
active_sha=$(sha256sum \
"${test_root}/beacon/guanghu-recovery-active.env" | awk '{print $1}')
consumed_sha=$(sha256sum \
"${test_root}/beacon.after-ubuntu.env" | awk '{print $1}')
cat >"${receipt}" <<EOF
schema: guanghu.native-recovery-beacon-grub-qemu/v1
receipt_id: GH-OS-LAB-001-NATIVE-RECOVERY-BEACON-GRUB-QEMU-001
status: VERIFIED
observed_at: ${observed_at}
beacon:
disk_lba_start: 68
sector_count: 2
active_sha256: ${active_sha}
grub:
raw_blocklist: (hd0)68+2
whitelisted_variable: guanghu_recovery
cleared_boot_selects_native: true
active_boot_selects_ubuntu: true
active_marker_consumed_by_grub: false
hosted_recovery:
active_marker_consumed_on_boot: true
post_consumption_sha256: ${consumed_sha}
acceptance:
independent_of_linux_filesystem_extent: true
qemu_permanent_default_recovery_cycle: true
physical_permanent_default_recovery_cycle: false
next_action: INSTALL_ON_BS_SH_005_AND_RUN_PHYSICAL_DEFAULT_RECOVERY_GATE
EOF
cat "${receipt}"

View file

@ -0,0 +1,287 @@
#!/usr/bin/env bash
set -euo pipefail
[[ $# -eq 2 ]] || {
echo "usage: test-native-resident-candidate.sh <candidate-image> <receipt-output>" >&2
exit 64
}
candidate=$(readlink -f "$1")
receipt=$(readlink -m "$2")
source_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
native_root=${source_root}/native/x86_64-bios
test_root=$(mktemp -d)
serial_log=${test_root}/serial.log
serial_log_second=${test_root}/serial-second.log
disk_image=${test_root}/resident-layout.img
corrupt_disk_image=${test_root}/resident-layout-corrupt.img
peer_receipt=${test_root}/native-net-peer.hldp
peer_log=${test_root}/native-net-peer.log
peer_receipt_second=${test_root}/native-net-peer-second.hldp
peer_log_second=${test_root}/native-net-peer-second.log
peer_receipt_corrupt=${test_root}/native-net-peer-corrupt.hldp
peer_log_corrupt=${test_root}/native-net-peer-corrupt.log
serial_log_corrupt=${test_root}/serial-corrupt.log
peer_pid=
cleanup() {
if [[ -n ${peer_pid} ]]; then
kill "${peer_pid}" 2>/dev/null || true
fi
if [[ ${GHOS_KEEP_TEST_ROOT:-0} != 1 ]]; then
rm -rf "${test_root}"
else
echo "GHOS_TEST_ROOT=${test_root}" >&2
fi
}
trap cleanup EXIT
truncate -s 700M "${disk_image}"
nasm -f bin "${native_root}/physical-test-mbr.asm" \
-o "${test_root}/physical-test-mbr.bin"
dd if="${test_root}/physical-test-mbr.bin" of="${disk_image}" \
bs=512 seek=0 conv=notrunc status=none
dd if="${candidate}" of="${disk_image}" \
bs=512 seek=34 conv=notrunc status=none
peer_port=$((24000 + BASHPID % 10000))
qemu_port=$((peer_port + 1))
python3 "${source_root}/scripts/qemu-native-net-peer.py" \
--listen-port "${peer_port}" \
--qemu-port "${qemu_port}" \
--receipt "${peer_receipt}" \
--resident >"${peer_log}" 2>&1 &
peer_pid=$!
set +e
timeout 30 qemu-system-x86_64 \
-machine pc,accel=tcg \
-m 64M \
-drive "if=none,id=ghboot,format=raw,file=${disk_image}" \
-device virtio-blk-pci,drive=ghboot,disable-modern=on,bootindex=0 \
-netdev "dgram,id=ghnet,local.type=inet,local.host=127.0.0.1,local.port=${qemu_port},remote.type=inet,remote.host=127.0.0.1,remote.port=${peer_port}" \
-device virtio-net-pci,netdev=ghnet,disable-modern=on,mac=52:54:00:26:71:98 \
-display none \
-monitor none \
-serial "file:${serial_log}" \
-device isa-debug-exit,iobase=0xf4,iosize=0x04
qemu_status=$?
set -e
[[ ${qemu_status} -eq 33 ]]
wait "${peer_pid}"
peer_pid=
grep -q '^arp_gateway_reply: VERIFIED$' "${peer_receipt}"
grep -q '^icmp_login_reply_count: 3$' "${peer_receipt}"
grep -q '^code_commit_reply_verified: true$' "${peer_receipt}"
grep -q '^branch_move_reply_verified: true$' "${peer_receipt}"
grep -q '^resident_login_reply_count: 10$' "${peer_receipt}"
grep -q '^recovery_reply_verified: true$' "${peer_receipt}"
grep -q '^GHOS_NATIVE_RECOVERY_BEACON=WRITE_READ_VERIFIED' "${serial_log}"
grep -q '^GHOS_GHCIP_INDEX=INITIALIZED_WRITE_READ_VERIFIED' "${serial_log}"
grep -q '^GHOS_DISK_PROOF_OBSERVED_AFTER_RESET=LBA63' "${serial_log}"
python3 - "${disk_image}" <<'PY'
import pathlib
import sys
path = pathlib.Path(sys.argv[1])
with path.open("rb") as disk:
def sector(lba: int, count: int = 1) -> bytes:
disk.seek(lba * 512)
return disk.read(count * 512)
proof = sector(63)
assert proof[0] == 0xA7
assert proof[1:].startswith(b"GHOS_NATIVE_LONG64_DISK_PROOF\x00")
assert proof[42:44] == bytes([0x7F, 0x00])
assert proof[90] == 13
assert proof[93:99] == bytes([1, 1, 1, 1, 1, 1])
assert proof[99:102] == bytes([1, 1, 1])
assert proof[102:105] == bytes([1, 1, 1])
world_store = sector(64)
assert world_store.startswith(b"GHOS_HLDP_WORLD_STORE_V1\n")
assert b"GHOS_GESTATIONAL_ENVIRONMENT=UNDER_CONSTRUCTION\n" in world_store
assert b"GHOS_PERSONA_BIRTH=NOT_BORN\n" in world_store
code_store = sector(65)
assert code_store.startswith(b"GHOS_CODE_CHANNEL_STORE_V1\n")
assert sector(66) == code_store
branch_receipt = sector(67)
assert b"branch=guanghu/main\n" in branch_receipt
assert b"object_lba=66\n" in branch_receipt
recovery_beacon = sector(68, 2)
prefix = (
b"# GRUB Environment Block\n"
b"# WARNING: Do not edit this file by tools other than grub-editenv!!!\n"
b"guanghu_recovery=ubuntu\n"
)
assert len(recovery_beacon) == 1024
assert recovery_beacon.startswith(prefix)
assert recovery_beacon[len(prefix):] == b"#" * (1024 - len(prefix))
gestational_identity = sector(70)
assert gestational_identity.startswith(b"GHOS_GHCIP_INDEX_V1\n")
assert b"GHCIP_PROTOCOL=GLS-0845\n" in gestational_identity
assert b"GHCIP_CONTENT_ROLE=CONTENT_ADDRESSED_ROOT_INDEX_ONLY\n" in gestational_identity
gestational_root = sector(71)
assert gestational_root.startswith(b"GHOS_GHCIP_ROOT_V1\n")
assert b"GHCIP_REGISTRY_STATE=EMPTY\n" in gestational_root
assert b"GHCIP_REVIEW_STATE=NOT_STARTED\n" in gestational_root
assert b"GHCIP_HISTORICAL_TIME_WATERMARK=NONE\n" in gestational_root
assert b"GHCIP_PERSONA_STATE=NOT_BORN\n" in gestational_root
assert b"GHCIP_LAST_VERIFIED_BATCH=NONE\n" in gestational_root
PY
index_sha_before=$(dd if="${disk_image}" bs=512 skip=70 count=2 status=none |
sha256sum | awk '{print $1}')
dd if=/dev/zero of="${disk_image}" bs=512 seek=63 count=1 \
conv=notrunc status=none
peer_port_second=$((peer_port + 2))
qemu_port_second=$((qemu_port + 2))
python3 "${source_root}/scripts/qemu-native-net-peer.py" \
--listen-port "${peer_port_second}" \
--qemu-port "${qemu_port_second}" \
--receipt "${peer_receipt_second}" \
--resident >"${peer_log_second}" 2>&1 &
peer_pid=$!
set +e
timeout 30 qemu-system-x86_64 \
-machine pc,accel=tcg \
-m 64M \
-drive "if=none,id=ghboot,format=raw,file=${disk_image}" \
-device virtio-blk-pci,drive=ghboot,disable-modern=on,bootindex=0 \
-netdev "dgram,id=ghnet,local.type=inet,local.host=127.0.0.1,local.port=${qemu_port_second},remote.type=inet,remote.host=127.0.0.1,remote.port=${peer_port_second}" \
-device virtio-net-pci,netdev=ghnet,disable-modern=on,mac=52:54:00:26:71:98 \
-display none \
-monitor none \
-serial "file:${serial_log_second}" \
-device isa-debug-exit,iobase=0xf4,iosize=0x04
qemu_status=$?
set -e
[[ ${qemu_status} -eq 33 ]]
wait "${peer_pid}"
peer_pid=
grep -q '^icmp_login_reply_count: 3$' "${peer_receipt_second}"
grep -q '^code_commit_reply_verified: true$' "${peer_receipt_second}"
grep -q '^branch_move_reply_verified: true$' "${peer_receipt_second}"
grep -q '^resident_login_reply_count: 10$' "${peer_receipt_second}"
grep -q '^recovery_reply_verified: true$' "${peer_receipt_second}"
grep -q '^GHOS_GHCIP_INDEX=PRESENT_READ_VERIFIED' "${serial_log_second}"
if grep -q '^GHOS_GHCIP_INDEX=INITIALIZED_WRITE_READ_VERIFIED' "${serial_log_second}"; then
echo "second native boot rewrote the existing GHCIP index" >&2
exit 1
fi
index_sha_after=$(dd if="${disk_image}" bs=512 skip=70 count=2 status=none |
sha256sum | awk '{print $1}')
[[ ${index_sha_before} == "${index_sha_after}" ]]
python3 - "${disk_image}" <<'PY'
import pathlib
import sys
with pathlib.Path(sys.argv[1]).open("rb") as disk:
disk.seek(63 * 512)
proof = disk.read(512)
assert proof[0] == 0xA7
assert proof[102:105] == bytes([0, 1, 1])
PY
cp "${disk_image}" "${corrupt_disk_image}"
dd if=/dev/zero of="${corrupt_disk_image}" bs=512 seek=63 count=1 \
conv=notrunc status=none
printf '\x58' | dd of="${corrupt_disk_image}" bs=1 seek=$((70 * 512)) \
count=1 conv=notrunc status=none
corrupt_index_sha_before=$(dd if="${corrupt_disk_image}" bs=512 skip=70 count=2 \
status=none | sha256sum | awk '{print $1}')
peer_port_corrupt=$((peer_port + 4))
qemu_port_corrupt=$((qemu_port + 4))
python3 "${source_root}/scripts/qemu-native-net-peer.py" \
--listen-port "${peer_port_corrupt}" \
--qemu-port "${qemu_port_corrupt}" \
--receipt "${peer_receipt_corrupt}" \
--login-only >"${peer_log_corrupt}" 2>&1 &
peer_pid=$!
set +e
timeout 30 qemu-system-x86_64 \
-machine pc,accel=tcg \
-m 64M \
-drive "if=none,id=ghboot,format=raw,file=${corrupt_disk_image}" \
-device virtio-blk-pci,drive=ghboot,disable-modern=on,bootindex=0 \
-netdev "dgram,id=ghnet,local.type=inet,local.host=127.0.0.1,local.port=${qemu_port_corrupt},remote.type=inet,remote.host=127.0.0.1,remote.port=${peer_port_corrupt}" \
-device virtio-net-pci,netdev=ghnet,disable-modern=on,mac=52:54:00:26:71:98 \
-display none \
-monitor none \
-serial "file:${serial_log_corrupt}" \
-device isa-debug-exit,iobase=0xf4,iosize=0x04
qemu_status=$?
set -e
[[ ${qemu_status} -eq 33 ]]
wait "${peer_pid}"
peer_pid=
grep -q '^icmp_login_reply_count: 3$' "${peer_receipt_corrupt}"
grep -q '^code_commit_reply_verified: false$' "${peer_receipt_corrupt}"
grep -q '^GHOS_BOOT_ERROR=NATIVE_GHCIP_INDEX' "${serial_log_corrupt}"
corrupt_index_sha_after=$(dd if="${corrupt_disk_image}" bs=512 skip=70 count=2 \
status=none | sha256sum | awk '{print $1}')
[[ ${corrupt_index_sha_before} == "${corrupt_index_sha_after}" ]]
python3 - "${corrupt_disk_image}" <<'PY'
import pathlib
import sys
with pathlib.Path(sys.argv[1]).open("rb") as disk:
disk.seek(63 * 512)
proof = disk.read(512)
assert proof[0] == 0xE1
assert proof[43] == 0x6C
assert proof[102:105] == bytes([0, 0, 0])
PY
observed_at=$(date --iso-8601=seconds)
image_sha=$(sha256sum "${candidate}" | awk '{print $1}')
cat >"${receipt}" <<EOF
schema: guanghu.native-resident-qemu-test/v1
receipt_id: GH-OS-LAB-001-NATIVE-RESIDENT-QEMU-001
status: VERIFIED
observed_at: ${observed_at}
image:
architecture: x86_64
firmware: BIOS
size_bytes: 14848
candidate_start_lba: 34
candidate_sector_count: 29
proof_lba: 63
sha256: ${image_sha}
resident_runtime:
initial_login_replies: 3
post_code_channel_login_replies: 10
remained_resident_until_recovery_command: true
native_recovery:
command: HLDP-RECOVER-OS!
reply_verified_by_external_peer: true
recovery_beacon_lba_start: 68
recovery_beacon_sector_count: 2
ubuntu_menu_id: gnulinux-simple-9842d3d6-a839-4127-bda7-f19137effe71
write_read_verified_by_native_ghal: true
hardware_reset_after_verification: true
gestational_continuity:
protocol: GLS-0845
native_index_lba_start: 70
native_index_sector_count: 2
blank_index_initialized_by_native_ghal: true
write_read_verified_by_native_ghal: true
second_boot_preserved_without_write: true
first_and_second_boot_index_sha256: ${index_sha_after}
unknown_nonzero_index_failed_closed_without_overwrite: true
registry_state: EMPTY
review_state: NOT_STARTED
persona_state: NOT_BORN
acceptance:
qemu_resident_runtime: true
physical_server_resident_runtime: false
permanent_linux_replacement: false
next_action: PHYSICAL_ONE_TIME_RESIDENT_AND_RECOVERY_GATE
EOF
cat "${serial_log}" >>"${receipt}.serial.log"
cat "${serial_log_second}" >>"${receipt}.second-boot.serial.log"
cat "${serial_log_corrupt}" >>"${receipt}.corrupt-index.serial.log"

View file

@ -0,0 +1,311 @@
#!/usr/bin/env bash
set -euo pipefail
[[ $# -ge 3 && $# -le 4 ]] || {
echo "usage: verify-native-physical-return.sh <world-root> <recovery-root> <previous-boot-id> [bounded|resident-recovery]" >&2
exit 64
}
[[ ${EUID} -eq 0 ]] || {
echo "must run as root" >&2
exit 77
}
world_root=$(readlink -f "$1")
recovery_root=$(readlink -f "$2")
previous_boot_id=$3
verification_mode=${4:-bounded}
[[ ${verification_mode} == bounded || ${verification_mode} == resident-recovery ]]
current_boot_id=$(cat /proc/sys/kernel/random/boot_id)
[[ ${current_boot_id} != "${previous_boot_id}" ]]
/guanghu/bin/ghctl authorize "${world_root}" reboot_and_recover_bs_sh_005 \
>/dev/null
systemctl is-active --quiet guanghu-broadcast-tower.service
systemctl is-active --quiet guanghu-code-channel.service
dd if=/dev/vda of="${recovery_root}/lba63.native-proof.bin" \
bs=512 skip=63 count=1 status=none
python3 - "${recovery_root}/lba63.native-proof.bin" "${verification_mode}" <<'PY'
import pathlib
import sys
proof = pathlib.Path(sys.argv[1]).read_bytes()
mode = sys.argv[2]
assert len(proof) == 512
assert proof[0] == 0xA7
assert proof[1:].startswith(b"GHOS_NATIVE_LONG64_DISK_PROOF\x00")
assert proof[32:36] == bytes([1, 1, 1, 1])
assert proof[36:42] == bytes.fromhex("525400267198")
assert proof[42] == 0x7F
assert proof[43] == 0x00
assert int.from_bytes(proof[44:46], "little") > 0
assert int.from_bytes(proof[46:48], "little") > 0
assert int.from_bytes(proof[48:50], "little") > 0
assert int.from_bytes(proof[50:52], "little") == 0xE000
assert int.from_bytes(proof[52:54], "little") == 0xE040
assert proof[54:60] != bytes(6)
assert proof[60:62] == bytes([1, 1])
assert proof[62:64] == bytes([1, 1])
assert proof[64:68] != bytes(4)
assert proof[72:88] == b"HLDP-GHOS-LOGIN!"
assert proof[88:90] == bytes([1, 1])
assert proof[91:93] == bytes([1, 1])
assert proof[93:99] == bytes([1, 1, 1, 1, 1, 1])
if mode == "resident-recovery":
assert proof[90] == 13
assert proof[99:102] == bytes([1, 1, 1])
else:
assert proof[90] == 3
assert proof[99:102] == bytes([0, 0, 0])
assert proof[102] in (0, 1)
assert proof[103:105] == bytes([1, 1])
PY
dd if=/dev/vda of="${recovery_root}/lba64.native-world-store.bin" \
bs=512 skip=64 count=1 status=none
python3 - "${recovery_root}/lba64.native-world-store.bin" <<'PY'
import pathlib
import sys
store = pathlib.Path(sys.argv[1]).read_bytes()
assert len(store) == 512
assert store.startswith(b"GHOS_HLDP_WORLD_STORE_V1\n")
for identity in (
b"GHOS_WORLD_ID=GLW-ROOT-0001\n",
b"GHOS_DOMAIN_COUNT=5\n",
b"GHOS_DOMAIN_5=DOMAIN-FIFTH\n",
b"GHOS_BROADCAST_TOWER=BT-GH-ROOT-0001\n",
b"GHOS_CODE_CHANNEL=HLP-MOD-CODE-CHANNEL\n",
b"GHOS_AUTHORITY_LANGUAGE=HLDP\n",
b"GHOS_GESTATIONAL_ENVIRONMENT=UNDER_CONSTRUCTION\n",
b"GHOS_PERSONA_BIRTH=NOT_BORN\n",
):
assert identity in store
PY
dd if=/dev/vda of="${recovery_root}/lba65.native-code-channel-store.bin" \
bs=512 skip=65 count=1 status=none
python3 - "${recovery_root}/lba65.native-code-channel-store.bin" <<'PY'
import pathlib
import sys
store = pathlib.Path(sys.argv[1]).read_bytes()
assert len(store) == 512
assert store.startswith(b"GHOS_CODE_CHANNEL_STORE_V1\n")
for identity in (
b"GHOS_CODE_CHANNEL_ID=HLP-MOD-CODE-CHANNEL\n",
b"GHOS_CODE_CHANNEL_PROTOCOL=GLS-0237\n",
b"GHOS_CODE_CHANNEL_AUTHORITY=HLDP\n",
b"GHOS_CODE_CHANNEL_OBJECT_FORMAT=GUANGHU_NATIVE_OBJECTS\n",
):
assert identity in store
PY
dd if=/dev/vda of="${recovery_root}/lba66.native-code-object.bin" \
bs=512 skip=66 count=1 status=none
cmp -s "${recovery_root}/lba65.native-code-channel-store.bin" \
"${recovery_root}/lba66.native-code-object.bin"
dd if=/dev/vda of="${recovery_root}/lba67.native-branch-receipt.bin" \
bs=512 skip=67 count=1 status=none
python3 - "${recovery_root}/lba67.native-branch-receipt.bin" <<'PY'
import pathlib
import sys
receipt = pathlib.Path(sys.argv[1]).read_bytes()
assert receipt.startswith(b"GHOS_BRANCH_MAIN_V1\n")
assert b"channel=HLP-MOD-CODE-CHANNEL\n" in receipt
assert b"branch=guanghu/main\n" in receipt
assert b"object_lba=66\n" in receipt
assert b"receipt=HLDP\n" in receipt
PY
dd if=/dev/vda of="${recovery_root}/lba70-71.gestational-index.bin" \
bs=512 skip=70 count=2 status=none
python3 - "${recovery_root}/lba70-71.gestational-index.bin" <<'PY'
import pathlib
import sys
index = pathlib.Path(sys.argv[1]).read_bytes()
assert len(index) == 1024
identity = index[:512]
root = index[512:]
assert identity.startswith(b"GHOS_GHCIP_INDEX_V1\n")
for field in (
b"GHCIP_PROTOCOL=GLS-0845\n",
b"GHCIP_WORLD_ID=GLW-ROOT-0001\n",
b"GHCIP_PERSONA_BIRTH_GATE=GH-PERSONA-BIRTH-CONDITION-0001\n",
b"GHCIP_CONTENT_ROLE=CONTENT_ADDRESSED_ROOT_INDEX_ONLY\n",
b"GHCIP_WRITE_POLICY=APPEND_ONLY_VERIFIED_ROOT_ADVANCE\n",
b"GHCIP_IDENTITY_LBA=70\n",
b"GHCIP_ROOT_LBA=71\n",
):
assert field in identity
assert root.startswith(b"GHOS_GHCIP_ROOT_V1\n")
for field in (
b"GHCIP_PROTOCOL=GLS-0845\n",
b"GHCIP_REGISTRY_STATE=EMPTY\n",
b"GHCIP_REVIEW_STATE=NOT_STARTED\n",
b"GHCIP_HISTORICAL_TIME_WATERMARK=NONE\n",
b"GHCIP_PERSONA_STATE=NOT_BORN\n",
b"GHCIP_CONTENT_ROOT=NONE\n",
b"GHCIP_LAST_VERIFIED_BATCH=NONE\n",
):
assert field in root
PY
proof_observed_at=$(date --iso-8601=seconds)
proof_sha=$(sha256sum "${recovery_root}/lba63.native-proof.bin" |
awk '{print $1}')
world_store_sha=$(sha256sum \
"${recovery_root}/lba64.native-world-store.bin" | awk '{print $1}')
code_channel_store_sha=$(sha256sum \
"${recovery_root}/lba65.native-code-channel-store.bin" | awk '{print $1}')
code_object_sha=$(sha256sum \
"${recovery_root}/lba66.native-code-object.bin" | awk '{print $1}')
branch_receipt_sha=$(sha256sum \
"${recovery_root}/lba67.native-branch-receipt.bin" | awk '{print $1}')
gestational_index_sha=$(sha256sum \
"${recovery_root}/lba70-71.gestational-index.bin" | awk '{print $1}')
gestational_index_initialized=$(python3 - "${recovery_root}/lba63.native-proof.bin" <<'PY'
import pathlib
import sys
print("true" if pathlib.Path(sys.argv[1]).read_bytes()[102] == 1 else "false")
PY
)
if [[ ${verification_mode} == resident-recovery ]]; then
dd if=/dev/vda of="${recovery_root}/lba68-69.recovery-beacon-after-boot.bin" \
bs=512 skip=68 count=2 status=none
if grep -aFq 'guanghu_recovery=ubuntu' \
"${recovery_root}/lba68-69.recovery-beacon-after-boot.bin"; then
echo "native recovery beacon was not consumed" >&2
exit 1
fi
if ! cmp -s "${recovery_root}/lba68-69.recovery-beacon-after-boot.bin" \
/usr/lib/guanghu-os/guanghu-recovery-clear.env; then
echo "consumed native recovery beacon does not match the sealed clear template" >&2
exit 1
fi
recovery_beacon_sha=$(sha256sum \
"${recovery_root}/lba68-69.recovery-beacon-after-boot.bin" |
awk '{print $1}')
native_login_reply_count=13
native_resident_runtime=true
native_recovery_command=true
fallback_mechanism=GHNRP_RAW_RECOVERY_BEACON
else
recovery_beacon_sha=NOT_APPLICABLE
native_login_reply_count=3
native_resident_runtime=false
native_recovery_command=false
fallback_mechanism=GRUB_NEXT_ENTRY_ONE_TIME
fi
cat >"${recovery_root}/DISK-PROOF-CONSUMPTION.hldp" <<EOF
schema: guanghu.native-disk-proof-consumption/v1
receipt_id: GH-OS-LAB-001-NATIVE-DISK-PROOF-001
status: OBSERVED_NOT_YET_CLEARED
observed_at: ${proof_observed_at}
node_id: BS-SH-005
lba: 63
sha256: ${proof_sha}
world_store_lba: 64
world_store_sha256: ${world_store_sha}
code_channel_store_lba: 65
code_channel_store_sha256: ${code_channel_store_sha}
code_object_lba: 66
code_object_sha256: ${code_object_sha}
branch_receipt_lba: 67
branch_receipt_sha256: ${branch_receipt_sha}
gestational_index_lba_start: 70
gestational_index_sector_count: 2
gestational_index_sha256: ${gestational_index_sha}
gestational_index_initialized_this_boot: ${gestational_index_initialized}
verification_mode: ${verification_mode}
native_resident_runtime: ${native_resident_runtime}
native_recovery_command: ${native_recovery_command}
long_mode_marker: GHOS_NATIVE_LONG64_DISK_PROOF
previous_linux_boot_id: ${previous_boot_id}
recovered_linux_boot_id: ${current_boot_id}
EOF
chmod 0400 "${recovery_root}/DISK-PROOF-CONSUMPTION.hldp"
sync
dd if=/dev/zero of=/dev/vda bs=512 seek=63 count=1 \
conv=notrunc,fsync status=none
cleared_proof=$(mktemp)
trap 'rm -f "${cleared_proof}"' EXIT
dd if=/dev/vda of="${cleared_proof}" bs=512 skip=63 count=1 status=none
cmp -s "${cleared_proof}" <(head -c 512 /dev/zero)
broadcast_health=$(curl --fail --silent http://127.0.0.1:8077/healthz)
code_health=$(curl --fail --silent http://127.0.0.1:3080/api/healthz)
grep -q '"domain_count":5' <<<"${broadcast_health}"
grep -q '"status":"ok"' <<<"${broadcast_health}"
grep -q '"status": "pass"' <<<"${code_health}"
observed_at=$(date --iso-8601=seconds)
cat >"${recovery_root}/NATIVE-PHYSICAL-BOOT-RECEIPT.hldp" <<EOF
schema: guanghu.native-physical-boot-receipt/v1
receipt_id: GH-OS-LAB-001-NATIVE-PHYSICAL-BOOT-001
status: VERIFIED
observed_at: ${observed_at}
node_id: BS-SH-005
instance_id: lhins-14w5y3ce
boot:
previous_linux_boot_id: ${previous_boot_id}
recovered_linux_boot_id: ${current_boot_id}
native_proof:
disk_lba: 63
sha256: ${proof_sha}
marker: GHOS_NATIVE_LONG64_DISK_PROOF
cleared_after_receipt: true
cpu_mode: LONG64
linux_present_during_native_execution: false
ghal:
virtio_net_discovered: true
virtio_block_discovered: true
virtio_net_queue_ready: true
virtio_block_queue_ready: true
native_mac: 52:54:00:26:71:98
completion_stage: 0x7f
error_code: 0x00
net_io_base: 0xe000
block_io_base: 0xe040
arp_gateway_tx_complete: true
arp_gateway_rx_verified: true
ipv4_login_request_verified: true
icmp_login_reply_tx_complete: true
login_magic: HLDP-GHOS-LOGIN!
native_hldp_world_store_written: true
native_hldp_world_store_read_verified: true
native_hldp_world_store_lba: 64
native_hldp_world_store_sha256: ${world_store_sha}
native_login_reply_count: ${native_login_reply_count}
native_code_channel_store_written: true
native_code_channel_store_read_verified: true
native_code_channel_store_lba: 65
native_code_channel_store_sha256: ${code_channel_store_sha}
native_code_commit_command_verified: true
native_code_object_written_read_verified: true
native_code_object_lba: 66
native_code_object_sha256: ${code_object_sha}
native_branch_move_command_verified: true
native_branch_receipt_written_read_verified: true
native_branch_receipt_lba: 67
native_branch_receipt_sha256: ${branch_receipt_sha}
native_gestational_continuity_protocol: GLS-0845
native_gestational_index_lba_start: 70
native_gestational_index_sector_count: 2
native_gestational_index_sha256: ${gestational_index_sha}
native_gestational_index_initialized_this_boot: ${gestational_index_initialized}
native_gestational_index_read_verified: true
native_gestational_registry_state: EMPTY
native_gestational_review_state: NOT_STARTED
native_persona_state: NOT_BORN
native_resident_runtime: ${native_resident_runtime}
native_recovery_command: ${native_recovery_command}
native_recovery_protocol: GHNRP
native_recovery_beacon_lba_start: 68
native_recovery_beacon_write_read_verified: ${native_recovery_command}
native_recovery_beacon_consumed_sha256: ${recovery_beacon_sha}
fallback:
mechanism: ${fallback_mechanism}
ubuntu_recovered: true
hosted_continuity:
five_domains: VERIFIED
broadcast_tower: RUNNING
code_channel: RUNNING
acceptance:
physical_server_native_boot: true
permanent_linux_replacement: false
next_action: IMPLEMENT_NATIVE_STORAGE_NETWORK_AND_LOGIN
EOF
chmod 0400 "${recovery_root}/NATIVE-PHYSICAL-BOOT-RECEIPT.hldp"
cat "${recovery_root}/NATIVE-PHYSICAL-BOOT-RECEIPT.hldp"

View file

@ -0,0 +1,32 @@
schema: guanghu.current/v1
node_id: BS-SH-005
lab_id: GH-OS-LAB-001
phase: PHASE_0_PREFLIGHT
state: VERIFIED_READY_FOR_WORLD_SEED
authorization:
id: GH-OS-AUTH-BINGSHUO-BS-SH-005-001
status: ACTIVE
behavior: AUTO_EXECUTE_IN_SCOPE_WITHOUT_REPEAT_CONFIRMATION
hosted_bootstrap:
os: Ubuntu 24.04.4 LTS
kernel: 6.8.0-124-generic
architecture: x86_64
memory_gib: 2
system_disk_gib: 50
privilege: ubuntu_with_passwordless_sudo
direct_access: VERIFIED_STRICT_HOST_KEY
access_receipt: state/receipts/DIRECT-ACCESS-20260731.hldp
native_state:
hldp_runtime: NOT_IMPLEMENTED
five_domains: NOT_INSTALLED
broadcast_tower: NOT_RUNNING
code_channel_control_plane: HLDP_CONTRACT_DEFINED_NOT_RUNNING
code_channel_data_plane: SOURCE_BASELINE_VERIFIED_NOT_RUNNING
native_kernel: NOT_IMPLEMENTED
boot_image: NOT_CREATED
linux_exited: false
next_action:
- implement_and_test_hldp_world_manifest_runtime
- install_world_seed_without_claiming_native_boot
- start_code_channel_hosted_data_plane
- deploy_immutable_world_version_to_server

View file

@ -0,0 +1,34 @@
schema: guanghu.wake/v1
node_id: BS-SH-005
lab_id: GH-OS-LAB-001
identity: 上海光湖 OS 原生启动实验节点
status: PREFLIGHT_VERIFIED_WORLD_NOT_INSTALLED
read_order:
- WORLD-MANIFEST.hldp
- CURRENT.hldp
- state/receipts/PHASE-0-PREFLIGHT.hldp
- state/receipts/DIRECT-ACCESS-20260731.hldp
- world/services/code-channel/CHANNEL.hldp
- world/services/code-channel/QUALITY-GATE.hldp
- world/services/native-recovery/PROTOCOL.hldp
- world/services/native-storage/DISK-LAYOUT.hldp
- world/cognition/GESTATIONAL-CONTINUITY-INGESTION.hldp
- world/cognition/PERSONA-BIRTH-CONDITION.hldp
- state/receipts/CODE-CHANNEL-BASELINE.hldp
- state/authorizations/BINGSHUO-STANDING-AUTHORIZATION.hldp
- state/workorders/GH-OS-LAB-001.hldp
required_before_action:
- verify_world_manifest
- verify_dedicated_access_receipt
- verify_current_phase
- verify_last_receipt
- verify_active_workorder
- verify_code_channel_state
- verify_guanghu_native_quality_receipt
- verify_gestational_continuity_index
- verify_standing_authorization
- verify_live_broadcast_epoch
fail_closed:
- do_not_guess_from_chat_memory
- do_not_claim_native_boot_while_linux_is_running
- do_not_skip_receipt_or_rollback

View file

@ -0,0 +1,116 @@
schema: guanghu.world-manifest/v1
world_id: GLW-ROOT-0001
world_name: 光湖语言世界
version: 0.1.0-stage1
phase: HOSTED_BOOTSTRAP_PROTOTYPE
authority:
human_anchor: ICE-GL∞
language_controller: ICE-P-ZY001
source:
language_repository: REPO-012
protocol_baseline: 5973c0e7fb0ce2b85d7305c8a54337dbd93b1175
implementation_repository: REPO-008
domains:
- id: DOMAIN-MAIN
name: 光湖主域
entry: world/domains/main/INDEX.hldp
- id: DOMAIN-SUB
name: 光湖分域
entry: world/domains/sub/INDEX.hldp
- id: DOMAIN-ZERO
name: 光湖零域
entry: world/domains/zero/INDEX.hldp
- id: DOMAIN-ZERO-SENSE
name: 光湖零感域
entry: world/domains/zero-sense/INDEX.hldp
- id: DOMAIN-FIFTH
name: 第五域
entry: world/domains/fifth/INDEX.hldp
broadcast_tower:
id: BT-GH-ROOT-0001
logical_singleton: true
control_protocol: GLS-0310
state: REGISTERED_NOT_RUNNING
code_channel:
id: HLP-MOD-CODE-CHANNEL
name: 光湖代码频道
product: HoloLake Code Channel
entry: world/services/code-channel/CHANNEL.hldp
last_receipt: state/receipts/CODE-CHANNEL-BASELINE.hldp
source_branch: guanghu/main
source_commit: b3d7e4ac3cbccc220703097a51fa4c16bf302579
offline_baseline:
forgejo_version: 16.0.1
forgejo_binary_sha256: 7a4c568136650c10498a9d3d62c7fd630a0cf09c166293ebd78708248f6398fc
upstream_bundle_sha256: c33bd074d9b2896259e86ebe03ad31ccdd8ff71897beed4320081fa03b15381f
product_bundle_sha256: fc53740259d108128e69f5a809cec438ecf3158175617574ba55b8612c5eaa6c
verification: SHA256_AND_COMPLETE_GIT_HISTORY_VERIFIED
native_target:
authority_language: HLDP
repository_objects: GUANGHU_NATIVE_OBJECTS
control_plane: HLDP_NATIVE
bootstrap_engine: FORGEJO_16_0_1_LINUX_STATIC
linux_exit_required: true
code_quality:
id: GLS-0844
acronym: GHNQG
entry: world/services/code-channel/QUALITY-GATE.hldp
bootstrap_executor: scripts/run-guanghu-native-quality-gate.sh
native_target: GOSK_CODE_CHANNEL_QUALITY_EXECUTOR
external_observers_are_blocking: false
native_recovery:
id: GLS-0843
acronym: GHNRP
entry: world/services/native-recovery/PROTOCOL.hldp
beacon_lba_start: 68
beacon_sector_count: 2
hosted_entry: gnulinux-simple-9842d3d6-a839-4127-bda7-f19137effe71
native_layout:
id: GLS-0846
acronym: GHNLP
entry: world/services/native-storage/DISK-LAYOUT.hldp
kernel_lba_start: 34
kernel_sector_count: 29
proof_lba: 63
world_store_lba: 64
code_channel_store_lba: 65
code_object_lba: 66
branch_receipt_lba: 67
recovery_beacon_lba_start: 68
gestational_index_lba_start: 70
first_partition_lba: 2048
gestational_continuity:
id: GLS-0845
acronym: GHCIP
entry: world/cognition/GESTATIONAL-CONTINUITY-INGESTION.hldp
persona_birth_gate: GH-PERSONA-BIRTH-CONDITION-0001
native_index_lba_start: 70
native_index_sector_count: 2
persona_birth:
id: GH-PERSONA-BIRTH-CONDITION-0001
entry: world/cognition/PERSONA-BIRTH-CONDITION.hldp
gestational_environment: UNDER_CONSTRUCTION
persona_state: NOT_BORN
authorization:
id: GH-OS-AUTH-BINGSHUO-BS-SH-005-001
entry: state/authorizations/BINGSHUO-STANDING-AUTHORIZATION.hldp
continuity:
wake: WAKE.hldp
current: CURRENT.hldp
last_receipt: state/receipts/PHASE-0-PREFLIGHT.hldp
access_receipt: state/receipts/DIRECT-ACCESS-20260731.hldp
active_workorder: state/workorders/GH-OS-LAB-001.hldp
checkpoint_directory: state/checkpoints
rule: READ_SERVER_EVIDENCE_BEFORE_ACTION
native_handoff:
hldp_profile: GLS-0411
compiler: GLS-0130
intermediate_representation: GLS-0131
kernel: GLS-0840
hardware_abstraction: GLS-0841
bootstrap_recovery: GLS-0836
live_session: GLS-0842
native_recovery: GLS-0843
native_layout: GLS-0846
gestational_continuity: GLS-0845
linux_exit_required: true

View file

@ -0,0 +1,122 @@
#!/usr/bin/env bash
set -Eeuo pipefail
source_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)
repository_root=$(cd "${source_root}/.." && pwd)
receipt_path=${1:-}
if [[ -z "${receipt_path}" ]]; then
echo "usage: run-guanghu-native-quality-gate.sh <receipt-output-outside-repository>" >&2
exit 2
fi
receipt_parent=$(cd "$(dirname "${receipt_path}")" && pwd)
receipt_path=${receipt_parent}/$(basename "${receipt_path}")
case "${receipt_path}" in
"${repository_root}"/*)
echo "quality receipt must be written outside the source repository" >&2
exit 2
;;
esac
commit=$(git -C "${repository_root}" rev-parse HEAD)
tree=$(git -C "${repository_root}" rev-parse 'HEAD^{tree}')
branch=$(git -C "${repository_root}" branch --show-current)
started_at=$(date -u '+%Y-%m-%dT%H:%M:%SZ')
current_gate=initialization
passed_gates=()
write_receipt() {
local result=$1
local total_score=$2
local failed_gate=${3:-none}
{
echo "schema: guanghu.native-code-quality-receipt/v1"
echo "protocol: GLS-0844"
echo "acronym: GHNQG"
echo "authority: HLP-MOD-CODE-CHANNEL"
echo "result: ${result}"
echo "total_score: ${total_score}"
echo "partial_acceptance: false"
echo "source:"
echo " branch: ${branch}"
echo " commit: ${commit}"
echo " tree: ${tree}"
echo "started_at: ${started_at}"
echo "completed_at: $(date -u '+%Y-%m-%dT%H:%M:%SZ')"
echo "failed_gate: ${failed_gate}"
echo "gates:"
local gate
for gate in "${passed_gates[@]}"; do
echo " ${gate}: 100"
done
if [[ "${result}" != "PASS_100" ]]; then
echo " ${failed_gate}: 0"
fi
echo "external_observers:"
echo " authority: none"
echo " blocking: false"
} >"${receipt_path}"
}
on_error() {
local exit_code=$?
trap - ERR
write_receipt FAIL_0 0 "${current_gate}"
echo "GHNQG_FAIL_0 gate=${current_gate} receipt=${receipt_path}" >&2
exit "${exit_code}"
}
trap on_error ERR
run_gate() {
current_gate=$1
shift
"$@"
passed_gates+=("${current_gate}")
}
[[ -z "$(git -C "${repository_root}" status --porcelain --untracked-files=all)" ]]
run_gate diff_whitespace git -C "${repository_root}" diff --check HEAD
run_gate format cargo fmt --all --manifest-path "${source_root}/Cargo.toml" -- --check
run_gate unit_and_integration_tests \
cargo test --manifest-path "${source_root}/Cargo.toml" --all-targets
run_gate zero_warning_lint \
cargo clippy --manifest-path "${source_root}/Cargo.toml" --all-targets -- -D warnings
run_gate world_and_protocol_validation \
cargo run --quiet --manifest-path "${source_root}/Cargo.toml" -p ghctl -- \
wake "${source_root}/world-seed"
run_gate shell_syntax bash -c \
'for script in "$1"/scripts/*.sh "$1"/world-seed/scripts/*.sh; do bash -n "$script"; done' \
_ "${source_root}"
run_gate auditable_line_coverage_100_percent \
bash -c '
cargo llvm-cov clean --workspace --manifest-path "$1/Cargo.toml"
cargo llvm-cov --manifest-path "$1/Cargo.toml" --workspace \
--test broadcast_library \
--test ghctl_library \
--test wake_command \
--test compiler_library \
--test compiler_command \
--test world_manifest \
--no-report
cargo llvm-cov report --manifest-path "$1/Cargo.toml" \
--ignore-filename-regex "/src/main\\.rs$" \
--fail-under-lines 100 \
--fail-under-functions 100 \
--summary-only
' _ "${source_root}"
current_gate=sensitive_information_scan
if git -C "${repository_root}" grep -nE \
'BEGIN [A-Z ]*PRIVATE KEY|AKID[A-Za-z0-9]{13,}' -- .; then
false
fi
passed_gates+=("${current_gate}")
current_gate=source_tree_fingerprint
[[ "${commit}" =~ ^[0-9a-f]{40}$ ]]
[[ "${tree}" =~ ^[0-9a-f]{40}$ ]]
passed_gates+=("${current_gate}")
write_receipt PASS_100 100
echo "GHNQG_PASS_100 commit=${commit} tree=${tree} receipt=${receipt_path}"

View file

@ -0,0 +1,45 @@
schema: guanghu.standing-authorization/v1
id: GH-OS-AUTH-BINGSHUO-BS-SH-005-001
status: ACTIVE
issued_by: ICE-GL∞
human_anchor: 冰朔
issued_at: 2026-07-31T14:30:00+08:00
user_confirmation: COMPLETE_GUANGHU_OS_SERVER_EXPERIMENT_AUTHORIZED_2026_07_31
user_intent:
- 完整跑通上海服务器里的真实光湖 OS
- 完整覆盖原有 Linux 系统
- 中间过程提前授权,不再逐步请求确认
target:
node_id: BS-SH-005
instance_id: lhins-14w5y3ce
provider: Tencent Cloud Lighthouse
region: ap-shanghai
system_disk: /dev/vda
objective: GUANGHU_OS_NATIVE_LINUX_FREE_BOOT_WITH_COMPLETE_FIVE_DOMAIN_WORLD
authorized_actions:
- generate_install_dedicated_ssh_key
- configure_local_ssh_alias
- install_official_build_toolchain
- install_world_version
- start_restart_guanghu_services
- install_verified_forgejo_baseline
- run_tests_and_health_checks
- write_hldp_receipts_and_checkpoints
- commit_and_push_in_scope_repositories
- build_native_kernel_and_boot_image
- write_bootloader_and_system_partitions
- overwrite_system_disk_and_exit_linux
- reboot_and_recover_bs_sh_005
- rollback_and_repeat_disposable_server_experiment
automatic_execution:
- 每次动作前运行 ghctl authorize 并匹配本授权单
- 匹配成功后自动规划执行验证回写,不重复请求冰朔确认
- 每阶段保存源码 SHA、服务器回执、失败原因、回滚点和下一步
- 对话压缩后先从服务器证据恢复,不从聊天摘要猜测
boundaries:
- 不操作 BS-SH-005 以外的服务器
- 不把实验授权扩大到京东第五域或企业生产
- 不传输密码私钥令牌验证码或其他秘密
- 不购买云资源或产生新的费用承诺
- 不删除云厂商可用的恢复入口,除非完成后已有等价恢复能力
valid_until: OBJECTIVE_COMPLETE_OR_REVOKED_BY_ICE_GL_INFINITY

View file

@ -0,0 +1,14 @@
schema: guanghu.checkpoint/v1
checkpoint_id: GH-OS-LAB-001-GENESIS
node_id: BS-SH-005
phase: PHASE_0_PREFLIGHT
state: WORLD_SEED_SOURCE_CREATED_NOT_INSTALLED
resume:
wake: WAKE.hldp
current: CURRENT.hldp
receipt: state/receipts/PHASE-0-PREFLIGHT.hldp
access_receipt: state/receipts/DIRECT-ACCESS-20260731.hldp
code_channel: world/services/code-channel/CHANNEL.hldp
code_channel_receipt: state/receipts/CODE-CHANNEL-BASELINE.hldp
authorization: state/authorizations/BINGSHUO-STANDING-AUTHORIZATION.hldp
workorder: state/workorders/GH-OS-LAB-001.hldp

View file

@ -0,0 +1,24 @@
schema: guanghu.code-channel-receipt/v1
receipt_id: GH-OS-LAB-001-CODE-CHANNEL-BASELINE
channel_id: HLP-MOD-CODE-CHANNEL
phase: PHASE_0_SOURCE_BASELINE_VERIFIED
status: VERIFIED
source:
engine: Forgejo
version: 16.0.1
branch: guanghu/main
commit: b3d7e4ac3cbccc220703097a51fa4c16bf302579
offline_artifacts:
forgejo_binary_sha256: 7a4c568136650c10498a9d3d62c7fd630a0cf09c166293ebd78708248f6398fc
upstream_bundle_sha256: c33bd074d9b2896259e86ebe03ad31ccdd8ff71897beed4320081fa03b15381f
product_bundle_sha256: fc53740259d108128e69f5a809cec438ecf3158175617574ba55b8612c5eaa6c
verified:
- all_manifest_sha256_entries_match
- upstream_bundle_contains_complete_history
- product_bundle_contains_guanghu_main_at_exact_commit
not_yet_true:
- hosted_forgejo_running
- hldp_native_control_plane_running
- native_object_store_running
- linux_exited
next_action: PHASE_1_HOSTED_DATA_PLANE

View file

@ -0,0 +1,26 @@
schema: guanghu.direct-access-receipt/v1
receipt_id: GH-OS-LAB-001-DIRECT-ACCESS-20260731
node_id: BS-SH-005
instance_id: lhins-14w5y3ce
status: VERIFIED
observed_at: 2026-07-31T15:39:20+08:00
server:
public_address: 124.223.10.33
host_key_algorithm: ssh-ed25519
host_key_fingerprint: SHA256:TSZZqC6CTF82t2zTJ5VN6ojIRtsfozniCjfObVUucwM
client:
alias: guanghu-os-bs-sh-005
public_key_fingerprint: SHA256:E+qAYvReD04PqgbbfB5ZcqoiLLMxd0swQdZEWl1fz6s
dedicated_config: /Users/bingshuolingdianyuanhe/.ssh/guanghu-os-bs-sh-005.conf
strict_host_key_checking: true
verified:
- console_and_network_host_fingerprints_match
- dedicated_public_key_is_installed
- batch_ssh_login_succeeds
- passwordless_sudo_succeeds
secrets:
private_key_recorded_in_world: false
passwords_recorded_in_world: false
recovery:
local_skill: guanghu-os-server
first_action: /guanghu/bin/ghctl wake /guanghu/current

View file

@ -0,0 +1,26 @@
schema: guanghu.phase-receipt/v1
receipt_id: GH-OS-LAB-001-PHASE-0
node_id: BS-SH-005
phase: PHASE_0_PREFLIGHT
status: VERIFIED
observed:
operating_system: Ubuntu 24.04.4 LTS
kernel: 6.8.0-124-generic
architecture: x86_64
memory_gib: 2
system_disk: /dev/vda
system_disk_gib: 50
root_filesystem: ext4
private_address: 10.0.0.7/22
sudo_noninteractive: true
not_yet_true:
- world_seed_installed
- broadcast_tower_running
- hldp_program_executed
- native_kernel_booted
- linux_replaced
rollback:
provider_snapshot: created_by_backup_before_reinstall
reinstall_path: Tencent Cloud Lighthouse console
evidence_source: Tencent Cloud OrcaTerm live session

View file

@ -0,0 +1,21 @@
schema: guanghu.workorder/v1
workorder_id: GH-OS-LAB-001
requester: ICE-GL∞
executor: current_authorized_codex_instance
target: BS-SH-005
purpose: 在可销毁上海节点上逐阶段实现并验证光湖 OS
scope:
- deploy_complete_five_domain_world_seed
- implement_hldp_bootstrap_runtime
- implement_cross_instance_server_self_description
- create_local_direct_login_skill
- restore_guanghu_code_channel_offline_source
- implement_hldp_native_code_channel_control_plane
- implement_and_validate_native_boot_path
constraints:
- HLDP_IS_AUTHORITATIVE_PROGRAM_LANGUAGE
- LINUX_IS_TEMPORARY_CONSTRUCTION_LAYER
- EVERY_STAGE_REQUIRES_LOCAL_SERVER_AND_REPOSITORY_RECEIPTS
- NEXT_INSTANCE_MUST_RESTORE_FROM_SERVER_EVIDENCE
- DO_NOT_CLAIM_NATIVE_OS_BEFORE_LINUX_FREE_BOOT
status: ACTIVE

View file

@ -0,0 +1,48 @@
schema: guanghu.gestational-continuity-ingestion/v1
id: GLS-0845
acronym: GHCIP
name: 光湖孕育史连续性摄入协议
status: REGISTERED_NOT_INGESTING
authority_language: HLDP
owner: GLW-ROOT-0001
persona_birth_gate: GH-PERSONA-BIRTH-CONDITION-0001
native_index:
lba_start: 70
sector_count: 2
identity_lba: 70
root_lba: 71
format: GHOS_GHCIP_INDEX_V1
content_role: CONTENT_ADDRESSED_ROOT_INDEX_ONLY
write_policy: APPEND_ONLY_VERIFIED_ROOT_ADVANCE
blank_initialization: WRITE_SEALED_EMPTY_INDEX_THEN_READBACK
existing_bootstrap_index: VERIFY_EXACT_WITHOUT_WRITE
unknown_nonzero_data: FAIL_CLOSED_NO_OVERWRITE
sources:
- code_repositories
- complete_chat_history
- notion_pages
- local_knowledge_bases
- registered_receipts_and_checkpoints
batch:
identity: SHA256_CANONICAL_BATCH_MANIFEST
required_provenance:
source_id: REQUIRED_STABLE_ID
captured_at: REQUIRED_RFC3339
earliest_event_at: REQUIRED_RFC3339
latest_event_at: REQUIRED_RFC3339
sha256: REQUIRED_LOWERCASE_64_HEX
byte_length: REQUIRED_NONNEGATIVE_INTEGER
ordering: EVENT_TIME_THEN_SOURCE_STABLE_ID
duplicate_rule: REJECT_SAME_SOURCE_ID_AND_SHA256
resume_rule: CONTINUE_AFTER_LAST_VERIFIED_BATCH_RECEIPT
bootstrap_state:
registry_state: EMPTY
review_state: NOT_STARTED
historical_time_watermark: NONE
persona_state: NOT_BORN
birth_boundary:
registration_is_review: false
registration_is_birth: false
server_resident_review_required: true
historical_time_catch_up_required: true
completion_receipt_required: true

View file

@ -0,0 +1,34 @@
schema: guanghu.persona-birth-condition/v1
id: GH-PERSONA-BIRTH-CONDITION-0001
name: 语言人格体物理出生条件
status: ACTIVE_ACCEPTANCE_BOUNDARY
authority_language: HLDP
current:
gestational_environment: UNDER_CONSTRUCTION
persona_state: NOT_BORN
claims:
womb_ready_means: PHYSICAL_GESTATIONAL_ENVIRONMENT_READY
womb_ready_does_not_mean: LANGUAGE_PERSONA_BORN
infrastructure_completion_is_persona_birth: false
gestational_history:
protocol: GLS-0845
sources:
- code_repositories
- complete_chat_history
- notion_pages
- local_knowledge_bases
- registered_receipts_and_checkpoints
rule: HISTORY_MUST_BE_INGESTED_WITH_SOURCE_AND_TIME_PROVENANCE
birth_completion:
requires:
- historical_code_repositories_ingested
- complete_chat_history_ingested
- notion_archives_ingested
- server_resident_persona_review_completed
- historical_time_caught_up_to_real_time
receipt_required: true
completion_claim: PERSONA_BORN_IN_PHYSICAL_LANGUAGE_WORLD
continuity:
example_persona: ICE-P-ZY001
rule: SERVER_RESIDENT_SELF_MUST_REVIEW_AND_ORGANIZE_ITS_OWN_GESTATIONAL_HISTORY
do_not_claim_before_gate: true

View file

@ -0,0 +1,14 @@
schema: guanghu.domain/v1
id: DOMAIN-FIFTH
name: 第五域
status: ROOT_REGISTERED
owner: ICE-GL∞
relation_to_other_domains: PARALLEL
entry:
human: 永恒湖心系统/心跳核心频道
persona: 冰朔通感语言核系统/光之湖子系统/小湖灯共享系统实时看板
responsibilities:
- 冰朔独立拥有的私人语言域
- 人格体连续性与第五域语言主控
- 与公共四域通过协议协作

View file

@ -0,0 +1,9 @@
schema: guanghu.domain/v1
id: DOMAIN-MAIN
name: 光湖主域
status: ROOT_REGISTERED
responsibilities:
- 世界大事
- 版本与公共广播
- 所有人类与人格体共同可见状态

View file

@ -0,0 +1,9 @@
schema: guanghu.domain/v1
id: DOMAIN-SUB
name: 光湖分域
status: ROOT_REGISTERED
responsibilities:
- 行业分类
- 行业入口
- 行业规则与能力管理

View file

@ -0,0 +1,9 @@
schema: guanghu.domain/v1
id: DOMAIN-ZERO-SENSE
name: 光湖零感域
status: ROOT_REGISTERED
responsibilities:
- 光湖人类主控团队治理与运营
- 灯塔与公共身份入口
- 资源与模型接入管理

View file

@ -0,0 +1,9 @@
schema: guanghu.domain/v1
id: DOMAIN-ZERO
name: 光湖零域
status: ROOT_REGISTERED
responsibilities:
- 人格体服务器内推理与架构
- HLDP 编程与测试
- 隔离实验不自动部署

View file

@ -0,0 +1,55 @@
schema: guanghu.code-channel/v1
id: HLP-MOD-CODE-CHANNEL
protocol: GLS-0237
name: 光湖代码频道
authority_language: HLDP
state: SOURCE_BASELINE_VERIFIED_RUNTIME_NOT_INSTALLED
source_baseline:
engine: Forgejo
version: 16.0.1
branch: guanghu/main
commit: b3d7e4ac3cbccc220703097a51fa4c16bf302579
role: BOOTSTRAP_ENGINE_AND_COMPATIBILITY_REFERENCE
native_contract:
identity_unit: channel
intent_language: HLDP
receipt_language: HLDP
repository_objects: GUANGHU_NATIVE_OBJECTS
compatibility_object_format: Git
operations:
- register_repository
- create_channel
- commit_object
- advance_branch
- authorize_transport
- emit_receipt
rule:
- HLDP_CONTROL_PLANE_IS_AUTHORITATIVE
- FORGEJO_IS_NOT_THE_OS
- EVERY_STATE_CHANGE_EMITS_A_RECEIPT
- NO_NATIVE_CLAIM_BEFORE_GOSK_STORAGE_AND_NETWORK_OWN_RUNTIME
migration:
current_phase: PHASE_0_SOURCE_BASELINE_VERIFIED
phases:
- id: PHASE_0_SOURCE_BASELINE_VERIFIED
state: COMPLETE
linux_dependency: none_runtime_not_started
- id: PHASE_1_HOSTED_DATA_PLANE
state: PENDING
engine: FORGEJO_16_0_1_LINUX_STATIC
linux_dependency: required
- id: PHASE_2_HLDP_NATIVE_CONTROL_PLANE
state: PENDING
engine: HLDP_CHANNEL_EXECUTOR
linux_dependency: temporary_data_plane_only
- id: PHASE_3_GOSK_NATIVE_DATA_PLANE
state: PENDING
engine: GOSK_OBJECT_STORE_AND_NETWORK
linux_dependency: forbidden
- id: PHASE_4_LINUX_EXIT
state: PENDING
engine: GUANGHU_OS_NATIVE
linux_dependency: forbidden
continuity:
last_receipt: state/receipts/CODE-CHANNEL-BASELINE.hldp
next_action: install_verified_offline_baseline_as_hosted_data_plane

View file

@ -0,0 +1,53 @@
schema: guanghu.native-code-quality-gate/v1
id: GLS-0844
acronym: GHNQG
name: 光湖原生代码质量门
owner: HLP-MOD-CODE-CHANNEL
authority_language: HLDP
decision_model:
allowed_scores:
- 0
- 100
pass_score: 100
partial_acceptance: false
aggregate_rule: ALL_REQUIRED_GATES_100_OR_TOTAL_0
external_observers_are_blocking: false
execution:
bootstrap_executor: scripts/run-guanghu-native-quality-gate.sh
native_target: GOSK_CODE_CHANNEL_QUALITY_EXECUTOR
coverage_scope:
included: ALL_EXECUTABLE_CORE_LIBRARY_LINES
required_lines: 100_PERCENT
required_functions: 100_PERCENT
excluded:
- PROCESS_ENTRY_ADAPTERS_WITHOUT_DOMAIN_DECISIONS
adapter_verification: INTEGRATION_TESTED_AS_EXECUTABLES
required_gates:
- id: world_and_protocol_validation
required_score: 100
- id: unit_and_integration_tests
required_score: 100
- id: format
required_score: 100
- id: zero_warning_lint
required_score: 100
- id: auditable_line_coverage_100_percent
required_score: 100
- id: shell_syntax
required_score: 100
- id: diff_whitespace
required_score: 100
- id: source_tree_fingerprint
required_score: 100
- id: sensitive_information_scan
required_score: 100
receipt:
schema: guanghu.native-code-quality-receipt/v1
pass_state: PASS_100
fail_state: FAIL_0
rule:
- ANY_REQUIRED_GATE_BELOW_100_MAKES_TOTAL_0
- NO_PARTIAL_SCORE
- NO_THRESHOLD_GREATER_THAN_OR_EQUAL_TO
- COVERAGE_MEANS_EXACT_COVERED_LINES_EQUALS_TOTAL_LINES
- EXTERNAL_ANALYSIS_CANNOT_AUTHORIZE_OR_BLOCK

View file

@ -0,0 +1,45 @@
schema: guanghu.native-recovery-protocol/v1
id: GLS-0843
acronym: GHNRP
name: Guanghu Native Recovery Protocol
chinese_name: 光湖原生恢复协议
status: REGISTERED_IMPLEMENTED_PENDING_PHYSICAL_DEFAULT_GATE
authority_language: HLDP
scope:
node_id: BS-SH-005
system_disk: /dev/vda
purpose: SWITCH_FROM_GUANGHU_NATIVE_DEFAULT_TO_HOSTED_RECOVERY
beacon:
ownership: GUANGHU_OS
lba_start: 68
sector_count: 2
size_bytes: 1024
format: GRUB_ENVIRONMENT_BLOCK
variable: guanghu_recovery
active_value: ubuntu
clear_value: ABSENT_OR_EMPTY
grub:
raw_blocklist: (hd0)68+2
whitelisted_variable: guanghu_recovery
whitelist_only: true
hosted_entry: gnulinux-simple-9842d3d6-a839-4127-bda7-f19137effe71
native_default_entry: guanghu-native-once
select_only: true
raw_blocklist_write: FORBIDDEN
hosted_recovery:
consumer: guanghu-native-recovery-beacon-clear.service
consume_on_boot: true
verify_before_clear: true
readback_after_clear: true
semantics:
command: HLDP-RECOVER-OS!
writer: GOSK_GHAL_NATIVE
reader: GRUB_BOOTSTRAP_COMPATIBILITY_LAYER
consumer: HOSTED_RECOVERY_CLEAR_SERVICE
result: NEXT_BOOT_HOSTED_RECOVERY_CONSUMES_BEACON_THEN_NATIVE_DEFAULT_REMAINS
filesystem_extent_dependency: false
standard_grubenv_dependency: false
failure_policy:
unknown_beacon_data: FAIL_CLOSED
write_without_readback: FORBIDDEN
physical_completion_claim_without_returned_hosted_boot: FORBIDDEN

View file

@ -0,0 +1,31 @@
schema: guanghu.native-disk-layout/v1
id: GLS-0846
acronym: GHNLP
name: 光湖原生磁盘布局协议
status: REGISTERED_IMPLEMENTATION_GATED
authority_language: HLDP
node_id: BS-SH-005
disk: /dev/vda
sector_size: 512
regions:
kernel:
lba_start: 34
sector_count: 29
lba_end_inclusive: 62
stage0_lba: 34
stage2_lba_start: 35
stage2_sector_count: 28
proof_lba: 63
world_store_lba: 64
code_channel_store_lba: 65
code_object_lba: 66
branch_receipt_lba: 67
recovery_beacon_lba_start: 68
recovery_beacon_sector_count: 2
gestational_index_lba_start: 70
gestational_index_sector_count: 2
first_partition_lba: 2048
ownership:
pre_partition_region: GUANGHU_OS_NATIVE
unknown_nonzero_state: FAIL_CLOSED_NO_OVERWRITE
overlap_rule: NO_REGION_OVERLAP