scope

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package scope decides which brains a request may read.

The rules are deliberately small and fail closed:

  • A token grants a fixed set of brains. Nothing outside that set is ever readable.
  • The harness sends the brains a session wants (from projects.yaml). Asking for a brain the token does not grant is an error, not a silent drop, so a misconfigured session is visible immediately.
  • With no requested brains, the session gets every granted brain except sensitive ones. Sensitive brains are only ever included by name.
  • Cortex is always included when the token grants it.
  • A grant may name a family, "client-*", which covers every brain named "client-<suffix>". Families are never expanded by default: their members are only read when named, so a new sub-project brain needs no new grant and never leaks into a default scope.

Index

Constants

View Source
const Cortex = "cortex"

Cortex is the shared brain every scope builds on.

View Source
const FamilySuffix = "-*"

FamilySuffix marks a family pattern: "client-*" covers "client-<suffix>".

Variables

View Source
var ErrForbidden = errors.New("brain not permitted for this token")

ErrForbidden is returned when a request asks for a brain its token does not grant.

Functions

func IsFamily

func IsFamily(s string) bool

IsFamily reports whether s is written as a family pattern.

func Matches

func Matches(entry, name string) bool

Matches reports whether name is entry itself, or a member of the family entry. A family never matches its own base name: "client-*" does not match "client".

func MatchesAny

func MatchesAny(entries []string, name string) bool

MatchesAny reports whether name matches any of the entries.

func ParseHeader

func ParseHeader(v string) ([]string, error)

ParseHeader splits a comma-separated brain list (the X-Ki-Brains header).

func Resolve

func Resolve(granted, requested []string, sensitive func(string) bool) ([]string, error)

Resolve returns the sorted brains a request may read. sensitive reports whether a brain must only be included when explicitly requested.

func ValidEntry

func ValidEntry(s string) bool

ValidEntry reports whether s is a valid brain name or family pattern.

func ValidFamily

func ValidFamily(s string) bool

ValidFamily reports whether s is a well-formed family pattern: a valid name followed by "-*".

func ValidName

func ValidName(s string) bool

ValidName reports whether s is a well-formed brain name.

Types

This section is empty.

Jump to

Keyboard shortcuts

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