Skip to content
This repository was archived by the owner on Sep 11, 2025. It is now read-only.

Conversation

@mattjohnsonpint
Copy link
Contributor

Modus requires a database for persistence of:

  • Plugin metadata
  • Inference history
  • Agent state

Before this PR, PostgresDB was used in production, and ModusGraph was used in development for Linux and macOS. However, since ModusGraph does not currently support Windows, there was no story for persistence on Windows at all, other than to manually spin up and configure a separate local Postgres server or Docker container.

Since Agent state requires persistence, it's important that we have a better story for Windows developers.

With this PR, a pseudo-embedded Postgres instance can be automatically created and used when needed. It is enabled by default for local development on Windows. It can also be manually enabled on other OSs (eg., for testing), by setting an environment variable MODUS_DB_USE_EMBEDDED_POSTGRES=true.

When enabled, a local postgres instance will automatically start and stop with the Modus Runtime. The data files for the local database will be in a .postgres folder in the project directory. The same queries used for Postgres in production will be used for the local database, and the DB migrations are applied automatically.

@mattjohnsonpint mattjohnsonpint requested review from a team and Copilot May 21, 2025 03:01
@linear
Copy link

linear bot commented May 21, 2025

@mattjohnsonpint mattjohnsonpint force-pushed the mjp/hyp-3374-modus-persistence-on-windows branch from 869b32b to 1562921 Compare May 21, 2025 03:03
@trunk-io
Copy link

trunk-io bot commented May 21, 2025

Running Code Quality on PRs by uploading data to Trunk will soon be removed. You can still run checks on your PRs using trunk-action - see the migration guide for more information.

@mattjohnsonpint mattjohnsonpint changed the title use embedded postgres on Windows feat: use embedded postgres on Windows May 21, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds embedded Postgres support on Windows (and optionally other OSes) to replace the manual Postgres setup for local development.

  • Introduces a new embeddedpg.go implementation that auto-starts/stops Postgres and runs migrations.
  • Updates db.Initialize/db.Stop to hook into embedded Postgres when enabled; refactors useModusDB logic.
  • Cleans up .gitignore, VSCode launch configs, and adds necessary Go module dependencies.

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
sdk/go/examples/agents/.gitignore Ignore new .postgres/ folder
sdk/assemblyscript/examples/agents/.gitignore Ignore new .postgres/ folder
runtime/services/services.go Log “Shutdown complete.” after services stop
runtime/go.mod Add embedded-postgres, migrate, lib/pq, xi2/xz; add replace
runtime/explorer/explorer.go Remove Windows stub and enable inference history endpoint
runtime/db/modusdb.go Simplify InitModusDb guard; refactor addToGitIgnore
runtime/db/embeddedpg.go New embedded Postgres support with migrations and shutdown
runtime/db/db.go Wire embedded Postgres into Initialize and Stop
.vscode/launch.json Remove hard-coded MODUS_DB env from launch configs
.trunk/configs/cspell.json Add new terms (embeddedpostgres, fergusstrange, iofs)
Comments suppressed due to low confidence (3)

runtime/db/embeddedpg.go:98

  • [nitpick] The variable name d is ambiguous; rename it to something like migrationSource to clarify its role.
d, err := iofs.New(migrationsFS, "migrations")

runtime/db/embeddedpg.go:103

  • [nitpick] The variable m is non-descriptive; consider renaming it to migrator or migrationEngine for clarity.
m, err := migrate.NewWithSourceInstance("iofs", d, cs)

runtime/db/embeddedpg.go:36

  • There are no accompanying unit or integration tests for the new embedded Postgres flow; adding tests for useEmbeddedPostgres, findAvailablePort, and prepareEmbeddedPostgresDB would improve confidence in this feature.
/*

@mattjohnsonpint mattjohnsonpint merged commit 7b3f816 into main May 22, 2025
86 checks passed
@mattjohnsonpint mattjohnsonpint deleted the mjp/hyp-3374-modus-persistence-on-windows branch May 22, 2025 00:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants