Integrate zinit SDK: ZinitLifecycle for UI, logging via zinit, remove legacy scripts #9
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
Parent issue: lhumina_code/hero_os#24
Related: lhumina_code/hero_rpc#7, lhumina_code/home#6
hero_embedder_server already has
ZinitLifecycle(Pattern B) with fullrun/start/stop/status/logssubcommands.Important: In-process long-running operations (corpus download/load, batch embedding, model loading, namespace ops) stay as in-process async tasks. They work with in-memory state (cached ONNX models, HNSW vector indexes, redb connections) and cannot be externalized to zinit subprocess jobs. However, they should log through zinit for centralized visibility.
1. Add
ZinitLifecycleto hero_embedder_uiFile:
crates/hero_embedder_ui/src/main.rs(~225 lines)Currently a standalone Axum server with basic CLI arg parsing — no subcommands, no zinit integration.
Improvement: Add
ZinitLifecycle(non-OpenRPC binary pattern):Update Makefile:
2. Replace custom OperationLogger with zinit logs
File:
crates/hero_embedder_lib/src/logging.rs(~250 lines)Custom circular-buffer logger (500 entries) with operation types: Embed, Search, Rerank, LoadCorpus, IndexAdd/Delete/Clear, NamespaceCreate/Delete, KVS*, Vectors*. Queryable via
logs.get,logs.clear,logs.streamRPC methods.Improvement: Forward operation logs to zinit via
logs.insert()with structured source names.Log source naming convention
hero_embedder.embed.{namespace}hero_embedder.search.{namespace}hero_embedder.rerank.{namespace}hero_embedder.corpus.downloadhero_embedder.corpus.load.{namespace}hero_embedder.namespace.{action}hero_embedder.init.modelhero_embedder.index.{namespace}3. Health checks in zinit service registration
Configure HTTP health checks for both services in their
ZinitLifecycleregistration:/healthon Unix socket (already has structured health response)/healthon Unix socket4. Remove legacy
run.shFile:
run.sh— Manual server startup with quality level selection, bypasses zinit.Remove. All execution goes through
hero_embedder_server run(zinit-managed). Quality level should be an env var or arg onserve.Summary
logs.insert()run.shexistsspawn_blocking/ async tasksAcceptance Criteria
run/start/stop/status/logs/servesubcommandsrun.shremovedCorrection: scope of zinit jobs vs in-process operations
After further discussion, the recommendation to convert most in-process operations to zinit jobs was incorrect. Zinit jobs are subprocess-based — they spawn external commands. Most hero_embedder operations work with in-memory state (cached ONNX models, vector indexes, redb connections) and cannot be externalized to subprocesses.
What should NOT become zinit jobs (stays in-process)
What SHOULD use zinit
ZinitLifecyclefor hero_embedder_uilogs.insert()with structured source namescurlZinitLifecycleRevised summary
The core improvements are:
ZinitLifecyclefor hero_embedder_ui (server already done)OperationLoggerwith zinitlogs.insert()using structured source namesrun.shIn-process long-running operations (corpus load, embedding, model loading) stay as async tasks but should log through zinit for centralized visibility.
Use zinit jobs API for long-running operations, integrate logging with zinit, add lifecycle to UIto Integrate zinit SDK: ZinitLifecycle for UI, logging via zinit, remove legacy scriptsImplementation audit — code is correct, build fixed
Audited all uncommitted changes:
hero_embedder_ui/src/lifecycle.rs) usingServiceBuilder/ActionBuilder/RetryPolicyBuilder— ✅ correctzinit_client.rswraps zinit RPC with graceful fallback (no-op when zinit unavailable) — ✅ correct pattern. Hascreate_jobmethod defined but never called — dead code, harmlessjobs.rsprovides RPC handlers for in-process job progress tracking (state.job_progress) — ✅ correct, these are NOT zinit subprocess jobslogging.rsforwards operation logs to zinit vialogs.insert()with structured source names — ✅ correctrun.shdeleted — ✅ per planjob_progressHashMapBuild fix applied: Added missing
hero_rpc_openrpcworkspace dependency and SDK crate dependency. Pre-existing issue (unrelated to zinit work) — theopenrpc_client!macro generates code requiring this crate. Workspace now compiles clean (cargo check --workspacepasses).Remaining: code is uncommitted. Needs to be committed and pushed.
All items implemented and pushed to
developmentbranch (commit642f88a):zinit_client.rswrapper with graceful fallbackjobs.rs+state.job_progresslogs.insert()with structured source namesrun.shremovedhero_rpc_openrpcdep)Closing.