backend-infra-engineer: Release v0.3.3 snapshot
This commit is contained in:
@@ -29,12 +29,12 @@ struct RomSnapshot {
|
||||
std::string rom_hash;
|
||||
std::vector<uint8_t> rom_data;
|
||||
size_t compressed_size;
|
||||
|
||||
|
||||
// Metadata
|
||||
std::string creator;
|
||||
bool is_checkpoint; // Manual checkpoint vs auto-backup
|
||||
bool is_safe_point; // Marked as "known good" by host
|
||||
|
||||
|
||||
#ifdef YAZE_WITH_JSON
|
||||
nlohmann::json metadata; // Custom metadata (proposals applied, etc.)
|
||||
#endif
|
||||
@@ -55,7 +55,7 @@ struct VersionDiff {
|
||||
/**
|
||||
* @class RomVersionManager
|
||||
* @brief Manages ROM versioning, snapshots, and rollback capabilities
|
||||
*
|
||||
*
|
||||
* Provides:
|
||||
* - Automatic periodic snapshots
|
||||
* - Manual checkpoints
|
||||
@@ -73,87 +73,84 @@ class RomVersionManager {
|
||||
bool compress_snapshots = true;
|
||||
bool enable_corruption_detection = true;
|
||||
};
|
||||
|
||||
|
||||
explicit RomVersionManager(Rom* rom);
|
||||
~RomVersionManager();
|
||||
|
||||
|
||||
/**
|
||||
* Initialize version management
|
||||
*/
|
||||
absl::Status Initialize(const Config& config);
|
||||
|
||||
|
||||
/**
|
||||
* Create a snapshot of current ROM state
|
||||
*/
|
||||
absl::StatusOr<std::string> CreateSnapshot(
|
||||
const std::string& description,
|
||||
const std::string& creator,
|
||||
bool is_checkpoint = false);
|
||||
|
||||
absl::StatusOr<std::string> CreateSnapshot(const std::string& description,
|
||||
const std::string& creator,
|
||||
bool is_checkpoint = false);
|
||||
|
||||
/**
|
||||
* Restore ROM to a previous snapshot
|
||||
*/
|
||||
absl::Status RestoreSnapshot(const std::string& snapshot_id);
|
||||
|
||||
|
||||
/**
|
||||
* Mark a snapshot as a safe point (host-verified)
|
||||
*/
|
||||
absl::Status MarkAsSafePoint(const std::string& snapshot_id);
|
||||
|
||||
|
||||
/**
|
||||
* Get all snapshots, sorted by timestamp
|
||||
*/
|
||||
std::vector<RomSnapshot> GetSnapshots(bool safe_points_only = false) const;
|
||||
|
||||
|
||||
/**
|
||||
* Get a specific snapshot
|
||||
*/
|
||||
absl::StatusOr<RomSnapshot> GetSnapshot(const std::string& snapshot_id) const;
|
||||
|
||||
|
||||
/**
|
||||
* Delete a snapshot
|
||||
*/
|
||||
absl::Status DeleteSnapshot(const std::string& snapshot_id);
|
||||
|
||||
|
||||
/**
|
||||
* Generate diff between two snapshots
|
||||
*/
|
||||
absl::StatusOr<VersionDiff> GenerateDiff(
|
||||
const std::string& from_id,
|
||||
const std::string& to_id) const;
|
||||
|
||||
absl::StatusOr<VersionDiff> GenerateDiff(const std::string& from_id,
|
||||
const std::string& to_id) const;
|
||||
|
||||
/**
|
||||
* Check for ROM corruption
|
||||
*/
|
||||
absl::StatusOr<bool> DetectCorruption();
|
||||
|
||||
|
||||
/**
|
||||
* Auto-recover from corruption using nearest safe point
|
||||
*/
|
||||
absl::Status AutoRecover();
|
||||
|
||||
|
||||
/**
|
||||
* Export snapshot to file
|
||||
*/
|
||||
absl::Status ExportSnapshot(
|
||||
const std::string& snapshot_id,
|
||||
const std::string& filepath);
|
||||
|
||||
absl::Status ExportSnapshot(const std::string& snapshot_id,
|
||||
const std::string& filepath);
|
||||
|
||||
/**
|
||||
* Import snapshot from file
|
||||
*/
|
||||
absl::Status ImportSnapshot(const std::string& filepath);
|
||||
|
||||
|
||||
/**
|
||||
* Get current ROM hash
|
||||
*/
|
||||
std::string GetCurrentHash() const;
|
||||
|
||||
|
||||
/**
|
||||
* Cleanup old snapshots based on policy
|
||||
*/
|
||||
absl::Status CleanupOldSnapshots();
|
||||
|
||||
|
||||
/**
|
||||
* Get statistics
|
||||
*/
|
||||
@@ -167,18 +164,19 @@ class RomVersionManager {
|
||||
int64_t newest_snapshot_timestamp;
|
||||
};
|
||||
Stats GetStats() const;
|
||||
|
||||
|
||||
private:
|
||||
Rom* rom_;
|
||||
Config config_;
|
||||
std::map<std::string, RomSnapshot> snapshots_;
|
||||
std::string last_known_hash_;
|
||||
int64_t last_backup_time_;
|
||||
|
||||
|
||||
// Helper functions
|
||||
std::string ComputeRomHash() const;
|
||||
std::vector<uint8_t> CompressData(const std::vector<uint8_t>& data) const;
|
||||
std::vector<uint8_t> DecompressData(const std::vector<uint8_t>& compressed) const;
|
||||
std::vector<uint8_t> DecompressData(
|
||||
const std::vector<uint8_t>& compressed) const;
|
||||
absl::Status ValidateRomIntegrity() const;
|
||||
size_t GetTotalStorageUsed() const;
|
||||
void PruneOldSnapshots();
|
||||
@@ -187,7 +185,7 @@ class RomVersionManager {
|
||||
/**
|
||||
* @class ProposalApprovalManager
|
||||
* @brief Manages proposal approval workflow for collaborative sessions
|
||||
*
|
||||
*
|
||||
* Features:
|
||||
* - Host approval required for all changes
|
||||
* - Participant voting system
|
||||
@@ -197,12 +195,12 @@ class RomVersionManager {
|
||||
class ProposalApprovalManager {
|
||||
public:
|
||||
enum class ApprovalMode {
|
||||
kHostOnly, // Only host can approve
|
||||
kMajorityVote, // Majority of participants must approve
|
||||
kUnanimous, // All participants must approve
|
||||
kAutoApprove // No approval needed (dangerous!)
|
||||
kHostOnly, // Only host can approve
|
||||
kMajorityVote, // Majority of participants must approve
|
||||
kUnanimous, // All participants must approve
|
||||
kAutoApprove // No approval needed (dangerous!)
|
||||
};
|
||||
|
||||
|
||||
struct ApprovalStatus {
|
||||
std::string proposal_id;
|
||||
std::string status; // "pending", "approved", "rejected", "applied"
|
||||
@@ -212,76 +210,71 @@ class ProposalApprovalManager {
|
||||
std::string snapshot_before; // Snapshot ID before applying
|
||||
std::string snapshot_after; // Snapshot ID after applying
|
||||
};
|
||||
|
||||
|
||||
explicit ProposalApprovalManager(RomVersionManager* version_mgr);
|
||||
|
||||
|
||||
/**
|
||||
* Set approval mode for the session
|
||||
*/
|
||||
void SetApprovalMode(ApprovalMode mode);
|
||||
|
||||
|
||||
/**
|
||||
* Set host username
|
||||
*/
|
||||
void SetHost(const std::string& host_username);
|
||||
|
||||
|
||||
/**
|
||||
* Submit a proposal for approval
|
||||
*/
|
||||
absl::Status SubmitProposal(
|
||||
const std::string& proposal_id,
|
||||
const std::string& sender,
|
||||
const std::string& description,
|
||||
const nlohmann::json& proposal_data);
|
||||
|
||||
absl::Status SubmitProposal(const std::string& proposal_id,
|
||||
const std::string& sender,
|
||||
const std::string& description,
|
||||
const nlohmann::json& proposal_data);
|
||||
|
||||
/**
|
||||
* Vote on a proposal
|
||||
*/
|
||||
absl::Status VoteOnProposal(
|
||||
const std::string& proposal_id,
|
||||
const std::string& username,
|
||||
bool approved);
|
||||
|
||||
absl::Status VoteOnProposal(const std::string& proposal_id,
|
||||
const std::string& username, bool approved);
|
||||
|
||||
/**
|
||||
* Apply an approved proposal
|
||||
*/
|
||||
absl::Status ApplyProposal(
|
||||
const std::string& proposal_id,
|
||||
Rom* rom);
|
||||
|
||||
absl::Status ApplyProposal(const std::string& proposal_id, Rom* rom);
|
||||
|
||||
/**
|
||||
* Reject and rollback a proposal
|
||||
*/
|
||||
absl::Status RejectProposal(const std::string& proposal_id);
|
||||
|
||||
|
||||
/**
|
||||
* Get proposal status
|
||||
*/
|
||||
absl::StatusOr<ApprovalStatus> GetProposalStatus(
|
||||
const std::string& proposal_id) const;
|
||||
|
||||
|
||||
/**
|
||||
* Get all pending proposals
|
||||
*/
|
||||
std::vector<ApprovalStatus> GetPendingProposals() const;
|
||||
|
||||
|
||||
/**
|
||||
* Check if proposal is approved
|
||||
*/
|
||||
bool IsProposalApproved(const std::string& proposal_id) const;
|
||||
|
||||
|
||||
/**
|
||||
* Get audit log
|
||||
*/
|
||||
std::vector<ApprovalStatus> GetAuditLog() const;
|
||||
|
||||
|
||||
private:
|
||||
RomVersionManager* version_mgr_;
|
||||
ApprovalMode mode_;
|
||||
std::string host_username_;
|
||||
std::map<std::string, ApprovalStatus> proposals_;
|
||||
std::vector<std::string> participants_;
|
||||
|
||||
|
||||
bool CheckApprovalThreshold(const ApprovalStatus& status) const;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user