NAH 1.0.6
Native Application Host - Library API Reference
Loading...
Searching...
No Matches
contract.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "nah/types.hpp"
4#include "nah/manifest.hpp"
7
8#include <optional>
9#include <string>
10#include <unordered_map>
11
12namespace nah {
13
14// ============================================================================
15// Contract Composition Inputs (per SPEC L861-L876)
16// ============================================================================
17
19 std::string nah_root; // NAH root path (default "/nah")
20 Manifest manifest; // App Manifest
21 AppInstallRecord install_record; // App Install Record
22 HostProfile profile; // Host Profile (active or explicit)
23 std::unordered_map<std::string, std::string> process_env; // Current process environment
24 std::optional<std::string> overrides_file_path; // Optional overrides file
25 std::string now; // RFC3339 timestamp for trust staleness check
26 bool enable_trace = false; // Whether to generate trace output
27};
28
29// ============================================================================
30// Contract Composition Result
31// ============================================================================
32
34 bool ok = false;
35 std::optional<CriticalError> critical_error;
37};
38
39// ============================================================================
40// Contract Composition (per SPEC L877-L1085)
41// ============================================================================
42
43// Compose a launch contract from the given inputs
44// This is the core algorithm that produces the Launch Contract
46
47// ============================================================================
48// Override Parsing
49// ============================================================================
50
52 std::unordered_map<std::string, std::string> environment;
53 std::unordered_map<std::string, std::string> warnings;
54};
55
57 bool ok = false;
58 std::string error;
60};
61
62// Parse an overrides file (TOML or JSON)
63OverridesParseResult parse_overrides_file(const std::string& content, const std::string& path);
64
65// ============================================================================
66// JSON Output
67// ============================================================================
68
69// Serialize the contract envelope to deterministic JSON
70std::string serialize_contract_json(const ContractEnvelope& envelope,
71 bool include_trace = false,
72 std::optional<CriticalError> critical_error = std::nullopt);
73
74// ============================================================================
75// Platform-specific helpers
76// ============================================================================
77
78// Get the platform-specific library path environment key
80
81// Get the platform-specific path separator
83
84} // namespace nah
Result type for fallible operations.
Definition nahhost.hpp:109
CompositionResult compose_contract(const CompositionInputs &inputs)
OverridesParseResult parse_overrides_file(const std::string &content, const std::string &path)
char get_path_separator()
std::string get_library_path_env_key()
std::string serialize_contract_json(const ContractEnvelope &envelope, bool include_trace=false, std::optional< CriticalError > critical_error=std::nullopt)
AppInstallRecord install_record
Definition contract.hpp:21
std::unordered_map< std::string, std::string > process_env
Definition contract.hpp:23
std::optional< std::string > overrides_file_path
Definition contract.hpp:24
std::optional< CriticalError > critical_error
Definition contract.hpp:35
ContractEnvelope envelope
Definition contract.hpp:36
std::unordered_map< std::string, std::string > warnings
Definition contract.hpp:53
std::unordered_map< std::string, std::string > environment
Definition contract.hpp:52
OverridesFile overrides
Definition contract.hpp:59