Skip to content

Merge stable into develop#9395

Open
infrahub-github-bot-app[bot] wants to merge 2 commits into
developfrom
stable
Open

Merge stable into develop#9395
infrahub-github-bot-app[bot] wants to merge 2 commits into
developfrom
stable

Conversation

@infrahub-github-bot-app
Copy link
Copy Markdown
Contributor

@infrahub-github-bot-app infrahub-github-bot-app Bot commented May 29, 2026

Merging stable into develop after merging pull request #9360.


Summary by cubic

Pins git sync fan-out to a specific commit so all workers converge on the same SHA even if upstream moves. Also adds a hard-reset path, fixes read-only broadcasts and a pull-time crash, and adds tests for Schema enum add/remove.

  • New Features

    • Added reset_to_commit(branch, commit) to hard-reset a branch worktree to a local SHA without contacting the remote.
    • RefreshGitFetch now carries an optional commit; workers fetch under a repo lock and reset to that SHA.
  • Bug Fixes

    • Prevented worker divergence by pinning and broadcasting the resolved commit for repo add, read-only add/pull, branch create, merge, and periodic sync.
    • Fixed crash when pull(create_if_missing=True) created a missing branch and needed to update its commit value.
    • Broadcast the correct READONLYREPOSITORY kind from the read-only add flow.
    • Return a clear error when a pinned commit is unreachable after fetch during hard reset.

Written for commit 9df62b7. Summary will update on new commits.

Review in cubic

* test: add failing test for #9349

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix: prevent git sync task workers from diverging (#9349)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix: bind infrahub_branch when pull creates a missing branch

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* refactor: share worktree resolution between pull and pull_to_commit

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix: pin commit SHA when pulling a read-only git repository

* fix: pin commit SHA when adding a git repository

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix: narrow git error catch in fan-out pin resolution

get_commit_value only raises ValueError (branch absent) or
InvalidGitRepositoryError (clone missing/corrupt). Catching the GitError
base class also swallowed GitCommandError, HookExecutionError, and other
unexpected git failures, masking them behind a silent fall-back to pull().
Narrow both pin-resolution sites to the exceptions actually expected.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix: pin commit SHA when merging a git repository branch

After merging into the destination branch, resolve the resulting commit and
broadcast it in RefreshGitFetch so fan-out workers check out the merge commit
instead of pulling the destination branch to whatever upstream HEAD is at that
moment, keeping the pool converged if upstream advances during fan-out.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix: pin commit SHA when creating a git repository branch

Resolve the new branch's commit and broadcast it in RefreshGitFetch so fan-out
workers check out that exact SHA rather than pulling the branch to whatever
upstream HEAD is at fetch time.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* docs: regenerate message-bus events for RefreshGitFetch commit field

Add the generated row for the new commit field and tighten its description
to a single line so the message-bus events reference matches generation.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix: pin resolved commit when pulling a read-only repository by ref

A ref-only pull (commit unset) resolved a concrete SHA during sync but
broadcast the unset commit, leaving fan-out workers to re-resolve the ref
independently and diverge. Resolve the ref once and use that SHA for both
the sync and the broadcast.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix: pin resolved commit when adding a read-only repository

Resolve the ref to a concrete SHA once and use it for both the initial sync
and the RefreshGitFetch broadcast, so fan-out workers cloning the new
read-only repository converge on that commit instead of re-resolving the ref.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* test: configure repo mocks for commit-pinned RefreshGitFetch

The add and read-only-add flows now resolve a commit and broadcast it, so the
mocked repos must return a SHA from get_commit_value (and expose ref for the
read-only flow), and the read-only sync assertion expects the pinned commit.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* duplicated line

* format

* addressing feedbacks

* get the lock upper in the chain to also encapsulate the pull

* refactor(git): drop unused _update_commit_value_if_requested helper

The helper was introduced but never wired into any call site — the
three existing producers (create_locally, pull, reset_to_commit)
already inline the `if update_commit_value:` conditional the helper
was meant to encapsulate. Remove the dead code.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(git): broadcast READONLYREPOSITORY kind from read-only add flow

add_git_repository_read_only operates on InfrahubReadOnlyRepository
but was broadcasting repository_kind=InfrahubKind.REPOSITORY, so peer
workers consuming the RefreshGitFetch notification re-instantiated the
repo as InfrahubRepository and ran the read-write pull path. Send the
matching READONLYREPOSITORY kind so consumers materialize the same
type the producer just created.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* better error message when the reset --hard fails

* testing that the repository generated is a read-only repository

* testing the sad path of hard reset related to git fetch operations

* docs(changelog): add fragment for read-only repository kind broadcast fix

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@infrahub-github-bot-app infrahub-github-bot-app Bot requested review from a team as code owners May 29, 2026 18:33
@github-actions github-actions Bot added type/documentation Improvements or additions to documentation group/backend Issue related to the backend (API Server, Git Agent) labels May 29, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 29, 2026

Merging this PR will not alter performance

✅ 12 untouched benchmarks


Comparing stable (9df62b7) with develop (db56c32)

Open in CodSpeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

group/backend Issue related to the backend (API Server, Git Agent) type/documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants