init hard reset, pipeline

This commit is contained in:
2026-03-24 13:40:34 +00:00
parent 463f72a123
commit 2638b0fc88
37 changed files with 649 additions and 122 deletions
+2
View File
@@ -8,6 +8,8 @@ description = ""
[dependencies]
serde = { version = "1.0.228", features = ["derive"] }
prometeu-core = { path = "../prometeu-core" }
anyhow = "1.0.101"
camino = "1.2.2"
[features]
default = []
+21 -1
View File
@@ -1 +1,21 @@
mod project_registry;
mod model;
mod resolve_project;
mod load_sources;
mod prepare_caches;
pub use resolve_project::resolve_project;
pub use prepare_caches::prepare_caches;
pub use load_sources::load_sources;
pub use model::resolved_project::ResolvedProject;
pub use model::resolved_explanation::ResolveExplanation;
pub use model::deps_config::DepsConfig;
pub use model::project_descriptor::ProjectDescriptor;
pub use model::build_stack::BuildStack;
pub use model::resolved_graph::ResolvedGraph;
pub use model::loaded_sources::LoadedSources;
pub use model::project_sources::ProjectSources;
pub use model::loaded_file::LoadedFile;
pub use model::cache_blobs::CacheBlobs;
pub use model::cache_plan::CachePlan;
@@ -0,0 +1,5 @@
use crate::{DepsConfig, LoadedSources, ResolvedProject};
pub fn load_sources(p0: &DepsConfig, p1: &ResolvedProject) -> anyhow::Result<LoadedSources> {
todo!()
}
@@ -0,0 +1,7 @@
use crate::model::project_descriptor::ProjectDescriptor;
#[derive(Debug, Clone)]
pub struct BuildStack {
/// deps-first order
pub projects: Vec<ProjectDescriptor>,
}
@@ -0,0 +1,7 @@
/// Cache blobs computed/validated by deps.
/// The pipeline may decide when to store, but deps executes IO and cache validity.
#[derive(Debug, Clone)]
pub struct CacheBlobs {
// placeholder
pub _unused: (),
}
@@ -0,0 +1,4 @@
#[derive(Debug, Clone)]
pub struct CachePlan {
}
@@ -0,0 +1,8 @@
use camino::Utf8PathBuf;
pub struct DepsConfig {
pub explain: bool,
// diretórios e política (só deps entende isso)
pub cache_dir: Utf8PathBuf,
pub registry_dirs: Vec<Utf8PathBuf>, // ou sources
}
@@ -0,0 +1,5 @@
#[derive(Debug, Clone)]
pub struct LoadedFile {
pub uri: String,
pub text: String,
}
@@ -0,0 +1,8 @@
use crate::model::project_sources::ProjectSources;
/// Sources already loaded by deps (IO happens in deps, not in pipeline).
#[derive(Debug, Clone)]
pub struct LoadedSources {
/// For each project in the stack, a list of files (uri + text).
pub per_project: Vec<ProjectSources>,
}
@@ -0,0 +1,11 @@
pub mod deps_config;
pub mod project_descriptor;
pub mod build_stack;
pub mod resolved_graph;
pub mod loaded_sources;
pub mod project_sources;
pub mod loaded_file;
pub mod cache_blobs;
pub mod resolved_project;
pub mod resolved_explanation;
pub(crate) mod cache_plan;
@@ -0,0 +1,8 @@
use prometeu_core::ProjectId;
#[derive(Debug, Clone)]
pub struct ProjectDescriptor {
pub project_id: ProjectId,
pub name: String,
pub version: String,
}
@@ -0,0 +1,8 @@
use prometeu_core::ProjectId;
use crate::model::loaded_file::LoadedFile;
#[derive(Debug, Clone)]
pub struct ProjectSources {
pub project_id: ProjectId,
pub files: Vec<LoadedFile>,
}
@@ -0,0 +1,4 @@
#[derive(Debug, Clone)]
pub struct ResolveExplanation {
}
@@ -0,0 +1,10 @@
use prometeu_core::ProjectId;
use crate::ProjectDescriptor;
#[derive(Debug, Clone)]
pub struct ResolvedGraph {
pub root: ProjectId,
pub projects: Vec<ProjectDescriptor>, // arena
// opcional: adjacency list para checks
pub edges: Vec<Vec<ProjectId>>, // edges[from] = vec[to]
}
@@ -0,0 +1,9 @@
use crate::{BuildStack, ResolvedGraph, ResolveExplanation, CachePlan};
#[derive(Debug, Clone)]
pub struct ResolvedProject {
pub graph: ResolvedGraph,
pub stack: BuildStack,
pub explain: Option<ResolveExplanation>,
pub cache_plan: CachePlan,
}
@@ -0,0 +1,5 @@
use crate::{CacheBlobs, CachePlan, DepsConfig};
pub fn prepare_caches(cfg: &DepsConfig, cache_plan: &CachePlan) -> anyhow::Result<CacheBlobs> {
todo!()
}
@@ -1,69 +0,0 @@
use std::collections::HashMap;
use prometeu_core::ProjectId;
#[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
pub struct ProjectKey {
pub name: String,
pub version: String,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct ProjectMeta {
pub id: ProjectId,
pub name: String,
pub version: String,
}
#[derive(Debug, Default, Clone)]
pub struct ProjectRegistry {
by_name: HashMap<ProjectKey, ProjectId>,
projects: Vec<ProjectMeta>,
}
impl ProjectRegistry {
pub fn new() -> Self { Self::default() }
pub fn intern(&mut self, key: &ProjectKey) -> ProjectId {
if let Some(id) = self.by_name.get(key).copied() { return id; }
let id = ProjectId(self.projects.len() as u32);
self.by_name.insert(key.clone(), id);
self.projects.push(ProjectMeta { id, name: key.name.clone(), version: key.version.clone() });
id
}
pub fn meta(&self, id: ProjectId) -> Option<&ProjectMeta> {
self.projects.get(id.as_usize())
}
pub fn key_of(&self, id: ProjectId) -> Option<ProjectKey> {
self.meta(id).map(|m| ProjectKey { name: m.name.clone(), version: m.version.clone() })
}
pub fn len(&self) -> usize { self.projects.len() }
pub fn is_empty(&self) -> bool { self.projects.is_empty() }
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn project_registry_stable_ids_for_same_key() {
let mut reg = ProjectRegistry::new();
let k = ProjectKey { name: "sdk".into(), version: "1.0.0".into() };
let id1 = reg.intern(&k);
let id2 = reg.intern(&k);
assert_eq!(id1, id2);
// Different version -> different id
let k2 = ProjectKey { name: "sdk".into(), version: "1.1.0".into() };
let id3 = reg.intern(&k2);
assert_ne!(id1, id3);
// Meta lookup
let m1 = reg.meta(id1).unwrap();
assert_eq!(m1.name, "sdk");
assert_eq!(m1.version, "1.0.0");
}
}
@@ -0,0 +1,8 @@
use crate::{DepsConfig, ResolvedProject};
use camino::Utf8Path;
use std::path::Path;
pub fn resolve_project(cfg: &DepsConfig, path: &Path) -> anyhow::Result<ResolvedProject> {
let project_dir = Utf8Path::from_path(path).unwrap();
todo!()
}