#include <proposal_registry.h>
Classes | |
struct | ProposalMetadata |
Public Types | |
enum class | ProposalStatus { kPending , kAccepted , kRejected } |
Public Member Functions | |
void | SetRootDirectory (const std::filesystem::path &root) |
const std::filesystem::path & | RootDirectory () const |
absl::StatusOr< ProposalMetadata > | CreateProposal (absl::string_view sandbox_id, const std::filesystem::path &sandbox_rom_path, absl::string_view prompt, absl::string_view description) |
absl::Status | RecordDiff (const std::string &proposal_id, absl::string_view diff_content) |
absl::Status | AppendLog (const std::string &proposal_id, absl::string_view log_entry) |
absl::Status | AddScreenshot (const std::string &proposal_id, const std::filesystem::path &screenshot_path) |
absl::Status | UpdateCommandStats (const std::string &proposal_id, int commands_executed) |
absl::Status | UpdateStatus (const std::string &proposal_id, ProposalStatus status) |
absl::StatusOr< ProposalMetadata > | GetProposal (const std::string &proposal_id) const |
std::vector< ProposalMetadata > | ListProposals (std::optional< ProposalStatus > filter_status=std::nullopt) const |
absl::StatusOr< ProposalMetadata > | GetLatestPendingProposal () const |
absl::Status | RemoveProposal (const std::string &proposal_id) |
absl::StatusOr< int > | CleanupOlderThan (absl::Duration max_age) |
Static Public Member Functions | |
static ProposalRegistry & | Instance () |
Private Member Functions | |
ProposalRegistry () | |
absl::Status | EnsureRootExistsLocked () |
absl::Status | LoadProposalsFromDiskLocked () |
std::string | GenerateProposalIdLocked () |
std::filesystem::path | ProposalDirectory (absl::string_view proposal_id) const |
absl::Status | WriteMetadataLocked (const ProposalMetadata &metadata) const |
Private Attributes | |
std::filesystem::path | root_directory_ |
std::mutex | mutex_ |
std::unordered_map< std::string, ProposalMetadata > | proposals_ |
int | sequence_ = 0 |
Definition at line 29 of file proposal_registry.h.
|
strong |
Enumerator | |
---|---|
kPending | |
kAccepted | |
kRejected |
Definition at line 31 of file proposal_registry.h.
|
private |
Definition at line 78 of file proposal_registry.cc.
Referenced by Instance().
|
static |
Definition at line 73 of file proposal_registry.cc.
References ProposalRegistry().
Referenced by yaze::editor::ProposalDrawer::AcceptProposal(), yaze::cli::agent::CreateProposalFromAgentResponse(), yaze::editor::ProposalDrawer::DeleteProposal(), yaze::cli::PolicyEvaluator::EvaluateChangeConstraints(), yaze::cli::PolicyEvaluator::EvaluateReviewRequirements(), yaze::cli::agent::HandleAcceptCommand(), yaze::cli::agent::HandleDiffCommand(), yaze::cli::agent::HandleListCommand(), yaze::cli::agent::HandlePlanCommand(), yaze::editor::ProposalDrawer::RefreshProposals(), and yaze::editor::ProposalDrawer::RejectProposal().
void yaze::cli::ProposalRegistry::SetRootDirectory | ( | const std::filesystem::path & | root | ) |
Definition at line 81 of file proposal_registry.cc.
References EnsureRootExistsLocked(), mutex_, and root_directory_.
const std::filesystem::path & yaze::cli::ProposalRegistry::RootDirectory | ( | ) | const |
Definition at line 87 of file proposal_registry.cc.
References root_directory_.
absl::StatusOr< ProposalRegistry::ProposalMetadata > yaze::cli::ProposalRegistry::CreateProposal | ( | absl::string_view | sandbox_id, |
const std::filesystem::path & | sandbox_rom_path, | ||
absl::string_view | prompt, | ||
absl::string_view | description | ||
) |
Definition at line 287 of file proposal_registry.cc.
References EnsureRootExistsLocked(), GenerateProposalIdLocked(), yaze::cli::ProposalRegistry::ProposalMetadata::id, kPending, mutex_, ProposalDirectory(), proposals_, RETURN_IF_ERROR, and WriteMetadataLocked().
absl::Status yaze::cli::ProposalRegistry::RecordDiff | ( | const std::string & | proposal_id, |
absl::string_view | diff_content | ||
) |
Definition at line 330 of file proposal_registry.cc.
References mutex_, proposals_, RETURN_IF_ERROR, and WriteMetadataLocked().
absl::Status yaze::cli::ProposalRegistry::AppendLog | ( | const std::string & | proposal_id, |
absl::string_view | log_entry | ||
) |
Definition at line 356 of file proposal_registry.cc.
References mutex_, and proposals_.
absl::Status yaze::cli::ProposalRegistry::AddScreenshot | ( | const std::string & | proposal_id, |
const std::filesystem::path & | screenshot_path | ||
) |
Definition at line 380 of file proposal_registry.cc.
References mutex_, proposals_, RETURN_IF_ERROR, and WriteMetadataLocked().
absl::Status yaze::cli::ProposalRegistry::UpdateCommandStats | ( | const std::string & | proposal_id, |
int | commands_executed | ||
) |
Definition at line 402 of file proposal_registry.cc.
References mutex_, proposals_, RETURN_IF_ERROR, and WriteMetadataLocked().
absl::Status yaze::cli::ProposalRegistry::UpdateStatus | ( | const std::string & | proposal_id, |
ProposalStatus | status | ||
) |
Definition at line 416 of file proposal_registry.cc.
References mutex_, proposals_, RETURN_IF_ERROR, and WriteMetadataLocked().
absl::StatusOr< ProposalRegistry::ProposalMetadata > yaze::cli::ProposalRegistry::GetProposal | ( | const std::string & | proposal_id | ) | const |
Definition at line 432 of file proposal_registry.cc.
References mutex_, and proposals_.
std::vector< ProposalRegistry::ProposalMetadata > yaze::cli::ProposalRegistry::ListProposals | ( | std::optional< ProposalStatus > | filter_status = std::nullopt | ) | const |
Definition at line 443 of file proposal_registry.cc.
References LoadProposalsFromDiskLocked(), mutex_, and proposals_.
absl::StatusOr< ProposalRegistry::ProposalMetadata > yaze::cli::ProposalRegistry::GetLatestPendingProposal | ( | ) | const |
Definition at line 476 of file proposal_registry.cc.
References yaze::cli::ProposalRegistry::ProposalMetadata::created_at, kPending, mutex_, and proposals_.
absl::Status yaze::cli::ProposalRegistry::RemoveProposal | ( | const std::string & | proposal_id | ) |
Definition at line 559 of file proposal_registry.cc.
References mutex_, ProposalDirectory(), and proposals_.
absl::StatusOr< int > yaze::cli::ProposalRegistry::CleanupOlderThan | ( | absl::Duration | max_age | ) |
Definition at line 579 of file proposal_registry.cc.
References mutex_, ProposalDirectory(), and proposals_.
|
private |
Definition at line 91 of file proposal_registry.cc.
References root_directory_.
Referenced by CreateProposal(), and SetRootDirectory().
|
private |
Definition at line 103 of file proposal_registry.cc.
References yaze::cli::ProposalRegistry::ProposalMetadata::bytes_changed, yaze::cli::ProposalRegistry::ProposalMetadata::commands_executed, yaze::cli::ProposalRegistry::ProposalMetadata::created_at, yaze::cli::ProposalRegistry::ProposalMetadata::description, yaze::cli::ProposalRegistry::ProposalMetadata::diff_path, yaze::cli::ProposalRegistry::ProposalMetadata::id, kPending, yaze::cli::ProposalRegistry::ProposalMetadata::log_path, yaze::cli::ProposalRegistry::ProposalMetadata::prompt, proposals_, yaze::cli::ProposalRegistry::ProposalMetadata::reviewed_at, root_directory_, yaze::cli::ProposalRegistry::ProposalMetadata::sandbox_directory, yaze::cli::ProposalRegistry::ProposalMetadata::sandbox_id, yaze::cli::ProposalRegistry::ProposalMetadata::sandbox_rom_path, yaze::cli::ProposalRegistry::ProposalMetadata::screenshots, yaze::cli::ProposalRegistry::ProposalMetadata::status, and WriteMetadataLocked().
Referenced by ListProposals().
|
private |
Definition at line 273 of file proposal_registry.cc.
References sequence_.
Referenced by CreateProposal().
|
private |
Definition at line 281 of file proposal_registry.cc.
References root_directory_.
Referenced by CleanupOlderThan(), CreateProposal(), RemoveProposal(), and WriteMetadataLocked().
|
private |
Definition at line 495 of file proposal_registry.cc.
References yaze::cli::ProposalRegistry::ProposalMetadata::bytes_changed, yaze::cli::ProposalRegistry::ProposalMetadata::commands_executed, yaze::cli::ProposalRegistry::ProposalMetadata::created_at, yaze::cli::ProposalRegistry::ProposalMetadata::description, yaze::cli::ProposalRegistry::ProposalMetadata::diff_path, yaze::cli::ProposalRegistry::ProposalMetadata::id, yaze::cli::ProposalRegistry::ProposalMetadata::log_path, yaze::cli::ProposalRegistry::ProposalMetadata::prompt, ProposalDirectory(), yaze::cli::ProposalRegistry::ProposalMetadata::reviewed_at, yaze::cli::ProposalRegistry::ProposalMetadata::sandbox_directory, yaze::cli::ProposalRegistry::ProposalMetadata::sandbox_id, yaze::cli::ProposalRegistry::ProposalMetadata::sandbox_rom_path, yaze::cli::ProposalRegistry::ProposalMetadata::screenshots, and yaze::cli::ProposalRegistry::ProposalMetadata::status.
Referenced by AddScreenshot(), CreateProposal(), LoadProposalsFromDiskLocked(), RecordDiff(), UpdateCommandStats(), and UpdateStatus().
|
private |
Definition at line 124 of file proposal_registry.h.
Referenced by EnsureRootExistsLocked(), LoadProposalsFromDiskLocked(), ProposalDirectory(), RootDirectory(), and SetRootDirectory().
|
mutableprivate |
Definition at line 125 of file proposal_registry.h.
Referenced by AddScreenshot(), AppendLog(), CleanupOlderThan(), CreateProposal(), GetLatestPendingProposal(), GetProposal(), ListProposals(), RecordDiff(), RemoveProposal(), SetRootDirectory(), UpdateCommandStats(), and UpdateStatus().
|
private |
Definition at line 126 of file proposal_registry.h.
Referenced by AddScreenshot(), AppendLog(), CleanupOlderThan(), CreateProposal(), GetLatestPendingProposal(), GetProposal(), ListProposals(), LoadProposalsFromDiskLocked(), RecordDiff(), RemoveProposal(), UpdateCommandStats(), and UpdateStatus().
|
private |
Definition at line 127 of file proposal_registry.h.
Referenced by GenerateProposalIdLocked().