[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/store/RFC.md fully. Find features d... #48
3 changed files with 20 additions and 23 deletions
36
compact.go
36
compact.go
|
|
@ -20,12 +20,12 @@ type CompactOptions struct {
|
|||
}
|
||||
|
||||
type compactArchiveEntry struct {
|
||||
id int64
|
||||
bucket string
|
||||
measurement string
|
||||
fieldsJSON string
|
||||
tagsJSON string
|
||||
committedAt int64
|
||||
entryID int64
|
||||
bucketName string
|
||||
measurementName string
|
||||
fieldsJSON string
|
||||
tagsJSON string
|
||||
committedAtUnixMilli int64
|
||||
}
|
||||
|
||||
// Compact archives old journal entries as newline-delimited JSON.
|
||||
|
|
@ -65,12 +65,12 @@ func (storeInstance *Store) Compact(options CompactOptions) core.Result {
|
|||
for rows.Next() {
|
||||
var entry compactArchiveEntry
|
||||
if err := rows.Scan(
|
||||
&entry.id,
|
||||
&entry.bucket,
|
||||
&entry.measurement,
|
||||
&entry.entryID,
|
||||
&entry.bucketName,
|
||||
&entry.measurementName,
|
||||
&entry.fieldsJSON,
|
||||
&entry.tagsJSON,
|
||||
&entry.committedAt,
|
||||
&entry.committedAtUnixMilli,
|
||||
); err != nil {
|
||||
return core.Result{Value: core.E("store.Compact", "scan journal row", err), OK: false}
|
||||
}
|
||||
|
|
@ -84,12 +84,12 @@ func (storeInstance *Store) Compact(options CompactOptions) core.Result {
|
|||
}
|
||||
|
||||
outputPath := compactOutputPath(outputDirectory, format)
|
||||
createResult := filesystem.Create(outputPath)
|
||||
if !createResult.OK {
|
||||
return core.Result{Value: core.E("store.Compact", "create archive file", createResult.Value.(error)), OK: false}
|
||||
archiveFileResult := filesystem.Create(outputPath)
|
||||
if !archiveFileResult.OK {
|
||||
return core.Result{Value: core.E("store.Compact", "create archive file", archiveFileResult.Value.(error)), OK: false}
|
||||
}
|
||||
|
||||
file, ok := createResult.Value.(io.WriteCloser)
|
||||
file, ok := archiveFileResult.Value.(io.WriteCloser)
|
||||
if !ok {
|
||||
return core.Result{Value: core.E("store.Compact", "archive file is not writable", nil), OK: false}
|
||||
}
|
||||
|
|
@ -150,7 +150,7 @@ func (storeInstance *Store) Compact(options CompactOptions) core.Result {
|
|||
if _, err := transaction.Exec(
|
||||
"UPDATE "+journalEntriesTableName+" SET archived_at = ? WHERE entry_id = ?",
|
||||
archivedAt,
|
||||
entry.id,
|
||||
entry.entryID,
|
||||
); err != nil {
|
||||
return core.Result{Value: core.E("store.Compact", "mark journal row archived", err), OK: false}
|
||||
}
|
||||
|
|
@ -177,11 +177,11 @@ func compactArchiveLine(entry compactArchiveEntry) (map[string]any, error) {
|
|||
}
|
||||
|
||||
return map[string]any{
|
||||
"bucket": entry.bucket,
|
||||
"measurement": entry.measurement,
|
||||
"bucket": entry.bucketName,
|
||||
"measurement": entry.measurementName,
|
||||
"fields": fields,
|
||||
"tags": tags,
|
||||
"committed_at": entry.committedAt,
|
||||
"committed_at": entry.committedAtUnixMilli,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
5
store.go
5
store.go
|
|
@ -113,10 +113,7 @@ func New(databasePath string, options ...StoreOption) (*Store, error) {
|
|||
}
|
||||
}
|
||||
storeInstance.startBackgroundPurge(purgeContext)
|
||||
orphanWorkspaces := storeInstance.RecoverOrphans(defaultWorkspaceStateDirectory)
|
||||
for _, orphanWorkspace := range orphanWorkspaces {
|
||||
orphanWorkspace.Discard()
|
||||
}
|
||||
storeInstance.cleanUpOrphanedWorkspaces(defaultWorkspaceStateDirectory)
|
||||
return storeInstance, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ type Workspace struct {
|
|||
closed bool
|
||||
}
|
||||
|
||||
// NewWorkspace creates a temporary SQLite state file under `.core/state/`.
|
||||
// NewWorkspace creates a workspace state file under `.core/state/`.
|
||||
// Usage example: `workspace, err := storeInstance.NewWorkspace("scroll-session-2026-03-30")`
|
||||
func (storeInstance *Store) NewWorkspace(name string) (*Workspace, error) {
|
||||
validation := core.ValidateName(name)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue