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

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

View file

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

View file

@ -23,23 +23,23 @@ type QuotaConfig struct {
// Usage example: `scopedStore := store.NewScoped(storeInstance, "tenant-a"); if scopedStore == nil { return }; if err := scopedStore.Set("config", "colour", "blue"); err != nil { return }`
type ScopedStore struct {
store *Store
namespace string
MaxKeys int
MaxGroups int
backingStore *Store
namespace string
MaxKeys int
MaxGroups int
}
func (scopedStore *ScopedStore) storeInstance(operation string) (*Store, error) {
if scopedStore == nil {
return nil, core.E(operation, "scoped store is nil", nil)
}
if scopedStore.store == nil {
if scopedStore.backingStore == nil {
return nil, core.E(operation, "underlying store is nil", nil)
}
if err := scopedStore.store.ensureReady(operation); err != nil {
if err := scopedStore.backingStore.ensureReady(operation); err != nil {
return nil, err
}
return scopedStore.store, nil
return scopedStore.backingStore, nil
}
// Usage example: `scopedStore := store.NewScoped(storeInstance, "tenant-a")`
@ -50,7 +50,7 @@ func NewScoped(storeInstance *Store, namespace string) *ScopedStore {
if !validNamespace.MatchString(namespace) {
return nil
}
scopedStore := &ScopedStore{store: storeInstance, namespace: namespace}
scopedStore := &ScopedStore{backingStore: storeInstance, namespace: namespace}
return scopedStore
}
@ -308,7 +308,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.store.Get(namespacedGroup, key)
_, err := scopedStore.backingStore.Get(namespacedGroup, key)
if err == nil {
// Key exists — this is an upsert, no quota check needed.
return nil
@ -320,7 +320,7 @@ func (scopedStore *ScopedStore) checkQuota(operation, group, key string) error {
// Check MaxKeys quota.
if scopedStore.MaxKeys > 0 {
keyCount, err := scopedStore.store.CountAll(namespacePrefix)
keyCount, err := scopedStore.backingStore.CountAll(namespacePrefix)
if err != nil {
return core.E(operation, "quota check", err)
}
@ -331,14 +331,14 @@ 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.store.Count(namespacedGroup)
existingGroupCount, err := scopedStore.backingStore.Count(namespacedGroup)
if err != nil {
return core.E(operation, "quota check", err)
}
if existingGroupCount == 0 {
// This group is new — check if adding it would exceed the group limit.
knownGroupCount := 0
for _, iterationErr := range scopedStore.store.GroupsSeq(namespacePrefix) {
for _, iterationErr := range scopedStore.backingStore.GroupsSeq(namespacePrefix) {
if iterationErr != nil {
return core.E(operation, "quota check", iterationErr)
}

View file

@ -35,7 +35,7 @@ var defaultWorkspaceStateDirectory = ".core/state"
// Usage example: `workspace, err := storeInstance.NewWorkspace("scroll-session-2026-03-30"); if err != nil { return }; defer workspace.Discard()`
type Workspace struct {
name string
store *Store
backingStore *Store
database *sql.DB
databasePath string
filesystem *core.Fs
@ -48,7 +48,7 @@ func (workspace *Workspace) ensureReady(operation string) error {
if workspace == nil {
return core.E(operation, "workspace is nil", nil)
}
if workspace.store == nil {
if workspace.backingStore == nil {
return core.E(operation, "workspace store is nil", nil)
}
if workspace.database == nil {
@ -57,7 +57,7 @@ func (workspace *Workspace) ensureReady(operation string) error {
if workspace.filesystem == nil {
return core.E(operation, "workspace filesystem is nil", nil)
}
if err := workspace.store.ensureReady(operation); err != nil {
if err := workspace.backingStore.ensureReady(operation); err != nil {
return err
}
@ -98,7 +98,7 @@ func (storeInstance *Store) NewWorkspace(name string) (*Workspace, error) {
return &Workspace{
name: name,
store: storeInstance,
backingStore: storeInstance,
database: workspaceDatabase,
databasePath: databasePath,
filesystem: filesystem,
@ -156,7 +156,7 @@ func (storeInstance *Store) RecoverOrphans(stateDirectory string) []*Workspace {
}
workspaces = append(workspaces, &Workspace{
name: name,
store: storeInstance,
backingStore: storeInstance,
database: workspaceDatabase,
databasePath: databasePath,
filesystem: filesystem,
@ -231,7 +231,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.store.commitWorkspaceAggregate(workspace.name, fields); err != nil {
if err := workspace.backingStore.commitWorkspaceAggregate(workspace.name, fields); err != nil {
return core.Result{Value: err, OK: false}
}
if err := workspace.closeAndDelete(); err != nil {