Skip to content

Fix marketplace upgrades for annotated tag refs - #1

Open
100yenadmin wants to merge 1 commit into
mainfrom
fix/marketplace-annotated-tag-revision
Open

100yenadmin wants to merge 1 commit into
mainfrom
fix/marketplace-annotated-tag-revision

Conversation

@100yenadmin

@100yenadmin 100yenadmin commented Jul 19, 2026 •

Copy link
Copy Markdown
Owner

Tracks upstream openai#34128.

Summary

  • request both the configured marketplace ref and its peeled ^{} form from git ls-remote
  • prefer the peeled commit SHA when the ref is an annotated tag
  • retain the direct SHA for branches and lightweight tags
  • add regression coverage using the exact tag-object/commit mismatch shape

Why

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 from git 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

  • New annotated-tag and direct-ref regression tests passed in codex-core-plugins.
  • just fix -p codex-core-plugins passed.
  • just fmt passed.
  • Full codex-core-plugins run: 329/330 passed. The unrelated failure was manager::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

  • Bug Fixes
    • Improved Git revision detection for remote annotated tags.
    • Ensures the correct commit revision is selected when both direct and peeled tag references are available.
    • Added validation for malformed or empty remote revision responses.

@evaos-code-review-bot

evaos-code-review-bot Bot commented Jul 19, 2026 •

Copy link
Copy Markdown

evaOS review status: completed

PR: #1 - Fix marketplace upgrades for annotated tag refs
Head: ffd488323f903fdb761c5cfe41c6140c3ad25bce
Updated: 2026-07-19T05:49:33.857Z

evaOS review completed for this PR head.

Automation note: agents should wait for this comment to reach completed, stale_head, closed_or_merged_before_review, skipped, or failed before treating evaOS review as settled for this head. provider_deferred means evaOS still intends to retry.

PR URL: #1

Review URL: #1 (review)

@coderabbitai

coderabbitai Bot commented Jul 19, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Remote Git revision lookup now queries peeled refs and parses complete git ls-remote output, preferring annotated-tag revisions. Validation rejects malformed or empty results, with tests covering peeled and direct-reference cases.

Changes

Git revision resolution

Layer / File(s) Summary
Parse and test remote revisions
codex-rs/core-plugins/src/marketplace_upgrade/git.rs
git_remote_revision queries the peeled ref and uses parse_git_ls_remote_revision to validate output, prefer peeled annotated-tag entries, and fall back to direct refs. Unit tests cover both selection paths.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: fixing marketplace upgrades for annotated tag refs.
Description check ✅ Passed The description is detailed and covers summary, rationale, testing, and an upstream issue reference.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/marketplace-annotated-tag-revision

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

@evaos-code-review-bot evaos-code-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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("^{}") {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0fb559f and ffd4883.

📒 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!

Comment on lines +20 to +26
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),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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 -S

Repository: 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 -n

Repository: 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 -n

Repository: 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:


Tie peeled revisions to the requested ref.

  • git ls-remote can return both refs/heads/main and refs/tags/main for a short ref like main.
  • parse_git_ls_remote_revision picks 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.

Comment on lines +254 to +276
#[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())
);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +49 to +50
if reference.trim().ends_with("^{}") {
return Ok(revision.to_string());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

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.

1 participant