refactor: move layer facades to subfolders as mod.zig

Move public API re-exports from repo root to layer subfolders:
- l0_transport.zig → l0-transport/mod.zig
- l1_identity.zig → l1-identity/mod.zig
- l2_session.zig → l2_session/mod.zig

Update build.zig to use mod.zig as root_source_file for:
- l0_mod (was lwf.zig)
- l1_mod (was crypto.zig)

Cleans up repo root and establishes consistent module structure.
This commit is contained in:
Markus Maiwald 2026-02-05 15:40:45 +01:00
parent c8435a65df
commit d23ab3dba4
Signed by: markus
GPG Key ID: 07DDBEA3CBDC090A
6 changed files with 45 additions and 125 deletions

View File

@ -21,7 +21,7 @@ pub fn build(b: *std.Build) void {
// L0: Transport Layer
// ========================================================================
const l0_mod = b.createModule(.{
.root_source_file = b.path("l0-transport/lwf.zig"),
.root_source_file = b.path("l0-transport/mod.zig"),
.target = target,
.optimize = optimize,
});
@ -134,7 +134,7 @@ pub fn build(b: *std.Build) void {
// L1: Identity & Crypto Layer
// ========================================================================
const l1_mod = b.createModule(.{
.root_source_file = b.path("l1-identity/crypto.zig"),
.root_source_file = b.path("l1-identity/mod.zig"),
.target = target,
.optimize = optimize,
});

View File

@ -1,19 +1,19 @@
const std = @import("std");
// Re-export LWF (Libertaria Wire Frame)
pub const lwf = @import("l0-transport/lwf.zig");
pub const lwf = @import("lwf.zig");
// Re-export Time primitives
pub const time = @import("l0-transport/time.zig");
pub const time = @import("time.zig");
// Re-export UTCP (UDP Transport)
pub const utcp = @import("l0-transport/utcp.zig");
pub const utcp = @import("utcp/utcp.zig");
// Re-export OPQ (Offline Packet Queue)
pub const opq = @import("l0-transport/opq.zig");
pub const opq = @import("opq.zig");
// Re-export Integrated Service (UTCP + OPQ)
pub const service = @import("l0-transport/service.zig");
pub const service = @import("service.zig");
test {
std.testing.refAllDecls(@This());

17
l1-identity/mod.zig Normal file
View File

@ -0,0 +1,17 @@
const std = @import("std");
// Re-export Identity modules
pub const did = @import("did.zig");
pub const soulkey = @import("soulkey.zig");
pub const qvl = @import("qvl.zig");
pub const qvl_ffi = @import("qvl_ffi.zig");
pub const entropy = @import("entropy.zig");
pub const crypto = @import("crypto.zig");
pub const argon2 = @import("argon2.zig");
pub const pqxdh = @import("pqxdh.zig");
pub const prekey = @import("prekey.zig");
pub const slash = @import("slash.zig");
test {
std.testing.refAllDecls(@This());
}

View File

@ -1,17 +0,0 @@
const std = @import("std");
// Re-export Identity modules
pub const did = @import("l1-identity/did.zig");
pub const soulkey = @import("l1-identity/soulkey.zig");
pub const vector = @import("l1-identity/vector.zig");
pub const trust_graph = @import("l1-identity/trust_graph.zig");
pub const proof_of_path = @import("l1-identity/proof_of_path.zig");
pub const entropy = @import("l1-identity/entropy.zig");
pub const crypto = @import("l1-identity/crypto.zig");
pub const argon2 = @import("l1-identity/argon2.zig");
pub const pqxdh = @import("l1-identity/pqxdh.zig");
pub const prekey = @import("l1-identity/prekey.zig");
test {
std.testing.refAllDecls(@This());
}

View File

@ -1,101 +0,0 @@
//! Sovereign Index: L2 Session Manager
//!
//! The L2 Session Manager provides cryptographically verified,
//! resilient peer-to-peer session management for the Libertaria Stack.
//!
//! ## Core Concepts
//!
//! - **Session**: A sovereign state machine representing trust relationship
//! - **Handshake**: PQxdh-based mutual authentication
//! - **Heartbeat**: Cooperative liveness verification
//! - **Rotation**: Seamless key material refresh
//!
//! ## Transport
//!
//! This module uses QUIC and μTCP (micro-transport).
//! WebSockets are explicitly excluded by design (ADR-001).
//!
//! ## Usage
//!
//! ```janus
//! // Establish a session
//! let session = try l2_session.establish(
//! peer_did: peer_identity,
//! ctx: ctx
//! );
//!
//! // Send message through session
//! try session.send(message, ctx);
//!
//! // Receive with automatic decryption
//! let response = try session.receive(timeout: 5s, ctx);
//! ```
//!
//! ## Architecture
//!
//! - State machine: Explicit, auditable transitions
//! - Crypto: X25519Kyber768 hybrid (PQ-safe)
//! - Resilience: Graceful degradation, automatic recovery
const std = @import("std");
// Public API exports
pub const Session = @import("l2_session/session.zig").Session;
pub const State = @import("l2_session/state.zig").State;
pub const Handshake = @import("l2_session/handshake.zig").Handshake;
pub const Heartbeat = @import("l2_session/heartbeat.zig").Heartbeat;
pub const KeyRotation = @import("l2_session/rotation.zig").KeyRotation;
pub const Transport = @import("l2_session/transport.zig").Transport;
// Re-export core types
pub const SessionConfig = @import("l2_session/config.zig").SessionConfig;
pub const SessionError = @import("l2_session/error.zig").SessionError;
/// Establish a new session with a peer
///
/// This initiates the PQxdh handshake and returns a session in
/// the `handshake_initiated` state. The session becomes `established`
/// after the peer responds.
pub fn establish(
peer_did: []const u8,
config: SessionConfig,
ctx: anytype,
) !Session {
return Handshake.initiate(peer_did, config, ctx);
}
/// Resume a previously established session
///
/// If valid key material exists from a previous session,
/// this reuses it for fast re-establishment.
pub fn resume(
peer_did: []const u8,
stored_session: StoredSession,
ctx: anytype,
) !Session {
return Handshake.resume(peer_did, stored_session, ctx);
}
/// Accept an incoming session request
///
/// Call this when receiving a handshake request from a peer.
pub fn accept(
request: HandshakeRequest,
config: SessionConfig,
ctx: anytype,
) !Session {
return Handshake.respond(request, config, ctx);
}
/// Process all pending session events
///
/// Call this periodically (e.g., in your event loop) to handle
/// heartbeats, timeouts, and state transitions.
pub fn tick(
sessions: []Session,
ctx: anytype,
) void {
for (sessions) |*session| {
session.tick(ctx);
}
}

21
l2_session/mod.zig Normal file
View File

@ -0,0 +1,21 @@
//! Sovereign Index: L2 Session Manager
//!
//! The L2 Session Manager provides cryptographically verified,
//! resilient peer-to-peer session management for the Libertaria Stack.
const std = @import("std");
// Public API exports
pub const Session = @import("session.zig").Session;
pub const State = @import("state.zig").State;
pub const Handshake = @import("handshake.zig").Handshake;
pub const Heartbeat = @import("heartbeat.zig").Heartbeat;
pub const KeyRotation = @import("rotation.zig").KeyRotation;
// Re-export core types
pub const SessionConfig = @import("config.zig").SessionConfig;
pub const SessionError = @import("error.zig").SessionError;
test {
std.testing.refAllDecls(@This());
}