fix: restore go compatibility for runtime models
This commit is contained in:
@@ -27,24 +27,16 @@ func (s Store) Snapshot() (Snapshot, error) {
|
||||
}
|
||||
stateExists := fileExists(statePath)
|
||||
goalsExists := fileExists(goalsPath)
|
||||
if !stateExists && !goalsExists {
|
||||
return Snapshot{
|
||||
Threads: []Thread{},
|
||||
SpawnEdges: []SpawnEdge{},
|
||||
Goals: []Goal{},
|
||||
Source: SourceEvidence{
|
||||
Kind: "sqlite_missing",
|
||||
Confidence: "low",
|
||||
Message: "Codex SQLite files were not found; returning an empty read-only snapshot.",
|
||||
},
|
||||
}, nil
|
||||
sources := SourceMap{
|
||||
"state": sqliteSource("state", statePath, stateExists),
|
||||
"goals": sqliteSource("goals", goalsPath, goalsExists),
|
||||
}
|
||||
|
||||
snapshot := Snapshot{
|
||||
Threads: []Thread{},
|
||||
SpawnEdges: []SpawnEdge{},
|
||||
Goals: []Goal{},
|
||||
Source: SourceEvidence{Kind: "sqlite_readonly", Path: statePath, Confidence: "high"},
|
||||
Source: aggregateSource(sources),
|
||||
Sources: sources,
|
||||
}
|
||||
if stateExists {
|
||||
db, err := openReadonlySQLite(statePath)
|
||||
@@ -75,6 +67,38 @@ func (s Store) Snapshot() (Snapshot, error) {
|
||||
return snapshot, nil
|
||||
}
|
||||
|
||||
func sqliteSource(name string, path string, exists bool) SourceEvidence {
|
||||
if exists {
|
||||
return SourceEvidence{Kind: "sqlite_readonly", Path: path, Confidence: "high"}
|
||||
}
|
||||
return SourceEvidence{
|
||||
Kind: "sqlite_missing",
|
||||
Path: path,
|
||||
Confidence: "low",
|
||||
Message: name + " SQLite file was not found; returning empty data for that source.",
|
||||
}
|
||||
}
|
||||
|
||||
func aggregateSource(sources SourceMap) SourceEvidence {
|
||||
state := sources["state"]
|
||||
goals := sources["goals"]
|
||||
if state.Kind == "sqlite_readonly" && goals.Kind == "sqlite_readonly" {
|
||||
return SourceEvidence{Kind: "sqlite_readonly", Confidence: "high"}
|
||||
}
|
||||
if state.Kind == "sqlite_missing" && goals.Kind == "sqlite_missing" {
|
||||
return SourceEvidence{
|
||||
Kind: "sqlite_missing",
|
||||
Confidence: "low",
|
||||
Message: "Codex SQLite files were not found; returning an empty read-only snapshot.",
|
||||
}
|
||||
}
|
||||
return SourceEvidence{
|
||||
Kind: "sqlite_partial",
|
||||
Confidence: "partial",
|
||||
Message: "One Codex SQLite source is missing; available data was read from existing sources only.",
|
||||
}
|
||||
}
|
||||
|
||||
func openReadonlySQLite(path string) (*sql.DB, error) {
|
||||
uri := url.URL{Scheme: "file", Path: path}
|
||||
query := uri.Query()
|
||||
|
||||
Reference in New Issue
Block a user