feat(actor): add Rust FFI planner actor #15

Open
yorunikakeru wants to merge 0 commits from feat/planner-actor-ffi into main
Owner

Summary

  • Add the planner-actor Rust crate with Tokio actor channels for IR and SystemState updates.
  • Add a safe Rust wrapper over the Haskell Planner FFI and decode Protobuf PlanResult via prost.
  • Add actor smoke tests plus a real FFI smoke test that initializes the GHC RTS and calls hs_plan.
  • Include planner-actor in flake checks so the Rust actor and real Haskell FFI smoke run in Nix.

Closes #7

Verification

  • cargo test --manifest-path planner-actor/Cargo.toml
  • nix build .#checks.x86_64-linux.planner-actor --print-build-logs
  • cargo fmt --manifest-path planner-actor/Cargo.toml --check
  • nix fmt
## Summary - Add the planner-actor Rust crate with Tokio actor channels for IR and SystemState updates. - Add a safe Rust wrapper over the Haskell Planner FFI and decode Protobuf PlanResult via prost. - Add actor smoke tests plus a real FFI smoke test that initializes the GHC RTS and calls hs_plan. - Include planner-actor in flake checks so the Rust actor and real Haskell FFI smoke run in Nix. Closes #7 ## Verification - cargo test --manifest-path planner-actor/Cargo.toml - nix build .#checks.x86_64-linux.planner-actor --print-build-logs - cargo fmt --manifest-path planner-actor/Cargo.toml --check - nix fmt
feat(actor): add Rust FFI planner actor
All checks were successful
CI / linux (pull_request) Successful in 1m58s
2063df2802
fix(actor): handle closed planner channels
All checks were successful
CI / linux (pull_request) Successful in 1m57s
69030ba7b7
refactor: migrate from service to module domain
Some checks failed
CI / linux (pull_request) Failing after 30s
3047b64bd3
Replace IR.Domain.Service with Domain.Module throughout the Planner.
The IR dropped the Service abstraction in favour of Module (with
ModuleRef carrying domain + name, and LifecycleAction replacing
Enable/DisableWithPriority).

- Rename Planner.Domain.Service -> Planner.Domain.Module; rewrite
  conflict resolution around Module.LifecycleAction
- Replace ServiceAction pattern with ModuleAction everywhere
- Remove IR. import prefix: Action, Condition, Domain.*, Types now
  consumed directly as exposed by frogos-ir
- Rename SystemState.activeServices -> activeModules
- Add AppRunning branch to evalCondition (new IR constructor)
- Update tests and fixtures to use ModuleRef instead of service names
- Document cabal clean workaround for stale IR cache in AGENTS.md
RestartModule and SetPowerProfile now carry Int priority. IRDocument
gains irUsers and irNetwork fields. Updated pattern matches and test
fixtures accordingly.
ResourceId/ResourceState/ResourceGraph model the system as a flat map
of resources. Delta carries typed service/package/user operations.
DeltaAction extends IR actions with package and user variants so
PlanStep can represent all backend operations.
- decodePlanError: map version_mismatch to VersionMismatch constructor
  (was incorrectly mapping to ConflictingActions)
- Proto.Planner: add cpu_load (double/field 4), battery_percent (int32/field 5),
  running_apps (repeated string/field 6) to SystemState generated type;
  update parser (getFixed64/wordToDouble for double), builder, defMessage, NFData
- Proto.Planner_Fields: add cpuLoad, batteryPercent, runningApps, vec'runningApps lenses
- Planner.Proto: wire new fields in decodeSystemState and encodeSystemState;
  sentinel: cpuLoad=0.0 -> Nothing, batteryPercent=-1 -> Nothing
- planner.proto: update PlanStep action_json/undo_json comments to DeltaAction
buildCurrentGraph maps SystemState fields to a ResourceGraph.
buildDesiredGraph collects desired states from active profiles and
global IR fields, resolving conflicts by action priority with
Fallback policy support.
Commit d6f6197 deleted 4 critical pattern arms from evalCondition:
- ProcessCondition (Process.ProcessRunning ...)
- ProcessCondition (Process.AppRunning ...)
- And c1 c2
- Not c

This caused 9 tests to fail with Non-exhaustive patterns error.

Restore all missing arms while keeping the checkMetric helper.
All 45 tests now pass. stan reports 0 issues.
computeDelta compares current ResourceGraph against desired states
to produce typed service/package/user deltas. orderSteps emits
PlanSteps in backend-safe order: users before packages before services.
plan now builds current and desired resource graphs, computes a typed
delta, and orders steps by backend (users → packages → services).
Power profile resolution is unchanged.
New tags 7-8 carry package and user data from Toad. decodeSystemState
populates the new SystemState fields. Rust bindings auto-regenerated
from proto by prost_build.
Encodes Toad-observed fields (installed_packages, existing_users,
running_processes, active_services, power_profile) into proto
SystemState bytes for PlannerMsg::SystemStateUpdate.
docs: update README
All checks were successful
CI / linux (pull_request) Successful in 2m5s
99284d25a6
choire: 9 -> x
All checks were successful
CI / linux (pull_request) Successful in 2m7s
CI / linux (push) Successful in 19s
10f7f06878
All checks were successful
CI / linux (pull_request) Successful in 2m7s
CI / linux (push) Successful in 19s
This branch is already included in the target branch. There is nothing to merge.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin feat/planner-actor-ffi:feat/planner-actor-ffi
git switch feat/planner-actor-ffi

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff feat/planner-actor-ffi
git switch feat/planner-actor-ffi
git rebase main
git switch main
git merge --ff-only feat/planner-actor-ffi
git switch feat/planner-actor-ffi
git rebase main
git switch main
git merge --no-ff feat/planner-actor-ffi
git switch main
git merge --squash feat/planner-actor-ffi
git switch main
git merge --ff-only feat/planner-actor-ffi
git switch main
git merge feat/planner-actor-ffi
git push origin main
Sign in to join this conversation.
No reviewers
No labels
core
ffi
haskell
rust
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
FrogOS/Planner!15
No description provided.