hephaestus/crates/heph-core/src/error.rs
Erich Blume 5d54e913c2
Some checks failed
Build / validate (pull_request) Failing after 4s
hephd: client mode + RemoteStore (sync 9b)
Add the online-only escape hatch — a no-replica daemon that proxies every
Store call to a server over HTTP (tech-spec §3.1).

- Daemon is now generic over the backing store (Arc<Mutex<dyn Store +
  Send>>), so the same unix-socket surface fronts either a LocalStore
  (local/server) or a RemoteStore (client). sync::router/sync_once and the
  Ctx follow suit.
- New POST /rpc route on the hub router runs the full rpc::dispatch over
  HTTP (result-xor-error body, always 200). dispatch gains task.get and
  links.add so the proxied API is complete.
- RemoteStore (hephd): implements heph_core::Store by forwarding each call
  to /rpc via a blocking reqwest client (Store is sync; the daemon only
  calls it from the blocking pool). Error::Remote for transport failures;
  NOT_FOUND is preserved as Error::NodeNotFound. Sync primitives are
  stubbed (a client keeps no op-log).
- main: --mode client + --server-url; client skips the file lock and opens
  no LocalStore.
- tests/client_mode.rs: a RemoteStore drives node/task/search/list/health
  against a real HTTP server, and not-found maps back correctly.

102 tests green; clippy -D warnings + fmt + prek clean. Next: OIDC auth.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-01 15:29:28 -07:00

33 lines
982 B
Rust

//! Error type for `heph-core`.
/// Errors surfaced by the core library.
#[derive(Debug, thiserror::Error)]
pub enum Error {
/// A SQLite-level failure.
#[error("sqlite: {0}")]
Sqlite(#[from] rusqlite::Error),
/// A filesystem failure (e.g. during `export`).
#[error("io: {0}")]
Io(#[from] std::io::Error),
/// The DB file is already locked by another `local`/`server` process.
#[error("store is already locked by another process: {0}")]
Locked(String),
/// A referenced node does not exist.
#[error("node not found: {0}")]
NodeNotFound(String),
/// A value in the database did not match the expected shape.
#[error("data integrity: {0}")]
Integrity(String),
/// A remote backend (a `RemoteStore` in `client` mode) failed or returned an
/// error response (tech-spec §3.1).
#[error("remote: {0}")]
Remote(String),
}
/// Convenience result alias.
pub type Result<T> = std::result::Result<T, Error>;