Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,46 @@ jobs:
- name: Test
run: make -C clients/openframe-client test

build-rust-common:
name: "Build Rust common (${{ matrix.os }})"
needs: changes
if: fromJSON(needs.changes.outputs.changes || '{}').rust == 'true'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest]
defaults:
run:
shell: bash

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false

- name: Prepare Rust tools
uses: ./.github/steps/rust-setup
with:
path: clients/openframe-common
components: clippy,rustfmt
shared-key: openframe-common-${{ matrix.os }}

- name: Install cargo-hack
uses: taiki-e/install-action@v2
with:
tool: cargo-hack@0.6.46
fallback: none

- name: Lint (cargo fmt --check + cargo clippy -D warnings)
run: make -C clients/openframe-common lint

- name: Check every feature combination
run: make -C clients/openframe-common hack

- name: Test
run: make -C clients/openframe-common test

cleanup:
name: Cleanup
if: github.event_name == 'pull_request' && github.event.pull_request.state != 'open'
Expand Down
16 changes: 10 additions & 6 deletions clients/.githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/usr/bin/env bash
# OpenFrame Rust client: verify formatting before committing.
# Only fires when staged changes touch Rust sources under clients/.
# OpenFrame Rust crates: verify formatting before committing.
# Only fires for the crates under clients/ whose Rust sources are staged.
set -euo pipefail

if ! git diff --cached --name-only | grep -qE '^clients/.*\.rs$'; then
crates="$(git diff --cached --name-only --diff-filter=ACMR | sed -nE 's#^clients/([^/]+)/.*\.rs$#\1#p' | sort -u)"
if [ -z "$crates" ]; then
exit 0
fi

Expand All @@ -12,6 +13,9 @@ if ! command -v cargo >/dev/null 2>&1; then
exit 0
fi

cd "$(git rev-parse --show-toplevel)/clients/openframe-client"
echo "[pre-commit] cargo fmt --all -- --check"
cargo fmt --all -- --check
root="$(git rev-parse --show-toplevel)"
for crate in $crates; do
cd "$root/clients/$crate"
echo "[pre-commit] $crate: cargo fmt --all -- --check"
cargo fmt --all -- --check
done
18 changes: 10 additions & 8 deletions clients/.githooks/pre-push
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# OpenFrame Rust client: run clippy (deny warnings) before pushing.
# Only fires when the pushed commits touch the Rust client; skips gracefully
# when cargo is unavailable so non-Rust contributors are not blocked.
# OpenFrame Rust crates: run every crate's clippy target (deny warnings) before pushing,
# since one crate builds on another. Only fires when the pushed commits touch Rust under
# clients/; skips gracefully without cargo or make so non-Rust contributors are not blocked.
set -euo pipefail

root="$(git rev-parse --show-toplevel)"
Expand All @@ -23,11 +23,13 @@ if ! echo "$changed" | grep -qE '\.(rs|toml)$'; then
exit 0
fi

if ! command -v cargo >/dev/null 2>&1; then
echo "[pre-push] cargo not found; skipping Rust clippy check." >&2
if ! command -v cargo >/dev/null 2>&1 || ! command -v make >/dev/null 2>&1; then
echo "[pre-push] cargo or make not found; skipping Rust clippy check." >&2
exit 0
fi

