Skip to content

refactor(client): add openframe-common crate CU-17tkuw66nxa - #3047

Merged
danylo-babenko-flamingo merged 7 commits into
mainfrom
refactor/openframe-common-crate
Nov 18, 2026
Merged

danylo-babenko-flamingo merged 7 commits into
mainfrom
refactor/openframe-common-crate

Conversation

@danylo-babenko-flamingo

@danylo-babenko-flamingo danylo-babenko-flamingo commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

ClickUp task: CU-17tkuw66nxa Add the openframe-common crate and move the client onto it

Change-Set: refactor-openframe-common-crate

Summary

The client, chat and Console each keep their own copy of the JWT parsing, the shared-token encryption and the NATS wire types, so one fix has to land up to three times. This PR adds the crate they will share, clients/openframe-common, with its first three parts, and moves the client onto it by path. No behaviour, wire, on-disk or log-text change.

Change

New standalone crate clients/openframe-common (lib openframe_common). It has its own Cargo.lock and Makefile and no workspace, like the client, and no Tauri:

  • auth::jwt: utils/jwt.rs and its tests, moved unchanged. Always on.
  • auth::shared_token, behind feature shared-token (pulls in aes-gcm and anyhow): KEY, FILE_NAME, encrypt(key, plaintext), decrypt(key, data). The envelope stays base64 of nonce(12) || AES-256-GCM ciphertext + tag, with the client's error texts. decrypt returns an error for another key, input shorter than the nonce and text that is not base64; a test covers each, since chat will rely on those paths.
  • protocol::InstalledAgentMessage: moved from models/, same serde shape ({"agentType":..,"version":..}, matching the openframe-data-nats DTO).

Client (openframe-agent-lib):

  • openframe-common = { path = "../openframe-common", features = ["shared-token"] }. aes-gcm is dropped, and base64 moves to [dev-dependencies] because only two test files use it now. The lockfile gains openframe-common and changes no versions.
  • EncryptionService and its module are deleted. It was a zero-sized wrapper around a single call. SharedTokenService::new no longer takes it and calls shared_token::encrypt(shared_token::KEY.as_bytes(), …) directly.
  • ToolCommandParamsResolver held a second literal copy of the key and of shared_token.enc. It now uses shared_token::KEY and shared_token::FILE_NAME, so each lives in one place.
  • Imports are updated in token_refresh_run_manager, installed_agent_message_publisher, integration_tests and two test files. The hidden per-file docs of jwt, installed_agent_message and encryption_service are deleted with their modules.

