refactor(core): eliminate duplicate utilities across crates#1381
Merged
maxamillion merged 1 commit intoMay 14, 2026
Merged
Conversation
Collaborator
|
@ericcurtin this is great! Should we include |
Contributor
Author
Sure thing, repushed |
Consolidate shared constants and helpers into openshell-core to avoid duplicate definitions scattered across crates. Adds OPENSHELL_SANDBOX to the sandbox_env module so all drivers and the sandbox supervisor reference it via a typed constant rather than string literals, matching the existing pattern for SANDBOX_ID, ENDPOINT, and the other env vars.
9fcbe8a to
8ec367a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Removes five categories of duplicated code that had been copy-pasted across the codebase, replacing each with a single canonical implementation. Also adds
OPENSHELL_SANDBOXto thesandbox_envmodule so all drivers and the sandbox supervisor reference it via a typed constant rather than string literals.Related Issue
N/A (internal refactoring)
Changes
openshell_core::time::now_ms()— replaces 7 independentcurrent_time_ms()implementations (sandbox denial aggregator, log pusher, server tracing bus, grpc handlers, compute reconciler, persistence layer, vm driver). Persistence and grpc wrappers simplified fromResult/Optionreturns to plaini64.openshell_core::sandbox_envconstants — typed constants for allOPENSHELL_*environment variable names replace identical string literals in the docker, vm, podman, and kubernetes drivers and the sandbox supervisor. Prevents silent typo bugs. IncludesOPENSHELL_SANDBOXadded in response to review feedback.openshell_core::driver_utils::sandbox_log_level()— replaces identical copy in docker and vm drivers.From<ComputeDriverError> for tonic::StatusandFrom<KubernetesDriverError> for ComputeDriverError— eliminates the duplicatestatus_from_driver_errorfunction that existed independently inkubernetes/grpc.rsandpodman/grpc.rs.tests/helpers/mod.rs— shared CLI integration test helpers (EnvVarGuard,build_ca,build_server_cert,build_client_cert,install_rustls_provider) extracted from 5 independent copies. The consolidatedEnvVarGuarduses a global mutex to safely serialize env-var mutations.Testing
mise run pre-commitpassescargo test— 800+ tests, all green)Checklist