Skip to content
Open
Show file tree
Hide file tree
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
Parse opt-in PostgreSQL storage modes
Add typed storage mode settings for a full PostgreSQL database or a
PostgreSQL catalog beside libSQL. Preserve the existing configuration
default and require the fields each selected mode needs.

Reject PostgreSQL URLs in the legacy libSQL setting and keep connection
credentials out of settings debug output.

Signed-off-by: Maciej Grochowski <maciej.grochowski@protonmail.com>
  • Loading branch information
mmpg-x86 committed Oct 15, 2026
commit ebb23b6dd7094f3ea2fcc84e6b692d9fa399a56e
4 changes: 2 additions & 2 deletions designs/DESIGN_POSTGRESQL_STORAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ Use an explicit database mode rather than inferring a backend from a URL:
| `postgresql` | PostgreSQL | PostgreSQL | no |
| `libsql_shared_bugs` | libSQL | PostgreSQL | no |

`[database]` keeps its existing `url` and `token` for libSQL. Add a
`postgres_url` value for the PostgreSQL connection. Require it in either
`[database]` keeps its existing `url` and `token` for libSQL. Add `[storage]`
with `mode` and `postgres_url` for the PostgreSQL connection. Require it in either
PostgreSQL mode. Reject a PostgreSQL URL passed as the libSQL URL, and reject
mixed mode without a local or remote libSQL URL. Do not log credentials.

Expand Down
4 changes: 4 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,10 @@ async fn run_daemon(
return Err(reason.into());
}

if settings.storage.mode != sashiko::settings::StorageMode::Libsql {
return Err(anyhow::anyhow!("PostgreSQL storage mode is not yet implemented").into());
}

// Initialize Database
let db = Arc::new(Database::new(&settings.database).await?);
db.migrate().await?;
Expand Down
97 changes: 96 additions & 1 deletion src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,25 @@ pub struct DatabaseSettings {
pub token: String,
}

/// Selects where the daemon stores its primary data and bug catalog.
#[derive(Debug, Deserialize, Clone, Copy, PartialEq, Eq, Default)]
#[serde(rename_all = "snake_case")]
pub enum StorageMode {
#[default]
Libsql,
Postgresql,
LibsqlSharedBugs,
}

#[derive(Debug, Deserialize, Clone, Default)]
#[serde(deny_unknown_fields)]
pub struct StorageSettings {
#[serde(default)]
pub mode: StorageMode,
#[serde(default)]
pub postgres_url: Option<String>,
}

/// An empty url, which is no database at all.
///
/// The section is optional because a local review has none and never asks. The
Expand Down Expand Up @@ -988,6 +1007,8 @@ pub struct Settings {
#[serde(default)]
pub database: DatabaseSettings,
#[serde(default)]
pub storage: StorageSettings,
#[serde(default)]
pub nntp: NntpSettings,
pub smtp: Option<SmtpSettings>,
#[serde(default)]
Expand Down Expand Up @@ -1065,13 +1086,37 @@ impl Settings {
/// and an empty one reaching a connection attempt or a git command produces
/// an error far from its cause.
pub fn validate_for_daemon(&self) -> Result<(), String> {
if self.database.url.trim().is_empty() {
if self.database.url.starts_with("postgres://")
|| self.database.url.starts_with("postgresql://")
{
return Err(
"[database] url is for libSQL; set PostgreSQL in [storage] postgres_url"
.to_string(),
);
}
if self.storage.mode != StorageMode::Postgresql && self.database.url.trim().is_empty() {
return Err(
"[database] url must be set: the daemon keeps every patchset, review and \
finding there"
.to_string(),
);
}
if self.storage.mode != StorageMode::Libsql
&& self
.storage
.postgres_url
.as_deref()
.is_none_or(|url| url.trim().is_empty())
{
return Err("[storage] postgres_url must be set in PostgreSQL modes".to_string());
}
if self.storage.mode != StorageMode::Libsql
&& self.storage.postgres_url.as_deref().is_some_and(|url| {
!url.starts_with("postgres://") && !url.starts_with("postgresql://")
})
{
return Err("[storage] postgres_url must be a PostgreSQL URL".to_string());
}
if self.git.repository_path.trim().is_empty() {
return Err(
"[git] repository_path must be set: the daemon reviews patches against a \
Expand Down Expand Up @@ -1398,6 +1443,56 @@ mod tests {
assert!(settings.validate_for_daemon().is_ok());
}

#[test]
fn test_storage_modes_preserve_libsql_default_and_require_their_urls() {
let temp = tempfile::tempdir().unwrap();
let path = temp.path().join("Settings.toml");
let base = "[ai]\nprovider = \"gemini\"\nmodel = \"gemini-3-pro\"\n\
[review]\nconcurrency = 8\nworktree_dir = \"review_trees\"\n\
[git]\nrepository_path = \"linux\"\n";

std::fs::write(&path, format!("{base}[database]\nurl = \"sashiko.db\"\n")).unwrap();
let settings = Settings::load(Some(&path)).unwrap();
assert_eq!(settings.storage.mode, StorageMode::Libsql);
assert!(settings.validate_for_daemon().is_ok());

std::fs::write(
&path,
format!(
"{base}[storage]\nmode = \"postgresql\"\n\
postgres_url = \"postgresql://localhost/sashiko\"\n"
),
)
.unwrap();
let settings = Settings::load(Some(&path)).unwrap();
assert_eq!(settings.storage.mode, StorageMode::Postgresql);
assert!(settings.validate_for_daemon().is_ok());

std::fs::write(
&path,
format!(
"{base}[storage]\nmode = \"libsql_shared_bugs\"\n\
postgres_url = \"postgresql://localhost/sashiko\"\n"
),
)
.unwrap();
let settings = Settings::load(Some(&path)).unwrap();
assert_eq!(settings.storage.mode, StorageMode::LibsqlSharedBugs);
assert!(settings.validate_for_daemon().is_err());

std::fs::write(
&path,
format!(
"{base}[database]\nurl = \"sashiko.db\"\n\
[storage]\nmode = \"libsql_shared_bugs\"\n\
postgres_url = \"postgresql://localhost/sashiko\"\n"
),
)
.unwrap();
let settings = Settings::load(Some(&path)).unwrap();
assert!(settings.validate_for_daemon().is_ok());
}

/// A flag wins over the file, a flag not given leaves the file alone, and
/// only the daemon's own flags produce the lines it has always logged.
#[test]
Expand Down