scope

package
v0.2.8 Latest Latest
Warning

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

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

Documentation

Overview

Package scope is layer 0 of the filtering pyramid (PRD section 19), as a value: WHICH project-relative files an audit pass is allowed to look at.

It is a pure leaf — it imports nothing from codefit — so the core, the sensors and the MCP adapter can all speak the same narrowing without a dependency.

codefit does not derive the scope from git. It never reads .git, never diffs refs and assumes no branch model: it has no power over the user's git (CLAUDE.md, autonomy principle), and the MCP caller is an agent that already knows which files it touched. The scope is therefore an INPUT.

Two fail-safes point in opposite directions, on purpose:

  • Of with an absent or empty list returns Full. "Nothing was passed" must never be read as "audit nothing"; the safe direction for an auditor is to look at MORE.
  • The zero value Scope{} includes NOTHING, and that is why Full is an explicit constructor rather than the zero value. baseline.Diff uses Scope.Includes to decide whether an item may be marked gone (and later pruned), so a caller that forgets to pass a scope prunes nothing — under-reporting instead of deleting audit memory it never verified.

A walk wants the third question, not either of those: does this scope restrict me at all? That is Scope.Narrows, false for both Full{} and the zero value, so an unset scope can never silently blank a walk.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Canon

func Canon(p string) string

Canon is the canonical form of a project-relative path, and the SINGLE definition of it: separators normalized to "/", then cleaned. A caller that must compare a path against a scope (a configured schema path, say) uses this rather than re-deriving the rule.

It is deliberately platform-INDEPENDENT — path.Clean over slash-normalized text, not filepath.Clean. The paths a scope holds are project-relative identifiers that travel between an agent, a committed baseline and a repository checked out on either OS; resolving `src\a.ts` only when codefit happens to be running on Windows would reintroduce exactly the separator drift v0.2.6 paid to remove.

Types

type Scope

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

Scope is the set of project-relative files an audit pass may examine. Build it with Full or Of; the zero value includes nothing (see the package doc).

func Full

func Full() Scope

Full returns the scope that includes every file — a complete audit.

func Of

func Of(rels []string) Scope

Of returns the scope of exactly these project-relative paths, canonicalized. An absent or empty list (or one holding only blanks) returns Full: an empty scope is never read as "audit nothing".

func (Scope) Files

func (s Scope) Files() []string

Files returns the scoped paths, canonical and sorted — nil when the scope is full (there is no finite list of "everything"). The result is a copy.

func (Scope) Includes

func (s Scope) Includes(rel string) bool

Includes reports whether rel is in the scope. rel is canonicalized on lookup, exactly as it was on construction, so a caller's separator or "./" prefix cannot make the same file miss itself.

func (Scope) IsFull

func (s Scope) IsFull() bool

IsFull reports whether the scope includes every file.

func (Scope) Narrows

func (s Scope) Narrows() bool

Narrows reports whether the scope actually restricts anything. It is false for Full AND for the zero value — the question a WALK must ask, so an unconfigured scope widens the audit instead of blanking it. Do not confuse it with Scope.Includes, whose zero-value answer is deliberately the opposite.

Jump to

Keyboard shortcuts

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