返回 DeepSeek-Reasonix
projection_open.go
根目录 / internal / session / projection_open.go
1 package session
2
3 import (
4 "context"
5 "path/filepath"
6
7 "reasonix/internal/projectiondb"
8 )
9
10 // A projection belongs to one canonical identity below the host's cache root.
11 // Reject invalid IDs here as well as at query admission: taking their basename
12 // would silently alias another session or escape the cache for "." and "..".
13 func sessionProjectionPath(root, sessionID, filename string) string {
14 if !filepath.IsLocal(sessionID) || validateSessionID(sessionID) != nil {
15 return ""
16 }
17 return filepath.Join(root, ".query-cache", sessionID, filename)
18 }
19
20 // Session read indexes are disposable projections. Every read entry point
21 // shares the same verified-file policy; authoritative stores keep full audits.
22 func openHistoryProjection(ctx context.Context, path string) (*projectiondb.Handle, error) {
23 return projectiondb.Open(ctx, projectiondb.OpenOptions{Path: path, Migrations: historyMigrations,
24 RequireDisk: true, MaxOpenConns: 1, ReuseIntegrityCheck: true})
25 }
26
27 func openSearchProjection(ctx context.Context, path string) (*projectiondb.Handle, error) {
28 return projectiondb.Open(ctx, projectiondb.OpenOptions{Path: path, Migrations: searchMigrations,
29 RequireDisk: true, MaxOpenConns: 1, ReuseIntegrityCheck: true})
30 }
31
31 lines GO