branchparse

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package branchparse holds the canonical ritual-shape branch grammar defined by ADR-0010: `epic/E-NNNN-<slug>`, `milestone/M-NNNN-<slug>`, `patch/g-NNNN-<slug>` (case-insensitive id segment). Lifted from internal/cli/status/worktrees.go in M-0102 so M-0103's preflight, M-0102's `aiwf authorize --branch` completion, and the existing `aiwf status --worktrees` correlation share one regex set — drift between them is structurally impossible.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LegalRungPair

func LegalRungPair(currentRung, targetRung string) bool

LegalRungPair returns true iff the (currentRung, targetRung) pair is in the closed legal set. Any pair involving an empty rung (`""` on either side) returns false — the rung predicate is only meaningful when both sides classify.

Used by the M-0161/AC-2 verb-layer authorize predicate.

func ParseEntityFromBranch

func ParseEntityFromBranch(branch string) string

ParseEntityFromBranch tries to derive an entity id from a ritual-shape branch name, requiring the prefix and id kind to agree: `epic/E-NNNN-...`, `milestone/M-NNNN-...`, `patch/g-NNNN-...`. Returns "" on no match or on a prefix-id mismatch (G-0198) — the caller treats that as "not a ritual branch."

func ParseEpicFromWorktreePath added in v0.25.0

func ParseEpicFromWorktreePath(path string) string

ParseEpicFromWorktreePath tries to derive an epic id from a worktree's filesystem path. Returns "" when the path carries no `epic/E-NNNN-...` segment. G-0332.

func RungOf

func RungOf(branch, trunkShort string) string

RungOf classifies a branch name into its ritual rung:

  • "trunk" if branch equals trunkShort (config-driven trunk detection).
  • "epic" if branch matches `epic/...`.
  • "milestone" if branch matches `milestone/...`.
  • "patch" if branch matches `patch/...`.
  • "" on no match (non-ritual branch; detached HEAD; degenerate input).

trunkShort is the consumer's configured trunk short-name as sourced from Config.TrunkBranchShortName() (M-0161/AC-1). When trunkShort is the empty string, no branch can be classified as "trunk" — the empty-guard prevents silent coincidence with an empty CurrentBranch (detached-HEAD state).

Trunk detection is config-driven so a repo using `master` (or any other operator-chosen trunk) gets the right rung classification without regex hardcoding. The ritual-prefix detection (epic/ milestone/ patch/) is independent of trunkShort — both predicates are checked in sequence.

Used by the M-0161/AC-2 verb-layer authorize predicate alongside LegalRungPair: the verb computes (RungOf(current, trunk), RungOf(target, trunk)) and refuses when the pair is not in the legal set.

Types

This section is empty.

Jump to

Keyboard shortcuts

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