yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
native_save_receipt.h
Go to the documentation of this file.
1#ifndef YAZE_CORE_NATIVE_SAVE_RECEIPT_H_
2#define YAZE_CORE_NATIVE_SAVE_RECEIPT_H_
3
4#include <cstdint>
5#include <filesystem>
6#include <optional>
7#include <string>
8#include <vector>
9
10#include "absl/status/statusor.h"
11
12namespace yaze::core {
13
15 std::string role;
16 std::filesystem::path path;
17 std::string expected_sha256;
18};
19
21 std::filesystem::path path;
23 std::string project_path;
24};
25
26// One pointer per canonical editing-source origin, keyed by its UTF-8 SHA-256.
27// The app-data root is queried on each call so isolated callers stay isolated.
28// These APIs return Unimplemented when JSON support is disabled.
29absl::StatusOr<NativeSaveContext> GetNativeSaveContext(
30 const std::string& editing_source_path, const std::string& project_path);
31
32// Invalidates a previously committed transfer after a successful project-only
33// relocation or session activation. A missing pointer remains absent. This
34// records rebound state without advancing a native generation. The internal
35// session_changed reason also serializes as rebound.
36absl::Status RetireNativeSaveContext(const NativeSaveContext& context,
37 const std::string& state);
38
40 std::filesystem::path receipt_path;
41 std::string operation_id;
42 std::string operation;
43 std::vector<NativeSaveArtifact> artifacts;
44 std::vector<std::string> binding_errors;
45 std::optional<NativeSaveContext> context;
46};
47
49 uint64_t generation;
50 std::string json;
51};
52
53// Receipt/context JSON paths use UTF-8 generic separators ("/") on every host.
54// Filesystem inputs may use the host's native separators.
55// Records an already completed native save. All paths must be absolute, roles
56// unique, and expected hashes lowercase SHA-256. Distinct roles may share an
57// exact canonical path only with the same expected hash. The rom and producer
58// roles are required. A new operation advances the persisted generation, even
59// when artifact bytes are unchanged. Repeating its current operation_id is
60// idempotent only when every binding and the operation are identical.
61// Explicit binding_errors record incomplete optional project qualification;
62// included artifacts still require exact hashes and required roles stay valid.
63//
64// Inputs are verified under the existing source-publication lock and again on
65// readback. The optional process context is published with the receipt. Only
66// receipt/context outputs are written or rolled back; a failure cannot undo
67// the save that the caller has already completed. Browser builds retain the
68// publisher's unsupported durable-lock behavior.
69absl::StatusOr<NativeSaveReceipt> PublishNativeSaveReceipt(
70 const NativeSaveReceiptRequest& request);
71
72} // namespace yaze::core
73
74#endif // YAZE_CORE_NATIVE_SAVE_RECEIPT_H_
absl::Status RetireNativeSaveContext(const NativeSaveContext &, const std::string &)
absl::StatusOr< NativeSaveContext > GetNativeSaveContext(const std::string &, const std::string &)
absl::StatusOr< NativeSaveReceipt > PublishNativeSaveReceipt(const NativeSaveReceiptRequest &)
std::vector< std::string > binding_errors
std::optional< NativeSaveContext > context
std::vector< NativeSaveArtifact > artifacts