This repository was archived by the owner on Sep 11, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
feat: use embedded postgres on Windows #851
Merged
mattjohnsonpint
merged 2 commits into
main
from
mjp/hyp-3374-modus-persistence-on-windows
May 22, 2025
Merged
feat: use embedded postgres on Windows #851
mattjohnsonpint
merged 2 commits into
main
from
mjp/hyp-3374-modus-persistence-on-windows
May 22, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
869b32b to
1562921
Compare
|
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. |
Contributor
There was a problem hiding this 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.goimplementation that auto-starts/stops Postgres and runs migrations. - Updates
db.Initialize/db.Stopto hook into embedded Postgres when enabled; refactorsuseModusDBlogic. - 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
dis ambiguous; rename it to something likemigrationSourceto clarify its role.
d, err := iofs.New(migrationsFS, "migrations")
runtime/db/embeddedpg.go:103
- [nitpick] The variable
mis non-descriptive; consider renaming it tomigratorormigrationEnginefor 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, andprepareEmbeddedPostgresDBwould improve confidence in this feature.
/*
ryanfoxtyler
approved these changes
May 21, 2025
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Modus requires a database for persistence of:
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
.postgresfolder 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.