scope

package
v0.13.34 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package scope defines the session/project scoping token that gates cross-session delivery in the daemon. The design goal is to make global (cross-project) access the loud, deliberate exception rather than the silent default.

Almost every delivery path — proxy lookups, overlay endpoint resolution, broadcast fan-out — takes a Scope. A Scope built with Project(path) only matches that one project. A Scope built with Unscoped(reason) matches everything but emits an audit log line at the construction site, so every global access is greppable and traceable.

The zero value is invalid on purpose: callers must construct a Scope explicitly, which prevents "forgot to scope" bugs from compiling into a silent global.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NormalizePath

func NormalizePath(path string) string

NormalizePath is the single canonical path normalizer used for all scope comparisons. It resolves to an absolute path and lowercases on Windows for case-insensitive filesystems. Empty and "." normalize to "".

Types

type Scope

type Scope struct {
	// contains filtered or unexported fields
}

Scope identifies which project(s) an operation is allowed to touch.

Construct via Project (single project) or Unscoped (all projects, audited). The zero value reports Valid() == false and matches nothing.

func Project

func Project(path string) Scope

Project returns a Scope restricted to a single project directory. The path is normalized so callers may pass a raw, un-normalized directory.

func Unscoped

func Unscoped(reason string) Scope

Unscoped returns a Scope that matches every project. It is the deliberate escape hatch for the handful of daemon-wide operations (shutdown reaps, state restore, orphan scans). Every call logs an audit line identifying the caller and reason so global access stays rare and visible.

func (Scope) IsUnscoped

func (s Scope) IsUnscoped() bool

IsUnscoped reports whether this scope matches every project.

func (Scope) Match

func (s Scope) Match(path string) bool

Match reports whether the given project directory falls within this scope. An unscoped scope matches anything. An invalid (zero) scope matches nothing. The argument is normalized before comparison.

func (Scope) ProjectPath

func (s Scope) ProjectPath() string

ProjectPath returns the normalized project path, or "" when unscoped.

func (Scope) Reason

func (s Scope) Reason() string

Reason returns the audit reason supplied to Unscoped, or "".

func (Scope) Valid

func (s Scope) Valid() bool

Valid reports whether this scope was constructed (not a zero value).

Jump to

Keyboard shortcuts

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