Fully Automated - 100% Backpressure - Pipeline runner ๐Ÿƒ for AI workflows. ๐Ÿš€

Commit 9feea5a3

9feea5a36520Merged

Scott Nixon <[email protected]> ยท 9 months ago ยท 3 files ยท +1 added ยท ~2 modified

Description

[attractor-86n] Add SQLite database layer for multi-project workspace

Implements the persistence foundation for the multi-project workspace epic.

Changes:

  • Created src/server/db.rs with SQLite pool initialization
  • Implemented CRUD functions: init_db, upsert_project, list_open_projects, close_project, upsert_document, get_documents
  • Database location: ~/.attractor/web.db
  • Schema: projects table (folder_path, name, is_open) and documents table (cached content per project)
  • Added comprehensive test suite (11 tests, all passing)
  • Module gated behind #[cfg(feature = "ssr")]

Technical decisions:

  • Uses runtime-checked sqlx::query_as (not compile-time macros)
  • Idempotent schema with CREATE TABLE IF NOT EXISTS
  • Soft-close projects (is_open=0) rather than deletion

All acceptance criteria met and verified.

Details

Commit
9feea5a36520
Parent
f8003dd54305

crates/attractor-cli/src/main.rsmodifiedView file

@@ -26,9 +26,9 @@
2626 #[arg(short, long)]
2727 workdir: Option<PathBuf>,
2828
29- /// Logs output directory
30- #[arg(short, long, default_value = ".attractor/logs")]
31- logs: PathBuf,
29+ /// Logs output directory (default: .attractor/logs/<pipeline>-<hash>)
30+ #[arg(short, long)]
31+ logs: Option<PathBuf>,
3232
3333 /// Don't actually call LLMs (dry run)
3434 #[arg(long)]
@@ -114,7 +114,7 @@
114114 max_budget_usd,
115115 max_steps,
116116 } => {
117- cmd_run(&pipeline, workdir.as_deref(), &logs, dry_run, max_budget_usd, max_steps).await?;
117+ cmd_run(&pipeline, workdir.as_deref(), logs.as_deref(), dry_run, max_budget_usd, max_steps).await?;
118118 }
119119 Commands::Validate { pipeline } => {
120120 cmd_validate(&pipeline)?;
@@ -204,20 +204,47 @@
204204 Ok(())
205205 }
206206
207+/// Generate a unique logs directory name from the pipeline filename and a short random suffix.
208+/// Format: `.attractor/logs/<stem>-<8hex>` e.g. `.attractor/logs/attractor-e0n-a3f1b2c9`
209+fn unique_logs_dir(pipeline_path: &std::path::Path) -> PathBuf {
210+ use std::collections::hash_map::DefaultHasher;
211+ use std::hash::{Hash, Hasher};
212+
213+ let stem = pipeline_path
214+ .file_stem()
215+ .unwrap_or_default()
216+ .to_string_lossy();
217+
218+ // Hash the current time + PID for uniqueness across concurrent runs
219+ let mut hasher = DefaultHasher::new();
220+ std::time::SystemTime::now().hash(&mut hasher);
221+ std::process::id().hash(&mut hasher);
222+ let hash = hasher.finish();
223+
224+ PathBuf::from(format!(".attractor/logs/{}-{:08x}", stem, hash as u32))
225+}
226+
207227 async fn cmd_run(
208228 path: &std::path::Path,
209229 workdir: Option<&std::path::Path>,
210- _logs: &std::path::Path,
230+ logs: Option<&std::path::Path>,
211231 dry_run: bool,
212232 max_budget_usd: Option<f64>,
213233 max_steps: u64,
214234 ) -> anyhow::Result<()> {
215235 let graph = load_pipeline(path)?;
216236
237+ // Resolve logs directory: explicit flag or auto-generated unique path
238+ let logs_dir = match logs {
239+ Some(l) => l.to_path_buf(),
240+ None => unique_logs_dir(path),
241+ };
242+
217243 println!("Running pipeline: {}", graph.name);
218244 if !graph.goal.is_empty() {
219245 println!("Goal: {}", graph.goal);
220246 }
247+ println!("Logs: {}", logs_dir.display());
221248 if dry_run {
222249 println!("(dry run mode -- no LLM calls)");
223250 }