package local import ( "context" "github.com/yaoapp/yao/trace/types" ) // Driver the local disk storage driver implementation type Driver struct { basePath string // Base directory for storing trace files } // New creates a new local driver func New(basePath string) (*Driver, error) { // TODO: Implement initialization (create directories, etc.) return &Driver{ basePath: basePath, }, nil } // SaveNode persists a node to disk func (d *Driver) SaveNode(ctx context.Context, traceID string, node *types.TraceNode) error { // TODO: Implement disk save // File path: {basePath}/{YYYYMMDD}/{traceID}/nodes/{nodeID}.json return nil } // LoadNode loads a node from disk func (d *Driver) LoadNode(ctx context.Context, traceID string, nodeID string) (*types.TraceNode, error) { // TODO: Implement disk load return nil, nil } // LoadTrace loads the entire trace tree from disk func (d *Driver) LoadTrace(ctx context.Context, traceID string) (*types.TraceNode, error) { // TODO: Implement disk load trace // File path: {basePath}/{YYYYMMDD}/{traceID}/trace.json return nil, nil } // SaveSpace persists a space to disk func (d *Driver) SaveSpace(ctx context.Context, traceID string, space *types.TraceSpace) error { // TODO: Implement disk save space // File path: {basePath}/{YYYYMMDD}/{traceID}/spaces/{spaceID}.json return nil } // LoadSpace loads a space from disk func (d *Driver) LoadSpace(ctx context.Context, traceID string, spaceID string) (*types.TraceSpace, error) { // TODO: Implement disk load space return nil, nil } // DeleteSpace removes a space from disk func (d *Driver) DeleteSpace(ctx context.Context, traceID string, spaceID string) error { // TODO: Implement disk delete space return nil } // ListSpaces lists all space IDs for a trace from disk func (d *Driver) ListSpaces(ctx context.Context, traceID string) ([]string, error) { // TODO: Implement disk list spaces return nil, nil } // SetSpaceKey stores a value by key in a space func (d *Driver) SetSpaceKey(ctx context.Context, traceID, spaceID, key string, value any) error { // TODO: Implement disk set space key // File path: {basePath}/{YYYYMMDD}/{traceID}/spaces/{spaceID}/data.json return nil } // GetSpaceKey retrieves a value by key from a space func (d *Driver) GetSpaceKey(ctx context.Context, traceID, spaceID, key string) (any, error) { // TODO: Implement disk get space key return nil, nil } // HasSpaceKey checks if a key exists in a space func (d *Driver) HasSpaceKey(ctx context.Context, traceID, spaceID, key string) bool { // TODO: Implement disk has space key return false } // DeleteSpaceKey removes a key-value pair from a space func (d *Driver) DeleteSpaceKey(ctx context.Context, traceID, spaceID, key string) error { // TODO: Implement disk delete space key return nil } // ClearSpaceKeys removes all key-value pairs from a space func (d *Driver) ClearSpaceKeys(ctx context.Context, traceID, spaceID string) error { // TODO: Implement disk clear space keys return nil } // ListSpaceKeys returns all keys in a space func (d *Driver) ListSpaceKeys(ctx context.Context, traceID, spaceID string) ([]string, error) { // TODO: Implement disk list space keys return nil, nil } // SaveLog appends a log entry to disk func (d *Driver) SaveLog(ctx context.Context, traceID string, log *types.TraceLog) error { // TODO: Implement disk save log // File path: {basePath}/{YYYYMMDD}/{traceID}/logs/{nodeID}.jsonl (append mode) return nil } // LoadLogs loads all logs for a trace or specific node from disk func (d *Driver) LoadLogs(ctx context.Context, traceID string, nodeID string) ([]*types.TraceLog, error) { // TODO: Implement disk load logs // If nodeID is empty, load all logs // If nodeID provided, load logs for that node only return nil, nil } // SaveTraceInfo persists trace metadata to disk func (d *Driver) SaveTraceInfo(ctx context.Context, info *types.TraceInfo) error { // TODO: Implement disk save trace info // File path: {basePath}/{YYYYMMDD}/{traceID}/trace_info.json return nil } // LoadTraceInfo loads trace metadata from disk func (d *Driver) LoadTraceInfo(ctx context.Context, traceID string) (*types.TraceInfo, error) { // TODO: Implement disk load trace info return nil, nil } // DeleteTrace removes entire trace from disk func (d *Driver) DeleteTrace(ctx context.Context, traceID string) error { // TODO: Implement disk delete trace // Delete directory: {basePath}/{YYYYMMDD}/{traceID}/ return nil } // Close closes the local driver func (d *Driver) Close() error { // TODO: Implement cleanup if needed return nil }