Agent Branch Patterns
LumenFlow maintains a central registry of AI agent branch patterns that can bypass worktree requirements. This enables cloud-hosted agents and automation tools to work in the main checkout while still enforcing worktree discipline for human developers.
How It Works
Section titled “How It Works”- Fetch from Registry - The
isAgentBranch()function fetches patterns fromlumenflow.dev/registry/agent-patterns.json - Cache Locally - Patterns are cached for 7 days in
~/.lumenflow/cache/ - Merge with Config - Registry patterns are merged with any custom patterns from config
- Check Branch Name - Branch names are matched against glob patterns using
micromatch
Default Patterns
Section titled “Default Patterns”The registry includes patterns for popular AI agents:
In TypeScript
Section titled “In TypeScript”In CLI (Git Hooks)
Section titled “In CLI (Git Hooks)”Synchronous Version (Deprecated)
Section titled “Synchronous Version (Deprecated)”For backwards compatibility, a sync version is available:
Configuration
Section titled “Configuration”Configure agent patterns in workspace.yaml. There are three modes:
Custom patterns are merged with registry patterns:
Result: Your patterns + registry patterns (deduplicated)
Replace registry patterns entirely:
Result: Only your override patterns (no registry fetch)
Disable network fetch for isolated environments:
Result: Only your config patterns (or defaults if none specified)
Configuration Options
Section titled “Configuration Options”| Option | Type | Default | Description |
| ----------------------------- | -------- | ----------- | ----------------------------------- |
| agentBranchPatterns | string[] | [] | Patterns to merge with registry |
| agentBranchPatternsOverride | string[] | undefined | Patterns that replace registry |
| disableAgentPatternRegistry | boolean | false | Skip network fetch (airgapped mode) |
Behavior Matrix
Section titled “Behavior Matrix”| Registry Disabled | Override Set | Config Patterns | Result | Source |
| ----------------- | ------------ | --------------- | ------------------------ | ---------- |
| false | no | none | Registry patterns | registry |
| false | no | ['custom/*'] | Config + Registry | merged |
| false | yes | any | Override only | override |
| true | no | none | Defaults (['agent/*']) | defaults |
| true | no | ['custom/*'] | Config only | config |
| true | yes | any | Override only | override |
Protected Branches
Section titled “Protected Branches”Some branches are never bypassed, regardless of patterns:
- Main branch (from
git.mainBranchconfig) - master (legacy protected)
- Lane branches (matching
lane/*)
Worktree Dependency Isolation
Section titled “Worktree Dependency Isolation”An agent-branch match changes where a client may work; it does not authorize one checkout to reuse another checkout’s mutable dependency graph.
For local worktree claims, LumenFlow runs a frozen package-manager install inside the new worktree.
Workspace package links must resolve inside that worktree. A package manager may share its
content-addressed store through hardlinks, reflinks, or copies materialized into checkout-local
virtual storage; a direct workspace link may never resolve to an external store. Root or
package-local node_modules directories are never linked to main or another worktree. Each
intermediate dependency scope and package component is realpath-checked, including directory
junctions. If local installation fails, claim setup fails without creating a shared fallback.
wu:claim --skip-setup creates no dependency links and runs no install. Before gates can run, set up
dependencies inside that checkout. A missing/non-directory dependency root or missing declared
workspace package fails preflight, and gates never substitutes main’s CLI dist for the worktree
copy. Gate preflight reports the exact path and resolved target, then refuses to execute any gate
command.
Older local worktrees can be converted through wu:rebase or
wu:recover --id WU-XXX --action resume. Use wu:rebase --dry-run to report
conversion-required without fetching, unlinking, installing, snapshotting or repairing main, or
mutating Git. An isolated result also leaves main unsnapshotted. Actual conversion records
deterministic link objects, continues through safe checkout-local ancestors, checks package-local
dependency roots even when a package declares no workspace dependencies, and unlinks only the first
broken or escaping object after revalidation. It never traverses or mutates the resolved target.
Once conversion starts, LumenFlow snapshots main before mutation and attests it afterward even if worktree unlink, install, or verification fails. An already-unsafe main is repaired to a safe graph without restoring that unsafe snapshot. If a safe pre-mutation snapshot later drifts, recovery also requires exact restoration of that safe baseline. That lifecycle attempt still hard-fails so the operator reruns from a clean, auditable boundary. Branch-only and branch-PR modes perform no local worktree conversion, even if a stale same-WU directory remains at the canonical path.
Cache Behavior
Section titled “Cache Behavior”| Scenario | Behavior |
| --------------------- | ----------------------------------------------- |
| Fresh cache (<7d) | Use cached patterns, no network request |
| Stale cache (>=7d) | Attempt fetch, use fresh if successful |
| Fetch fails | Use stale cache if available, else use defaults |
| No cache, no network | Use defaults (['agent/*']) |
Cache Location
Section titled “Cache Location”Patterns are cached in:
Or if LUMENFLOW_HOME is set:
Clearing the Cache
Section titled “Clearing the Cache”To clear disk cache, delete the cache file:
Advanced: Programmatic Resolution
Section titled “Advanced: Programmatic Resolution”Use resolveAgentPatterns() for testing or custom resolution:
Injectable Fetcher
Section titled “Injectable Fetcher”For testing, inject a custom fetcher:
Registry API
Section titled “Registry API”The registry is served as static JSON:
URL: https://lumenflow.dev/registry/agent-patterns.json
Response Schema:
Adding New Patterns
Section titled “Adding New Patterns”To request a new agent pattern be added, include the agent name and the typical branch prefix in a community discussion (channels will be announced with v5.0.0). Patterns are added to the registry after review.
Headless Mode
Section titled “Headless Mode”For CI/CD environments that don’t use agent branches, enable guarded headless mode:
This bypasses all worktree checks. See AI Agent Integration for details.
Fail-Closed Design
Section titled “Fail-Closed Design”The system is fail-closed:
- Unknown branches are protected (require worktrees)
- Detached HEAD is protected
- Null/empty branches are protected
- Network errors fall back to cache/defaults (not bypass)
This ensures accidental work in the wrong location is prevented.