cd "$root/clients/openframe-client"
echo "[pre-push] cargo clippy --all-targets -- -D warnings"
OPENFRAME_VERSION="${OPENFRAME_VERSION:-0.0.0-dev}" cargo clippy --all-targets -- -D warnings
for manifest in "$root"/clients/*/Cargo.toml; do
crate="$(dirname "$manifest")"
echo "[pre-push] $(basename "$crate"): make clippy"
make -C "$crate" clippy
done
22 changes: 14 additions & 8 deletions clients/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ clients/
├── Makefile # hook setup only: `make -C clients setup-hooks`
├── rustfmt.toml # formatting config (applies to every crate below it)
├── .githooks/ # pre-commit (fmt) + pre-push (clippy)
└── openframe-client/ # the standalone library crate (openframe-agent-lib)
├── Cargo.toml # incl. [lints.clippy] policy
├── openframe-client/ # the standalone library crate (openframe-agent-lib)
│ ├── Cargo.toml # incl. [lints.clippy] policy
│ ├── Cargo.lock
│ └── Makefile # fmt / fmt-check / clippy / lint / build / test
└── openframe-common/ # code shared by the agent and the desktop apps
├── Cargo.toml # opt-in parts behind cargo features
├── Cargo.lock
└── Makefile # fmt / fmt-check / clippy / lint / build / test
└── Makefile # fmt / fmt-check / clippy / lint / hack / test
```

## One-time setup
Expand All @@ -29,12 +33,14 @@ make -C clients setup-hooks

This enables the committed git hooks:

- **pre-commit** → `cargo fmt --all -- --check` (fails on unformatted Rust).
- **pre-push** → `cargo clippy --all-targets -- -D warnings`.
- **pre-commit** → `cargo fmt --all -- --check` in each crate with staged Rust.
- **pre-push** → `make clippy` in every crate (`-D warnings`).

Both hooks only fire when the change touches the Rust client, and skip cleanly
if `cargo` is not installed, so they do not get in the way of Java-only work.
CI (`.github/workflows/rust-client.yml`) runs the same gate authoritatively.
Both hooks only fire when the change touches Rust under `clients/`, and skip
cleanly if `cargo` (or `make`, for pre-push) is not installed, so they do not get
in the way of Java-only work. CI (`.github/workflows/build.yml`) runs the same
checks on PRs with the `build` label and in the merge queue. They are not
required checks: `main` requires only `Flamingo Code Review / reviewed`.

Requires a stable Rust toolchain (`rustup` recommended) with the `rustfmt` and
`clippy` components.
Expand Down
13 changes: 12 additions & 1 deletion clients/openframe-client/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions clients/openframe-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ zip = "0.6"
tempfile = "3.10"
semver = "1.0"
sys-info = "0.9"
aes-gcm = "0.10"
base64 = "0.21"
log = "0.4.27"
clap = { version = "4.5", features = ["derive", "env", "std", "cargo", "string"] }
whoami = "1.4"
Expand All @@ -119,6 +117,7 @@ async-nats = { git = "https://github.com/flamingo-stack/nats.rs.git", rev = "3cf
rustls-pemfile = "1.0"
redb = "2"
regex = "1.11.1"
openframe-common = { path = "../openframe-common", features = ["shared-token"] }

[target.'cfg(windows)'.dependencies]
winreg = "0.52"
Expand All @@ -131,6 +130,9 @@ windows = { version = "0.52", features = ["Win32_Foundation", "Win32_System_Thre
libc = "0.2"
nix = { version = "0.29", features = ["user"] }

[dev-dependencies]
base64 = "0.21"

[build-dependencies]
embed-resource = "2.4"

Expand Down
7 changes: 1 addition & 6 deletions clients/openframe-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ use crate::services::agent_configuration_service::AgentConfigurationService;
use crate::services::deactivation_service::DeactivationService;
use crate::services::delivery_results::DeliveryResults;
use crate::services::device_data_fetcher::DeviceDataFetcher;
use crate::services::encryption_service::EncryptionService;
use crate::services::execution_service::ExecutionService;
use crate::services::feature_flags_service::FeatureFlagsService;
use crate::services::github_download_service::GithubDownloadService;
Expand Down Expand Up @@ -295,12 +294,8 @@ impl Client {
deactivation_service.clone(),
);

// Initialize encryption service
let encryption_service = EncryptionService::new();

// Initialize shared token service
let shared_token_service =
SharedTokenService::new(directory_manager.clone(), encryption_service.clone());
let shared_token_service = SharedTokenService::new(directory_manager.clone());

// Initialize authentication service
let auth_service = AgentAuthService::new(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use super::{
use crate::config::update_config::DEV_CLIENT_VERSION;
use crate::models::{
DeliveryRef, DeliveryResult, DeliveryResultMessage, FailReason, Feature, FeatureFlagsState,
InstalledAgentMessage, InstalledAsset, InstalledTool, OpenFrameClientUpdateMessage, PackageRef,
InstalledAsset, InstalledTool, OpenFrameClientUpdateMessage, PackageRef,
PackageUpdateStatusMessage, ToolRecordState, UpdateStatus,
};
use crate::platform::{DirectoryManager, DmgExtractor};
Expand Down Expand Up @@ -44,6 +44,7 @@ use crate::services::{
use crate::test_support::{connection_manager, NatsServer};
use crate::utils::in_progress::InProgress;
use crate::utils::latch::Latch;
use openframe_common::protocol::InstalledAgentMessage;

const MACHINE: &str = "it-machine";
const BOUND: Duration = Duration::from_secs(10);
Expand Down
22 changes: 0 additions & 22 deletions clients/openframe-client/src/models/.installed_agent_message.md

This file was deleted.

2 changes: 0 additions & 2 deletions clients/openframe-client/src/models/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ pub mod execution;
pub mod feature_flags;
pub mod hostname_report_message;
pub mod initial_configuration;
pub mod installed_agent_message;
pub mod installed_tool;
pub mod machine_heartbeat_message;
pub mod machine_timezone_message;
Expand Down Expand Up @@ -50,7 +49,6 @@ pub use feature_flags::{
};
pub use hostname_report_message::HostnameReportMessage;
pub use initial_configuration::InitialConfiguration;
pub use installed_agent_message::InstalledAgentMessage;
pub use installed_tool::{
Installation, InstalledAsset, InstalledTool, ToolRecordState, CHAT_TOOL_AGENT_ID,
};
Expand Down
33 changes: 0 additions & 33 deletions clients/openframe-client/src/services/.encryption_service.md

This file was deleted.

46 changes: 0 additions & 46 deletions clients/openframe-client/src/services/encryption_service.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::models::InstalledAgentMessage;
use crate::services::nats_message_publisher::NatsMessagePublisher;
use anyhow::Context;
use openframe_common::protocol::InstalledAgentMessage;

#[derive(Clone)]
pub struct InstalledAgentMessagePublisher {
Expand Down
2 changes: 0 additions & 2 deletions clients/openframe-client/src/services/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ pub mod deactivation_service;
pub mod delivery_results;
pub mod deregistration_service;
pub mod device_data_fetcher;
pub mod encryption_service;
pub mod execution_service;
pub mod feature_flags_service;
pub mod github_download_service;
Expand Down Expand Up @@ -56,7 +55,6 @@ pub use agent_configuration_service::AgentConfigurationService;
pub use agent_registration_service::AgentRegistrationService;
pub use deactivation_service::DeactivationService;
pub use deregistration_service::DeregistrationService;
pub use encryption_service::EncryptionService;
pub use github_download_service::GithubDownloadService;
pub use hostname_report_publisher::HostnameReportPublisher;
pub use initial_configuration_service::InitialConfigurationService;
Expand Down
Loading
Loading