Why: Shared project reads previously doubled as write permission, project mutations bypassed the domain lifecycle, and coarse retrieval shared private resources. Evidence: SELF red-before-implementation logs cover projection, lifecycle, private work, resource filtering, canonical retrieval scope, publication source and namespace. SELF go test ./..., isolated PostgreSQL go test ./internal/store -count=1, and CGO_ENABLED=0 go build ./cmd/agent-system passed; task owner owns replay/CI. Impact: Add optional actor-scoped projection/lifecycle capabilities; registered providers control public lifecycle and live work. Preserve owned conversation history and ordinary unregistered behavior. Authorize knowledge by stored ID/source, map current host scopes through trusted service metadata, and filter artifact lists. Refs: Dev project-member-access implementation plan r1 Task 1; approved design r0.1; 2026-10-13 trusted publication Source hardening ruling
36 lines
1.4 KiB
Go
36 lines
1.4 KiB
Go
package extension
|
|
|
|
import (
|
|
core "agent-system-core"
|
|
"context"
|
|
)
|
|
|
|
// ProjectHost is an optional actor-scoped host projection capability. Metadata
|
|
// can be shared by an authorizer; owned lookups and mutations remain owner-only.
|
|
type ProjectHost interface {
|
|
Owner() string
|
|
OwnedProjects() ([]core.Project, error)
|
|
ProjectMetadata(projectID string) (core.Project, error)
|
|
OwnedProject(projectID string) (core.Project, error)
|
|
EnsureProject(projectID, name string) (core.Project, error)
|
|
RenameOwnedProject(projectID, name string) (core.Project, error)
|
|
ProjectNameAvailable(name, exceptID string) (bool, error)
|
|
}
|
|
|
|
// ProjectLifecycle supplies the domain's public project lifecycle and live work
|
|
// authorization. Each Host is scoped to the authenticated actor. Errors with a
|
|
// StatusCode() int method may report 400, 403, 404, 409, or 503 to HTTP clients.
|
|
type ProjectLifecycle struct {
|
|
List func(context.Context, Host) ([]core.Project, error)
|
|
Create func(context.Context, Host, string) (core.Project, error)
|
|
Rename func(context.Context, Host, string, string) (core.Project, error)
|
|
Archive func(context.Context, Host, string) error
|
|
Work func(context.Context, string, core.ID) (bool, error)
|
|
}
|
|
|
|
// ProjectLifecycleRegistry is optional so older Registry implementations retain
|
|
// their contract. Only in-process plugins can register one complete provider.
|
|
type ProjectLifecycleRegistry interface {
|
|
RegisterProjectLifecycle(ProjectLifecycle) error
|
|
}
|