feat(app): add UnitOfWork and owner-bound repositories

Give each document command one postgres transaction and only let table owners unwrap the scope, so cross-owner writes can roll back together.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
weichen
2026-09-14 13:54:27 +00:00
co-authored by Cursor
parent 158ce2586d
commit f8b21ecd7c
11 changed files with 755 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
package freedoc
import (
"context"
"fmt"
"chat-agent-system/internal/app/uow"
)
// Repository is a M3 stub. M1 freeform projection stays on the existing service path.
type Repository struct{}
func (Repository) ForbiddenInM1(ctx context.Context, scope uow.TxScope) error {
if _, err := uow.AsPG(scope); err != nil {
return err
}
return fmt.Errorf("freedoc: repository writes are not enabled until M3")
}