fix(opencode): enforce storage path invariants#29666
Open
Hona wants to merge 7 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a dedicated PathStorage value object to enforce invariants for paths stored in SQLite (absolute vs relative, and forward-slash normalization on Windows), and wires it through the DB read/write seams plus a data migration to normalize existing rows and persisted event JSON.
Changes:
- Add
PathStoragebranded types/utilities and apply them to session/project storage columns and query filters. - Add a data migration to normalize existing stored paths (including event JSON payloads) into the storage form.
- Add/adjust tests covering path invariants, row/event persistence, and migrations.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/opencode/src/util/path-storage.ts | Introduces branded absolute/relative storage path helpers and platform conversion. |
| packages/opencode/src/project/project.sql.ts | Brands project.worktree and project.sandboxes columns with PathStorage.AbsolutePath. |
| packages/opencode/src/session/session.sql.ts | Brands session.directory and session.path columns with PathStorage types. |
| packages/opencode/src/project/project.ts | Normalizes project worktree/sandboxes at DB write boundaries; converts storage paths back to platform form when reading. |
| packages/opencode/src/session/session.ts | Normalizes session directory/path at DB boundaries; normalizes filters; converts storage directory back to platform form when reading. |
| packages/opencode/src/v2/session.ts | Normalizes directory/path filters when querying sessions. |
| packages/opencode/src/sync/index.ts | Adds persistEvent hook to normalize event payloads before persisting. |
| packages/opencode/src/server/projectors.ts | Uses persistEvent to ensure session event payload paths conform to storage invariants. |
| packages/opencode/src/data-migration.ts | Adds migration to normalize existing project/session rows and event JSON path fields. |
| packages/opencode/src/cli/cmd/import.ts | Ensures imported session path is stored as a PathStorage.RelativePath. |
| packages/opencode/test/util/path-storage.test.ts | Adds unit tests for PathStorage behavior across platforms and Windows specifics. |
| packages/opencode/test/storage/path-storage-migration.test.ts | Adds a migration test validating Windows path normalization without alias resolution. |
| packages/opencode/test/storage/json-migration.test.ts | Updates assertions to account for branded/converted path storage types. |
| packages/opencode/test/session/session-row.test.ts | Verifies Session.toRow persists directory/path with storage invariants. |
| packages/opencode/test/session/session-event-storage.test.ts | Verifies persisted session event JSON uses storage-form paths. |
| packages/opencode/test/project/project.test.ts | Updates test setup to use PathStorage.absolute for session directory rows. |
| packages/opencode/test/project/migrate-global.test.ts | Adjusts legacy seeding to satisfy new storage invariants. |
| packages/opencode/test/control-plane/workspace.test.ts | Updates project insertion to store worktree as PathStorage.AbsolutePath. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Tests