42 lines
1.3 KiB
Go
42 lines
1.3 KiB
Go
package app
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
|
|
"chat-agent-system/internal/artifactvault"
|
|
"chat-agent-system/internal/docgov"
|
|
"chat-agent-system/internal/taskrun"
|
|
)
|
|
|
|
// TaskStoreReady reports whether task_runs tables are available.
|
|
// HTTP adapters must use this instead of holding *pgxpool.Pool.
|
|
func (r *Runtime) TaskStoreReady(ctx context.Context) bool {
|
|
if r == nil || r.Pool == nil {
|
|
return false
|
|
}
|
|
return taskrun.TablesReady(ctx, r.Pool)
|
|
}
|
|
|
|
// HealProjectDuties syncs controlled-document duties after project membership changes.
|
|
func (r *Runtime) HealProjectDuties(ctx context.Context, projectID int64) error {
|
|
if r == nil || r.Pool == nil || projectID <= 0 {
|
|
return nil
|
|
}
|
|
_, _, err := docgov.HealProjectDocuments(ctx, r.Pool, projectID)
|
|
if err != nil {
|
|
log.Printf("[docgov] heal project %d after member change failed: %v", projectID, err)
|
|
}
|
|
return err
|
|
}
|
|
|
|
// ArtifactVaultRegistry returns a PG-backed registry when the pool is available,
|
|
// otherwise an in-memory stub suitable for FAV publisher off / tests.
|
|
// HTTP adapters must not hold *pgxpool.Pool to construct the registry.
|
|
func (r *Runtime) ArtifactVaultRegistry() artifactvault.Registry {
|
|
if r == nil || r.Pool == nil {
|
|
return artifactvault.NewMemoryRegistry()
|
|
}
|
|
return artifactvault.NewPGRegistry(r.Pool)
|
|
}
|