permissions

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 2 Imported by: 0 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 permissions defines golder's approval modes and the live, mutable state that tracks the active one. It is a leaf package: standard library only, no imports from judge/trust/runtime, so every layer (the risk gate, the bash tool, the slash command) can read the mode without an import cycle.

The four modes mirror codex's approval presets, adapted to golder's gate:

  • read-only: mutating tools (bash, apply_patch) are blocked outright.
  • ask: the reviewer grades each mutating call; Allow runs, the rest asks the human (or is denied when no prompt exists).
  • auto: the reviewer decides: Allow/Confirm run, Sandbox runs isolated, Deny is blocked — each non-trivial decision is announced with a one-line rationale.
  • full-access: no review and no sandbox; only the static hard-deny floor still applies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mode

type Mode int

Mode is one of the four approval modes.

const (
	// ReadOnly blocks mutating tools: the model may inspect but not change.
	ReadOnly Mode = iota
	// Ask grades each mutating call and asks the human about anything that is
	// not clearly low-risk. Without an interactive prompt the call is denied.
	Ask
	// Auto lets the reviewer decide without a human: reviewed calls run, risky
	// ones run sandboxed, dangerous ones are blocked, and each decision is
	// announced with its rationale.
	Auto
	// FullAccess disables review and sandboxing (the static floor remains).
	FullAccess
)

func FromEnv

func FromEnv(getenv func(string) string) (Mode, bool)

FromEnv resolves the default mode from GOLDER_PERMISSIONS. GOLDER_JUDGE=off is honored as a legacy alias for full-access. ok is false when the variable is unset or unparseable, leaving the caller's own default in place.

func Parse

func Parse(s string) (Mode, bool)

Parse resolves a user-supplied mode name. It accepts the canonical names plus a few common shorthands ("readonly", "ro", "full"), case-insensitively. ok is false for anything unrecognized so callers can report a usage error instead of silently picking a default.

func (Mode) Description

func (m Mode) Description(lang string) string

Description returns the one-line explanation shown next to the label.

func (Mode) Label

func (m Mode) Label(lang string) string

Label returns the human-facing name of the mode in the given language ("zh" for Simplified Chinese, anything else English). UI surfaces use it so the /permissions output matches the language of the conversation.

func (Mode) String

func (m Mode) String() string

String returns the canonical, lowercase mode name used by the CLI, the slash command, and the config/env layers.

type State

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

State is the process-wide, concurrency-safe holder of the active mode. The gate, the bash tool and the slash command all read it live, so a /permissions switch applies to the very next tool call (even mid-run).

func New

func New(mode Mode) *State

New returns a State seeded with mode.

func (*State) Mode

func (s *State) Mode() Mode

Mode returns the active mode.

func (*State) Set

func (s *State) Set(mode Mode)

Set replaces the active mode.

Jump to

Keyboard shortcuts

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