Branching & Rebasing
Relevant source files
The following files were used as context for generating this wiki page:
Infrahub manages infrastructure data by combining Git-like branching and version control with a Neo4j graph database. This system isolates changes in individual branches before merging them into a stable state. Users interact with these branches to manage schemas and infrastructure data.
Sources: AGENTS.md:3-5, dev/guidelines/git-workflow.md:7-12
Branch Strategy
Infrahub utilizes a structured branch strategy to maintain production stability. The system defines two primary main branches and allows for feature-specific branches.
Main Branches
- stable: This branch represents the production state.
- develop: This branch serves as the primary development target.
- release-*: These branches manage specific release cycles.
Sources: dev/guidelines/git-workflow.md:7-9
Feature Branches
You create feature branches from develop to isolate new enhancements. You merge these branches back into develop using a Pull Request (PR) after completing development. Bug fixes and performance improvements target the oldest maintained branch that requires the fix.
Sources: dev/guidelines/git-workflow.md:10-15
Branch Lifecycle and Status
Branches transition through specific states during their lifecycle. These states dictate what operations the system can perform on the data.
| Status | Description |
|---|---|
ACTIVE | The branch is available for data modifications and queries. |
MERGED | The system successfully integrated the branch changes into the target. |
DELETING | The system is currently removing the branch and its relationships. |
Sources: dev/specs/infp-389-branch-merge-delete/plan.md:33, dev/specs/infp-389-branch-merge-delete/plan.md:58
Merging Orchestration
The BranchMergeOrchestrator manages the technical process of merging data. Merging can occur via standard branch merges or through Proposed Changes.
Merge Flow
- Capture Diff: The orchestrator serializes the branch diff into a summary.
- Apply Merge: The system integrates changes into the target branch.
- Update Status: The branch transitions to the
MERGEDstate. - Lift Write Block: The system removes blocks to allow further operations.
- Run Follow-ups: The
PostMergeDispatcherinitiates post-merge tasks.
Sources: specs/archive/ifc-2704-incremental-merge-regen/tasks.md:46-52, dev/specs/infp-389-branch-merge-delete/plan.md:12
Post-Merge Automation
Infrahub can automatically delete branches after a successful merge. This behavior is opt-in and controlled by configuration settings.
The diagram shows the logic flow from merge initiation to potential automated branch deletion.
Sources: dev/specs/infp-389-branch-merge-delete/plan.md:12-20, specs/archive/ifc-2704-incremental-merge-regen/tasks.md:52-54
Rebasing Mechanics
Rebasing updates a branch by applying changes from a parent branch. This ensures the feature branch contains the latest updates from develop or main.
During a rebase, Infrahub emits node events for every changed node. These events trigger automatic recomputations for:
- Computed attributes
- Display labels
- Human Friendly Identifiers (HFIDs)
Sources: dev/specs/ifc-2761-merge-recompute-profile/plan.md:7-10
Configuration for Branch Management
You control branch behavior through Pydantic settings in the backend configuration.
| Configuration Field | Type | Default | Description |
|---|---|---|---|
delete_branch_after_merge | Boolean | False | Enables automatic deletion of Infrahub branches post-merge. |
delete_git_branch_after_merge | Boolean | False | Enables deletion of linked Git branches post-merge. |
selective_execution_after_merge | Boolean | True | Triggers regeneration only for affected artifacts. |
Sources: dev/specs/infp-389-branch-merge-delete/plan.md:37, specs/archive/ifc-2704-incremental-merge-regen/tasks.md:37-39
Incremental Regeneration
Infrahub uses a selective_regen routine to optimize system performance after a merge. Instead of regenerating every artifact, the system identifies specific definitions affected by the diff.
- Diff Summary: The system loads the cached diff summary from the merge.
- Predicate Checks: Predicates like
_query_changedand_definition_changedidentify impacted definitions. - Member Scoping: The system narrows regeneration to specific members if only a subset of data changed.
- Dispatch: The system submits targeted
REQUEST_GENERATOR_DEFINITION_RUNtasks.
Sources: specs/archive/ifc-2704-incremental-merge-regen/tasks.md:88-96, specs/archive/ifc-2704-incremental-merge-regen/tasks.md:104-106
The branching and rebasing system provides a safe environment for infrastructure changes. By combining Neo4j graph versioning with automated post-merge workflows, Infrahub ensures data consistency and reduces manual cleanup efforts.