pub struct Database { /* private fields */ }Expand description
Database connection wrapper with connection pool
Implementations§
Source§impl Database
impl Database
Sourcepub fn open() -> Result<Self>
pub fn open() -> Result<Self>
Open database at default path (respects DECIDUOUS_DB_PATH env var)
Sourcepub fn migrate_add_change_ids(&self) -> Result<bool>
pub fn migrate_add_change_ids(&self) -> Result<bool>
Migrate existing database to add change_id columns if missing
Sourcepub fn create_node(
&self,
node_type: &str,
title: &str,
description: Option<&str>,
confidence: Option<u8>,
commit: Option<&str>,
) -> Result<i32>
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
Sourcepub 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>
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)
Sourcepub fn add_node(
&self,
node_type: &str,
title: &str,
description: Option<&str>,
confidence: Option<u8>,
commit: Option<&str>,
) -> Result<i32>
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)
Sourcepub 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>
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)
Sourcepub fn create_edge(
&self,
from_id: i32,
to_id: i32,
edge_type: &str,
rationale: Option<&str>,
) -> Result<i32>
pub fn create_edge( &self, from_id: i32, to_id: i32, edge_type: &str, rationale: Option<&str>, ) -> Result<i32>
Create an edge between nodes
Sourcepub fn add_edge(
&self,
from_id: i32,
to_id: i32,
edge_type: &str,
rationale: Option<&str>,
) -> Result<i32>
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)
Sourcepub fn delete_edge(&self, from_id: i32, to_id: i32) -> Result<()>
pub fn delete_edge(&self, from_id: i32, to_id: i32) -> Result<()>
Delete an edge between two nodes
Sourcepub fn delete_node(&self, node_id: i32, dry_run: bool) -> Result<DeleteSummary>
pub fn delete_node(&self, node_id: i32, dry_run: bool) -> Result<DeleteSummary>
Delete a node and all its connected edges
Sourcepub fn update_node_commit(&self, node_id: i32, commit_hash: &str) -> Result<()>
pub fn update_node_commit(&self, node_id: i32, commit_hash: &str) -> Result<()>
Update a node’s commit hash in metadata_json
Sourcepub fn update_node_prompt(&self, node_id: i32, prompt: &str) -> Result<()>
pub fn update_node_prompt(&self, node_id: i32, prompt: &str) -> Result<()>
Update a node’s prompt in metadata_json
Sourcepub fn get_all_nodes(&self) -> Result<Vec<DecisionNode>>
pub fn get_all_nodes(&self) -> Result<Vec<DecisionNode>>
Get all nodes
Sourcepub fn get_all_edges(&self) -> Result<Vec<DecisionEdge>>
pub fn get_all_edges(&self) -> Result<Vec<DecisionEdge>>
Get all edges
Sourcepub fn get_node_children(&self, node_id: i32) -> Result<Vec<DecisionNode>>
pub fn get_node_children(&self, node_id: i32) -> Result<Vec<DecisionNode>>
Get children of a node (outgoing edges)
Sourcepub fn get_node_parents(&self, node_id: i32) -> Result<Vec<DecisionNode>>
pub fn get_node_parents(&self, node_id: i32) -> Result<Vec<DecisionNode>>
Get parents of a node (incoming edges)
Sourcepub fn get_graph(&self) -> Result<DecisionGraph>
pub fn get_graph(&self) -> Result<DecisionGraph>
Get full graph as JSON-serializable structure
Sourcepub fn get_graph_with_config(
&self,
config: Option<Config>,
) -> Result<DecisionGraph>
pub fn get_graph_with_config( &self, config: Option<Config>, ) -> Result<DecisionGraph>
Get full graph with config included (for export)
Sourcepub fn log_command(
&self,
command: &str,
description: Option<&str>,
working_dir: Option<&str>,
) -> Result<i32>
pub fn log_command( &self, command: &str, description: Option<&str>, working_dir: Option<&str>, ) -> Result<i32>
Log a command execution
Sourcepub fn complete_command(
&self,
log_id: i32,
exit_code: i32,
stdout: Option<&str>,
stderr: Option<&str>,
duration_ms: i32,
) -> Result<()>
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
Sourcepub fn get_recent_commands(&self, limit: i64) -> Result<Vec<CommandLog>>
pub fn get_recent_commands(&self, limit: i64) -> Result<Vec<CommandLog>>
Get recent commands
Sourcepub fn create_roadmap_item(
&self,
title: &str,
description: Option<&str>,
section: Option<&str>,
parent_id: Option<i32>,
checkbox_state: &str,
) -> Result<i32>
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
Sourcepub 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>
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)
Sourcepub fn get_all_roadmap_items(&self) -> Result<Vec<RoadmapItem>>
pub fn get_all_roadmap_items(&self) -> Result<Vec<RoadmapItem>>
Get all roadmap items
Sourcepub fn clear_roadmap_items(&self) -> Result<usize>
pub fn clear_roadmap_items(&self) -> Result<usize>
Clear all roadmap items (for refresh)
Sourcepub fn get_roadmap_items_by_section(
&self,
section: &str,
) -> Result<Vec<RoadmapItem>>
pub fn get_roadmap_items_by_section( &self, section: &str, ) -> Result<Vec<RoadmapItem>>
Get roadmap items by section
Sourcepub fn get_roadmap_item_by_change_id(
&self,
change_id: &str,
) -> Result<Option<RoadmapItem>>
pub fn get_roadmap_item_by_change_id( &self, change_id: &str, ) -> Result<Option<RoadmapItem>>
Get a roadmap item by change_id
Sourcepub fn update_roadmap_item_github(
&self,
item_id: i32,
issue_number: Option<i32>,
issue_state: Option<&str>,
) -> Result<()>
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
Sourcepub fn update_roadmap_item_github_by_title(
&self,
title: &str,
issue_number: i32,
issue_state: &str,
) -> Result<()>
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)
Sourcepub fn update_roadmap_item_github_by_change_id(
&self,
change_id: &str,
issue_number: i32,
issue_state: &str,
) -> Result<()>
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)
Sourcepub fn link_roadmap_to_outcome(
&self,
item_id: i32,
outcome_node_id: i32,
outcome_change_id: &str,
) -> Result<()>
pub fn link_roadmap_to_outcome( &self, item_id: i32, outcome_node_id: i32, outcome_change_id: &str, ) -> Result<()>
Link a roadmap item to a decision graph outcome node
Sourcepub fn unlink_roadmap_from_outcome(&self, item_id: i32) -> Result<()>
pub fn unlink_roadmap_from_outcome(&self, item_id: i32) -> Result<()>
Unlink a roadmap item from its outcome node
Sourcepub fn update_roadmap_item_checkbox(
&self,
item_id: i32,
checkbox_state: &str,
) -> Result<()>
pub fn update_roadmap_item_checkbox( &self, item_id: i32, checkbox_state: &str, ) -> Result<()>
Update a roadmap item’s checkbox state
Sourcepub fn update_roadmap_item_synced(&self, item_id: i32) -> Result<()>
pub fn update_roadmap_item_synced(&self, item_id: i32) -> Result<()>
Update last synced timestamp for a roadmap item
Sourcepub fn get_roadmap_sync_state(
&self,
roadmap_path: &str,
) -> Result<Option<RoadmapSyncState>>
pub fn get_roadmap_sync_state( &self, roadmap_path: &str, ) -> Result<Option<RoadmapSyncState>>
Get roadmap sync state (returns None if not initialized)
Sourcepub fn get_or_create_sync_state(
&self,
roadmap_path: &str,
) -> Result<RoadmapSyncState>
pub fn get_or_create_sync_state( &self, roadmap_path: &str, ) -> Result<RoadmapSyncState>
Get or create roadmap sync state
Sourcepub 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<()>
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
Sourcepub fn create_roadmap_conflict(
&self,
item_change_id: &str,
conflict_type: &str,
local_value: Option<&str>,
remote_value: Option<&str>,
) -> Result<i32>
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
Sourcepub fn get_unresolved_conflicts(&self) -> Result<Vec<RoadmapConflict>>
pub fn get_unresolved_conflicts(&self) -> Result<Vec<RoadmapConflict>>
Get all unresolved conflicts
Sourcepub fn resolve_roadmap_conflict(
&self,
conflict_id: i32,
resolution: &str,
) -> Result<()>
pub fn resolve_roadmap_conflict( &self, conflict_id: i32, resolution: &str, ) -> Result<()>
Resolve a conflict
Sourcepub fn delete_roadmap_item(&self, item_id: i32) -> Result<()>
pub fn delete_roadmap_item(&self, item_id: i32) -> Result<()>
Delete a roadmap item by ID
Sourcepub fn check_roadmap_item_completion(
&self,
item_id: i32,
) -> Result<(bool, bool, bool)>
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)
Sourcepub 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<()>
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
Sourcepub fn get_cached_issue(
&self,
repo: &str,
issue_number: i32,
) -> Result<Option<GitHubIssueCache>>
pub fn get_cached_issue( &self, repo: &str, issue_number: i32, ) -> Result<Option<GitHubIssueCache>>
Get a cached GitHub issue by repo and number
Sourcepub fn get_cached_issues_for_repo(
&self,
repo: &str,
) -> Result<Vec<GitHubIssueCache>>
pub fn get_cached_issues_for_repo( &self, repo: &str, ) -> Result<Vec<GitHubIssueCache>>
Get all cached issues for a repo
Sourcepub fn get_all_cached_issues(&self) -> Result<Vec<GitHubIssueCache>>
pub fn get_all_cached_issues(&self) -> Result<Vec<GitHubIssueCache>>
Get all cached issues
Sourcepub fn clear_stale_cache(&self, max_age_hours: i64) -> Result<usize>
pub fn clear_stale_cache(&self, max_age_hours: i64) -> Result<usize>
Clear cached issues older than a specified duration
Source§impl Database
impl Database
Sourcepub fn export_patch(
&self,
node_ids: Option<Vec<i32>>,
branch_filter: Option<&str>,
author: Option<String>,
base_commit: Option<String>,
) -> Result<GraphPatch, DbError>
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
Sourcepub fn apply_patch(
&self,
patch: &GraphPatch,
dry_run: bool,
) -> Result<ApplyResult, DbError>
pub fn apply_patch( &self, patch: &GraphPatch, dry_run: bool, ) -> Result<ApplyResult, DbError>
Apply a patch to the database
Auto Trait Implementations§
impl Freeze for Database
impl !RefUnwindSafe for Database
impl Send for Database
impl Sync for Database
impl Unpin for Database
impl !UnwindSafe for Database
Blanket Implementations§
Source§impl<T> AggregateExpressionMethods for T
impl<T> AggregateExpressionMethods for T
Source§fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
DISTINCT modifier for aggregate functions Read moreSource§fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
ALL modifier for aggregate functions Read moreSource§fn aggregate_filter<P>(self, f: P) -> Self::Output
fn aggregate_filter<P>(self, f: P) -> Self::Output
Source§fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> IntoSql for T
impl<T> IntoSql for T
Source§fn into_sql<T>(self) -> Self::Expression
fn into_sql<T>(self) -> Self::Expression
self to an expression for Diesel’s query builder. Read moreSource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
&self to an expression for Diesel’s query builder. Read more