Merge pull request '[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/store/RFC.md fully. Find features d...' (#137) from agent/read---spec-code-core-go-store-rfc-md-fu into dev
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run

This commit is contained in:
Virgil 2026-04-04 11:48:04 +00:00
commit c281ab2b93
3 changed files with 24 additions and 24 deletions

View file

@ -304,7 +304,7 @@ func TestCoverage_ScopedStore_Bad_GroupsSeqRowsError(t *testing.T) {
defer database.Close()
scopedStore := &ScopedStore{
backingStore: &Store{
parentStore: &Store{
sqliteDatabase: database,
cancelPurge: func() {},
},

View file

@ -26,8 +26,8 @@ type QuotaConfig struct {
// ScopedStore keeps one namespace isolated behind helpers such as Set and
// GetFrom so callers do not repeat the `tenant-a:` prefix manually.
type ScopedStore struct {
backingStore *Store
namespace string
parentStore *Store
namespace string
// Usage example: `scopedStore.MaxKeys = 100`
MaxKeys int
// Usage example: `scopedStore.MaxGroups = 10`
@ -74,7 +74,7 @@ func (scopedConfig ScopedStoreConfig) Validate() error {
}
type scopedWatcherBinding struct {
backingStore *Store
parentStore *Store
underlyingEvents <-chan Event
done chan struct{}
stop chan struct{}
@ -85,13 +85,13 @@ func (scopedStore *ScopedStore) resolvedStore(operation string) (*Store, error)
if scopedStore == nil {
return nil, core.E(operation, "scoped store is nil", nil)
}
if scopedStore.backingStore == nil {
if scopedStore.parentStore == nil {
return nil, core.E(operation, "underlying store is nil", nil)
}
if err := scopedStore.backingStore.ensureReady(operation); err != nil {
if err := scopedStore.parentStore.ensureReady(operation); err != nil {
return nil, err
}
return scopedStore.backingStore, nil
return scopedStore.parentStore, nil
}
// Usage example: `scopedStore := store.NewScoped(storeInstance, "tenant-a"); if scopedStore == nil { return }`
@ -102,7 +102,7 @@ func NewScoped(storeInstance *Store, namespace string) *ScopedStore {
if !validNamespace.MatchString(namespace) {
return nil
}
scopedStore := &ScopedStore{backingStore: storeInstance, namespace: namespace}
scopedStore := &ScopedStore{parentStore: storeInstance, namespace: namespace}
return scopedStore
}
@ -362,7 +362,7 @@ func (scopedStore *ScopedStore) Watch(group string) <-chan Event {
forwardedEvents := make(chan Event, watcherEventBufferCapacity)
binding := &scopedWatcherBinding{
backingStore: backingStore,
parentStore: backingStore,
underlyingEvents: backingStore.Watch("*"),
done: make(chan struct{}),
stop: make(chan struct{}),
@ -784,8 +784,8 @@ func (scopedStore *ScopedStore) forgetAndStopScopedWatcher(events <-chan Event)
binding.stopOnce.Do(func() {
close(binding.stop)
})
if binding.backingStore != nil {
binding.backingStore.Unwatch("*", binding.underlyingEvents)
if binding.parentStore != nil {
binding.parentStore.Unwatch("*", binding.underlyingEvents)
}
<-binding.done
}
@ -806,7 +806,7 @@ func (scopedStore *ScopedStore) checkQuota(operation, group, key string) error {
namespacePrefix := scopedStore.namespacePrefix()
// Check if this is an upsert (key already exists) — upserts never exceed quota.
_, err := scopedStore.backingStore.Get(namespacedGroup, key)
_, err := scopedStore.parentStore.Get(namespacedGroup, key)
if err == nil {
// Key exists — this is an upsert, no quota check needed.
return nil
@ -818,7 +818,7 @@ func (scopedStore *ScopedStore) checkQuota(operation, group, key string) error {
// Check MaxKeys quota.
if scopedStore.MaxKeys > 0 {
keyCount, err := scopedStore.backingStore.CountAll(namespacePrefix)
keyCount, err := scopedStore.parentStore.CountAll(namespacePrefix)
if err != nil {
return core.E(operation, "quota check", err)
}
@ -829,13 +829,13 @@ func (scopedStore *ScopedStore) checkQuota(operation, group, key string) error {
// Check MaxGroups quota — only if this would create a new group.
if scopedStore.MaxGroups > 0 {
existingGroupCount, err := scopedStore.backingStore.Count(namespacedGroup)
existingGroupCount, err := scopedStore.parentStore.Count(namespacedGroup)
if err != nil {
return core.E(operation, "quota check", err)
}
if existingGroupCount == 0 {
// This group is new, so count existing namespace groups with the public helper.
groupNames, err := scopedStore.backingStore.Groups(namespacePrefix)
groupNames, err := scopedStore.parentStore.Groups(namespacePrefix)
if err != nil {
return core.E(operation, "quota check", err)
}

View file

@ -39,7 +39,7 @@ var defaultWorkspaceStateDirectory = ".core/state/"
// Usage example: `workspace, err := storeInstance.NewWorkspace("scroll-session-2026-03-30"); if err != nil { return }; defer workspace.Discard(); _ = workspace.Put("like", map[string]any{"user": "@alice"})`
type Workspace struct {
name string
backingStore *Store
parentStore *Store
sqliteDatabase *sql.DB
databasePath string
filesystem *core.Fs
@ -77,7 +77,7 @@ func (workspace *Workspace) ensureReady(operation string) error {
if workspace == nil {
return core.E(operation, "workspace is nil", nil)
}
if workspace.backingStore == nil {
if workspace.parentStore == nil {
return core.E(operation, "workspace store is nil", nil)
}
if workspace.sqliteDatabase == nil {
@ -86,7 +86,7 @@ func (workspace *Workspace) ensureReady(operation string) error {
if workspace.filesystem == nil {
return core.E(operation, "workspace filesystem is nil", nil)
}
if err := workspace.backingStore.ensureReady(operation); err != nil {
if err := workspace.parentStore.ensureReady(operation); err != nil {
return err
}
@ -131,7 +131,7 @@ func (storeInstance *Store) NewWorkspace(name string) (*Workspace, error) {
return &Workspace{
name: name,
backingStore: storeInstance,
parentStore: storeInstance,
sqliteDatabase: sqliteDatabase,
databasePath: databasePath,
filesystem: filesystem,
@ -180,11 +180,11 @@ func discoverOrphanWorkspacePaths(stateDirectory string) []string {
return orphanPaths
}
func discoverOrphanWorkspaces(stateDirectory string, backingStore *Store) []*Workspace {
return loadRecoveredWorkspaces(stateDirectory, backingStore)
func discoverOrphanWorkspaces(stateDirectory string, parentStore *Store) []*Workspace {
return loadRecoveredWorkspaces(stateDirectory, parentStore)
}
func loadRecoveredWorkspaces(stateDirectory string, backingStore *Store) []*Workspace {
func loadRecoveredWorkspaces(stateDirectory string, parentStore *Store) []*Workspace {
filesystem := (&core.Fs{}).NewUnrestricted()
orphanWorkspaces := make([]*Workspace, 0)
for _, databasePath := range discoverOrphanWorkspacePaths(stateDirectory) {
@ -194,7 +194,7 @@ func loadRecoveredWorkspaces(stateDirectory string, backingStore *Store) []*Work
}
orphanWorkspace := &Workspace{
name: workspaceNameFromPath(stateDirectory, databasePath),
backingStore: backingStore,
parentStore: parentStore,
sqliteDatabase: sqliteDatabase,
databasePath: databasePath,
filesystem: filesystem,
@ -300,7 +300,7 @@ func (workspace *Workspace) Commit() core.Result {
if err != nil {
return core.Result{Value: core.E("store.Workspace.Commit", "aggregate workspace", err), OK: false}
}
if err := workspace.backingStore.commitWorkspaceAggregate(workspace.name, fields); err != nil {
if err := workspace.parentStore.commitWorkspaceAggregate(workspace.name, fields); err != nil {
return core.Result{Value: err, OK: false}
}
if err := workspace.closeAndRemoveFiles(); err != nil {