Repository navigation
Fix marketplace upgrades for annotated tag refs - #1
100yenadmin wants to merge 1 commit into
Conversation
evaOS review status: completedPR: #1 - Fix marketplace upgrades for annotated tag refs evaOS review completed for this PR head. Automation note: agents should wait for this comment to reach PR URL: #1 Review URL: #1 (review) |
📝 WalkthroughWalkthroughRemote Git revision lookup now queries peeled refs and parses complete ChangesGit revision resolution
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Walkthrough
PR: #1 - Fix marketplace upgrades for annotated tag refs
Head: ffd488323f903fdb761c5cfe41c6140c3ad25bce into main. Review event: COMMENT.
Provider: GLM/Z.ai through ZCode (zcode-glm, zcode, model GLM-5.2).
Estimated review effort: 1/5 (~12 min)
Changed Files
| File | Status | Churn | Purpose | Risk |
|---|---|---|---|---|
codex-rs/core-plugins/src/marketplace_upgrade/git.rs |
modified | +51/-13 | Changed file | Moderate: validated P3 finding |
Review Signal
Validated inline findings: 2 (P0: 0, P1: 0, P2: 0, P3: 2).
Dropped findings before posting: 0. High-severity findings: 0.
Risk Taxonomy
- Release regression: 1
- Runtime correctness: 1
Validation and Proof
No required validation recommendation selected; rely on existing GitHub checks and human review.
Proof status: not_applicable - No required behavior proof selected for this changed surface.
Profile validation hints: Prefer correctness, security, data-loss, release, and regression findings over style-only feedback.
Profile proof expectations: Look for focused validation, rollback notes, and evidence appropriate to the changed surface.
Related Context
Related issues/PRs: openai#34128.
Suggested labels: none.
Suggested reviewers: none from current metadata.
Review Settings Preview
- Profile: assertive
- Enabled sections: Review summary (inline_review); Walkthrough (inline_review); Changed-files table (walkthrough); Effort estimate (walkthrough); Related issues/PRs (walkthrough); Review status comment (sticky_status)
- Path instructions: none
- Label suggestions: none
- Reviewer suggestions: none
- Suggestion behavior: suggestions only; labels and reviewers are not auto-applied.
- Roadmap-only settings: auto-apply labels; auto-request reviewers; required status checks
Pre-merge checklist
- Inline comments target current RIGHT-side diff lines.
- No secret-like content survived into posted inline comments.
- REQUEST_CHANGES is only used when eligible P0/P1 findings survive validation.
- Required behavior proof is present or not applicable.
- Labels and reviewers are suggestions only; the bot did not auto-apply them.
| let revision = revision.trim(); | ||
| if revision.is_empty() { | ||
| return Err("git ls-remote returned empty revision for marketplace source".to_string()); | ||
| parse_git_ls_remote_revision(&stdout) |
There was a problem hiding this comment.
P3: Revision semantics change may force a one-time re-clone for existing annotated-tag marketplaces
Before this PR, git_remote_revision returned the annotated-tag object SHA for tag refs; after the PR it returns the peeled commit SHA. Existing installs that persisted last_revision as a tag SHA (or whose stored last_revision came from clone_git_source's rev-parse HEAD, which already yielded the commit SHA) will fail the equality check at marketplace_upgrade.rs:220 and trigger a one-time re-clone on the next upgrade. This is not data loss and the new behavior is correct going forward, but it is a behavioral change worth a release/migration note so it is not mistaken for a regression.
Category: Release regression
Why this matters: Cache-invalidation semantics change for a release-adjacent path; a surprise re-clone on upgrade could look like a regression to operators without context.
| return Err("git ls-remote returned empty revision for marketplace source".to_string()); | ||
| } | ||
| first_revision.get_or_insert_with(|| revision.to_string()); | ||
| if reference.trim().ends_with("^{}") { |
There was a problem hiding this comment.
P3: Parser matches any ^{} line without verifying it corresponds to the requested ref
parse_git_ls_remote_revision returns the first line whose reference ends with "^{}". With the two explicit refspec arguments (ref_name and ref_name^{}) this is bounded and correct in practice, but the parser does not assert that the peeled line's base reference matches the requested ref_name. If git ls-remote ever returns additional peeled refs (e.g., via future refspec changes or glob-like ref names), the parser would silently pick an unrelated peeled commit. Consider anchoring the match on the expected base ref (e.g., reference == peeled_ref_name or reference starts with ref_name) so the assertion is explicit. Low impact given current callers.
Category: Runtime correctness
Why this matters: Defensive correctness: the parser's invariant (the ^{} line corresponds to the requested ref) is currently implicit and enforced only by git's refspec behavior, not by the code.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@codex-rs/core-plugins/src/marketplace_upgrade/git.rs`:
- Around line 254-276: Add an ambiguous-reference regression test alongside
remote_revision_prefers_peeled_annotated_tag and
remote_revision_uses_direct_ref_when_no_peeled_ref_exists, using output
containing refs/heads/main, refs/tags/main, and refs/tags/main^{}. Assert the
configured branch remains selected, or that parse_git_ls_remote_revision rejects
the ambiguous result, according to the intended lookup behavior.
- Around line 20-26: Update the git revision lookup around
run_git_command_with_timeout and parse_git_ls_remote_revision so direct and
peeled ls-remote entries are matched to the requested ref rather than selecting
the first peeled result. Reject ambiguous branch/tag collisions or require fully
qualified refs, preserving correct resolution for unambiguous refs, and add a
regression test covering a short ref shared by a branch and tag.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 273ffc21-4c2f-46a3-9721-1fb1673ae3a8
📒 Files selected for processing (1)
codex-rs/core-plugins/src/marketplace_upgrade/git.rs
📜 Review details
⏰ Context from checks skipped due to timeout. (10)
- GitHub Check: rust-ci / Argument comment lint - Linux
- GitHub Check: rust-ci / cargo shear
- GitHub Check: rust-ci / Format / etc
- GitHub Check: Bazel / Bazel clippy on ubuntu-24.04 for x86_64-unknown-linux-gnu
- GitHub Check: Bazel / Bazel test on ubuntu-24.04 for x86_64-unknown-linux-gnu
- GitHub Check: Bazel / Bazel test on ubuntu-24.04 for x86_64-unknown-linux-musl
- GitHub Check: Bazel / Verify release build on ubuntu-24.04 for x86_64-unknown-linux-gnu
- GitHub Check: Bazel / Verify release build on macos-15-xlarge for aarch64-apple-darwin
- GitHub Check: repo-checks / build-test
- GitHub Check: cargo-deny / cargo-deny
🔇 Additional comments (1)
codex-rs/core-plugins/src/marketplace_upgrade/git.rs (1)
242-242: LGTM!
| let peeled_ref_name = format!("{ref_name}^{{}}"); | ||
| let output = run_git_command_with_timeout( | ||
| git_command().arg("ls-remote").arg(source).arg(ref_name), | ||
| git_command() | ||
| .arg("ls-remote") | ||
| .arg(source) | ||
| .arg(ref_name) | ||
| .arg(peeled_ref_name), |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect the target file and any nearby tests.
git ls-files codex-rs/core-plugins/src/marketplace_upgrade
echo '--- git.rs ---'
cat -n codex-rs/core-plugins/src/marketplace_upgrade/git.rs | sed -n '1,220p'
echo '--- tests search ---'
rg -n "git_remote_revision|parse_git_ls_remote_revision|ls-remote|peeled|\\^\\{\\}" codex-rs/core-plugins/src/marketplace_upgrade -SRepository: 100yenadmin/codex
Length of output: 10954
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "ping"Repository: 100yenadmin/codex
Length of output: 160
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Read the parser tests around the referenced area.
sed -n '230,290p' codex-rs/core-plugins/src/marketplace_upgrade/git.rs | cat -nRepository: 100yenadmin/codex
Length of output: 2495
🏁 Script executed:
#!/bin/bash
set -euo pipefail
sed -n '230,300p' codex-rs/core-plugins/src/marketplace_upgrade/git.rs | cat -nRepository: 100yenadmin/codex
Length of output: 2820
🌐 Web query:
git ls-remote pattern matching refs glob exact tail ^{} peeled annotated tag documentation
💡 Result:
In the git ls-remote command, patterns are used to filter the list of remote references [1][2]. The command's documentation provides the following technical details regarding pattern matching, reference output, and peeled tags [1][3][4]: Pattern Matching When patterns are specified, git ls-remote displays only references that match one or more of the given patterns [1][5]. Each pattern is interpreted as a glob (as defined in gitglossary(7)) [1][6]. Matching is performed against the tail of a reference, starting from the beginning of the ref or after a slash separator [1][2][5]. For example: - A full name like refs/heads/foo will match the pattern foo [1][5]. - The pattern bar will match refs/heads/bar but will not match refs/heads/foobar [1][3]. Peeled Tags and ^{} By default, unless the --refs flag is used, git ls-remote shows peeled tags [1][7]. When an annotated tag is encountered, the command displays two lines: 1. One line showing the refname of the tag itself [4][8]. 2. A second line showing the same refname followed by ^{} [4][7]. The object ID on this line represents the target object (e.g., the commit) that the annotated tag points to [4][7][8]. The --refs option can be used to suppress the output of these peeled tags as well as other pseudorefs like HEAD [1][3][9]. Top Results: [1][5][4][7]
Citations:
- 1: https://git-scm.com/docs/git-ls-remote.html
- 2: https://git-scm.com/docs/git-ls-remote
- 3: https://code.googlesource.com/git/+/master/Documentation/git-ls-remote.adoc
- 4: https://git.github.io/htmldocs/git-ls-remote.html
- 5: https://stackoverflow.com/questions/52662337/what-is-the-definition-of-pattern-for-git-ls-remote
- 6: https://www.kernel.org/pub/software/scm/git/docs/git-ls-remote.html
- 7: https://stackoverflow.com/questions/70436768/what-is-the-mean-of-in-git-ls-remote
- 8: https://code.googlesource.com/git/+/HEAD/Documentation/git-ls-remote.adoc
- 9: https://github.com/git/git/blob/maint/builtin/ls-remote.c
Tie peeled revisions to the requested ref.
git ls-remotecan return bothrefs/heads/mainandrefs/tags/mainfor a short ref likemain.parse_git_ls_remote_revisionpicks the first peeled entry without associating it with the requested ref, so a branch/tag collision can return the tag commit instead of the branch commit.
Track the direct/peeled pair by ref, reject ambiguous matches, or require fully qualified refs before querying. Add a branch/tag-collision regression test.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@codex-rs/core-plugins/src/marketplace_upgrade/git.rs` around lines 20 - 26,
Update the git revision lookup around run_git_command_with_timeout and
parse_git_ls_remote_revision so direct and peeled ls-remote entries are matched
to the requested ref rather than selecting the first peeled result. Reject
ambiguous branch/tag collisions or require fully qualified refs, preserving
correct resolution for unambiguous refs, and add a regression test covering a
short ref shared by a branch and tag.
| #[test] | ||
| fn remote_revision_prefers_peeled_annotated_tag() { | ||
| let output = concat!( | ||
| "0c7a0df5d351306392958f37ba80d590070a318d\trefs/tags/electric/v1.6.10-electric.2\n", | ||
| "e690cabf19dea108fced6ee1a7ef17e9e623ec54\trefs/tags/electric/v1.6.10-electric.2^{}\n", | ||
| ); | ||
|
|
||
| assert_eq!( | ||
| parse_git_ls_remote_revision(output), | ||
| Ok("e690cabf19dea108fced6ee1a7ef17e9e623ec54".to_string()) | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn remote_revision_uses_direct_ref_when_no_peeled_ref_exists() { | ||
| let output = "e690cabf19dea108fced6ee1a7ef17e9e623ec54\trefs/heads/main\n"; | ||
|
|
||
| assert_eq!( | ||
| parse_git_ls_remote_revision(output), | ||
| Ok("e690cabf19dea108fced6ee1a7ef17e9e623ec54".to_string()) | ||
| ); | ||
| } | ||
|
|
There was a problem hiding this comment.
🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win
Add an ambiguous-ref regression test.
These tests cover only unambiguous output. Add a case containing refs/heads/main, refs/tags/main, and refs/tags/main^{}; assert that the configured branch remains selected or that the lookup rejects the ambiguity.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@codex-rs/core-plugins/src/marketplace_upgrade/git.rs` around lines 254 - 276,
Add an ambiguous-reference regression test alongside
remote_revision_prefers_peeled_annotated_tag and
remote_revision_uses_direct_ref_when_no_peeled_ref_exists, using output
containing refs/heads/main, refs/tags/main, and refs/tags/main^{}. Assert the
configured branch remains selected, or that parse_git_ls_remote_revision rejects
the ambiguous result, according to the intended lookup behavior.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ffd488323f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if reference.trim().ends_with("^{}") { | ||
| return Ok(revision.to_string()); |
There was a problem hiding this comment.
Constrain peeled matches to the checked-out ref
When the requested name also matches an annotated tag that the checkout does not select—for example no configured ref (HEAD) with a refs/tags/HEAD, or a default branch main plus refs/tags/main—the added peeled pattern makes ls-remote emit the tag's ^{} line, and this condition returns that SHA even though clone_git_source records the branch commit. Git's ls-remote docs note that patterns can match refs by tail and annotated tags add <ref>^{} lines, so this can reintroduce the repeated-upgrade/no-op miss for those repositories unless the peeled line is tied to the actual direct ref being used.
Useful? React with 👍 / 👎.
Tracks upstream openai#34128.
Summary
^{}form fromgit ls-remoteWhy
The marketplace activation path stores
git rev-parse HEAD, which resolves an annotated tag to its commit. The remote no-op check previously used the first result fromgit ls-remote <source> <tag>, which is the tag object instead. Since those SHAs never match, every startup or refresh can clone and reactivate the same marketplace again.This became especially costly when multiple app-server processes refreshed the same large marketplace: staging and backup clones accumulated until the disk filled.
Testing
codex-core-plugins.just fix -p codex-core-pluginspassed.just fmtpassed.codex-core-pluginsrun: 329/330 passed. The unrelated failure wasmanager::tests::skills_service_reuses_skills_parsed_during_plugin_load, whose expected skill-description list differed from the machine's installed global skills.Summary by CodeRabbit