resolve

package
v0.0.25 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package resolve maps tracked paths to owner sets (S-1: last match wins).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All(f *file.File, tree []string) map[string]Resolution

All resolves every tracked path (INV-3: the tree, not the pattern set, is the domain of resolution).

func CanonicalOwners added in v0.0.13

func CanonicalOwners(owners []string) []string

CanonicalOwners drops repeated owners under the identity, keeping the first spelling. It returns the input slice untouched when there is nothing to drop — the common case, and the one where copying every rule's owners for every tracked path would be pure allocation.

Exported for owner collections that did NOT come from One: a snapshot on disk was written by whatever version of the tool (or whichever hand) made it, and comparing one that lists an owner twice against one that lists it once must not read as an ownership change.

func OwnersEqual

func OwnersEqual(a, b []string) bool

OwnersEqual compares two owner sets. Order is presentation, not semantics (owners on a line are alternatives, not a sequence), so this is set equality — but nil (unmatched) and empty (explicitly zero-owned) are distinct states and never equal.

Members compare under ops.FoldOwner (R-38a): `@org/team` and `@Org/Team` are one owner, so a plan whose model spells a handle one way and whose file spells it the other has changed nobody's access and must not be refused as an invariant violation. Only the SPELLING is indifferent here — multiplicity is not, so this stays a multiset comparison and still catches a model that carries an owner twice where the file carries it once.

Types

type Resolution

type Resolution struct {
	Path    string   `json:"path"`
	Matched bool     `json:"matched"`
	Owners  []string `json:"owners"` // nil if unmatched; non-nil (possibly empty, S-9) if matched
	// LineIndex is the index into File.Lines of the winning rule (-1 if none).
	LineIndex int `json:"line_index"`
}

Resolution is the resolved ownership of one tracked path.

func One

func One(rules []*file.Rule, path string) Resolution

One resolves a single path against the file's rules: the LAST matching valid rule wins (S-1); invalid lines are skipped.

The winning rule's owners are CANONICALISED before they leave: each owner once, under ops.FoldOwner, first spelling kept (R-38a/R-38f). A resolution is "who owns this path", and a hand-written `/x/ @org/team @Org/Team` names one owner twice — reporting it twice would make the two ways this codebase compares owner collections disagree, since ops.sameOwnerSet compares as a SET and OwnersEqual as a MULTISET. Canonicalising here means every owner collection either of them can ever see is already free of folded duplicates, so they cannot disagree, and OwnersEqual keeps its multiplicity check — which is what lets plan.Build's gate still catch a planner that wrote an owner twice into its own model.

The RULE's own slice is never touched: spelling is preserved on the line (R-38b), and `sync` does not collapse a pre-existing duplicate (R-38f).

Jump to

Keyboard shortcuts

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