Files
Agent-System/internal/app/docflow/query.go
T
weichenandCursor c754f7743d feat(docquery): serve ledger when projection is missing
Authorize first, then return immutable ledger markdown with typed consistency so a missing or drifted projection is no longer a 404/409. GET stays read-only and FAV degraded read stays off.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-14 14:07:05 +00:00

31 lines
825 B
Go

package docflow
import (
"context"
"chat-agent-system/internal/docquery"
)
// Query is the authorized read model for controlled documents.
type Query struct {
Docs *docquery.Service
}
func (q *Query) Get(ctx context.Context, userID int64, docID string) (*docquery.ContentView, error) {
if q == nil || q.Docs == nil {
return nil, docquery.ErrClosed
}
return q.Docs.Get(ctx, docquery.Principal{UserID: userID}, docquery.DocRef{DocID: docID})
}
func (q *Query) BatchGet(ctx context.Context, userID int64, docIDs []string) ([]*docquery.ContentView, error) {
if q == nil || q.Docs == nil {
return nil, docquery.ErrClosed
}
refs := make([]docquery.DocRef, len(docIDs))
for i, id := range docIDs {
refs[i] = docquery.DocRef{DocID: id}
}
return q.Docs.BatchGet(ctx, docquery.Principal{UserID: userID}, refs)
}