feat: Enable conditional compilation for Policy Evaluation Framework in yaze target
This commit is contained in:
@@ -48,7 +48,10 @@ The Policy Evaluation Framework enables safe AI-driven ROM modifications by gati
|
|||||||
|
|
||||||
- Added `cli/service/policy_evaluator.cc` to:
|
- Added `cli/service/policy_evaluator.cc` to:
|
||||||
- `src/cli/z3ed.cmake` (z3ed CLI target)
|
- `src/cli/z3ed.cmake` (z3ed CLI target)
|
||||||
- `src/app/app.cmake` (yaze GUI target, both macOS and Windows/Linux)
|
- `src/app/app.cmake` (yaze GUI target, with `YAZE_ENABLE_POLICY_FRAMEWORK=1`)
|
||||||
|
- **Conditional Compilation**: Policy framework only enabled in main `yaze` target
|
||||||
|
- `yaze_emu` (emulator) builds without policy support
|
||||||
|
- Uses `#ifdef YAZE_ENABLE_POLICY_FRAMEWORK` to wrap optional code
|
||||||
- Clean build with no errors (warnings only for Abseil version mismatch)
|
- Clean build with no errors (warnings only for Abseil version mismatch)
|
||||||
|
|
||||||
## Code Changes
|
## Code Changes
|
||||||
@@ -93,15 +96,38 @@ The Policy Evaluation Framework enables safe AI-driven ROM modifications by gati
|
|||||||
- Added: `cli/service/policy_evaluator.cc` to z3ed sources
|
- Added: `cli/service/policy_evaluator.cc` to z3ed sources
|
||||||
|
|
||||||
4. **src/app/app.cmake**
|
4. **src/app/app.cmake**
|
||||||
- Added: `cli/service/policy_evaluator.cc` to yaze sources (macOS + Windows/Linux)
|
- Added: `cli/service/policy_evaluator.cc` to yaze sources
|
||||||
|
- Added: `YAZE_ENABLE_POLICY_FRAMEWORK=1` compile definition
|
||||||
|
- Note: `yaze_emu` target does NOT include policy framework (optional feature)
|
||||||
|
|
||||||
5. **docs/z3ed/E6-z3ed-implementation-plan.md**
|
5. **src/app/editor/system/proposal_drawer.cc**
|
||||||
|
- Wrapped policy code with `#ifdef YAZE_ENABLE_POLICY_FRAMEWORK`
|
||||||
|
- Gracefully degrades when policy framework disabled
|
||||||
|
|
||||||
|
6. **docs/z3ed/E6-z3ed-implementation-plan.md**
|
||||||
- Updated: AW-04 status from "📋 Next" to "✅ Done"
|
- Updated: AW-04 status from "📋 Next" to "✅ Done"
|
||||||
- Updated: Active phase to Policy Framework complete
|
- Updated: Active phase to Policy Framework complete
|
||||||
- Updated: Time investment to 28.5 hours total
|
- Updated: Time investment to 28.5 hours total
|
||||||
|
|
||||||
## Technical Details
|
## Technical Details
|
||||||
|
|
||||||
|
### Conditional Compilation
|
||||||
|
|
||||||
|
The policy framework uses conditional compilation to allow building without policy support:
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
#ifdef YAZE_ENABLE_POLICY_FRAMEWORK
|
||||||
|
auto& policy_eval = cli::PolicyEvaluator::GetInstance();
|
||||||
|
auto policy_result = policy_eval.EvaluateProposal(p.id);
|
||||||
|
// ... policy evaluation logic ...
|
||||||
|
#endif
|
||||||
|
```
|
||||||
|
|
||||||
|
**Build Targets**:
|
||||||
|
- `yaze` (main editor): Policy framework **enabled** ✅
|
||||||
|
- `yaze_emu` (emulator): Policy framework **disabled** (not needed)
|
||||||
|
- `z3ed` (CLI): Policy framework **enabled** ✅
|
||||||
|
|
||||||
### API Usage Patterns
|
### API Usage Patterns
|
||||||
|
|
||||||
**StatusOr Error Handling**:
|
**StatusOr Error Handling**:
|
||||||
@@ -132,6 +158,7 @@ PolicyResult result = evaluator.EvaluateProposal(proposal_id);
|
|||||||
2. **StatusOr API**: Used `.ok()` and `.value()` instead of `.has_value()`
|
2. **StatusOr API**: Used `.ok()` and `.value()` instead of `.has_value()`
|
||||||
3. **String Numbers**: Added `#include "absl/strings/numbers.h"` for SimpleAtoi
|
3. **String Numbers**: Added `#include "absl/strings/numbers.h"` for SimpleAtoi
|
||||||
4. **String View**: Explicit `std::string()` cast for all absl::StripAsciiWhitespace() calls
|
4. **String View**: Explicit `std::string()` cast for all absl::StripAsciiWhitespace() calls
|
||||||
|
5. **Conditional Compilation**: Wrapped policy code with `YAZE_ENABLE_POLICY_FRAMEWORK` to fix yaze_emu build
|
||||||
|
|
||||||
## Testing Plan
|
## Testing Plan
|
||||||
|
|
||||||
|
|||||||
@@ -131,6 +131,9 @@ target_link_libraries(
|
|||||||
ImGui
|
ImGui
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Enable policy framework in main yaze target
|
||||||
|
target_compile_definitions(yaze PRIVATE YAZE_ENABLE_POLICY_FRAMEWORK=1)
|
||||||
|
|
||||||
# Increase stack size on Windows to prevent stack overflow during asset loading
|
# Increase stack size on Windows to prevent stack overflow during asset loading
|
||||||
# Windows default is 1MB, macOS/Linux is typically 8MB
|
# Windows default is 1MB, macOS/Linux is typically 8MB
|
||||||
# LoadAssets() loads 223 graphics sheets and initializes multiple editors
|
# LoadAssets() loads 223 graphics sheets and initializes multiple editors
|
||||||
|
|||||||
@@ -9,7 +9,11 @@
|
|||||||
#include "imgui/imgui.h"
|
#include "imgui/imgui.h"
|
||||||
#include "app/gui/icons.h"
|
#include "app/gui/icons.h"
|
||||||
#include "cli/service/rom_sandbox_manager.h"
|
#include "cli/service/rom_sandbox_manager.h"
|
||||||
#include "cli/service/policy_evaluator.h" // NEW: Policy evaluation support
|
|
||||||
|
// Policy evaluation support (optional, only in main yaze build)
|
||||||
|
#ifdef YAZE_ENABLE_POLICY_FRAMEWORK
|
||||||
|
#include "cli/service/policy_evaluator.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace editor {
|
namespace editor {
|
||||||
@@ -93,6 +97,7 @@ void ProposalDrawer::Draw() {
|
|||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef YAZE_ENABLE_POLICY_FRAMEWORK
|
||||||
// Policy override dialog (NEW)
|
// Policy override dialog (NEW)
|
||||||
if (show_override_dialog_) {
|
if (show_override_dialog_) {
|
||||||
ImGui::OpenPopup("Override Policy");
|
ImGui::OpenPopup("Override Policy");
|
||||||
@@ -122,6 +127,8 @@ void ProposalDrawer::Draw() {
|
|||||||
}
|
}
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
|
#endif // YAZE_ENABLE_POLICY_FRAMEWORK
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProposalDrawer::DrawProposalList() {
|
void ProposalDrawer::DrawProposalList() {
|
||||||
@@ -251,7 +258,9 @@ void ProposalDrawer::DrawProposalDetail() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Policy Status section (NEW)
|
// Policy Status section (NEW)
|
||||||
|
#ifdef YAZE_ENABLE_POLICY_FRAMEWORK
|
||||||
DrawPolicyStatus();
|
DrawPolicyStatus();
|
||||||
|
#endif
|
||||||
|
|
||||||
// Action buttons
|
// Action buttons
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
@@ -270,6 +279,7 @@ void ProposalDrawer::DrawStatusFilter() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ProposalDrawer::DrawPolicyStatus() {
|
void ProposalDrawer::DrawPolicyStatus() {
|
||||||
|
#ifdef YAZE_ENABLE_POLICY_FRAMEWORK
|
||||||
if (!selected_proposal_) return;
|
if (!selected_proposal_) return;
|
||||||
|
|
||||||
const auto& p = *selected_proposal_;
|
const auto& p = *selected_proposal_;
|
||||||
@@ -362,6 +372,7 @@ void ProposalDrawer::DrawPolicyStatus() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // YAZE_ENABLE_POLICY_FRAMEWORK
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProposalDrawer::DrawActionButtons() {
|
void ProposalDrawer::DrawActionButtons() {
|
||||||
@@ -374,6 +385,7 @@ void ProposalDrawer::DrawActionButtons() {
|
|||||||
bool can_accept = true;
|
bool can_accept = true;
|
||||||
bool needs_override = false;
|
bool needs_override = false;
|
||||||
|
|
||||||
|
#ifdef YAZE_ENABLE_POLICY_FRAMEWORK
|
||||||
if (is_pending) {
|
if (is_pending) {
|
||||||
auto& policy_eval = cli::PolicyEvaluator::GetInstance();
|
auto& policy_eval = cli::PolicyEvaluator::GetInstance();
|
||||||
if (policy_eval.IsEnabled()) {
|
if (policy_eval.IsEnabled()) {
|
||||||
@@ -385,6 +397,7 @@ void ProposalDrawer::DrawActionButtons() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // YAZE_ENABLE_POLICY_FRAMEWORK
|
||||||
|
|
||||||
// Accept button (only for pending proposals, gated by policy)
|
// Accept button (only for pending proposals, gated by policy)
|
||||||
if (is_pending) {
|
if (is_pending) {
|
||||||
|
|||||||
Reference in New Issue
Block a user