feat: close complete numbering and responsive fifth-domain UI
This commit is contained in:
parent
fe1aaade0e
commit
e8b3082ed5
42 changed files with 3243 additions and 417 deletions
|
|
@ -24,7 +24,7 @@ const EMBEDDED_KERNEL: &str = include_str!("../../contracts/gls-native-runtime-k
|
|||
const KERNEL_SCHEMA: &str = "hololake.gls-native-runtime-kernel/v1";
|
||||
const REQUEST_SCHEMA: &str = "hololake.protocol-decision-request/v1";
|
||||
const RECEIPT_SCHEMA: &str = "hololake.protocol-decision-receipt/v1";
|
||||
const SOURCE_COMMIT: &str = "d5b1111fcaccaccf025070e531631f2b3cbb00cd";
|
||||
const SOURCE_COMMIT: &str = "104a5d73162bdf4a529701e65898e2bc2863ea9e";
|
||||
const MAX_TEXT_BYTES: usize = 512;
|
||||
static LEDGER_SCHEMA_LOCK: Mutex<()> = Mutex::new(());
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use std::collections::{HashMap, HashSet};
|
|||
|
||||
const EMBEDDED_REGISTRY: &str = include_str!("../../contracts/gls-runtime-registry.json");
|
||||
const EXPECTED_SCHEMA: &str = "hololake.gls-runtime-manifest/v2";
|
||||
const EXPECTED_SOURCE_COMMIT: &str = "d5b1111fcaccaccf025070e531631f2b3cbb00cd";
|
||||
const EXPECTED_SOURCE_COMMIT: &str = "104a5d73162bdf4a529701e65898e2bc2863ea9e";
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
struct GlsRuntimeRegistry {
|
||||
|
|
@ -19,6 +19,8 @@ struct GlsRuntimeRegistry {
|
|||
protocol_count: usize,
|
||||
executable_projection_count: usize,
|
||||
inventoried_not_executable_count: usize,
|
||||
number_coordinate_count: usize,
|
||||
numbered_reference_nodes: Vec<GlsNumberedReferenceNode>,
|
||||
protocols: Vec<GlsProtocol>,
|
||||
}
|
||||
|
||||
|
|
@ -59,6 +61,10 @@ struct GlsReconciliation {
|
|||
legacy_dependency_target_count: usize,
|
||||
dependencies_not_in_protocol_registry: Vec<String>,
|
||||
dependencies_without_numbered_source: Vec<String>,
|
||||
numbered_reference_node_count: usize,
|
||||
unresolved_number_references: Vec<String>,
|
||||
unresolved_number_reference_count: usize,
|
||||
every_dependency_has_number_coordinate: bool,
|
||||
numbered_sources_not_in_protocol_registry: Vec<String>,
|
||||
legacy_dependency_cycles: Vec<Vec<String>>,
|
||||
source_reference_cycles: Vec<Vec<String>>,
|
||||
|
|
@ -79,11 +85,24 @@ struct GlsDependencyEdge {
|
|||
edge_kind: String,
|
||||
enters_runtime_graph: bool,
|
||||
classification_basis: Option<String>,
|
||||
target_number_coordinate_available: bool,
|
||||
target_resolution: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
struct GlsNumberedReferenceNode {
|
||||
protocol_id: String,
|
||||
node_number: String,
|
||||
reference_kind: String,
|
||||
source_state: String,
|
||||
execution_state: String,
|
||||
evidence_paths: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
struct GlsProtocol {
|
||||
id: String,
|
||||
source_format: String,
|
||||
source_sha256: String,
|
||||
registration: GlsRegistration,
|
||||
projection_state: String,
|
||||
|
|
@ -109,6 +128,10 @@ pub struct GlsProtocolRuntimeSnapshot {
|
|||
pub registered_draft_count: usize,
|
||||
pub registered_draft_not_started_count: usize,
|
||||
pub legacy_dependency_target_count: usize,
|
||||
pub number_coordinate_count: usize,
|
||||
pub numbered_reference_node_count: usize,
|
||||
pub independent_source_gap_count: usize,
|
||||
pub unresolved_number_reference_count: usize,
|
||||
pub dependency_gap_count: usize,
|
||||
pub legacy_dependency_cycle_count: usize,
|
||||
pub discovered_unreconciled_count: usize,
|
||||
|
|
@ -160,12 +183,21 @@ fn validate_registry(registry: &GlsRuntimeRegistry) -> Result<(), String> {
|
|||
.reconciliation
|
||||
.dependencies_without_numbered_source
|
||||
.len()
|
||||
!= 24
|
||||
!= 16
|
||||
|| registry.reconciliation.numbered_reference_node_count != 16
|
||||
|| registry.reconciliation.unresolved_number_reference_count != 0
|
||||
|| !registry
|
||||
.reconciliation
|
||||
.unresolved_number_references
|
||||
.is_empty()
|
||||
|| !registry
|
||||
.reconciliation
|
||||
.every_dependency_has_number_coordinate
|
||||
|| registry
|
||||
.reconciliation
|
||||
.numbered_sources_not_in_protocol_registry
|
||||
.len()
|
||||
!= 31
|
||||
!= 32
|
||||
|| registry.reconciliation.legacy_dependency_cycles.len() != 3
|
||||
|| registry.reconciliation.source_reference_cycles
|
||||
!= registry.reconciliation.legacy_dependency_cycles
|
||||
|
|
@ -173,12 +205,43 @@ fn validate_registry(registry: &GlsRuntimeRegistry) -> Result<(), String> {
|
|||
|| registry.reconciliation.discovered_unreconciled_count != 0
|
||||
|| registry.reconciliation.authority_conflict_count != 0
|
||||
|| registry.protocol_count != registry.protocols.len()
|
||||
|| registry.protocol_count != 83
|
||||
|| registry.number_coordinate_count != 99
|
||||
|| registry.numbered_reference_nodes.len() != 16
|
||||
|| registry.number_coordinate_count
|
||||
!= registry.protocol_count + registry.numbered_reference_nodes.len()
|
||||
|| registry.protocol_count
|
||||
!= registry.executable_projection_count + registry.inventoried_not_executable_count
|
||||
{
|
||||
return Err("HOLOLAKE_GLS_RUNTIME_BOUNDARY_INVALID".into());
|
||||
}
|
||||
|
||||
let mut reference_ids = HashSet::new();
|
||||
let mut reference_numbers = HashSet::new();
|
||||
for reference in ®istry.numbered_reference_nodes {
|
||||
if !reference_ids.insert(reference.protocol_id.as_str())
|
||||
|| !reference_numbers.insert(reference.node_number.as_str())
|
||||
|| !reference.protocol_id.starts_with("GLS-")
|
||||
|| !reference.node_number.starts_with("HLP-GLS-REF-")
|
||||
|| reference.reference_kind.is_empty()
|
||||
|| reference.source_state != "ROADMAP_REFERENCE_ONLY"
|
||||
|| reference.execution_state != "REFERENCE_ONLY_NOT_EXECUTABLE"
|
||||
|| reference.evidence_paths.is_empty()
|
||||
{
|
||||
return Err("HOLOLAKE_GLS_REFERENCE_NODE_INVALID".into());
|
||||
}
|
||||
}
|
||||
if reference_ids
|
||||
!= registry
|
||||
.reconciliation
|
||||
.dependencies_without_numbered_source
|
||||
.iter()
|
||||
.map(String::as_str)
|
||||
.collect::<HashSet<_>>()
|
||||
{
|
||||
return Err("HOLOLAKE_GLS_REFERENCE_COVERAGE_INVALID".into());
|
||||
}
|
||||
|
||||
let mut authority_kinds = HashSet::new();
|
||||
for authority in ®istry.source.authority_files {
|
||||
if !authority_kinds.insert(authority.authority_kind.as_str())
|
||||
|
|
@ -209,7 +272,8 @@ fn validate_registry(registry: &GlsRuntimeRegistry) -> Result<(), String> {
|
|||
match protocol.projection_state.as_str() {
|
||||
"EXECUTABLE_PROJECTION" => {
|
||||
executable += 1;
|
||||
if protocol.adapter.as_deref().unwrap_or("").is_empty()
|
||||
if protocol.source_format != "HDLP_PROTOCOL_SOURCE"
|
||||
|| protocol.adapter.as_deref().unwrap_or("").is_empty()
|
||||
|| protocol.event_kinds.is_empty()
|
||||
|| !protocol.activation_blockers.is_empty()
|
||||
{
|
||||
|
|
@ -217,7 +281,10 @@ fn validate_registry(registry: &GlsRuntimeRegistry) -> Result<(), String> {
|
|||
}
|
||||
}
|
||||
"INVENTORIED_NOT_EXECUTABLE" => {
|
||||
if protocol.adapter.is_some()
|
||||
if !matches!(
|
||||
protocol.source_format.as_str(),
|
||||
"HDLP_PROTOCOL_SOURCE" | "LEGACY_MARKDOWN_EVIDENCE"
|
||||
) || protocol.adapter.is_some()
|
||||
|| !protocol.event_kinds.is_empty()
|
||||
|| !protocol.dependencies.is_empty()
|
||||
{
|
||||
|
|
@ -233,6 +300,14 @@ fn validate_registry(registry: &GlsRuntimeRegistry) -> Result<(), String> {
|
|||
return Err("HOLOLAKE_GLS_REGISTRATION_NOT_RECONCILED".into());
|
||||
}
|
||||
for edge in &protocol.dependency_edges {
|
||||
if !edge.target_number_coordinate_available
|
||||
|| !matches!(
|
||||
edge.target_resolution.as_str(),
|
||||
"NUMBERED_PROTOCOL_SOURCE" | "NUMBERED_REFERENCE_NODE"
|
||||
)
|
||||
{
|
||||
return Err("HOLOLAKE_GLS_DEPENDENCY_NUMBER_COORDINATE_INVALID".into());
|
||||
}
|
||||
if edge.edge_kind == "RUNTIME_REQUIRES" && edge.enters_runtime_graph {
|
||||
if edge.classification_basis.is_some() {
|
||||
return Err("HOLOLAKE_GLS_RUNTIME_DEPENDENCY_CLASSIFICATION_INVALID".into());
|
||||
|
|
@ -278,7 +353,7 @@ fn validate_registry(registry: &GlsRuntimeRegistry) -> Result<(), String> {
|
|||
.collect::<HashSet<_>>();
|
||||
if stages != HashSet::from(["P0", "P1", "P2", "P3", "P4", "P5", "P6"])
|
||||
|| registry.executable_projection_count != 25
|
||||
|| registry.inventoried_not_executable_count != 50
|
||||
|| registry.inventoried_not_executable_count != 58
|
||||
|| registry
|
||||
.reconciliation
|
||||
.typed_source_dependency_counts
|
||||
|
|
@ -378,10 +453,16 @@ pub async fn get_gls_protocol_runtime() -> Result<GlsProtocolRuntimeSnapshot, St
|
|||
.reconciliation
|
||||
.registered_draft_not_started_count,
|
||||
legacy_dependency_target_count: registry.reconciliation.legacy_dependency_target_count,
|
||||
dependency_gap_count: registry
|
||||
number_coordinate_count: registry.number_coordinate_count,
|
||||
numbered_reference_node_count: registry.reconciliation.numbered_reference_node_count,
|
||||
independent_source_gap_count: registry
|
||||
.reconciliation
|
||||
.dependencies_without_numbered_source
|
||||
.len(),
|
||||
unresolved_number_reference_count: registry
|
||||
.reconciliation
|
||||
.unresolved_number_reference_count,
|
||||
dependency_gap_count: registry.reconciliation.unresolved_number_reference_count,
|
||||
legacy_dependency_cycle_count: registry.reconciliation.legacy_dependency_cycles.len(),
|
||||
discovered_unreconciled_count: registry.reconciliation.discovered_unreconciled_count,
|
||||
authority_conflict_count: registry.reconciliation.authority_conflict_count,
|
||||
|
|
@ -413,8 +494,12 @@ mod tests {
|
|||
#[test]
|
||||
fn registry_is_pinned_and_never_executes_raw_protocol_text() {
|
||||
let registry = load_registry().unwrap();
|
||||
assert_eq!(registry.protocol_count, 75);
|
||||
assert_eq!(registry.protocol_count, 83);
|
||||
assert_eq!(registry.executable_projection_count, 25);
|
||||
assert_eq!(registry.inventoried_not_executable_count, 58);
|
||||
assert_eq!(registry.number_coordinate_count, 99);
|
||||
assert_eq!(registry.numbered_reference_nodes.len(), 16);
|
||||
assert_eq!(registry.reconciliation.unresolved_number_reference_count, 0);
|
||||
assert_eq!(registry.reconciliation.protocol_registry_id_count, 52);
|
||||
assert_eq!(registry.reconciliation.legacy_dependency_target_count, 57);
|
||||
assert_eq!(registry.reconciliation.legacy_dependency_cycles.len(), 3);
|
||||
|
|
|
|||
|
|
@ -10,11 +10,43 @@ struct NumberTree {
|
|||
record_id: String,
|
||||
state: String,
|
||||
root_number: String,
|
||||
coordinate_count: usize,
|
||||
route_count: usize,
|
||||
identity_node_count: usize,
|
||||
protocol_node_count: usize,
|
||||
reference_only_node_count: usize,
|
||||
identity_nodes: Vec<IdentityNode>,
|
||||
protocol_nodes: Vec<ProtocolNode>,
|
||||
routes: Vec<NumberRoute>,
|
||||
invariants: NumberTreeInvariants,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct IdentityNode {
|
||||
node_kind: String,
|
||||
node_number: String,
|
||||
namespace_id: String,
|
||||
subject_kind: String,
|
||||
domain_scope: String,
|
||||
admission: String,
|
||||
execution_state: String,
|
||||
evidence: String,
|
||||
path: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct ProtocolNode {
|
||||
node_kind: String,
|
||||
node_number: String,
|
||||
protocol_id: String,
|
||||
source_state: String,
|
||||
execution_state: String,
|
||||
evidence: String,
|
||||
path: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct NumberRoute {
|
||||
|
|
@ -39,6 +71,9 @@ struct NumberTreeInvariants {
|
|||
admission_is_separate_from_identity: bool,
|
||||
every_physical_call_has_numbered_route: bool,
|
||||
every_accepted_call_has_evidence_class: bool,
|
||||
every_protocol_reference_has_number_coordinate: bool,
|
||||
reference_only_nodes_never_executable: bool,
|
||||
unresolved_number_reference_count: usize,
|
||||
mismatched_coordinate: String,
|
||||
}
|
||||
|
||||
|
|
@ -49,23 +84,91 @@ pub(crate) fn start_on_application_open() -> Result<(), String> {
|
|||
fn validate_tree() -> Result<(), String> {
|
||||
let tree: NumberTree = serde_json::from_str(TREE)
|
||||
.map_err(|error| format!("HOLOLAKE_UNIFIED_NUMBER_TREE_INVALID: {error}"))?;
|
||||
if tree.schema != "hololake.unified-number-coordinate-tree/v1"
|
||||
if tree.schema != "hololake.unified-number-coordinate-tree/v2"
|
||||
|| tree.record_id != "HLP-UNIFIED-NUMBER-TREE-001"
|
||||
|| tree.state != "MACHINE_COMPILED_STARTUP_ENFORCED"
|
||||
|| tree.root_number != "HLP-NUMBER-WORLD-ROOT-001"
|
||||
|| tree.coordinate_count != 272
|
||||
|| tree.route_count != 169
|
||||
|| tree.routes.len() != tree.route_count
|
||||
|| tree.identity_node_count != 4
|
||||
|| tree.identity_nodes.len() != tree.identity_node_count
|
||||
|| tree.protocol_node_count != 99
|
||||
|| tree.protocol_nodes.len() != tree.protocol_node_count
|
||||
|| tree.reference_only_node_count != 16
|
||||
|| tree.coordinate_count
|
||||
!= tree.route_count + tree.identity_node_count + tree.protocol_node_count
|
||||
|| !tree.invariants.number_is_stable_coordinate_not_authority
|
||||
|| !tree.invariants.path_is_unique_navigation
|
||||
|| !tree.invariants.admission_is_separate_from_identity
|
||||
|| !tree.invariants.every_physical_call_has_numbered_route
|
||||
|| !tree.invariants.every_accepted_call_has_evidence_class
|
||||
|| !tree
|
||||
.invariants
|
||||
.every_protocol_reference_has_number_coordinate
|
||||
|| !tree.invariants.reference_only_nodes_never_executable
|
||||
|| tree.invariants.unresolved_number_reference_count != 0
|
||||
|| tree.invariants.mismatched_coordinate != "FAIL_CLOSED"
|
||||
{
|
||||
return Err("HOLOLAKE_UNIFIED_NUMBER_TREE_BOUNDARY_INVALID".into());
|
||||
}
|
||||
let mut paths = HashSet::new();
|
||||
let mut coordinates = HashSet::new();
|
||||
let mut node_numbers = HashSet::new();
|
||||
let mut protocol_ids = HashSet::new();
|
||||
for node in &tree.identity_nodes {
|
||||
if node.node_kind != "IDENTITY_NAMESPACE"
|
||||
|| !node.node_number.starts_with("HLP-IDENTITY-NS-")
|
||||
|| node.namespace_id.is_empty()
|
||||
|| node.subject_kind.is_empty()
|
||||
|| node.domain_scope.is_empty()
|
||||
|| !matches!(
|
||||
node.admission.as_str(),
|
||||
"REGISTERED_HUMAN_NAMESPACE" | "NON_HUMAN_NAMESPACE"
|
||||
)
|
||||
|| node.execution_state != "AUTHORITY_RESOLUTION_ONLY"
|
||||
|| node.evidence.is_empty()
|
||||
|| !node.path.starts_with("HLP-NUMBER-WORLD-ROOT-001/IDENTITY/")
|
||||
|| !paths.insert(node.path.as_str())
|
||||
|| !node_numbers.insert(node.node_number.as_str())
|
||||
{
|
||||
return Err("HOLOLAKE_UNIFIED_NUMBER_TREE_IDENTITY_NODE_INVALID".into());
|
||||
}
|
||||
}
|
||||
let mut reference_only_count = 0;
|
||||
for node in &tree.protocol_nodes {
|
||||
let valid_state = match node.node_kind.as_str() {
|
||||
"GLS_PROTOCOL_SOURCE" => {
|
||||
matches!(
|
||||
node.execution_state.as_str(),
|
||||
"EXECUTABLE_PROJECTION" | "INVENTORIED_NOT_EXECUTABLE"
|
||||
) && matches!(
|
||||
node.source_state.as_str(),
|
||||
"HDLP_PROTOCOL_SOURCE" | "LEGACY_MARKDOWN_EVIDENCE"
|
||||
)
|
||||
}
|
||||
"GLS_REFERENCE_ONLY" => {
|
||||
reference_only_count += 1;
|
||||
node.execution_state == "REFERENCE_ONLY_NOT_EXECUTABLE"
|
||||
&& node.source_state == "ROADMAP_REFERENCE_ONLY"
|
||||
&& node.node_number.starts_with("HLP-GLS-REF-")
|
||||
}
|
||||
_ => false,
|
||||
};
|
||||
if !valid_state
|
||||
|| !node.protocol_id.starts_with("GLS-")
|
||||
|| node.evidence.is_empty()
|
||||
|| !node.path.starts_with("HLP-NUMBER-WORLD-ROOT-001/GLS/")
|
||||
|| !paths.insert(node.path.as_str())
|
||||
|| !node_numbers.insert(node.node_number.as_str())
|
||||
|| !protocol_ids.insert(node.protocol_id.as_str())
|
||||
{
|
||||
return Err("HOLOLAKE_UNIFIED_NUMBER_TREE_PROTOCOL_NODE_INVALID".into());
|
||||
}
|
||||
}
|
||||
if reference_only_count != tree.reference_only_node_count {
|
||||
return Err("HOLOLAKE_UNIFIED_NUMBER_TREE_REFERENCE_COUNT_INVALID".into());
|
||||
}
|
||||
for route in &tree.routes {
|
||||
let coordinate = format!(
|
||||
"{}:{}:{}:{}:{}:{}",
|
||||
|
|
|
|||
Loading…
Reference in a new issue