Repository navigation
Conversation
PR Summary by QodoAdd push-signed CLI command to replay local commits on GitHub
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
Code Review by Qodo
1. Removing an executable bit is silently lost
|
| content, err := readFileAtCommit(repoDir, commitSHA, change.Path) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("reading %s at %s: %w", change.Path, commitSHA[:12], err) | ||
| } | ||
| mode := change.Mode | ||
| if mode == "" { | ||
| mode = "100644" | ||
| } | ||
| files = append(files, forge.TreeFile{ | ||
| Path: change.Path, | ||
| Content: content, | ||
| Mode: mode, | ||
| }) |
There was a problem hiding this comment.
8. Submodule changes cannot be replayed 🔗 Cross-repo conflict ≡ Correctness
buildTreeFiles reads every non-deletion as file content, and the GitHub REST writer submits it as a blob even when its mode is 160000. When an agent commit updates a submodule, the replay cannot produce the commit-type tree entry with the submodule SHA that the agents signed-push helper represents.
Agent Prompt
## Issue description
Gitlink changes are treated as blob files, although submodule tree entries require a commit-type entry and the gitlink SHA.
## Fix Focus Areas
- internal/cli/pushsigned.go[173-195]
- internal/cli/pushsigned.go[315-324]
- internal/forge/github/github.go[1763-1782]
- /cross_repos/agents/scripts/lib/github-signed-push.lib.sh[124-143]
## Recommended Fix
Detect mode `160000` before reading file content, read the gitlink SHA from the local tree, and extend the forge write path to create a commit-type tree entry with that SHA using a signing-capable credential. Alternatively, reject submodule commits before any remote writes. Test the result against the agents publisher's submodule representation.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
1fef6c5 to
6219783
Compare
waynesun09
left a comment
There was a problem hiding this comment.
Review findings (9 inline comments: 1 HIGH, 8 MEDIUM). Main issue: the local base is never matched against the remote base, and the final tree is never compared with local HEAD, so a moved or diverged base gives a wrong tree while the command still exits 0.
| if err != nil { | ||
| return fmt.Errorf("listing local commits: %w", err) | ||
| } | ||
| if len(commits) == 0 { |
There was a problem hiding this comment.
MEDIUM: Remote branch is created before any commit is validated, so a later failure leaves a stray branch and a partial push; zero commits is a hard error
Lines 129-138 create the remote branch before any commit's changes are listed or validated. A later submodule rejection (line 184), a git show failure or an API error leaves a new branch that holds some of the commits. Lines 119-121 also return an error when base..HEAD is empty, which fails a post-script that legitimately produced nothing to push.
Suggestion: List and build the tree files for every commit first, then create the branch only when at least one non-empty commit exists. Treat 'nothing to push' as success, or document the non-zero exit.
| @@ -0,0 +1,64 @@ | |||
| --- | |||
There was a problem hiding this comment.
MEDIUM: New CLI page is missing from the VitePress sidebar and the CLI internals command tree
docs/.vitepress/config.ts (lines 227-239) lists each /cli/ page explicitly, and /cli/push-signed is not among them, so the new page cannot be reached from the site navigation. docs/guides/dev/cli-internals.md has the full command tree, and push-signed is missing there too. The qodo thread on root.go asked for a page, and this PR added one. This finding is about the navigation entries, which are still missing.
Suggestion: Add { text: "fullsend push-signed", link: "/cli/push-signed" } to the /cli/ sidebar, and add push-signed to the command tree in cli-internals.md.
| assert.True(t, hasSideTxt, "merge commit changes should include side.txt") | ||
| } | ||
|
|
||
| func TestPushSignedCommits_rootCommit(t *testing.T) { |
There was a problem hiding this comment.
MEDIUM: Tests do not exercise the root-commit path or the main failure modes, and there is no real-GitHub validation
Despite its name, TestPushSignedCommits_rootCommit pushes an ordinary child of main, so a root commit inside base..HEAD (the --root path) is never tested. Also untested: the --branch and --base required-flag checks (only --repo is covered), error propagation from GetBranchRef, CreateBranchFromSHA and CommitFilesToBranch, and a moved remote base. FakeClient always returns changed=true and does not model the GraphQL/REST split. Issue #9062's validation criterion (a re-dispatch on a required_signatures repo that produces a PR without GH013) has no recorded run.
Suggestion: Add a real orphan or root commit test, tests for required flags and error propagation, and an httptest-based LiveClient test asserting a single createCommitOnBranch mutation. Run against a scratch repo with a required_signatures ruleset and record the commit verification output in the PR.
…commits Add `fullsend push-signed` subcommand that pushes local git commits to a remote GitHub branch via the GraphQL `createCommitOnBranch` mutation, producing server-side verified signatures. This enables post-code.sh (in fullsend-ai/agents) to create signed commits that comply with repository rulesets requiring verified signatures (GH013). The command reads local commits between --base and HEAD, creates the remote branch if needed, then replays each commit individually through the forge.Client.CommitFilesToBranch method, preserving commit messages and handling additions, modifications, deletions, renames, and copies. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Anu Oguntayo <aoguntay@redhat.com>
6219783 to
57288d6
Compare
waynesun09
left a comment
There was a problem hiding this comment.
Review-only pass at 57288d6: 1 HIGH and 5 MEDIUM findings, posted inline. The HIGH one is a failing test (TestPushSignedCommits_mergeCommit) with no Go test or lint job in CI to catch it.
| assert.True(t, files[0].Delete) | ||
| } | ||
|
|
||
| func TestPushSignedCommits_mergeCommit(t *testing.T) { |
There was a problem hiding this comment.
HIGH: TestPushSignedCommits_mergeCommit fails on the PR head, and no Go test or lint job ran in CI
I ran go test ./internal/cli/ -run PushSigned -count=1 at 57288d6 and it fails at pushsigned_test.go:476 with local base main (77c9749dc532) does not match remote base (611b72039e8a); pull or rebase before pushing. The test commits "main commit" onto local main at lines 461-463, but the fake remote main is still baseSHA (lines 466-470). The new base check at pushsigned.go:147 correctly refuses.
The expectations are also wrong. git log --first-parent main..HEAD leaves out commits already on main, so require.Len(..., 2, "expect main commit + merge commit") at line 481 could not pass even if the bases matched.
gh pr checks 9281 lists only DCO and dispatch jobs, with no Go test, lint or coverage job, so the PR's tests and lint checkboxes have nothing in CI behind them.
Suggestion: Make the side-branch commit the only change the merge brings in. Either keep local main at baseSHA and make "main commit" on feature, or set the fake remote main to the new local main SHA and expect only the merge commit, with its exact change list. Then run make go-test and make lint (or hack/ci-local, coverage included) and paste the output in the PR.
| if change.Mode == "160000" { | ||
| return nil, fmt.Errorf("submodule change at %s cannot be replayed via the GraphQL API", change.Path) | ||
| } | ||
| if change.Mode != "" && change.Mode != "100644" { |
There was a problem hiding this comment.
MEDIUM: Non-100644 modes are always rejected, but the stated reason is wrong for the App installation tokens post-code.sh uses
buildTreeFiles rejects every file whose new mode is not 100644, so an executable script (100755) or a symlink (120000) aborts the whole push. The error message and the Limitations section of docs/cli/push-signed.md say non-default modes go through REST, "which does not produce signed commits with user tokens". That is true only for user tokens. internal/forge/github/commit_graphql.go:17 says "GitHub signs Git Data REST commits only for App installation tokens", and the target caller (agent post-scripts) pushes with an installation token.
An agent commit that adds or chmod +xes a script is common, and today it fails even though a signed path exists for that token type. The earlier qodo thread said user tokens produce unsigned commits; the PR fixed that by rejecting the mode for every token, App tokens included.
Suggestion: Pass the real mode through so CommitFilesToBranch takes the Git Data path that GitHub signs for installation tokens. Reject only when the token is a user token, or put the fallback behind an explicit opt-in flag that warns loudly. In the docs, change "rejected" to "requires an App installation token".
| @@ -0,0 +1,405 @@ | |||
| package cli | |||
There was a problem hiding this comment.
MEDIUM: fullsend-ai/agents already ships a signed-push path; this PR duplicates it with different behaviour, and nothing calls the new command
fullsend-ai/agents already has forge_push_branch with GITHUB_SIGNED_COMMITS in scripts/lib/github-signed-push.lib.sh, used by post-code.sh, post-fix.sh, pre-code.sh and pre-fix.sh. It rebuilds commits through the Git Data API with the installation token. It supports existing branches and --force-with-lease (lines 244-277). It strips any Authored-by line the agent wrote and then adds the trailer with git interpret-trailers --if-exists doNothing (lines 163-175). The fix-history checks depend on that trailer format.
This PR adds a second implementation with weaker behaviour: modes are rejected, existing branches are refused, the local ref is not updated, and trailers are not stripped. No agents change wires it in, while #9062's triage named post-code.sh in agents as the fix target.
Suggestion: Before merging, ask the #9062 owners whether turning on GITHUB_SIGNED_COMMITS, or making it the default for repos with a signature ruleset, already fixes the reported GH013. If a Go CLI is still wanted, match the agents behaviour (modes, existing branches, moving the local ref, trailer stripping) and link the agents PR that will call it.
| } | ||
| } | ||
|
|
||
| fmt.Fprintf(os.Stderr, "push-signed: done\n") |
There was a problem hiding this comment.
MEDIUM: The local branch stays on the unsigned commits after the push, so local and remote history diverge
After the loop the remote branch holds new GitHub-created commits with different SHAs. Local HEAD and any upstream tracking still point at the unsigned originals, and the command just prints done. A later git push, git rebase origin/<branch>, PR-head comparison or a second push-signed run in the same job then sees diverged history. The agents implementation fetches the branch and resets the local branch onto the created commits for this reason. The docs say nothing about it.
Suggestion: Collect the commit OIDs that createCommitOnBranch returns (or fetch the branch at the end) and update the local branch ref. At minimum, document that callers must run git fetch && git reset --hard origin/<branch> afterwards.
| if err != nil { | ||
| return fmt.Errorf("getting remote base branch %q ref: %w", base, err) | ||
| } | ||
| if localBaseSHA != remotBaseSHA { |
There was a problem hiding this comment.
MEDIUM: The new base check compares branch tips but never checks that base is an ancestor of HEAD
The fix for the earlier base-mismatch thread checks only localBaseSHA == remoteBaseSHA. It never checks that base is an ancestor of HEAD (git merge-base --is-ancestor <base> HEAD). Suppose the working branch was cut from an older main and local main was then fast-forwarded to match the remote. The tip check passes, base..HEAD lists the feature commits, and each replay sends whole-file content onto the newer remote base. That overwrites upstream edits to the touched paths and publishes a tree that never existed locally, and the command still exits 0.
The earlier thread (the unresolved HIGH comment on the base check) also asked for a final remote-tree vs HEAD^{tree} comparison, and that comparison is still missing, so nothing catches this case.
Suggestion: Add git merge-base --is-ancestor <base> HEAD and fail with a clear message when it is false. Add a test where the feature branch is cut from an older base.
| return message | ||
| } | ||
| message = strings.TrimRight(message, "\n") | ||
| return message + "\n\nAuthored-by: " + author |
There was a problem hiding this comment.
MEDIUM: The Authored-by trailer starts a new paragraph, and agent-written Authored-by lines are kept
The doc comment says the trailer is placed "in the last paragraph per git trailer conventions", but the code always adds \n\n, which starts a new paragraph. For a message that already ends in a trailer block (Co-authored-by:, Signed-off-by:), git interpret-trailers and GitHub now see only Authored-by as a trailer, and GitHub stops showing the co-authors.
The duplicate check at line 400 is a plain substring match, so (a) quoted text in the body suppresses the trailer and (b) an agent-written Authored-by: line for a different identity is kept next to the real one. The agents publisher strips existing Authored-by lines for this reason, because downstream fix-history checks (.github/scripts/count-fix-commits.jq) trust that trailer.
Suggestion: Remove any existing Authored-by: lines, then add the trailer to the existing trailer block: a single \n when the last paragraph is all trailers, otherwise \n\n. Keep it in the last paragraph so count-fix-commits.jq still matches, and add tests for a message with an existing trailer block and one with a spoofed Authored-by line.
Summary
Add
fullsend push-signedsubcommand that pushes local git commits to a remote GitHub branch via the GraphQLcreateCommitOnBranchmutation, producing server-side verified signatures. This enables post-code.sh (in fullsend-ai/agents) to create signed commits that comply with repository rulesets requiring verified signatures (GH013).The command reads local commits between --base and HEAD, creates the remote branch if needed, then replays each commit individually through the forge.Client.CommitFilesToBranch method, preserving commit messages and handling additions, modifications, deletions, renames, and copies.
Related Issue
#9062
Changes
between --base and HEAD, creates the remote branch if needed, then replays each commit individually through forge.Client.CommitFilesToBranch, handling additions, modifications, deletions, renames, and
copies.
validation. Uses a forge.FakeClient for integration-style tests.
Testing
make lintpasses (stage changes first, then run)Checklist
!for breaking changes)