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
938 B
Go
36 lines
938 B
Go
// Package projectscope resolves host retrieval filters using service-provided
|
|
// lifecycle metadata. Stored/client settings never supply an authority mapping.
|
|
package projectscope
|
|
|
|
import (
|
|
"agent-system-backend/internal/store"
|
|
"agent-system-backend/pkg/extension"
|
|
core "agent-system-core"
|
|
"context"
|
|
)
|
|
|
|
func Resolve(ctx context.Context, host extension.Host, p extension.ProjectLifecycle, id core.ID) (core.ID, error) {
|
|
if id == "" {
|
|
return id, nil
|
|
}
|
|
if p.List == nil {
|
|
return "", store.ErrNotFound
|
|
}
|
|
projects, err := p.List(ctx, host)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
for _, project := range projects {
|
|
domainID, _ := project.Settings["rdm.projectId"].(string)
|
|
if project.ID != id && domainID != id {
|
|
continue
|
|
}
|
|
state, _ := project.Settings["rdm.state"].(string)
|
|
if domainID == "" || state != "ready" {
|
|
return "", store.ErrNotFound
|
|
}
|
|
return core.ID(domainID), nil
|
|
}
|
|
return "", store.ErrNotFound
|
|
}
|