NAH 1.0.6
Native Application Host - Library API Reference
Loading...
Searching...
No Matches
nak_record.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4#include <unordered_map>
5#include <vector>
6
7namespace nah {
8
9// ============================================================================
10// NAK Install Record (per SPEC L381-L468)
11// ============================================================================
12
14 std::string schema; // MUST be "nah.nak.install.v1"
15
16 // [nak] section
17 struct {
18 std::string id;
19 std::string version;
20 } nak;
21
22 // [paths] section
23 struct {
24 std::string root; // Absolute NAK root path
25 std::string resource_root; // Absolute, defaults to root if omitted
26 std::vector<std::string> lib_dirs; // Absolute paths
28
29 // [environment] section
30 std::unordered_map<std::string, std::string> environment;
31
32 // [loader] section (OPTIONAL per SPEC L395)
33 struct {
34 bool present = false;
35 std::string exec_path; // Absolute path to loader executable
36 std::vector<std::string> args_template; // Template with {NAME} placeholders
38
39 // [execution] section (OPTIONAL per SPEC L402)
40 struct {
41 bool present = false;
42 std::string cwd; // Template, resolved at composition time
44
45 // [provenance] section (optional)
46 struct {
47 std::string package_hash;
48 std::string installed_at;
49 std::string installed_by;
50 std::string source;
52
53 // Source path for trace
54 std::string source_path;
55};
56
57// ============================================================================
58// NAK Install Record Parsing Result
59// ============================================================================
60
62 bool ok = false;
63 std::string error;
65 std::vector<std::string> warnings;
66};
67
68// Parse a NAK Install Record from TOML string
70 const std::string& source_path = "");
71
72// ============================================================================
73// NAK Install Record Validation
74// ============================================================================
75
76// Validate required fields per SPEC Presence semantics
77// Returns true if all required fields are present and valid
78bool validate_nak_install_record(const NakInstallRecord& record, std::string& error);
79
80// ============================================================================
81// NAK Pack Manifest (per SPEC L2677-L2772)
82// ============================================================================
83
85 std::string schema; // MUST be "nah.nak.pack.v1"
86
87 struct {
88 std::string id;
89 std::string version;
90 } nak;
91
92 struct {
93 std::string resource_root; // Relative to pack root
94 std::vector<std::string> lib_dirs; // Relative paths
96
97 std::unordered_map<std::string, std::string> environment;
98
99 struct {
100 bool present = false;
101 std::string exec_path; // Relative path
102 std::vector<std::string> args_template;
104
105 struct {
106 bool present = false;
107 std::string cwd;
109};
110
112 bool ok = false;
113 std::string error;
115 std::vector<std::string> warnings;
116};
117
118// Parse a NAK pack manifest from TOML string
120
121// ============================================================================
122// Legacy API for backward compatibility
123// ============================================================================
124
126 bool ok;
127 std::string error;
128};
129
131
132} // namespace nah
Result type for fallible operations.
Definition nahhost.hpp:109
NakPackManifestParseResult parse_nak_pack_manifest(const std::string &toml_str)
NakInstallRecordParseResult parse_nak_install_record_full(const std::string &toml_str, const std::string &source_path="")
bool validate_nak_install_record(const NakInstallRecord &record, std::string &error)
NakInstallValidation parse_nak_install_record(const std::string &toml, NakInstallRecord &out)
std::vector< std::string > warnings
struct nah::NakInstallRecord::@15 execution
struct nah::NakInstallRecord::@13 paths
std::string package_hash
struct nah::NakInstallRecord::@14 loader
std::string source_path
std::vector< std::string > lib_dirs
std::string installed_by
struct nah::NakInstallRecord::@12 nak
std::unordered_map< std::string, std::string > environment
struct nah::NakInstallRecord::@16 provenance
std::vector< std::string > args_template
std::string resource_root
std::string installed_at
std::vector< std::string > warnings
struct nah::NakPackManifest::@18 paths
struct nah::NakPackManifest::@17 nak
std::unordered_map< std::string, std::string > environment
std::string resource_root
std::vector< std::string > args_template
struct nah::NakPackManifest::@19 loader
std::vector< std::string > lib_dirs
struct nah::NakPackManifest::@20 execution