Move document_records duty-slot writes into docgov, project ledger heads through docgov/freedoc ports, and workspace deliverable I/O through DeliverableStore so arch-check baseline drops to sql_write:1 path:13.
46 lines
1.2 KiB
Go
46 lines
1.2 KiB
Go
package docrevision
|
|
|
|
import (
|
|
"context"
|
|
|
|
"chat-agent-system/internal/app/uow"
|
|
)
|
|
|
|
// RootPointerProjector projects controlled/freeform root ledger pointers.
|
|
// Implemented outside this package (docgov + freedoc) to avoid import cycles.
|
|
type RootPointerProjector interface {
|
|
Project(ctx context.Context, scope uow.TxScope, root *DocRootPointers) error
|
|
}
|
|
|
|
// SetRootPointerProjector injects the composition-root projector.
|
|
func (s *Service) SetRootPointerProjector(p RootPointerProjector) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
s.rootPointers = p
|
|
}
|
|
|
|
// CompositeRootPointerProjector routes by DocRootPointers.Kind.
|
|
type CompositeRootPointerProjector struct {
|
|
Controlled func(ctx context.Context, scope uow.TxScope, root *DocRootPointers) error
|
|
Freeform func(ctx context.Context, scope uow.TxScope, root *DocRootPointers) error
|
|
}
|
|
|
|
func (c CompositeRootPointerProjector) Project(ctx context.Context, scope uow.TxScope, root *DocRootPointers) error {
|
|
if root == nil {
|
|
return nil
|
|
}
|
|
switch root.Kind {
|
|
case "freeform":
|
|
if c.Freeform == nil {
|
|
return nil
|
|
}
|
|
return c.Freeform(ctx, scope, root)
|
|
default:
|
|
if c.Controlled == nil {
|
|
return nil
|
|
}
|
|
return c.Controlled(ctx, scope, root)
|
|
}
|
|
}
|