Create the PikaciRunStore module
Intent: Introduce a new module that encapsulates the state-root derivation and all pikaci data-loading operations (run records, logs, run bundles) behind a clean struct interface, removing the need for callers to manually resolve forge repo config and compute paths.
Affected files: crates/pika-news/src/pikaci_store.rs, crates/pika-news/src/main.rs
@@ -0,0 +1,46 @@
+use std::path::{Path, PathBuf};
+
+use anyhow::{anyhow, Result};
+use pikaci::{load_logs, load_run_bundle, load_run_record, LogKind, Logs, RunBundle, RunRecord};
+
+use crate::config::{Config, ForgeRepoConfig};
+use crate::forge;
+
+#[derive(Clone, Debug)]
+pub struct PikaciRunStore {
+ state_root: PathBuf,
+}
+
+impl PikaciRunStore {
+ pub fn from_config(config: &Config) -> Option<Self> {
+ pub fn from_forge_repo(repo: &ForgeRepoConfig) -> Self {
+ pub fn state_root(&self) -> &Path {
+ pub fn load_run(&self, run_id: &str) -> Result<RunRecord> {
+ pub fn load_logs(&self, run_id: &str, job_id: Option<&str>, kind: LogKind) -> Result<Logs> {
+ pub fn load_run_bundle(&self, run_id: &str) -> Result<RunBundle> {
+}
+
+pub fn require_pikaci_run_store(store: Option<&PikaciRunStore>) -> Result<&PikaciRunStore> {
+ store.ok_or_else(|| anyhow!("forge repo is not configured"))
+}
@@ -13,6 +13,7 @@ mod live;
mod local;
mod mirror;
mod model;
+mod pikaci_store;
mod poller;
The new crates/pika-news/src/pikaci_store.rs file defines PikaciRunStore, a small wrapper around a PathBuf state root. It provides two constructors:
from_config(config: &Config) -> Option<Self>— returnsNonewhen no forge repo is configured, making the optionality explicit at construction time rather than at every call site.from_forge_repo(repo: &ForgeRepoConfig) -> Self— for cases where aForgeRepoConfigis already available.
The struct exposes three data-loading methods (load_run, load_logs, load_run_bundle) that delegate to the raw pikaci crate functions, always passing self.state_root as the base path.
A free function require_pikaci_run_store converts Option<&PikaciRunStore> into a Result, producing a consistent error message when the store is absent.
The module is registered in main.rs via mod pikaci_store;.