refactor: merge hm-util into hm-common#178
Merged
Merged
Conversation
Fold the hm-util crate (dirs resolution + os fs helpers) into hm-common and delete it. Its modules land as hm_common::dirs, hm_common::fs, and a pub(crate) hm_common::os for platform primitives. Replace the FileMode(u32)/DirMode(u32) newtypes on the atomic writer with a semantic Privacy enum (Private = owner-only, Public = world-readable). The parent dir is now always created owner-only, so the dir-mode argument drops out entirely. Raw mode bits no longer leak into call sites, and the long-standing Windows no-op (modes silently ignored) is now documented on Privacy rather than hidden in u32s. write_atomic_restricted is renamed to write_atomic. Call sites in hm-config/hm-exec/hm move from hm_util::* to hm_common::*.
markovejnovic
force-pushed
the
refactor/merge-hm-util-into-hm-common
branch
from
July 26, 2026 03:42
a16b8b0 to
66f0aec
Compare
The fs::blocking wrappers existed for extism host_fn sync callbacks, which the plugin-era cleanup already removed. Delete the module and make every public fs writer async: write_atomic, atomic_rename_over, remove_file_if_exists, and write_create_all (now tokio::fs, was std::fs). Propagate async through the only sync callers — hm-config's credential and config writers (save/set/delete/save_to/save_user/set_cloud_token/ forget_cloud_token) and hm's init/run helpers (write_template, write_skills, persist_project_pipeline) — plus the cloud auth verbs that drive them. Tests touching these move to #[tokio::test].
Introduce DirProvider (dir_provider.rs): it resolves the platform per-user directory roots (config, cache) a single time at construction and hands them out as &Path, so consumers stop re-resolving them per call. It is deliberately application-agnostic — it knows nothing of Harmont's own `hm/` subdirectory; callers join that (and any file name) onto these roots. Replaces the pub(crate) os/dirs.rs platform primitives, which are deleted, and the hm_config_dir/hm_cache_dir/ hm_workspace_cache_dir free functions in dirs.rs. dirs.rs now holds only find_project_root (project discovery, orthogonal to the platform roots). AppRuntime gains a resolved-once DirProvider and an AppRuntime::dirs() accessor, alongside an InitError::Dirs variant. Consumers migrate: hm/cache-clean reads AppRuntime::dirs(); hm-config and hm-exec (no app-runtime feature) construct DirProvider::new() directly. Each joins `hm/` onto the returned root as before, so resolved paths are unchanged. Also make write_atomic create the parent directory at the file's own Privacy (0o755 for Public, 0o700 for Private) rather than always owner-only.
markovejnovic
force-pushed
the
refactor/merge-hm-util-into-hm-common
branch
from
July 26, 2026 06:09
dc27505 to
3bb8470
Compare
Rename app_runtime.rs -> sys_runtime.rs, the AppRuntime type -> SysRuntime, and the app-runtime feature -> sys-runtime, across hm-common, hm, and hm-dsl-engine. The type resolves host toolchain and platform directories from the OS environment, so the "system runtime" name fits better than "app runtime". Also correct the SysRuntime::dirs() and DirProvider docblocks, which described the roots as hm-namespaced; DirProvider now exposes the raw platform roots.
…-export Delete crates/hm-common/src/dirs.rs. Its sole remaining function, find_project_root, discovers the `.hm/` project root and is used only by the hm crate (context.rs and the config_layered test), so it moves to crates/hm/src/project.rs where it belongs. Also drop the `pub use dir_provider::DirProvider` crate-root re-export: every other hm-common type is module-qualified (hm_common::git::Git, hm_common::fs::write_atomic), so callers now use hm_common::dir_provider::DirProvider for consistency.
markovejnovic
marked this pull request as ready for review
July 26, 2026 06:27
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.
Generated by an AI agent.