182 lines
13 KiB
JavaScript
182 lines
13 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import test from "node:test";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
const readJson = (relative) => JSON.parse(fs.readFileSync(path.join(root, relative), "utf8"));
|
|
const contract = readJson("routing/guanghu-os-control-architecture.json");
|
|
const architecture = readJson("routing/hololake-current-architecture.json");
|
|
const rules = readJson("routing/hololake-engineering-rules.json");
|
|
const serviceContract = readJson(
|
|
"product-source/hololake-platform/guanghu-os/standards/jd-native-service-equivalence-contract.json",
|
|
);
|
|
const projectionContract = readJson(
|
|
"product-source/hololake-platform/guanghu-os/standards/jd-native-public-projection-contract.json",
|
|
);
|
|
const forgejoContract = readJson(
|
|
"product-source/hololake-platform/guanghu-os/standards/jd-independent-forgejo-continuity-contract.json",
|
|
);
|
|
|
|
test("final topology makes Guanghu the master while preserving Linux as on-demand subcontrol and rescue", () => {
|
|
assert.equal(contract.final_topology, "GUANGHU_MASTER_WITH_ON_DEMAND_LINUX_SUBCONTROL_AND_RESCUE");
|
|
assert.equal(contract.control_ownership.normal_entry, "GUANGHU_OS");
|
|
assert.equal(contract.control_ownership.execution_lifecycle, "GUANGHU_OS");
|
|
assert.equal(contract.linux_role.deleted, false);
|
|
assert.equal(contract.linux_role.normally_running_full_os, false);
|
|
assert.equal(contract.linux_role.on_demand_subcontrol, true);
|
|
assert.equal(contract.linux_role.independent_rescue_channel, true);
|
|
assert.equal(contract.acceptance.linux_absence_required, false);
|
|
assert.equal(contract.acceptance.linux_deletion_required, false);
|
|
});
|
|
|
|
test("current JD state stays transitional and cannot impersonate final master control", () => {
|
|
assert.equal(
|
|
contract.jd_fd_primary.observed_state,
|
|
"LANGUAGE_PRIMARY_WITH_QEMU_VERIFIED_PRE_ROOT_GUANGHU_SUPERVISOR",
|
|
);
|
|
assert.equal(contract.jd_fd_primary.guanghu_semantic_service_control, 100);
|
|
assert.equal(contract.jd_fd_primary.guanghu_final_boot_control, 0);
|
|
assert.equal(contract.jd_fd_primary.linux_on_demand_subcontrol, 0);
|
|
assert.equal(contract.jd_fd_primary.linux_rescue_preserved, 100);
|
|
assert.equal(contract.jd_fd_primary.final_guanghu_os_master, 0);
|
|
assert.equal(
|
|
contract.jd_fd_primary.next_engineering_gate,
|
|
"BUILD_AND_VERIFY_CROSS_SWITCH_ROOT_PERSISTENT_GUANGHU_SUPERVISOR_IN_JD_HOST_QEMU",
|
|
);
|
|
});
|
|
|
|
test("the physical shadow and host QEMU cycles are registered without impersonating Guanghu-owned boot control", () => {
|
|
assert.equal(contract.version, "2026-08-15.12");
|
|
assert.equal(contract.implementation.guanghu_supervisor_lifecycle_contract_source, 100);
|
|
assert.equal(contract.implementation.target_readback_and_mandatory_reclaim_state_machine, 100);
|
|
assert.equal(contract.implementation.declared_supervisor_core_line_and_function_coverage, 100);
|
|
assert.equal(contract.implementation.docker_shadow_backend_source_and_isolation_contract, 100);
|
|
assert.equal(contract.implementation.linux_hosted_isolated_shadow_backend, 100);
|
|
assert.equal(contract.implementation.real_isolated_linux_backend, 0);
|
|
assert.equal(contract.implementation.jd_shadow_backend_physical_cycle, 100);
|
|
assert.equal(contract.implementation.native_service_equivalence_contract_source, 100);
|
|
assert.equal(contract.implementation.native_anchor_http_qemu_capability, 100);
|
|
assert.equal(contract.implementation.native_code_channel_read_only_qemu_capability, 100);
|
|
assert.equal(contract.implementation.jd_physical_host_isolated_qemu_capability, 100);
|
|
assert.equal(contract.implementation.native_public_projection_contract_source, 100);
|
|
assert.equal(contract.implementation.native_public_projection_isolated_end_to_end_test, 100);
|
|
assert.equal(contract.implementation.bs_gz_shadow_projection_receiver, 100);
|
|
assert.equal(contract.implementation.bs_sg_authenticated_projection_sender, 100);
|
|
assert.equal(contract.implementation.live_native_projection_freshness, 0);
|
|
assert.equal(contract.implementation.nginx_native_projection_route_switch, 0);
|
|
assert.equal(contract.implementation.independent_forgejo_continuity_contract_source, 100);
|
|
assert.equal(contract.implementation.independent_forgejo_shadow_verifier_test, 100);
|
|
assert.equal(contract.implementation.bs_sg_full_forgejo_shadow, 0);
|
|
assert.equal(contract.implementation.bs_gz_to_bs_sg_forgejo_tunnel, 0);
|
|
assert.equal(contract.implementation.nginx_code_route_switch, 0);
|
|
assert.equal(contract.implementation.public_native_anchor_equivalence, 0);
|
|
assert.equal(contract.implementation.public_native_code_channel_equivalence, 0);
|
|
assert.equal(contract.implementation.full_forgejo_equivalence, 0);
|
|
assert.equal(contract.implementation.independent_guanghu_hosted_supervisor_bridge, 100);
|
|
assert.equal(contract.implementation.linux_code_bridge_under_guanghu_supervisor, 100);
|
|
assert.equal(contract.implementation.guanghu_pre_root_supervisor_contract_source, 100);
|
|
assert.equal(contract.implementation.guanghu_first_boot_initramfs_builder_source, 100);
|
|
assert.equal(contract.implementation.jd_host_qemu_pre_root_supervisor, 100);
|
|
assert.equal(contract.implementation.guanghu_root_supervisor_contract_source, 100);
|
|
assert.equal(contract.implementation.guanghu_root_supervisor_systemd_unit_source, 100);
|
|
assert.equal(contract.implementation.guanghu_cross_root_fixture_builder_source, 100);
|
|
assert.equal(contract.implementation.jd_host_qemu_cross_switch_root_supervisor, 0);
|
|
assert.equal(contract.implementation.independent_guanghu_first_boot_supervisor, 0);
|
|
assert.equal(contract.implementation.jd_physical_deployment, 0);
|
|
assert.equal(contract.current_target_evidence.final_state, "DORMANT");
|
|
assert.match(contract.current_target_evidence.server_receipt_sha256, /^[0-9a-f]{64}$/);
|
|
assert.equal(contract.native_service_qemu_evidence.native_physical_residency, 0);
|
|
assert.equal(contract.native_service_qemu_evidence.public_native_service_equivalence, 0);
|
|
assert.match(contract.native_service_qemu_evidence.server_receipt_sha256, /^[0-9a-f]{64}$/);
|
|
assert.equal(contract.pre_root_supervisor_qemu_evidence.positive_pre_root_execution, 100);
|
|
assert.equal(contract.pre_root_supervisor_qemu_evidence.negative_authority_binding_hard_fail, 100);
|
|
assert.equal(contract.pre_root_supervisor_qemu_evidence.physical_boot_files_changed, false);
|
|
assert.equal(contract.pre_root_supervisor_qemu_evidence.physical_reboot_performed, false);
|
|
assert.equal(contract.pre_root_supervisor_qemu_evidence.cross_switch_root_persistent_supervisor, 0);
|
|
assert.equal(contract.pre_root_supervisor_qemu_evidence.final_guanghu_os_master, 0);
|
|
assert.match(contract.pre_root_supervisor_qemu_evidence.server_receipt_sha256, /^[0-9a-f]{64}$/);
|
|
assert.equal(contract.native_public_projection_shadow_evidence.synthetic_ready_shadow_readback, 100);
|
|
assert.equal(contract.native_public_projection_shadow_evidence.post_test_state, "DORMANT");
|
|
assert.equal(contract.native_public_projection_shadow_evidence.live_native_freshness_readback, 0);
|
|
assert.equal(contract.native_public_projection_shadow_evidence.nginx_public_route_switched, 0);
|
|
assert.match(contract.native_public_projection_shadow_evidence.bs_gz_server_receipt_sha256, /^[0-9a-f]{64}$/);
|
|
assert.match(contract.native_public_projection_shadow_evidence.bs_sg_server_receipt_sha256, /^[0-9a-f]{64}$/);
|
|
assert.equal(contract.guard_cleanup_evidence.bs_gz_duplicate_forgejo_guard_removed, 100);
|
|
assert.equal(contract.guard_cleanup_evidence.preserved_live_forgejo_http, 200);
|
|
assert.equal(contract.guard_cleanup_evidence.public_code_http_after, 200);
|
|
assert.equal(contract.guard_cleanup_evidence.data_deleted, false);
|
|
assert.match(contract.guard_cleanup_evidence.server_receipt_sha256, /^[0-9a-f]{64}$/);
|
|
assert.equal(contract.hosted_supervisor_bridge_evidence.guanghu_supervisor_service_active, 100);
|
|
assert.equal(contract.hosted_supervisor_bridge_evidence.repository_bridge_dependency_bound, 100);
|
|
assert.equal(contract.hosted_supervisor_bridge_evidence.repository_process_preserved, 100);
|
|
assert.equal(contract.hosted_supervisor_bridge_evidence.public_code_http, 200);
|
|
assert.equal(contract.hosted_supervisor_bridge_evidence.public_anchor_http, 200);
|
|
assert.equal(contract.hosted_supervisor_bridge_evidence.linux_shadow_backend_post_state, "DORMANT");
|
|
assert.equal(contract.hosted_supervisor_bridge_evidence.linux_rescue_preserved, 100);
|
|
assert.equal(contract.hosted_supervisor_bridge_evidence.independent_guanghu_boot_control, 0);
|
|
assert.equal(contract.hosted_supervisor_bridge_evidence.final_guanghu_os_master, 0);
|
|
assert.match(contract.hosted_supervisor_bridge_evidence.server_receipt_sha256, /^[0-9a-f]{64}$/);
|
|
});
|
|
|
|
test("full Forgejo continuity remains separate from the read-only native code snapshot", () => {
|
|
assert.equal(forgejoContract.source_binding.node_id, "JD-FD-PRIMARY");
|
|
assert.equal(forgejoContract.source_binding.repository_count, 7);
|
|
assert.equal(forgejoContract.shadow_binding.node_id, "BS-SG-003");
|
|
assert.equal(forgejoContract.shadow_binding.publicly_reachable, false);
|
|
assert.equal(forgejoContract.migration_policy.online_snapshot_is_cutover_authority, false);
|
|
assert.equal(forgejoContract.migration_policy.final_cutover_requires_bounded_write_freeze, true);
|
|
assert.equal(forgejoContract.acceptance_gates.verifier_source, 100);
|
|
assert.equal(forgejoContract.acceptance_gates.isolated_verifier_test, 100);
|
|
assert.equal(forgejoContract.acceptance_gates.bs_sg_full_forgejo_shadow_deployed, 0);
|
|
assert.equal(forgejoContract.acceptance_gates.bs_gz_to_bs_sg_authenticated_tunnel, 0);
|
|
assert.equal(forgejoContract.acceptance_gates.nginx_code_route_switched, 0);
|
|
assert.equal(forgejoContract.acceptance_gates.full_forgejo_equivalence, 0);
|
|
assert.equal(forgejoContract.acceptance_gates.production_native_cutover, 0);
|
|
});
|
|
|
|
test("native public projection separates liveness, authenticated state, and pinned public bytes", () => {
|
|
assert.deepEqual(projectionContract.causal_route, ["JD-FD-PRIMARY", "BS-SG-003", "BS-GZ-006"]);
|
|
assert.equal(projectionContract.authentication.native_to_relay.may_supply_public_content, false);
|
|
assert.equal(projectionContract.public_bytes.provenance, "PINNED_REPO_012_SNAPSHOT");
|
|
assert.equal(projectionContract.public_bytes.relay_may_supply_or_mutate_bytes, false);
|
|
assert.equal(projectionContract.public_bytes.full_forgejo_equivalence, false);
|
|
assert.equal(projectionContract.front_door_projection.listen_scope, "LOOPBACK_ONLY");
|
|
assert.equal(projectionContract.front_door_projection.nginx_route_switch_authorized, false);
|
|
assert.equal(projectionContract.acceptance_gates.contract_source, 100);
|
|
assert.equal(projectionContract.acceptance_gates.isolated_end_to_end_test, 100);
|
|
assert.equal(projectionContract.acceptance_gates.bs_gz_shadow_receiver_deployed, 100);
|
|
assert.equal(projectionContract.acceptance_gates.bs_sg_authenticated_projector_deployed, 100);
|
|
assert.equal(projectionContract.acceptance_gates.live_native_freshness_readback, 0);
|
|
assert.equal(projectionContract.acceptance_gates.nginx_public_route_switched, 0);
|
|
assert.equal(projectionContract.acceptance_gates.public_native_anchor_equivalence, 0);
|
|
assert.equal(projectionContract.acceptance_gates.public_native_code_channel_equivalence, 0);
|
|
assert.equal(projectionContract.acceptance_gates.full_forgejo_equivalence, 0);
|
|
assert.equal(projectionContract.acceptance_gates.production_native_cutover, 0);
|
|
});
|
|
|
|
test("current architecture and global engineering rules project the same control contract", () => {
|
|
assert.equal(architecture.version, "2026-08-14.1");
|
|
assert.equal(architecture.server_os_control.machine_projection, "routing/guanghu-os-control-architecture.json");
|
|
assert.equal(architecture.server_os_control.final_topology, contract.final_topology);
|
|
assert.equal(rules.server_os_control.linux_deletion_is_completion, false);
|
|
assert.equal(rules.server_os_control.linux_hosted_language_primary_is_final_master, false);
|
|
assert.equal(rules.server_os_control.live_readback_predicates_required, true);
|
|
});
|
|
|
|
test("native service surface is exact while every physical and public claim remains zero", () => {
|
|
assert.equal(serviceContract.node_id, "JD-FD-PRIMARY");
|
|
assert.deepEqual(
|
|
serviceContract.native_read_only_surface.map((endpoint) => endpoint.path),
|
|
["/v1/anchor", "/v1/code-channel"],
|
|
);
|
|
assert.equal(serviceContract.accepted_repository.commit, "fb1096c5ecdcfb36015d51273f487c2f36d9c9cd");
|
|
assert.equal(serviceContract.acceptance_gates.native_anchor_qemu, 100);
|
|
assert.equal(serviceContract.acceptance_gates.native_code_channel_read_only_qemu, 100);
|
|
assert.equal(serviceContract.acceptance_gates.native_physical_readback, 0);
|
|
assert.equal(serviceContract.acceptance_gates.public_anchor_during_native_residency, 0);
|
|
assert.equal(serviceContract.acceptance_gates.public_code_during_native_residency, 0);
|
|
assert.equal(serviceContract.acceptance_gates.full_forgejo_equivalence, 0);
|
|
assert.equal(serviceContract.acceptance_gates.production_native_cutover, 0);
|
|
});
|