Skip to content

fix(xtest): refresh otdf-sdk-mgr bare-repo branches; clean up interrupted js installs - #667

Merged
dmihalcik-virtru merged 2 commits into
mainfrom
DSPX-4372-s2-sdkmgr-fixes
Oct 23, 2026
Merged

dmihalcik-virtru merged 2 commits into
mainfrom
DSPX-4372-s2-sdkmgr-fixes

Conversation

@dmihalcik-virtru

@dmihalcik-virtru dmihalcik-virtru commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Part 2a of the DSPX-4372-t1 plan, split out of #626: fixes the benchmark needs, which every otdf-sdk-mgr install benefits from. Based on main.

What it does

  • Bare repos refresh their branches. git clone --bare records no fetch refspec, so the fetch --all --tags before every checkout refreshed tags only. Every branch stayed where the first clone found it, and install tip main or --platform main built that stale commit. checkout.BARE_REFRESH now fetches origin's branches into refs/remotes/origin/* with --prune, for the SDK and platform bare repos alike, and checkout.upstream_ref maps a branch name onto them. Fetching into the bare repo's own refs/heads/* instead would move branches that other worktrees have checked out, leaving their HEAD ahead of their files, and would fail for good once upstream replaced a branch foo with foo/bar.
  • Worktrees are detached and reset to the refreshed ref. A branch origin no longer has is refused rather than built from the clone's stale copy, and HEAD means origin's default branch as of the clone; a platform HEAD worktree used to reset to itself.
  • Go source rebuilds work a second time. checkout_go_from_platform reset an existing worktree to a FETCH_HEAD fetched into the bare repo, which no worktree can see, so every rebuild after the first failed with pathspec 'FETCH_HEAD' did not match. It now resets to the refreshed ref, like the SDK and platform paths.
  • install tip reports checkout failures as errors. A refused branch, or a failed git command with git's stderr, now prints Error: … and exits 1 for go, js and java, as the platform path already did, instead of a traceback.
  • An interrupted js install leaves nothing behind. fix(xtest): test the real latest web-sdk, and gate js PQ/T hybrids explicitly #663 already removes a partial dist/ when npm fails. A Ctrl-C mid-install still left a directory holding only cli.sh, which install_release then skipped as installed from then on. Both js install paths now remove it unless the install finished.
  • AGENTS.md claimed the bare clone mapped refs/heads/*, which is what hid the first bug. It and the code comments also said git pull fails in a worktree; it merges origin's default branch into whatever is checked out.

Validation

  • uv run pytest in otdf-sdk-mgr: 207 passed, and 321 at the top of this track (feat(xtest): export benchmark manifest pins from otdf-local env #642). ruff, ruff format and pyright are clean.
  • test_checkout.py runs real git against a local origin. Every shared behaviour is parametrized over the SDK, go and platform entry points: new and existing worktrees follow their branch, HEAD (including beside a tag named main), a deleted branch is refused, tags and SHAs are checked out and then reused, and a force-pushed refs/pull/N/head is followed. This replaces the stubbed command-string test for platform PR refs. SDK-only tests guard other worktrees, force pushes and x → x/y renames; platform-only tests cover the helper-scripts worktree. A CliRunner test covers the install tip error path.
  • Mutation-checked: symbolic-ref --short, treating every non-origin name as a deleted branch, dropping go's explicit PR-ref fetch or its +, swallowing go's refusal, and dropping the install tip catch each fail a test.
  • Two new tests interrupt each js install path.
  • isolated_git keeps those tests off the developer's git config, any inherited GIT_DIR, and the network (GIT_ALLOW_PROTOCOL=file).

Follow-ups

Older problems found while reviewing this PR are fixed in a stack of drafts based on it: #673 (don't reset a directory that isn't a worktree) → #674 (branch names vs versions) → #675 (tags moved upstream) → #676 (checkout go / --all).

Stack (DSPX-4372-t1 plan)

Two parallel tracks from main; they share no imports and meet in stage 5.

Part PR Base
2a: bare-repo and js install fixes #667 (this PR) main
2b: manifest contract #668 2a
2c: install benchmark #626 2b
2d: otdf-local env exports #642 2c
3a: arms as a tuple #669 main
3b: two to four arms #658 3a
3c: pytest reads the manifest #670 3b
4: candidate-to-candidate conclusions #659 3c
5, 6: CI and report #660, #661 not yet moved onto these stacks

Summary by CodeRabbit

  • Bug Fixes

    • SDK and platform worktrees now follow updated branches and pull request refs, including after force-pushes. Missing branches produce a clear error instead of a traceback.
    • Interrupted JavaScript installations no longer leave partial distribution files behind.
  • Documentation

    • Updated platform installation guidance for branch refreshes, detached worktrees, and pull request refs.

@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9048dc79-337e-468a-9999-5fb36f339df5
📥 Commits

Reviewing files that changed from the base of the PR and between 96d1425 and 4fe63aa.

📒 Files selected for processing: 1
  • otdf-sdk-mgr/src/otdf_sdk_mgr/installers.py
+--------------------+
| Expecto bugtronum! |
+--------------------+
  \
   \     /)/)
        ( '')
        /  |
      o(___)

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f7409a3c-1bae-444b-a5a2-eada0c4a069c
📥 Commits

Reviewing files that changed from the base of the PR and between 77e2f33 and 96d1425.

📒 Files selected for processing: 9
  • otdf-sdk-mgr/AGENTS.md
  • otdf-sdk-mgr/src/otdf_sdk_mgr/checkout.py
  • otdf-sdk-mgr/src/otdf_sdk_mgr/cli_install.py
  • otdf-sdk-mgr/src/otdf_sdk_mgr/installers.py
  • otdf-sdk-mgr/src/otdf_sdk_mgr/platform_installer.py
  • otdf-sdk-mgr/tests/conftest.py
  • otdf-sdk-mgr/tests/test_checkout.py
  • otdf-sdk-mgr/tests/test_installers.py
  • otdf-sdk-mgr/tests/test_platform_installer.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

SDK and platform checkout paths now refresh bare-repository branch refs and use resolved targets for detached worktrees. The tip command reports checkout failures. Both JavaScript installation paths remove incomplete distribution directories when an install is interrupted.

Changes: Bare Repository Checkout

Layer / File(s) Summary
Refresh bare refs and resolve checkout targets
otdf-sdk-mgr/src/otdf_sdk_mgr/checkout.py, otdf-sdk-mgr/src/otdf_sdk_mgr/platform_installer.py
SDK and platform paths refresh origin branches and tags. Checkout targets resolve branch names to origin tracking refs, with explicit handling for HEAD and refs/... inputs.
Use resolved targets for worktrees
otdf-sdk-mgr/src/otdf_sdk_mgr/checkout.py, otdf-sdk-mgr/src/otdf_sdk_mgr/platform_installer.py, otdf-sdk-mgr/tests/conftest.py, otdf-sdk-mgr/tests/test_checkout.py, otdf-sdk-mgr/tests/test_platform_installer.py, otdf-sdk-mgr/AGENTS.md
New worktrees are detached at resolved targets. Existing mutable worktrees reset to those targets. Local Git tests cover branch updates, immutable refs, PR refs, worktree isolation, and helper scripts. The guidance describes the updated fetch and reset behavior.
Report checkout failures
otdf-sdk-mgr/src/otdf_sdk_mgr/cli_install.py, otdf-sdk-mgr/tests/test_checkout.py
tip catches checkout and Git command errors, reports the error, and exits with status 1. A test checks the missing-branch case.

Interrupted JavaScript Install Cleanup

Layer / File(s) Summary
Remove incomplete distributions
otdf-sdk-mgr/src/otdf_sdk_mgr/installers.py, otdf-sdk-mgr/tests/test_installers.py
Both JavaScript installation paths remove the distribution directory when installation does not complete. Tests verify cleanup when an interrupt occurs.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant SDKCheckout
  participant GitBareRepo
  participant upstream_ref
  participant GitWorktree
  SDKCheckout->>GitBareRepo: Refresh origin branches and tags
  SDKCheckout->>upstream_ref: Resolve requested ref
  upstream_ref-->>SDKCheckout: Return checkout target
  SDKCheckout->>GitWorktree: Add detached worktree or reset to target
Loading

Suggested reviewers: sujankota

Merge Risk: ⚪ Minimal · up to 96d14

The reviewed checkout and install changes have no identified merge-blocking issue. Normal test checks remain appropriate before merging.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 58.54% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 41 functions across 8 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly summarizes the two main changes: refreshing bare-repository branches and cleaning up interrupted JavaScript installs. It is concise, specific, and directly related to the pull reques…
Linked Issues check Passed The PR meets the coding requirements in issue #667. checkout.py refreshes bare repositories into pruned refs/remotes/origin/*, resolves upstream refs, refuses deleted branches, and uses detached w…
Out of Scope Changes check Passed The changes stay within issue #667. Source changes implement bare-repository refresh, checkout error handling, repeated Go rebuilds, and JavaScript cleanup. The tests, Git isolation fixture, comments,…
Full details: Title check

Explanation

The title clearly summarizes the two main changes: refreshing bare-repository branches and cleaning up interrupted JavaScript installs. It is concise, specific, and directly related to the pull request.

Full details: Linked Issues check

Explanation

The PR meets the coding requirements in issue #667. checkout.py refreshes bare repositories into pruned refs/remotes/origin/*, resolves upstream refs, refuses deleted branches, and uses detached worktrees with hard resets. The Go path uses the refreshed target. cli_install.py converts checkout failures into Error: output with exit status 1. installers.py removes incomplete JavaScript install directories in finally blocks, including interruption cases. The PR also updates AGENTS.md and adds focused integration and interruption tests for these behaviors.

Full details: Out of Scope Changes check

Explanation

The changes stay within issue #667. Source changes implement bare-repository refresh, checkout error handling, repeated Go rebuilds, and JavaScript cleanup. The tests, Git isolation fixture, comments, and AGENTS.md corrections support those objectives. No unrelated benchmark, manifest, environment, multi-arm, reporting, or CI implementation is present.

Full details: Docstring Coverage

Explanation

Docstring coverage is 58.54% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 41 functions across 8 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks the branch refs bright,
Then sets each worktree right.
If installs stop before the end,
The leftover files will not pretend.
The checkout path reports its way,
And leaves clean folders at the day.

Comment @coderabbitai help to get the list of available commands.

…s installs

`git clone --bare` records no fetch refspec, so the `fetch --all --tags`
run on every later checkout refreshed tags only. Every branch stayed at
clone time, and a worktree added for it -- `install tip`, or
`--platform main` -- built that stale commit.

checkout.BARE_REFRESH now fetches origin's branches into
refs/remotes/origin/* with --prune, for the SDK and platform bare repos
alike, and runs after a fresh clone too. checkout.upstream_ref maps a
branch name onto those refs. A branch origin no longer has is refused
with a CheckoutError rather than built from the clone's copy, and `HEAD`
means origin's default branch as of the clone. Fetching into the bare
repo's own refs/heads/* instead would move branches that other worktrees
have checked out, and would fail for good once upstream replaced a
branch `foo` with `foo/bar`.

Worktrees are added --detach and reset to the refreshed ref. That also
fixes go source rebuilds: checkout_go_from_platform reset an existing
worktree to a FETCH_HEAD fetched into the bare repo, and FETCH_HEAD is
per worktree, so every rebuild after the first failed with "pathspec
'FETCH_HEAD' did not match".

`install tip` for go, js and java now reports a refused branch, or a
failed git command with git's stderr, as an error rather than a
traceback, as it already did for the platform.

The tests run real git against a local origin, through the SDK, go and
platform entry points alike: branches, HEAD, tags, SHAs and force-pushed
PR refs. isolated_git keeps them off the developer's config, any
inherited GIT_DIR, and the network. AGENTS.md claimed the bare clone
mapped refs/heads/*, which is what hid this. It and the code comments
also said `git pull` fails in a worktree; it fast-forwards or merges
origin's default branch into whatever is checked out.

install_js_release already removes a partial dist when npm fails (#663).
It now does the same when the install is interrupted: install_release
skips any dist that exists, so a Ctrl-C mid-install left a directory
with no CLI that every later install accepted as installed.

Part 2a of the DSPX-4372-t1 plan.

Signed-off-by: Dave Mihalcik <dmihalcik@virtru.com>
@dmihalcik-virtru
dmihalcik-virtru merged commit efc0ec2 into main Oct 23, 2026
5 checks passed
@dmihalcik-virtru
dmihalcik-virtru deleted the DSPX-4372-s2-sdkmgr-fixes branch October 23, 2026 13:52
@sonarqubecloud

Copy link
Copy Markdown

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants