contextresolver

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package contextresolver discovers and assembles session-scoped coding-agent instructions without depending on an agent framework.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtensionPolicy

func ExtensionPolicy(allowed, denied []extensions.ToolPattern, restricted bool) syntax.ToolPolicy

ExtensionPolicy projects a normalized extension tool declaration into the single turn-scope policy representation.

Types

type Expansion

type Expansion struct {
	Source     string
	Path       string
	Trust      TrustLevel
	Arguments  string
	Declared   []string
	SessionID  string
	SkillDir   string
	ProjectDir string
	PluginRoot string
	PluginData string
	Effort     string
}

Expansion supplies the supported deterministic extension substitutions.

type HostSelection

type HostSelection struct {
	Claude  bool
	Codex   bool
	Copilot bool
}

HostSelection enables instruction inputs owned by each compatible host.

type InstructionProvenance

type InstructionProvenance struct {
	Host           string `json:"host"`
	Scope          string `json:"scope"`
	SourcePath     string `json:"source_path"`
	Enabled        bool   `json:"enabled"`
	Trusted        bool   `json:"trusted"`
	Classification string `json:"classification"`
}

InstructionProvenance identifies one retained instruction source.

type InstructionRecord

type InstructionRecord struct {
	Name       string                  `json:"name"`
	Provenance []InstructionProvenance `json:"provenance"`
}

InstructionRecord is secret-free metadata for one normalized instruction declaration retained by a session snapshot.

type Options

type Options struct {
	Root                *workspace.Root
	HomeDir             string
	ImportRoots         []string
	TrustedRoots        []string
	MaxFileBytes        int
	MaxBytes            int
	MaxImportDepth      int
	MaxImportDepthSet   bool
	MaxDiscoveryEntries int
	PromptCommands      config.PromptCommandMode
	CommandTimeout      time.Duration
	DocumentTimeout     time.Duration
	CommandOutputBytes  int
	DocumentOutputBytes int
	Executor            *shellexec.Executor
	Hosts               *HostSelection
	WarningSink         warning.Warner
}

Options configures one resolver owned by a Harness.

type Resolver

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

Resolver owns immutable session snapshots, lazy activation, and turn scope.

func New

func New(options Options) (*Resolver, error)

New validates resolver configuration. Discovery remains inert until a session starts.

func (*Resolver) ActiveScopes

func (r *Resolver) ActiveScopes() int

ActiveScopes reports the current scope count for conformance tests.

func (*Resolver) Allows

func (r *Resolver) Allows(sessionID, invocationID, toolName string, args map[string]any) bool

Allows rechecks the argument-aware policy for one native tool invocation.

func (*Resolver) Close

func (r *Resolver) Close()

Close releases all session snapshots. It is idempotent.

func (*Resolver) Closed

func (r *Resolver) Closed() bool

Closed reports whether resource teardown has started.

func (*Resolver) DropSession

func (r *Resolver) DropSession(sessionID string)

DropSession releases one snapshot after transactional session-start failure.

func (*Resolver) Expand

func (r *Resolver) Expand(ctx context.Context, value Expansion) (string, error)

Expand applies argument and Harness substitutions once, then runs prompt commands through the resolver's single bounded executor and trust gate.

func (*Resolver) InstructionRecords

func (r *Resolver) InstructionRecords(sessionID string) []InstructionRecord

InstructionRecords returns a defensive copy of normalized metadata from a started session snapshot.

func (*Resolver) Instructions

func (r *Resolver) Instructions(ctx context.Context, sessionID, invocationID string) (string, error)

Instructions returns assembled instructions and records the exact invocation policy used by the native before-tool callback.

func (*Resolver) IntersectPolicy

func (r *Resolver) IntersectPolicy(sessionID, invocationID string, policy syntax.ToolPolicy) error

IntersectPolicy atomically narrows the active invocation scope. It cannot create a scope or widen any existing instruction or skill policy.

func (*Resolver) ObserveTouch

func (r *Resolver) ObserveTouch(_ context.Context, touch workspace.Touch)

ObserveTouch activates nested and path-scoped documents once per session.

func (*Resolver) ReleaseRun

func (r *Resolver) ReleaseRun(sessionID string)

ReleaseRun removes every invocation scope belonging to a completed or aborted session run.

func (*Resolver) SetRunPolicy

func (r *Resolver) SetRunPolicy(sessionID string, policy syntax.ToolPolicy) error

SetRunPolicy installs one additional deny-wins layer for the next active run in a session. The Harness serializes runs per session.

func (*Resolver) StartSession

func (r *Resolver) StartSession(ctx context.Context, sessionID string) error

StartSession captures a stable catalog snapshot for a session.

func (*Resolver) Visible

func (r *Resolver) Visible(sessionID, invocationID, toolName string) bool

Visible reports name-level model visibility for one invocation scope.

type TrustLevel

type TrustLevel uint8

TrustLevel classifies command authority without changing instruction visibility.

const (
	TrustUntrusted TrustLevel = iota
	TrustRepository
	TrustUser
)

func ExtensionTrust

func ExtensionTrust(source extensions.Provenance) TrustLevel

ExtensionTrust projects normalized extension provenance into the single prompt-execution trust model.

func (TrustLevel) String

func (t TrustLevel) String() string

Jump to

Keyboard shortcuts

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