CI and hooks:

  • New build-rust-common job in build.yml, on macos-latest and windows-latest like build-rust: make lint, make hack and make test in the new crate. It runs on the existing rust filter (clients/**).
  • make hack is cargo hack --feature-powerset clippy --all-targets --locked -- -D warnings. That lints every feature combination with tests included. A plain check with --no-dev-deps never compiles the tests, so a test that needs shared-token but is not gated by it would only show up later, in a consumer.
  • cargo-hack 0.6.46 is installed with taiki-e/install-action@v2 and fallback: none: the tool comes from its own release with a checksum, and without the cargo-binstall fallback the action gets no job token.
  • clients/.githooks: pre-commit runs cargo fmt --check in each crate that has staged Rust. pre-push runs make clippy in every crate under clients/, because a change in openframe-common can break the client without touching it. It skips without make the same way it skips without cargo.
  • clients/README.md: the layout, the hooks text, and the CI workflow name, which was rust-client.yml but is build.yml. It no longer calls CI a gate: the Rust jobs are not required checks on main.

Things that look odd on purpose

  • decrypt with no caller in this repo. Chat is its next user: it decrypts shared_token.enc with the secret it is launched with, so the key stays a parameter. The fixture test uses it too.
  • The fixture and exact-JSON tests. These are not the round-trip tests rule 2 asks to avoid. The ticket's acceptance criteria ask for fixtures written by the current code.
    • shared_token_tests.rs decrypts a ciphertext produced by the old EncryptionService. The format is read by osquery (C++), orbit (Go), meshagent (C) and chat, so its bytes must not drift.
    • protocol_tests.rs compares the serialized InstalledAgentMessage with the exact JSON the backend reads.
  • No new NATS integration test. The type moved, but the subject, the publisher and the flow are the same code, and the exact-JSON test pins the payload. The existing installed-agent integration test now imports the type from the crate.
  • #![allow(deprecated)] and // TODO: use generated key moved with the code. The key was already a public literal in this repo, twice, so nothing new is exposed. Generating it is out of scope.
  • The jwt tests now run in the new CI job instead of build-rust.

Not in this PR

Testing

  • openframe-common on Windows: make lint, make hack (both feature combinations), make test (13 passed). Without the length check in decrypt, the short-input test panics.
  • openframe-client on Windows: make lint, cargo build --release --locked, make test (528 passed, 7 ignored).
  • A path dependency inside a git dependency resolves. I checked this with a scratch crate pinning the branch by git = "file://…", the way the saas-tenant thin client pins openframe-agent-lib.
  • NATS integration suite on Windows against a real nats-server 2.15.2: REQUIRE_NATS_SERVER=1 OPENFRAME_VERSION=0.0.0-dev cargo test --lib --locked, 528 passed, 7 ignored. All 25 integration tests ran, including the two installed-agent tests that decode InstalledAgentMessage from the new crate. CI installs no nats-server, so there the suite skips.
  • macOS: Build Rust common (macos-latest) (lint, every feature combination, tests) and Build Rust (macos-latest) (client lint and tests) pass on this PR. Not run on a physical Mac; the change has no platform code.

Change set flamingo-stack/openframe-oss-lib#3047: these pull requests are one change, reviewed together.

Linked work

  • …and 1 linked item not shown here

Linked by the Depends-On / Change-Set lines in these descriptions; this block is maintained by the hub.

@danylo-babenko-flamingo
danylo-babenko-flamingo requested a review from a team as a code owner November 13, 2026 11:16
@danylo-babenko-flamingo danylo-babenko-flamingo added the build Run the PR builds and publish snapshots (Java, npm preview); stays on until removed label Nov 13, 2026
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

🦩 Flamingo Code Review

➖ No tests ran on this commit (no lane ran): nothing here proves the change works.

3 findings: 🔴 0 action required · 🟠 0 recommended · 🔵 3 informational

Advisory: findings do not block the merge.

3 defects outside any rule

Files Lines 🔴 Action required 🟠 Recommended 🔵 Informational
32 +561 / -196 0 0 3

🔵 Informational (3)

# Where Finding Flagged by
1 shared_token.rs:11 Hardcoded 32-byte AES-256-GCM key shared across all installs (Pre-existing) Review
2 Cargo.toml:4 openframe-common declares no rust-version, so nothing keeps it under chat's 1.77.2 Tests and mutation
3 shared_token.rs:37 decrypt's failure paths have no test Tests and mutation

✅ What this change does well

  • clients/openframe-client/src/lib.rs and shared_token_service.rs cleanly drop the now-unnecessary EncryptionService wiring, simplifying SharedTokenService::new to a single dependency.
  • clients/.githooks/pre-commit and pre-push were generalized to iterate over every crate under clients/ rather than hardcoding openframe-client, correctly anticipating the new openframe-common crate.
  • .github/workflows/build.yml adds a dedicated build-rust-common job with cargo-hack feature-powerset checks, giving good coverage of the new crate's optional shared-token feature.
  • clients/openframe-common/src/auth/jwt_tests.rs adds solid edge-case coverage for JWT TTL parsing including overflow and malformed-token cases.
  • clients/openframe-common/src/protocol_tests.rs locks down the exact camelCase wire shape of InstalledAgentMessage, guarding against accidental serde contract drift.
  • clients/openframe-common/src/auth/shared_token_tests.rs pins the deployed envelope with a fixed ciphertext, so a format drift fails a test instead of osquery, orbit, meshagent or chat in the field.
  • clients/openframe-client/src/services/tool_command_params_resolver.rs now takes the key and file name from the crate, which removes a second literal copy of both.
  • clients/openframe-common/src/protocol_tests.rs checks the exact JSON the backend reads, not a round trip.

Inline comments: 3 new

7 possible problems checked and ruled out, 5 after reading more of the repository
  • clients/openframe-client/src/services/shared_token_service.rs:16 Hardcoded encryption key carried over into the new shared crate, now also used as the plaintext placeholder value: duplicate of candidate 2
  • clients/openframe-client/src/models/mod.rs:9 23 new or changed definitions have no test referencing them: Mostly boilerplate module re-export files (mod.rs) and generic missing-test noise across 23 unrelated definitions in files this PR did not touch in most cases; not a specific actionable logic gap.
  • clients/openframe-common/src/auth.rs:1 New openframe-common Rust source files lack the Apache-2.0 header: NATSRS-008 is a NATS-project-specific license header rule misapplied to openframe-oss-lib; no evidence this repo uses that convention, and missing boilerplate headers are not a substantive defect.
  • clients/openframe-common/src/auth/jwt_tests.rs:1 Missing Apache-2.0 copyright header in jwt_tests.rs: Same misapplied NATS license-header rule as index 0; not a real org-specific defect for this repo.
  • clients/openframe-common/src/auth/shared_token.rs:1 Missing Apache-2.0 copyright header in shared_token.rs: Same misapplied NATS license-header rule as index 0.
  • clients/openframe-common/src/lib.rs:1 Missing Apache-2.0 copyright header in lib.rs: Same misapplied NATS license-header rule as index 0.
  • clients/openframe-common/src/protocol.rs:1 Missing Apache-2.0 copyright header in protocol.rs: Same misapplied NATS license-header rule as index 0.

🧪 Tests and mutation

Tests per lane

Language Project Command Status Counts Time

Stage 2 ran no lanes: the hub planned only Trivy and YAML checks for this change, and neither tool is on this machine. It has no Rust lane, so it ran no Rust tests and no mutation testing.

Run by hand on macOS arm64 at 9b3bfdf: in clients/openframe-common, make lint, clippy without features, cargo test (8 passed) and make test with shared-token (10 passed). The fixture in shared_token_tests.rs decrypts.

CI on 9b3bfdf: Build Rust and Build Rust common pass on macos-latest and windows-latest.

🤖 Prompt for AI agents: fix every finding
Address these code-review findings on pull request #3047 of flamingo-stack/openframe-oss-lib, most important first.
For each one, make the minimal change that resolves it and do not refactor unrelated code.
If you can show a finding is wrong, skip it and say why.

1. [Informational] clients/openframe-common/src/auth/shared_token.rs:11 Hardcoded 32-byte AES-256-GCM key shared across all installs
   The KEY constant is a hardcoded, publicly-visible string compiled into the binary and used to encrypt the shared token file via aes_gcm::Aes256Gcm::new_from_slice. Anyone with the binary (or source) can decrypt any installation's shared_token.enc, as demonstrated by the test using a fixed DEPLOYED_FORMAT_CIPHERTEXT. The TODO comment acknowledges this is a placeholder, but it is now published in the openframe_agent_lib crate and openframe-common, broadening exposure.
2. [Informational] clients/openframe-common/Cargo.toml:4 openframe-common declares no rust-version, so nothing keeps it under chat's 1.77.2
   The parent ticket requires the crate's MSRV to fit chat's `rust-version = "1.77.2"`, but the crate declares none and CI builds only on stable. Today's code is fine; the client already uses `std::sync::LazyLock` (1.80) in tool_command_params_resolver.rs, and later steps move that kind of code here.
3. [Informational] clients/openframe-common/src/auth/shared_token.rs:37 decrypt's failure paths have no test
   Both tests feed `decrypt` valid input. Nothing checks that a wrong key, input shorter than the 12-byte nonce, or invalid base64 returns `Err` rather than panicking. These are the branches chat relies on when it adopts this function in place of its own `TokenDecryptionService`.

Next: commit a suggestion, or hand a comment's prompt to your coding agent. React 👍 on a finding that helped and 👎 on one that is wrong: the reviewer learns from both.

Review again. New commits are not reviewed until you ask:

  • Review the new commits: only what was pushed since this review
  • Review the whole diff again: everything, including what was already reviewed

Or comment @flamingo-review (new commits) or @flamingo-review full (everything). Add the flamingo-review-always label to review every push.

Updated 2026-11-16 19:37 UTC · reviewed from Mikhail Matsykh's machine

@danylo-babenko-flamingo danylo-babenko-flamingo changed the title refactor(client): add openframe-common crate CU-17tkuw646xj refactor(client): add openframe-common crate CU-17tkuw66nxa Nov 13, 2026
@viktor-flamingo

Copy link
Copy Markdown
Contributor

devops side:

  • the path dep adds a second openframe-oss-lib.git?tag= line to the saas-tenant Cargo.lock, so claude-skills client-release verify-bump.sh:17 fails with VERIFY_FAILED on the first bump after this merges
  • clients/README.md:41-42 says CI is a gate, but only Flamingo Code Review / reviewed is required
  • taiki-e/install-action@v2: add fallback: none so the job token stays out of the action env

mikhailm-coder
mikhailm-coder previously approved these changes Nov 16, 2026
Comment thread clients/openframe-common/Cargo.toml Resolved
@danylo-babenko-flamingo
danylo-babenko-flamingo added this pull request to the merge queue Nov 18, 2026
Merged via the queue into main with commit 0399330 Nov 18, 2026
20 checks passed
@danylo-babenko-flamingo
danylo-babenko-flamingo deleted the refactor/openframe-common-crate branch November 18, 2026 04:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Run the PR builds and publish snapshots (Java, npm preview); stays on until removed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants