profile

package
v0.74.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package profile carries request-scoped in-proxy profile filtering (Spec 057).

A profile is a named, stateless view over a subset of the configured upstream servers, addressable at /mcp/p/<slug>. A ProfileScope is resolved once per request and filters which servers that request may see/call. The URL tier is only one of its sources: the server package's resolver (Profiles v2) also builds a scope from an agent token's profile_pin and from a session's set_profile selection, in that precedence order. The scope stays an independent, auth-type-agnostic primitive that composes with (but does not depend on) the Spec 028 agent-token scope — an unauthenticated /mcp/p/<slug> connection runs as an admin AuthContext yet must still be profile-filtered.

Index

Constants

View Source
const (
	ErrorCodeBindingBypassable  = "binding_bypassable_without_auth"
	ErrorCodeNoClientCredential = "no_client_credential"
	// ErrorCodeConnectInProgress answers a second connect, rotate, finalize or
	// binding change of a client whose connect holds the in-flight claim
	// (FR-021a).
	ErrorCodeConnectInProgress = "connect_in_progress"
	// ErrorCodeCredentialSuperseded answers a connect whose credential was
	// replaced or revoked before it could be finalized (FR-021a).
	ErrorCodeCredentialSuperseded = "credential_superseded"

	// Spec 108-f: the profile CRUD refusals (contracts/rest-api.md).
	ErrorCodeProfileInUse       = "profile_in_use"
	ErrorCodeProfileIsAnonymous = "profile_is_anonymous_profile"
	ErrorCodeProfileExists      = "profile_exists"
	ErrorCodeNameMismatch       = "name_mismatch"
	// ErrorCodePreconditionFailed answers an upgrade-admin-key-holders apply
	// whose precondition_token no longer matches what the preview showed.
	// (Connect's own 409 carries the same meaning under `action`.)
	ErrorCodePreconditionFailed = "precondition_failed"
)

Error codes carried in the `code` field of a Profiles v3 refusal body (contracts/refusals.md).

View Source
const (
	// StaleClassificationAnnotated: the tool now carries its own annotations,
	// which a classify entry never overrides.
	StaleClassificationAnnotated = "annotated"
	// StaleClassificationMissing: the tool no longer exists.
	StaleClassificationMissing = "missing"
)

Why a classify entry no longer applies (EffectiveToolsResult. StaleClassificationReasons, FR-005).

View Source
const (
	GuardFixRequireMCPAuth      = "require_mcp_auth"
	GuardFixSetAnonymousProfile = "set_anonymous_profile"
)

GuardFix kinds offered by the FR-008a binding-guard refusal `fixes[]`.

View Source
const (
	CredentialErrorCodeSecretInArgument       = "secret_in_argument"
	CredentialErrorCodeArgumentsTooLarge      = "arguments_too_large"
	CredentialErrorCodeUnknownOperation       = "unknown_operation"
	CredentialErrorCodeMissingArgument        = "missing_argument"
	CredentialErrorCodeInvalidArgument        = "invalid_argument"
	CredentialErrorCodeProfileRequired        = "profile_required"
	CredentialErrorCodeUnknownProfile         = "unknown_profile"
	CredentialErrorCodeInvalidExpiry          = "invalid_expiry"
	CredentialErrorCodeIdentityExists         = "identity_exists"
	CredentialErrorCodeReservedIdentity       = "reserved_identity"
	CredentialErrorCodeIdentityNotFound       = "identity_not_found"
	CredentialErrorCodeTokenLimitReached      = "token_limit_reached"
	CredentialErrorCodeReadOnlyMode           = "read_only_mode"
	CredentialErrorCodeManagementDisabled     = "management_disabled"
	CredentialErrorCodeUnsupportedEdition     = "unsupported_edition"
	CredentialErrorCodeCredentialsUnavailable = "credentials_unavailable"
)

Credential error codes of the `credentials` admin MCP tool (Spec 115, contracts/errors.md). Each is the `code` of a refusal body {code, error, field?}. binding_bypassable_without_auth is reused from the Profiles v3 codes above.

