pub struct Database { /* private fields */ }Implementations§
Source§impl Database
impl Database
Sourcepub fn upsert_issue_index(
&self,
issue: &IssueIndexEntry,
workspace_id: &str,
sync_token: &str,
) -> Result<IndexUpsertOutcome>
pub fn upsert_issue_index( &self, issue: &IssueIndexEntry, workspace_id: &str, sync_token: &str, ) -> Result<IndexUpsertOutcome>
Merge the authoritative list/index fields without replacing rich fields populated by an earlier hydration.
pub fn mark_hydration_running( &self, workspace_id: &str, issue_id: &str, resource: HydrationResource, attempted_at: &str, ) -> Result<u32>
pub fn requeue_issue_hydration( &self, workspace_id: &str, issue_id: &str, reason: &str, ) -> Result<()>
pub fn requeue_team_hydration( &self, workspace_id: &str, team_key: &str, reason: &str, ) -> Result<usize>
pub fn requeue_team_retryable_comments( &self, workspace_id: &str, team_key: &str, ) -> Result<usize>
pub fn mark_hydration_complete( &self, workspace_id: &str, issue_id: &str, resource: HydrationResource, source_updated_at: &str, hydrated_at: &str, ) -> Result<()>
pub fn mark_hydration_failed( &self, workspace_id: &str, issue_id: &str, resource: HydrationResource, status: HydrationStatus, next_retry_at: Option<&str>, error: &str, ) -> Result<()>
pub fn get_issue_hydration_state( &self, workspace_id: &str, issue_id: &str, ) -> Result<IssueHydrationState>
pub fn queue_stale_comment_hydration( &self, workspace_id: &str, team_key: &str, policy: HydrationPolicy, stale_before: &str, recent_after: &str, ) -> Result<usize>
pub fn queue_stale_issue_comment_hydration( &self, workspace_id: &str, issue_id: &str, stale_before: &str, ) -> Result<usize>
pub fn list_hydration_candidates( &self, workspace_id: &str, team_key: &str, limit: usize, policy: HydrationPolicy, now: &str, recent_after: &str, ) -> Result<Vec<HydrationCandidate>>
pub fn ensure_hydration_state_for_issue( &self, workspace_id: &str, issue: &Issue, reason: &str, ) -> Result<()>
Source§impl Database
impl Database
pub fn upsert_project_metadata(&self, project: &Project) -> Result<()>
pub fn upsert_project(&self, project: &Project) -> Result<()>
pub fn upsert_project_milestone( &self, milestone: &ProjectMilestone, ) -> Result<()>
pub fn get_project( &self, workspace_id: &str, id_or_name: &str, ) -> Result<Option<Project>>
pub fn list_projects( &self, workspace_id: &str, include_archived: bool, ) -> Result<Vec<Project>>
pub fn get_project_milestone( &self, workspace_id: &str, id_or_name: &str, project_id: Option<&str>, ) -> Result<Option<ProjectMilestone>>
pub fn list_project_milestones( &self, project_id: &str, ) -> Result<Vec<ProjectMilestone>>
pub fn get_project_bundle( &self, workspace_id: &str, id_or_name: &str, ) -> Result<Option<ProjectBundle>>
pub fn get_project_milestone_bundle( &self, workspace_id: &str, id_or_name: &str, project_id: Option<&str>, ) -> Result<Option<ProjectMilestoneBundle>>
pub fn list_project_issues( &self, workspace_id: &str, project_id: &str, ) -> Result<Vec<Issue>>
pub fn list_project_milestone_issues( &self, workspace_id: &str, milestone_id: &str, ) -> Result<Vec<Issue>>
pub fn reconcile_project_issue_membership( &self, workspace_id: &str, project_id: &str, keep_issue_ids: &[String], ) -> Result<usize>
pub fn reconcile_project_milestone_issue_membership( &self, workspace_id: &str, milestone_id: &str, keep_issue_ids: &[String], ) -> Result<usize>
pub fn delete_project_local(&self, project_id: &str) -> Result<usize>
pub fn delete_project_milestone_local( &self, milestone_id: &str, ) -> Result<usize>
pub fn delete_projects_for_workspace_not_in( &self, workspace_id: &str, keep_ids: &[String], ) -> Result<usize>
pub fn delete_milestones_for_workspace_not_in( &self, workspace_id: &str, keep_ids: &[String], ) -> Result<usize>
pub fn delete_milestones_for_project_not_in( &self, project_id: &str, keep_ids: &[String], ) -> Result<usize>
Source§impl Database
impl Database
pub fn upsert_issue_label_page( &self, issue_id: &str, label_ids: &[String], sync_token: &str, ) -> Result<()>
pub fn complete_issue_label_sync( &self, issue_id: &str, sync_token: &str, ) -> Result<usize>
pub fn mark_project_sync_token( &self, project_id: &str, sync_token: &str, ) -> Result<()>
pub fn list_project_ids_for_sync_token( &self, workspace_id: &str, sync_token: &str, after_id: Option<&str>, limit: usize, ) -> Result<Vec<String>>
pub fn reconcile_workspace_projects( &self, workspace_id: &str, sync_token: &str, ) -> Result<usize>
pub fn reconcile_team_projects( &self, workspace_id: &str, team_key: &str, sync_token: &str, ) -> Result<usize>
pub fn upsert_project_team_page( &self, project_id: &str, teams: &[ProjectTeam], sync_token: &str, ) -> Result<()>
pub fn complete_project_team_sync( &self, project_id: &str, sync_token: &str, ) -> Result<usize>
pub fn upsert_project_member_page( &self, project_id: &str, members: &[ProjectMember], sync_token: &str, ) -> Result<()>
pub fn complete_project_member_sync( &self, project_id: &str, sync_token: &str, ) -> Result<usize>
pub fn upsert_project_label_page( &self, project_id: &str, labels: &[ProjectLabel], sync_token: &str, ) -> Result<()>
pub fn complete_project_label_sync( &self, project_id: &str, sync_token: &str, ) -> Result<usize>
pub fn mark_project_milestone_sync_token( &self, milestone_id: &str, sync_token: &str, ) -> Result<()>
pub fn reconcile_project_milestones_by_token( &self, project_id: &str, sync_token: &str, ) -> Result<usize>
pub fn mark_label_sync_token( &self, label_id: &str, sync_token: &str, ) -> Result<()>
pub fn reconcile_label_sync( &self, workspace_id: &str, sync_token: &str, ) -> Result<usize>
pub fn mark_issue_sync_token( &self, issue_id: &str, sync_token: &str, ) -> Result<()>
pub fn list_issue_sync_refs( &self, workspace_id: &str, team_key: &str, sync_token: &str, after_id: Option<&str>, limit: usize, ) -> Result<Vec<IssueSyncRef>>
Sourcepub fn list_comment_hydration_refs(
&self,
workspace_id: &str,
team_key: &str,
sync_token: &str,
after_id: Option<&str>,
limit: usize,
) -> Result<Vec<IssueSyncRef>>
pub fn list_comment_hydration_refs( &self, workspace_id: &str, team_key: &str, sync_token: &str, after_id: Option<&str>, limit: usize, ) -> Result<Vec<IssueSyncRef>>
Issues changed in this catalog sync plus any issue whose previous comment hydration failed. The latter makes supplemental failures naturally recoverable even after the authoritative issue cursor moves.
pub fn reconcile_full_issue_sync( &self, workspace_id: &str, team_key: &str, sync_token: &str, ) -> Result<usize>
Sourcepub fn reconcile_full_issue_index(
&self,
workspace_id: &str,
team_key: &str,
sync_token: &str,
upper_bound: &str,
) -> Result<usize>
pub fn reconcile_full_issue_index( &self, workspace_id: &str, team_key: &str, sync_token: &str, upper_bound: &str, ) -> Result<usize>
Reconcile a full issue-index traversal as of its fixed upper bound. Locally cached rows newer than that bound were intentionally outside the traversal and must not be mistaken for hard deletions.
pub fn upsert_relation_page( &self, issue_id: &str, relations: &[Relation], sync_token: &str, ) -> Result<()>
pub fn complete_relation_sync( &self, issue_id: &str, sync_token: &str, ) -> Result<usize>
pub fn upsert_comment_page( &self, issue_id: &str, workspace_id: &str, comments: &[Comment], sync_token: &str, ) -> Result<()>
pub fn complete_comment_sync( &self, issue_id: &str, workspace_id: &str, sync_token: &str, ) -> Result<usize>
pub fn upsert_cycle(&self, cycle: &Cycle, sync_token: &str) -> Result<()>
pub fn reconcile_cycles( &self, workspace_id: &str, team_key: &str, sync_token: &str, ) -> Result<usize>
pub fn mark_sync_family_running( &self, workspace_id: &str, team_key: &str, family: &str, cursor: Option<&str>, page_size: Option<usize>, sync_token: &str, ) -> Result<()>
pub fn mark_sync_family_complete( &self, workspace_id: &str, team_key: &str, family: &str, page_size: Option<usize>, sync_token: &str, ) -> Result<()>
pub fn mark_sync_family_failed( &self, workspace_id: &str, team_key: &str, family: &str, sync_token: &str, error: &str, ) -> Result<()>
pub fn mark_sync_family_partial( &self, workspace_id: &str, team_key: &str, family: &str, sync_token: &str, error: &str, ) -> Result<()>
pub fn get_sync_family_state( &self, workspace_id: &str, team_key: &str, family: &str, ) -> Result<Option<SyncFamilyState>>
Source§impl Database
impl Database
pub fn open(path: &Path) -> Result<Self>
pub fn with_conn<F, T>(&self, f: F) -> Result<T>
pub fn upsert_workspace( &self, id: &str, linear_org_id: Option<&str>, display_name: Option<&str>, ) -> Result<()>
pub fn get_workspace(&self, id: &str) -> Result<Option<WorkspaceRow>>
pub fn list_workspaces(&self) -> Result<Vec<WorkspaceRow>>
Sourcepub fn delete_workspace(&self, id: &str) -> Result<usize>
pub fn delete_workspace(&self, id: &str) -> Result<usize>
Delete a workspace and all its associated data (issues, chunks, comments, sync state).
pub fn upsert_label(&self, label: &Label) -> Result<()>
pub fn list_labels(&self, workspace_id: &str) -> Result<Vec<Label>>
Sourcepub fn delete_labels_for_workspace_not_in(
&self,
workspace_id: &str,
keep_ids: &[String],
) -> Result<usize>
pub fn delete_labels_for_workspace_not_in( &self, workspace_id: &str, keep_ids: &[String], ) -> Result<usize>
Delete labels in workspace_id whose id is NOT in keep_ids.
Returns the number of rows deleted. Cascades to issue_labels.
Sourcepub fn resolve_label_ids_local(
&self,
workspace_id: &str,
names: &[String],
) -> Result<(Vec<String>, Vec<String>)>
pub fn resolve_label_ids_local( &self, workspace_id: &str, names: &[String], ) -> Result<(Vec<String>, Vec<String>)>
Resolve label names to ids using the local catalog (case-insensitive). Returns (resolved_ids, unknown_names). Order of resolved_ids is not guaranteed.
Sourcepub fn replace_issue_labels(
&self,
issue_id: &str,
label_ids: &[String],
) -> Result<()>
pub fn replace_issue_labels( &self, issue_id: &str, label_ids: &[String], ) -> Result<()>
Replace the label set for an issue. Atomic via transaction.
Skips any label_ids not present in the labels table (logged at warn level via eprintln).
pub fn get_issue_label_ids(&self, issue_id: &str) -> Result<Vec<String>>
pub fn upsert_issue(&self, issue: &Issue) -> Result<()>
pub fn upsert_issue_preserving_labels(&self, issue: &Issue) -> Result<()>
pub fn get_issue(&self, id_or_identifier: &str) -> Result<Option<Issue>>
pub fn get_unprioritized_issues( &self, team_key: Option<&str>, include_completed: bool, workspace_id: &str, ) -> Result<Vec<Issue>>
pub fn get_unprioritized_issues_filtered( &self, team_key: Option<&str>, include_completed: bool, workspace_id: &str, label_ids: Option<&[String]>, ) -> Result<Vec<Issue>>
pub fn get_issues_by_state_types( &self, team_key: &str, state_types: &[String], workspace_id: &str, ) -> Result<Vec<Issue>>
Sourcepub fn get_blockers_for_issues(
&self,
issue_ids: &[String],
) -> Result<Vec<BlockerRow>>
pub fn get_blockers_for_issues( &self, issue_ids: &[String], ) -> Result<Vec<BlockerRow>>
For a set of issue IDs, return all blocked_by relations with resolved state info.
Returns (issue_id, blocker_identifier, blocker_title, blocker_state_name, blocker_state_type).
pub fn count_issues( &self, team_key: Option<&str>, workspace_id: &str, ) -> Result<usize>
Sourcepub fn get_field_completeness(
&self,
team_key: Option<&str>,
workspace_id: &str,
) -> Result<(usize, usize, usize, usize, usize)>
pub fn get_field_completeness( &self, team_key: Option<&str>, workspace_id: &str, ) -> Result<(usize, usize, usize, usize, usize)>
Count issues with each optional field populated. Returns (total, with_description, with_priority, with_labels, with_project).
Sourcepub fn list_all_issues(
&self,
team_key: Option<&str>,
filter: Option<&str>,
limit: usize,
offset: usize,
workspace_id: &str,
) -> Result<Vec<IssueSummary>>
pub fn list_all_issues( &self, team_key: Option<&str>, filter: Option<&str>, limit: usize, offset: usize, workspace_id: &str, ) -> Result<Vec<IssueSummary>>
List all issues with summary info (no description text). Supports pagination, optional team filter, and optional text filter on identifier/title.
pub fn upsert_relations( &self, issue_id: &str, relations: &[Relation], ) -> Result<()>
pub fn get_relations_enriched( &self, issue_id: &str, ) -> Result<Vec<EnrichedRelation>>
Sourcepub fn find_relation_id(
&self,
issue_id: &str,
related_issue_id: &str,
relation_type: &str,
) -> Result<Option<String>>
pub fn find_relation_id( &self, issue_id: &str, related_issue_id: &str, relation_type: &str, ) -> Result<Option<String>>
Look up a relation ID between two issues (by identifier) for deletion
pub fn upsert_chunks( &self, issue_id: &str, chunks: &[(usize, String, Vec<u8>)], ) -> Result<()>
pub fn upsert_chunks_with_model( &self, issue_id: &str, chunks: &[(usize, String, Vec<u8>)], model_name: &str, ) -> Result<()>
pub fn upsert_chunks_with_model_and_hash( &self, issue_id: &str, chunks: &[(usize, String, Vec<u8>)], model_name: &str, source_content_hash: &str, ) -> Result<()>
Sourcepub fn get_embedding_model(&self, issue_id: &str) -> Result<Option<String>>
pub fn get_embedding_model(&self, issue_id: &str) -> Result<Option<String>>
Get the embedding model name for an issue’s chunks, if any exist.
pub fn compute_issue_embedding_content_hash( &self, issue_id: &str, ) -> Result<String>
pub fn get_all_chunks(&self, workspace_id: &str) -> Result<Vec<Chunk>>
pub fn get_chunks_for_team( &self, team_key: &str, workspace_id: &str, ) -> Result<Vec<Chunk>>
pub fn count_embedded_issues( &self, team_key: Option<&str>, workspace_id: &str, ) -> Result<usize>
pub fn get_issues_needing_embedding( &self, team_key: Option<&str>, force: bool, workspace_id: &str, ) -> Result<Vec<Issue>>
pub fn get_issues_needing_embedding_for_model( &self, team_key: Option<&str>, force: bool, workspace_id: &str, model_name: Option<&str>, ) -> Result<Vec<Issue>>
pub fn get_comments(&self, issue_id: &str) -> Result<Vec<Comment>>
pub fn replace_issue_comments( &self, issue_id: &str, workspace_id: &str, comments: &[Comment], ) -> Result<()>
pub fn get_comment_sync_state(&self, issue_id: &str) -> Result<CommentSyncState>
pub fn mark_comments_synced( &self, issue_id: &str, workspace_id: &str, comment_count: usize, ) -> Result<()>
pub fn mark_comments_sync_failed( &self, issue_id: &str, workspace_id: &str, status: &str, error: &str, ) -> Result<()>
pub fn get_sync_cursor( &self, workspace_id: &str, team_key: &str, ) -> Result<Option<String>>
pub fn get_synced_through_at( &self, workspace_id: &str, team_key: &str, ) -> Result<Option<String>>
pub fn set_sync_cursor( &self, workspace_id: &str, team_key: &str, last_updated_at: &str, ) -> Result<()>
pub fn is_full_sync_done( &self, workspace_id: &str, team_key: &str, ) -> Result<bool>
Sourcepub fn get_last_synced_at(
&self,
workspace_id: &str,
team_key: &str,
) -> Result<Option<String>>
pub fn get_last_synced_at( &self, workspace_id: &str, team_key: &str, ) -> Result<Option<String>>
Get the wall-clock time of the last sync for a team.
pub fn get_metadata(&self, key: &str) -> Result<Option<String>>
pub fn set_metadata(&self, key: &str, value: &str) -> Result<()>
Sourcepub fn list_synced_teams(&self, workspace_id: &str) -> Result<Vec<TeamSummary>>
pub fn list_synced_teams(&self, workspace_id: &str) -> Result<Vec<TeamSummary>>
List teams that have synced issues, with issue and embedding counts. Local-only query — no network required.