Skip to content
Open
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
dfb4908
Document configurable PostgreSQL storage design
mmpg-x86 Oct 14, 2026
953c8d2
Initialize pseudoterminals in display tests
mmpg-x86 Oct 15, 2026
ebb23b6
Parse opt-in PostgreSQL storage modes
mmpg-x86 Oct 15, 2026
8cc1137
Add PostgreSQL catalog migration foundation
mmpg-x86 Oct 15, 2026
282da5e
Support PostgreSQL for daemon storage
mmpg-x86 Oct 15, 2026
5ff2a61
Synchronize shared bug catalogs through PostgreSQL
mmpg-x86 Oct 15, 2026
0d7e948
Keep catalog merge bases until local changes are acknowledged
mmpg-x86 Oct 15, 2026
f0ab873
Keep imported discovery links scoped to their producer
mmpg-x86 Oct 15, 2026
1b9ef39
Honor the selected storage backend in database clients
mmpg-x86 Oct 15, 2026
dec5920
Provide OpenSSL dependencies for Linux Nix builds
mmpg-x86 Oct 15, 2026
9d63568
Run PostgreSQL integration coverage in CI
mmpg-x86 Oct 15, 2026
f74127a
Preserve ASCII subsystem scope matching on both backends
mmpg-x86 Oct 15, 2026
1256de8
Redact foreign duplicate history in scoped bug views
mmpg-x86 Oct 15, 2026
0a1ddeb
Bound pending catalog lookups to the requested bug views
mmpg-x86 Oct 15, 2026
67b4b3d
Preserve shared duplicate relationships during concurrent triage
mmpg-x86 Oct 15, 2026
b67bc94
Preserve analysis outcomes across shared catalog outages
mmpg-x86 Oct 15, 2026
44b0051
Recover ordinary PostgreSQL sessions after connection loss
mmpg-x86 Oct 15, 2026
ba8ef01
Keep the libSQL covering index for review statistics
mmpg-x86 Oct 15, 2026
3d64a2d
Exercise PostgreSQL adapter boundaries with deterministic fixtures
mmpg-x86 Oct 15, 2026
4447f1f
Describe PostgreSQL deployment and execution boundaries
mmpg-x86 Oct 15, 2026
56b079b
Keep shared publication scoped to the configured project
mmpg-x86 Oct 15, 2026
f5f686c
Scope PostgreSQL coordination locks to the configured schema
mmpg-x86 Oct 15, 2026
592d15d
Version shared mirror tracking and exclude local bookkeeping
mmpg-x86 Oct 15, 2026
44eb292
Reuse the shared catalog connection and TLS configuration
mmpg-x86 Oct 15, 2026
35b5c79
Discard PostgreSQL sessions after interrupted operations
mmpg-x86 Oct 15, 2026
672dbce
Classify transient catalog failures before refunding attempts
mmpg-x86 Oct 15, 2026
085e67a
Preserve legacy bug identifiers in project catalog namespaces
mmpg-x86 Oct 15, 2026
e875af3
Bound shared catalog synchronization with durable scheduling
mmpg-x86 Oct 15, 2026
490c9dc
Preserve original metadata when importing shared bug history
mmpg-x86 Oct 15, 2026
13fd37c
Match libSQL bug triage behavior on PostgreSQL
mmpg-x86 Oct 15, 2026
66e32d9
Verify the shared catalog readiness contract
mmpg-x86 Oct 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Keep the libSQL covering index for review statistics
Select the existing token index hint only for libSQL while leaving
the PostgreSQL join native. Preserve the default backend optimization
that avoids reading large AI interaction payloads for homepage totals.

Assert that the libSQL query plan uses the covering token index.

Signed-off-by: Maciej Grochowski <maciej.grochowski@protonmail.com>
  • Loading branch information
mmpg-x86 committed Oct 15, 2026
commit ba8ef0131fffe31bc7f82fe122f67b970da62a5e
62 changes: 46 additions & 16 deletions src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5480,6 +5480,26 @@ impl Database {
}))
}

fn review_stats_sql(&self) -> String {
let index_hint = self.conn.sql(" INDEXED BY idx_ai_interactions_tokens", "");
format!(
"WITH last_reviews AS (
SELECT * FROM reviews ORDER BY id DESC LIMIT 1000
)
SELECT
r.provider,
r.model,
r.status,
count(*),
sum(COALESCE(ai.tokens_in, 0)),
sum(COALESCE(ai.tokens_out, 0)),
sum(COALESCE(ai.tokens_cached, 0))
FROM last_reviews r
LEFT JOIN ai_interactions ai{index_hint} ON r.interaction_id = ai.id
GROUP BY r.provider, r.model, r.status"
)
}

pub async fn get_review_stats(&self) -> Result<serde_json::Value> {
let mut total_rows = self
.conn
Expand Down Expand Up @@ -5507,22 +5527,7 @@ impl Database {
0
};

let sql = "WITH last_reviews AS (
SELECT * FROM reviews ORDER BY id DESC LIMIT 1000
)
SELECT
r.provider,
r.model,
r.status,
count(*),
sum(COALESCE(ai.tokens_in, 0)),
sum(COALESCE(ai.tokens_out, 0)),
sum(COALESCE(ai.tokens_cached, 0))
FROM last_reviews r
LEFT JOIN ai_interactions ai ON r.interaction_id = ai.id
GROUP BY r.provider, r.model, r.status";

let mut rows = self.conn.query(sql, ()).await?;
let mut rows = self.conn.query(&self.review_stats_sql(), ()).await?;
let mut stats = Vec::new();
#[allow(clippy::similar_names)]
while let Ok(Some(row)) = rows.next().await {
Expand Down Expand Up @@ -10960,6 +10965,31 @@ mod tests {
Ok(())
}

#[tokio::test]
async fn review_statistics_keep_the_libsql_covering_index() -> Result<()> {
let db = Database::new(&crate::settings::DatabaseSettings {
url: ":memory:".into(),
token: String::new(),
})
.await?;
db.migrate().await?;
let mut rows = db
.conn
.query(&format!("EXPLAIN QUERY PLAN {}", db.review_stats_sql()), ())
.await?;
let mut covering_index = false;
while let Some(row) = rows.next().await? {
covering_index |= row
.get::<String>(3)?
.contains("COVERING INDEX idx_ai_interactions_tokens");
}
assert!(
covering_index,
"statistics must avoid reading interaction payloads"
);
Ok(())
}

#[tokio::test]
async fn test_bug_scope_preserves_non_ascii_section_names() -> Result<()> {
let db = setup_db().await;
Expand Down