identity

package
v0.6.7 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: MIT Imports: 9 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 identity checks that the git author identity a commit would use in a managed repo matches the identity pinned in .abcd/config/identity.json.

It is the single source of truth for the iss-62 managed-repo identity gate: `ahoy doctor` surfaces a divergence as a detection gap, and the installed pre-commit hook calls Check to fail closed before a mis-attributed commit can land — so a stray repo-local override (e.g. a sandbox "Test User") is caught up front rather than discovered later.

Index

Constants

View Source
const PinRelPath = ".abcd/config/identity.json"

PinRelPath is the committed identity pin, relative to the repo root.

Variables

This section is empty.

Functions

func WritePin

func WritePin(root string, p Pin) error

WritePin writes the pin to .abcd/config/identity.json (creating the config directory), pretty-printed with a trailing newline. It is how a repo adopts the identity gate. Both fields are required.

Types

type Effective

type Effective struct {
	Name  string
	Email string
}

Effective is the identity git would actually stamp on a commit in the repo, resolved as git resolves the author: the GIT_AUTHOR_NAME/GIT_AUTHOR_EMAIL environment overrides first, then git config's local > global > system layering.

func EffectiveIdentity

func EffectiveIdentity(root string) (Effective, error)

EffectiveIdentity returns the author identity git would stamp on a commit in root. Git gives the GIT_AUTHOR_NAME/GIT_AUTHOR_EMAIL environment variables HIGHER precedence than user.name/user.email config, so an agent/CI sandbox that exports them lands a mis-attributed commit that a config-only check would wave through. Each field is therefore resolved from its GIT_AUTHOR_* override first, falling back to `git config` (local > global > system) when the override is unset or blank. Unset name or email yields an empty field, not an error.

type Pin

type Pin struct {
	Name  string `json:"name"`
	Email string `json:"email"`
}

Pin is the expected commit identity, committed so every checkout enforces the same value regardless of local git config.

func LoadPin

func LoadPin(root string) (Pin, bool, error)

LoadPin reads .abcd/config/identity.json. It returns (pin, true, nil) when the pin is present and well formed, (Pin{}, false, nil) when the file is absent, and an error when it is malformed or missing a field — validating this external input rather than trusting it.

type Result

type Result struct {
	Status    Status
	Pin       Pin
	Effective Effective
	Reason    string
}

Result carries the comparison outcome and both identities for reporting.

func Check

func Check(root string) (Result, error)

Check resolves the effective identity, loads the pin, and compares them.

func (Result) Blocks

func (r Result) Blocks() bool

Blocks reports whether a pre-commit hook should refuse the commit. A mismatch or an unset identity blocks; a match, or an un-pinned (opted-out) repo, does not — an absent pin must never break commits in a repo that has not adopted the gate.

type Status

type Status int

Status is the outcome of comparing the effective identity to the pin.

const (
	// StatusOK: a pin exists and the effective identity matches it.
	StatusOK Status = iota
	// StatusNoPin: no identity.json — the repo has not opted into the gate.
	StatusNoPin
	// StatusMismatch: a pin exists and the effective identity differs.
	StatusMismatch
	// StatusUnset: a pin exists but git has no author identity configured.
	StatusUnset
)

func (Status) String

func (s Status) String() string

Jump to

Keyboard shortcuts

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