apps/node 중심 구현 — TCP+JSON transport, Hexagonal Architecture, mock/cli adapter, fx DI, SQLite 실행 이력 저장. edge/control-plane/worker는 cobra placeholder. 유닛 테스트 및 통합 테스트 클라이언트 계획서 추가.
25 lines
801 B
Go
25 lines
801 B
Go
package policy
|
|
|
|
import "context"
|
|
|
|
// Spec is a policy specification map passed in ExecutionSpec.Policy.
|
|
type Spec map[string]any
|
|
|
|
// Engine applies and validates policies on execution specs.
|
|
type Engine interface {
|
|
// Apply enriches or modifies spec fields based on policy rules.
|
|
Apply(ctx context.Context, adapter, model string, policy Spec) (Spec, error)
|
|
// Validate returns an error if the policy rejects the request.
|
|
Validate(ctx context.Context, adapter, model string, policy Spec) error
|
|
}
|
|
|
|
// Passthrough is a no-op policy engine used when no policy is configured.
|
|
type Passthrough struct{}
|
|
|
|
func (Passthrough) Apply(_ context.Context, _, _ string, policy Spec) (Spec, error) {
|
|
return policy, nil
|
|
}
|
|
|
|
func (Passthrough) Validate(_ context.Context, _, _ string, _ Spec) error {
|
|
return nil
|
|
}
|