[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/store/RFC.md fully. Find features d... #78

Merged
Virgil merged 1 commit from agent/read---spec-code-core-go-store-rfc-md-fu into dev 2026-04-03 08:15:16 +00:00
3 changed files with 15 additions and 7 deletions

View file

@ -156,6 +156,7 @@ func newStoreFromConfig(operation string, config StoreConfig) (*Store, error) {
}
storeInstance.startBackgroundPurge()
storeInstance.cleanUpOrphanedWorkspaces(defaultWorkspaceStateDirectory)
return storeInstance, nil
}

View file

@ -159,6 +159,17 @@ func discoverOrphanWorkspacePaths(stateDirectory string) []string {
return orphanPaths
}
func (storeInstance *Store) cleanUpOrphanedWorkspaces(stateDirectory string) {
if storeInstance == nil {
return
}
for _, orphanWorkspace := range storeInstance.RecoverOrphans(stateDirectory) {
_ = orphanWorkspace.Aggregate()
orphanWorkspace.Discard()
}
}
func workspaceNameFromPath(stateDirectory, databasePath string) string {
relativePath := core.TrimPrefix(databasePath, joinPath(stateDirectory, ""))
return core.TrimSuffix(relativePath, ".duckdb")

View file

@ -184,7 +184,7 @@ func TestWorkspace_RecoverOrphans_Good(t *testing.T) {
assert.False(t, testFilesystem().Exists(workspaceFilePath(stateDirectory, "orphan-session")))
}
func TestWorkspace_New_Good_PreservesOrphanedWorkspacesUntilRecovered(t *testing.T) {
func TestWorkspace_New_Good_CleansUpOrphanedWorkspaces(t *testing.T) {
stateDirectory := useWorkspaceStateDirectory(t)
requireCoreOK(t, testFilesystem().EnsureDir(stateDirectory))
@ -198,11 +198,7 @@ func TestWorkspace_New_Good_PreservesOrphanedWorkspacesUntilRecovered(t *testing
require.NoError(t, err)
defer storeInstance.Close()
assert.True(t, testFilesystem().Exists(orphanDatabasePath))
orphans := storeInstance.RecoverOrphans(stateDirectory)
require.Len(t, orphans, 1)
orphans[0].Discard()
assert.False(t, testFilesystem().Exists(orphanDatabasePath))
assert.False(t, testFilesystem().Exists(orphanDatabasePath+"-wal"))
assert.False(t, testFilesystem().Exists(orphanDatabasePath+"-shm"))
}