Database

Struct Database 

Source
pub struct Database { /* private fields */ }
Expand description

Database connection wrapper with connection pool

Implementations§

Source§

impl Database

Source

pub fn db_path() -> PathBuf

Get the database path that will be used

Source

pub fn new(path: &str) -> Result<Self>

Create a new database at a custom path

Source

pub fn open() -> Result<Self>

Open database at default path (respects DECIDUOUS_DB_PATH env var)

Source

pub fn open_at<P: AsRef<Path>>(path: P) -> Result<Self>

Open database at specified path

Source

pub fn migrate_add_change_ids(&self) -> Result<bool>

Migrate existing database to add change_id columns if missing

Source

pub fn create_node( &self, node_type: &str, title: &str, description: Option<&str>, confidence: Option<u8>, commit: Option<&str>, ) -> Result<i32>

Create a new decision node

Source

pub fn create_node_full( &self, node_type: &str, title: &str, description: Option<&str>, confidence: Option<u8>, commit: Option<&str>, prompt: Option<&str>, files: Option<&str>, branch: Option<&str>, created_at: Option<&str>, ) -> Result<i32>

Create a decision node with full metadata (including prompt and files)

Source

pub fn add_node( &self, node_type: &str, title: &str, description: Option<&str>, confidence: Option<u8>, commit: Option<&str>, ) -> Result<i32>

Add a node (alias for create_node for doc examples)

Source

pub fn create_node_with_change_id( &self, change_id: &str, node_type: &str, title: &str, description: Option<&str>, confidence: Option<u8>, commit: Option<&str>, prompt: Option<&str>, files: Option<&str>, branch: Option<&str>, ) -> Result<i32>

Create a node with a specific change_id (for patch application)

Source

pub fn create_edge( &self, from_id: i32, to_id: i32, edge_type: &str, rationale: Option<&str>, ) -> Result<i32>

Create an edge between nodes

Source

pub fn add_edge( &self, from_id: i32, to_id: i32, edge_type: &str, rationale: Option<&str>, ) -> Result<i32>

Add an edge (alias for create_edge for doc examples)

Source

pub fn delete_edge(&self, from_id: i32, to_id: i32) -> Result<()>

Delete an edge between two nodes

Source

pub fn delete_node(&self, node_id: i32, dry_run: bool) -> Result<DeleteSummary>

Delete a node and all its connected edges

Source

pub fn update_node_status(&self, node_id: i32, status: &str) -> Result<()>

Update node status

Source

pub fn update_node_commit(&self, node_id: i32, commit_hash: &str) -> Result<()>

Update a node’s commit hash in metadata_json

Source

pub fn update_node_prompt(&self, node_id: i32, prompt: &str) -> Result<()>

Update a node’s prompt in metadata_json

Source

pub fn get_all_nodes(&self) -> Result<Vec<DecisionNode>>

Get all nodes

Source

pub fn get_all_edges(&self) -> Result<Vec<DecisionEdge>>

Get all edges

Source

pub fn get_node(&self, node_id: i32) -> Result<Option<DecisionNode>>

Get a single node by ID

Source

pub fn get_node_children(&self, node_id: i32) -> Result<Vec<DecisionNode>>

Get children of a node (outgoing edges)

Source

pub fn get_node_parents(&self, node_id: i32) -> Result<Vec<DecisionNode>>

Get parents of a node (incoming edges)

Source

pub fn get_graph(&self) -> Result<DecisionGraph>

Get full graph as JSON-serializable structure

Source

pub fn get_graph_with_config( &self, config: Option<Config>, ) -> Result<DecisionGraph>

Get full graph with config included (for export)

Source

pub fn log_command( &self, command: &str, description: Option<&str>, working_dir: Option<&str>, ) -> Result<i32>

Log a command execution

Source

pub fn complete_command( &self, log_id: i32, exit_code: i32, stdout: Option<&str>, stderr: Option<&str>, duration_ms: i32, ) -> Result<()>

Complete a command log entry

Source

pub fn get_recent_commands(&self, limit: i64) -> Result<Vec<CommandLog>>

Get recent commands

Source

pub fn create_roadmap_item( &self, title: &str, description: Option<&str>, section: Option<&str>, parent_id: Option<i32>, checkbox_state: &str, ) -> Result<i32>

Create a new roadmap item

Source

pub fn create_roadmap_item_full( &self, change_id: &str, title: &str, description: Option<&str>, section: Option<&str>, parent_id: Option<i32>, checkbox_state: &str, github_issue_number: Option<i32>, github_issue_state: Option<&str>, outcome_node_id: Option<i32>, outcome_change_id: Option<&str>, markdown_line_start: Option<i32>, markdown_line_end: Option<i32>, content_hash: Option<&str>, ) -> Result<i32>

Create a roadmap item with full metadata (for sync operations)

Source

pub fn get_all_roadmap_items(&self) -> Result<Vec<RoadmapItem>>

Get all roadmap items

Source

pub fn clear_roadmap_items(&self) -> Result<usize>

Clear all roadmap items (for refresh)

Source

pub fn get_roadmap_items_by_section( &self, section: &str, ) -> Result<Vec<RoadmapItem>>

Get roadmap items by section

Source

pub fn get_roadmap_item_by_change_id( &self, change_id: &str, ) -> Result<Option<RoadmapItem>>

Get a roadmap item by change_id

Source

