Documentation
¶
Overview ¶
Package assist is which AI adapter performs each AI function (R-259), and the administrative functions built on that: drafting access and policy, searching the audit log, and answering from the reference (R-343 … R-346).
It is the service layer both the HTTP API and the MCP server call (R-261). An adapter here proposes and never applies: every draft is checked against the closed set it was drawn from, every audit query is run by core under the caller's own authority, and nothing is created except by a person through the ordinary endpoints.
Index ¶
- Constants
- type AccessResult
- type Assignments
- func (s *Assignments) Assign(ctx context.Context, fn api.AIFunction, ref, model, by string) (Function, error)
- func (s *Assignments) List(ctx context.Context) ([]Function, error)
- func (s *Assignments) Load(ctx context.Context) error
- func (s *Assignments) Unassign(ctx context.Context, fn api.AIFunction) (Function, error)
- type AuditResult
- type Declared
- type Function
- type PolicyChange
- type PolicyDeclined
- type PolicyResult
- type Ran
- type ReferenceResult
- type Service
- func (s *Service) AnswerReference(ctx context.Context, question string) (ReferenceResult, error)
- func (s *Service) DraftAccess(ctx context.Context, p authz.Principal, description string, ...) (AccessResult, error)
- func (s *Service) DraftPolicy(ctx context.Context, description string, proposed *policy.Document) (PolicyResult, error)
- func (s *Service) SearchAudit(ctx context.Context, p authz.Principal, question string) (AuditResult, error)
- type Source
- type Store
Constants ¶
const DefaultTimeout = 90 * time.Second
DefaultTimeout bounds one function's calls to its adapter.
const MaxAsk = 2000
MaxAsk is the longest description or question accepted, in characters. A few sentences is what these functions are for; a page is a document.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessResult ¶
type AccessResult struct {
Role *api.RoleDraft `json:"role,omitempty"`
Group *api.GroupDraft `json:"group,omitempty"`
Reply string `json:"reply"`
// Refused is what the adapter proposed and Pando would not draft, each
// with its reason.
Refused []string `json:"refused,omitempty"`
Ran
}
AccessResult is a checked access draft.
type Assignments ¶
type Assignments struct {
Store Store
Registry *api.Registry
Declared []Declared
// Name returns an adapter's display name, for refusals: "the Anthropic
// adapter (ai_anthropic)" is clearer than the ID alone. Nil uses the ID.
Name func(ref string) string
}
Assignments is the service over AI function assignments.
func (*Assignments) Assign ¶
func (s *Assignments) Assign(ctx context.Context, fn api.AIFunction, ref, model, by string) (Function, error)
Assign gives fn to the adapter ref, on model (empty for the adapter's own).
func (*Assignments) List ¶
func (s *Assignments) List(ctx context.Context) ([]Function, error)
List reports every assignable function, assigned or not.
func (*Assignments) Load ¶
func (s *Assignments) Load(ctx context.Context) error
Load reads stored assignments, lays declared ones over them, and gives the result to the registry. Called at startup and after every change.
func (*Assignments) Unassign ¶
func (s *Assignments) Unassign(ctx context.Context, fn api.AIFunction) (Function, error)
Unassign turns fn off.
type AuditResult ¶
type AuditResult struct {
Filter api.AuditFilter `json:"filter"`
Note string `json:"note,omitempty"`
Summary string `json:"summary"`
Matched int `json:"matched"`
Truncated bool `json:"truncated"`
Ran
}
AuditResult is a question turned into a filter, the filter's results counted, and a summary of them.
type Declared ¶
type Declared struct {
Function api.AIFunction
Adapter string
Model string
Source Source
}
Declared is an assignment made in the startup configuration. It overrides a stored one for the same function, and cannot be changed through the API while it is declared.
type Function ¶
type Function struct {
Function api.AIFunction `json:"function"`
Title string `json:"title"`
// AdapterID is empty when nothing is assigned.
AdapterID string `json:"adapter_id,omitempty"`
// Model is the assignment's model, empty for the adapter's own.
// EffectiveModel is what runs: this, else the adapter's default.
Model string `json:"model,omitempty"`
EffectiveModel string `json:"effective_model,omitempty"`
// On is whether a call would reach an adapter now. Off says why.
On bool `json:"on"`
Off string `json:"off,omitempty"`
Source *Source `json:"source,omitempty"`
// Overridden is a stored assignment the startup configuration replaces.
// Remove the declaration and restart, and it applies again.
Overridden *state.AIAssignment `json:"overridden,omitempty"`
}
Function is one AI function as the API reports it.
type PolicyChange ¶
type PolicyChange struct {
Key string `json:"key"`
From json.RawMessage `json:"from"`
To json.RawMessage `json:"to"`
}
PolicyChange is one field a policy draft changes.
type PolicyDeclined ¶
type PolicyDeclined struct {
Key string `json:"key"`
Reason string `json:"reason"`
Source policy.Source `json:"source"`
}
PolicyDeclined is a change Pando declined because the startup configuration fixes the field (R-271).
type PolicyResult ¶
type PolicyResult struct {
Proposed policy.Document `json:"proposed"`
Changes []PolicyChange `json:"changes"`
Declined []PolicyDeclined `json:"declined,omitempty"`
Refused []string `json:"refused,omitempty"`
Reply string `json:"reply"`
Ran
}
PolicyResult is a checked policy draft: the document as it would be saved, and what changed.
type Ran ¶
Ran is which adapter and model answered, for the reply and the audit event recording that data left the host.
type ReferenceResult ¶
type ReferenceResult struct {
Answer string `json:"answer"`
Cites []string `json:"cites"`
Covered bool `json:"covered"`
Ran
}
ReferenceResult is an answer from the reference.
type Service ¶
type Service struct {
Registry *api.Registry
// Users, Apps and Groups are searched, never listed whole (O-54): every
// read here is bounded by a limit or a set of IDs.
Users interface {
Search(ctx context.Context, q string, limit int) ([]state.User, error)
ListPage(ctx context.Context, page state.Page) ([]state.User, string, int, error)
}
Apps interface {
ListAllPage(ctx context.Context, page state.Page) ([]state.App, string, int, error)
ListForPrincipalPage(ctx context.Context, p authz.Principal, page state.Page) ([]state.App, string, int, error)
}
Groups interface {
Search(ctx context.Context, q string, limit int) ([]state.Group, error)
}
// Roles are read whole: the built-in roles and the custom ones an
// administrator made, which a draft must not duplicate (R-082). Their
// number is set by people defining roles by hand, not by the size of the
// organization.
Roles interface {
List(ctx context.Context) ([]state.RoleRow, error)
}
// Verbs is what a principal holds install-wide, which bounds what an
// access draft may grant and what the AI may look up for them.
Verbs interface {
InstallVerbsFor(ctx context.Context, p authz.Principal) ([]string, error)
}
// Policy reads the effective policy document, startup fields included;
// Overlay says which fields those are and where each was set.
Policy interface {
Load(ctx context.Context) (policy.Document, error)
}
Overlay *policy.Overlay
// Audit runs the filter an audit search becomes. The action names the
// adapter chooses from are audit.Actions, the code's own catalog (O-54).
Audit interface {
List(ctx context.Context, q audit.Query) ([]audit.Record, error)
}
// Reference is the generated reference in Markdown.
Reference func() string
// Now is the clock. Nil is the system clock.
Now func() time.Time
Timeout time.Duration
}
Service runs the administrative AI functions (R-343 … R-346).
Each reads only what its caller could read through the ordinary endpoints, and returns a draft, a filter or an answer. Nothing here writes: creating a role, saving a policy, reading the audit log's pages — each is the caller's own request, under the caller's own authority.
func (*Service) AnswerReference ¶
AnswerReference answers "How can I…" from the generated reference. It describes; nothing here acts. A citation that is not in the reference is dropped, the cheapest check on whether the answer came from the reference or from memory.
func (*Service) DraftAccess ¶
func (s *Service) DraftAccess(ctx context.Context, p authz.Principal, description string, current *api.AccessDraft) (AccessResult, error)
DraftAccess drafts a role and a group from a description.
The verb catalog handed over is what the caller could grant: every app verb, which POST /roles lets them put in an app role, and only the install verbs they hold themselves. A draft is refused any verb outside it, a mix of scopes (R-080), and the name of a role that exists, built-in or not (R-082).
func (*Service) DraftPolicy ¶
func (s *Service) DraftPolicy(ctx context.Context, description string, proposed *policy.Document) (PolicyResult, error)
DraftPolicy proposes a policy from a description.
A field the startup configuration fixes is declined here, citing where it was set, whatever the adapter returned: the refusal does not depend on the model's cooperation.
proposed, when set, is the document so far while a person refines a proposal. The model changes it, and the changes reported are relative to the stored policy, so what the person kept earlier is still listed. Fields the startup configuration fixes are put back whatever proposed says.
func (*Service) SearchAudit ¶
func (s *Service) SearchAudit(ctx context.Context, p authz.Principal, question string) (AuditResult, error)
SearchAudit answers a question about the audit log. The caller must be able to read the log (install.audit.read); the adapter sees the records that caller could see and nothing more, and never queries the log itself (R-027): it returns a filter, and core runs it.
The adapter is not handed every account and app (O-54): one that LooksUp searches for those the question names, as p; any other is given what the question's own words match. The action names are audit.Actions, the code's catalog, not a scan of the log.
type Source ¶
type Source struct {
// Kind is "database" or "file".
Kind string `json:"kind"`
// Name is the config file's path.
Name string `json:"name,omitempty"`
// Key is the key inside the config file.
Key string `json:"key,omitempty"`
}
Source is where an assignment was made: the database, or the startup configuration (R-271).