View Source
const (
	RotationFinalized  = "finalized"
	RotationRolledBack = "rolled_back"
	RotationPending    = "pending"
)

Staged-rotation states (FR-021a): the `diff.outcome` of a `rotate` record and a client row's `rotation.state`.

View Source
const (
	// SetProfileLockedRefusalFormat is the refusal for a locked client credential.
	SetProfileLockedRefusalFormat = "cannot switch to profile '%s': this client's profile is locked"
	// SetProfileNotSwitchableRefusalFormat is the refusal for a switchable
	// client credential asking for a profile it may not switch to.
	SetProfileNotSwitchableRefusalFormat = "cannot switch to profile '%s': it is not a profile this client may switch to"
)

The MCP set_profile refusal texts a Spec 108 client credential receives (contracts/refusals.md; golden testdata/contract/set_profile_refusals.json).

They depend only on the caller's own credential (its kind and profile mode), never on whether the requested slug exists or is in the binding's switchable_to, so for one caller every refused slug returns byte-identical text with the slug substituted (the uniform-refusal property). Neither names the bound profile. Every other caller (agent tokens, anonymous, confined anonymous, URL-scoped) keeps the Spec 105 "unknown profile '<slug>'" text.

View Source
const WarningActionUpgradeAdminKeyHolders = "upgrade_admin_key_holders"

WarningActionUpgradeAdminKeyHolders is the `action.kind` of the client_holds_admin_key warning: a one-click "upgrade every client that holds the admin key" (FR-025). The other action kinds reuse FixAction spellings (change_setting, reconnect_client, move_client, edit_token).

Variables

View Source
var ErrClientCredentialToken = errors.New("use client=<id> for a client credential")

ErrClientCredentialToken is returned when an access subject names a client credential as a token: it is explained as a client instead.

View Source
var ErrCodeExecutionBlocked = errors.New("blocked by profile: code execution is disabled for this profile")

ErrCodeExecutionBlocked identifies a code_execution refusal enforced by the active profile. REST uses it to return the profile-specific 403 while MCP and the generic tool-call route retain the unknown-tool response shape.

View Source
var ErrExplainBuiltinTool = errors.New("access/explain covers upstream tools (server:tool) only")

ErrExplainBuiltinTool is returned by the explainer for a tool name that is not an upstream server:tool: built-in management tools do not walk the upstream chain and are not explained (Spec 108-f F23).

View Source
var ErrToolOutsideProfile = errors.New("tool call not found")

ErrToolOutsideProfile is intentionally non-descriptive so REST replay can answer the same not-found shape for a hidden server and an unknown record.

View Source
var ErrUnknownClient = errors.New("client not found")

ErrUnknownClient is returned when an access subject names a client that is neither a known client nor holds a credential record.

View Source
var ErrUnknownProfile = errors.New("profile not found")

ErrUnknownProfile is returned when an access subject names a profile that does not exist.

View Source
var ErrUnknownToken = errors.New("token not found")

ErrUnknownToken is returned when an access subject names a token that does not exist (Spec 108-f).

Functions

func WithProfileScope

func WithProfileScope(ctx context.Context, p *ProfileScope) context.Context

WithProfileScope returns a context carrying the given ProfileScope.

Types

type AccessReason added in v0.70.0

type AccessReason string

AccessReason is why an effective-tool row is not visible or not callable. The zero value ("") means callable. The FR-010 decision reasons are reported by the step that carries them (data-model.md §7 EffectiveTool); every other value is the failing step's own name.

const (
	AccessReasonNone AccessReason = ""
	// The four FR-010 decision reasons (Reason), reported by the step that
	// carries them: server_not_in_profile by server_in_scope, denied_by_rule
	// by tool_rule, unannotated_hidden and above_tier_cap by tier_cap.
	AccessReasonServerNotInProfile AccessReason = "server_not_in_profile"
	AccessReasonDeniedByRule       AccessReason = "denied_by_rule"
	AccessReasonUnannotatedHidden  AccessReason = "unannotated_hidden"
	AccessReasonAboveTierCap       AccessReason = "above_tier_cap"
	// The step names.
	AccessReasonCredential      AccessReason = "credential"
	AccessReasonProfile         AccessReason = "profile"
	AccessReasonServerInScope   AccessReason = "server_in_scope"
	AccessReasonTokenPermission AccessReason = "token_permission"
	AccessReasonGlobalGate      AccessReason = "global_gate"
	AccessReasonServerState     AccessReason = "server_state"
	AccessReasonToolApproval    AccessReason = "tool_approval"
)