pub fn update_roadmap_item_github( &self, item_id: i32, issue_number: Option<i32>, issue_state: Option<&str>, ) -> Result<()>

Update a roadmap item’s GitHub issue info

Source

pub fn update_roadmap_item_github_by_title( &self, title: &str, issue_number: i32, issue_state: &str, ) -> Result<()>

Update a roadmap item’s GitHub issue info by finding it by title (first match)

Source

pub fn update_roadmap_item_github_by_change_id( &self, change_id: &str, issue_number: i32, issue_state: &str, ) -> Result<()>

Update a roadmap item’s GitHub issue info by change_id (unique key)

Link a roadmap item to a decision graph outcome node

Unlink a roadmap item from its outcome node

Source

pub fn update_roadmap_item_checkbox( &self, item_id: i32, checkbox_state: &str, ) -> Result<()>

Update a roadmap item’s checkbox state

Source

pub fn update_roadmap_item_synced(&self, item_id: i32) -> Result<()>

Update last synced timestamp for a roadmap item

Source

pub fn get_roadmap_sync_state( &self, roadmap_path: &str, ) -> Result<Option<RoadmapSyncState>>

Get roadmap sync state (returns None if not initialized)

Source

pub fn get_or_create_sync_state( &self, roadmap_path: &str, ) -> Result<RoadmapSyncState>

Get or create roadmap sync state

Source

pub fn update_sync_state( &self, state_id: i32, content_hash: Option<&str>, github_repo: Option<&str>, github_synced: bool, markdown_parsed: bool, conflict_count: i32, ) -> Result<()>

Update sync state after a sync operation

Source

pub fn create_roadmap_conflict( &self, item_change_id: &str, conflict_type: &str, local_value: Option<&str>, remote_value: Option<&str>, ) -> Result<i32>

Create a conflict record

Source

pub fn get_unresolved_conflicts(&self) -> Result<Vec<RoadmapConflict>>

Get all unresolved conflicts

Source

pub fn resolve_roadmap_conflict( &self, conflict_id: i32, resolution: &str, ) -> Result<()>

Resolve a conflict

Source

pub fn delete_roadmap_item(&self, item_id: i32) -> Result<()>

Delete a roadmap item by ID

Source

pub fn check_roadmap_item_completion( &self, item_id: i32, ) -> Result<(bool, bool, bool)>

Check if a roadmap item is complete (has outcome AND issue closed)

Source

pub fn cache_github_issue( &self, issue_number: i32, repo: &str, title: &str, body: Option<&str>, state: &str, html_url: &str, created_at: &str, updated_at: &str, ) -> Result<()>

Cache a GitHub issue for local display in TUI/Web

Source

pub fn get_cached_issue( &self, repo: &str, issue_number: i32, ) -> Result<Option<GitHubIssueCache>>

Get a cached GitHub issue by repo and number

Source

pub fn get_cached_issues_for_repo( &self, repo: &str, ) -> Result<Vec<GitHubIssueCache>>

Get all cached issues for a repo

Source

pub fn get_all_cached_issues(&self) -> Result<Vec<GitHubIssueCache>>

Get all cached issues

Source

pub fn clear_stale_cache(&self, max_age_hours: i64) -> Result<usize>

Clear cached issues older than a specified duration

Source§

impl Database

Source

pub fn export_patch( &self, node_ids: Option<Vec<i32>>, branch_filter: Option<&str>, author: Option<String>, base_commit: Option<String>, ) -> Result<GraphPatch, DbError>

Export nodes and edges as a patch

Source

pub fn apply_patch( &self, patch: &GraphPatch, dry_run: bool, ) -> Result<ApplyResult, DbError>

Apply a patch to the database

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> AggregateExpressionMethods for T

Source§

fn aggregate_distinct(self) -> Self::Output
where Self: DistinctDsl,

DISTINCT modifier for aggregate functions Read more
Source§

fn aggregate_all(self) -> Self::Output
where Self: AllDsl,

ALL modifier for aggregate functions Read more
Source§

fn aggregate_filter<P>(self, f: P) -> Self::Output
where P: AsExpression<Bool>, Self: FilterDsl<<P as AsExpression<Bool>>::Expression>,

Add an aggregate function filter Read more
Source§

fn aggregate_order<O>(self, o: O) -> Self::Output
where Self: OrderAggregateDsl<O>,

Add an aggregate function order Read more
Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoSql for T

Source§

fn into_sql<T>(self) -> Self::Expression

Convert self to an expression for Diesel’s query builder. Read more
Source§

fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
where &'a Self: AsExpression<T>, T: SqlType + TypedExpressionType,

Convert &self to an expression for Diesel’s query builder. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WindowExpressionMethods for T

Source§

fn over(self) -> Self::Output
where Self: OverDsl,

Turn a function call into a window function call Read more
Source§

fn window_filter<P>(self, f: P) -> Self::Output
where P: AsExpression<Bool>, Self: FilterDsl<<P as AsExpression<Bool>>::Expression>,

Add a filter to the current window function Read more
Source§

fn partition_by<E>(self, expr: E) -> Self::Output
where Self: PartitionByDsl<E>,

Add a partition clause to the current window function Read more
Source§

fn window_order<E>(self, expr: E) -> Self::Output
where Self: OrderWindowDsl<E>,

Add a order clause to the current window function Read more
Source§

fn frame_by<E>(self, expr: E) -> Self::Output
where Self: FrameDsl<E>,

Add a frame clause to the current window function Read more