func AccessReasonFromDecision added in v0.70.0

func AccessReasonFromDecision(r Reason) AccessReason

AccessReasonFromDecision maps an FR-010 decision Reason onto AccessReason.

func AccessReasonFromStep added in v0.70.0

func AccessReasonFromStep(s ExplainStep) AccessReason

AccessReasonFromStep is the reason a failing step reports when it carries no FR-010 decision reason of its own: the step's name. tool_rule and tier_cap always report a decision reason instead (AccessReasonFromDecision).

func AccessReasons added in v0.70.0

func AccessReasons() []AccessReason

AccessReasons returns every non-empty AccessReason in data-model.md §7 order. It is the enumeration the contract test pins, the generated types are built from and every consumer switches over.

type AccessStep added in v0.70.0

type AccessStep struct {
	Step   ExplainStep      `json:"step"`
	Status AccessStepStatus `json:"status"`
	Detail string           `json:"detail,omitempty"`
}

AccessStep is one evaluated link of the chain, in StepOrder.

type AccessStepStatus added in v0.70.0

type AccessStepStatus string

AccessStepStatus is the outcome of one step of the chain.

const (
	AccessStepPass AccessStepStatus = "pass"
	AccessStepFail AccessStepStatus = "fail"
	// AccessStepSkip marks a step that does not apply to the subject (the
	// credential and token_permission steps of a profile subject).
	AccessStepSkip AccessStepStatus = "skip"
)

type AccessSubject added in v0.70.0

type AccessSubject struct {
	Kind AccessSubjectKind
	// ClientID names the client for AccessSubjectClient.
	ClientID string
	// CredentialState is what the client's connection actually carries
	// (client | admin_key | none | revoked | expired). Empty means "derive it
	// from the client's credential record".
	CredentialState CredentialState
	// Profile names the profile for AccessSubjectProfile. For
	// AccessSubjectClient it is an optional OVERRIDE: the client's credential
	// evaluated under this profile ("what would Cursor get on that profile",
	// GET /profiles/{name}/effective-tools?client=).
	Profile string
	// TokenName names the token for AccessSubjectToken.
	TokenName string
}

AccessSubject names the subject of an access evaluation.

type AccessSubjectKind added in v0.70.0

type AccessSubjectKind string

AccessSubjectKind selects whose access is evaluated.

const (
	// AccessSubjectClient is a client as its connection resolves today: its
	// credential (or lack of one) and binding.
	AccessSubjectClient AccessSubjectKind = "client"
	// AccessSubjectProfile is a profile's own reach, independent of any
	// credential: the credential and token_permission steps are skipped.
	AccessSubjectProfile AccessSubjectKind = "profile"
	// AccessSubjectToken is a regular agent token (Spec 108-f): its pin is
	// the base profile, and its AllowedServers/Permissions apply. A client
	// credential is explained as a client, never as a token.
	AccessSubjectToken AccessSubjectKind = "token"
	// AccessSubjectAnonymous is a caller that presents no credential
	// (Spec 108-f): refused outright under require_mcp_auth, otherwise
	// resolved through anonymous_profile and the FR-008a binding guard.
	AccessSubjectAnonymous AccessSubjectKind = "anonymous"
)

type AccessVerdict added in v0.70.0

type AccessVerdict struct {
	// Visible is true when credential, profile, server_in_scope, tool_rule and
	// tier_cap all pass: what the subject's discovery would list (FR-010/FR-011
	// plus scope).
	Visible bool
	// Callable is true when Visible and every later step passes: what a real
	// call would do (FR-032, SC-009).
	Callable bool
	// Reason is the first failing step's reason; empty when Callable.
	Reason AccessReason
	// ProfileTier is the tool's tier under the subject's profile (the intrinsic
	// tier when no profile applies).
	ProfileTier Tier
	Steps       []AccessStep
}

AccessVerdict is the complete evaluation of one (server, tool) for one subject. Steps is complete (every step of StepOrder, in order), so the explainer (Spec 108-f) only renders it and adds fixes[].

func (AccessVerdict) FirstFailure added in v0.70.0

func (v AccessVerdict) FirstFailure() ExplainStep

FirstFailure returns the first failing step, or "" when none failed.

type BlockReason added in v0.70.0

type BlockReason string

BlockReason is the activity-record cause of a profile-driven call refusal (FR-013, FR-014, FR-016; data-model.md §5 ActivityRecord.BlockReason).

const (
	BlockReasonTier          BlockReason = "profile_tier"
	BlockReasonRule          BlockReason = "profile_rule"
	BlockReasonUnannotated   BlockReason = "profile_unannotated"
	BlockReasonCodeExecution BlockReason = "profile_code_execution"
	BlockReasonManagement    BlockReason = "profile_management"
	// BlockReasonServerScope marks a nested code_execution call to a server
	// outside the caller's profile scope. Top-level out-of-scope refusals stay
	// the Spec 105 non-disclosing row with no block_reason.
	BlockReasonServerScope BlockReason = "profile_server_scope"
)

type ChangeKind added in v0.70.0

type ChangeKind string

ChangeKind is the `change` of a `profile_change` activity record (data-model.md §5). The clients service writes assign/lock/unlock/forget/ rotate; the profiles service writes the rest.

const (
	ChangeCreate    ChangeKind = "create"
	ChangeUpdate    ChangeKind = "update"
	ChangeDelete    ChangeKind = "delete"
	ChangeRename    ChangeKind = "rename"
	ChangeClassify  ChangeKind = "classify"
	ChangeAssign    ChangeKind = "assign"
	ChangeLock      ChangeKind = "lock"
	ChangeUnlock    ChangeKind = "unlock"
	ChangeForget    ChangeKind = "forget"
	ChangeRotate    ChangeKind = "rotate"
	ChangeAnonymous ChangeKind = "anonymous"
	// ChangeIssue and ChangeRevoke are the Spec 115 credential lifecycle
	// records: a credential issued or revoked through the credentials
	// service, on any surface (MCP, REST, CLI). `forget` stays the Clients
	// page's Forget action.
	ChangeIssue  ChangeKind = "issue"
	ChangeRevoke ChangeKind = "revoke"
)

type CompiledPolicy added in v0.70.0

type CompiledPolicy struct {
	Name, Title string
	Servers     map[string]struct{}

	// Cap is the tier ceiling (FR-001 max_tier); TierUnannotated (0) means
	// "no cap" (legacy, or max_tier unset).
	Cap Tier
	// Unannotated is the effective handling of an unclassified, unannotated
	// tool (config.ProfileConfig.EffectiveUnannotated: "deny"|"as_write"|
	// "as_read").
	Unannotated string

	// CodeExecution is config.ProfileConfig.EffectiveCodeExecution()
	// (FR-003a): unset (nil) fails closed to false under a read/write cap
	// and defaults to true (global gate decides) under destructive/legacy;
	// an explicit value always wins. The global enable_code_execution gate
	// is ANDed at the call site — this field never widens past it.
	CodeExecution   bool
	ManagementTools *bool
	// SwitchableTo is nil for "legacy/none" (FR-022); a non-nil, possibly
	// empty, set means "the profiles this one may set_profile into".
	SwitchableTo map[string]struct{}

	// Fingerprint is a sha256 over a canonical JSON encoding of exactly the
	// six FR-001 POLICY fields (never Name/Title, which are display-only,
	// and never Servers, which Spec 108 FR-027 tracks separately from the
	// policy fingerprint) — stable regardless of Go map iteration order
	// (encoding/json sorts string map keys) or the caller's slice order
	// (allow/deny are sorted before hashing), and changes whenever any one
	// of those six fields changes.
	Fingerprint [32]byte
	// contains filtered or unexported fields
}

CompiledPolicy is the compiled, request-ready form of one profile's Spec 108 policy (data-model.md §2), built once per published config snapshot by Compile and cached inside profileIndex (internal/server) alongside its server-scope data, taken with the snapshot as one immutable pair (Spec 105 D17 pattern) — never recompiled per request.

func Compile added in v0.70.0

func Compile(pc *config.ProfileConfig) *CompiledPolicy

Compile builds the request-ready CompiledPolicy for one profile (data-model §2). It is deliberately cheap for a legacy profile (pc.IsLegacy(): Tools is nil, so the allow/deny/classify loops below do zero work and Cap/ SwitchableTo/ManagementTools stay at their zero values; CodeExecution still resolves through EffectiveCodeExecution(), which is `true` — global gate decides — for a legacy/uncapped profile, FR-003a) — the "fast path" a legacy snapshot takes through the profileIndex that caches this per snapshot (internal/server/profile_tool.go).

Rule/classify entries naming a server outside pc.Servers were already warned-and-ignored at validation time (config.ValidateProfiles, FR-004/ FR-007); Compile re-applies that same filter so a stale or hand-edited config can never let such an entry widen anything here either.

func (*CompiledPolicy) Decide added in v0.70.0

func (p *CompiledPolicy) Decide(server, tool string, intrinsic Tier) (admitted bool, reason Reason, profileTier Tier)

Decide computes the FR-010 profile decision for (server, tool) with its caller-supplied intrinsic tier (from IntrinsicTier). Order (highest priority first, matching FR-010 and contracts/enforcement-matrix.md exactly): (1) server not in the profile's servers -> excluded, server_not_in_profile; (2) a deny rule matches -> excluded, denied_by_rule; (3) an allow rule matches -> ADMITTED (an explicit allow bypasses the tier cap and unannotated policy entirely — deny beats allow on overlap because step 2 runs first); (4) unannotated and unclassified with policy "deny" -> excluded, unannotated_hidden; (5) the effective profile tier exceeds the cap -> excluded, above_tier_cap; else admitted.

p == nil is treated as "no policy" (defensive; every real caller only calls Decide when it already holds a non-nil CompiledPolicy for the caller's effective profile — data-model.md §4 ProfileResolution.Policy is nil only for source "none", which never reaches Decide).

func (*CompiledPolicy) HasAllowRules added in v0.70.0

func (p *CompiledPolicy) HasAllowRules() bool

HasAllowRules reports whether the policy has explicit tools.allow rules, which Decide admits even above the tier cap.

type CredentialState added in v0.70.0

type CredentialState string

CredentialState reports what a client's connection carries (FR-025; data-model.md §7 ClientView.credential_state / connect.ClientStatus).

const (
	CredentialStateClient   CredentialState = "client"
	CredentialStateAdminKey CredentialState = "admin_key"
	CredentialStateNone     CredentialState = "none"
	CredentialStateRevoked  CredentialState = "revoked"
	CredentialStateExpired  CredentialState = "expired"
	// CredentialStateUnknown means the client's config was not read: the
	// stat-only GET /connect listing (Spec 075 keeps that path free of
	// content reads) reports it for connected rows. The on-demand
	// GET /connect/{client} resolves the real state.
	CredentialStateUnknown CredentialState = "unknown"
)

type ExplainStep added in v0.70.0

type ExplainStep string

ExplainStep is one link of the access-explanation chain, in the canonical enforcement order every refusal, view-as row and explainer walks (FR-032, FR-035; data-model.md §7 AccessExplanation).

const (
	StepCredential      ExplainStep = "credential"
	StepProfile         ExplainStep = "profile"
	StepServerInScope   ExplainStep = "server_in_scope"
	StepToolRule        ExplainStep = "tool_rule"
	StepTierCap         ExplainStep = "tier_cap"
	StepTokenPermission ExplainStep = "token_permission"
	StepGlobalGate      ExplainStep = "global_gate"
	StepServerState     ExplainStep = "server_state"
	StepToolApproval    ExplainStep = "tool_approval"
)

func StepOrder added in v0.70.0

func StepOrder() []ExplainStep

StepOrder returns the canonical access-explanation step order (data-model.md §7), a defensive copy the caller may mutate freely.

type ExplainVerdict added in v0.70.0

type ExplainVerdict string

ExplainVerdict is the overall answer of an access explanation (FR-035): allowed = callable; hidden = not visible; blocked = visible but not callable.

const (
	ExplainVerdictAllowed ExplainVerdict = "allowed"
	ExplainVerdictBlocked ExplainVerdict = "blocked"
	ExplainVerdictHidden  ExplainVerdict = "hidden"
)

type FixAction added in v0.70.0

type FixAction string

FixAction names a remediation the access explainer offers alongside a failing step (FR-035; data-model.md §7 AccessExplanation.fixes[].action).

const (
	FixAllowInProfile     FixAction = "allow_in_profile"
	FixClassifyInProfile  FixAction = "classify_in_profile"
	FixAddServerToProfile FixAction = "add_server_to_profile"
	FixMoveClient         FixAction = "move_client"
	FixEditToken          FixAction = "edit_token"
	FixEnableServer       FixAction = "enable_server"
	FixApproveTool        FixAction = "approve_tool"
	FixChangeSetting      FixAction = "change_setting"
	FixReconnectClient    FixAction = "reconnect_client"
)

type ProfileScope

type ProfileScope struct {
	// Name is the resolved profile slug, used in rejection messages and activity
	// metadata (FR-012).
	Name string
	// contains filtered or unexported fields
}

ProfileScope is the immutable, request-scoped set of servers a profile exposes. It is resolved once — from a token pin, a /mcp/p/<slug> URL, or a session selection — and never mutated for the lifetime of a request.

func NewProfileScope

func NewProfileScope(name string, servers []string) *ProfileScope

NewProfileScope builds a scope for the named profile over the given effective server set. The returned scope is always non-nil (an empty/nil server list is a legal profile that allows nothing).

func ProfileScopeFromContext

func ProfileScopeFromContext(ctx context.Context) *ProfileScope

ProfileScopeFromContext extracts the URL-injected ProfileScope, or nil when the request did not enter via a profile URL.

This is the URL TIER ONLY. Enforcement code must not call it directly: a request can carry a higher-precedence token pin or a session selection that never touches the context. Resolve the effective scope through the server package's resolveActiveProfile instead — reading this alone is how the code_execution sandbox once ran outside a pinned token's profile.

func (*ProfileScope) AllowedServerNames

func (p *ProfileScope) AllowedServerNames() []string

AllowedServerNames returns the list of server names in this profile scope. Returns nil for a nil receiver (allow-all — no restriction list). Returns an empty slice for a non-nil scope with no servers (deny-all).

func (*ProfileScope) Allows

func (p *ProfileScope) Allows(serverName string) bool

Allows reports whether the named server is visible under this scope.

A nil receiver means no profile is in effect for this request — no URL slug, no session selection, no token pin — so it is not profile-filtered and every server is allowed (FR-010). A non-nil scope allows only servers in its set; the empty server name is never allowed for a real scope.

func (*ProfileScope) DeniesAll added in v0.58.0

func (p *ProfileScope) DeniesAll() bool

DeniesAll reports whether this scope allows nothing at all — an empty profile, or the deny-all scope a stale agent-token pin resolves to. A nil receiver is "no profile filtering" and therefore never denies all.

It exists so callers can distinguish "filtered to nothing" from "not filtered" without allocating an AllowedServerNames slice, notably to avoid lazily creating a per-profile Bleve index for a scope that can return no results anyway.

type Reason added in v0.70.0

type Reason string

Reason is why the FR-010 profile decision excluded a tool. The zero value ("") means admitted — no exclusion reason.

const (
	ReasonNone               Reason = ""
	ReasonServerNotInProfile Reason = "server_not_in_profile"
	ReasonDeniedByRule       Reason = "denied_by_rule"
	ReasonUnannotatedHidden  Reason = "unannotated_hidden"
	ReasonAboveTierCap       Reason = "above_tier_cap"
)

type Source added in v0.70.0

type Source string

Source is where an effective profile resolution came from (FR-020, data-model.md §4 ProfileResolution.Source).

const (
	SourcePin       Source = "pin"
	SourceBinding   Source = "binding"
	SourceURL       Source = "url"
	SourceSession   Source = "session"
	SourceAnonymous Source = "anonymous"
	SourceNone      Source = "none"
)

type Surface added in v0.70.0

type Surface string

Surface names the caller of a profile-mutating operation, recorded on `profile_change` activity (FR-030; the `X-MCPProxy-Surface` header).

const (
	SurfaceWeb   Surface = "web"
	SurfaceMacOS Surface = "macos"
	SurfaceCLI   Surface = "cli"
	SurfaceMCP   Surface = "mcp"
	SurfaceAPI   Surface = "api"
)

type Tier added in v0.70.0

type Tier int

Tier is a tool's capability classification under a profile: none (an unannotated tool with no cap-relevant classification) < read < write < destructive. It is an int, unlike contracts.Tier (a string), because CompiledPolicy.Decide compares it against a numeric cap (data-model.md §2).

const (
	TierUnannotated Tier = iota // 0: no tier hint and no classification/policy resolved one
	TierRead
	TierWrite
	TierDestructive
)

func IntrinsicTier added in v0.70.0

func IntrinsicTier(a *config.ToolAnnotations, found bool) Tier

IntrinsicTier derives a tool's intrinsic tier from its effective annotations, through Spec 109-a's contracts.AnnotationTier (research D30) — the ONE place the annotation→tier rule is computed; this is an EXHAUSTIVE adapter over every contracts.Tier value, never a second implementation of the rule. found=false (the tool's identity could not be resolved, e.g. a stale/unknown server:tool pair) fails closed to TierDestructive regardless of a (FR-011).

func (Tier) String added in v0.70.0

func (t Tier) String() string

String returns the contracts.Tier spelling, so every surface that prints a profile tier prints Spec 109's word (data-model.md §2).

type ToolBlockedError added in v0.70.0

type ToolBlockedError struct {
	Reason  BlockReason
	Message string
}

ToolBlockedError identifies an upstream tool call refused by a compiled profile policy. Its message is the stable MCP refusal rendered from the decision, while Reason carries the typed audit/HTTP classification.

func (*ToolBlockedError) Error added in v0.70.0

func (e *ToolBlockedError) Error() string

type UnannotatedPolicy added in v0.70.0

type UnannotatedPolicy string

UnannotatedPolicy is a profile's handling of a tool whose effective annotations carry no tier hint (FR-001, FR-003). The string spellings match config.ProfileUnannotated* (internal/config/profiles.go) exactly; that package cannot import this one (see the PolicyEnforcementReady note there), so the two are kept in sync by convention and pinned by contract_test.go.

const (
	UnannotatedDeny    UnannotatedPolicy = "deny"
	UnannotatedAsWrite UnannotatedPolicy = "as_write"
	UnannotatedAsRead  UnannotatedPolicy = "as_read"
)

type WarningCode added in v0.70.0

type WarningCode string

WarningCode is a Clients-surface warning code (data-model.md §7 ClientView.warnings[]; Spec 109-l maps these same names to Needs-attention kinds).

const (
	WarningAnonymousDeniedByBindingGuard WarningCode = "anonymous_denied_by_binding_guard"
	WarningClientHoldsAdminKey           WarningCode = "client_holds_admin_key"
	WarningClientCredentialExpiring      WarningCode = "client_credential_expiring"
	WarningClientRotationPending         WarningCode = "client_rotation_pending"
	WarningProfileMissing                WarningCode = "profile_missing"
	WarningClientTokenNameConflict       WarningCode = "client_token_name_conflict"
)

type WarningSeverity added in v0.70.0

type WarningSeverity string

WarningSeverity grades a Clients-surface warning (data-model.md §7).

const (
	WarningSeverityWarn WarningSeverity = "warn"
	WarningSeverityInfo WarningSeverity = "info"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL